16 #ifndef LLVM_CODEGEN_LEXICALSCOPES_H 17 #define LLVM_CODEGEN_LEXICALSCOPES_H 25 #include <unordered_map> 30 class MachineBasicBlock;
31 class MachineFunction;
39 using InsnRange = std::pair<const MachineInstr *, const MachineInstr *>;
48 : Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(A) {
52 "Don't build lexical scopes for non-debug locations");
83 assert(FirstInsn &&
"MI Range is not open!");
93 assert(LastInsn &&
"Last insn missing!");
99 if (Parent && (!NewScope || !Parent->
dominates(NewScope)))
119 void dump(
unsigned Indent = 0)
const;
153 bool empty() {
return CurrentFnLexicalScope ==
nullptr; }
157 return CurrentFnLexicalScope;
163 void getMachineBasicBlocks(
const DILocation *DL,
176 return AbstractScopesList;
181 auto I = AbstractScopeMap.find(N);
182 return I != AbstractScopeMap.end() ? &
I->second :
nullptr;
187 auto I = InlinedLexicalScopeMap.find(std::make_pair(N, IA));
188 return I != InlinedLexicalScopeMap.end() ? &
I->second :
nullptr;
193 auto I = LexicalScopeMap.find(N);
194 return I != LexicalScopeMap.end() ? &
I->second :
nullptr;
209 return DL ? getOrCreateLexicalScope(DL->getScope(), DL->getInlinedAt())
233 std::unordered_map<const DILocalScope *, LexicalScope> LexicalScopeMap;
237 std::unordered_map<std::pair<const DILocalScope *, const DILocation *>,
240 InlinedLexicalScopeMap;
244 std::unordered_map<const DILocalScope *, LexicalScope> AbstractScopeMap;
252 LexicalScope *CurrentFnLexicalScope =
nullptr;
257 #endif // LLVM_CODEGEN_LEXICALSCOPES_H Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface ...
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...
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
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.
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.