1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 ; RUN: llc -O0 -mtriple=aarch64-apple-ios -verify-machineinstrs -global-isel -stop-after=legalizer %s -o - | FileCheck %s
4 @_ZTIi = external global ptr
7 declare i32 @__gxx_personality_v0(...)
8 declare i32 @llvm.eh.typeid.for(ptr)
9 declare void @_Unwind_Resume(ptr)
11 define void @bar() personality ptr @__gxx_personality_v0 {
12 ; CHECK-LABEL: name: bar
13 ; CHECK: bb.1 (%ir-block.0):
14 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
16 ; CHECK-NEXT: G_INVOKE_REGION_START
17 ; CHECK-NEXT: EH_LABEL <mcsymbol >
18 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
19 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
20 ; CHECK-NEXT: $w0 = COPY [[C]](s32)
21 ; CHECK-NEXT: BL @foo, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $w0, implicit-def $w0
22 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
23 ; CHECK-NEXT: EH_LABEL <mcsymbol >
24 ; CHECK-NEXT: G_BR %bb.3
26 ; CHECK-NEXT: bb.2.cleanup (landing-pad):
27 ; CHECK-NEXT: successors: %bb.4(0x80000000)
28 ; CHECK-NEXT: liveins: $x0, $x1
30 ; CHECK-NEXT: EH_LABEL <mcsymbol >
31 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
32 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
33 ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0)
34 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[PTRTOINT]](s64)
35 ; CHECK-NEXT: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.exn.slot
36 ; CHECK-NEXT: G_STORE [[COPY]](p0), [[FRAME_INDEX]](p0) :: (store (p0) into %ir.exn.slot)
37 ; CHECK-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.1.ehselector.slot
38 ; CHECK-NEXT: G_STORE [[TRUNC]](s32), [[FRAME_INDEX1]](p0) :: (store (s32) into %ir.ehselector.slot)
39 ; CHECK-NEXT: G_BR %bb.4
41 ; CHECK-NEXT: bb.3.continue:
42 ; CHECK-NEXT: RET_ReallyLR
44 ; CHECK-NEXT: bb.4.eh.resume:
45 ; CHECK-NEXT: [[FRAME_INDEX2:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.exn.slot
46 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX2]](p0) :: (dereferenceable load (p0) from %ir.exn.slot)
47 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
48 ; CHECK-NEXT: $x0 = COPY [[LOAD]](p0)
49 ; CHECK-NEXT: BL @_Unwind_Resume, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x0
50 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
51 ; CHECK-NEXT: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.trap)
52 %exn.slot = alloca ptr
53 %ehselector.slot = alloca i32
54 %1 = invoke i32 @foo(i32 42) to label %continue unwind label %cleanup
57 %2 = landingpad { ptr, i32 } cleanup
58 %3 = extractvalue { ptr, i32 } %2, 0
59 store ptr %3, ptr %exn.slot, align 8
60 %4 = extractvalue { ptr, i32 } %2, 1
61 store i32 %4, ptr %ehselector.slot, align 4
68 %exn = load ptr, ptr %exn.slot, align 8
69 call void @_Unwind_Resume(ptr %exn)