Enhance the memdep interface so that users can tell the difference between a dependency which cannot be calculated and a path reaching the entry point of the function. This patch introduces isNonFuncLocal, which replaces isUnknown in some cases.

Patch by Xiaoyi Guo.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141896 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eli Friedman
2011-10-13 22:14:57 +00:00
parent 48ba0e45ed
commit b414142036
6 changed files with 107 additions and 61 deletions

View File

@@ -1279,7 +1279,9 @@ bool GVN::processNonLocalLoad(LoadInst *LI) {
// If we had a phi translation failure, we'll have a single entry which is a
// clobber in the current block. Reject this early.
if (Deps.size() == 1 && Deps[0].getResult().isUnknown()) {
if (Deps.size() == 1
&& !Deps[0].getResult().isDef() && !Deps[0].getResult().isClobber())
{
DEBUG(
dbgs() << "GVN: non-local load ";
WriteAsOperand(dbgs(), LI);
@@ -1299,7 +1301,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI) {
BasicBlock *DepBB = Deps[i].getBB();
MemDepResult DepInfo = Deps[i].getResult();
if (DepInfo.isUnknown()) {
if (!DepInfo.isDef() && !DepInfo.isClobber()) {
UnavailableBlocks.push_back(DepBB);
continue;
}
@@ -1364,7 +1366,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI) {
continue;
}
assert(DepInfo.isDef() && "Expecting def here");
// DepInfo.isDef() here
Instruction *DepInst = DepInfo.getInst();
@@ -1761,7 +1763,11 @@ bool GVN::processLoad(LoadInst *L) {
return false;
}
if (Dep.isUnknown()) {
// If it is defined in another block, try harder.
if (Dep.isNonLocal())
return processNonLocalLoad(L);
if (!Dep.isDef()) {
DEBUG(
// fast print dep, using operator<< on instruction is too slow.
dbgs() << "GVN: load ";
@@ -1771,12 +1777,6 @@ bool GVN::processLoad(LoadInst *L) {
return false;
}
// If it is defined in another block, try harder.
if (Dep.isNonLocal())
return processNonLocalLoad(L);
assert(Dep.isDef() && "Expecting def here");
Instruction *DepInst = Dep.getInst();
if (StoreInst *DepSI = dyn_cast<StoreInst>(DepInst)) {
Value *StoredVal = DepSI->getValueOperand();