summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/CloneFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-10 22:53:04 +0000
committerChris Lattner <sabre@nondot.org>2007-12-10 22:53:04 +0000
commitf286f6fd93d569befe6e77c94a947e6e04e95685 (patch)
tree400c56bd0a897bc94b6b69e53505a2d1074cdb57 /lib/Transforms/Utils/CloneFunction.cpp
parent9324665a7845d6ffd23e3bd53443d28cbf2e75fa (diff)
downloadllvm-f286f6fd93d569befe6e77c94a947e6e04e95685.tar.gz
llvm-f286f6fd93d569befe6e77c94a947e6e04e95685.tar.bz2
llvm-f286f6fd93d569befe6e77c94a947e6e04e95685.tar.xz
Fix PR1850 by removing an unsafe transformation from VMCore/ConstantFold.cpp.
Reimplement the xform in Analysis/ConstantFolding.cpp where we can use targetdata to validate that it is safe. While I'm in there, fix some const correctness issues and generalize the interface to the "operand folder". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r--lib/Transforms/Utils/CloneFunction.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
index f05085fca1..e85fe8e40a 100644
--- a/lib/Transforms/Utils/CloneFunction.cpp
+++ b/lib/Transforms/Utils/CloneFunction.cpp
@@ -299,7 +299,13 @@ ConstantFoldMappedInstruction(const Instruction *I) {
else
return 0; // All operands not constant!
- return ConstantFoldInstOperands(I, &Ops[0], Ops.size(), TD);
+
+ if (const CmpInst *CI = dyn_cast<CmpInst>(I))
+ return ConstantFoldCompareInstOperands(CI->getPredicate(),
+ &Ops[0], Ops.size(), TD);
+ else
+ return ConstantFoldInstOperands(I->getOpcode(), I->getType(),
+ &Ops[0], Ops.size(), TD);
}
/// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto,