forked from OSchip/llvm-project
Formatting, 80-col, trailing whitespace.
llvm-svn: 195180
This commit is contained in:
parent
d4b22dcbf3
commit
6211e4b995
|
@ -63,7 +63,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getCurrentFunctionScope - Return lexical scope for the current function.
|
/// getCurrentFunctionScope - Return lexical scope for the current function.
|
||||||
LexicalScope *getCurrentFunctionScope() const { return CurrentFnLexicalScope;}
|
LexicalScope *getCurrentFunctionScope() const {
|
||||||
|
return CurrentFnLexicalScope;
|
||||||
|
}
|
||||||
|
|
||||||
/// getMachineBasicBlocks - Populate given set using machine basic blocks
|
/// getMachineBasicBlocks - Populate given set using machine basic blocks
|
||||||
/// which have machine instructions that belong to lexical scope identified by
|
/// which have machine instructions that belong to lexical scope identified by
|
||||||
|
@ -104,7 +106,6 @@ public:
|
||||||
void dump();
|
void dump();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
|
/// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
|
||||||
/// not available then create new lexical scope.
|
/// not available then create new lexical scope.
|
||||||
LexicalScope *getOrCreateLexicalScope(DebugLoc DL);
|
LexicalScope *getOrCreateLexicalScope(DebugLoc DL);
|
||||||
|
@ -123,7 +124,8 @@ private:
|
||||||
void extractLexicalScopes(SmallVectorImpl<InsnRange> &MIRanges,
|
void extractLexicalScopes(SmallVectorImpl<InsnRange> &MIRanges,
|
||||||
DenseMap<const MachineInstr *, LexicalScope *> &M);
|
DenseMap<const MachineInstr *, LexicalScope *> &M);
|
||||||
void constructScopeNest(LexicalScope *Scope);
|
void constructScopeNest(LexicalScope *Scope);
|
||||||
void assignInstructionRanges(SmallVectorImpl<InsnRange> &MIRanges,
|
void
|
||||||
|
assignInstructionRanges(SmallVectorImpl<InsnRange> &MIRanges,
|
||||||
DenseMap<const MachineInstr *, LexicalScope *> &M);
|
DenseMap<const MachineInstr *, LexicalScope *> &M);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -133,7 +135,8 @@ private:
|
||||||
/// contained LexicalScope*s.
|
/// contained LexicalScope*s.
|
||||||
DenseMap<const MDNode *, LexicalScope *> LexicalScopeMap;
|
DenseMap<const MDNode *, LexicalScope *> LexicalScopeMap;
|
||||||
|
|
||||||
/// InlinedLexicalScopeMap - Tracks inlined function scopes in current function.
|
/// InlinedLexicalScopeMap - Tracks inlined function scopes in current
|
||||||
|
/// function.
|
||||||
DenseMap<DebugLoc, LexicalScope *> InlinedLexicalScopeMap;
|
DenseMap<DebugLoc, LexicalScope *> InlinedLexicalScopeMap;
|
||||||
|
|
||||||
/// AbstractScopeMap - These scopes are not included LexicalScopeMap.
|
/// AbstractScopeMap - These scopes are not included LexicalScopeMap.
|
||||||
|
@ -157,8 +160,8 @@ class LexicalScope {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LexicalScope(LexicalScope *P, const MDNode *D, const MDNode *I, bool A)
|
LexicalScope(LexicalScope *P, const MDNode *D, const MDNode *I, bool A)
|
||||||
: Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(A),
|
: Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(A), LastInsn(0),
|
||||||
LastInsn(0), FirstInsn(0), DFSIn(0), DFSOut(0) {
|
FirstInsn(0), DFSIn(0), DFSOut(0) {
|
||||||
if (Parent)
|
if (Parent)
|
||||||
Parent->addChild(this);
|
Parent->addChild(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,7 @@
|
||||||
#include "llvm/Support/FormattedStream.h"
|
#include "llvm/Support/FormattedStream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
LexicalScopes::~LexicalScopes() {
|
LexicalScopes::~LexicalScopes() { releaseMemory(); }
|
||||||
releaseMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// releaseMemory - release memory.
|
/// releaseMemory - release memory.
|
||||||
void LexicalScopes::releaseMemory() {
|
void LexicalScopes::releaseMemory() {
|
||||||
|
@ -54,13 +52,13 @@ void LexicalScopes::initialize(const MachineFunction &Fn) {
|
||||||
|
|
||||||
/// extractLexicalScopes - Extract instruction ranges for each lexical scopes
|
/// extractLexicalScopes - Extract instruction ranges for each lexical scopes
|
||||||
/// for the given machine function.
|
/// for the given machine function.
|
||||||
void LexicalScopes::
|
void LexicalScopes::extractLexicalScopes(
|
||||||
extractLexicalScopes(SmallVectorImpl<InsnRange> &MIRanges,
|
SmallVectorImpl<InsnRange> &MIRanges,
|
||||||
DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap) {
|
DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap) {
|
||||||
|
|
||||||
// Scan each instruction and create scopes. First build working set of scopes.
|
// Scan each instruction and create scopes. First build working set of scopes.
|
||||||
for (MachineFunction::const_iterator I = MF->begin(), E = MF->end();
|
for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E;
|
||||||
I != E; ++I) {
|
++I) {
|
||||||
const MachineInstr *RangeBeginMI = NULL;
|
const MachineInstr *RangeBeginMI = NULL;
|
||||||
const MachineInstr *PrevMI = NULL;
|
const MachineInstr *PrevMI = NULL;
|
||||||
DebugLoc PrevDL;
|
DebugLoc PrevDL;
|
||||||
|
@ -117,7 +115,8 @@ LexicalScope *LexicalScopes::findLexicalScope(DebugLoc DL) {
|
||||||
MDNode *Scope = NULL;
|
MDNode *Scope = NULL;
|
||||||
MDNode *IA = NULL;
|
MDNode *IA = NULL;
|
||||||
DL.getScopeAndInlinedAt(Scope, IA, MF->getFunction()->getContext());
|
DL.getScopeAndInlinedAt(Scope, IA, MF->getFunction()->getContext());
|
||||||
if (!Scope) return NULL;
|
if (!Scope)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// The scope that we were created with could have an extra file - which
|
// The scope that we were created with could have an extra file - which
|
||||||
// isn't what we care about in this case.
|
// isn't what we care about in this case.
|
||||||
|
@ -164,8 +163,8 @@ LexicalScope *LexicalScopes::getOrCreateRegularScope(MDNode *Scope) {
|
||||||
Parent = getOrCreateLexicalScope(DebugLoc::getFromDILexicalBlock(Scope));
|
Parent = getOrCreateLexicalScope(DebugLoc::getFromDILexicalBlock(Scope));
|
||||||
WScope = new LexicalScope(Parent, DIDescriptor(Scope), NULL, false);
|
WScope = new LexicalScope(Parent, DIDescriptor(Scope), NULL, false);
|
||||||
LexicalScopeMap.insert(std::make_pair(Scope, WScope));
|
LexicalScopeMap.insert(std::make_pair(Scope, WScope));
|
||||||
if (!Parent && DIDescriptor(Scope).isSubprogram()
|
if (!Parent && DIDescriptor(Scope).isSubprogram() &&
|
||||||
&& DISubprogram(Scope).describes(MF->getFunction()))
|
DISubprogram(Scope).describes(MF->getFunction()))
|
||||||
CurrentFnLexicalScope = WScope;
|
CurrentFnLexicalScope = WScope;
|
||||||
|
|
||||||
return WScope;
|
return WScope;
|
||||||
|
@ -221,7 +220,8 @@ void LexicalScopes::constructScopeNest(LexicalScope *Scope) {
|
||||||
const SmallVectorImpl<LexicalScope *> &Children = WS->getChildren();
|
const SmallVectorImpl<LexicalScope *> &Children = WS->getChildren();
|
||||||
bool visitedChildren = false;
|
bool visitedChildren = false;
|
||||||
for (SmallVectorImpl<LexicalScope *>::const_iterator SI = Children.begin(),
|
for (SmallVectorImpl<LexicalScope *>::const_iterator SI = Children.begin(),
|
||||||
SE = Children.end(); SI != SE; ++SI) {
|
SE = Children.end();
|
||||||
|
SI != SE; ++SI) {
|
||||||
LexicalScope *ChildScope = *SI;
|
LexicalScope *ChildScope = *SI;
|
||||||
if (!ChildScope->getDFSOut()) {
|
if (!ChildScope->getDFSOut()) {
|
||||||
WorkStack.push_back(ChildScope);
|
WorkStack.push_back(ChildScope);
|
||||||
|
@ -239,14 +239,14 @@ void LexicalScopes::constructScopeNest(LexicalScope *Scope) {
|
||||||
|
|
||||||
/// assignInstructionRanges - Find ranges of instructions covered by each
|
/// assignInstructionRanges - Find ranges of instructions covered by each
|
||||||
/// lexical scope.
|
/// lexical scope.
|
||||||
void LexicalScopes::
|
void LexicalScopes::assignInstructionRanges(
|
||||||
assignInstructionRanges(SmallVectorImpl<InsnRange> &MIRanges,
|
SmallVectorImpl<InsnRange> &MIRanges,
|
||||||
DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap)
|
DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap) {
|
||||||
{
|
|
||||||
|
|
||||||
LexicalScope *PrevLexicalScope = NULL;
|
LexicalScope *PrevLexicalScope = NULL;
|
||||||
for (SmallVectorImpl<InsnRange>::const_iterator RI = MIRanges.begin(),
|
for (SmallVectorImpl<InsnRange>::const_iterator RI = MIRanges.begin(),
|
||||||
RE = MIRanges.end(); RI != RE; ++RI) {
|
RE = MIRanges.end();
|
||||||
|
RI != RE; ++RI) {
|
||||||
const InsnRange &R = *RI;
|
const InsnRange &R = *RI;
|
||||||
LexicalScope *S = MI2ScopeMap.lookup(R.first);
|
LexicalScope *S = MI2ScopeMap.lookup(R.first);
|
||||||
assert(S && "Lost LexicalScope for a machine instruction!");
|
assert(S && "Lost LexicalScope for a machine instruction!");
|
||||||
|
@ -264,24 +264,24 @@ assignInstructionRanges(SmallVectorImpl<InsnRange> &MIRanges,
|
||||||
/// getMachineBasicBlocks - Populate given set using machine basic blocks which
|
/// getMachineBasicBlocks - Populate given set using machine basic blocks which
|
||||||
/// have machine instructions that belong to lexical scope identified by
|
/// have machine instructions that belong to lexical scope identified by
|
||||||
/// DebugLoc.
|
/// DebugLoc.
|
||||||
void LexicalScopes::
|
void LexicalScopes::getMachineBasicBlocks(
|
||||||
getMachineBasicBlocks(DebugLoc DL,
|
DebugLoc DL, SmallPtrSet<const MachineBasicBlock *, 4> &MBBs) {
|
||||||
SmallPtrSet<const MachineBasicBlock*, 4> &MBBs) {
|
|
||||||
MBBs.clear();
|
MBBs.clear();
|
||||||
LexicalScope *Scope = getOrCreateLexicalScope(DL);
|
LexicalScope *Scope = getOrCreateLexicalScope(DL);
|
||||||
if (!Scope)
|
if (!Scope)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Scope == CurrentFnLexicalScope) {
|
if (Scope == CurrentFnLexicalScope) {
|
||||||
for (MachineFunction::const_iterator I = MF->begin(), E = MF->end();
|
for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E;
|
||||||
I != E; ++I)
|
++I)
|
||||||
MBBs.insert(I);
|
MBBs.insert(I);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallVectorImpl<InsnRange> &InsnRanges = Scope->getRanges();
|
SmallVectorImpl<InsnRange> &InsnRanges = Scope->getRanges();
|
||||||
for (SmallVectorImpl<InsnRange>::iterator I = InsnRanges.begin(),
|
for (SmallVectorImpl<InsnRange>::iterator I = InsnRanges.begin(),
|
||||||
E = InsnRanges.end(); I != E; ++I) {
|
E = InsnRanges.end();
|
||||||
|
I != E; ++I) {
|
||||||
InsnRange &R = *I;
|
InsnRange &R = *I;
|
||||||
MBBs.insert(R.first->getParent());
|
MBBs.insert(R.first->getParent());
|
||||||
}
|
}
|
||||||
|
@ -299,8 +299,8 @@ bool LexicalScopes::dominates(DebugLoc DL, MachineBasicBlock *MBB) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool Result = false;
|
bool Result = false;
|
||||||
for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
|
for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E;
|
||||||
I != E; ++I) {
|
++I) {
|
||||||
DebugLoc IDL = I->getDebugLoc();
|
DebugLoc IDL = I->getDebugLoc();
|
||||||
if (IDL.isUnknown())
|
if (IDL.isUnknown())
|
||||||
continue;
|
continue;
|
||||||
|
@ -332,4 +332,3 @@ void LexicalScope::dump(unsigned Indent) const {
|
||||||
Children[i]->dump(Indent + 2);
|
Children[i]->dump(Indent + 2);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue