diff options
author | Chris Lattner <sabre@nondot.org> | 2007-12-10 22:53:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-12-10 22:53:04 +0000 |
commit | d2265b45ae58c2c26fb12035df1e3900ef37e5b8 (patch) | |
tree | 2d97b40f1282b0566509c19fb788da69f715eb7a /llvm/lib/Transforms | |
parent | 91f78080e3727d4472f9aac4b401938ce2195c80 (diff) | |
download | bcm5719-llvm-d2265b45ae58c2c26fb12035df1e3900ef37e5b8.tar.gz bcm5719-llvm-d2265b45ae58c2c26fb12035df1e3900ef37e5b8.zip |
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".
llvm-svn: 44817
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneFunction.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index f05085fca16..e85fe8e40a0 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/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, |