xref: /aosp_15_r20/external/llvm/test/CodeGen/ARM/ehabi-handlerdata-nounwind.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Test for handlerdata when the function has landingpad and nounwind.
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; This test case checks whether the handlerdata is generated for the function
4*9880d681SAndroid Build Coastguard Worker; with landingpad instruction, even if the function has "nounwind" atttribute.
5*9880d681SAndroid Build Coastguard Worker;
6*9880d681SAndroid Build Coastguard Worker; For example, although the following function never throws any exception,
7*9880d681SAndroid Build Coastguard Worker; however, it is still required to generate LSDA, otherwise, we can't catch
8*9880d681SAndroid Build Coastguard Worker; the exception properly.
9*9880d681SAndroid Build Coastguard Worker;
10*9880d681SAndroid Build Coastguard Worker; void test1() noexcept {
11*9880d681SAndroid Build Coastguard Worker;   try {
12*9880d681SAndroid Build Coastguard Worker;     throw_exception();
13*9880d681SAndroid Build Coastguard Worker;   } catch (...) {
14*9880d681SAndroid Build Coastguard Worker;   }
15*9880d681SAndroid Build Coastguard Worker; }
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple arm-unknown-linux-gnueabi -filetype=asm -o - %s \
18*9880d681SAndroid Build Coastguard Worker; RUN:   | FileCheck %s
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workerdeclare void @throw_exception()
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerdeclare i32 @__gxx_personality_v0(...)
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workerdeclare i8* @__cxa_begin_catch(i8*)
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Workerdeclare void @__cxa_end_catch()
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerdefine void @test1() nounwind personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
29*9880d681SAndroid Build Coastguard Workerentry:
30*9880d681SAndroid Build Coastguard Worker  invoke void @throw_exception() to label %try.cont unwind label %lpad
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Workerlpad:
33*9880d681SAndroid Build Coastguard Worker  %0 = landingpad { i8*, i32 }
34*9880d681SAndroid Build Coastguard Worker          catch i8* null
35*9880d681SAndroid Build Coastguard Worker  %1 = extractvalue { i8*, i32 } %0, 0
36*9880d681SAndroid Build Coastguard Worker  %2 = tail call i8* @__cxa_begin_catch(i8* %1)
37*9880d681SAndroid Build Coastguard Worker  tail call void @__cxa_end_catch()
38*9880d681SAndroid Build Coastguard Worker  br label %try.cont
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Workertry.cont:
41*9880d681SAndroid Build Coastguard Worker  ret void
42*9880d681SAndroid Build Coastguard Worker}
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Worker; CHECK:   .globl test1
45*9880d681SAndroid Build Coastguard Worker; CHECK:   .p2align 2
46*9880d681SAndroid Build Coastguard Worker; CHECK:   .type test1,%function
47*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test1:
48*9880d681SAndroid Build Coastguard Worker; CHECK:   .fnstart
49*9880d681SAndroid Build Coastguard Worker
50*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: .cantunwind
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Worker; CHECK:   .personality __gxx_personality_v0
53*9880d681SAndroid Build Coastguard Worker; CHECK:   .handlerdata
54*9880d681SAndroid Build Coastguard Worker; CHECK:   .p2align 2
55*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: GCC_except_table0:
56*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: .Lexception0:
57*9880d681SAndroid Build Coastguard Worker; CHECK:   .byte 255                     @ @LPStart Encoding = omit
58*9880d681SAndroid Build Coastguard Worker; CHECK:   .byte 0                       @ @TType Encoding = absptr
59*9880d681SAndroid Build Coastguard Worker; CHECK:   .asciz
60*9880d681SAndroid Build Coastguard Worker; CHECK:   .byte 3                       @ Call site Encoding = udata4
61*9880d681SAndroid Build Coastguard Worker; CHECK:   .fnend
62