summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-01-03 18:28:15 +0000
committerChris Lattner <sabre@nondot.org>2011-01-03 18:28:15 +0000
commit142f1cd251438f2ea24ad14ca966381756f487f5 (patch)
tree93d460b34980f92f19716d6e598895d65a370000 /llvm/lib/Transforms/Scalar/EarlyCSE.cpp
parentc63f1c5ab65b0318a0daf85bf02b936a07dd1921 (diff)
downloadbcm5719-llvm-142f1cd251438f2ea24ad14ca966381756f487f5.tar.gz
bcm5719-llvm-142f1cd251438f2ea24ad14ca966381756f487f5.zip
fix PR8895: metadata operands don't have a strong use of their
nested values, so they can change and drop to null, which can change the hash and cause havok. It turns out that it isn't a good idea to value number stuff with metadata operands anyway, so... don't. llvm-svn: 122758
Diffstat (limited to 'llvm/lib/Transforms/Scalar/EarlyCSE.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/EarlyCSE.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
index 9e7092bacda..61830e02d6c 100644
--- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -145,9 +145,15 @@ namespace {
}
static bool canHandle(Instruction *Inst) {
- if (CallInst *CI = dyn_cast<CallInst>(Inst))
- return CI->onlyReadsMemory();
- return false;
+ CallInst *CI = dyn_cast<CallInst>(Inst);
+ if (CI == 0 || !CI->onlyReadsMemory())
+ return false;
+
+ // Check that there are no metadata operands.
+ for (unsigned i = 0, e = CI->getNumOperands(); i != e; ++i)
+ if (CI->getOperand(i)->getType()->isMetadataTy())
+ return false;
+ return true;
}
};
}
@@ -407,7 +413,7 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
if (LastStore &&
LastStore->getPointerOperand() == SI->getPointerOperand()) {
DEBUG(dbgs() << "EarlyCSE DEAD STORE: " << *LastStore << " due to: "
- << *Inst << '\n');
+ << *Inst << '\n');
LastStore->eraseFromParent();
Changed = true;
++NumDSE;
OpenPOWER on IntegriCloud