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 datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 11 target triple = "wasm32-unknown-unknown" 12 13 declare void @foo(i32, i32) 14 define void @compiler_fence_test(i32) { 15 ret void 16 } 17 define void @atomic_fence_test(i32) { 18 ret void 19 } 20... 21--- 22# CHECK-LABEL: name: compiler_fence_test 23name: compiler_fence_test 24liveins: 25 - { reg: '$arguments' } 26tracksRegLiveness: true 27body: | 28 bb.0: 29 ; CHECK: %[[REG:[0-9]+]]:i32 = MEMORY_ATOMIC_NOTIFY_A32 30 ; CHECK: LOCAL_SET_I32 [[LOCAL:[0-9]+]], %[[REG]] 31 ; CHECK: COMPILER_FENCE 32 ; CHECK: ADD_I32 33 ; CHECK: LOCAL_GET_I32 [[LOCAL]] 34 ; CHECK: CALL @foo 35 36 liveins: $arguments 37 %0:i32 = CONST_I32 0, implicit-def $arguments 38 %1:i32 = MEMORY_ATOMIC_NOTIFY_A32 2, 0, %0:i32, %0:i32, implicit-def $arguments 39 COMPILER_FENCE implicit-def $arguments 40 %2:i32 = ADD_I32 %0:i32, %0:i32, implicit-def $arguments 41 CALL @foo, %2:i32, %1:i32, implicit-def $arguments 42 RETURN implicit-def $arguments 43... 44 45--- 46# CHECK-LABEL: name: atomic_fence_test 47name: atomic_fence_test 48liveins: 49 - { reg: '$arguments' } 50tracksRegLiveness: true 51body: | 52 bb.0: 53 ; CHECK: %[[REG:[0-9]+]]:i32 = MEMORY_ATOMIC_NOTIFY_A32 54 ; CHECK: LOCAL_SET_I32 [[LOCAL:[0-9]+]], %[[REG]] 55 ; CHECK: ATOMIC_FENCE 56 ; CHECK: ADD_I32 57 ; CHECK: LOCAL_GET_I32 [[LOCAL]] 58 ; CHECK: CALL @foo 59 60 liveins: $arguments 61 %0:i32 = CONST_I32 0, implicit-def $arguments 62 %1:i32 = MEMORY_ATOMIC_NOTIFY_A32 2, 0, %0:i32, %0:i32, implicit-def $arguments 63 ATOMIC_FENCE 0, implicit-def $arguments 64 %2:i32 = ADD_I32 %0:i32, %0:i32, implicit-def $arguments 65 CALL @foo, %2:i32, %1:i32, implicit-def $arguments 66 RETURN implicit-def $arguments 67... 68