summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/simplify-locals-gc.wast35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/lit/passes/simplify-locals-gc.wast b/test/lit/passes/simplify-locals-gc.wast
new file mode 100644
index 000000000..4308a25a1
--- /dev/null
+++ b/test/lit/passes/simplify-locals-gc.wast
@@ -0,0 +1,35 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
+;; RUN: wasm-opt %s --simplify-locals -all -S -o - \
+;; RUN: | filecheck %s
+
+(module
+ (type $struct (struct (field (mut i32))))
+
+ ;; Writes to heap objects cannot be reordered with reads.
+ ;; CHECK: (func $no-reorder-past-write (param $x (ref $struct)) (result i32)
+ ;; CHECK-NEXT: (local $temp i32)
+ ;; CHECK-NEXT: (local.set $temp
+ ;; CHECK-NEXT: (struct.get $struct 0
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (struct.set $struct 0
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: (i32.const 42)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.get $temp)
+ ;; CHECK-NEXT: )
+ (func $no-reorder-past-write (param $x (ref $struct)) (result i32)
+ (local $temp i32)
+ (local.set $temp
+ (struct.get $struct 0
+ (local.get $x)
+ )
+ )
+ (struct.set $struct 0
+ (local.get $x)
+ (i32.const 42)
+ )
+ (local.get $temp)
+ )
+)