[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 6 00:35:56 PDT 2019


HsiangKai created this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In debug frame information, some fields, e.g., Length in CIE/FDE and
Offset in FDE are attributes to describe the structure of CIE/FDE. They
are not related to the relaxed code. However, these attributes are
symbol differences. So, in current design, these attributes will be
filled as zero and LLVM generates relocations for them.

I add a flag Fixed in MCExpr. Use the flag to decide to evaluate the
symbol difference or not. When the flag is set, the symbol difference
will be evaluated even the relax is enabled.


Repository:
  rL LLVM

https://reviews.llvm.org/D61584

Files:
  include/llvm/MC/MCExpr.h
  lib/MC/MCDwarf.cpp
  lib/MC/MCExpr.cpp


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.198227.patch
Type: text/x-patch
Size: 2396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190506/ca726be2/attachment.bin>


More information about the llvm-commits mailing list