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 | f286f6fd93d569befe6e77c94a947e6e04e95685 (patch) | |
tree | 400c56bd0a897bc94b6b69e53505a2d1074cdb57 /include/llvm/Analysis/ConstantFolding.h | |
parent | 9324665a7845d6ffd23e3bd53443d28cbf2e75fa (diff) | |
download | llvm-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 'include/llvm/Analysis/ConstantFolding.h')
-rw-r--r-- | include/llvm/Analysis/ConstantFolding.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/include/llvm/Analysis/ConstantFolding.h b/include/llvm/Analysis/ConstantFolding.h index 9c19f111d1..654eee299f 100644 --- a/include/llvm/Analysis/ConstantFolding.h +++ b/include/llvm/Analysis/ConstantFolding.h @@ -21,6 +21,7 @@ namespace llvm { class Instruction; class TargetData; class Function; + class Type; /// ConstantFoldInstruction - Attempt to constant fold the specified /// instruction. If successful, the constant result is returned, if not, null @@ -35,12 +36,17 @@ Constant *ConstantFoldInstruction(Instruction *I, const TargetData *TD = 0); /// fold instructions like loads and stores, which have no constant expression /// form. /// -Constant *ConstantFoldInstOperands( - const Instruction *I, ///< The model instruction - Constant** Ops, ///< The array of constant operands to use. - unsigned NumOps, ///< The number of operands provided. - const TargetData *TD = 0 ///< Optional target information. -); +Constant *ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, + Constant*const * Ops, unsigned NumOps, + const TargetData *TD = 0); + +/// ConstantFoldCompareInstOperands - Attempt to constant fold a compare +/// instruction (icmp/fcmp) with the specified operands. If it fails, it +/// returns a constant expression of the specified operands. +/// +Constant *ConstantFoldCompareInstOperands(unsigned Predicate, + Constant*const * Ops, unsigned NumOps, + const TargetData *TD = 0); /// ConstantFoldLoadThroughGEPConstantExpr - Given a constant and a @@ -55,7 +61,7 @@ bool canConstantFoldCallTo(Function *F); /// ConstantFoldCall - Attempt to constant fold a call to the specified function /// with the specified arguments, returning null if unsuccessful. Constant * -ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands); +ConstantFoldCall(Function *F, Constant* const* Operands, unsigned NumOperands); } #endif |