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