1 ; RUN: llc -O0 -mtriple=aarch64-apple-ios -global-isel -stop-after=irtranslator %s -o - | FileCheck %s
3 @_ZTIi = external global i8*
6 declare i32 @__gxx_personality_v0(...)
7 declare i32 @llvm.eh.typeid.for(i8*)
9 ; CHECK-LABEL: name: bar
11 ; CHECK-NEXT: bb.1 (%ir-block.0):
12 ; CHECK: successors: %[[GOOD:bb.[0-9]+]]{{.*}}%[[BAD:bb.[0-9]+]]
15 ; CHECK: BL @foo, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $w0, implicit-def $w0
16 ; CHECK: {{%[0-9]+}}:_(s32) = COPY $w0
18 ; CHECK: G_BR %[[GOOD]]
20 ; CHECK: [[BAD]].{{[a-z]+}} (landing-pad):
22 ; CHECK: [[PTR_RET:%[0-9]+]]:_(p0) = COPY $x0
23 ; CHECK: [[SEL_PTR:%[0-9]+]]:_(p0) = COPY $x1
24 ; CHECK: [[SEL_RET:%[0-9]+]]:_(s32) = G_PTRTOINT [[SEL_PTR]]
25 ; CHECK: $x0 = COPY [[PTR_RET]]
26 ; CHECK: $w1 = COPY [[SEL_RET]]
28 ; CHECK: [[GOOD]].{{[a-z]+}}:
29 ; CHECK: [[SEL:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
30 ; CHECK: $w1 = COPY [[SEL]]
32 define { i8*, i32 } @bar() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
33 %res32 = invoke i32 @foo(i32 42) to label %continue unwind label %broken
37 %ptr.sel = landingpad { i8*, i32 } catch i8* bitcast(i8** @_ZTIi to i8*)
38 ret { i8*, i32 } %ptr.sel
41 %sel.int = tail call i32 @llvm.eh.typeid.for(i8* bitcast(i8** @_ZTIi to i8*))
42 %res.good = insertvalue { i8*, i32 } undef, i32 %sel.int, 1
43 ret { i8*, i32 } %res.good
46 ; CHECK-LABEL: name: test_invoke_indirect
47 ; CHECK: [[CALLEE:%[0-9]+]]:gpr64(p0) = COPY $x0
48 ; CHECK: BLR [[CALLEE]]
49 define void @test_invoke_indirect(void()* %callee) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
50 invoke void %callee() to label %continue unwind label %broken
53 landingpad { i8*, i32 } catch i8* bitcast(i8** @_ZTIi to i8*)
60 ; CHECK-LABEL: name: test_invoke_varargs
62 ; CHECK: [[NULL:%[0-9]+]]:_(p0) = G_CONSTANT i64 0
63 ; CHECK: [[ANSWER:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
64 ; CHECK: [[ONE:%[0-9]+]]:_(s32) = G_FCONSTANT float 1.0
66 ; CHECK: $x0 = COPY [[NULL]]
68 ; CHECK: [[SP:%[0-9]+]]:_(p0) = COPY $sp
69 ; CHECK: [[OFFSET:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
70 ; CHECK: [[SLOT:%[0-9]+]]:_(p0) = G_PTR_ADD [[SP]], [[OFFSET]](s64)
71 ; CHECK: [[ANSWER_EXT:%[0-9]+]]:_(s64) = G_ANYEXT [[ANSWER]]
72 ; CHECK: G_STORE [[ANSWER_EXT]](s64), [[SLOT]]
74 ; CHECK: [[OFFSET:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
75 ; CHECK: [[SLOT:%[0-9]+]]:_(p0) = G_PTR_ADD [[SP]], [[OFFSET]](s64)
76 ; CHECK: G_STORE [[ONE]](s32), [[SLOT]]
79 declare void @printf(i8*, ...)
80 define void @test_invoke_varargs() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
81 invoke void(i8*, ...) @printf(i8* null, i32 42, float 1.0) to label %continue unwind label %broken
84 landingpad { i8*, i32 } catch i8* bitcast(i8** @_ZTIi to i8*)
91 ; CHECK-LABEL: name: test_lpad_phi
93 ; CHECK-NEXT: bb.1 (%ir-block.0):
94 ; CHECK: successors: %[[GOOD:bb.[0-9]+]]{{.*}}%[[BAD:bb.[0-9]+]]
95 ; CHECK: [[ELEVEN:%[0-9]+]]:_(s32) = G_CONSTANT i32 11
97 ; CHECK: BL @may_throw, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp
99 ; CHECK: G_BR %[[GOOD]]
101 ; CHECK: [[BAD]].{{[a-z]+}} (landing-pad):
102 ; CHECK: [[PHI_ELEVEN:%[0-9]+]]:_(s32) = G_PHI [[ELEVEN]](s32), %bb.1
104 ; CHECK: G_STORE [[PHI_ELEVEN]](s32), {{%[0-9]+}}(p0) :: (store (s32) into @global_var)
106 ; CHECK: [[GOOD]].{{[a-z]+}}:
107 ; CHECK: [[SEL:%[0-9]+]]:_(s32) = G_PHI
108 ; CHECK: $w0 = COPY [[SEL]]
110 @global_var = external global i32
112 declare void @may_throw()
113 define i32 @test_lpad_phi() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
114 store i32 42, i32* @global_var
115 invoke void @may_throw()
116 to label %continue unwind label %lpad
118 lpad: ; preds = %entry
119 %p = phi i32 [ 11, %0 ] ; Trivial, but -O0 keeps it
120 %1 = landingpad { i8*, i32 }
122 store i32 %p, i32* @global_var
125 continue: ; preds = %entry, %lpad
126 %r.0 = phi i32 [ 13, %0 ], [ 55, %lpad ]