1 ; RUN: llc < %s -mtriple=armv6-linux-gnueabi | FileCheck %s -check-prefix=CHECKELF
2 ; RUN: llc < %s -mtriple=thumbv7-apple-ios5.0 | FileCheck %s -check-prefix=CHECKT2D
4 %struct.A = type { i8 }
5 %struct.B = type { i32 }
6 %struct.C = type { %struct.B }
7 %struct.D = type { %struct.B }
8 %struct.E = type { %struct.B, %struct.B }
10 declare ptr @A_ctor_base(ptr returned)
11 declare ptr @B_ctor_base(ptr returned, i32)
12 declare ptr @B_ctor_complete(ptr returned, i32)
14 declare ptr @A_ctor_base_nothisret(ptr)
15 declare ptr @B_ctor_base_nothisret(ptr, i32)
16 declare ptr @B_ctor_complete_nothisret(ptr, i32)
18 define ptr @C_ctor_base(ptr returned %this, i32 %x) {
20 ; CHECKELF-LABEL: C_ctor_base:
21 ; CHECKELF-NOT: mov {{r[0-9]+}}, r0
22 ; CHECKELF: bl A_ctor_base
23 ; CHECKELF-NOT: mov r0, {{r[0-9]+}}
24 ; CHECKELF: b B_ctor_base
25 ; CHECKT2D-LABEL: C_ctor_base:
26 ; CHECKT2D-NOT: mov {{r[0-9]+}}, r0
27 ; CHECKT2D: bl _A_ctor_base
28 ; CHECKT2D-NOT: mov r0, {{r[0-9]+}}
29 ; CHECKT2D: b.w _B_ctor_base
30 %call = tail call ptr @A_ctor_base(ptr returned %this)
31 %call2 = tail call ptr @B_ctor_base(ptr returned %this, i32 %x)
35 define ptr @C_ctor_base_nothisret(ptr %this, i32 %x) {
37 ; CHECKELF-LABEL: C_ctor_base_nothisret:
38 ; CHECKELF: mov [[SAVETHIS:r[0-9]+]], r0
39 ; CHECKELF: bl A_ctor_base_nothisret
40 ; CHECKELF: mov r0, [[SAVETHIS]]
41 ; CHECKELF-NOT: b B_ctor_base_nothisret
42 ; CHECKT2D-LABEL: C_ctor_base_nothisret:
43 ; CHECKT2D: mov [[SAVETHIS:r[0-9]+]], r0
44 ; CHECKT2D: bl _A_ctor_base_nothisret
45 ; CHECKT2D: mov r0, [[SAVETHIS]]
46 ; CHECKT2D-NOT: b.w _B_ctor_base_nothisret
47 %call = tail call ptr @A_ctor_base_nothisret(ptr %this)
48 %call2 = tail call ptr @B_ctor_base_nothisret(ptr %this, i32 %x)
52 define ptr @C_ctor_complete(ptr %this, i32 %x) {
54 ; CHECKELF-LABEL: C_ctor_complete:
55 ; CHECKELF: b C_ctor_base
56 ; CHECKT2D-LABEL: C_ctor_complete:
57 ; CHECKT2D: b.w _C_ctor_base
58 %call = tail call ptr @C_ctor_base(ptr returned %this, i32 %x)
62 define ptr @C_ctor_complete_nothisret(ptr %this, i32 %x) {
64 ; CHECKELF-LABEL: C_ctor_complete_nothisret:
65 ; CHECKELF-NOT: b C_ctor_base_nothisret
66 ; CHECKT2D-LABEL: C_ctor_complete_nothisret:
67 ; CHECKT2D-NOT: b.w _C_ctor_base_nothisret
68 %call = tail call ptr @C_ctor_base_nothisret(ptr %this, i32 %x)
72 define ptr @D_ctor_base(ptr %this, i32 %x) {
74 ; CHECKELF-LABEL: D_ctor_base:
75 ; CHECKELF-NOT: mov {{r[0-9]+}}, r0
76 ; CHECKELF: bl B_ctor_complete
77 ; CHECKELF-NOT: mov r0, {{r[0-9]+}}
78 ; CHECKELF: b B_ctor_complete
79 ; CHECKT2D-LABEL: D_ctor_base:
80 ; CHECKT2D-NOT: mov {{r[0-9]+}}, r0
81 ; CHECKT2D: bl _B_ctor_complete
82 ; CHECKT2D-NOT: mov r0, {{r[0-9]+}}
83 ; CHECKT2D: b.w _B_ctor_complete
84 %call = tail call ptr @B_ctor_complete(ptr returned %this, i32 %x)
85 %call2 = tail call ptr @B_ctor_complete(ptr returned %this, i32 %x)
89 define ptr @E_ctor_base(ptr %this, i32 %x) {
91 ; CHECKELF-LABEL: E_ctor_base:
92 ; CHECKELF-NOT: b B_ctor_complete
93 ; CHECKT2D-LABEL: E_ctor_base:
94 ; CHECKT2D-NOT: b.w _B_ctor_complete
95 %call = tail call ptr @B_ctor_complete(ptr returned %this, i32 %x)
96 %b2 = getelementptr inbounds %struct.E, ptr %this, i32 0, i32 1
97 %call2 = tail call ptr @B_ctor_complete(ptr returned %b2, i32 %x)