[PATCH] D61584: [DebugInfo] Some fields do not need relocations even relax is enabled.
Hsiangkai Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 22 08:50:07 PDT 2019
HsiangKai updated this revision to Diff 206120.
HsiangKai added a comment.
Fix bugs.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61584/new/
https://reviews.llvm.org/D61584
Files:
lib/MC/MCExpr.cpp
test/DebugInfo/RISCV/relax-debug-frame.ll
Index: test/DebugInfo/RISCV/relax-debug-frame.ll
===================================================================
--- test/DebugInfo/RISCV/relax-debug-frame.ll
+++ test/DebugInfo/RISCV/relax-debug-frame.ll
@@ -2,10 +2,12 @@
; RUN: | llvm-readobj -r | FileCheck -check-prefix=RELAX %s
;
; RELAX: .rela.{{eh|debug}}_frame {
-; RELAX: R_RISCV_ADD32
-; RELAX: R_RISCV_SUB32
-; RELAX: R_RISCV_SET6
-; RELAX: R_RISCV_SUB6
+; RELAX-NOT: 0x0 R_RISCV_ADD32
+; RELAX-NOT: 0x0 R_RISCV_SUB32
+; RELAX: 0x20 R_RISCV_ADD32
+; RELAX: 0x20 R_RISCV_SUB32
+; RELAX: 0x25 R_RISCV_SET6
+; RELAX: 0x25 R_RISCV_SUB6
source_filename = "frame.c"
; Function Attrs: noinline nounwind optnone
Index: lib/MC/MCExpr.cpp
===================================================================
--- lib/MC/MCExpr.cpp
+++ lib/MC/MCExpr.cpp
@@ -566,6 +566,24 @@
A = B = nullptr;
}
+static bool canFold(const MCAssembler *Asm, const MCSymbolRefExpr *A,
+ const MCSymbolRefExpr *B, bool InSet) {
+ if (InSet)
+ return true;
+
+ if (!Asm->getBackend().requiresDiffExpressionRelocations())
+ return true;
+
+ const MCSymbol &CheckSym = A ? A->getSymbol() : B->getSymbol();
+ if (!CheckSym.isInSection())
+ return true;
+
+ if (!CheckSym.getSection().hasInstructions())
+ return true;
+
+ return false;
+}
+
/// Evaluate the result of an add between (conceptually) two MCValues.
///
/// This routine conceptually attempts to construct an MCValue:
@@ -606,8 +624,7 @@
// the backend requires this to be emitted as individual relocations, unless
// the InSet flag is set to get the current difference anyway (used for
// example to calculate symbol sizes).
- if (Asm &&
- (InSet || !Asm->getBackend().requiresDiffExpressionRelocations())) {
+ if (Asm && canFold(Asm, LHS_A, LHS_B, InSet)) {
// First, fold out any differences which are fully resolved. By
// reassociating terms in
// Result = (LHS_A - LHS_B + LHS_Cst) + (RHS_A - RHS_B + RHS_Cst).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61584.206120.patch
Type: text/x-patch
Size: 1996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190622/7dc850d1/attachment.bin>
More information about the llvm-commits
mailing list