Lines Matching full:scope

1 //===- LexicalScopes.cpp - Collecting lexical scope info ------------------===//
11 // This pass collects lexical scope information and maps machine instructions
50 /// initialize - Scan machine function and constuct lexical scope nest.
53 // Don't attempt any lexical scope creation for a NoDebug compile unit.
90 // If scope has not changed then skip this instruction.
98 // current instruction scope does not match scope of first instruction
122 /// findLexicalScope - Find lexical scope, either regular or inlined, for the
125 DILocalScope *Scope = DL->getScope();
126 if (!Scope)
129 // The scope that we were created with could have an extra file - which
131 Scope = Scope->getNonLexicalBlockFileScope();
134 auto I = InlinedLexicalScopeMap.find(std::make_pair(Scope, IA));
137 return findLexicalScope(Scope);
140 /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
141 /// not available then create new lexical scope.
142 LexicalScope *LexicalScopes::getOrCreateLexicalScope(const DILocalScope *Scope,
146 if (Scope->getSubprogram()->getUnit()->getEmissionKind() ==
149 // Create an abstract scope for inlined function.
150 getOrCreateAbstractScope(Scope);
151 // Create an inlined scope for inlined function.
152 return getOrCreateInlinedScope(Scope, IA);
155 return getOrCreateRegularScope(Scope);
158 /// getOrCreateRegularScope - Find or create a regular lexical scope.
160 LexicalScopes::getOrCreateRegularScope(const DILocalScope *Scope) {
161 assert(Scope && "Invalid Scope encoding!");
162 Scope = Scope->getNonLexicalBlockFileScope();
164 auto I = LexicalScopeMap.find(Scope);
170 if (auto *Block = dyn_cast<DILexicalBlockBase>(Scope))
173 std::forward_as_tuple(Scope),
174 std::forward_as_tuple(Parent, Scope, nullptr,
178 assert(cast<DISubprogram>(Scope)->describes(&MF->getFunction()));
186 /// getOrCreateInlinedScope - Find or create an inlined lexical scope.
188 LexicalScopes::getOrCreateInlinedScope(const DILocalScope *Scope,
190 assert(Scope && "Invalid Scope encoding!");
191 Scope = Scope->getNonLexicalBlockFileScope();
192 std::pair<const DILocalScope *, const DILocation *> P(Scope, InlinedAt);
198 if (auto *Block = dyn_cast<DILexicalBlockBase>(Scope))
205 std::forward_as_tuple(Parent, Scope, InlinedAt, false))
210 /// getOrCreateAbstractScope - Find or create an abstract lexical scope.
212 LexicalScopes::getOrCreateAbstractScope(const DILocalScope *Scope) {
213 assert(Scope && "Invalid Scope encoding!");
214 Scope = Scope->getNonLexicalBlockFileScope();
215 auto I = AbstractScopeMap.find(Scope);
221 if (auto *Block = dyn_cast<DILexicalBlockBase>(Scope))
225 std::forward_as_tuple(Scope),
226 std::forward_as_tuple(Parent, Scope,
228 if (isa<DISubprogram>(Scope))
233 /// constructScopeNest - Traverse the Scope tree depth-first, storing
236 void LexicalScopes::constructScopeNest(LexicalScope *Scope) {
237 assert(Scope && "Unable to calculate scope dominance graph!");
239 WorkStack.push_back(std::make_pair(Scope, 0));
258 /// lexical scope.
278 /// have machine instructions that belong to lexical scope identified by
285 LexicalScope *Scope = getOrCreateLexicalScope(DL);
286 if (!Scope)
289 if (Scope == CurrentFnLexicalScope) {
295 // The scope ranges can cover multiple basic blocks in each span. Iterate over
298 SmallVectorImpl<InsnRange> &InsnRanges = Scope->getRanges();
308 LexicalScope *Scope = getOrCreateLexicalScope(DL);
309 if (!Scope)
312 // Current function scope covers all basic blocks in the function.
313 if (Scope == CurrentFnLexicalScope && MBB->getParent() == MF)
316 // Fetch all the blocks in DLs scope. Because the range / block list also
339 err << std::string(Indent, ' ') << "Abstract Scope\n";