xref: /llvm-project/llvm/test/CodeGen/ARM/this-return.ll (revision bed1c7f061aa12417aa081e334afdba45767b938)
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
3
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 }
9
10declare ptr @A_ctor_base(ptr returned)
11declare ptr @B_ctor_base(ptr returned, i32)
12declare ptr @B_ctor_complete(ptr returned, i32)
13
14declare ptr @A_ctor_base_nothisret(ptr)
15declare ptr @B_ctor_base_nothisret(ptr, i32)
16declare ptr @B_ctor_complete_nothisret(ptr, i32)
17
18define ptr @C_ctor_base(ptr returned %this, i32 %x) {
19entry:
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)
32  ret ptr %this
33}
34
35define ptr @C_ctor_base_nothisret(ptr %this, i32 %x) {
36entry:
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)
49  ret ptr %this
50}
51
52define ptr @C_ctor_complete(ptr %this, i32 %x) {
53entry:
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)
59  ret ptr %this
60}
61
62define ptr @C_ctor_complete_nothisret(ptr %this, i32 %x) {
63entry:
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)
69  ret ptr %this
70}
71
72define ptr @D_ctor_base(ptr %this, i32 %x) {
73entry:
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)
86  ret ptr %this
87}
88
89define ptr @E_ctor_base(ptr %this, i32 %x) {
90entry:
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)
98  ret ptr %this
99}
100