[llvm] r219370 - Sink DwarfDebug::addScopeRangeList down into DwarfCompileUnit
David Blaikie
dblaikie at gmail.com
Wed Oct 8 17:11:40 PDT 2014
Author: dblaikie
Date: Wed Oct 8 19:11:39 2014
New Revision: 219370
URL: http://llvm.org/viewvc/llvm-project?rev=219370&view=rev
Log:
Sink DwarfDebug::addScopeRangeList down into DwarfCompileUnit
(& add a few accessors/make a couple of things public for this - it's a
bit of a toss-up, but I think I prefer it this way, keeping some more of
the meaty code down in DwarfCompileUnit - if only to make for smaller
implementation files, etc)
I think we could simplify range handling a bit if we removed the range
lists from each unit and just put a single range list on DwarfDebug,
similar to address pooling.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=219370&r1=219369&r2=219370&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Wed Oct 8 19:11:39 2014
@@ -395,4 +395,30 @@ void DwarfCompileUnit::addSectionDelta(D
Value);
}
+void
+DwarfCompileUnit::addScopeRangeList(DIE &ScopeDIE,
+ const SmallVectorImpl<InsnRange> &Range) {
+ // Emit offset in .debug_range as a relocatable label. emitDIE will handle
+ // emitting it appropriately.
+ MCSymbol *RangeSym =
+ Asm->GetTempSymbol("debug_ranges", DD->getNextRangeNumber());
+
+ auto *RangeSectionSym = DD->getRangeSectionSym();
+
+ // Under fission, ranges are specified by constant offsets relative to the
+ // CU's DW_AT_GNU_ranges_base.
+ if (DD->useSplitDwarf())
+ addSectionDelta(ScopeDIE, dwarf::DW_AT_ranges, RangeSym, RangeSectionSym);
+ else
+ addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges, RangeSym, RangeSectionSym);
+
+ RangeSpanList List(RangeSym);
+ for (const InsnRange &R : Range)
+ List.addRange(RangeSpan(DD->getLabelBeforeInsn(R.first),
+ DD->getLabelAfterInsn(R.second)));
+
+ // Add the range list to the set of ranges to be emitted.
+ addRangeList(std::move(List));
+}
+
} // end llvm namespace
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=219370&r1=219369&r2=219370&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Wed Oct 8 19:11:39 2014
@@ -81,6 +81,11 @@ public:
void constructScopeDIE(LexicalScope *Scope,
SmallVectorImpl<std::unique_ptr<DIE>> &FinalChildren);
+
+ /// \brief A helper function to construct a RangeSpanList for a given
+ /// lexical scope.
+ void addScopeRangeList(DIE &ScopeDIE,
+ const SmallVectorImpl<InsnRange> &Range);
};
} // end llvm namespace
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=219370&r1=219369&r2=219370&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Oct 8 19:11:39 2014
@@ -330,31 +330,6 @@ bool DwarfDebug::isLexicalScopeDIENull(L
return !getLabelAfterInsn(Ranges.front().second);
}
-void DwarfDebug::addScopeRangeList(DwarfCompileUnit &TheCU, DIE &ScopeDIE,
- const SmallVectorImpl<InsnRange> &Range) {
- // Emit offset in .debug_range as a relocatable label. emitDIE will handle
- // emitting it appropriately.
- MCSymbol *RangeSym = Asm->GetTempSymbol("debug_ranges", GlobalRangeCount++);
-
- // Under fission, ranges are specified by constant offsets relative to the
- // CU's DW_AT_GNU_ranges_base.
- if (useSplitDwarf())
- TheCU.addSectionDelta(ScopeDIE, dwarf::DW_AT_ranges, RangeSym,
- DwarfDebugRangeSectionSym);
- else
- TheCU.addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges, RangeSym,
- DwarfDebugRangeSectionSym);
-
- RangeSpanList List(RangeSym);
- for (const InsnRange &R : Range) {
- RangeSpan Span(getLabelBeforeInsn(R.first), getLabelAfterInsn(R.second));
- List.addRange(std::move(Span));
- }
-
- // Add the range list to the set of ranges to be emitted.
- TheCU.addRangeList(std::move(List));
-}
-
void DwarfDebug::attachRangesOrLowHighPC(DwarfCompileUnit &TheCU, DIE &Die,
const SmallVectorImpl<InsnRange> &Ranges) {
assert(!Ranges.empty());
@@ -362,7 +337,7 @@ void DwarfDebug::attachRangesOrLowHighPC
TheCU.attachLowHighPC(Die, getLabelBeforeInsn(Ranges.front().first),
getLabelAfterInsn(Ranges.front().second));
else
- addScopeRangeList(TheCU, Die, Ranges);
+ TheCU.addScopeRangeList(Die, Ranges);
}
// Construct new DW_TAG_lexical_block for this scope and attach
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=219370&r1=219369&r2=219370&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Oct 8 19:11:39 2014
@@ -349,11 +349,6 @@ class DwarfDebug : public AsmPrinterHand
void ensureAbstractVariableIsCreatedIfScoped(const DIVariable &Var,
const MDNode *Scope);
- /// \brief A helper function to construct a RangeSpanList for a given
- /// lexical scope.
- void addScopeRangeList(DwarfCompileUnit &TheCU, DIE &ScopeDIE,
- const SmallVectorImpl<InsnRange> &Range);
-
DIE *createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope,
DIE &ScopeDIE);
/// \brief Construct a DIE for this abstract scope.
@@ -518,17 +513,11 @@ class DwarfDebug : public AsmPrinterHand
LabelsBeforeInsn.insert(std::make_pair(MI, nullptr));
}
- /// \brief Return Label preceding the instruction.
- MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
-
/// \brief Ensure that a label will be emitted after MI.
void requestLabelAfterInsn(const MachineInstr *MI) {
LabelsAfterInsn.insert(std::make_pair(MI, nullptr));
}
- /// \brief Return Label immediately following the instruction.
- MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
-
void attachRangesOrLowHighPC(DwarfCompileUnit &Unit, DIE &D,
const SmallVectorImpl<InsnRange> &Ranges);
@@ -602,6 +591,9 @@ public:
/// Returns the section symbol for the .debug_str section.
MCSymbol *getDebugStrSym() const { return DwarfStrSectionSym; }
+ /// Returns the section symbol for the .debug_ranges section.
+ MCSymbol *getRangeSectionSym() const { return DwarfDebugRangeSectionSym; }
+
/// Returns the previous CU that was being updated
const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
@@ -688,6 +680,14 @@ public:
DIE *createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope,
SmallVectorImpl<std::unique_ptr<DIE>> &Children,
unsigned *ChildScopeCount = nullptr);
+
+ /// \brief Return Label preceding the instruction.
+ MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
+
+ /// \brief Return Label immediately following the instruction.
+ MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
+
+ unsigned getNextRangeNumber() { return GlobalRangeCount++; }
};
} // End of namespace llvm
More information about the llvm-commits
mailing list