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_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: [[ZERO:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
63 ; CHECK: [[NULL:%[0-9]+]]:_(p0) = G_INTTOPTR [[ZERO]]
64 ; CHECK: [[ANSWER:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
65 ; CHECK: [[ONE:%[0-9]+]]:_(s32) = G_FCONSTANT float 1.0
67 ; CHECK: $x0 = COPY [[NULL]]
69 ; CHECK: [[SP:%[0-9]+]]:_(p0) = COPY $sp
70 ; CHECK: [[OFFSET:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
71 ; CHECK: [[SLOT:%[0-9]+]]:_(p0) = G_GEP [[SP]], [[OFFSET]](s64)
72 ; CHECK: [[ANSWER_EXT:%[0-9]+]]:_(s64) = G_ANYEXT [[ANSWER]]
73 ; CHECK: G_STORE [[ANSWER_EXT]](s64), [[SLOT]]
75 ; CHECK: [[SP:%[0-9]+]]:_(p0) = COPY $sp
76 ; CHECK: [[OFFSET:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
77 ; CHECK: [[SLOT:%[0-9]+]]:_(p0) = G_GEP [[SP]], [[OFFSET]](s64)
78 ; CHECK: G_STORE [[ONE]](s32), [[SLOT]]
81 declare void @printf(i8*, ...)
82 define void @test_invoke_varargs() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
83 invoke void(i8*, ...) @printf(i8* null, i32 42, float 1.0) to label %continue unwind label %broken
86 landingpad { i8*, i32 } catch i8* bitcast(i8** @_ZTIi to i8*)