1; RUN: llc -mtriple mips-unknown-linux-gnu -mattr=+micromips \
2; RUN:     -relocation-model=static -O3 -filetype=obj -o - %s | \
3; RUN:     llvm-readelf -r - | FileCheck %s --check-prefixes=STATIC
4; RUN: llc -mtriple mips-unknown-linux-gnu -mattr=+micromips \
5; RUN:     -relocation-model=pic -O3 -filetype=obj -o - %s | \
6; RUN:     llvm-readelf -r - | FileCheck %s --check-prefixes=PIC
7; RUN: llc -mtriple mips-unknown-linux-gnu -mattr=+micromips \
8; RUN:     -relocation-model=static -O3 -filetype=obj -o - %s | \
9; RUN:     llvm-objdump -s -j .gcc_except_table - | FileCheck %s --check-prefix=EXCEPT-TABLE-STATIC
10; RUN: llc -mtriple mips-unknown-linux-gnu -mattr=+micromips \
11; RUN:     -relocation-model=pic -O3 -filetype=obj -o - %s | \
12; RUN:     llvm-objdump -s -j .gcc_except_table - | FileCheck %s --check-prefix=EXCEPT-TABLE-PIC
13
14; STATIC-LABEL: Relocation section '.rel.eh_frame'
15; STATIC-DAG: R_MIPS_32 00000000 DW.ref.__gxx_personality_v0
16; STATIC-DAG: R_MIPS_32 00000000 .text
17; STATIC-DAG: R_MIPS_32 00000000 .gcc_except_table
18
19; PIC-LABEL: Relocation section '.rel.eh_frame'
20; PIC-DAG: R_MIPS_32   00000000 DW.ref.__gxx_personality_v0
21; PIC-DAG: R_MIPS_PC32
22; PIC-DAG: R_MIPS_32   00000000 .gcc_except_table
23
24; CHECK-READELF: DW.ref.__gxx_personality_v0
25; CHECK-READELF-STATIC-NEXT: R_MIPS_32 00000000 .text
26; CHECK-READELF-PIC-NEXT: R_MIPS_PC32
27; CHECK-READELF-NEXT: .gcc_except_table
28
29; EXCEPT-TABLE-STATIC: 0000 ff9b1501 0c011500 00150e23 01231e00  ...........#.#..
30; EXCEPT-TABLE-STATIC: 0010 00010000 00000000
31; EXCEPT-TABLE-PIC:    0000 ff9b1501 0c012d00 002d133f 013f2a00 ......-..-.?.?*.
32; EXCEPT-TABLE-PIC:    0010 00010000 00000000                    ........
33
34@_ZTIi = external constant i8*
35
36define dso_local i32 @main() local_unnamed_addr personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
37entry:
38  %exception.i = tail call i8* @__cxa_allocate_exception(i32 4) nounwind
39  %0 = bitcast i8* %exception.i to i32*
40  store i32 5, i32* %0, align 16
41  invoke void @__cxa_throw(i8* %exception.i, i8* bitcast (i8** @_ZTIi to i8*), i8* null) noreturn
42          to label %.noexc unwind label %return
43
44.noexc:
45  unreachable
46
47return:
48  %1 = landingpad { i8*, i32 }
49          catch i8* null
50  %2 = extractvalue { i8*, i32 } %1, 0
51  %3 = tail call i8* @__cxa_begin_catch(i8* %2) nounwind
52  tail call void @__cxa_end_catch()
53  ret i32 0
54}
55
56declare i32 @__gxx_personality_v0(...)
57
58declare i8* @__cxa_begin_catch(i8*) local_unnamed_addr
59
60declare void @__cxa_end_catch() local_unnamed_addr
61
62declare i8* @__cxa_allocate_exception(i32) local_unnamed_addr
63
64declare void @__cxa_throw(i8*, i8*, i8*) local_unnamed_addr
65