1; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s 2 3target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 4target triple = "wasm32-unknown-unknown" 5 6declare void @somefunc(i32*) 7 8; CHECK-LABEL: underalign: 9; CHECK: get_global $push[[L1:.+]]=, __stack_pointer{{$}} 10; CHECK-NEXT: i32.const $push[[L2:.+]]=, 16 11; CHECK-NEXT: i32.sub $push[[L10:.+]]=, $pop[[L1]], $pop[[L2]] 12; CHECK-NEXT: tee_local $push{{.+}}=, [[SP:.+]], $pop[[L10]] 13 14; CHECK: get_local $push[[L3:.+]]=, [[SP]]{{$}} 15; CHECK: i32.add $push[[underaligned:.+]]=, $pop[[L3]], $pop{{.+}} 16; CHECK-NEXT: call somefunc@FUNCTION, $pop[[underaligned]] 17 18; CHECK: get_local $push[[M4:.+]]=, [[SP]]{{$}} 19; CHECK: i32.add $push[[L5:.+]]=, $pop[[M4]], $pop{{.+}} 20; CHECK-NEXT: set_global __stack_pointer, $pop[[L5]] 21define void @underalign() { 22entry: 23 %underaligned = alloca i32, align 8 24 call void @somefunc(i32* %underaligned) 25 ret void 26} 27 28; CHECK-LABEL: overalign: 29; CHECK: get_global $push[[L10:.+]]=, __stack_pointer{{$}} 30; CHECK-NEXT: tee_local $push[[L9:.+]]=, [[BP:.+]], $pop[[L10]] 31; CHECK-NEXT: i32.const $push[[L2:.+]]=, 32 32; CHECK-NEXT: i32.sub $push[[L8:.+]]=, $pop[[L9]], $pop[[L2]] 33; CHECK-NEXT: i32.const $push[[L3:.+]]=, -32 34; CHECK-NEXT: i32.and $push[[L7:.+]]=, $pop[[L8]], $pop[[L3]] 35; CHECK-NEXT: tee_local $push{{.+}}=, [[SP:.+]], $pop[[L7]] 36 37; CHECK: get_local $push[[M5:.+]]=, [[SP]]{{$}} 38; CHECK: call somefunc@FUNCTION, $pop[[M5]]{{$}} 39 40; CHECK: get_local $push[[M6:.+]]=, [[BP]]{{$}} 41; CHECK-NEXT: set_global __stack_pointer, $pop[[M6]] 42define void @overalign() { 43entry: 44 %overaligned = alloca i32, align 32 45 call void @somefunc(i32* %overaligned) 46 ret void 47} 48 49; CHECK-LABEL: over_and_normal_align: 50; CHECK: get_global $push[[L14:.+]]=, __stack_pointer{{$}} 51; CHECK-NEXT: tee_local $push[[L13:.+]]=, [[BP:.+]], $pop[[L14]] 52; CHECK: i32.sub $push[[L12:.+]]=, $pop[[L13]], $pop{{.+}} 53; CHECK: i32.and $push[[L11:.+]]=, $pop[[L12]], $pop{{.+}} 54; CHECK-NEXT: tee_local $push{{.+}}=, [[SP:.+]], $pop[[L11]] 55 56; CHECK: get_local $push[[M6:.+]]=, [[SP]]{{$}} 57; CHECK: i32.add $push[[L6:.+]]=, $pop[[M6]], $pop{{.+}} 58; CHECK-NEXT: call somefunc@FUNCTION, $pop[[L6]] 59; CHECK: get_local $push[[M7:.+]]=, [[SP]]{{$}} 60; CHECK: i32.add $push[[L8:.+]]=, $pop[[M7]], $pop{{.+}} 61; CHECK-NEXT: call somefunc@FUNCTION, $pop[[L8]] 62 63; CHECK: get_local $push[[L6:.+]]=, [[BP]]{{$}} 64; CHECK-NEXT: set_global __stack_pointer, $pop[[L6]] 65define void @over_and_normal_align() { 66entry: 67 %over = alloca i32, align 32 68 %normal = alloca i32 69 call void @somefunc(i32* %over) 70 call void @somefunc(i32* %normal) 71 ret void 72} 73 74; CHECK-LABEL: dynamic_overalign: 75; CHECK: get_global $push[[L18:.+]]=, __stack_pointer{{$}} 76; CHECK-NEXT: tee_local $push[[L17:.+]]=, [[SP:.+]], $pop[[L18]] 77; CHECK-NEXT: set_local [[BP:.+]], $pop[[L17]] 78; CHECK: tee_local $push{{.+}}=, [[SP_2:.+]], $pop{{.+}} 79 80; CHECK: get_local $push[[M8:.+]]=, [[SP_2]]{{$}} 81; CHECK: call somefunc@FUNCTION, $pop[[M8]] 82 83; CHECK: get_local $push[[M9:.+]]=, [[BP]]{{$}} 84; CHECK-NEXT: set_global __stack_pointer, $pop[[M9]] 85define void @dynamic_overalign(i32 %num) { 86entry: 87 %dynamic = alloca i32, i32 %num, align 32 88 call void @somefunc(i32* %dynamic) 89 ret void 90} 91 92; CHECK-LABEL: overalign_and_dynamic: 93; CHECK: get_global $push[[L21:.+]]=, __stack_pointer{{$}} 94; CHECK-NEXT: tee_local $push[[L20:.+]]=, [[BP:.+]], $pop[[L21]] 95; CHECK: i32.sub $push[[L19:.+]]=, $pop[[L20]], $pop{{.+}} 96; CHECK: i32.and $push[[L18:.+]]=, $pop[[L19]], $pop{{.+}} 97; CHECK: tee_local $push{{.+}}=, [[FP:.+]], $pop[[L18]] 98; CHECK: get_local $push[[M10:.+]]=, [[FP]]{{$}} 99; CHECK: i32.sub $push[[L16:.+]]=, $pop[[M10]], $pop{{.+}} 100; CHECK-NEXT: tee_local $push{{.+}}=, [[SP:.+]], $pop[[L16]] 101 102; CHECK: get_local $push[[over:.+]]=, [[FP]] 103; CHECK-NEXT: call somefunc@FUNCTION, $pop[[over]] 104; CHECK: get_local $push[[another:.+]]=, [[SP]] 105; CHECK-NEXT: call somefunc@FUNCTION, $pop[[another]] 106 107; CHECK: get_local $push[[M11:.+]]=, [[BP]]{{$}} 108; CHECK-NEXT: set_global __stack_pointer, $pop[[M11]] 109define void @overalign_and_dynamic(i32 %num) { 110entry: 111 %over = alloca i32, align 32 112 %dynamic = alloca i32, i32 %num 113 call void @somefunc(i32* %over) 114 call void @somefunc(i32* %dynamic) 115 ret void 116} 117 118; CHECK-LABEL: overalign_static_and_dynamic: 119; CHECK: get_global $push[[L26:.+]]=, __stack_pointer{{$}} 120; CHECK-NEXT: tee_local $push[[L25:.+]]=, [[BP:.+]], $pop[[L26]] 121; CHECK: i32.sub $push[[L24:.+]]=, $pop[[L25]], $pop{{.+}} 122; CHECK: i32.and $push[[L23:.+]]=, $pop[[L24]], $pop{{.+}} 123; CHECK: tee_local $push{{.+}}=, [[FP:.+]], $pop[[L23]] 124; CHECK: get_local $push[[M12:.+]]=, [[FP]]{{$}} 125; CHECK: i32.sub $push[[L21:.+]]=, $pop[[M12]], $pop{{.+}} 126; CHECK-NEXT: tee_local $push{{.+}}=, [[SP:.+]], $pop[[L21]] 127 128; CHECK: get_local $push[[L19:.+]]=, [[FP]] 129; CHECK: tee_local $push[[L18:.+]]=, [[FP_2:.+]], $pop[[L19]] 130; CHECK: i32.add $push[[over:.+]]=, $pop[[L18]], $pop{{.+}} 131; CHECK-NEXT: call somefunc@FUNCTION, $pop[[over]] 132; CHECK: get_local $push[[M12:.+]]=, [[SP]] 133; CHECK: call somefunc@FUNCTION, $pop[[M12]] 134; CHECK: get_local $push[[M13:.+]]=, [[FP_2]] 135; CHECK: i32.add $push[[static:.+]]=, $pop[[M13]], $pop{{.+}} 136; CHECK-NEXT: call somefunc@FUNCTION, $pop[[static]] 137 138; CHECK: get_local $push[[M14:.+]]=, [[BP]]{{$}} 139; CHECK-NEXT: set_global __stack_pointer, $pop[[M14]] 140define void @overalign_static_and_dynamic(i32 %num) { 141entry: 142 %over = alloca i32, align 32 143 %dynamic = alloca i32, i32 %num 144 %static = alloca i32 145 call void @somefunc(i32* %over) 146 call void @somefunc(i32* %dynamic) 147 call void @somefunc(i32* %static) 148 ret void 149} 150