[llvm] [RISCV] Restore DW_EH_PE_uleb128 call site encoding for .gcc_except_table (PR #77276)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 7 22:44:05 PST 2024


https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/77276

Call site records in .gcc_except_table reference text sections.
https://reviews.llvm.org/D63415 switched the encoding to DW_EH_PE_udata4 so that
`.uleb128 A-B`, which requires relocations in the generic case in the
presence of linker relaxation, can be avoided.

binutils 2.41 and latest lld (#77261) support
R_RISCV_SET_ULEB128/R_RISCV_SUB_ULEB128. This patch restores
DW_EH_PE_uleb128 to make .gcc_except_table smaller. Sparc is restored as
well, which was incorrectly changed by https://reviews.llvm.org/D63415 .

emitCallSiteOffset/emitCallSiteValue should be preserved as now AIX uses
the DW_EH_PE_udata4 code path.


>From faf0bcf968a20b759d3647da45a63f466d098488 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Sun, 7 Jan 2024 22:43:57 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp |  2 --
 llvm/test/CodeGen/RISCV/dwarf-eh.ll               | 15 +++++++--------
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 6e69dc66429d31..cf9522dc140ce5 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -244,7 +244,6 @@ void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
       PersonalityEncoding = dwarf::DW_EH_PE_absptr;
       TTypeEncoding = dwarf::DW_EH_PE_absptr;
     }
-    CallSiteEncoding = dwarf::DW_EH_PE_udata4;
     break;
   case Triple::riscv32:
   case Triple::riscv64:
@@ -253,7 +252,6 @@ void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
                           dwarf::DW_EH_PE_sdata4;
     TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
                     dwarf::DW_EH_PE_sdata4;
-    CallSiteEncoding = dwarf::DW_EH_PE_udata4;
     break;
   case Triple::sparcv9:
     LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
diff --git a/llvm/test/CodeGen/RISCV/dwarf-eh.ll b/llvm/test/CodeGen/RISCV/dwarf-eh.ll
index 39cc0d52c9fe18..9e13ecf81aac5e 100644
--- a/llvm/test/CodeGen/RISCV/dwarf-eh.ll
+++ b/llvm/test/CodeGen/RISCV/dwarf-eh.ll
@@ -52,15 +52,14 @@ try.cont:
 ; TTypeEncoding = DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4
 ; CHECK-NEXT: .byte 155 # @TType Encoding = indirect pcrel sdata4
 ; CHECK: .Lttbaseref0:
-; CallSiteEncoding = dwarf::DW_EH_PE_udata4
-; CHECK-NEXT: .byte	3                       # Call site Encoding = udata4
+; CHECK-NEXT: .byte	1                       # Call site Encoding = uleb128
 ; CHECK-NEXT: .uleb128 .Lcst_end0-.Lcst_begin0
 ; CHECK-NEXT: cst_begin0:
-; CHECK-NEXT: .word .Ltmp0-.Lfunc_begin0   # >> Call Site 1 <<
-; CHECK-NEXT: .word .Ltmp1-.Ltmp0          #   Call between .Ltmp0 and .Ltmp1
-; CHECK-NEXT: .word .Ltmp2-.Lfunc_begin0   #     jumps to .Ltmp2
+; CHECK-NEXT: .uleb128 .Ltmp0-.Lfunc_begin0     # >> Call Site 1 <<
+; CHECK-NEXT: .uleb128 .Ltmp1-.Ltmp0            #   Call between .Ltmp0 and .Ltmp1
+; CHECK-NEXT: .uleb128 .Ltmp2-.Lfunc_begin0     #     jumps to .Ltmp2
 ; CHECK-NEXT: .byte	1                       #   On action: 1
-; CHECK-NEXT: .word .Ltmp1-.Lfunc_begin0   # >> Call Site 2 <<
-; CHECK-NEXT: .word .Lfunc_end0-.Ltmp1     #   Call between .Ltmp1 and .Lfunc_end0
-; CHECK-NEXT: .word	0                       #     has no landing pad
+; CHECK-NEXT: .uleb128 .Ltmp1-.Lfunc_begin0     # >> Call Site 2 <<
+; CHECK-NEXT: .uleb128 .Lfunc_end0-.Ltmp1       #   Call between .Ltmp1 and .Lfunc_end0
+; CHECK-NEXT: .byte	0                       #     has no landing pad
 ; CHECK-NEXT: .byte	0                       #   On action: cleanup



More information about the llvm-commits mailing list