diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/help/wasm-metadce.test | 2 | ||||
-rw-r--r-- | test/lit/help/wasm-opt.test | 2 | ||||
-rw-r--r-- | test/lit/help/wasm2js.test | 2 | ||||
-rw-r--r-- | test/lit/passes/O1.wast | 1 | ||||
-rw-r--r-- | test/lit/passes/heap-store-optimization.wast (renamed from test/lit/passes/optimize-instructions-gc-heap.wast) | 57 |
5 files changed, 62 insertions, 2 deletions
diff --git a/test/lit/help/wasm-metadce.test b/test/lit/help/wasm-metadce.test index 665d78746..41a43bf1b 100644 --- a/test/lit/help/wasm-metadce.test +++ b/test/lit/help/wasm-metadce.test @@ -190,6 +190,8 @@ ;; CHECK-NEXT: --gufa-optimizing GUFA plus local optimizations in ;; CHECK-NEXT: functions we modified ;; CHECK-NEXT: +;; CHECK-NEXT: --heap-store-optimization optimize heap (GC) stores +;; CHECK-NEXT: ;; CHECK-NEXT: --heap2local replace GC allocations with ;; CHECK-NEXT: locals ;; CHECK-NEXT: diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test index 4eea3c431..e5b30e304 100644 --- a/test/lit/help/wasm-opt.test +++ b/test/lit/help/wasm-opt.test @@ -199,6 +199,8 @@ ;; CHECK-NEXT: --gufa-optimizing GUFA plus local optimizations in ;; CHECK-NEXT: functions we modified ;; CHECK-NEXT: +;; CHECK-NEXT: --heap-store-optimization optimize heap (GC) stores +;; CHECK-NEXT: ;; CHECK-NEXT: --heap2local replace GC allocations with ;; CHECK-NEXT: locals ;; CHECK-NEXT: diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test index 501d1d3f1..2d933984e 100644 --- a/test/lit/help/wasm2js.test +++ b/test/lit/help/wasm2js.test @@ -153,6 +153,8 @@ ;; CHECK-NEXT: --gufa-optimizing GUFA plus local optimizations in ;; CHECK-NEXT: functions we modified ;; CHECK-NEXT: +;; CHECK-NEXT: --heap-store-optimization optimize heap (GC) stores +;; CHECK-NEXT: ;; CHECK-NEXT: --heap2local replace GC allocations with ;; CHECK-NEXT: locals ;; CHECK-NEXT: diff --git a/test/lit/passes/O1.wast b/test/lit/passes/O1.wast index 8ffc29301..49271699d 100644 --- a/test/lit/passes/O1.wast +++ b/test/lit/passes/O1.wast @@ -40,4 +40,3 @@ ) ) - diff --git a/test/lit/passes/optimize-instructions-gc-heap.wast b/test/lit/passes/heap-store-optimization.wast index 2988b1bd8..635963523 100644 --- a/test/lit/passes/optimize-instructions-gc-heap.wast +++ b/test/lit/passes/heap-store-optimization.wast @@ -1,5 +1,5 @@ ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. -;; RUN: wasm-opt %s --remove-unused-names --optimize-instructions -all -S -o - \ +;; RUN: wasm-opt %s --remove-unused-names --heap-store-optimization -all -S -o - \ ;; RUN: | filecheck %s ;; ;; --remove-unused-names allows the optimizer to see that the blocks have no @@ -822,4 +822,59 @@ (func $helper-i32 (param $x i32) (result i32) (i32.const 42) ) + + ;; CHECK: (func $control-flow-in-set-value (type $5) (result i32) + ;; CHECK-NEXT: (local $ref (ref null $struct)) + ;; CHECK-NEXT: (block $label + ;; CHECK-NEXT: (local.set $ref + ;; CHECK-NEXT: (struct.new $struct + ;; CHECK-NEXT: (if (result i32) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (then + ;; CHECK-NEXT: (br $label) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (else + ;; CHECK-NEXT: (i32.const 42) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (struct.get $struct 0 + ;; CHECK-NEXT: (local.get $ref) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $control-flow-in-set-value (result i32) + ;; Test we handle control flow in the struct.set's value when we combine a + ;; struct.set with a struct.new. + ;; XXX The output above is wrong atm, and the pass needs fixing! + (local $ref (ref null $struct)) + (block $label + (struct.set $struct 0 + (local.tee $ref + (struct.new $struct + (i32.const 1) + ) + ) + (if (result i32) + (i32.const 1) + (then + ;; This conditional break happens *after* the local.tee of $ref. We + ;; must not move code around that reorders it, since there is a use + ;; of the local below that could notice changes. + (br $label) + ) + (else + (i32.const 42) + ) + ) + ) + ) + ;; We did not reach the struct.set, but we did reach the local.tee, so this + ;; reads the initial value of 1 (and does not trap on a nullref). + (struct.get $struct 0 + (local.get $ref) + ) + ) ) + |