Change ConstantFoldConstantExpression to accept a null
authorDan Gohman <gohman@apple.com>
Tue, 2 Jun 2009 21:48:15 +0000 (21:48 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 2 Jun 2009 21:48:15 +0000 (21:48 +0000)
TargetData pointer. The only thing it's used for are
calls to ConstantFoldCompareInstOperands and
ConstantFoldInstOperands, which both already accept a
null TargetData pointer. This makes
ConstantFoldConstantExpression easier to use in clients
where TargetData is optional.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72741 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/ConstantFolding.h
lib/Analysis/ConstantFolding.cpp

index bf360f7e88470e5e89c11556420caf2831b4dcae..5fdf6d2c916ccdb922d5703d860e025eae6bb8d0 100644 (file)
@@ -34,7 +34,7 @@ Constant *ConstantFoldInstruction(Instruction *I, const TargetData *TD = 0);
 /// using the specified TargetData.  If successful, the constant result is
 /// result is returned, if not, null is returned.
 Constant *ConstantFoldConstantExpression(ConstantExpr *CE,
-                                         const TargetData *TD);
+                                         const TargetData *TD = 0);
 
 /// ConstantFoldInstOperands - Attempt to constant fold an instruction with the
 /// specified operands.  If successful, the constant result is returned, if not,
index e5ab3226ce49b45fdbf42bc61d22aef8994ebcbf..261c635feb4a2db8c3edd86d51bcd83cfbb7cbf6 100644 (file)
@@ -317,8 +317,6 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I, const TargetData *TD) {
 /// result is returned, if not, null is returned.
 Constant *llvm::ConstantFoldConstantExpression(ConstantExpr *CE,
                                                const TargetData *TD) {
-  assert(TD && "ConstantFoldConstantExpression requires a valid TargetData.");
-
   SmallVector<Constant*, 8> Ops;
   for (User::op_iterator i = CE->op_begin(), e = CE->op_end(); i != e; ++i)
     Ops.push_back(cast<Constant>(*i));