summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/CloneFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-01-30 23:13:49 +0000
committerChris Lattner <sabre@nondot.org>2007-01-30 23:13:49 +0000
commit2c4610e4cadf0c877117052fb6b3bdc01091166b (patch)
treed3afd474357c9a27dfcd4f47e5f059f5194fe316 /llvm/lib/Transforms/Utils/CloneFunction.cpp
parent1e6cf2ee3cb4fa560f7d8bf4a8331797fad978dd (diff)
downloadbcm5719-llvm-2c4610e4cadf0c877117052fb6b3bdc01091166b.tar.gz
bcm5719-llvm-2c4610e4cadf0c877117052fb6b3bdc01091166b.zip
Change constant folding APIs to take an optional TargetData, and change
ConstantFoldInstOperands/ConstantFoldCall to take a pointer to an array of operands + size, instead of an std::vector. In some cases, switch to using a SmallVector instead of a vector. This allows us to get rid of some special case gross code that was there to avoid the cost of constructing a vector. llvm-svn: 33670
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp22
1 files changed, 3 insertions, 19 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 753d657d583..f47bf1b7bff 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -21,6 +21,7 @@
#include "llvm/Support/CFG.h"
#include "ValueMapper.h"
#include "llvm/Transforms/Utils/Local.h"
+#include "llvm/ADT/SmallVector.h"
using namespace llvm;
// CloneBasicBlock - See comments in Cloning.h
@@ -281,24 +282,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB) {
/// mapping its operands through ValueMap if they are available.
Constant *PruningFunctionCloner::
ConstantFoldMappedInstruction(const Instruction *I) {
- if (isa<CmpInst>(I)) {
- if (Constant *Op0 = dyn_cast_or_null<Constant>(MapValue(I->getOperand(0),
- ValueMap)))
- if (Constant *Op1 = dyn_cast_or_null<Constant>(MapValue(I->getOperand(1),
- ValueMap)))
- return ConstantExpr::getCompare(cast<CmpInst>(I)->getPredicate(), Op0,
- Op1);
- return 0;
- } else if (isa<BinaryOperator>(I) || isa<ShiftInst>(I)) {
- if (Constant *Op0 = dyn_cast_or_null<Constant>(MapValue(I->getOperand(0),
- ValueMap)))
- if (Constant *Op1 = dyn_cast_or_null<Constant>(MapValue(I->getOperand(1),
- ValueMap)))
- return ConstantExpr::get(I->getOpcode(), Op0, Op1);
- return 0;
- }
-
- std::vector<Constant*> Ops;
+ SmallVector<Constant*, 8> Ops;
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
if (Constant *Op = dyn_cast_or_null<Constant>(MapValue(I->getOperand(i),
ValueMap)))
@@ -306,7 +290,7 @@ ConstantFoldMappedInstruction(const Instruction *I) {
else
return 0; // All operands not constant!
- return ConstantFoldInstOperands(I, Ops);
+ return ConstantFoldInstOperands(I, &Ops[0], Ops.size());
}
/// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto,
OpenPOWER on IntegriCloud