[PATCH] D55281: debuginfo: Use symbol difference for CU length to simplify assembly reading/editing
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 4 09:46:35 PST 2018
dblaikie created this revision.
dblaikie added reviewers: aprantl, JDevlieghere, probinson, ABataev.
Herald added a subscriber: llvm-commits.
Mucking about simplifying a test case ( https://reviews.llvm.org/D55261 ) I stumbled across something I've hit before - that LLVM's (GCC's does too, FWIW) assembly output includes a hardcode length for a DWARF unit in its header. Instead we could emit a label difference - making the assembly easier to read/edit (though potentially at a slight (I haven't tried to observe it) performance cost of delaying/sinking the length computation into the MC layer).
This does cause a few tests to fail currently - DebugInfo/X86/sections_as_references.ll (which was testing that there were no labels in the unit header & now there's one label there) and a few NVPTX ones (these might be a real issue - because NVPTX seems to have some strong limitations on what sort of assembly it can cope with - and maybe these label differences wouldn't be acceptable there, so I've added Alexey to this review to get his perspective on that part)
Repository:
rL LLVM
https://reviews.llvm.org/D55281
Files:
lib/CodeGen/AsmPrinter/DwarfFile.cpp
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
lib/CodeGen/AsmPrinter/DwarfUnit.h
Index: lib/CodeGen/AsmPrinter/DwarfUnit.h
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -48,6 +48,7 @@
/// Target of Dwarf emission.
AsmPrinter *Asm;
+ MCSymbol *EndLabel;
// Holders for some common dwarf information.
DwarfDebug *DD;
@@ -82,6 +83,7 @@
public:
// Accessors.
AsmPrinter* getAsmPrinter() const { return Asm; }
+ MCSymbol *getEndLabel() const { return EndLabel; }
uint16_t getLanguage() const { return CUNode->getSourceLanguage(); }
const DICompileUnit *getCUNode() const { return CUNode; }
Index: lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1553,7 +1553,11 @@
void DwarfUnit::emitCommonHeader(bool UseOffsets, dwarf::UnitType UT) {
// Emit size of content not including length itself
Asm->OutStreamer->AddComment("Length of Unit");
- Asm->emitInt32(getHeaderSize() + getUnitDie().getSize());
+ StringRef Prefix = isDwoUnit() ? "debug_info_dwo_" : "debug_info_";
+ MCSymbol *BeginLabel = Asm->createTempSymbol(Prefix + "start");
+ EndLabel = Asm->createTempSymbol(Prefix + "end");
+ Asm->EmitLabelDifference(EndLabel, BeginLabel, 4);
+ Asm->OutStreamer->EmitLabel(BeginLabel);
Asm->OutStreamer->AddComment("DWARF version number");
unsigned Version = DD->getDwarfVersion();
Index: lib/CodeGen/AsmPrinter/DwarfFile.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfFile.cpp
+++ lib/CodeGen/AsmPrinter/DwarfFile.cpp
@@ -46,6 +46,8 @@
TheU->emitHeader(UseOffsets);
Asm->emitDwarfDIE(Die);
+
+ Asm->OutStreamer->EmitLabel(TheU->getEndLabel());
}
// Compute the size and offset for each DIE.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55281.176659.patch
Type: text/x-patch
Size: 1870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181204/90301e1a/attachment.bin>
More information about the llvm-commits
mailing list