1; RUN: llc -O0 -mtriple=aarch64-apple-ios -verify-machineinstrs -global-isel -stop-after=legalizer %s -o - | FileCheck %s
2
3@_ZTIi = external global i8*
4
5declare i32 @foo(i32)
6declare i32 @__gxx_personality_v0(...)
7declare i32 @llvm.eh.typeid.for(i8*)
8declare void @_Unwind_Resume(i8*)
9
10; CHECK: name: bar
11; CHECK: body:
12; CHECK-NEXT:   bb.1 (%ir-block.0):
13; CHECK:     successors: %{{bb.[0-9]+.*}}%[[LP:bb.[0-9]+]]
14
15; CHECK:   [[LP]].{{[a-z]+}} (landing-pad):
16; CHECK:     EH_LABEL
17
18; CHECK:     [[PTR:%[0-9]+]]:_(p0) = COPY $x0
19; CHECK:     [[SEL_PTR:%[0-9]+]]:_(p0) = COPY $x1
20; CHECK:     [[SEL_PTR_INT:%[0-9]+]]:_(s32) = G_PTRTOINT [[SEL_PTR]](p0)
21; CHECK:     G_STORE [[PTR]](p0), %0(p0) :: (store 8 into %ir.exn.slot)
22; CHECK:     G_STORE [[SEL_PTR_INT]](s32), %1(p0) :: (store 4 into %ir.ehselector.slot)
23
24define void @bar() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
25  %exn.slot = alloca i8*
26  %ehselector.slot = alloca i32
27  %1 = invoke i32 @foo(i32 42) to label %continue unwind label %cleanup
28
29cleanup:
30  %2 = landingpad { i8*, i32 } cleanup
31  %3 = extractvalue { i8*, i32 } %2, 0
32  store i8* %3, i8** %exn.slot, align 8
33  %4 = extractvalue { i8*, i32 } %2, 1
34  store i32 %4, i32* %ehselector.slot, align 4
35  br label %eh.resume
36
37continue:
38  ret void
39
40eh.resume:
41  %exn = load i8*, i8** %exn.slot, align 8
42  call void @_Unwind_Resume(i8* %exn)
43  unreachable
44}
45