llvm.org GIT mirror llvm / 8c42ca9
_2_ gcc crashes, ah, ah, ah... (Rolling back r97906.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97909 91177308-0d34-0410-b5e6-96231b3b80d8 Jeffrey Yasskin 10 years ago
3 changed file(s) with 22 addition(s) and 46 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
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"
174173 unsigned EndLabelID; // Label ID of the end of scope.
175174 const MachineInstr *LastInsn; // Last instruction of this scope.
176175 const MachineInstr *FirstInsn; // First instruction of this scope.
177 // Scopes defined in scope. Contents not owned.
178 SmallVector Scopes;
179 // Variables declared in scope. Contents owned.
180 SmallVectorVariable *, 8> Variables;
176 SmallVectorScope *, 4> Scopes; // Scopes defined in scope.
177 SmallVector Variables;// Variables declared in scope.
181178
182179 // Private state for dump()
183180 mutable unsigned IndentLevel;
198195 MDNode *getScopeNode() const { return Desc.getNode(); }
199196 unsigned getStartLabelID() const { return StartLabelID; }
200197 unsigned getEndLabelID() const { return EndLabelID; }
201 const SmallVector &getScopes() { return Scopes; }
202 const SmallVector &getVariables() { return Variables; }
198 SmallVector &getScopes() { return Scopes; }
199 SmallVector &getVariables() { return Variables; }
203200 void setStartLabelID(unsigned S) { StartLabelID = S; }
204201 void setEndLabelID(unsigned E) { EndLabelID = E; }
205202 void setLastInsn(const MachineInstr *MI) { LastInsn = MI; }
222219 assert (getFirstInsn() && "First instruction is missing!");
223220
224221 // Use the end of last child scope as end of this scope.
225 const SmallVector &Scopes = getScopes();
222 SmallVector &Scopes = getScopes();
226223 const MachineInstr *LastInsn = getFirstInsn();
227224 unsigned LIndex = 0;
228225 if (Scopes.empty()) {
229226 assert (getLastInsn() && "Inner most scope does not have last insn!");
230227 return;
231228 }
232 for (SmallVector::const_iterator SI = Scopes.begin(),
229 for (SmallVector::iterator SI = Scopes.begin(),
233230 SE = Scopes.end(); SI != SE; ++SI) {
234231 DbgScope *DS = *SI;
235232 DS->fixInstructionMarkers(MIIndexMap);
281278 #endif
282279
283280 DbgScope::~DbgScope() {
281 for (unsigned i = 0, N = Scopes.size(); i < N; ++i)
282 delete Scopes[i];
284283 for (unsigned j = 0, M = Variables.size(); j < M; ++j)
285284 delete Variables[j];
286285 }
15851584 }
15861585
15871586 // Add variables to scope.
1588 const SmallVector &Variables = Scope->getVariables();
1587 SmallVector &Variables = Scope->getVariables();
15891588 for (unsigned i = 0, N = Variables.size(); i < N; ++i) {
15901589 DIE *VariableDIE = constructVariableDIE(Variables[i], Scope);
15911590 if (VariableDIE)
15931592 }
15941593
15951594 // Add nested scopes.
1596 const SmallVector &Scopes = Scope->getScopes();
1595 SmallVector &Scopes = Scope->getScopes();
15971596 for (unsigned j = 0, M = Scopes.size(); j < M; ++j) {
15981597 // Define the Scope debug information entry.
15991598 DIE *NestedDIE = constructScopeDIE(Scopes[j]);
16961695 }
16971696
16981697 CompileUnitMap[DIUnit.getNode()] = Unit;
1698 CompileUnits.push_back(Unit);
16991699 return Unit;
17001700 }
17011701
18011801 E = DbgFinder.compile_unit_end(); I != E; ++I)
18021802 constructCompileUnit(*I);
18031803
1804 if (CompileUnitMap.empty()) {
1804 if (CompileUnits.empty()) {
18051805 if (TimePassesIsEnabled)
18061806 DebugTimer->stopTimer();
18071807
18111811 // If main compile unit for this module is not seen than randomly
18121812 // select first compile unit.
18131813 if (!ModuleCU)
1814 ModuleCU = CompileUnitMap.begin()->second;
1814 ModuleCU = CompileUnits[0];
18151815
18161816 // Create DIEs for each subprogram.
18171817 for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(),
19421942
19431943 // Emit inline info.
19441944 emitDebugInlineInfo();
1945
1946 // Clear debug info in preparation for the next Module.
1947 ModuleCU = NULL;
1948 DeleteContainerSeconds(CompileUnitMap);
19491945
19501946 if (TimePassesIsEnabled)
19511947 DebugTimer->stopTimer();
21172113 while (!WorkList.empty()) {
21182114 DbgScope *S = WorkList.back(); WorkList.pop_back();
21192115
2120 const SmallVector &Children = S->getScopes();
2116 SmallVector &Children = S->getScopes();
21212117 if (!Children.empty())
2122 for (SmallVector::const_iterator SI = Children.begin(),
2118 for (SmallVector::iterator SI = Children.begin(),
21232119 SE = Children.end(); SI != SE; ++SI)
21242120 WorkList.push_back(*SI);
21252121
22242220
22252221 // Clear debug info
22262222 CurrentFnDbgScope = NULL;
2227 DeleteContainerSeconds(DbgScopeMap);
2223 DbgScopeMap.clear();
22282224 DbgScopeBeginMap.clear();
22292225 DbgScopeEndMap.clear();
22302226 ConcreteScopes.clear();
2231 DeleteContainerSeconds(AbstractScopes);
22322227 AbstractScopesList.clear();
22332228 Lines.clear();
22342229
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