1 ; We specify -mcpu explicitly to avoid instruction reordering that happens on
2 ; some setups (e.g., Atom) from affecting the output.
3 ; RUN: llc < %s -mcpu=core2 -mtriple=i686-pc-win32 | FileCheck %s -check-prefix=WIN32
4 ; RUN: llc < %s -mtriple=i686-pc-mingw32 | FileCheck %s -check-prefix=MINGW_X86
5 ; RUN: llc < %s -mtriple=i386-pc-linux | FileCheck %s -check-prefix=LINUX
6 ; RUN: llc < %s -mcpu=core2 -O0 -mtriple=i686-pc-win32 | FileCheck %s -check-prefix=WIN32
7 ; RUN: llc < %s -O0 -mtriple=i686-pc-mingw32 | FileCheck %s -check-prefix=MINGW_X86
8 ; RUN: llc < %s -O0 -mtriple=i386-pc-linux | FileCheck %s -check-prefix=LINUX
10 ; The SysV ABI used by most Unixes and Mingw on x86 specifies that an sret pointer
11 ; is callee-cleanup. However, in MSVC's cdecl calling convention, sret pointer
12 ; arguments are caller-cleanup like normal arguments.
14 define void @sret1(i8* sret %x) nounwind {
17 ; WIN32: movb $42, (%eax)
18 ; WIN32-NOT: popl %eax
27 store i8 42, i8* %x, align 4
31 define void @sret2(i8* sret %x, i8 %y) nounwind {
34 ; WIN32: movb {{.*}}, (%eax)
35 ; WIN32-NOT: popl %eax
48 define void @sret3(i8* sret %x, i8* %y) nounwind {
51 ; WIN32: movb $42, (%eax)
52 ; WIN32-NOT: movb $13, (%eax)
53 ; WIN32-NOT: popl %eax
68 %struct.S4 = type { i32, i32, i32 }
70 define void @sret4(%struct.S4* noalias sret %agg.result) {
73 ; WIN32: movl $42, (%eax)
74 ; WIN32-NOT: popl %eax
83 %x = getelementptr inbounds %struct.S4* %agg.result, i32 0, i32 0
84 store i32 42, i32* %x, align 4
88 %struct.S5 = type { i32 }
89 %class.C5 = type { i8 }
91 define x86_thiscallcc void @"\01?foo@C5@@QAE?AUS5@@XZ"(%struct.S5* noalias sret %agg.result, %class.C5* %this) {
93 %this.addr = alloca %class.C5*, align 4
94 store %class.C5* %this, %class.C5** %this.addr, align 4
95 %this1 = load %class.C5** %this.addr
96 %x = getelementptr inbounds %struct.S5* %agg.result, i32 0, i32 0
97 store i32 42, i32* %x, align 4
99 ; WIN32: {{^}}"?foo@C5@@QAE?AUS5@@XZ":
101 ; The address of the return structure is passed as an implicit parameter.
102 ; In the -O0 build, %eax is spilled at the beginning of the function, hence we
103 ; should match both 4(%esp) and 8(%esp).
104 ; WIN32: {{[48]}}(%esp), %eax
105 ; WIN32: movl $42, (%eax)
109 define void @call_foo5() {
111 %c = alloca %class.C5, align 1
112 %s = alloca %struct.S5, align 4
113 call x86_thiscallcc void @"\01?foo@C5@@QAE?AUS5@@XZ"(%struct.S5* sret %s, %class.C5* %c)
114 ; WIN32: {{^}}_call_foo5:
116 ; Load the address of the result and put it onto stack
117 ; (through %ecx in the -O0 build).
118 ; WIN32: leal {{[0-9]+}}(%esp), %e{{[a-d]}}x
119 ; WIN32: movl %e{{[a-d]}}x, (%e{{([a-d]x)|(sp)}})
121 ; The this pointer goes to ECX.
122 ; WIN32-NEXT: leal {{[0-9]+}}(%esp), %ecx
123 ; WIN32-NEXT: calll "?foo@C5@@QAE?AUS5@@XZ"