aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2010-04-22 20:52:00 +0000
committerDevang Patel <dpatel@apple.com>2010-04-22 20:52:00 +0000
commit18ee3bb0b784d29fdff40301d5691e7e855de547 (patch)
tree031359d53612890889ffc5dcb50b02cc5a83c21f /lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parent9c675f14c1288f99692e4906ea4c8a434ac4d693 (diff)
Adjust debug range offsets for isWeakForLinker() functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102127 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index dc6b998db8..06782423fe 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/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);