Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 1 | ; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -o - %s | FileCheck %s |
Christian Pirker | 99974c7 | 2014-03-26 14:57:32 +0000 | [diff] [blame] | 2 | ; RUN: llc -mtriple=aarch64_be-none-linux-gnu -relocation-model=pic -o - %s | FileCheck %s |
Tim Northover | 3ec1de7 | 2014-04-16 11:52:55 +0000 | [diff] [blame^] | 3 | ; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic -o - %s | FileCheck %s |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 4 | |
| 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 Northover | 3ec1de7 | 2014-04-16 11:52:55 +0000 | [diff] [blame^] | 15 | ; CHECK: [[TYPEINFO_LBL:.Ltmp[0-9]+]]: // TypeInfo 1 |
| 16 | ; CHECK-NEXT: .xword .L_ZTIi.DW.stub-[[TYPEINFO_LBL]] |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 17 | |
| 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 | |
| 25 | define i32 @_Z3barv() { |
| 26 | entry: |
| 27 | invoke void @_Z3foov() |
| 28 | to label %return unwind label %lpad |
| 29 | |
| 30 | lpad: ; 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 | |
| 38 | catch: ; 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 | |
| 46 | return: ; preds = %entry, %catch |
| 47 | %retval.0 = phi i32 [ %exn.scalar, %catch ], [ 42, %entry ] |
| 48 | ret i32 %retval.0 |
| 49 | |
| 50 | eh.resume: ; preds = %lpad |
| 51 | resume { i8*, i32 } %0 |
| 52 | } |
| 53 | |
| 54 | declare void @_Z3foov() |
| 55 | |
| 56 | declare i32 @__gxx_personality_v0(...) |
| 57 | |
| 58 | declare i32 @llvm.eh.typeid.for(i8*) nounwind readnone |
| 59 | |
| 60 | declare i8* @__cxa_begin_catch(i8*) |
| 61 | |
Stephen Lin | f799e3f | 2013-07-13 20:38:47 +0000 | [diff] [blame] | 62 | declare void @__cxa_end_catch() |