1 ; RUN: llc < %s -mtriple=x86_64-pc-win32 | FileCheck %s
3 %struct.A = type { i8 }
4 %struct.B = type { i32 }
5 %struct.C = type { %struct.B }
6 %struct.D = type { %struct.B }
7 %struct.E = type { %struct.B }
9 declare %struct.A* @A_ctor(%struct.A* returned)
10 declare %struct.B* @B_ctor(%struct.B* returned, i32)
12 declare %struct.A* @A_ctor_nothisret(%struct.A*)
13 declare %struct.B* @B_ctor_nothisret(%struct.B*, i32)
15 define %struct.C* @C_ctor(%struct.C* %this, i32 %y) {
17 ; CHECK-LABEL: C_ctor:
18 ; CHECK: jmp B_ctor # TAILCALL
19 %0 = getelementptr inbounds %struct.C, %struct.C* %this, i64 0, i32 0
20 %call = tail call %struct.B* @B_ctor(%struct.B* %0, i32 %y)
24 define %struct.C* @C_ctor_nothisret(%struct.C* %this, i32 %y) {
26 ; CHECK-LABEL: C_ctor_nothisret:
27 ; CHECK-NOT: jmp B_ctor_nothisret
28 %0 = getelementptr inbounds %struct.C, %struct.C* %this, i64 0, i32 0
29 %call = tail call %struct.B* @B_ctor_nothisret(%struct.B* %0, i32 %y)
33 define %struct.D* @D_ctor(%struct.D* %this, i32 %y) {
35 ; CHECK-LABEL: D_ctor:
36 ; CHECK: movq %rcx, [[SAVETHIS:%r[0-9a-z]+]]
38 ; CHECK: movq [[SAVETHIS]], %rcx
39 ; CHECK: jmp B_ctor # TAILCALL
40 %0 = bitcast %struct.D* %this to %struct.A*
41 %call = tail call %struct.A* @A_ctor(%struct.A* %0)
42 %1 = getelementptr inbounds %struct.D, %struct.D* %this, i64 0, i32 0
43 %call2 = tail call %struct.B* @B_ctor(%struct.B* %1, i32 %y)
44 ; (this next line would never be generated by Clang, actually)
45 %2 = bitcast %struct.A* %call to %struct.D*
49 define %struct.D* @D_ctor_nothisret(%struct.D* %this, i32 %y) {
51 ; CHECK-LABEL: D_ctor_nothisret:
52 ; CHECK: movq %rcx, [[SAVETHIS:%r[0-9a-z]+]]
53 ; CHECK: callq A_ctor_nothisret
54 ; CHECK: movq [[SAVETHIS]], %rcx
55 ; CHECK-NOT: jmp B_ctor_nothisret
56 %0 = bitcast %struct.D* %this to %struct.A*
57 %call = tail call %struct.A* @A_ctor_nothisret(%struct.A* %0)
58 %1 = getelementptr inbounds %struct.D, %struct.D* %this, i64 0, i32 0
59 %call2 = tail call %struct.B* @B_ctor_nothisret(%struct.B* %1, i32 %y)
60 ; (this next line would never be generated by Clang, actually)
61 %2 = bitcast %struct.A* %call to %struct.D*
65 define %struct.E* @E_ctor(%struct.E* %this, i32 %x) {
67 ; CHECK-LABEL: E_ctor:
68 ; CHECK: movq %rcx, [[SAVETHIS:%r[0-9a-z]+]]
70 ; CHECK: movq [[SAVETHIS]], %rcx
71 ; CHECK: jmp B_ctor # TAILCALL
72 %b = getelementptr inbounds %struct.E, %struct.E* %this, i64 0, i32 0
73 %call = tail call %struct.B* @B_ctor(%struct.B* %b, i32 %x)
74 %call4 = tail call %struct.B* @B_ctor(%struct.B* %b, i32 %x)
78 define %struct.E* @E_ctor_nothisret(%struct.E* %this, i32 %x) {
80 ; CHECK-LABEL: E_ctor_nothisret:
81 ; CHECK: movq %rcx, [[SAVETHIS:%r[0-9a-z]+]]
82 ; CHECK: callq B_ctor_nothisret
83 ; CHECK: movq [[SAVETHIS]], %rcx
84 ; CHECK-NOT: jmp B_ctor_nothisret
85 %b = getelementptr inbounds %struct.E, %struct.E* %this, i64 0, i32 0
86 %call = tail call %struct.B* @B_ctor_nothisret(%struct.B* %b, i32 %x)
87 %call4 = tail call %struct.B* @B_ctor_nothisret(%struct.B* %b, i32 %x)