17 #ifndef LLVM_CODEGEN_LEXICALSCOPES_H 18 #define LLVM_CODEGEN_LEXICALSCOPES_H 26 #include <unordered_map> 31 class MachineBasicBlock;
32 class MachineFunction;
40 using InsnRange = std::pair<const MachineInstr *, const MachineInstr *>;
49 : Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(A) {
53 "Don't build lexical scopes for non-debug locations");
84 assert(FirstInsn &&
"MI Range is not open!");
94 assert(LastInsn &&
"Last insn missing!");
100 if (Parent && (!NewScope || !Parent->
dominates(NewScope)))
154 bool empty() {
return CurrentFnLexicalScope ==
nullptr; }
158 return CurrentFnLexicalScope;
164 void getMachineBasicBlocks(
const DILocation *DL,
177 return AbstractScopesList;
182 auto I = AbstractScopeMap.find(N);
183 return I != AbstractScopeMap.end() ? &
I->second :
nullptr;
188 auto I = InlinedLexicalScopeMap.find(std::make_pair(N, IA));
189 return I != InlinedLexicalScopeMap.end() ? &
I->second :
nullptr;
194 auto I = LexicalScopeMap.find(N);
195 return I != LexicalScopeMap.end() ? &
I->second :
nullptr;
210 return DL ? getOrCreateLexicalScope(DL->getScope(), DL->getInlinedAt())
234 std::unordered_map<const DILocalScope *, LexicalScope> LexicalScopeMap;
238 std::unordered_map<std::pair<const DILocalScope *, const DILocation *>,
241 InlinedLexicalScopeMap;
245 std::unordered_map<const DILocalScope *, LexicalScope> AbstractScopeMap;
253 LexicalScope *CurrentFnLexicalScope =
nullptr;
258 #endif // LLVM_CODEGEN_LEXICALSCOPES_H void openInsnRange(const MachineInstr *MI)
openInsnRange - This scope covers instruction range starting from MI.
const DILocalScope * getScopeNode() const
void extendInsnRange(const MachineInstr *MI)
extendInsnRange - Extend the current instruction range covered by this scope.
This class represents lattice values for constants.
bool isAbstractScope() const
void dump(unsigned Indent=0) const
dump - print lexical scope.
const MDNode * getDesc() const
void push_back(const T &Elt)
SmallVectorImpl< InsnRange > & getRanges()
LexicalScope - This class is used to track scope information.
SmallVectorImpl< LexicalScope * > & getChildren()
LexicalScope * getParent() const
bool isResolved() const
Check if node is fully resolved.
void setDFSOut(unsigned O)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LexicalScope * findAbstractScope(const DILocalScope *N)
findAbstractScope - Find an abstract scope or return null.
const DILocation * getInlinedAt() const
LexicalScope * findLexicalScope(const DILocalScope *N)
findLexicalScope - Find regular lexical scope or return null.
void setDFSIn(unsigned I)
LexicalScope * findInlinedScope(const DILocalScope *N, const DILocation *IA)
findInlinedScope - Find an inlined scope for the given scope/inlined-at.
unsigned getDFSOut() const
unsigned getDFSIn() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LexicalScope(LexicalScope *P, const DILocalScope *D, const DILocation *I, bool A)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringRef > StandardNames)
Initialize the set of available library functions based on the specified target triple.
Representation of each machine instruction.
LexicalScopes - This class provides interface to collect and use lexical scoping information from mac...
void closeInsnRange(LexicalScope *NewScope=nullptr)
closeInsnRange - Create a range based on FirstInsn and LastInsn collected until now.
void addChild(LexicalScope *S)
addChild - Add a child scope.
ArrayRef< LexicalScope * > getAbstractScopesList() const
getAbstractScopesList - Return a reference to list of abstract scopes.
bool dominates(const LexicalScope *S) const
dominates - Return true if current scope dominates given lexical scope.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::pair< const MachineInstr *, const MachineInstr * > InsnRange
InsnRange - This is used to track range of instructions with identical lexical scope.
bool empty()
empty - Return true if there is any lexical scope information available.
LexicalScope * getCurrentFunctionScope() const
getCurrentFunctionScope - Return lexical scope for the current function.