1# RUN: llc -mtriple=wasm32-unknown-unknown -run-pass wasm-reg-stackify -run-pass wasm-explicit-locals %s -o - | FileCheck %s 2 3# In the two tests below, without compiler_fence or atomic.fence in between, 4# memory.atomic.notify and i32.add will be reordered by register stackify pass 5# to meet 'call @foo''s requirements. But because we have fences between 6# memory.atomic.notify and i32.add, they cannot be reordered, and local.set and 7# local.get are inserted to save and load memory.atomic.notify's return value. 8 9--- | 10 target triple = "wasm32-unknown-unknown" 11 12 declare void @foo(i32, i32) 13 define void @compiler_fence_test(i32) { 14 ret void 15 } 16 define void @atomic_fence_test(i32) { 17 ret void 18 } 19... 20--- 21# CHECK-LABEL: name: compiler_fence_test 22name: compiler_fence_test 23liveins: 24 - { reg: '$arguments' } 25tracksRegLiveness: true 26body: | 27 bb.0: 28 ; CHECK: %[[REG:[0-9]+]]:i32 = MEMORY_ATOMIC_NOTIFY_A32 29 ; CHECK: LOCAL_SET_I32 [[LOCAL:[0-9]+]], %[[REG]] 30 ; CHECK: COMPILER_FENCE 31 ; CHECK: ADD_I32 32 ; CHECK: LOCAL_GET_I32 [[LOCAL]] 33 ; CHECK: CALL @foo 34 35 liveins: $arguments 36 %0:i32 = CONST_I32 0, implicit-def $arguments 37 %1:i32 = MEMORY_ATOMIC_NOTIFY_A32 2, 0, %0:i32, %0:i32, implicit-def $arguments 38 COMPILER_FENCE implicit-def $arguments 39 %2:i32 = ADD_I32 %0:i32, %0:i32, implicit-def $arguments 40 CALL @foo, %2:i32, %1:i32, implicit-def $arguments 41 RETURN implicit-def $arguments 42... 43 44--- 45# CHECK-LABEL: name: atomic_fence_test 46name: atomic_fence_test 47liveins: 48 - { reg: '$arguments' } 49tracksRegLiveness: true 50body: | 51 bb.0: 52 ; CHECK: %[[REG:[0-9]+]]:i32 = MEMORY_ATOMIC_NOTIFY_A32 53 ; CHECK: LOCAL_SET_I32 [[LOCAL:[0-9]+]], %[[REG]] 54 ; CHECK: ATOMIC_FENCE 55 ; CHECK: ADD_I32 56 ; CHECK: LOCAL_GET_I32 [[LOCAL]] 57 ; CHECK: CALL @foo 58 59 liveins: $arguments 60 %0:i32 = CONST_I32 0, implicit-def $arguments 61 %1:i32 = MEMORY_ATOMIC_NOTIFY_A32 2, 0, %0:i32, %0:i32, implicit-def $arguments 62 ATOMIC_FENCE 0, implicit-def $arguments 63 %2:i32 = ADD_I32 %0:i32, %0:i32, implicit-def $arguments 64 CALL @foo, %2:i32, %1:i32, implicit-def $arguments 65 RETURN implicit-def $arguments 66... 67