[llvm] r204101 - DebugInfo: Avoid emitting standard opcode lengths in debug_line.dwo headers where opcodes are never used anyway
David Blaikie
dblaikie at gmail.com
Mon Mar 17 19:13:24 PDT 2014
Author: dblaikie
Date: Mon Mar 17 21:13:23 2014
New Revision: 204101
URL: http://llvm.org/viewvc/llvm-project?rev=204101&view=rev
Log:
DebugInfo: Avoid emitting standard opcode lengths in debug_line.dwo headers where opcodes are never used anyway
Introduce a slightly tighter wrapper around the header structure that
handles this use case. (MCDwarfDwoLineTable)
Modified:
llvm/trunk/include/llvm/MC/MCDwarf.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
llvm/trunk/lib/MC/MCDwarf.cpp
llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll
Modified: llvm/trunk/include/llvm/MC/MCDwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=204101&r1=204100&r2=204101&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCDwarf.h (original)
+++ llvm/trunk/include/llvm/MC/MCDwarf.h Mon Mar 17 21:13:23 2014
@@ -15,6 +15,7 @@
#ifndef LLVM_MC_MCDWARF_H
#define LLVM_MC_MCDWARF_H
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/MapVector.h"
@@ -187,6 +188,17 @@ struct MCDwarfLineTableHeader {
unsigned getFile(StringRef &Directory, StringRef &FileName,
unsigned FileNumber = 0);
std::pair<MCSymbol *, MCSymbol *> Emit(MCStreamer *MCOS) const;
+ std::pair<MCSymbol *, MCSymbol *>
+ Emit(MCStreamer *MCOS, ArrayRef<char> SpecialOpcodeLengths) const;
+};
+
+class MCDwarfDwoLineTable {
+ MCDwarfLineTableHeader Header;
+public:
+ unsigned getFile(StringRef Directory, StringRef FileName) {
+ return Header.getFile(Directory, FileName);
+ }
+ void Emit(MCStreamer &MCOS) const;
};
class MCDwarfLineTable {
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=204101&r1=204100&r2=204101&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Mar 17 21:13:23 2014
@@ -2684,7 +2684,7 @@ void DwarfDebug::emitDebugLineDWO() {
assert(useSplitDwarf() && "No split dwarf?");
Asm->OutStreamer.SwitchSection(
Asm->getObjFileLowering().getDwarfLineDWOSection());
- Asm->OutStreamer.EmitLabel(SplitTypeUnitFileTable.Emit(&Asm->OutStreamer).second);
+ SplitTypeUnitFileTable.Emit(Asm->OutStreamer);
}
// Emit the .debug_str.dwo section for separated dwarf. This contains the
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=204101&r1=204100&r2=204101&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Mar 17 21:13:23 2014
@@ -489,7 +489,7 @@ class DwarfDebug : public AsmPrinterHand
// Store file names for type units under fission in a line table header that
// will be emitted into debug_line.dwo.
- MCDwarfLineTableHeader SplitTypeUnitFileTable;
+ MCDwarfDwoLineTable SplitTypeUnitFileTable;
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=204101&r1=204100&r2=204101&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Mon Mar 17 21:13:23 2014
@@ -57,7 +57,7 @@ DwarfCompileUnit::DwarfCompileUnit(unsig
DwarfTypeUnit::DwarfTypeUnit(unsigned UID, DIE *D, DwarfCompileUnit &CU,
AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU,
- MCDwarfLineTableHeader *SplitLineTable)
+ MCDwarfDwoLineTable *SplitLineTable)
: DwarfUnit(UID, D, CU.getCUNode(), A, DW, DWU), CU(CU),
SplitLineTable(SplitLineTable) {
if (SplitLineTable)
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=204101&r1=204100&r2=204101&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Mon Mar 17 21:13:23 2014
@@ -616,12 +616,12 @@ private:
uint64_t TypeSignature;
const DIE *Ty;
DwarfCompileUnit &CU;
- MCDwarfLineTableHeader *SplitLineTable;
+ MCDwarfDwoLineTable *SplitLineTable;
public:
DwarfTypeUnit(unsigned UID, DIE *D, DwarfCompileUnit &CU, AsmPrinter *A,
DwarfDebug *DW, DwarfFile *DWU,
- MCDwarfLineTableHeader *SplitLineTable = nullptr);
+ MCDwarfDwoLineTable *SplitLineTable = nullptr);
void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; }
uint64_t getTypeSignature() const { return TypeSignature; }
Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=204101&r1=204100&r2=204101&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Mon Mar 17 21:13:23 2014
@@ -224,7 +224,33 @@ const MCSymbol *MCDwarfLineTable::Emit(M
return LineStartSym;
}
+void MCDwarfDwoLineTable::Emit(MCStreamer &MCOS) const {
+ MCOS.EmitLabel(Header.Emit(&MCOS, None).second);
+}
+
std::pair<MCSymbol *, MCSymbol *> MCDwarfLineTableHeader::Emit(MCStreamer *MCOS) const {
+ static const char StandardOpcodeLengths[] = {
+ 0, // length of DW_LNS_copy
+ 1, // length of DW_LNS_advance_pc
+ 1, // length of DW_LNS_advance_line
+ 1, // length of DW_LNS_set_file
+ 1, // length of DW_LNS_set_column
+ 0, // length of DW_LNS_negate_stmt
+ 0, // length of DW_LNS_set_basic_block
+ 0, // length of DW_LNS_const_add_pc
+ 1, // length of DW_LNS_fixed_advance_pc
+ 0, // length of DW_LNS_set_prologue_end
+ 0, // length of DW_LNS_set_epilogue_begin
+ 1 // DW_LNS_set_isa
+ };
+ assert(array_lengthof(StandardOpcodeLengths) == (DWARF2_LINE_OPCODE_BASE - 1));
+ return Emit(MCOS, StandardOpcodeLengths);
+}
+
+std::pair<MCSymbol *, MCSymbol *>
+MCDwarfLineTableHeader::Emit(MCStreamer *MCOS,
+ ArrayRef<char> StandardOpcodeLengths) const {
+
MCContext &context = MCOS->getContext();
// Create a symbol at the beginning of the line table.
@@ -260,21 +286,11 @@ std::pair<MCSymbol *, MCSymbol *> MCDwar
MCOS->EmitIntValue(DWARF2_LINE_DEFAULT_IS_STMT, 1);
MCOS->EmitIntValue(DWARF2_LINE_BASE, 1);
MCOS->EmitIntValue(DWARF2_LINE_RANGE, 1);
- MCOS->EmitIntValue(DWARF2_LINE_OPCODE_BASE, 1);
+ MCOS->EmitIntValue(StandardOpcodeLengths.size() + 1, 1);
// Standard opcode lengths
- MCOS->EmitIntValue(0, 1); // length of DW_LNS_copy
- MCOS->EmitIntValue(1, 1); // length of DW_LNS_advance_pc
- MCOS->EmitIntValue(1, 1); // length of DW_LNS_advance_line
- MCOS->EmitIntValue(1, 1); // length of DW_LNS_set_file
- MCOS->EmitIntValue(1, 1); // length of DW_LNS_set_column
- MCOS->EmitIntValue(0, 1); // length of DW_LNS_negate_stmt
- MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_basic_block
- MCOS->EmitIntValue(0, 1); // length of DW_LNS_const_add_pc
- MCOS->EmitIntValue(1, 1); // length of DW_LNS_fixed_advance_pc
- MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_prologue_end
- MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_epilogue_begin
- MCOS->EmitIntValue(1, 1); // DW_LNS_set_isa
+ for (char Length : StandardOpcodeLengths)
+ MCOS->EmitIntValue(Length, 1);
// Put out the directory and file tables.
Modified: llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll?rev=204101&r1=204100&r2=204101&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll Mon Mar 17 21:13:23 2014
@@ -141,6 +141,8 @@
; CHECK-LABEL: .debug_line.dwo contents:
; FISSION: Line table prologue
+; FISSION: opcode_base: 1
+; FISSION-NOT: standard_opcode_lengths
; FISSION-NOT: file_names[
; FISSION: file_names{{.*}} bar.h
; FISSION: file_names{{.*}} bar.cpp
More information about the llvm-commits
mailing list