[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
Mon May 13 19:37:22 PDT 2019
HsiangKai updated this revision to Diff 199357.
HsiangKai added a comment.
Herald added subscribers: jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar, asb.
Attach a test case.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61584/new/
https://reviews.llvm.org/D61584
Files:
include/llvm/MC/MCExpr.h
lib/MC/MCDwarf.cpp
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
@@ -646,7 +646,7 @@
const MCFixup *Fixup) const {
MCAssembler *Assembler = Layout ? &Layout->getAssembler() : nullptr;
return evaluateAsRelocatableImpl(Res, Assembler, Layout, Fixup, nullptr,
- false);
+ Fixed);
}
bool MCExpr::evaluateAsValue(MCValue &Res, const MCAsmLayout &Layout) const {
Index: lib/MC/MCDwarf.cpp
===================================================================
--- lib/MC/MCDwarf.cpp
+++ lib/MC/MCDwarf.cpp
@@ -1570,6 +1570,7 @@
// Length
const MCExpr *Length =
MakeStartMinusEndExpr(Streamer, *sectionStart, *sectionEnd, 4);
+ Length->setFixed();
emitAbsValue(Streamer, Length, 4);
// CIE ID
@@ -1686,6 +1687,7 @@
// Length
const MCExpr *Length = MakeStartMinusEndExpr(Streamer, *fdeStart, *fdeEnd, 0);
+ Length->setFixed();
emitAbsValue(Streamer, Length, 4);
Streamer.EmitLabel(fdeStart);
@@ -1695,6 +1697,7 @@
if (IsEH) {
const MCExpr *offset =
MakeStartMinusEndExpr(Streamer, cieStart, *fdeStart, 0);
+ offset->setFixed();
emitAbsValue(Streamer, offset, 4);
} else if (!asmInfo->doesDwarfUseRelocationsAcrossSections()) {
const MCExpr *offset =
Index: include/llvm/MC/MCExpr.h
===================================================================
--- include/llvm/MC/MCExpr.h
+++ include/llvm/MC/MCExpr.h
@@ -45,6 +45,7 @@
private:
ExprKind Kind;
SMLoc Loc;
+ mutable bool Fixed;
bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
const MCAsmLayout *Layout,
@@ -55,7 +56,8 @@
const SectionAddrMap *Addrs, bool InSet) const;
protected:
- explicit MCExpr(ExprKind Kind, SMLoc Loc) : Kind(Kind), Loc(Loc) {}
+ explicit MCExpr(ExprKind Kind, SMLoc Loc)
+ : Kind(Kind), Loc(Loc), Fixed(false) {}
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
const MCAsmLayout *Layout,
@@ -71,6 +73,8 @@
ExprKind getKind() const { return Kind; }
SMLoc getLoc() const { return Loc; }
+ bool getFixed() const { return Fixed; }
+ void setFixed() const { Fixed = true; }
/// @}
/// \name Utility Methods
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61584.199357.patch
Type: text/x-patch
Size: 3076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190514/013b04a7/attachment.bin>
More information about the llvm-commits
mailing list