From b167839943efccd89e96544e288948ef7ee3cdb4 Mon Sep 17 00:00:00 2001 From: Alex Bradbury Date: Wed, 17 Jul 2019 13:54:38 +0000 Subject: [PATCH] [RISCV] Set correct encodings for DWARF exception handling This patch sets correct encodings for DWARF exception handling for RISC-V (other than call site encoding, which must be udata4 rather than uleb128 and is handled by D63415). This has the same intend as D63409, except this version matches GCC/binutils behaviour which uses the same encodings regardless of PIC/non-PIC and medlow/medany code model. llvm-svn: 366327 --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 8 ++++++ test/CodeGen/RISCV/dwarf-eh.ll | 30 +++++++++----------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 4c18152ea8d..d8e6b3ef93a 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -219,6 +219,14 @@ void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx, TTypeEncoding = dwarf::DW_EH_PE_absptr; } break; + case Triple::riscv32: + case Triple::riscv64: + LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; + PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | + dwarf::DW_EH_PE_sdata4; + TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | + dwarf::DW_EH_PE_sdata4; + break; case Triple::sparcv9: LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; if (isPositionIndependent()) { diff --git a/test/CodeGen/RISCV/dwarf-eh.ll b/test/CodeGen/RISCV/dwarf-eh.ll index 6abea5c2a65..67236d7da66 100644 --- a/test/CodeGen/RISCV/dwarf-eh.ll +++ b/test/CodeGen/RISCV/dwarf-eh.ll @@ -1,19 +1,19 @@ ; RUN: llc -march=riscv32 --code-model=small < %s \ -; RUN: | FileCheck --check-prefixes=CHECK,SMALL %s +; RUN: | FileCheck %s ; RUN: llc -march=riscv32 --code-model=medium < %s \ -; RUN: | FileCheck --check-prefixes=CHECK,MED %s +; RUN: | FileCheck %s ; RUN: llc -march=riscv32 --code-model=small -relocation-model=pic < %s \ -; RUN: | FileCheck --check-prefixes=CHECK,PIC %s +; RUN: | FileCheck %s ; RUN: llc -march=riscv32 --code-model=medium -relocation-model=pic < %s \ -; RUN: | FileCheck --check-prefixes=CHECK,PIC %s +; RUN: | FileCheck %s ; RUN: llc -march=riscv64 --code-model=small < %s \ -; RUN: | FileCheck --check-prefixes=CHECK,SMALL %s +; RUN: | FileCheck %s ; RUN: llc -march=riscv64 --code-model=medium < %s \ -; RUN: | FileCheck --check-prefixes=CHECK,MED %s +; RUN: | FileCheck %s ; RUN: llc -march=riscv64 --code-model=small -relocation-model=pic < %s \ -; RUN: | FileCheck --check-prefixes=CHECK,PIC %s +; RUN: | FileCheck %s ; RUN: llc -march=riscv64 --code-model=medium -relocation-model=pic < %s \ -; RUN: | FileCheck --check-prefixes=CHECK,PIC %s +; RUN: | FileCheck %s declare void @throw_exception() @@ -25,11 +25,10 @@ declare void @__cxa_end_catch() ; CHECK-LABEL: test1: ; CHECK: .cfi_startproc -; TODO: Personality encoding should be DW_EH_PE_indirect | DW_EH_PE_pcrel | -; DW_EH_PE_sdata4 -; CHECK-NEXT: .cfi_personality 0, __gxx_personality_v0 -; TODO: LSDA encoding should be DW_EH_PE_pcrel | DW_EH_PE_sdata4 -; CHECK-NEXT: .cfi_lsda 0, .Lexception0 +; PersonalityEncoding = DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4 +; CHECK-NEXT: .cfi_personality 155, DW.ref.__gxx_personality_v0 +; LSDAEncoding = DW_EH_PE_pcrel | DW_EH_PE_sdata4 +; CHECK-NEXT: .cfi_lsda 27, .Lexception0 define void @test1() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { entry: @@ -50,9 +49,8 @@ try.cont: ; CHECK-LABEL: GCC_except_table0: ; CHECK-NEXT: .Lexception0: ; CHECK-NEXT: .byte 255 # @LPStart Encoding = omit -; TODO: TTypeEncoding encoding should be DW_EH_PE_indirect | DW_EH_PE_pcrel | -; DW_EH_PE_sdata4 -; CHECK-NEXT: .byte 0 # @TType Encoding = absptr +; TTypeEncoding = DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4 +; CHECK-NEXT: .byte 155 # @TType Encoding = indirect pcrel sdata4 ; TODO: call site encoding should be DW_EH_PE_udata4 ; CHECK: .Lttbaseref0: ; CHECK-NEXT: .byte 1 # Call site Encoding = uleb128