@@ -34,13 +34,12 @@ class MachineInstr;
34
34
class MDNode ;
35
35
36
36
// ===----------------------------------------------------------------------===//
37
- // / InsnRange - This is used to track range of instructions with identical
38
- // / lexical scope.
37
+ // / This is used to track range of instructions with identical lexical scope.
39
38
// /
40
39
using InsnRange = std::pair<const MachineInstr *, const MachineInstr *>;
41
40
42
41
// ===----------------------------------------------------------------------===//
43
- // / LexicalScope - This class is used to track scope information.
42
+ // / This class is used to track scope information.
44
43
// /
45
44
class LexicalScope {
46
45
public:
@@ -66,10 +65,10 @@ class LexicalScope {
66
65
SmallVectorImpl<LexicalScope *> &getChildren () { return Children; }
67
66
SmallVectorImpl<InsnRange> &getRanges () { return Ranges; }
68
67
69
- // / addChild - Add a child scope.
68
+ // / Add a child scope.
70
69
void addChild (LexicalScope *S) { Children.push_back (S); }
71
70
72
- // / openInsnRange - This scope covers instruction range starting from MI.
71
+ // / This scope covers instruction range starting from MI.
73
72
void openInsnRange (const MachineInstr *MI) {
74
73
if (!FirstInsn)
75
74
FirstInsn = MI;
@@ -78,18 +77,17 @@ class LexicalScope {
78
77
Parent->openInsnRange (MI);
79
78
}
80
79
81
- // / extendInsnRange - Extend the current instruction range covered by
82
- // / this scope.
80
+ // / Extend the current instruction range covered by this scope.
83
81
void extendInsnRange (const MachineInstr *MI) {
84
82
assert (FirstInsn && " MI Range is not open!" );
85
83
LastInsn = MI;
86
84
if (Parent)
87
85
Parent->extendInsnRange (MI);
88
86
}
89
87
90
- // / closeInsnRange - Create a range based on FirstInsn and LastInsn collected
91
- // / until now. This is used when a new scope is encountered while walking
92
- // / machine instructions.
88
+ // / Create a range based on FirstInsn and LastInsn collected until now.
89
+ // / This is used when a new scope is encountered while walking machine
90
+ // / instructions.
93
91
void closeInsnRange (LexicalScope *NewScope = nullptr ) {
94
92
assert (LastInsn && " Last insn missing!" );
95
93
Ranges.push_back (InsnRange (FirstInsn, LastInsn));
@@ -101,7 +99,7 @@ class LexicalScope {
101
99
Parent->closeInsnRange (NewScope);
102
100
}
103
101
104
- // / dominates - Return true if current scope dominates given lexical scope.
102
+ // / Return true if current scope dominates given lexical scope.
105
103
bool dominates (const LexicalScope *S) const {
106
104
if (S == this )
107
105
return true ;
@@ -116,7 +114,7 @@ class LexicalScope {
116
114
unsigned getDFSIn () const { return DFSIn; }
117
115
void setDFSIn (unsigned I) { DFSIn = I; }
118
116
119
- // / dump - print lexical scope.
117
+ // / Print lexical scope.
120
118
LLVM_ABI void dump (unsigned Indent = 0 ) const ;
121
119
122
120
private:
@@ -136,31 +134,30 @@ class LexicalScope {
136
134
};
137
135
138
136
// ===----------------------------------------------------------------------===//
139
- // / LexicalScopes - This class provides interface to collect and use lexical
140
- // / scoping information from machine instruction.
137
+ // / This class provides interface to collect and use lexical scoping information
138
+ // / from machine instruction.
141
139
// /
142
140
class LexicalScopes {
143
141
public:
144
142
LexicalScopes () = default ;
145
143
146
- // / initialize - Scan machine function and constuct lexical scope nest, resets
144
+ // / Scan machine function and constuct lexical scope nest, resets
147
145
// / the instance if necessary.
148
146
LLVM_ABI void initialize (const MachineFunction &);
149
147
150
- // / releaseMemory - release memory.
148
+ // / Release memory.
151
149
LLVM_ABI void reset ();
152
150
153
- // / empty - Return true if there is any lexical scope information available.
151
+ // / Return true if there is any lexical scope information available.
154
152
bool empty () { return CurrentFnLexicalScope == nullptr ; }
155
153
156
- // / getCurrentFunctionScope - Return lexical scope for the current function.
154
+ // / Return lexical scope for the current function.
157
155
LexicalScope *getCurrentFunctionScope () const {
158
156
return CurrentFnLexicalScope;
159
157
}
160
158
161
- // / getMachineBasicBlocks - Populate given set using machine basic blocks
162
- // / which have machine instructions that belong to lexical scope identified by
163
- // / DebugLoc.
159
+ // / Populate given set using machine basic blocks which have machine
160
+ // / instructions that belong to lexical scope identified by DebugLoc.
164
161
LLVM_ABI void
165
162
getMachineBasicBlocks (const DILocation *DL,
166
163
SmallPtrSetImpl<const MachineBasicBlock *> &MBBs);
@@ -169,39 +166,39 @@ class LexicalScopes {
169
166
// / instruction's lexical scope in a given machine basic block.
170
167
LLVM_ABI bool dominates (const DILocation *DL, MachineBasicBlock *MBB);
171
168
172
- // / findLexicalScope - Find lexical scope, either regular or inlined, for the
173
- // / given DebugLoc. Return NULL if not found.
169
+ // / Find lexical scope, either regular or inlined, for the given DebugLoc.
170
+ // / Return NULL if not found.
174
171
LLVM_ABI LexicalScope *findLexicalScope (const DILocation *DL);
175
172
176
- // / getAbstractScopesList - Return a reference to list of abstract scopes.
173
+ // / Return a reference to list of abstract scopes.
177
174
ArrayRef<LexicalScope *> getAbstractScopesList () const {
178
175
return AbstractScopesList;
179
176
}
180
177
181
- // / findAbstractScope - Find an abstract scope or return null.
178
+ // / Find an abstract scope or return null.
182
179
LexicalScope *findAbstractScope (const DILocalScope *N) {
183
180
auto I = AbstractScopeMap.find (N);
184
181
return I != AbstractScopeMap.end () ? &I->second : nullptr ;
185
182
}
186
183
187
- // / findInlinedScope - Find an inlined scope for the given scope/inlined-at.
184
+ // / Find an inlined scope for the given scope/inlined-at.
188
185
LexicalScope *findInlinedScope (const DILocalScope *N, const DILocation *IA) {
189
186
auto I = InlinedLexicalScopeMap.find (std::make_pair (N, IA));
190
187
return I != InlinedLexicalScopeMap.end () ? &I->second : nullptr ;
191
188
}
192
189
193
- // / findLexicalScope - Find regular lexical scope or return null.
190
+ // / Find regular lexical scope or return null.
194
191
LexicalScope *findLexicalScope (const DILocalScope *N) {
195
192
auto I = LexicalScopeMap.find (N);
196
193
return I != LexicalScopeMap.end () ? &I->second : nullptr ;
197
194
}
198
195
199
- // / getOrCreateAbstractScope - Find or create an abstract lexical scope.
196
+ // / Find or create an abstract lexical scope.
200
197
LLVM_ABI LexicalScope *getOrCreateAbstractScope (const DILocalScope *Scope);
201
198
202
199
private:
203
- // / getOrCreateLexicalScope - Find lexical scope for the given Scope/IA. If
204
- // / not available then create new lexical scope.
200
+ // / Find lexical scope for the given Scope/IA. If not available
201
+ // / then create new lexical scope.
205
202
LLVM_ABI LexicalScope *
206
203
getOrCreateLexicalScope (const DILocalScope *Scope,
207
204
const DILocation *IA = nullptr );
@@ -210,14 +207,14 @@ class LexicalScopes {
210
207
: nullptr ;
211
208
}
212
209
213
- // / getOrCreateRegularScope - Find or create a regular lexical scope.
210
+ // / Find or create a regular lexical scope.
214
211
LexicalScope *getOrCreateRegularScope (const DILocalScope *Scope);
215
212
216
- // / getOrCreateInlinedScope - Find or create an inlined lexical scope.
213
+ // / Find or create an inlined lexical scope.
217
214
LexicalScope *getOrCreateInlinedScope (const DILocalScope *Scope,
218
215
const DILocation *InlinedAt);
219
216
220
- // / extractLexicalScopes - Extract instruction ranges for each lexical scopes
217
+ // / Extract instruction ranges for each lexical scopes
221
218
// / for the given machine function.
222
219
void extractLexicalScopes (SmallVectorImpl<InsnRange> &MIRanges,
223
220
DenseMap<const MachineInstr *, LexicalScope *> &M);
@@ -228,27 +225,24 @@ class LexicalScopes {
228
225
229
226
const MachineFunction *MF = nullptr ;
230
227
231
- // / LexicalScopeMap - Tracks the scopes in the current function.
228
+ // / Tracks the scopes in the current function.
232
229
// Use an unordered_map to ensure value pointer validity over insertion.
233
230
std::unordered_map<const DILocalScope *, LexicalScope> LexicalScopeMap;
234
231
235
- // / InlinedLexicalScopeMap - Tracks inlined function scopes in current
236
- // / function.
232
+ // / Tracks inlined function scopes in current function.
237
233
std::unordered_map<std::pair<const DILocalScope *, const DILocation *>,
238
234
LexicalScope,
239
235
pair_hash<const DILocalScope *, const DILocation *>>
240
236
InlinedLexicalScopeMap;
241
237
242
- // / AbstractScopeMap - These scopes are not included LexicalScopeMap.
238
+ // / These scopes are not included LexicalScopeMap.
243
239
// Use an unordered_map to ensure value pointer validity over insertion.
244
240
std::unordered_map<const DILocalScope *, LexicalScope> AbstractScopeMap;
245
241
246
- // / AbstractScopesList - Tracks abstract scopes constructed while processing
247
- // / a function.
242
+ // / Tracks abstract scopes constructed while processing a function.
248
243
SmallVector<LexicalScope *, 4 > AbstractScopesList;
249
244
250
- // / CurrentFnLexicalScope - Top level scope for the current function.
251
- // /
245
+ // / Top level scope for the current function.
252
246
LexicalScope *CurrentFnLexicalScope = nullptr ;
253
247
254
248
// / Map a location to the set of basic blocks it dominates. This is a cache
0 commit comments