[llvm] r201469 - DebugInfo: Deduplicate entries in the fission address table
David Blaikie
dblaikie at gmail.com
Sat Feb 15 11:34:04 PST 2014
Author: dblaikie
Date: Sat Feb 15 13:34:03 2014
New Revision: 201469
URL: http://llvm.org/viewvc/llvm-project?rev=201469&view=rev
Log:
DebugInfo: Deduplicate entries in the fission address table
This broke in r185459 while TLS support was being generalized to handle
non-symbol TLS representations.
I thought about/tried having an enum rather than a bool to track the
TLS-ness of the address table entry, but namespaces and naming seemed
more hassle than it was worth for only one caller that needed to specify
this.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/trunk/test/DebugInfo/X86/tls.ll
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=201469&r1=201468&r2=201469&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sat Feb 15 13:34:03 2014
@@ -265,16 +265,12 @@ unsigned DwarfFile::getStringPoolIndex(S
return Entry.second;
}
-unsigned DwarfFile::getAddrPoolIndex(const MCSymbol *Sym) {
- return getAddrPoolIndex(MCSymbolRefExpr::Create(Sym, Asm->OutContext));
-}
-
-unsigned DwarfFile::getAddrPoolIndex(const MCExpr *Sym) {
- std::pair<DenseMap<const MCExpr *, unsigned>::iterator, bool> P =
- AddressPool.insert(std::make_pair(Sym, NextAddrPoolNumber));
+unsigned DwarfFile::getAddrPoolIndex(const MCSymbol *Sym, bool TLS) {
+ std::pair<AddrPool::iterator, bool> P = AddressPool.insert(
+ std::make_pair(Sym, AddressPoolEntry(NextAddrPoolNumber, TLS)));
if (P.second)
++NextAddrPoolNumber;
- return P.first->second;
+ return P.first->second.Number;
}
// Define a unique number for the abbreviation.
@@ -2548,10 +2544,12 @@ void DwarfFile::emitAddresses(const MCSe
// Order the address pool entries by ID
SmallVector<const MCExpr *, 64> Entries(AddressPool.size());
- for (DenseMap<const MCExpr *, unsigned>::iterator I = AddressPool.begin(),
- E = AddressPool.end();
+ for (AddrPool::iterator I = AddressPool.begin(), E = AddressPool.end();
I != E; ++I)
- Entries[I->second] = I->first;
+ Entries[I->second.Number] =
+ I->second.TLS
+ ? Asm->getObjFileLowering().getDebugThreadLocalSymbol(I->first)
+ : MCSymbolRefExpr::Create(I->first, Asm->OutContext);
for (unsigned i = 0, e = Entries.size(); i != e; ++i)
Asm->OutStreamer.EmitValue(Entries[i],
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=201469&r1=201468&r2=201469&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Sat Feb 15 13:34:03 2014
@@ -244,10 +244,15 @@ class DwarfFile {
unsigned NextStringPoolNumber;
std::string StringPref;
+ struct AddressPoolEntry {
+ unsigned Number;
+ bool TLS;
+ AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
+ };
// Collection of addresses for this unit and assorted labels.
// A Symbol->unsigned mapping of addresses used by indirect
// references.
- typedef DenseMap<const MCExpr *, unsigned> AddrPool;
+ typedef DenseMap<const MCSymbol *, AddressPoolEntry> AddrPool;
AddrPool AddressPool;
unsigned NextAddrPoolNumber;
@@ -303,8 +308,7 @@ public:
/// \brief Returns the index into the address pool with the given
/// label/symbol.
- unsigned getAddrPoolIndex(const MCExpr *Sym);
- unsigned getAddrPoolIndex(const MCSymbol *Sym);
+ unsigned getAddrPoolIndex(const MCSymbol *Sym, bool TLS = false);
/// \brief Returns the address pool.
AddrPool *getAddrPool() { return &AddressPool; }
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=201469&r1=201468&r2=201469&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Sat Feb 15 13:34:03 2014
@@ -1580,8 +1580,6 @@ void DwarfCompileUnit::createGlobalVaria
unsigned PointerSize = Asm->getDataLayout().getPointerSize();
assert((PointerSize == 4 || PointerSize == 8) &&
"Add support for other sizes if necessary");
- const MCExpr *Expr =
- Asm->getObjFileLowering().getDebugThreadLocalSymbol(Sym);
// Based on GCC's support for TLS:
if (!DD->useSplitDwarf()) {
// 1) Start with a constNu of the appropriate pointer size
@@ -1589,10 +1587,12 @@ void DwarfCompileUnit::createGlobalVaria
PointerSize == 4 ? dwarf::DW_OP_const4u : dwarf::DW_OP_const8u);
// 2) containing the (relocated) offset of the TLS variable
// within the module's TLS block.
- addExpr(Block, dwarf::DW_FORM_udata, Expr);
+ addExpr(Block, dwarf::DW_FORM_udata,
+ Asm->getObjFileLowering().getDebugThreadLocalSymbol(Sym));
} else {
addUInt(Block, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_const_index);
- addUInt(Block, dwarf::DW_FORM_udata, DU->getAddrPoolIndex(Expr));
+ addUInt(Block, dwarf::DW_FORM_udata,
+ DU->getAddrPoolIndex(Sym, /* TLS */ true));
}
// 3) followed by a custom OP to make the debugger do a TLS lookup.
addUInt(Block, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_push_tls_address);
Modified: llvm/trunk/test/DebugInfo/X86/tls.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/tls.ll?rev=201469&r1=201468&r2=201469&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/tls.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/tls.ll Sat Feb 15 13:34:03 2014
@@ -43,8 +43,7 @@
; FISSION: .byte 3 # DW_AT_location
; DW_OP_GNU_addr_index
; FISSION-NEXT: .byte 251
-; FIXME: This should be '1' to share the address table entry with the variable location above
-; FISSION-NEXT: .byte 2
+; FISSION-NEXT: .byte 1
; DW_OP_stack_value
; FISSION-NEXT: .byte 159
@@ -52,8 +51,7 @@
; FISSION: .section .debug_addr
; FISSION-NEXT: .quad tls at DTPOFF
; FISSION-NEXT: .quad glbl
-; FIXME: Deduplicate the debug_addr list
-; FISSION-NEXT: .quad glbl
+; FISSION-NOT: .quad glbl
; Generated from:
More information about the llvm-commits
mailing list