mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-13 08:56:04 +00:00
Cache the results of dependsOnInvoke()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37622 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a8daa7176b
commit
bbf1197be1
@ -103,6 +103,7 @@ namespace {
|
|||||||
|
|
||||||
std::map<BasicBlock*, std::set<Value*, ExprLT> > availableOut;
|
std::map<BasicBlock*, std::set<Value*, ExprLT> > availableOut;
|
||||||
std::map<BasicBlock*, std::set<Value*, ExprLT> > anticipatedIn;
|
std::map<BasicBlock*, std::set<Value*, ExprLT> > anticipatedIn;
|
||||||
|
std::map<User*, bool> invokeDep;
|
||||||
|
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.setPreservesCFG();
|
AU.setPreservesCFG();
|
||||||
@ -136,6 +137,8 @@ namespace {
|
|||||||
void cleanup();
|
void cleanup();
|
||||||
void elimination();
|
void elimination();
|
||||||
|
|
||||||
|
bool dependsOnInvoke(Value* V);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
char GVNPRE::ID = 0;
|
char GVNPRE::ID = 0;
|
||||||
@ -285,11 +288,15 @@ void GVNPRE::phi_translate_set(std::set<Value*, ExprLT>& anticIn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dependsOnInvoke(Value* V) {
|
bool GVNPRE::dependsOnInvoke(Value* V) {
|
||||||
if (!isa<User>(V))
|
if (!isa<User>(V))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
User* U = cast<User>(V);
|
User* U = cast<User>(V);
|
||||||
|
std::map<User*, bool>::iterator I = invokeDep.find(U);
|
||||||
|
if (I != invokeDep.end())
|
||||||
|
return I->second;
|
||||||
|
|
||||||
std::vector<Value*> worklist(U->op_begin(), U->op_end());
|
std::vector<Value*> worklist(U->op_begin(), U->op_end());
|
||||||
std::set<Value*> visited;
|
std::set<Value*> visited;
|
||||||
|
|
||||||
@ -304,10 +311,16 @@ bool dependsOnInvoke(Value* V) {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
User* curr = cast<User>(current);
|
User* curr = cast<User>(current);
|
||||||
|
std::map<User*, bool>::iterator CI = invokeDep.find(curr);
|
||||||
|
if (CI != invokeDep.end()) {
|
||||||
|
if (CI->second)
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
for (unsigned i = 0; i < curr->getNumOperands(); ++i)
|
for (unsigned i = 0; i < curr->getNumOperands(); ++i)
|
||||||
if (visited.find(curr->getOperand(i)) == visited.end())
|
if (visited.find(curr->getOperand(i)) == visited.end())
|
||||||
worklist.push_back(curr->getOperand(i));
|
worklist.push_back(curr->getOperand(i));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -593,6 +606,7 @@ bool GVNPRE::runOnFunction(Function &F) {
|
|||||||
createdExpressions.clear();
|
createdExpressions.clear();
|
||||||
availableOut.clear();
|
availableOut.clear();
|
||||||
anticipatedIn.clear();
|
anticipatedIn.clear();
|
||||||
|
invokeDep.clear();
|
||||||
|
|
||||||
std::map<BasicBlock*, std::set<Value*, ExprLT> > generatedExpressions;
|
std::map<BasicBlock*, std::set<Value*, ExprLT> > generatedExpressions;
|
||||||
std::map<BasicBlock*, std::set<PHINode*> > generatedPhis;
|
std::map<BasicBlock*, std::set<PHINode*> > generatedPhis;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user