Replace dyn_castGetElementPtr with dyn_cast<GEPOperator>.
[oota-llvm.git] / lib / Transforms / Scalar / MemCpyOptimizer.cpp
index 8937e1c86334c2274c0b821d7ffcc6ebced64c7e..c359e47d05d790dcb2a7ccc7f505b8278aa70073 100644 (file)
@@ -69,7 +69,7 @@ static Value *isBytewiseValue(Value *V, LLVMContext& Context) {
         if (Val != Val2)
           return 0;
       }
-      return Context.getConstantInt(Val);
+      return ConstantInt::get(Context, Val);
     }
   }
   
@@ -352,6 +352,8 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
 
   TargetData &TD = getAnalysis<TargetData>();
   AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
+  LLVMContext &Context = SI->getContext();
+  Module *M = SI->getParent()->getParent()->getParent();
 
   // Okay, so we now have a single store that can be splatable.  Scan to find
   // all subsequent stores of the same value to offset from the same pointer.
@@ -431,8 +433,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
   
     if (MemSetF == 0) {
       const Type *Tys[] = {Type::Int64Ty};
-      MemSetF = Intrinsic::getDeclaration(SI->getParent()->getParent()
-                                          ->getParent(), Intrinsic::memset,
+      MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset,
                                           Tys, 1);
    }
     
@@ -440,17 +441,17 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
     StartPtr = Range.StartPtr;
   
     // Cast the start ptr to be i8* as memset requires.
-    const Type *i8Ptr = SI->getContext().getPointerTypeUnqual(Type::Int8Ty);
+    const Type *i8Ptr = Context.getPointerTypeUnqual(Type::Int8Ty);
     if (StartPtr->getType() != i8Ptr)
-      StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getNameStart(),
+      StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(),
                                  InsertPt);
   
     Value *Ops[] = {
       StartPtr, ByteVal,   // Start, value
       // size
-      SI->getContext().getConstantInt(Type::Int64Ty, Range.End-Range.Start),
+      ConstantInt::get(Type::Int64Ty, Range.End-Range.Start),
       // align
-      SI->getContext().getConstantInt(Type::Int32Ty, Range.Alignment)
+      ConstantInt::get(Type::Int32Ty, Range.Alignment)
     };
     Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt);
     DEBUG(cerr << "Replace stores:\n";