diff options
author | Alon Zakai <azakai@google.com> | 2021-06-29 16:03:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-29 16:03:37 -0700 |
commit | 10ef52d62468aec5762742930630e882dc5e5c0b (patch) | |
tree | 794b3754a8c6aeedce3b4acb2240e169c526eb50 /test | |
parent | 6ab05d914bbee87dd4a26f218a04e7ea918a2271 (diff) | |
download | binaryen-10ef52d62468aec5762742930630e882dc5e5c0b.tar.gz binaryen-10ef52d62468aec5762742930630e882dc5e5c0b.tar.bz2 binaryen-10ef52d62468aec5762742930630e882dc5e5c0b.zip |
[Wasm GC] Fix LinearExecutionWalker (#3954)
That traversal did not mention BrOn, which led to it doing incorrect work in
SimplifyLocals.
Also add assertions at the end, that aim to prevent future issues.
The rest of the fix is to make SimplifyLocals not assume that things
are a Switch if they are not an If/Block/etc., so that we don't crash
on a BrOn.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/simplify-locals-gc.wast | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/lit/passes/simplify-locals-gc.wast b/test/lit/passes/simplify-locals-gc.wast index 06822a5d7..89e696d8f 100644 --- a/test/lit/passes/simplify-locals-gc.wast +++ b/test/lit/passes/simplify-locals-gc.wast @@ -33,4 +33,59 @@ ) (local.get $temp) ) + + ;; CHECK: (func $no-block-values-if-br_on + ;; CHECK-NEXT: (local $temp anyref) + ;; CHECK-NEXT: (block $block + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (br_on_null $block + ;; CHECK-NEXT: (ref.null any) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $temp + ;; CHECK-NEXT: (ref.null any) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br $block) + ;; CHECK-NEXT: (local.set $temp + ;; CHECK-NEXT: (ref.null any) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (local.get $temp) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $no-block-values-if-br_on + (local $temp (ref null any)) + (block $block + (drop + ;; This br_on should inhibit trying to create a block return value for + ;; this block. Aside from the br_on, it looks correct, i.e., we have a + ;; break with a set before it, and a set before the end of the block. Due + ;; to the br_on's presence, the pass should not do anything to this + ;; function. + ;; + ;; TODO: support br_on in this optimization eventually, but the variable + ;; possible return values and sent values make that nontrivial. + (br_on_null $block + (ref.null any) + ) + ) + (local.set $temp + (ref.null any) + ) + (br $block) + (local.set $temp + (ref.null any) + ) + ) + ;; Attempt to use the local that the pass will try to move to a block return + ;; value, to cause the optimization to try to run. + (drop + (ref.as_non_null + (local.get $temp) + ) + ) + ) ) |