[llvm-commits] [llvm] r122759 - /llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
Chris Lattner
sabre at nondot.org
Mon Jan 3 10:43:03 PST 2011
Author: lattner
Date: Mon Jan 3 12:43:03 2011
New Revision: 122759
URL: http://llvm.org/viewvc/llvm-project?rev=122759&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp?rev=122759&r1=122758&r2=122759&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp Mon Jan 3 12:43:03 2011
@@ -145,14 +145,13 @@
}
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 @@
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();
}
More information about the llvm-commits
mailing list