[llvm-commits] [llvm] r102127 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h test/DebugInfo/2010-04-22-range.ll
Devang Patel
dpatel at apple.com
Thu Apr 22 13:52:00 PDT 2010
Author: dpatel
Date: Thu Apr 22 15:52:00 2010
New Revision: 102127
URL: http://llvm.org/viewvc/llvm-project?rev=102127&view=rev
Log:
Adjust debug range offsets for isWeakForLinker() functions.
Added:
llvm/trunk/test/DebugInfo/2010-04-22-range.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=102127&r1=102126&r2=102127&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Apr 22 15:52:00 2010
@@ -1384,6 +1384,11 @@
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 @@
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 @@
// 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);
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=102127&r1=102126&r2=102127&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Thu Apr 22 15:52:00 2010
@@ -197,6 +197,7 @@
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.
Added: llvm/trunk/test/DebugInfo/2010-04-22-range.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2010-04-22-range.ll?rev=102127&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/2010-04-22-range.ll (added)
+++ llvm/trunk/test/DebugInfo/2010-04-22-range.ll Thu Apr 22 15:52:00 2010
@@ -0,0 +1,38 @@
+; RUN: llc < %s | grep "Ltmp3-Lfunc_begin"
+; PR 6894
+
+declare void @_Z7examplev() ssp
+
+define linkonce_odr void @_bar(i64, i64, i64 %__depth_limit) ssp {
+entry:
+ br i1 undef, label %while.body, label %while.end, !dbg !0
+
+while.body: ; preds = %entry
+ br i1 undef, label %if.then, label %if.end, !dbg !8
+
+if.then: ; preds = %while.body
+ call void @_Z7examplev(), !dbg !10
+ ret void, !dbg !12
+
+if.end: ; preds = %while.body
+ call void @_Z7examplev(), !dbg !13
+ unreachable
+
+while.end: ; preds = %entry
+ ret void, !dbg !12
+}
+
+!0 = metadata !{i32 2742, i32 7, metadata !1, null}
+!1 = metadata !{i32 524299, metadata !2, i32 2738, i32 5} ; [ DW_TAG_lexical_block ]
+!2 = metadata !{i32 524334, i32 0, metadata !3, metadata !"__introsort_loop", metadata !"__introsort_loop", metadata !"_bar", metadata !3, i32 2738, metadata !5, i1 false, i1 true, i32 0, i32 0, null, i1 false} ; [ DW_TAG_subprogram ]
+!3 = metadata !{i32 524329, metadata !"stl_algo.h", metadata !"/usr/include/c++/4.2.1/bits", metadata !4} ; [ DW_TAG_file_type ]
+!4 = metadata !{i32 524305, i32 0, i32 4, metadata !"example.cc", metadata !"/tmp", metadata !"clang 1.5", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
+!5 = metadata !{i32 524309, metadata !6, metadata !"", metadata !6, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, null} ; [ DW_TAG_subroutine_type ]
+!6 = metadata !{i32 524329, metadata !"example.cc", metadata !"/tmp", metadata !4} ; [ DW_TAG_file_type ]
+!7 = metadata !{null}
+!8 = metadata !{i32 2744, i32 4, metadata !9, null}
+!9 = metadata !{i32 524299, metadata !1, i32 2743, i32 2} ; [ DW_TAG_lexical_block ]
+!10 = metadata !{i32 2746, i32 8, metadata !11, null}
+!11 = metadata !{i32 524299, metadata !9, i32 2745, i32 6} ; [ DW_TAG_lexical_block ]
+!12 = metadata !{i32 2762, i32 5, metadata !1, null}
+!13 = metadata !{i32 2750, i32 4, metadata !9, null}
More information about the llvm-commits
mailing list