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