diff options
author | Devang Patel <dpatel@apple.com> | 2010-04-22 20:52:00 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-04-22 20:52:00 +0000 |
commit | ea2744f4dc82611edb8d70e2dd0b3beef29e4c17 (patch) | |
tree | 1710c988672b7fa1cb299637e83259ce7e18b329 /llvm/lib/CodeGen | |
parent | 00365f967b6c1cefb464ed5ab43bef382764ff64 (diff) | |
download | bcm5719-llvm-ea2744f4dc82611edb8d70e2dd0b3beef29e4c17.tar.gz bcm5719-llvm-ea2744f4dc82611edb8d70e2dd0b3beef29e4c17.zip |
Adjust debug range offsets for isWeakForLinker() functions.
llvm-svn: 102127
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 34 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 1 |
2 files changed, 29 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index dc6b998db8a..06782423fe3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1384,6 +1384,11 @@ DIE *DwarfDebug::constructLexicalScopeDIE(DbgScope *Scope) { if (Ranges.empty()) return 0; + bool MarkFunctionBegin = false; + if (FunctionBeginSym && + Asm->MF->getFunction()->isWeakForLinker()) + MarkFunctionBegin = true; + SmallVector<DbgRange, 4>::const_iterator RI = Ranges.begin(); if (Ranges.size() > 1) { // .debug_range section has not been laid out yet. Emit offset in @@ -1393,8 +1398,15 @@ DIE *DwarfDebug::constructLexicalScopeDIE(DbgScope *Scope) { DebugRangeSymbols.size() * Asm->getTargetData().getPointerSize()); for (SmallVector<DbgRange, 4>::const_iterator RI = Ranges.begin(), RE = Ranges.end(); RI != RE; ++RI) { - DebugRangeSymbols.push_back(LabelsBeforeInsn.lookup(RI->first)); - DebugRangeSymbols.push_back(LabelsAfterInsn.lookup(RI->second)); + MCSymbol *Sym = LabelsBeforeInsn.lookup(RI->first); + if (MarkFunctionBegin) + WeakDebugRangeSymbols.insert(std::make_pair(Sym, FunctionBeginSym)); + DebugRangeSymbols.push_back(Sym); + + Sym = LabelsAfterInsn.lookup(RI->second); + if (MarkFunctionBegin) + WeakDebugRangeSymbols.insert(std::make_pair(Sym, FunctionBeginSym)); + DebugRangeSymbols.push_back(Sym); } DebugRangeSymbols.push_back(NULL); DebugRangeSymbols.push_back(NULL); @@ -3228,11 +3240,21 @@ void DwarfDebug::emitDebugRanges() { // Start the dwarf ranges section. Asm->OutStreamer.SwitchSection( Asm->getObjFileLowering().getDwarfRangesSection()); - for (SmallVector<const MCSymbol *, 8>::const_iterator I = DebugRangeSymbols.begin(), - E = DebugRangeSymbols.end(); I != E; ++I) { - if (*I) - Asm->EmitLabelDifference(*I, TextSectionSym, + for (SmallVector<const MCSymbol *, 8>::const_iterator + I = DebugRangeSymbols.begin(), E = DebugRangeSymbols.end(); + I != E; ++I) { + if (*I) { + const MCSymbol *Begin = TextSectionSym; + // If this symbol is inside linkonce section then use appropriate begin + // marker; + DenseMap<const MCSymbol *, const MCSymbol *>::iterator WI + = WeakDebugRangeSymbols.find(*I); + if (WI != WeakDebugRangeSymbols.end()) + Begin = WI->second; + + Asm->EmitLabelDifference(*I, Begin, Asm->getTargetData().getPointerSize()); + } else Asm->OutStreamer.EmitIntValue(0, Asm->getTargetData().getPointerSize(), /*addrspace*/0); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index 698f7106019..b3f97458081 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -197,6 +197,7 @@ class DwarfDebug { DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn; SmallVector<const MCSymbol *, 8> DebugRangeSymbols; + DenseMap<const MCSymbol *, const MCSymbol *> WeakDebugRangeSymbols; /// Previous instruction's location information. This is used to determine /// label location to indicate scope boundries in dwarf debug info. |