[ms-inline asm] Add back-end test case for r166632. Make sure we emit the
[oota-llvm.git] / test / CodeGen / X86 / thiscall-struct-return.ll
1 ; RUN: llc < %s -mtriple=i386-PC-Win32 | FileCheck %s
2
3 %class.C = type { i8 }
4 %struct.S = type { i32 }
5 %struct.M = type { i32, i32 }
6
7 declare void @_ZN1CC1Ev(%class.C* %this) unnamed_addr nounwind align 2
8 declare x86_thiscallcc void @_ZNK1C5SmallEv(%struct.S* noalias sret %agg.result, %class.C* %this) nounwind align 2
9 declare x86_thiscallcc void @_ZNK1C6MediumEv(%struct.M* noalias sret %agg.result, %class.C* %this) nounwind align 2
10
11 define void @testv() nounwind {
12 ; CHECK: testv:
13 ; CHECK: leal 16(%esp), %esi
14 ; CHECK-NEXT: movl      %esi, (%esp)
15 ; CHECK-NEXT: calll _ZN1CC1Ev
16 ; CHECK: leal 8(%esp), %eax
17 ; CHECK-NEXT: movl %esi, %ecx
18 ; CHECK-NEXT: calll _ZNK1C5SmallEv
19 entry:
20   %c = alloca %class.C, align 1
21   %tmp = alloca %struct.S, align 4
22   call void @_ZN1CC1Ev(%class.C* %c)
23   ; This call should put the return structure as a pointer
24   ; into EAX instead of returning directly in EAX.  The this
25   ; pointer should go into ECX
26   call x86_thiscallcc void @_ZNK1C5SmallEv(%struct.S* sret %tmp, %class.C* %c)
27   ret void
28 }
29
30 define void @test2v() nounwind {
31 ; CHECK: test2v:
32 ; CHECK: leal 16(%esp), %esi
33 ; CHECK-NEXT: movl      %esi, (%esp)
34 ; CHECK-NEXT: calll _ZN1CC1Ev
35 ; CHECK: leal 8(%esp), %eax
36 ; CHECK-NEXT: movl %esi, %ecx
37 ; CHECK-NEXT: calll _ZNK1C6MediumEv
38 entry:
39   %c = alloca %class.C, align 1
40   %tmp = alloca %struct.M, align 4
41   call void @_ZN1CC1Ev(%class.C* %c)
42   ; This call should put the return structure as a pointer
43   ; into EAX instead of returning directly in EAX/EDX.  The this
44   ; pointer should go into ECX
45   call x86_thiscallcc void @_ZNK1C6MediumEv(%struct.M* sret %tmp, %class.C* %c)
46   ret void
47 }