Lines Matching +full:fetch +full:- +full:depth
1 //===- LexicalScopes.cpp - Collecting lexical scope info ------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
22 #include "llvm/Config/llvm-config.h"
39 /// reset - Reset the instance so that it's prepared for another function.
50 /// initialize - Scan machine function and constuct lexical scope nest.
54 if (Fn.getFunction().getSubprogram()->getUnit()->getEmissionKind() == in initialize()
67 /// extractLexicalScopes - Extract instruction ranges for each lexical scopes
122 /// findLexicalScope - Find lexical scope, either regular or inlined, for the
125 DILocalScope *Scope = DL->getScope(); in findLexicalScope()
129 // The scope that we were created with could have an extra file - which in findLexicalScope()
131 Scope = Scope->getNonLexicalBlockFileScope(); in findLexicalScope()
133 if (auto *IA = DL->getInlinedAt()) { in findLexicalScope()
135 return I != InlinedLexicalScopeMap.end() ? &I->second : nullptr; in findLexicalScope()
140 /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
146 if (Scope->getSubprogram()->getUnit()->getEmissionKind() == in getOrCreateLexicalScope()
158 /// getOrCreateRegularScope - Find or create a regular lexical scope.
162 Scope = Scope->getNonLexicalBlockFileScope(); in getOrCreateRegularScope()
166 return &I->second; in getOrCreateRegularScope()
171 Parent = getOrCreateLexicalScope(Block->getScope()); in getOrCreateRegularScope()
178 assert(cast<DISubprogram>(Scope)->describes(&MF->getFunction())); in getOrCreateRegularScope()
180 CurrentFnLexicalScope = &I->second; in getOrCreateRegularScope()
183 return &I->second; in getOrCreateRegularScope()
186 /// getOrCreateInlinedScope - Find or create an inlined lexical scope.
191 Scope = Scope->getNonLexicalBlockFileScope(); in getOrCreateInlinedScope()
195 return &I->second; in getOrCreateInlinedScope()
199 Parent = getOrCreateInlinedScope(Block->getScope(), InlinedAt); in getOrCreateInlinedScope()
207 return &I->second; in getOrCreateInlinedScope()
210 /// getOrCreateAbstractScope - Find or create an abstract lexical scope.
214 Scope = Scope->getNonLexicalBlockFileScope(); in getOrCreateAbstractScope()
217 return &I->second; in getOrCreateAbstractScope()
222 Parent = getOrCreateAbstractScope(Block->getScope()); in getOrCreateAbstractScope()
229 AbstractScopesList.push_back(&I->second); in getOrCreateAbstractScope()
230 return &I->second; in getOrCreateAbstractScope()
233 /// constructScopeNest - Traverse the Scope tree depth-first, storing
234 /// traversal state in WorkStack and recording the depth-first
245 const SmallVectorImpl<LexicalScope *> &Children = WS->getChildren(); in constructScopeNest()
249 ChildScope->setDFSIn(++Counter); in constructScopeNest()
252 WS->setDFSOut(++Counter); in constructScopeNest()
257 /// assignInstructionRanges - Find ranges of instructions covered by each
266 if (PrevLexicalScope && !PrevLexicalScope->dominates(S)) in assignInstructionRanges()
267 PrevLexicalScope->closeInsnRange(S); in assignInstructionRanges()
268 S->openInsnRange(R.first); in assignInstructionRanges()
269 S->extendInsnRange(R.second); in assignInstructionRanges()
274 PrevLexicalScope->closeInsnRange(); in assignInstructionRanges()
277 /// getMachineBasicBlocks - Populate given set using machine basic blocks which
298 SmallVectorImpl<InsnRange> &InsnRanges = Scope->getRanges(); in getMachineBasicBlocks()
300 for (auto CurMBBIt = R.first->getParent()->getIterator(), in getMachineBasicBlocks()
301 EndBBIt = std::next(R.second->getParent()->getIterator()); in getMachineBasicBlocks()
313 if (Scope == CurrentFnLexicalScope && MBB->getParent() == MF) in dominates()
316 // Fetch all the blocks in DLs scope. Because the range / block list also in dominates()
327 return Set->contains(MBB); in dominates()
337 N->dump(); in dump()
345 Child->dump(Indent + 2); in dump()