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