Home | History | Annotate | Download | only in AArch64
      1 ; 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
     13 ; CHECK: .Ltmp9:
     14 ; CHECK-NEXT: .xword  .L_ZTIi.DW.stub-.Ltmp9
     15 
     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 
     23 define i32 @_Z3barv() {
     24 entry:
     25   invoke void @_Z3foov()
     26           to label %return unwind label %lpad
     27 
     28 lpad:                                             ; 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 
     36 catch:                                            ; 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 
     44 return:                                           ; preds = %entry, %catch
     45   %retval.0 = phi i32 [ %exn.scalar, %catch ], [ 42, %entry ]
     46   ret i32 %retval.0
     47 
     48 eh.resume:                                        ; preds = %lpad
     49   resume { i8*, i32 } %0
     50 }
     51 
     52 declare void @_Z3foov()
     53 
     54 declare i32 @__gxx_personality_v0(...)
     55 
     56 declare i32 @llvm.eh.typeid.for(i8*) nounwind readnone
     57 
     58 declare i8* @__cxa_begin_catch(i8*)
     59 
     60 declare void @__cxa_end_catch()
     61