-
Notifications
You must be signed in to change notification settings - Fork 793
Require then
and else
with if
#6201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
We previously supported (and primarily used) a non-standard text format for conditionals in which the condition, if-true expression, and if-false expression were all simply s-expression children of the `if` expression. The standard text format, however, requires the use of `then` and `else` forms to introduce the if-true and if-false arms of the conditional. Update the legacy text parser to require the standard format and update all tests to match. Update the printer to print the standard format as well. The .wast and .wat test inputs were mechanically updated with this script: https://gist.github.com/tlively/85ae7f01f92f772241ec994c840ccbb1
Current dependencies on/for this PR: This stack of pull requests is managed by Graphite. |
I strongly recommend hiding whitespace when viewing the diff 😆 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this must have changed when wasm switched to a stack machine... because it is needed to identify structural children.
lgtm % questions
@@ -65,7 +67,7 @@ TEST_F(CFGTest, Print) { | |||
;; preds: [3], succs: [6] | |||
4: | |||
6: i32.const 3 | |||
7: block | |||
7: block (result i32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is a necessary change. Probably due to a difference in finalization between the parsing for block
and the parsing for then
, but not sure it's worth digging into more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, it's probably that.
$12$hi = i64toi32_i32$2; | ||
if (($0_1 | 0) == (i64toi32_i32$3 | 0) & ($0$hi | 0) == (i64toi32_i32$1 | 0) | 0) { | ||
$8 = 1; | ||
$8$hi = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am surprised to see codegen changes here. This change even looks non-NFC. Do you know why this changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the source file contains then
and else
blocks containing single instructions. Those were previously parsed as singleton blocks, but now they're parsed as the actual instructions. I think that change to the IR probably explains the different output here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be. But looking at the output it's not obvious to me if it is or isn't a regression (line 21 is gone, for example - these aren't just renamed variables, there is a structural change), so I think it's worth investigating. Let me know if you'd like help with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I verified that the different parsing behavior explains this. I ran wasm2js on one of the source functions with and without the special case for singleton then
and else
blocks and the output had precisely these differences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
I see a fuzzer error shortly after this landed which bisects down to this:
That is on seed Reduced testcase: (module
(type $0 (func (result i32)))
(func $0 (result i32)
(i32.popcnt
(i32.const 0)
)
)
) STR:
Oddly it's not a text format issue, as it happens when parsing a binary..? |
The intrinsics file changed in #6201 and somehow CMake doesn't automatically update itself, and needs a manual step for people with existing checkouts (a new fresh checkout always works). To avoid annoyance for existing checkouts, rename the vars, which forces CMake to recompute the contents.
We previously supported (and primarily used) a non-standard text format for conditionals in which the condition, if-true expression, and if-false expression were all simply s-expression children of the `if` expression. The standard text format, however, requires the use of `then` and `else` forms to introduce the if-true and if-false arms of the conditional. Update the legacy text parser to require the standard format and update all tests to match. Update the printer to print the standard format as well. The .wast and .wat test inputs were mechanically updated with this script: https://gist.github.com/tlively/85ae7f01f92f772241ec994c840ccbb1
The intrinsics file changed in WebAssembly#6201 and somehow CMake doesn't automatically update itself, and needs a manual step for people with existing checkouts (a new fresh checkout always works). To avoid annoyance for existing checkouts, rename the vars, which forces CMake to recompute the contents.
We previously supported (and primarily used) a non-standard text format for
conditionals in which the condition, if-true expression, and if-false expression
were all simply s-expression children of the
if
expression. The standard textformat, however, requires the use of
then
andelse
forms to introduce theif-true and if-false arms of the conditional. Update the legacy text parser to
require the standard format and update all tests to match. Update the printer to
print the standard format as well.
The .wast and .wat test inputs were mechanically updated with this script:
https://gist.github.com/tlively/85ae7f01f92f772241ec994c840ccbb1