adjust to constant folding api changes.
authorChris Lattner <sabre@nondot.org>
Tue, 30 Jan 2007 23:15:43 +0000 (23:15 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 30 Jan 2007 23:15:43 +0000 (23:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33673 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ConstantFolding.cpp
lib/Analysis/ScalarEvolution.cpp

index 46f9c577270a41d5865e44fa555a927fe10e5721..ef70ece7765bee26d7ca00f7d2376c79a4d9518c 100644 (file)
@@ -85,23 +85,24 @@ llvm::canConstantFoldCallTo(Function *F) {
   }
 }
 
-Constant *
-llvm::ConstantFoldFP(double (*NativeFP)(double), double V, const Type *Ty) {
+static Constant *ConstantFoldFP(double (*NativeFP)(double), double V, 
+                                const Type *Ty) {
   errno = 0;
   V = NativeFP(V);
   if (errno == 0)
     return ConstantFP::get(Ty, V);
+  errno = 0;
   return 0;
 }
 
 /// ConstantFoldCall - Attempt to constant fold a call to the specified function
 /// with the specified arguments, returning null if unsuccessful.
 Constant *
-llvm::ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands) {
+llvm::ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands) {
   const std::string &Name = F->getName();
   const Type *Ty = F->getReturnType();
 
-  if (Operands.size() == 1) {
+  if (NumOperands == 1) {
     if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) {
       double V = Op->getValue();
       switch (Name[0])
@@ -172,7 +173,7 @@ llvm::ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands) {
       else if (Name == "llvm.bswap.i64")
         return ConstantInt::get(Ty, ByteSwap_64(V));
     }
-  } else if (Operands.size() == 2) {
+  } else if (NumOperands == 2) {
     if (ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) {
       double Op1V = Op1->getValue();
       if (ConstantFP *Op2 = dyn_cast<ConstantFP>(Operands[1])) {
index 1ee1cf2784f0795ab55e5c5100db0c3fa165d05a..a30eeea4f17a8518acf5762b2cbde70985daa615 100644 (file)
@@ -1761,8 +1761,8 @@ static Constant *ConstantFold(const Instruction *I,
     return ConstantExpr::getSelect(Operands[0], Operands[1], Operands[2]);
   case Instruction::Call:
     if (Function *GV = dyn_cast<Function>(Operands[0])) {
-      Operands.erase(Operands.begin());
-      return ConstantFoldCall(cast<Function>(GV), Operands);
+      return ConstantFoldCall(cast<Function>(GV), &Operands[1],
+                              Operands.size()-1);
     }
     return 0;
   case Instruction::GetElementPtr: {