1; This checks to ensure that Subzero aligns spill slots. 2 3; RUN: %p2i --filetype=obj --disassemble -i %s --args -Om1 \ 4; RUN: -allow-externally-defined-symbols | FileCheck %s 5; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 \ 6; RUN: -allow-externally-defined-symbols | FileCheck %s 7 8; The location of the stack slot for a variable is inferred from the 9; return sequence. 10 11; In this file, "global" refers to a variable with a live range across 12; multiple basic blocks (not an LLVM global variable) and "local" 13; refers to a variable that is live in only a single basic block. 14 15define internal <4 x i32> @align_global_vector(i32 %arg) { 16entry: 17 %vec.global = insertelement <4 x i32> undef, i32 %arg, i32 0 18 br label %block 19block: 20 call void @ForceXmmSpills() 21 ret <4 x i32> %vec.global 22; CHECK-LABEL: align_global_vector 23; CHECK: movups xmm0,XMMWORD PTR [esp] 24; CHECK-NEXT: add esp,0x1c 25; CHECK-NEXT: ret 26} 27 28define internal <4 x i32> @align_local_vector(i32 %arg) { 29entry: 30 br label %block 31block: 32 %vec.local = insertelement <4 x i32> undef, i32 %arg, i32 0 33 call void @ForceXmmSpills() 34 ret <4 x i32> %vec.local 35; CHECK-LABEL: align_local_vector 36; CHECK: movups xmm0,XMMWORD PTR [esp] 37; CHECK-NEXT: add esp,0x1c 38; CHECK-NEXT: ret 39} 40 41declare void @ForceXmmSpills() 42 43define internal <4 x i32> @align_global_vector_ebp_based(i32 %arg) { 44entry: 45 br label %eblock ; Disable alloca optimization 46eblock: 47 %alloc = alloca i8, i32 1, align 1 48 %vec.global = insertelement <4 x i32> undef, i32 %arg, i32 0 49 br label %block 50block: 51 call void @ForceXmmSpillsAndUseAlloca(i8* %alloc) 52 ret <4 x i32> %vec.global 53; CHECK-LABEL: align_global_vector_ebp_based 54; CHECK: movups xmm0,XMMWORD PTR [ebp-0x18] 55; CHECK-NEXT: mov esp,ebp 56; CHECK-NEXT: pop ebp 57; CHECK: ret 58} 59 60define internal <4 x i32> @align_local_vector_ebp_based(i32 %arg) { 61entry: 62 br label %eblock ; Disable alloca optimization 63eblock: 64 %alloc = alloca i8, i32 1, align 1 65 %vec.local = insertelement <4 x i32> undef, i32 %arg, i32 0 66 call void @ForceXmmSpillsAndUseAlloca(i8* %alloc) 67 ret <4 x i32> %vec.local 68; CHECK-LABEL: align_local_vector_ebp_based 69; CHECK: movups xmm0,XMMWORD PTR [ebp-0x18] 70; CHECK-NEXT: mov esp,ebp 71; CHECK-NEXT: pop ebp 72; CHECK: ret 73} 74 75define internal <4 x i32> @align_local_vector_and_global_float(i32 %arg) { 76entry: 77 %float.global = sitofp i32 %arg to float 78 call void @ForceXmmSpillsAndUseFloat(float %float.global) 79 br label %block 80block: 81 %vec.local = insertelement <4 x i32> undef, i32 undef, i32 0 82 call void @ForceXmmSpillsAndUseFloat(float %float.global) 83 ret <4 x i32> %vec.local 84; CHECK-LABEL: align_local_vector_and_global_float 85; CHECK: cvtsi2ss xmm0,eax 86; CHECK-NEXT: movss DWORD PTR [esp+{{0x1c|0x2c}}],xmm0 87; CHECK: movups xmm0,XMMWORD PTR [{{esp\+0x10|esp\+0x20}}] 88; CHECK-NEXT: add esp,0x3c 89; CHECK-NEXT: ret 90} 91 92declare void @ForceXmmSpillsAndUseAlloca(i8*) 93declare void @ForceXmmSpillsAndUseFloat(float) 94