llvm.org GIT mirror llvm / 1ddcf35
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 Douglas Gregor 10 years ago
4 changed file(s) with 30 addition(s) and 51 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
303281 } // End llvm namespace
304282
305283 #endif
111111 //===--------------------------------------------------------------------===//
112112 /// DIE - A structured debug information entry. Has an abbreviation which
113113 /// describes it's organization.
114 class CompileUnit;
114115 class DIEValue;
115116
116117 class DIE {
157158 void setTag(unsigned Tag) { Abbrev.setTag(Tag); }
158159 void setOffset(unsigned O) { Offset = O; }
159160 void setSize(unsigned S) { Size = S; }
161 void setParent(DIE *P) { Parent = P; }
160162
161163 /// addValue - Add a value and attributes to a DIE.
162164 ///
182184 }
183185 Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes);
184186 Children.push_back(Child);
185 Child->Parent = this;
187 Child->setParent(this);
186188 }
187189
188190 #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"
2625 #include "llvm/ADT/StringExtras.h"
2726 #include "llvm/Support/Debug.h"
2827 #include "llvm/Support/ErrorHandling.h"
5049
5150 /// Die - Compile unit debug information entry.
5251 ///
53 const OwningPtr CUDie;
54
55 /// IndexTyDie - An anonymous type for index type. Owned by CUDie
52 DIE *CUDie;
53
54 /// IndexTyDie - An anonymous type for index type.
5655 DIE *IndexTyDie;
5756
5857 /// GVToDieMap - Tracks the mapping of unit level debug informaton
7675 public:
7776 CompileUnit(unsigned I, DIE *D)
7877 : 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.get(); }
82 DIE* getCUDie() const { return CUDie; }
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 // Scopes defined in scope. Contents not owned.
177 SmallVector Scopes;
178 // Variables declared in scope. Contents owned.
179 SmallVectorVariable *, 8> Variables;
176 SmallVectorScope *, 4> Scopes; // Scopes defined in scope.
177 SmallVector Variables;// Variables declared in scope.
180178
181179 // Private state for dump()
182180 mutable unsigned IndentLevel;
197195 MDNode *getScopeNode() const { return Desc.getNode(); }
198196 unsigned getStartLabelID() const { return StartLabelID; }
199197 unsigned getEndLabelID() const { return EndLabelID; }
200 const SmallVector &getScopes() { return Scopes; }
201 const SmallVector &getVariables() { return Variables; }
198 SmallVector &getScopes() { return Scopes; }
199 SmallVector &getVariables() { return Variables; }
202200 void setStartLabelID(unsigned S) { StartLabelID = S; }
203201 void setEndLabelID(unsigned E) { EndLabelID = E; }
204202 void setLastInsn(const MachineInstr *MI) { LastInsn = MI; }
221219 assert (getFirstInsn() && "First instruction is missing!");
222220
223221 // Use the end of last child scope as end of this scope.
224 const SmallVector &Scopes = getScopes();
222 SmallVector &Scopes = getScopes();
225223 const MachineInstr *LastInsn = getFirstInsn();
226224 unsigned LIndex = 0;
227225 if (Scopes.empty()) {
228226 assert (getLastInsn() && "Inner most scope does not have last insn!");
229227 return;
230228 }
231 for (SmallVector::const_iterator SI = Scopes.begin(),
229 for (SmallVector::iterator SI = Scopes.begin(),
232230 SE = Scopes.end(); SI != SE; ++SI) {
233231 DbgScope *DS = *SI;
234232 DS->fixInstructionMarkers(MIIndexMap);
280278 #endif
281279
282280 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 const SmallVector &Variables = Scope->getVariables();
1587 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 const SmallVector &Scopes = Scope->getScopes();
1595 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);
16981699 return Unit;
16991700 }
17001701
18001801 E = DbgFinder.compile_unit_end(); I != E; ++I)
18011802 constructCompileUnit(*I);
18021803
1803 if (CompileUnitMap.empty()) {
1804 if (CompileUnits.empty()) {
18041805 if (TimePassesIsEnabled)
18051806 DebugTimer->stopTimer();
18061807
18101811 // If main compile unit for this module is not seen than randomly
18111812 // select first compile unit.
18121813 if (!ModuleCU)
1813 ModuleCU = CompileUnitMap.begin()->second;
1814 ModuleCU = CompileUnits[0];
18141815
18151816 // Create DIEs for each subprogram.
18161817 for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(),
19411942
19421943 // Emit inline info.
19431944 emitDebugInlineInfo();
1944
1945 // Clear debug info in preparation for the next Module.
1946 ModuleCU = NULL;
1947 DeleteContainerSeconds(CompileUnitMap);
19481945
19491946 if (TimePassesIsEnabled)
19501947 DebugTimer->stopTimer();
21162113 while (!WorkList.empty()) {
21172114 DbgScope *S = WorkList.back(); WorkList.pop_back();
21182115
2119 const SmallVector &Children = S->getScopes();
2116 SmallVector &Children = S->getScopes();
21202117 if (!Children.empty())
2121 for (SmallVector::const_iterator SI = Children.begin(),
2118 for (SmallVector::iterator SI = Children.begin(),
21222119 SE = Children.end(); SI != SE; ++SI)
21232120 WorkList.push_back(*SI);
21242121
22232220
22242221 // Clear debug info
22252222 CurrentFnDbgScope = NULL;
2226 DeleteContainerSeconds(DbgScopeMap);
2223 DbgScopeMap.clear();
22272224 DbgScopeBeginMap.clear();
22282225 DbgScopeEndMap.clear();
22292226 ConcreteScopes.clear();
2230 DeleteContainerSeconds(AbstractScopes);
22312227 AbstractScopesList.clear();
22322228 Lines.clear();
22332229
6565 /// compile units.
6666 DenseMap CompileUnitMap;
6767
68 /// CompileUnits - All the compile units in this module.
69 ///
70 SmallVector CompileUnits;
71
6872 /// ModuleCU - All DIEs are inserted in ModuleCU.
6973 CompileUnit *ModuleCU;
7074
129133 //
130134 DbgScope *CurrentFnDbgScope;
131135
132 /// DbgScopeMap - Tracks the scopes in the current function. Owns the
133 /// contained DbgScope*s.
136 /// DbgScopeMap - Tracks the scopes in the current function.
134137 ///
135138 DenseMap DbgScopeMap;
136139
139142 DenseMap ConcreteScopes;
140143
141144 /// AbstractScopes - Tracks the abstract scopes a module. These scopes are
142 /// not included DbgScopeMap. AbstractScopes owns its DbgScope*s.
145 /// not included DbgScopeMap.
143146 DenseMap AbstractScopes;
144147 SmallVectorAbstractScopesList;
145148