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