1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 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)
)
|