[llvm-commits] [llvm] r97917 - in /llvm/trunk: include/llvm/ADT/STLExtras.h lib/CodeGen/AsmPrinter/DIE.h lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h
Jeffrey Yasskin
jyasskin at google.com
Sun Mar 7 09:10:13 PST 2010
Author: jyasskin
Date: Sun Mar 7 11:10:13 2010
New Revision: 97917
URL: http://llvm.org/viewvc/llvm-project?rev=97917&view=rev
Log:
Roll r97906 forward again, without double-deleting CompileUnit::IndexTyDie.
Modified:
llvm/trunk/include/llvm/ADT/STLExtras.h
llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
Modified: llvm/trunk/include/llvm/ADT/STLExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/STLExtras.h?rev=97917&r1=97916&r2=97917&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/STLExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/STLExtras.h Sun Mar 7 11:10:13 2010
@@ -279,6 +279,28 @@
qsort(&*Start, End-Start, sizeof(*Start), Compare);
}
+//===----------------------------------------------------------------------===//
+// Extra additions to <algorithm>
+//===----------------------------------------------------------------------===//
+
+/// For a container of pointers, deletes the pointers and then clears the
+/// container.
+template<typename Container>
+void DeleteContainerPointers(Container &C) {
+ for (typename Container::iterator I = C.begin(), E = C.end(); I != E; ++I)
+ delete *I;
+ C.clear();
+}
+
+/// In a container of pairs (usually a map) whose second element is a pointer,
+/// deletes the second elements and then clears the container.
+template<typename Container>
+void DeleteContainerSeconds(Container &C) {
+ for (typename Container::iterator I = C.begin(), E = C.end(); I != E; ++I)
+ delete I->second;
+ C.clear();
+}
+
} // End llvm namespace
#endif
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h?rev=97917&r1=97916&r2=97917&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h Sun Mar 7 11:10:13 2010
@@ -112,7 +112,6 @@
//===--------------------------------------------------------------------===//
/// DIE - A structured debug information entry. Has an abbreviation which
/// describes it's organization.
- class CompileUnit;
class DIEValue;
class DIE {
@@ -159,7 +158,6 @@
void setTag(unsigned Tag) { Abbrev.setTag(Tag); }
void setOffset(unsigned O) { Offset = O; }
void setSize(unsigned S) { Size = S; }
- void setParent(DIE *P) { Parent = P; }
/// addValue - Add a value and attributes to a DIE.
///
@@ -185,7 +183,7 @@
}
Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes);
Children.push_back(Child);
- Child->setParent(this);
+ Child->Parent = this;
}
#ifndef NDEBUG
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=97917&r1=97916&r2=97917&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sun Mar 7 11:10:13 2010
@@ -23,6 +23,7 @@
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetRegisterInfo.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
@@ -50,9 +51,9 @@
/// Die - Compile unit debug information entry.
///
- DIE *CUDie;
+ const OwningPtr<DIE> CUDie;
- /// IndexTyDie - An anonymous type for index type.
+ /// IndexTyDie - An anonymous type for index type. Owned by CUDie
DIE *IndexTyDie;
/// GVToDieMap - Tracks the mapping of unit level debug informaton
@@ -76,11 +77,10 @@
public:
CompileUnit(unsigned I, DIE *D)
: ID(I), CUDie(D), IndexTyDie(0) {}
- ~CompileUnit() { delete CUDie; delete IndexTyDie; }
// Accessors.
unsigned getID() const { return ID; }
- DIE* getCUDie() const { return CUDie; }
+ DIE* getCUDie() const { return CUDie.get(); }
const StringMap<DIE*> &getGlobals() const { return Globals; }
const StringMap<DIE*> &getGlobalTypes() const { return GlobalTypes; }
@@ -174,8 +174,10 @@
unsigned EndLabelID; // Label ID of the end of scope.
const MachineInstr *LastInsn; // Last instruction of this scope.
const MachineInstr *FirstInsn; // First instruction of this scope.
- SmallVector<DbgScope *, 4> Scopes; // Scopes defined in scope.
- SmallVector<DbgVariable *, 8> Variables;// Variables declared in scope.
+ // Scopes defined in scope. Contents not owned.
+ SmallVector<DbgScope *, 4> Scopes;
+ // Variables declared in scope. Contents owned.
+ SmallVector<DbgVariable *, 8> Variables;
// Private state for dump()
mutable unsigned IndentLevel;
@@ -196,8 +198,8 @@
MDNode *getScopeNode() const { return Desc.getNode(); }
unsigned getStartLabelID() const { return StartLabelID; }
unsigned getEndLabelID() const { return EndLabelID; }
- SmallVector<DbgScope *, 4> &getScopes() { return Scopes; }
- SmallVector<DbgVariable *, 8> &getVariables() { return Variables; }
+ const SmallVector<DbgScope *, 4> &getScopes() { return Scopes; }
+ const SmallVector<DbgVariable *, 8> &getVariables() { return Variables; }
void setStartLabelID(unsigned S) { StartLabelID = S; }
void setEndLabelID(unsigned E) { EndLabelID = E; }
void setLastInsn(const MachineInstr *MI) { LastInsn = MI; }
@@ -220,14 +222,14 @@
assert (getFirstInsn() && "First instruction is missing!");
// Use the end of last child scope as end of this scope.
- SmallVector<DbgScope *, 4> &Scopes = getScopes();
+ const SmallVector<DbgScope *, 4> &Scopes = getScopes();
const MachineInstr *LastInsn = getFirstInsn();
unsigned LIndex = 0;
if (Scopes.empty()) {
assert (getLastInsn() && "Inner most scope does not have last insn!");
return;
}
- for (SmallVector<DbgScope *, 4>::iterator SI = Scopes.begin(),
+ for (SmallVector<DbgScope *, 4>::const_iterator SI = Scopes.begin(),
SE = Scopes.end(); SI != SE; ++SI) {
DbgScope *DS = *SI;
DS->fixInstructionMarkers(MIIndexMap);
@@ -279,8 +281,6 @@
#endif
DbgScope::~DbgScope() {
- for (unsigned i = 0, N = Scopes.size(); i < N; ++i)
- delete Scopes[i];
for (unsigned j = 0, M = Variables.size(); j < M; ++j)
delete Variables[j];
}
@@ -1585,7 +1585,7 @@
}
// Add variables to scope.
- SmallVector<DbgVariable *, 8> &Variables = Scope->getVariables();
+ const SmallVector<DbgVariable *, 8> &Variables = Scope->getVariables();
for (unsigned i = 0, N = Variables.size(); i < N; ++i) {
DIE *VariableDIE = constructVariableDIE(Variables[i], Scope);
if (VariableDIE)
@@ -1593,7 +1593,7 @@
}
// Add nested scopes.
- SmallVector<DbgScope *, 4> &Scopes = Scope->getScopes();
+ const SmallVector<DbgScope *, 4> &Scopes = Scope->getScopes();
for (unsigned j = 0, M = Scopes.size(); j < M; ++j) {
// Define the Scope debug information entry.
DIE *NestedDIE = constructScopeDIE(Scopes[j]);
@@ -1696,7 +1696,6 @@
}
CompileUnitMap[DIUnit.getNode()] = Unit;
- CompileUnits.push_back(Unit);
return Unit;
}
@@ -1802,7 +1801,7 @@
E = DbgFinder.compile_unit_end(); I != E; ++I)
constructCompileUnit(*I);
- if (CompileUnits.empty()) {
+ if (CompileUnitMap.empty()) {
if (TimePassesIsEnabled)
DebugTimer->stopTimer();
@@ -1812,7 +1811,7 @@
// If main compile unit for this module is not seen than randomly
// select first compile unit.
if (!ModuleCU)
- ModuleCU = CompileUnits[0];
+ ModuleCU = CompileUnitMap.begin()->second;
// Create DIEs for each subprogram.
for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(),
@@ -1944,6 +1943,10 @@
// Emit inline info.
emitDebugInlineInfo();
+ // Clear debug info in preparation for the next Module.
+ ModuleCU = NULL;
+ DeleteContainerSeconds(CompileUnitMap);
+
if (TimePassesIsEnabled)
DebugTimer->stopTimer();
}
@@ -2114,9 +2117,9 @@
while (!WorkList.empty()) {
DbgScope *S = WorkList.back(); WorkList.pop_back();
- SmallVector<DbgScope *, 4> &Children = S->getScopes();
+ const SmallVector<DbgScope *, 4> &Children = S->getScopes();
if (!Children.empty())
- for (SmallVector<DbgScope *, 4>::iterator SI = Children.begin(),
+ for (SmallVector<DbgScope *, 4>::const_iterator SI = Children.begin(),
SE = Children.end(); SI != SE; ++SI)
WorkList.push_back(*SI);
@@ -2221,10 +2224,11 @@
// Clear debug info
CurrentFnDbgScope = NULL;
- DbgScopeMap.clear();
+ DeleteContainerSeconds(DbgScopeMap);
DbgScopeBeginMap.clear();
DbgScopeEndMap.clear();
ConcreteScopes.clear();
+ DeleteContainerSeconds(AbstractScopes);
AbstractScopesList.clear();
Lines.clear();
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=97917&r1=97916&r2=97917&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Sun Mar 7 11:10:13 2010
@@ -66,10 +66,6 @@
/// compile units.
DenseMap<Value *, CompileUnit *> CompileUnitMap;
- /// CompileUnits - All the compile units in this module.
- ///
- SmallVector<CompileUnit *, 8> CompileUnits;
-
/// ModuleCU - All DIEs are inserted in ModuleCU.
CompileUnit *ModuleCU;
@@ -134,7 +130,8 @@
//
DbgScope *CurrentFnDbgScope;
- /// DbgScopeMap - Tracks the scopes in the current function.
+ /// DbgScopeMap - Tracks the scopes in the current function. Owns the
+ /// contained DbgScope*s.
///
DenseMap<MDNode *, DbgScope *> DbgScopeMap;
@@ -143,7 +140,7 @@
DenseMap<MDNode *, DbgScope *> ConcreteScopes;
/// AbstractScopes - Tracks the abstract scopes a module. These scopes are
- /// not included DbgScopeMap.
+ /// not included DbgScopeMap. AbstractScopes owns its DbgScope*s.
DenseMap<MDNode *, DbgScope *> AbstractScopes;
SmallVector<DbgScope *, 4>AbstractScopesList;
More information about the llvm-commits
mailing list