summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-01-03 18:43:03 +0000
committerChris Lattner <sabre@nondot.org>2011-01-03 18:43:03 +0000
commit16ca19ffc5b71a6c0d2ac9d6c80aef7e806c68b6 (patch)
treed5b3fb17bc7d328e33d604dadb1f61f83b0e4728 /llvm/lib/Transforms
parent142f1cd251438f2ea24ad14ca966381756f487f5 (diff)
downloadbcm5719-llvm-16ca19ffc5b71a6c0d2ac9d6c80aef7e806c68b6.tar.gz
bcm5719-llvm-16ca19ffc5b71a6c0d2ac9d6c80aef7e806c68b6.zip
stength reduce my previous patch a bit. The only instructions
that are allowed to have metadata operands are intrinsic calls, and the only ones that take metadata currently return void. Just reject all void instructions, which should not be value numbered anyway. To future proof things, add an assert to the getHashValue impl for calls to check that metadata operands aren't present. llvm-svn: 122759
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/EarlyCSE.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
index 61830e02d6c..6c2ea39896a 100644
--- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -145,14 +145,13 @@ namespace {
}
static bool canHandle(Instruction *Inst) {
+ // Don't value number anything that returns void.
+ if (Inst->getType()->isVoidTy())
+ 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;
}
};
@@ -179,8 +178,12 @@ unsigned DenseMapInfo<CallValue>::getHashValue(CallValue Val) {
Instruction *Inst = Val.Inst;
// Hash in all of the operands as pointers.
unsigned Res = 0;
- for (unsigned i = 0, e = Inst->getNumOperands(); i != e; ++i)
+ for (unsigned i = 0, e = Inst->getNumOperands(); i != e; ++i) {
+ assert(!Inst->getOperand(i)->getType()->isMetadataTy() &&
+ "Cannot value number calls with metadata operands");
Res ^= getHash(Inst->getOperand(i)) << i;
+ }
+
// Mix in the opcode.
return (Res << 1) ^ Inst->getOpcode();
}
OpenPOWER on IntegriCloud