blob: c87b2e7284257772e778901109b3a0504e172658 [file] [log] [blame]
Tim Northovere0e3aef2013-01-31 12:12:40 +00001; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -o - %s | FileCheck %s
2
3; Make sure exception-handling PIC code can be linked correctly. An alternative
4; to the sequence described below would have .gcc_except_table itself writable
5; and not use the indirection, but this isn't what LLVM does right now.
6
7 ; There should be a read-only .gcc_except_table section...
8; CHECK: .section .gcc_except_table,"a"
9
10 ; ... referring indirectly to stubs for its typeinfo ...
11; CHECK: // @TType Encoding = indirect pcrel sdata8
12 ; ... one of which is "int"'s typeinfo
Rafael Espindolab1f25f12014-03-07 06:08:31 +000013; CHECK: .Ltmp7:
14; CHECK-NEXT: .xword .L_ZTIi.DW.stub-.Ltmp7
Tim Northovere0e3aef2013-01-31 12:12:40 +000015
16 ; .. and which is properly defined (in a writable section for the dynamic loader) later.
17; CHECK: .section .data.rel,"aw"
18; CHECK: .L_ZTIi.DW.stub:
19; CHECK-NEXT: .xword _ZTIi
20
21@_ZTIi = external constant i8*
22
23define i32 @_Z3barv() {
24entry:
25 invoke void @_Z3foov()
26 to label %return unwind label %lpad
27
28lpad: ; preds = %entry
29 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
30 catch i8* bitcast (i8** @_ZTIi to i8*)
31 %1 = extractvalue { i8*, i32 } %0, 1
32 %2 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) nounwind
33 %matches = icmp eq i32 %1, %2
34 br i1 %matches, label %catch, label %eh.resume
35
36catch: ; preds = %lpad
37 %3 = extractvalue { i8*, i32 } %0, 0
38 %4 = tail call i8* @__cxa_begin_catch(i8* %3) nounwind
39 %5 = bitcast i8* %4 to i32*
40 %exn.scalar = load i32* %5, align 4
41 tail call void @__cxa_end_catch() nounwind
42 br label %return
43
44return: ; preds = %entry, %catch
45 %retval.0 = phi i32 [ %exn.scalar, %catch ], [ 42, %entry ]
46 ret i32 %retval.0
47
48eh.resume: ; preds = %lpad
49 resume { i8*, i32 } %0
50}
51
52declare void @_Z3foov()
53
54declare i32 @__gxx_personality_v0(...)
55
56declare i32 @llvm.eh.typeid.for(i8*) nounwind readnone
57
58declare i8* @__cxa_begin_catch(i8*)
59
Stephen Linf799e3f2013-07-13 20:38:47 +000060declare void @__cxa_end_catch()