MDNode *IA = NULL;
DL.getScopeAndInlinedAt(Scope, IA, MF->getFunction()->getContext());
if (!Scope) return NULL;
+
+ // The scope that we were created with could have an extra file - which
+ // isn't what we care about in this case.
+ DIDescriptor D = DIDescriptor(Scope);
+ if (D.isLexicalBlockFile())
+ Scope = DILexicalBlockFile(Scope).getScope();
+
if (IA)
return InlinedLexicalScopeMap.lookup(DebugLoc::getFromDILocation(IA));
- return LexicalScopeMap.lookup(DL.getScope(Scope->getContext()));
+ return LexicalScopeMap.lookup(Scope);
}
/// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
MDNode *Scope = NULL;
MDNode *InlinedAt = NULL;
DL.getScopeAndInlinedAt(Scope, InlinedAt, MF->getFunction()->getContext());
+
if (InlinedAt) {
// Create an abstract scope for inlined function.
getOrCreateAbstractScope(Scope);
/// getOrCreateRegularScope - Find or create a regular lexical scope.
LexicalScope *LexicalScopes::getOrCreateRegularScope(MDNode *Scope) {
+ DIDescriptor D = DIDescriptor(Scope);
+ if (D.isLexicalBlockFile()) {
+ Scope = DILexicalBlockFile(Scope).getScope();
+ D = DIDescriptor(Scope);
+ }
+
LexicalScope *WScope = LexicalScopeMap.lookup(Scope);
if (WScope)
return WScope;
LexicalScope *Parent = NULL;
- if (DIDescriptor(Scope).isLexicalBlock())
+ if (D.isLexicalBlock())
Parent = getOrCreateLexicalScope(DebugLoc::getFromDILexicalBlock(Scope));
WScope = new LexicalScope(Parent, DIDescriptor(Scope), NULL, false);
LexicalScopeMap.insert(std::make_pair(Scope, WScope));
LexicalScope *LexicalScopes::getOrCreateAbstractScope(const MDNode *N) {
assert(N && "Invalid Scope encoding!");
+ DIDescriptor Scope(N);
+ if (Scope.isLexicalBlockFile())
+ Scope = DILexicalBlockFile(Scope).getScope();
LexicalScope *AScope = AbstractScopeMap.lookup(N);
if (AScope)
return AScope;
LexicalScope *Parent = NULL;
- DIDescriptor Scope(N);
if (Scope.isLexicalBlock()) {
DILexicalBlock DB(N);
DIDescriptor ParentDesc = DB.getContext();
}
}
-/// assignInstructionRanges - Find ranges of instructions covered by each lexical
-/// scope.
+/// assignInstructionRanges - Find ranges of instructions covered by each
+/// lexical scope.
void LexicalScopes::
assignInstructionRanges(SmallVectorImpl<InsnRange> &MIRanges,
- DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap) {
+ DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap)
+{
LexicalScope *PrevLexicalScope = NULL;
for (SmallVectorImpl<InsnRange>::const_iterator RI = MIRanges.begin(),
/// have machine instructions that belong to lexical scope identified by
/// DebugLoc.
void LexicalScopes::
-getMachineBasicBlocks(DebugLoc DL, SmallPtrSet<const MachineBasicBlock*, 4> &MBBs) {
+getMachineBasicBlocks(DebugLoc DL,
+ SmallPtrSet<const MachineBasicBlock*, 4> &MBBs) {
MBBs.clear();
LexicalScope *Scope = getOrCreateLexicalScope(DL);
if (!Scope)
return;
+ if (Scope == CurrentFnLexicalScope) {
+ for (MachineFunction::const_iterator I = MF->begin(), E = MF->end();
+ I != E; ++I)
+ MBBs.insert(I);
+ return;
+ }
+
SmallVector<InsnRange, 4> &InsnRanges = Scope->getRanges();
for (SmallVector<InsnRange, 4>::iterator I = InsnRanges.begin(),
E = InsnRanges.end(); I != E; ++I) {
LexicalScope *Scope = getOrCreateLexicalScope(DL);
if (!Scope)
return false;
+
+ // Current function scope covers all basic blocks in the function.
+ if (Scope == CurrentFnLexicalScope && MBB->getParent() == MF)
+ return true;
+
bool Result = false;
for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
I != E; ++I) {
return Result;
}
+void LexicalScope::anchor() { }
+
/// dump - Print data structures.
void LexicalScope::dump() const {
#ifndef NDEBUG