diff options
author | Owen Anderson <resistor@mac.com> | 2011-01-03 23:51:43 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2011-01-03 23:51:43 +0000 |
commit | d62d37225ac53245981c23fdbb671aa7cf81270d (patch) | |
tree | 00fef4b8337b7fbe5d3ecf57364b594566ade425 /llvm/lib/Transforms | |
parent | f02ca16ba78d3a12529a8e2d2f2ef1ecf0a0f2b9 (diff) | |
download | bcm5719-llvm-d62d37225ac53245981c23fdbb671aa7cf81270d.tar.gz bcm5719-llvm-d62d37225ac53245981c23fdbb671aa7cf81270d.zip |
Use the new addEscapingValue callback to update GlobalsModRef when GVN adds PHIs of GEPs. For the moment,
have GlobalsModRef handle this conservatively by simply removing the value from its maps.
llvm-svn: 122787
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index bf46bd98c3d..f0e0f381425 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -1063,6 +1063,15 @@ static Value *ConstructSSAForLoadSet(LoadInst *LI, if (V->getType()->isPointerTy()) for (unsigned i = 0, e = NewPHIs.size(); i != e; ++i) AA->copyValue(LI, NewPHIs[i]); + + // Now that we've copied information to the new PHIs, scan through + // them again and inform alias analysis that we've added potentially + // escaping uses to any values that are operands to these PHIs. + for (unsigned i = 0, e = NewPHIs.size(); i != e; ++i) { + PHINode *P = NewPHIs[i]; + for (unsigned ii = 0, ee = P->getNumIncomingValues(); ii != ee; ++ii) + AA->addEscapingUse(P->getOperandUse(2*ii)); + } return V; } @@ -1957,8 +1966,16 @@ bool GVN::performPRE(Function &F) { insert_table(ValNo, Phi, CurrentBlock); CurInst->replaceAllUsesWith(Phi); - if (MD && Phi->getType()->isPointerTy()) - MD->invalidateCachedPointerInfo(Phi); + if (Phi->getType()->isPointerTy()) { + // Because we have added a PHI-use of the pointer value, it has now + // "escaped" from alias analysis' perspective. We need to inform + // AA of this. + for (unsigned ii = 0, ee = Phi->getNumIncomingValues(); ii != ee; ++ii) + VN.getAliasAnalysis()->addEscapingUse(Phi->getOperandUse(2*ii)); + + if (MD) + MD->invalidateCachedPointerInfo(Phi); + } VN.erase(CurInst); erase_table(ValNo, CurInst, CurrentBlock); |