blob: e87488e9749dcca9acbff2c8064fbc294cff6526 [file] [log] [blame]
Matt Walad4799f42014-08-14 14:24:12 -07001; This checks to ensure that Subzero aligns spill slots.
2
Karl Schimpf2a5324a2014-09-25 09:37:49 -07003; TODO(kschimpf) Find out why lc2i needed.
Karl Schimpfb262c5e2014-10-27 14:41:57 -07004; REQUIRES: allow_llvm_ir_as_input
Karl Schimpf2a5324a2014-09-25 09:37:49 -07005; RUN: %lc2i -i %s --args --verbose none \
Jim Stichnothbca2f652014-11-01 10:13:54 -07006; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \
Jan Voung8acded02014-09-22 18:02:25 -07007; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s
Karl Schimpf2a5324a2014-09-25 09:37:49 -07008; RUN: %lc2i -i %s --args -O2 --verbose none \
Jim Stichnothbca2f652014-11-01 10:13:54 -07009; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \
Jan Voung8acded02014-09-22 18:02:25 -070010; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s
Matt Walad4799f42014-08-14 14:24:12 -070011
12; The location of the stack slot for a variable is inferred from the
13; return sequence.
14
15; In this file, "global" refers to a variable with a live range across
16; multiple basic blocks (not an LLVM global variable) and "local"
17; refers to a variable that is live in only a single basic block.
18
19define <4 x i32> @align_global_vector(i32 %arg) {
20entry:
21 %vec.global = insertelement <4 x i32> undef, i32 %arg, i32 0
22 br label %block
23block:
24 call void @ForceXmmSpills()
25 ret <4 x i32> %vec.global
26; CHECK-LABEL: align_global_vector:
27; CHECK: movups xmm0, xmmword ptr [esp]
28; CHECK-NEXT: add esp, 28
29; CHECK-NEXT: ret
30}
31
32define <4 x i32> @align_local_vector(i32 %arg) {
33entry:
34 br label %block
35block:
36 %vec.local = insertelement <4 x i32> undef, i32 %arg, i32 0
37 call void @ForceXmmSpills()
38 ret <4 x i32> %vec.local
39; CHECK-LABEL: align_local_vector:
40; CHECK: movups xmm0, xmmword ptr [esp]
41; CHECK-NEXT: add esp, 28
42; CHECK-NEXT: ret
43}
44
45declare void @ForceXmmSpills()
46
47define <4 x i32> @align_global_vector_ebp_based(i32 %arg) {
48entry:
49 %alloc = alloca i8, i32 1, align 1
50 %vec.global = insertelement <4 x i32> undef, i32 %arg, i32 0
51 br label %block
52block:
53 call void @ForceXmmSpillsAndUseAlloca(i8* %alloc)
54 ret <4 x i32> %vec.global
55; CHECK-LABEL: align_global_vector_ebp_based:
Jan Voung8acded02014-09-22 18:02:25 -070056; CHECK: movups xmm0, xmmword ptr [ebp - 24]
Matt Walad4799f42014-08-14 14:24:12 -070057; CHECK-NEXT: mov esp, ebp
58; CHECK-NEXT: pop ebp
59; CHECK: ret
60}
61
62define <4 x i32> @align_local_vector_ebp_based(i32 %arg) {
63entry:
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:
Jan Voung8acded02014-09-22 18:02:25 -070069; CHECK: movups xmm0, xmmword ptr [ebp - 24]
Matt Walad4799f42014-08-14 14:24:12 -070070; CHECK-NEXT: mov esp, ebp
71; CHECK-NEXT: pop ebp
72; CHECK: ret
73}
74
75define <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
Jan Voung8acded02014-09-22 18:02:25 -070086; CHECK-NEXT: movss dword ptr [esp + {{12|28}}], xmm0
87; CHECK: movups xmm0, xmmword ptr [{{esp|esp \+ 16}}]
Matt Walad4799f42014-08-14 14:24:12 -070088; CHECK-NEXT: add esp, 44
89; CHECK-NEXT: ret
90}
91
92declare void @ForceXmmSpillsAndUseAlloca(i8*)
93declare void @ForceXmmSpillsAndUseFloat(float)