WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
171390
B3::FoldPathConstants does not consider the fall through case for Switch
https://bugs.webkit.org/show_bug.cgi?id=171390
Summary
B3::FoldPathConstants does not consider the fall through case for Switch
Saam Barati
Reported
2017-04-27 13:19:37 PDT
Say you have a B3 switch that's the moral equivalent of this C this: ``` switch (v) { 1: doSomething; break; 2: doSomethingElse; break; 3: default: BB that uses v } ``` we'll rewrite the BB to replace "v" with the number 3. This is obviously wrong. Note that the phase already handles IR for: ``` switch (v) { 1: 2: BB; break; default: break; } ``` We are smart enough to not replace "v" inside BB with either "1" or "2".
Attachments
patch
(7.80 KB, patch)
2017-04-27 14:16 PDT
,
Saam Barati
fpizlo
: review+
Details
Formatted Diff
Diff
patch for landing
(7.84 KB, patch)
2017-04-27 14:33 PDT
,
Saam Barati
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Filip Pizlo
Comment 1
2017-04-27 14:14:56 PDT
Wow, that's glorious.
Saam Barati
Comment 2
2017-04-27 14:16:36 PDT
Created
attachment 308444
[details]
patch
Saam Barati
Comment 3
2017-04-27 14:18:11 PDT
Comment on
attachment 308444
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=308444&action=review
> Source/JavaScriptCore/b3/B3FoldPathConstants.cpp:109 > + if (switchValue->hasFallThrough()) > + targetUses.add(switchValue->fallThrough(block), 0).iterator->value++;
If we wanted to, we could be a bit niftier here: We could check if any target is zero, and if so, we could check if targetUses(fall through) === 0, and if both are true, we could say that in the default block, the switch value is nonzero (obviously only if default block has a single predecessor). I'm not sure if it's worth bothering though.
Build Bot
Comment 4
2017-04-27 14:18:40 PDT
Attachment 308444
[details]
did not pass style-queue: ERROR: Source/JavaScriptCore/b3/testb3.cpp:10784: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10785: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10786: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10786: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10787: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10787: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10788: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10788: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10789: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10789: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] Total errors found: 10 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Filip Pizlo
Comment 5
2017-04-27 14:20:33 PDT
Comment on
attachment 308444
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=308444&action=review
R=me without that if.
>> Source/JavaScriptCore/b3/B3FoldPathConstants.cpp:109 >> + targetUses.add(switchValue->fallThrough(block), 0).iterator->value++; > > If we wanted to, we could be a bit niftier here: > We could check if any target is zero, and if so, we could check if targetUses(fall through) === 0, and if both are true, we could say that in the default block, the switch value is nonzero (obviously only if default block has a single predecessor). I'm not sure if it's worth bothering though.
VALIDATE(value->as<SwitchValue>()->hasFallThrough(valueOwner.get(value)), ("At ", *value)); Therefore, you don't need to check if hasFallThrough(). It must hasFallThrough().
Saam Barati
Comment 6
2017-04-27 14:33:41 PDT
Created
attachment 308448
[details]
patch for landing
Build Bot
Comment 7
2017-04-27 14:36:14 PDT
Attachment 308448
[details]
did not pass style-queue: ERROR: Source/JavaScriptCore/b3/testb3.cpp:10784: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10785: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10786: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10786: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10787: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10787: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10788: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10788: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10789: Consider using CHECK_EQ instead of CHECK(a == b) [readability/check] [2] ERROR: Source/JavaScriptCore/b3/testb3.cpp:10789: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] Total errors found: 10 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 8
2017-04-27 16:52:45 PDT
Comment on
attachment 308448
[details]
patch for landing Clearing flags on attachment: 308448 Committed
r215908
: <
http://trac.webkit.org/changeset/215908
>
WebKit Commit Bot
Comment 9
2017-04-27 16:52:46 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug