Use move and stack allocation for RangeSpanLists. As a result make

a few things more const as well because we're now using const
references to refer to iterators.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196398 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher 2013-12-04 19:06:58 +00:00
parent 12b493af2b
commit fb934a2183
3 changed files with 17 additions and 21 deletions

View File

@ -471,17 +471,17 @@ void DwarfDebug::addScopeRangeList(CompileUnit *TheCU, DIE *ScopeDIE,
// emitting it appropriately. // emitting it appropriately.
TheCU->addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges, TheCU->addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges,
Asm->GetTempSymbol("debug_ranges", GlobalRangeCount)); Asm->GetTempSymbol("debug_ranges", GlobalRangeCount));
RangeSpanList *List = new RangeSpanList(GlobalRangeCount++); RangeSpanList List(GlobalRangeCount++);
for (SmallVectorImpl<InsnRange>::const_iterator RI = Range.begin(), for (SmallVectorImpl<InsnRange>::const_iterator RI = Range.begin(),
RE = Range.end(); RE = Range.end();
RI != RE; ++RI) { RI != RE; ++RI) {
RangeSpan Span(getLabelBeforeInsn(RI->first), RangeSpan Span(getLabelBeforeInsn(RI->first),
getLabelAfterInsn(RI->second)); getLabelAfterInsn(RI->second));
List->addRange(Span); List.addRange(llvm_move(Span));
} }
// Add the range list to the set of ranges to be emitted. // Add the range list to the set of ranges to be emitted.
TheCU->addRangeList(List); TheCU->addRangeList(llvm_move(List));
} }
// Construct new DW_TAG_lexical_block for this scope and attach // Construct new DW_TAG_lexical_block for this scope and attach
@ -2938,22 +2938,22 @@ void DwarfDebug::emitDebugRanges() {
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("gnu_ranges", ID)); Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("gnu_ranges", ID));
// Iterate over the misc ranges for the compile units in the module. // Iterate over the misc ranges for the compile units in the module.
const SmallVectorImpl<RangeSpanList *> &RangeLists = TheCU->getRangeLists(); const SmallVectorImpl<RangeSpanList> &RangeLists = TheCU->getRangeLists();
for (SmallVectorImpl<RangeSpanList *>::const_iterator for (SmallVectorImpl<RangeSpanList>::const_iterator
I = RangeLists.begin(), I = RangeLists.begin(),
E = RangeLists.end(); E = RangeLists.end();
I != E; ++I) { I != E; ++I) {
RangeSpanList *List = *I; const RangeSpanList &List = *I;
// Emit a symbol so we can find the beginning of the range. // Emit a symbol so we can find the beginning of the range.
Asm->OutStreamer.EmitLabel( Asm->OutStreamer.EmitLabel(
Asm->GetTempSymbol("debug_ranges", List->getIndex())); Asm->GetTempSymbol("debug_ranges", List.getIndex()));
for (SmallVectorImpl<RangeSpan>::const_iterator for (SmallVectorImpl<RangeSpan>::const_iterator
I = List->getRanges().begin(), RI = List.getRanges().begin(),
E = List->getRanges().end(); RE = List.getRanges().end();
I != E; ++I) { RI != RE; ++RI) {
RangeSpan Range = *I; const RangeSpan &Range = *RI;
// We occasionally have ranges without begin/end labels. // We occasionally have ranges without begin/end labels.
// FIXME: Verify and fix. // FIXME: Verify and fix.
const MCSymbol *Begin = Range.getStart(); const MCSymbol *Begin = Range.getStart();

View File

@ -59,10 +59,6 @@ TypeUnit::TypeUnit(unsigned UID, DIE *D, uint16_t Language, AsmPrinter *A,
Unit::~Unit() { Unit::~Unit() {
for (unsigned j = 0, M = DIEBlocks.size(); j < M; ++j) for (unsigned j = 0, M = DIEBlocks.size(); j < M; ++j)
DIEBlocks[j]->~DIEBlock(); DIEBlocks[j]->~DIEBlock();
for (SmallVectorImpl<RangeSpanList *>::iterator RI = getRangeLists().begin(),
RE = getRangeLists().end();
RI != RE; ++RI)
delete *RI;
} }
/// createDIEEntry - Creates a new DIEEntry to be a proxy for a debug /// createDIEEntry - Creates a new DIEEntry to be a proxy for a debug

View File

@ -35,8 +35,8 @@ class DbgVariable;
class RangeSpan { class RangeSpan {
public: public:
RangeSpan(MCSymbol *S, MCSymbol *E) : Start(S), End(E) {} RangeSpan(MCSymbol *S, MCSymbol *E) : Start(S), End(E) {}
const MCSymbol *getStart() { return Start; } const MCSymbol *getStart() const { return Start; }
const MCSymbol *getEnd() { return End; } const MCSymbol *getEnd() const { return End; }
private: private:
const MCSymbol *Start, *End; const MCSymbol *Start, *End;
@ -119,7 +119,7 @@ protected:
// List of range lists for a given compile unit, separate from the ranges for // List of range lists for a given compile unit, separate from the ranges for
// the CU itself. // the CU itself.
SmallVector<RangeSpanList *, 1> CURangeLists; SmallVector<RangeSpanList, 1> CURangeLists;
// DIEValueAllocator - All DIEValues are allocated through this allocator. // DIEValueAllocator - All DIEValues are allocated through this allocator.
BumpPtrAllocator DIEValueAllocator; BumpPtrAllocator DIEValueAllocator;
@ -162,13 +162,13 @@ public:
bool hasContent() const { return !UnitDie->getChildren().empty(); } bool hasContent() const { return !UnitDie->getChildren().empty(); }
/// addRangeList - Add an address range list to the list of range lists. /// addRangeList - Add an address range list to the list of range lists.
void addRangeList(RangeSpanList *Ranges) { CURangeLists.push_back(Ranges); } void addRangeList(RangeSpanList Ranges) { CURangeLists.push_back(Ranges); }
/// getRangeLists - Get the vector of range lists. /// getRangeLists - Get the vector of range lists.
const SmallVectorImpl<RangeSpanList *> &getRangeLists() const { const SmallVectorImpl<RangeSpanList> &getRangeLists() const {
return CURangeLists; return CURangeLists;
} }
SmallVectorImpl<RangeSpanList *> &getRangeLists() { return CURangeLists; } SmallVectorImpl<RangeSpanList> &getRangeLists() { return CURangeLists; }
/// getParentContextString - Get a string containing the language specific /// getParentContextString - Get a string containing the language specific
/// context for a global name. /// context for a global name.