llvm.org GIT mirror llvm / 9467f0e
Roll r97906 forward again, without double-deleting CompileUnit::IndexTyDie. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97917 91177308-0d34-0410-b5e6-96231b3b80d8 Jeffrey Yasskin 10 years ago
4 changed file(s) with 51 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
278278 qsort(&*Start, End-Start, sizeof(*Start), Compare);
279279 }
280280
281 //===----------------------------------------------------------------------===//
282 // Extra additions to
283 //===----------------------------------------------------------------------===//
284
285 /// For a container of pointers, deletes the pointers and then clears the
286 /// container.
287 template
288 void DeleteContainerPointers(Container &C) {
289 for (typename Container::iterator I = C.begin(), E = C.end(); I != E; ++I)
290 delete *I;
291 C.clear();
292 }
293
294 /// In a container of pairs (usually a map) whose second element is a pointer,
295 /// deletes the second elements and then clears the container.
296 template
297 void DeleteContainerSeconds(Container &C) {
298 for (typename Container::iterator I = C.begin(), E = C.end(); I != E; ++I)
299 delete I->second;
300 C.clear();
301 }
302
281303 } // End llvm namespace
282304
283305 #endif
111111 //===--------------------------------------------------------------------===//
112112 /// DIE - A structured debug information entry. Has an abbreviation which
113113 /// describes it's organization.
114 class CompileUnit;
115114 class DIEValue;
116115
117116 class DIE {
158157 void setTag(unsigned Tag) { Abbrev.setTag(Tag); }
159158 void setOffset(unsigned O) { Offset = O; }
160159 void setSize(unsigned S) { Size = S; }
161 void setParent(DIE *P) { Parent = P; }
162160
163161 /// addValue - Add a value and attributes to a DIE.
164162 ///
184182 }
185183 Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes);
186184 Children.push_back(Child);
187 Child->setParent(this);
185 Child->Parent = this;
188186 }
189187
190188 #ifndef NDEBUG
2222 #include "llvm/Target/TargetFrameInfo.h"
2323 #include "llvm/Target/TargetLoweringObjectFile.h"
2424 #include "llvm/Target/TargetRegisterInfo.h"
25 #include "llvm/ADT/STLExtras.h"
2526 #include "llvm/ADT/StringExtras.h"
2627 #include "llvm/Support/Debug.h"
2728 #include "llvm/Support/ErrorHandling.h"
4950
5051 /// Die - Compile unit debug information entry.
5152 ///
52 DIE *CUDie;
53
54 /// IndexTyDie - An anonymous type for index type.
53 const OwningPtr CUDie;
54
55 /// IndexTyDie - An anonymous type for index type. Owned by CUDie
5556 DIE *IndexTyDie;
5657
5758 /// GVToDieMap - Tracks the mapping of unit level debug informaton
7576 public:
7677 CompileUnit(unsigned I, DIE *D)
7778 : ID(I), CUDie(D), IndexTyDie(0) {}
78 ~CompileUnit() { delete CUDie; delete IndexTyDie; }
7979
8080 // Accessors.
8181 unsigned getID() const { return ID; }
82 DIE* getCUDie() const { return CUDie; }
82 DIE* getCUDie() const { return CUDie.get(); }
8383 const StringMap &getGlobals() const { return Globals; }
8484 const StringMap &getGlobalTypes() const { return GlobalTypes; }
8585
173173 unsigned EndLabelID; // Label ID of the end of scope.
174174 const MachineInstr *LastInsn; // Last instruction of this scope.
175175 const MachineInstr *FirstInsn; // First instruction of this scope.
176 SmallVector Scopes; // Scopes defined in scope.
177 SmallVector Variables;// Variables declared in scope.
176 // Scopes defined in scope. Contents not owned.
177 SmallVector Scopes;
178 // Variables declared in scope. Contents owned.
179 SmallVector Variables;
178180
179181 // Private state for dump()
180182 mutable unsigned IndentLevel;
195197 MDNode *getScopeNode() const { return Desc.getNode(); }
196198 unsigned getStartLabelID() const { return StartLabelID; }
197199 unsigned getEndLabelID() const { return EndLabelID; }
198 SmallVector &getScopes() { return Scopes; }
199 SmallVector &getVariables() { return Variables; }
200 const SmallVector &getScopes() { return Scopes; }
201 const SmallVector &getVariables() { return Variables; }
200202 void setStartLabelID(unsigned S) { StartLabelID = S; }
201203 void setEndLabelID(unsigned E) { EndLabelID = E; }
202204 void setLastInsn(const MachineInstr *MI) { LastInsn = MI; }
219221 assert (getFirstInsn() && "First instruction is missing!");
220222
221223 // Use the end of last child scope as end of this scope.
222 SmallVector &Scopes = getScopes();
224 const SmallVector &Scopes = getScopes();
223225 const MachineInstr *LastInsn = getFirstInsn();
224226 unsigned LIndex = 0;
225227 if (Scopes.empty()) {
226228 assert (getLastInsn() && "Inner most scope does not have last insn!");
227229 return;
228230 }
229 for (SmallVector::iterator SI = Scopes.begin(),
231 for (SmallVector::const_iterator SI = Scopes.begin(),
230232 SE = Scopes.end(); SI != SE; ++SI) {
231233 DbgScope *DS = *SI;
232234 DS->fixInstructionMarkers(MIIndexMap);
278280 #endif
279281
280282 DbgScope::~DbgScope() {
281 for (unsigned i = 0, N = Scopes.size(); i < N; ++i)
282 delete Scopes[i];
283283 for (unsigned j = 0, M = Variables.size(); j < M; ++j)
284284 delete Variables[j];
285285 }
15841584 }
15851585
15861586 // Add variables to scope.
1587 SmallVector &Variables = Scope->getVariables();
1587 const SmallVector &Variables = Scope->getVariables();
15881588 for (unsigned i = 0, N = Variables.size(); i < N; ++i) {
15891589 DIE *VariableDIE = constructVariableDIE(Variables[i], Scope);
15901590 if (VariableDIE)
15921592 }
15931593
15941594 // Add nested scopes.
1595 SmallVector &Scopes = Scope->getScopes();
1595 const SmallVector &Scopes = Scope->getScopes();
15961596 for (unsigned j = 0, M = Scopes.size(); j < M; ++j) {
15971597 // Define the Scope debug information entry.
15981598 DIE *NestedDIE = constructScopeDIE(Scopes[j]);
16951695 }
16961696
16971697 CompileUnitMap[DIUnit.getNode()] = Unit;
1698 CompileUnits.push_back(Unit);
16991698 return Unit;
17001699 }
17011700
18011800 E = DbgFinder.compile_unit_end(); I != E; ++I)
18021801 constructCompileUnit(*I);
18031802
1804 if (CompileUnits.empty()) {
1803 if (CompileUnitMap.empty()) {
18051804 if (TimePassesIsEnabled)
18061805 DebugTimer->stopTimer();
18071806
18111810 // If main compile unit for this module is not seen than randomly
18121811 // select first compile unit.
18131812 if (!ModuleCU)
1814 ModuleCU = CompileUnits[0];
1813 ModuleCU = CompileUnitMap.begin()->second;
18151814
18161815 // Create DIEs for each subprogram.
18171816 for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(),
19421941
19431942 // Emit inline info.
19441943 emitDebugInlineInfo();
1944
1945 // Clear debug info in preparation for the next Module.
1946 ModuleCU = NULL;
1947 DeleteContainerSeconds(CompileUnitMap);
19451948
19461949 if (TimePassesIsEnabled)
19471950 DebugTimer->stopTimer();
21132116 while (!WorkList.empty()) {
21142117 DbgScope *S = WorkList.back(); WorkList.pop_back();
21152118
2116 SmallVector &Children = S->getScopes();
2119 const SmallVector &Children = S->getScopes();
21172120 if (!Children.empty())
2118 for (SmallVector::iterator SI = Children.begin(),
2121 for (SmallVector::const_iterator SI = Children.begin(),
21192122 SE = Children.end(); SI != SE; ++SI)
21202123 WorkList.push_back(*SI);
21212124
22202223
22212224 // Clear debug info
22222225 CurrentFnDbgScope = NULL;
2223 DbgScopeMap.clear();
2226 DeleteContainerSeconds(DbgScopeMap);
22242227 DbgScopeBeginMap.clear();
22252228 DbgScopeEndMap.clear();
22262229 ConcreteScopes.clear();
2230 DeleteContainerSeconds(AbstractScopes);
22272231 AbstractScopesList.clear();
22282232 Lines.clear();
22292233
6565 /// compile units.
6666 DenseMap CompileUnitMap;
6767
68 /// CompileUnits - All the compile units in this module.
69 ///
70 SmallVector CompileUnits;
71
7268 /// ModuleCU - All DIEs are inserted in ModuleCU.
7369 CompileUnit *ModuleCU;
7470
133129 //
134130 DbgScope *CurrentFnDbgScope;
135131
136 /// DbgScopeMap - Tracks the scopes in the current function.
132 /// DbgScopeMap - Tracks the scopes in the current function. Owns the
133 /// contained DbgScope*s.
137134 ///
138135 DenseMap DbgScopeMap;
139136
142139 DenseMap ConcreteScopes;
143140
144141 /// AbstractScopes - Tracks the abstract scopes a module. These scopes are
145 /// not included DbgScopeMap.
142 /// not included DbgScopeMap. AbstractScopes owns its DbgScope*s.
146143 DenseMap AbstractScopes;
147144 SmallVectorAbstractScopesList;
148145