summaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-08 02:58:37 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-08 02:58:37 +0000
commit1ddcf35b68a4c326c548272134611ce54b1afd25 (patch)
tree5c79b73f645fbb8507ff0e2b94a4ff2018213836 /lib/CodeGen
parent6fec233a1e4b26be2f69e02884d4f3c2a2c4a437 (diff)
downloadllvm-1ddcf35b68a4c326c548272134611ce54b1afd25.tar.gz
llvm-1ddcf35b68a4c326c548272134611ce54b1afd25.tar.bz2
llvm-1ddcf35b68a4c326c548272134611ce54b1afd25.tar.xz
Revert r97917, which was causing Clang Debug self-host failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97932 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter/DIE.h4
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp44
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.h9
3 files changed, 29 insertions, 28 deletions
diff --git a/lib/CodeGen/AsmPrinter/DIE.h b/lib/CodeGen/AsmPrinter/DIE.h
index 21f5d629e1..af90289e5f 100644
--- a/lib/CodeGen/AsmPrinter/DIE.h
+++ b/lib/CodeGen/AsmPrinter/DIE.h
@@ -112,6 +112,7 @@ namespace llvm {
//===--------------------------------------------------------------------===//
/// DIE - A structured debug information entry. Has an abbreviation which
/// describes it's organization.
+ class CompileUnit;
class DIEValue;
class DIE {
@@ -158,6 +159,7 @@ namespace llvm {
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.
///
@@ -183,7 +185,7 @@ namespace llvm {
}
Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes);
Children.push_back(Child);
- Child->Parent = this;
+ Child->setParent(this);
}
#ifndef NDEBUG
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 6846511130..5ad1e5ea05 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -23,7 +23,6 @@
#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"
@@ -51,9 +50,9 @@ class CompileUnit {
/// Die - Compile unit debug information entry.
///
- const OwningPtr<DIE> CUDie;
+ DIE *CUDie;
- /// IndexTyDie - An anonymous type for index type. Owned by CUDie
+ /// IndexTyDie - An anonymous type for index type.
DIE *IndexTyDie;
/// GVToDieMap - Tracks the mapping of unit level debug informaton
@@ -77,10 +76,11 @@ class CompileUnit {
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.get(); }
+ DIE* getCUDie() const { return CUDie; }
const StringMap<DIE*> &getGlobals() const { return Globals; }
const StringMap<DIE*> &getGlobalTypes() const { return GlobalTypes; }
@@ -174,10 +174,8 @@ class DbgScope {
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.
- // Scopes defined in scope. Contents not owned.
- SmallVector<DbgScope *, 4> Scopes;
- // Variables declared in scope. Contents owned.
- SmallVector<DbgVariable *, 8> Variables;
+ SmallVector<DbgScope *, 4> Scopes; // Scopes defined in scope.
+ SmallVector<DbgVariable *, 8> Variables;// Variables declared in scope.
// Private state for dump()
mutable unsigned IndentLevel;
@@ -198,8 +196,8 @@ public:
MDNode *getScopeNode() const { return Desc.getNode(); }
unsigned getStartLabelID() const { return StartLabelID; }
unsigned getEndLabelID() const { return EndLabelID; }
- const SmallVector<DbgScope *, 4> &getScopes() { return Scopes; }
- const SmallVector<DbgVariable *, 8> &getVariables() { return Variables; }
+ SmallVector<DbgScope *, 4> &getScopes() { return Scopes; }
+ 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; }
@@ -222,14 +220,14 @@ public:
assert (getFirstInsn() && "First instruction is missing!");
// Use the end of last child scope as end of this scope.
- const SmallVector<DbgScope *, 4> &Scopes = getScopes();
+ 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>::const_iterator SI = Scopes.begin(),
+ for (SmallVector<DbgScope *, 4>::iterator SI = Scopes.begin(),
SE = Scopes.end(); SI != SE; ++SI) {
DbgScope *DS = *SI;
DS->fixInstructionMarkers(MIIndexMap);
@@ -281,6 +279,8 @@ void DbgScope::dump() const {
#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 @@ DIE *DwarfDebug::constructScopeDIE(DbgScope *Scope) {
}
// Add variables to scope.
- const SmallVector<DbgVariable *, 8> &Variables = Scope->getVariables();
+ 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 @@ DIE *DwarfDebug::constructScopeDIE(DbgScope *Scope) {
}
// Add nested scopes.
- const SmallVector<DbgScope *, 4> &Scopes = Scope->getScopes();
+ 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,6 +1696,7 @@ CompileUnit *DwarfDebug::constructCompileUnit(MDNode *N) {
}
CompileUnitMap[DIUnit.getNode()] = Unit;
+ CompileUnits.push_back(Unit);
return Unit;
}
@@ -1801,7 +1802,7 @@ void DwarfDebug::beginModule(Module *M, MachineModuleInfo *mmi) {
E = DbgFinder.compile_unit_end(); I != E; ++I)
constructCompileUnit(*I);
- if (CompileUnitMap.empty()) {
+ if (CompileUnits.empty()) {
if (TimePassesIsEnabled)
DebugTimer->stopTimer();
@@ -1811,7 +1812,7 @@ void DwarfDebug::beginModule(Module *M, MachineModuleInfo *mmi) {
// If main compile unit for this module is not seen than randomly
// select first compile unit.
if (!ModuleCU)
- ModuleCU = CompileUnitMap.begin()->second;
+ ModuleCU = CompileUnits[0];
// Create DIEs for each subprogram.
for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(),
@@ -1943,10 +1944,6 @@ void DwarfDebug::endModule() {
// Emit inline info.
emitDebugInlineInfo();
- // Clear debug info in preparation for the next Module.
- ModuleCU = NULL;
- DeleteContainerSeconds(CompileUnitMap);
-
if (TimePassesIsEnabled)
DebugTimer->stopTimer();
}
@@ -2117,9 +2114,9 @@ bool DwarfDebug::extractScopeInformation() {
while (!WorkList.empty()) {
DbgScope *S = WorkList.back(); WorkList.pop_back();
- const SmallVector<DbgScope *, 4> &Children = S->getScopes();
+ SmallVector<DbgScope *, 4> &Children = S->getScopes();
if (!Children.empty())
- for (SmallVector<DbgScope *, 4>::const_iterator SI = Children.begin(),
+ for (SmallVector<DbgScope *, 4>::iterator SI = Children.begin(),
SE = Children.end(); SI != SE; ++SI)
WorkList.push_back(*SI);
@@ -2224,11 +2221,10 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
// Clear debug info
CurrentFnDbgScope = NULL;
- DeleteContainerSeconds(DbgScopeMap);
+ DbgScopeMap.clear();
DbgScopeBeginMap.clear();
DbgScopeEndMap.clear();
ConcreteScopes.clear();
- DeleteContainerSeconds(AbstractScopes);
AbstractScopesList.clear();
Lines.clear();
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 8d75b1ff93..55baa92100 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -66,6 +66,10 @@ class DwarfDebug : public DwarfPrinter {
/// 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;
@@ -130,8 +134,7 @@ class DwarfDebug : public DwarfPrinter {
//
DbgScope *CurrentFnDbgScope;
- /// DbgScopeMap - Tracks the scopes in the current function. Owns the
- /// contained DbgScope*s.
+ /// DbgScopeMap - Tracks the scopes in the current function.
///
DenseMap<MDNode *, DbgScope *> DbgScopeMap;
@@ -140,7 +143,7 @@ class DwarfDebug : public DwarfPrinter {
DenseMap<MDNode *, DbgScope *> ConcreteScopes;
/// AbstractScopes - Tracks the abstract scopes a module. These scopes are
- /// not included DbgScopeMap. AbstractScopes owns its DbgScope*s.
+ /// not included DbgScopeMap.
DenseMap<MDNode *, DbgScope *> AbstractScopes;
SmallVector<DbgScope *, 4>AbstractScopesList;