Allow using normal .eh_frame based unwinding on ARM. Use the same

encodings as x86. Use this exception model for NetBSD.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208166 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Joerg Sonnenberger 2014-05-07 07:49:34 +00:00
parent 8a25ee1440
commit 2ecdcdc026
5 changed files with 307 additions and 1 deletions

View File

@ -260,6 +260,10 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
}
switch (T.getArch()) {
case Triple::arm:
case Triple::armeb:
case Triple::thumb:
case Triple::thumbeb:
case Triple::x86:
PersonalityEncoding = (RelocM == Reloc::PIC_)
? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4

View File

@ -11,6 +11,7 @@
#include "ARMSubtarget.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/Mangler.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSectionELF.h"
@ -45,6 +46,10 @@ const MCExpr *ARMElfTargetObjectFile::getTTypeGlobalReference(
const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
const TargetMachine &TM, MachineModuleInfo *MMI,
MCStreamer &Streamer) const {
if (TM.getMCAsmInfo()->getExceptionHandlingType() != ExceptionHandling::ARM)
return TargetLoweringObjectFileELF::getTTypeGlobalReference(
GV, Encoding, Mang, TM, MMI, Streamer);
assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only");
return MCSymbolRefExpr::Create(TM.getSymbol(GV, Mang),

View File

@ -59,7 +59,14 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo(StringRef TT) {
SupportsDebugInformation = true;
// Exceptions handling
ExceptionsType = ExceptionHandling::ARM;
switch (TheTriple.getOS()) {
case Triple::NetBSD:
ExceptionsType = ExceptionHandling::DwarfCFI;
break;
default:
ExceptionsType = ExceptionHandling::ARM;
break;
}
// foo(plt) instead of foo@plt
UseParensForSymbolVariant = true;

View File

@ -0,0 +1,71 @@
; RUN: llc -mtriple=arm-netbsd-eabi -o - -filetype=asm %s | \
; RUN: FileCheck %s
; RUN: llc -mtriple=arm-netbsd-eabi -o - -filetype=asm %s \
; RUN: -relocation-model=pic | FileCheck -check-prefix=CHECK-PIC %s
; ModuleID = 'test.cc'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S64"
target triple = "armv5e--netbsd-eabi"
%struct.exception = type { i8 }
@_ZTVN10__cxxabiv117__class_type_infoE = external global i8*
@_ZTS9exception = linkonce_odr constant [11 x i8] c"9exception\00"
@_ZTI9exception = linkonce_odr unnamed_addr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8** @_ZTVN10__cxxabiv117__class_type_infoE, i32 2) to i8*), i8* getelementptr inbounds ([11 x i8]* @_ZTS9exception, i32 0, i32 0) }
define void @f() uwtable {
%1 = alloca i8*
%2 = alloca i32
%e = alloca %struct.exception*, align 4
invoke void @g()
to label %3 unwind label %4
br label %16
%5 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
catch i8* bitcast ({ i8*, i8* }* @_ZTI9exception to i8*)
%6 = extractvalue { i8*, i32 } %5, 0
store i8* %6, i8** %1
%7 = extractvalue { i8*, i32 } %5, 1
store i32 %7, i32* %2
br label %8
%9 = load i32* %2
%10 = call i32 @llvm.eh.typeid.for(i8* bitcast ({ i8*, i8* }* @_ZTI9exception to i8*)) nounwind
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %17
%13 = load i8** %1
%14 = call i8* @__cxa_begin_catch(i8* %13) #3
%15 = bitcast i8* %14 to %struct.exception*
store %struct.exception* %15, %struct.exception** %e
call void @__cxa_end_catch()
br label %16
ret void
%18 = load i8** %1
%19 = load i32* %2
%20 = insertvalue { i8*, i32 } undef, i8* %18, 0
%21 = insertvalue { i8*, i32 } %20, i32 %19, 1
resume { i8*, i32 } %21
}
declare void @g()
declare i32 @__gxx_personality_v0(...)
declare i32 @llvm.eh.typeid.for(i8*) nounwind readnone
declare i8* @__cxa_begin_catch(i8*)
declare void @__cxa_end_catch()
; CHECK: .cfi_personality 0,
; CHECK: .cfi_lsda 0,
; CHECK: @TType Encoding = absptr
; CHECK: @ Call site Encoding = udata4
; CHECK-PIC: .cfi_personality 155,
; CHECK-PIC: .cfi_lsda 27,
; CHECK-PIC: @TType Encoding = indirect pcrel sdata4
; CHECK-PIC: @ Call site Encoding = udata4

View File

@ -50,6 +50,22 @@
; RUN: -filetype=asm -o - %s \
; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP-ELIM
; RUN: llc -mtriple arm-unknown-netbsd-eabi \
; RUN: -disable-fp-elim -filetype=asm -o - %s \
; RUN: | FileCheck %s --check-prefix=DWARF-FP
; RUN: llc -mtriple arm-unknown-netbsd-eabi \
; RUN: -filetype=asm -o - %s \
; RUN: | FileCheck %s --check-prefix=DWARF-FP-ELIM
; RUN: llc -mtriple armv7-unknown-netbsd-eabi \
; RUN: -disable-fp-elim -filetype=asm -o - %s \
; RUN: | FileCheck %s --check-prefix=DWARF-V7-FP
; RUN: llc -mtriple armv7-unknown-netbsd-eabi \
; RUN: -filetype=asm -o - %s \
; RUN: | FileCheck %s --check-prefix=DWARF-V7-FP-ELIM
;-------------------------------------------------------------------------------
; Test 1
;-------------------------------------------------------------------------------
@ -172,6 +188,93 @@ declare void @_ZSt9terminatev()
; CHECK-V7-FP-ELIM: .handlerdata
; CHECK-V7-FP-ELIM: .fnend
; DWARF-FP-LABEL: _Z4testiiiiiddddd:
; DWARF-FP: .cfi_startproc
; DWARF-FP: .cfi_personality 0, __gxx_personality_v0
; DWARF-FP: .cfi_lsda 0, .Lexception0
; DWARF-FP: push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
; DWARF-FP: .cfi_def_cfa_offset 36
; DWARF-FP: .cfi_offset lr, -4
; DWARF-FP: .cfi_offset r11, -8
; DWARF-FP: .cfi_offset r10, -12
; DWARF-FP: .cfi_offset r9, -16
; DWARF-FP: .cfi_offset r8, -20
; DWARF-FP: .cfi_offset r7, -24
; DWARF-FP: .cfi_offset r6, -28
; DWARF-FP: .cfi_offset r5, -32
; DWARF-FP: .cfi_offset r4, -36
; DWARF-FP: add r11, sp, #28
; DWARF-FP: .cfi_def_cfa r11, 8
; DWARF-FP: sub sp, sp, #28
; DWARF-FP: sub sp, r11, #28
; DWARF-FP: pop {r4, r5, r6, r7, r8, r9, r10, r11, lr}
; DWARF-FP: mov pc, lr
; DWARF-FP: .cfi_endproc
; DWARF-FP-ELIM-LABEL: _Z4testiiiiiddddd:
; DWARF-FP-ELIM: .cfi_startproc
; DWARF-FP-ELIM: .cfi_personality 0, __gxx_personality_v0
; DWARF-FP-ELIM: .cfi_lsda 0, .Lexception0
; DWARF-FP-ELIM: push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
; DWARF-FP-ELIM: .cfi_def_cfa_offset 36
; DWARF-FP-ELIM: .cfi_offset lr, -4
; DWARF-FP-ELIM: .cfi_offset r11, -8
; DWARF-FP-ELIM: .cfi_offset r10, -12
; DWARF-FP-ELIM: .cfi_offset r9, -16
; DWARF-FP-ELIM: .cfi_offset r8, -20
; DWARF-FP-ELIM: .cfi_offset r7, -24
; DWARF-FP-ELIM: .cfi_offset r6, -28
; DWARF-FP-ELIM: .cfi_offset r5, -32
; DWARF-FP-ELIM: .cfi_offset r4, -36
; DWARF-FP-ELIM: sub sp, sp, #28
; DWARF-FP-ELIM: .cfi_def_cfa_offset 64
; DWARF-FP-ELIM: add sp, sp, #28
; DWARF-FP-ELIM: pop {r4, r5, r6, r7, r8, r9, r10, r11, lr}
; DWARF-FP-ELIM: mov pc, lr
; DWARF-FP-ELIM: .cfi_endproc
; DWARF-V7-FP-LABEL: _Z4testiiiiiddddd:
; DWARF-V7-FP: .cfi_startproc
; DWARF-V7-FP: .cfi_personality 0, __gxx_personality_v0
; DWARF-V7-FP: .cfi_lsda 0, .Lexception0
; DWARF-V7-FP: push {r4, r10, r11, lr}
; DWARF-V7-FP: .cfi_def_cfa_offset 16
; DWARF-V7-FP: .cfi_offset lr, -4
; DWARF-V7-FP: .cfi_offset r11, -8
; DWARF-V7-FP: .cfi_offset r10, -12
; DWARF-V7-FP: .cfi_offset r4, -16
; DWARF-V7-FP: add r11, sp, #8
; DWARF-V7-FP: .cfi_def_cfa r11, 8
; DWARF-V7-FP: vpush {d8, d9, d10, d11, d12}
; DWARF-V7-FP: .cfi_offset d12, -24
; DWARF-V7-FP: .cfi_offset d11, -32
; DWARF-V7-FP: .cfi_offset d10, -40
; DWARF-V7-FP: .cfi_offset d9, -48
; DWARF-V7-FP: sub sp, sp, #24
; DWARF-V7-FP: sub sp, r11, #48
; DWARF-V7-FP: vpop {d8, d9, d10, d11, d12}
; DWARF-V7-FP: pop {r4, r10, r11, pc}
; DWARF-V7-FP: .cfi_endproc
; DWARF-V7-FP-ELIM-LABEL: _Z4testiiiiiddddd:
; DWARF-V7-FP-ELIM: .cfi_startproc
; DWARF-V7-FP-ELIM: .cfi_personality 0, __gxx_personality_v0
; DWARF-V7-FP-ELIM: .cfi_lsda 0, .Lexception0
; DWARF-V7-FP-ELIM: push {r4, lr}
; DWARF-V7-FP-ELIM: .cfi_def_cfa_offset 8
; DWARF-V7-FP-ELIM: .cfi_offset lr, -4
; DWARF-V7-FP-ELIM: .cfi_offset r4, -8
; DWARF-V7-FP-ELIM: vpush {d8, d9, d10, d11, d12}
; DWARF-V7-FP-ELIM: .cfi_offset d12, -16
; DWARF-V7-FP-ELIM: .cfi_offset d11, -24
; DWARF-V7-FP-ELIM: .cfi_offset d10, -32
; DWARF-V7-FP-ELIM: .cfi_offset d9, -40
; DWARF-V7-FP-ELIM: sub sp, sp, #24
; DWARF-V7-FP-ELIM: .cfi_def_cfa_offset 72
; DWARF-V7-FP-ELIM: add sp, sp, #24
; DWARF-V7-FP-ELIM: vpop {d8, d9, d10, d11, d12}
; DWARF-V7-FP-ELIM: pop {r4, pc}
; DWARF-V7-FP-ELIM: .cfi_endproc
;-------------------------------------------------------------------------------
; Test 2
@ -219,6 +322,48 @@ entry:
; CHECK-V7-FP-ELIM: pop {r11, pc}
; CHECK-V7-FP-ELIM: .fnend
; DWARF-FP-LABEL: test2:
; DWARF-FP: .cfi_startproc
; DWARF-FP: push {r11, lr}
; DWARF-FP: .cfi_def_cfa_offset 8
; DWARF-FP: .cfi_offset lr, -4
; DWARF-FP: .cfi_offset r11, -8
; DWARF-FP: mov r11, sp
; DWARF-FP: .cfi_def_cfa_register r11
; DWARF-FP: pop {r11, lr}
; DWARF-FP: mov pc, lr
; DWARF-FP: .cfi_endproc
; DWARF-FP-ELIM-LABEL: test2:
; DWARF-FP-ELIM: .cfi_startproc
; DWARF-FP-ELIM: push {r11, lr}
; DWARF-FP-ELIM: .cfi_def_cfa_offset 8
; DWARF-FP-ELIM: .cfi_offset lr, -4
; DWARF-FP-ELIM: .cfi_offset r11, -8
; DWARF-FP-ELIM: pop {r11, lr}
; DWARF-FP-ELIM: mov pc, lr
; DWARF-FP-ELIM: .cfi_endproc
; DWARF-V7-FP-LABEL: test2:
; DWARF-V7-FP: .cfi_startproc
; DWARF-V7-FP: push {r11, lr}
; DWARF-V7-FP: .cfi_def_cfa_offset 8
; DWARF-V7-FP: .cfi_offset lr, -4
; DWARF-V7-FP: .cfi_offset r11, -8
; DWARF-V7-FP: mov r11, sp
; DWARF-V7-FP: .cfi_def_cfa_register r11
; DWARF-V7-FP: pop {r11, pc}
; DWARF-V7-FP: .cfi_endproc
; DWARF-V7-FP-ELIM-LABEL: test2:
; DWARF-V7-FP-ELIM: .cfi_startproc
; DWARF-V7-FP-ELIM: push {r11, lr}
; DWARF-V7-FP-ELIM: .cfi_def_cfa_offset 8
; DWARF-V7-FP-ELIM: .cfi_offset lr, -4
; DWARF-V7-FP-ELIM: .cfi_offset r11, -8
; DWARF-V7-FP-ELIM: pop {r11, pc}
; DWARF-V7-FP-ELIM: .cfi_endproc
;-------------------------------------------------------------------------------
; Test 3
@ -275,6 +420,56 @@ entry:
; CHECK-V7-FP-ELIM: pop {r4, r5, r11, pc}
; CHECK-V7-FP-ELIM: .fnend
; DWARF-FP-LABEL: test3:
; DWARF-FP: .cfi_startproc
; DWARF-FP: push {r4, r5, r11, lr}
; DWARF-FP: .cfi_def_cfa_offset 16
; DWARF-FP: .cfi_offset lr, -4
; DWARF-FP: .cfi_offset r11, -8
; DWARF-FP: .cfi_offset r5, -12
; DWARF-FP: .cfi_offset r4, -16
; DWARF-FP: add r11, sp, #8
; DWARF-FP: .cfi_def_cfa r11, 8
; DWARF-FP: pop {r4, r5, r11, lr}
; DWARF-FP: mov pc, lr
; DWARF-FP: .cfi_endproc
; DWARF-FP-ELIM-LABEL: test3:
; DWARF-FP-ELIM: .cfi_startproc
; DWARF-FP-ELIM: push {r4, r5, r11, lr}
; DWARF-FP-ELIM: .cfi_def_cfa_offset 16
; DWARF-FP-ELIM: .cfi_offset lr, -4
; DWARF-FP-ELIM: .cfi_offset r11, -8
; DWARF-FP-ELIM: .cfi_offset r5, -12
; DWARF-FP-ELIM: .cfi_offset r4, -16
; DWARF-FP-ELIM: pop {r4, r5, r11, lr}
; DWARF-FP-ELIM: mov pc, lr
; DWARF-FP-ELIM: .cfi_endproc
; DWARF-V7-FP-LABEL: test3:
; DWARF-V7-FP: .cfi_startproc
; DWARF-V7-FP: push {r4, r5, r11, lr}
; DWARF-V7-FP: .cfi_def_cfa_offset 16
; DWARF-V7-FP: .cfi_offset lr, -4
; DWARF-V7-FP: .cfi_offset r11, -8
; DWARF-V7-FP: .cfi_offset r5, -12
; DWARF-V7-FP: .cfi_offset r4, -16
; DWARF-V7-FP: add r11, sp, #8
; DWARF-V7-FP: .cfi_def_cfa r11, 8
; DWARF-V7-FP: pop {r4, r5, r11, pc}
; DWARF-V7-FP: .cfi_endproc
; DWARF-V7-FP-ELIM-LABEL: test3:
; DWARF-V7-FP-ELIM: .cfi_startproc
; DWARF-V7-FP-ELIM: push {r4, r5, r11, lr}
; DWARF-V7-FP-ELIM: .cfi_def_cfa_offset 16
; DWARF-V7-FP-ELIM: .cfi_offset lr, -4
; DWARF-V7-FP-ELIM: .cfi_offset r11, -8
; DWARF-V7-FP-ELIM: .cfi_offset r5, -12
; DWARF-V7-FP-ELIM: .cfi_offset r4, -16
; DWARF-V7-FP-ELIM: pop {r4, r5, r11, pc}
; DWARF-V7-FP-ELIM: .cfi_endproc
;-------------------------------------------------------------------------------
; Test 4
@ -308,3 +503,27 @@ entry:
; CHECK-V7-FP-ELIM: bx lr
; CHECK-V7-FP-ELIM: .cantunwind
; CHECK-V7-FP-ELIM: .fnend
; DWARF-FP-LABEL: test4:
; DWARF-FP-NOT: .cfi_startproc
; DWARF-FP: mov pc, lr
; DWARF-FP-NOT: .cfi_endproc
; DWARF-FP: .size test4,
; DWARF-FP-ELIM-LABEL: test4:
; DWARF-FP-ELIM-NOT: .cfi_startproc
; DWARF-FP-ELIM: mov pc, lr
; DWARF-FP-ELIM-NOT: .cfi_endproc
; DWARF-FP-ELIM: .size test4,
; DWARF-V7-FP-LABEL: test4:
; DWARF-V7-FP-NOT: .cfi_startproc
; DWARF-V7-FP: bx lr
; DWARF-V7-FP-NOT: .cfi_endproc
; DWARF-V7-FP: .size test4,
; DWARF-V7-FP-ELIM-LABEL: test4:
; DWARF-V7-FP-ELIM-NOT: .cfi_startproc
; DWARF-V7-FP-ELIM: bx lr
; DWARF-V7-FP-ELIM-NOT: .cfi_endproc
; DWARF-V7-FP-ELIM: .size test4,