1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 ; RUN: llc -O0 -mtriple=aarch64-apple-ios -global-isel -stop-after=irtranslator %s -o - | FileCheck %s
4 @_ZTIi = external global ptr
7 declare i32 @__gxx_personality_v0(...)
8 declare i32 @llvm.eh.typeid.for(ptr)
10 define { ptr, i32 } @bar() personality ptr @__gxx_personality_v0 {
11 ; CHECK-LABEL: name: bar
12 ; CHECK: bb.1 (%ir-block.0):
13 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
15 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
16 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(p0) = G_IMPLICIT_DEF
17 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
18 ; CHECK-NEXT: G_INVOKE_REGION_START
19 ; CHECK-NEXT: EH_LABEL <mcsymbol >
20 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
21 ; CHECK-NEXT: $w0 = COPY [[C]](s32)
22 ; CHECK-NEXT: BL @foo, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $w0, implicit-def $w0
23 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
24 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
25 ; CHECK-NEXT: EH_LABEL <mcsymbol >
26 ; CHECK-NEXT: G_BR %bb.3
28 ; CHECK-NEXT: bb.2.broken (landing-pad):
29 ; CHECK-NEXT: liveins: $x0, $x1
31 ; CHECK-NEXT: EH_LABEL <mcsymbol >
32 ; CHECK-NEXT: [[DEF2:%[0-9]+]]:_(s128) = G_IMPLICIT_DEF
33 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x0
34 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY $x1
35 ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY2]](p0)
36 ; CHECK-NEXT: $x0 = COPY [[COPY1]](p0)
37 ; CHECK-NEXT: $w1 = COPY [[PTRTOINT]](s32)
38 ; CHECK-NEXT: RET_ReallyLR implicit $x0, implicit $w1
40 ; CHECK-NEXT: bb.3.continue:
41 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
42 ; CHECK-NEXT: $x0 = COPY [[DEF]](p0)
43 ; CHECK-NEXT: $w1 = COPY [[C1]](s32)
44 ; CHECK-NEXT: RET_ReallyLR implicit $x0, implicit $w1
45 %res32 = invoke i32 @foo(i32 42) to label %continue unwind label %broken
49 %ptr.sel = landingpad { ptr, i32 } catch ptr @_ZTIi
50 ret { ptr, i32 } %ptr.sel
53 %sel.int = tail call i32 @llvm.eh.typeid.for(ptr @_ZTIi)
54 %res.good = insertvalue { ptr, i32 } undef, i32 %sel.int, 1
55 ret { ptr, i32 } %res.good
58 define void @test_invoke_indirect(ptr %callee) personality ptr @__gxx_personality_v0 {
59 ; CHECK-LABEL: name: test_invoke_indirect
60 ; CHECK: bb.1 (%ir-block.0):
61 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
62 ; CHECK-NEXT: liveins: $x0
64 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64(p0) = COPY $x0
65 ; CHECK-NEXT: G_INVOKE_REGION_START
66 ; CHECK-NEXT: EH_LABEL <mcsymbol >
67 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
68 ; CHECK-NEXT: BLR [[COPY]](p0), csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp
69 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
70 ; CHECK-NEXT: EH_LABEL <mcsymbol >
71 ; CHECK-NEXT: G_BR %bb.3
73 ; CHECK-NEXT: bb.2.broken (landing-pad):
74 ; CHECK-NEXT: liveins: $x0, $x1
76 ; CHECK-NEXT: EH_LABEL <mcsymbol >
77 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s128) = G_IMPLICIT_DEF
78 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x0
79 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY $x1
80 ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY2]](p0)
81 ; CHECK-NEXT: RET_ReallyLR
83 ; CHECK-NEXT: bb.3.continue:
84 ; CHECK-NEXT: RET_ReallyLR
85 invoke void %callee() to label %continue unwind label %broken
88 landingpad { ptr, i32 } catch ptr @_ZTIi
95 declare void @printf(ptr, ...)
96 define void @test_invoke_varargs() personality ptr @__gxx_personality_v0 {
97 ; CHECK-LABEL: name: test_invoke_varargs
98 ; CHECK: bb.1 (%ir-block.0):
99 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
101 ; CHECK-NEXT: [[C:%[0-9]+]]:_(p0) = G_CONSTANT i64 0
102 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
103 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_FCONSTANT float 1.000000e+00
104 ; CHECK-NEXT: G_INVOKE_REGION_START
105 ; CHECK-NEXT: EH_LABEL <mcsymbol >
106 ; CHECK-NEXT: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp
107 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $sp
108 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
109 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C3]](s64)
110 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[C1]](s32)
111 ; CHECK-NEXT: G_STORE [[ANYEXT]](s64), [[PTR_ADD]](p0) :: (store (s64) into stack, align 1)
112 ; CHECK-NEXT: [[C4:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
113 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C4]](s64)
114 ; CHECK-NEXT: G_STORE [[C2]](s32), [[PTR_ADD1]](p0) :: (store (s32) into stack + 8, align 1)
115 ; CHECK-NEXT: $x0 = COPY [[C]](p0)
116 ; CHECK-NEXT: BL @printf, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x0
117 ; CHECK-NEXT: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp
118 ; CHECK-NEXT: EH_LABEL <mcsymbol >
119 ; CHECK-NEXT: G_BR %bb.3
121 ; CHECK-NEXT: bb.2.broken (landing-pad):
122 ; CHECK-NEXT: liveins: $x0, $x1
124 ; CHECK-NEXT: EH_LABEL <mcsymbol >
125 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s128) = G_IMPLICIT_DEF
126 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x0
127 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY $x1
128 ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY2]](p0)
129 ; CHECK-NEXT: RET_ReallyLR
131 ; CHECK-NEXT: bb.3.continue:
132 ; CHECK-NEXT: RET_ReallyLR
133 invoke void(ptr, ...) @printf(ptr null, i32 42, float 1.0) to label %continue unwind label %broken
136 landingpad { ptr, i32 } catch ptr @_ZTIi
143 @global_var = external global i32
145 declare void @may_throw()
146 define i32 @test_lpad_phi() personality ptr @__gxx_personality_v0 {
147 ; CHECK-LABEL: name: test_lpad_phi
148 ; CHECK: bb.1 (%ir-block.0):
149 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
151 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
152 ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @global_var
153 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 11
154 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 13
155 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 55
156 ; CHECK-NEXT: G_STORE [[C]](s32), [[GV]](p0) :: (store (s32) into @global_var)
157 ; CHECK-NEXT: G_INVOKE_REGION_START
158 ; CHECK-NEXT: EH_LABEL <mcsymbol >
159 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
160 ; CHECK-NEXT: BL @may_throw, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp
161 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
162 ; CHECK-NEXT: EH_LABEL <mcsymbol >
163 ; CHECK-NEXT: G_BR %bb.3
165 ; CHECK-NEXT: bb.2.lpad (landing-pad):
166 ; CHECK-NEXT: successors: %bb.3(0x80000000)
167 ; CHECK-NEXT: liveins: $x0, $x1
169 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[C1]](s32), %bb.1
170 ; CHECK-NEXT: EH_LABEL <mcsymbol >
171 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s128) = G_IMPLICIT_DEF
172 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
173 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
174 ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY1]](p0)
175 ; CHECK-NEXT: G_STORE [[PHI]](s32), [[GV]](p0) :: (store (s32) into @global_var)
176 ; CHECK-NEXT: G_BR %bb.3
178 ; CHECK-NEXT: bb.3.continue:
179 ; CHECK-NEXT: [[PHI1:%[0-9]+]]:_(s32) = G_PHI [[C2]](s32), %bb.1, [[C3]](s32), %bb.2
180 ; CHECK-NEXT: $w0 = COPY [[PHI1]](s32)
181 ; CHECK-NEXT: RET_ReallyLR implicit $w0
182 store i32 42, ptr @global_var
183 invoke void @may_throw()
184 to label %continue unwind label %lpad
186 lpad: ; preds = %entry
187 %p = phi i32 [ 11, %0 ] ; Trivial, but -O0 keeps it
188 %1 = landingpad { ptr, i32 }
190 store i32 %p, ptr @global_var
193 continue: ; preds = %entry, %lpad
194 %r.0 = phi i32 [ 13, %0 ], [ 55, %lpad ]