Go to the documentation of this file.
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) {
50 assert(
D->getSubprogram()->getUnit()->getEmissionKind() !=
52 "Don't build lexical scopes for non-debug locations");
53 assert(
D->isResolved() &&
"Expected resolved node");
54 assert((!
I ||
I->isResolved()) &&
"Expected resolved node");
83 assert(FirstInsn &&
"MI Range is not open!");
93 assert(LastInsn &&
"Last insn missing!");
94 Ranges.push_back(
InsnRange(FirstInsn, LastInsn));
99 if (Parent && (!NewScope || !Parent->
dominates(NewScope)))
107 if (DFSIn < S->
getDFSIn() && DFSOut >
S->getDFSOut())
119 void dump(
unsigned Indent = 0)
const;
153 bool empty() {
return CurrentFnLexicalScope ==
nullptr; }
157 return CurrentFnLexicalScope;
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;
206 return DL ? getOrCreateLexicalScope(
DL->getScope(),
DL->getInlinedAt())
211 LexicalScope *getOrCreateRegularScope(
const DILocalScope *
Scope);
214 LexicalScope *getOrCreateInlinedScope(
const DILocalScope *
Scope,
215 const DILocation *InlinedAt);
219 void extractLexicalScopes(SmallVectorImpl<InsnRange> &MIRanges,
220 DenseMap<const MachineInstr *, LexicalScope *> &M);
221 void constructScopeNest(LexicalScope *
Scope);
223 assignInstructionRanges(SmallVectorImpl<InsnRange> &MIRanges,
224 DenseMap<const MachineInstr *, LexicalScope *> &M);
226 const MachineFunction *MF =
nullptr;
230 std::unordered_map<const DILocalScope *, LexicalScope> LexicalScopeMap;
234 std::unordered_map<std::pair<const DILocalScope *, const DILocation *>,
236 pair_hash<const DILocalScope *, const DILocation *>>
237 InlinedLexicalScopeMap;
241 std::unordered_map<const DILocalScope *, LexicalScope> AbstractScopeMap;
245 SmallVector<LexicalScope *, 4> AbstractScopesList;
249 LexicalScope *CurrentFnLexicalScope =
nullptr;
253 using BlockSetT = SmallPtrSet<const MachineBasicBlock *, 4>;
254 DenseMap<const DILocation *, std::unique_ptr<BlockSetT>> DominatedBlocks;
259 #endif // LLVM_CODEGEN_LEXICALSCOPES_H
This is an optimization pass for GlobalISel generic memory operations.
void setDFSIn(unsigned I)
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LexicalScope - This class is used to track scope information.
unsigned getDFSIn() const
void getMachineBasicBlocks(const DILocation *DL, SmallPtrSetImpl< const MachineBasicBlock * > &MBBs)
getMachineBasicBlocks - Populate given set using machine basic blocks which have machine instructions...
void initialize(const MachineFunction &)
initialize - Scan machine function and constuct lexical scope nest, resets the instance if necessary.
SmallVectorImpl< InsnRange > & getRanges()
bool dominates(const DILocation *DL, MachineBasicBlock *MBB)
Return true if DebugLoc's lexical scope dominates at least one machine instruction's lexical scope in...
LexicalScope(LexicalScope *P, const DILocalScope *D, const DILocation *I, bool A)
bool dominates(const LexicalScope *S) const
dominates - Return true if current scope dominates given lexical scope.
LexicalScope * getParent() const
void reset()
releaseMemory - release memory.
unsigned getDFSOut() const
LexicalScope * getOrCreateAbstractScope(const DILocalScope *Scope)
getOrCreateAbstractScope - Find or create an abstract lexical scope.
LexicalScope * findAbstractScope(const DILocalScope *N)
findAbstractScope - Find an abstract scope or return null.
Representation of each machine instruction.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
void closeInsnRange(LexicalScope *NewScope=nullptr)
closeInsnRange - Create a range based on FirstInsn and LastInsn collected until now.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const DILocation * getInlinedAt() const
void openInsnRange(const MachineInstr *MI)
openInsnRange - This scope covers instruction range starting from MI.
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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< LexicalScope * > getAbstractScopesList() const
getAbstractScopesList - Return a reference to list of abstract scopes.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
void setDFSOut(unsigned O)
LexicalScope * findLexicalScope(const DILocalScope *N)
findLexicalScope - Find regular lexical scope or return null.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
const DILocalScope * getScopeNode() const
LexicalScope * findInlinedScope(const DILocalScope *N, const DILocation *IA)
findInlinedScope - Find an inlined scope for the given scope/inlined-at.
LexicalScope * findLexicalScope(const DILocation *DL)
findLexicalScope - Find lexical scope, either regular or inlined, for the given DebugLoc.
void extendInsnRange(const MachineInstr *MI)
extendInsnRange - Extend the current instruction range covered by this scope.
const MDNode * getDesc() const
void addChild(LexicalScope *S)
addChild - Add a child scope.
LexicalScope * getCurrentFunctionScope() const
getCurrentFunctionScope - Return lexical scope for the current function.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isAbstractScope() const
LexicalScopes - This class provides interface to collect and use lexical scoping information from mac...
void dump(unsigned Indent=0) const
dump - print lexical scope.
SmallVectorImpl< LexicalScope * > & getChildren()