[llvm] r366327 - [RISCV] Set correct encodings for DWARF exception handling

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 06:54:38 PDT 2019


Author: asb
Date: Wed Jul 17 06:54:38 2019
New Revision: 366327

URL: http://llvm.org/viewvc/llvm-project?rev=366327&view=rev
Log:
[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.


Modified:
    llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    llvm/trunk/test/CodeGen/RISCV/dwarf-eh.ll

Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=366327&r1=366326&r2=366327&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Wed Jul 17 06:54:38 2019
@@ -219,6 +219,14 @@ void TargetLoweringObjectFileELF::Initia
       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()) {

Modified: llvm/trunk/test/CodeGen/RISCV/dwarf-eh.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/RISCV/dwarf-eh.ll?rev=366327&r1=366326&r2=366327&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/RISCV/dwarf-eh.ll (original)
+++ llvm/trunk/test/CodeGen/RISCV/dwarf-eh.ll Wed Jul 17 06:54:38 2019
@@ -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




More information about the llvm-commits mailing list