diff gen/passes/SimplifyDRuntimeCalls.cpp @ 1545:7fcb72d518f6

More factory methods moved to LLVMContext
author Benjamin Kramer <benny.kra@gmail.com>
date Wed, 15 Jul 2009 18:09:41 +0200
parents 61f12f4651b5
children ed0feda76820
line wrap: on
line diff
--- a/gen/passes/SimplifyDRuntimeCalls.cpp	Fri Jul 17 19:23:20 2009 +0200
+++ b/gen/passes/SimplifyDRuntimeCalls.cpp	Wed Jul 15 18:09:41 2009 +0200
@@ -46,6 +46,7 @@
         bool* Changed;
         const TargetData *TD;
         AliasAnalysis *AA;
+        LLVMContext *Context;
         
         /// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
         Value *CastToCStr(Value *V, IRBuilder<> &B);
@@ -71,6 +72,8 @@
             this->Changed = &Changed;
             this->TD = &TD;
             this->AA = &AA;
+            if (CI->getCalledFunction())
+              Context = CI->getCalledFunction()->getContext();
             return CallOptimizer(CI->getCalledFunction(), CI, B);
         }
     };
@@ -91,7 +94,7 @@
   Tys[0] = Len->getType();
   Value *MemCpy = Intrinsic::getDeclaration(M, IID, Tys, 1);
   return B.CreateCall4(MemCpy, CastToCStr(Dst, B), CastToCStr(Src, B), Len,
-                       ConstantInt::get(Type::Int32Ty, Align));
+                       Context->getConstantInt(Type::Int32Ty, Align));
 }
 
 //===----------------------------------------------------------------------===//
@@ -177,7 +180,7 @@
                 APInt Quot, Rem;
                 APInt::udivrem(OldInt->getValue(), NewInt->getValue(), Quot, Rem);
                 if (Rem == 0)
-                    return B.CreateMul(OldLen, ConstantInt::get(Quot));
+                    return B.CreateMul(OldLen, Context->getConstantInt(Quot));
             }
         return 0;
     }
@@ -198,7 +201,7 @@
                 Constant* C = 0;
                 if ((C = dyn_cast<Constant>(Cmp->getOperand(0)))
                     || (C = dyn_cast<Constant>(Cmp->getOperand(1)))) {
-                    Value* Result = ConstantInt::get(Type::Int1Ty, !Cmp->isTrueWhenEqual());
+                    Value* Result = Context->getConstantInt(Type::Int1Ty, !Cmp->isTrueWhenEqual());
                     Cmp->replaceAllUsesWith(Result);
                     // Don't delete the comparison because there may be an
                     // iterator to it. Instead, set the operands to constants