llvm.org GIT mirror llvm / 7a1b190
[X86] Use 4 byte preferred aggregate alignment on Win32 This helps reduce the frequency of stack realignment prologues in 32-bit X86 Windows code. Before this change and the corresponding clang change, we would take the max of the type preferred alignment and the explicit alignment on the alloca. If you don't override aggregate alignment in datalayout, you get a default of 8. This dates back to 2007 / r34356, and changing it seems prohibitively difficult at this point. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236270 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 4 years ago
5 changed file(s) with 24 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
8080
8181 // The stack is aligned to 32 bits on some ABIs and 128 bits on others.
8282 if (!TT.isArch64Bit() && TT.isOSWindows())
83 Ret += "-S32";
83 Ret += "-a:0:32-S32";
8484 else
8585 Ret += "-S128";
8686
2020 %end = getelementptr %frame.reverse, %frame.reverse* %rev_args, i32 0, i32 1
2121
2222 ; CHECK: calll __chkstk
23 ; CHECK: movl %[[beg:[^,]*]], %esp
24 ; CHECK: leal 12(%[[beg]]), %[[end:[^ ]*]]
23 ; CHECK: movl %esp, %[[beg:[^ ]*]]
24 ; CHECK: movl %esp, %[[end:[^ ]*]]
25 ; CHECK: addl $12, %[[end]]
2526
2627 call void @begin(%Iter* sret %temp.lvalue)
2728 ; CHECK: calll _begin
99 %b = alloca inalloca %Foo
1010 ; CHECK: movl $8, %eax
1111 ; CHECK: calll __chkstk
12 ; CHECK: movl %[[REG:[^,]*]], %esp
1312 %f1 = getelementptr %Foo, %Foo* %b, i32 0, i32 0
1413 %f2 = getelementptr %Foo, %Foo* %b, i32 0, i32 1
1514 store i32 13, i32* %f1
1615 store i32 42, i32* %f2
17 ; CHECK: movl $13, (%[[REG]])
18 ; CHECK: movl $42, 4(%[[REG]])
16 ; CHECK: movl $13, (%esp)
17 ; CHECK: movl $42, 4(%esp)
1918 call x86_stdcallcc void @f(%Foo* inalloca %b)
2019 ; CHECK: calll _f@8
2120 ; CHECK-NOT: %esp
99 %b = alloca inalloca %Foo
1010 ; CHECK: movl $8, %eax
1111 ; CHECK: calll __chkstk
12 ; CHECK: movl %[[REG:[^,]*]], %esp
1312 %f1 = getelementptr %Foo, %Foo* %b, i32 0, i32 0
1413 %f2 = getelementptr %Foo, %Foo* %b, i32 0, i32 1
1514 store i32 13, i32* %f1
1615 store i32 42, i32* %f2
17 ; CHECK: movl $13, (%[[REG]])
18 ; CHECK: movl $42, 4(%[[REG]])
16 ; CHECK: movl $13, (%esp)
17 ; CHECK: movl $42, 4(%esp)
1918 call void @f(%Foo* inalloca %b)
2019 ; CHECK: calll _f
2120 ret void
2928 %b = alloca inalloca %Foo
3029 ; CHECK: movl $8, %eax
3130 ; CHECK: calll __chkstk
32 ; CHECK: movl %[[REG:[^,]*]], %esp
3331 %f1 = getelementptr %Foo, %Foo* %b, i32 0, i32 0
3432 %f2 = getelementptr %Foo, %Foo* %b, i32 0, i32 1
3533 store i32 13, i32* %f1
3634 store i32 42, i32* %f2
37 ; CHECK: movl $13, (%[[REG]])
38 ; CHECK: movl $42, 4(%[[REG]])
35 ; CHECK: movl $13, (%esp)
36 ; CHECK: movl $42, 4(%esp)
3937 call void @inreg_with_inalloca(i32 inreg 1, %Foo* inalloca %b)
4038 ; CHECK: movl $1, %eax
4139 ; CHECK: calll _inreg_with_inalloca
5048 %b = alloca inalloca %Foo
5149 ; CHECK: movl $8, %eax
5250 ; CHECK: calll __chkstk
53 ; CHECK: movl %[[REG:[^,]*]], %esp
5451 %f1 = getelementptr %Foo, %Foo* %b, i32 0, i32 0
5552 %f2 = getelementptr %Foo, %Foo* %b, i32 0, i32 1
5653 store i32 13, i32* %f1
5754 store i32 42, i32* %f2
58 ; CHECK-DAG: movl $13, (%[[REG]])
59 ; CHECK-DAG: movl $42, 4(%[[REG]])
55 ; CHECK-DAG: movl $13, (%esp)
56 ; CHECK-DAG: movl $42, 4(%esp)
6057 call x86_thiscallcc void @thiscall_with_inalloca(i8* null, %Foo* inalloca %b)
6158 ; CHECK-DAG: xorl %ecx, %ecx
6259 ; CHECK: calll _thiscall_with_inalloca
154154 ; LINUX-LABEL: test6_f:
155155
156156 ; The %x argument is moved to %ecx. It will be the this pointer.
157 ; WIN32: movl 8(%ebp), %ecx
157 ; WIN32: movl 20(%esp), %ecx
158158
159159 ; The %x argument is moved to (%esp). It will be the this pointer. With -O0
160160 ; we copy esp to ecx and use (ecx) instead of (esp).
161 ; MINGW_X86: movl 8(%ebp), %eax
161 ; MINGW_X86: movl 20(%esp), %eax
162162 ; MINGW_X86: movl %eax, (%e{{([a-d]x)|(sp)}})
163163
164 ; CYGWIN: movl 8(%ebp), %eax
164 ; CYGWIN: movl 20(%esp), %eax
165165 ; CYGWIN: movl %eax, (%e{{([a-d]x)|(sp)}})
166166
167167 ; The sret pointer is (%esp)
168 ; WIN32: leal 8(%esp), %[[REG:e[a-d]x]]
168 ; WIN32: leal 4(%esp), %[[REG:e[a-d]x]]
169169 ; WIN32-NEXT: movl %[[REG]], (%e{{([a-d]x)|(sp)}})
170170
171171 ; The sret pointer is %ecx
172 ; MINGW_X86-NEXT: leal 8(%esp), %ecx
172 ; MINGW_X86-NEXT: leal 4(%esp), %ecx
173173 ; MINGW_X86-NEXT: calll _test6_g
174174
175 ; CYGWIN-NEXT: leal 8(%esp), %ecx
175 ; CYGWIN-NEXT: leal 4(%esp), %ecx
176176 ; CYGWIN-NEXT: calll _test6_g
177177
178178 %tmp = alloca %struct.test6, align 4
190190 ; LINUX-LABEL: test7_f:
191191
192192 ; The %x argument is moved to %ecx on all OSs. It will be the this pointer.
193 ; WIN32: movl 8(%ebp), %ecx
194 ; MINGW_X86: movl 8(%ebp), %ecx
195 ; CYGWIN: movl 8(%ebp), %ecx
193 ; WIN32: movl 20(%esp), %ecx
194 ; MINGW_X86: movl 20(%esp), %ecx
195 ; CYGWIN: movl 20(%esp), %ecx
196196
197197 ; The sret pointer is (%esp)
198 ; WIN32: leal 8(%esp), %[[REG:e[a-d]x]]
198 ; WIN32: leal 4(%esp), %[[REG:e[a-d]x]]
199199 ; WIN32-NEXT: movl %[[REG]], (%e{{([a-d]x)|(sp)}})
200 ; MINGW_X86: leal 8(%esp), %[[REG:e[a-d]x]]
200 ; MINGW_X86: leal 4(%esp), %[[REG:e[a-d]x]]
201201 ; MINGW_X86-NEXT: movl %[[REG]], (%e{{([a-d]x)|(sp)}})
202 ; CYGWIN: leal 8(%esp), %[[REG:e[a-d]x]]
202 ; CYGWIN: leal 4(%esp), %[[REG:e[a-d]x]]
203203 ; CYGWIN-NEXT: movl %[[REG]], (%e{{([a-d]x)|(sp)}})
204204
205205 %tmp = alloca %struct.test7, align 4