summaryrefslogtreecommitdiff
path: root/test/lit
diff options
context:
space:
mode:
Diffstat (limited to 'test/lit')
-rw-r--r--test/lit/passes/simplify-locals-global.wast51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/lit/passes/simplify-locals-global.wast b/test/lit/passes/simplify-locals-global.wast
new file mode 100644
index 000000000..215b32a3c
--- /dev/null
+++ b/test/lit/passes/simplify-locals-global.wast
@@ -0,0 +1,51 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
+;; RUN: wasm-opt %s --simplify-locals -S -o - | filecheck %s
+
+(module
+ ;; CHECK: (global $imm-glob i32 (i32.const 1234))
+ (global $imm-glob i32 (i32.const 1234))
+
+ ;; CHECK: (global $mut-glob (mut i32) (i32.const 5678))
+ (global $mut-glob (mut i32) (i32.const 5678))
+
+ ;; CHECK: (func $reorder-of-immmutable-global (result i32)
+ ;; CHECK-NEXT: (local $temp i32)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: (call $helper)
+ ;; CHECK-NEXT: (global.get $imm-glob)
+ ;; CHECK-NEXT: )
+ (func $reorder-of-immmutable-global (result i32)
+ (local $temp i32)
+ ;; As the global is immutable, it cannot be modified in the call, and we can
+ ;; reorder here.
+ (local.set $temp
+ (global.get $imm-glob)
+ )
+ (call $helper)
+ (local.get $temp)
+ )
+
+ ;; CHECK: (func $no-reorder-of-mutable-global (result i32)
+ ;; CHECK-NEXT: (local $temp i32)
+ ;; CHECK-NEXT: (local.set $temp
+ ;; CHECK-NEXT: (global.get $mut-glob)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $helper)
+ ;; CHECK-NEXT: (local.get $temp)
+ ;; CHECK-NEXT: )
+ (func $no-reorder-of-mutable-global (result i32)
+ (local $temp i32)
+ ;; As the global is mutable, it can be modified in the call, and we cannot
+ ;; reorder here.
+ (local.set $temp
+ (global.get $mut-glob)
+ )
+ (call $helper)
+ (local.get $temp)
+ )
+
+ ;; CHECK: (func $helper
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ (func $helper)
+)