[PATCH] D41920: [DWARF][NFC] Prep for upcoming DWARF v5 string offsets table producer patch.

Wolfgang Pieb via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 14:57:54 PST 2018


wolfgangp created this revision.
wolfgangp added reviewers: aprantl, JDevlieghere, dblaikie.

This is in preparation for an upcoming patch to implement the producer side of DWARF v5 string offsets tables. We'd like to use AsmPrinter's emitDwarfStringOffsets() with a simple DwarfStringPoolEntry record in order to emit string offsets from the DwarfStringPool class directly. Currently the method only takes a DwarfStringPoolEntryRef, which is awkward to construct from a DwarfStringPoolEntry and would create unnecessary overhead.


https://reviews.llvm.org/D41920

Files:
  include/llvm/CodeGen/AsmPrinter.h
  include/llvm/CodeGen/DwarfStringPoolEntry.h
  lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp


Index: include/llvm/CodeGen/DwarfStringPoolEntry.h
===================================================================
--- include/llvm/CodeGen/DwarfStringPoolEntry.h
+++ include/llvm/CodeGen/DwarfStringPoolEntry.h
@@ -41,6 +41,7 @@
   unsigned getOffset() const { return I->second.Offset; }
   unsigned getIndex() const { return I->second.Index; }
   StringRef getString() const { return I->first(); }
+  DwarfStringPoolEntry getEntry() const { return I->getValue(); }
 
   bool operator==(const DwarfStringPoolEntryRef &X) const { return I == X.I; }
   bool operator!=(const DwarfStringPoolEntryRef &X) const { return I != X.I; }
Index: lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
@@ -167,14 +167,15 @@
   EmitLabelDifference(Label, Label->getSection().getBeginSymbol(), 4);
 }
 
-void AsmPrinter::emitDwarfStringOffset(DwarfStringPoolEntryRef S) const {
+void AsmPrinter::emitDwarfStringOffset(DwarfStringPoolEntry S) const {
   if (MAI->doesDwarfUseRelocationsAcrossSections()) {
-    emitDwarfSymbolReference(S.getSymbol());
+    assert(S.Symbol && "No symbol available");
+    emitDwarfSymbolReference(S.Symbol);
     return;
   }
 
   // Just emit the offset directly; no need for symbol math.
-  EmitInt32(S.getOffset());
+  EmitInt32(S.Offset);
 }
 
 //===----------------------------------------------------------------------===//
Index: include/llvm/CodeGen/AsmPrinter.h
===================================================================
--- include/llvm/CodeGen/AsmPrinter.h
+++ include/llvm/CodeGen/AsmPrinter.h
@@ -508,8 +508,13 @@
   /// When possible, emit a DwarfStringPool section offset without any
   /// relocations, and without using the symbol.  Otherwise, defers to \a
   /// emitDwarfSymbolReference().
-  void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const;
+  void emitDwarfStringOffset(DwarfStringPoolEntry S) const;
 
+  /// Emit the 4-byte offset of a string from the start of its section.
+  void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const {
+    emitDwarfStringOffset(S.getEntry());
+  }
+
   /// Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
   virtual unsigned getISAEncoding() { return 0; }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41920.129347.patch
Type: text/x-patch
Size: 2334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180110/a917d40e/attachment.bin>


More information about the llvm-commits mailing list