[llvm-commits] [poolalloc] r49340 - in /poolalloc/trunk: include/poolalloc/PoolAllocate.h lib/PoolAllocate/AccessTrace.cpp lib/PoolAllocate/PASimple.cpp lib/PoolAllocate/PointerCompress.cpp lib/PoolAllocate/PoolAllocate.cpp lib/PoolAllocate/PoolOptimize.cpp lib/PoolAllocate/TransformFunctionBody.cpp

John Criswell criswell at uiuc.edu
Mon Apr 7 08:09:42 PDT 2008


Author: criswell
Date: Mon Apr  7 10:09:40 2008
New Revision: 49340

URL: http://llvm.org/viewvc/llvm-project?rev=49340&view=rev
Log:
Updated Pool Allocation to new LLVM API.
Added the PoolAllocateGroup analysis group.

Modified:
    poolalloc/trunk/include/poolalloc/PoolAllocate.h
    poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp
    poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
    poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp
    poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
    poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp
    poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp

Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=49340&r1=49339&r2=49340&view=diff

==============================================================================
--- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original)
+++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Mon Apr  7 10:09:40 2008
@@ -109,6 +109,22 @@
 } // end PA namespace
 
 
+class PoolAllocateGroup : public ImmutablePass {
+public:
+  static char ID;
+  virtual PA::FuncInfo *getFuncInfo(Function &F);
+  virtual PA::FuncInfo *getFuncInfoOrClone(Function &F);
+  virtual DSGraph & getDSGraph (const Function & F) const;
+
+  virtual DSGraph & getGlobalsGraph () const;
+
+  virtual Value * getPool (const DSNode * N, Function & F);
+
+  virtual Value * getGlobalPool (const DSNode * Node);
+
+  virtual CompleteBUDataStructures::callee_iterator callee_begin (CallInst *CI);
+  virtual CompleteBUDataStructures::callee_iterator callee_end   (CallInst *CI);
+};
 
 /// PoolAllocate - The main pool allocation pass
 ///

Modified: poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp?rev=49340&r1=49339&r2=49340&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp Mon Apr  7 10:09:40 2008
@@ -95,7 +95,7 @@
 
   // Insert the trace call.
   Value *Opts[2] = {Ptr, PD};
-  new CallInst(PoolAccessTraceFn, Opts, Opts + 2, "", I);
+  CallInst::Create (PoolAccessTraceFn, Opts, Opts + 2, "", I);
 }
 
 bool PoolAccessTrace::runOnModule(Module &M) {
@@ -108,7 +108,7 @@
   Function *MainFunc = M.getFunction("main");
   if (MainFunc && !MainFunc->isDeclaration())
     // Insert a call to the library init function into the beginning of main.
-    new CallInst(AccessTraceInitFn, "", MainFunc->begin()->begin());
+    CallInst::Create (AccessTraceInitFn, "", MainFunc->begin()->begin());
 
   // Look at all of the loads in the program.
   for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {

Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=49340&r1=49339&r2=49340&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Mon Apr  7 10:09:40 2008
@@ -46,6 +46,8 @@
 namespace {
   RegisterPass<PoolAllocateSimple>
   X("poolalloc-simple", "Pool allocate everything into a single global pool");
+
+  RegisterAnalysisGroup<PoolAllocateGroup> PAGroup1(X);
 }
 
 static inline Value *
@@ -74,6 +76,7 @@
   AU.addRequired<TargetData>();
   AU.addRequiredTransitive<EquivClassGraphs>();
   AU.addPreserved<EquivClassGraphs>();
+  AU.setPreservesAll();
 }
 
 bool PoolAllocateSimple::runOnModule(Module &M) {
@@ -153,7 +156,7 @@
         }
 
         Value* args[] = {TheGlobalPool, AllocSize};
-        Instruction* x = new CallInst(PoolAlloc, &args[0], &args[2], MI->getName(), ii);
+        Instruction* x = CallInst::Create(PoolAlloc, &args[0], &args[2], MI->getName(), ii);
         ii->replaceAllUsesWith(CastInst::createPointerCast(x, ii->getType(), "", ii));
       } else if (AllocaInst * AI = dyn_cast<AllocaInst>(ii)) {
 #if 0
@@ -162,7 +165,7 @@
         toDelete.push_back(ii);
         //Fixme: fixup size
         Value* args[] = {TheGlobalPool, ii->getOperand(0)};
-        Instruction* x = new CallInst(PoolAlloc, &args[0], &args[2], AI->getName(), ii);
+        Instruction* x = CallInst::Create(PoolAlloc, &args[0], &args[2], AI->getName(), ii);
         ToFree.push_back(x);
         ii->replaceAllUsesWith(CastInst::createPointerCast(x, ii->getType(), "", ii));
 #endif
@@ -203,7 +206,7 @@
 
           std::string Name = CI->getName(); CI->setName("");
           Value* Opts[3] = {TheGlobalPool, OldPtr, Size};
-          Instruction *V = new CallInst (PoolRealloc,
+          Instruction *V = CallInst::Create (PoolRealloc,
                                          Opts,
                                          Opts + 3,
                                          Name,
@@ -220,7 +223,7 @@
         Value * FreedNode = castTo (FI->getPointerOperand(), VoidPtrTy, "cast", ii);
         toDelete.push_back(ii);
         Value* args[] = {TheGlobalPool, FreedNode};
-        new CallInst(PoolFree, &args[0], &args[2], "", ii);
+        CallInst::Create(PoolFree, &args[0], &args[2], "", ii);
       } else if (isa<ReturnInst>(ii)) {
         Returns.push_back(cast<ReturnInst>(ii));
       }
@@ -234,7 +237,7 @@
         std::vector<Value*> args;
         args.push_back (TheGlobalPool);
         args.push_back (*ii);
-        new CallInst(PoolFree, args.begin(), args.end(), "", *i);
+        CallInst::Create(PoolFree, args.begin(), args.end(), "", *i);
     }
   
   //delete malloc and alloca insts
@@ -269,7 +272,7 @@
   Value *ElSize = ConstantInt::get(Type::Int32Ty, RecSize);
   Value *AlignV = ConstantInt::get(Type::Int32Ty, Align);
   Value* Opts[3] = {GV, ElSize, AlignV};
-  new CallInst(PoolInit, Opts, Opts + 3, "", InsertPt);
+  CallInst::Create(PoolInit, Opts, Opts + 3, "", InsertPt);
   return GV;
 }
 

Modified: poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp?rev=49340&r1=49339&r2=49340&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp Mon Apr  7 10:09:40 2008
@@ -289,7 +289,7 @@
     // Get the pool base pointer.
     Constant *Zero = Constant::getNullValue(Type::Int32Ty);
     Value *Opts[2] = {Zero, Zero};
-    Value *BasePtrPtr = new GetElementPtrInst(getPoolDesc(), Opts, Opts + 2,
+    Value *BasePtrPtr = GetElementPtrInst::Create(getPoolDesc(), Opts, Opts + 2,
                                               "poolbaseptrptr", &I);
     return new LoadInst(BasePtrPtr, "poolbaseptr", &I);
   } else {
@@ -301,7 +301,7 @@
       while (isa<AllocaInst>(IP)) ++IP;
       Constant *Zero = Constant::getNullValue(Type::Int32Ty);
       Value *Opts[2] = {Zero, Zero};
-      Value *BasePtrPtr = new GetElementPtrInst(getPoolDesc(), Opts, Opts + 2,
+      Value *BasePtrPtr = GetElementPtrInst::Create(getPoolDesc(), Opts, Opts + 2,
                                                 "poolbaseptrptr", IP);
       PoolBase = new LoadInst(BasePtrPtr, "poolbaseptr", IP);
     }
@@ -575,7 +575,7 @@
   if (RI.getNumOperands() && isa<PointerType>(RI.getOperand(0)->getType()))
     if (!isa<PointerType>(RI.getParent()->getParent()->getReturnType())) {
       // Compressing the return value.  
-      new ReturnInst(getTransformedValue(RI.getOperand(0)), &RI);
+      ReturnInst::Create(getTransformedValue(RI.getOperand(0)), &RI);
       RI.eraseFromParent();
     }
 }
@@ -604,7 +604,7 @@
   const CompressedPoolInfo *DestPI = getPoolInfo(&PN);
   if (DestPI == 0) return;
 
-  PHINode *New = new PHINode(SCALARUINTTYPE, PN.getName(), &PN);
+  PHINode *New = PHINode::Create (SCALARUINTTYPE, PN.getName(), &PN);
   New->reserveOperandSpace(PN.getNumIncomingValues());
 
   for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
@@ -617,7 +617,7 @@
   const CompressedPoolInfo *DestPI = getPoolInfo(&SI);
   if (DestPI == 0) return;
 
-  setTransformedValue(SI, new SelectInst(SI.getOperand(0),
+  setTransformedValue(SI, SelectInst::Create(SI.getOperand(0),
                                          getTransformedValue(SI.getOperand(1)),
                                          getTransformedValue(SI.getOperand(2)),
                                          SI.getName(), &SI));
@@ -773,7 +773,7 @@
   Value* Ops = getTransformedValue(LI.getOperand(0));
   if (Ops->getType() == Type::Int16Ty)
     Ops = CastInst::createZExtOrBitCast(Ops, Type::Int32Ty, "extend_idx", &LI);
-  Value *SrcPtr = new GetElementPtrInst(BasePtr, Ops,
+  Value *SrcPtr = GetElementPtrInst::Create(BasePtr, Ops,
                                         LI.getOperand(0)->getName()+".pp", &LI);
   const Type *DestTy = LoadingCompressedPtr ? MEMUINTTYPE : LI.getType();
   SrcPtr = CastInst::createPointerCast(SrcPtr, PointerType::getUnqual(DestTy),
@@ -839,7 +839,7 @@
   if (Ops->getType() == Type::Int16Ty)
     Ops = CastInst::createZExtOrBitCast(Ops, Type::Int32Ty, "extend_idx", &SI);
 
-  Value *DestPtr = new GetElementPtrInst(BasePtr, Ops,
+  Value *DestPtr = GetElementPtrInst::Create(BasePtr, Ops,
                                          SI.getOperand(1)->getName()+".pp",
                                          &SI);
   DestPtr = CastInst::createPointerCast(DestPtr,
@@ -869,7 +869,7 @@
   Ops.push_back(ConstantInt::get(Type::Int32Ty,
              PA::Heuristic::getRecommendedAlignment(PI->getNewType(), TD)));
   // TODO: Compression could reduce the alignment restriction for the pool!
-  Value *PB = new CallInst(PtrComp.PoolInitPC, Ops.begin(), Ops.end(), "", &CI);
+  Value *PB = CallInst::Create(PtrComp.PoolInitPC, Ops.begin(), Ops.end(), "", &CI);
 
   if (!DisablePoolBaseASR) { // Load the pool base immediately.
     PB->setName(CI.getOperand(1)->getName()+".poolbase");
@@ -886,7 +886,7 @@
   const CompressedPoolInfo *PI = getPoolInfoForPoolDesc(CI.getOperand(1));
   if (PI == 0) return;  // Pool isn't compressed.
 
-  new CallInst(PtrComp.PoolDestroyPC, CI.getOperand(1), "", &CI);
+  CallInst::Create(PtrComp.PoolDestroyPC, CI.getOperand(1), "", &CI);
   CI.eraseFromParent();
 }
 
@@ -912,7 +912,7 @@
     }
 
   Value *Opts[2] = {CI.getOperand(1), Size};
-  Value *NC = new CallInst(PtrComp.PoolAllocPC, Opts, Opts + 2, CI.getName(), &CI);
+  Value *NC = CallInst::Create(PtrComp.PoolAllocPC, Opts, Opts + 2, CI.getName(), &CI);
   setTransformedValue(CI, NC);
 }
 
@@ -968,7 +968,7 @@
     } else if (Callee->getName() == "read") {
       if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(2))) {
         Value *BasePtr = DestPI->EmitPoolBaseLoad(CI);
-        Value *SrcPtr = new GetElementPtrInst(BasePtr, getTransformedValue(CI.getOperand(2)),
+        Value *SrcPtr = GetElementPtrInst::Create(BasePtr, getTransformedValue(CI.getOperand(2)),
                                        CI.getOperand(2)->getName()+".pp", &CI);
         SrcPtr = CastInst::createPointerCast(SrcPtr, CI.getOperand(2)->getType(), "", &CI);
         CI.setOperand(2, SrcPtr);
@@ -977,7 +977,7 @@
     } else if (Callee->getName() == "fwrite") {
       if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(1))) {
         Value *BasePtr = DestPI->EmitPoolBaseLoad(CI);
-        Value *SrcPtr = new GetElementPtrInst(BasePtr, getTransformedValue(CI.getOperand(1)),
+        Value *SrcPtr = GetElementPtrInst::Create(BasePtr, getTransformedValue(CI.getOperand(1)),
                                        CI.getOperand(1)->getName()+".pp", &CI);
         SrcPtr = CastInst::createPointerCast(SrcPtr, CI.getOperand(1)->getType(), "", &CI);
         CI.setOperand(1, SrcPtr);
@@ -988,7 +988,7 @@
                Callee->getName() == "llvm.memset.i64") {
       if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(1))) {
         Value *BasePtr = DestPI->EmitPoolBaseLoad(CI);
-        Value *SrcPtr = new GetElementPtrInst(BasePtr, getTransformedValue(CI.getOperand(1)),
+        Value *SrcPtr = GetElementPtrInst::Create(BasePtr, getTransformedValue(CI.getOperand(1)),
                                        CI.getOperand(1)->getName()+".pp", &CI);
         SrcPtr = CastInst::createPointerCast(SrcPtr, CI.getOperand(1)->getType(), "", &CI);
         CI.setOperand(1, SrcPtr);
@@ -1000,7 +1000,7 @@
       bool doret = false;
       if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(1))) {
         Value *BasePtr = DestPI->EmitPoolBaseLoad(CI);
-        Value *SrcPtr = new GetElementPtrInst(BasePtr, getTransformedValue(CI.getOperand(1)),
+        Value *SrcPtr = GetElementPtrInst::Create(BasePtr, getTransformedValue(CI.getOperand(1)),
                                        CI.getOperand(1)->getName()+".pp", &CI);
         SrcPtr = CastInst::createPointerCast(SrcPtr, CI.getOperand(1)->getType(), "", &CI);
         CI.setOperand(1, SrcPtr);
@@ -1008,7 +1008,7 @@
       }
       if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(2))) {
         Value *BasePtr = DestPI->EmitPoolBaseLoad(CI);
-        Value *SrcPtr = new GetElementPtrInst(BasePtr, getTransformedValue(CI.getOperand(2)),
+        Value *SrcPtr = GetElementPtrInst::Create(BasePtr, getTransformedValue(CI.getOperand(2)),
                                        CI.getOperand(2)->getName()+".pp", &CI);
         SrcPtr = CastInst::createPointerCast(SrcPtr, CI.getOperand(2)->getType(), "", &CI);
         CI.setOperand(2, SrcPtr);
@@ -1037,7 +1037,7 @@
     }
 
     Function *Clone = PtrComp.GetExtFunctionClone(Callee, CompressedArgs);
-    Value *NC = new CallInst(Clone, Operands.begin(), Operands.end(), CI.getName(), &CI);
+    Value *NC = CallInst::Create(Clone, Operands.begin(), Operands.end(), CI.getName(), &CI);
     if (NC->getType() != CI.getType())      // Compressing return value?
       setTransformedValue(CI, NC);
     else {
@@ -1114,7 +1114,7 @@
     else
       Operands.push_back(CI.getOperand(i));
 
-  Value *NC = new CallInst(Clone, Operands.begin(), Operands.end(), CI.getName(), &CI);
+  Value *NC = CallInst::Create(Clone, Operands.begin(), Operands.end(), CI.getName(), &CI);
   if (NC->getType() != CI.getType())      // Compressing return value?
     setTransformedValue(CI, NC);
   else {
@@ -1353,7 +1353,7 @@
   FunctionType *CFTy = FunctionType::get(RetTy, ParamTypes, FTy->isVarArg());
 
   // Next, create the clone prototype and insert it into the module.
-  Clone = new Function(CFTy, GlobalValue::ExternalLinkage,
+  Clone = Function::Create (CFTy, GlobalValue::ExternalLinkage,
                        F->getName()+"_pc");
   F->getParent()->getFunctionList().insert(F, Clone);
   return Clone;
@@ -1399,8 +1399,8 @@
   FunctionType *CFTy = FunctionType::get(RetTy, ParamTypes, FTy->isVarArg());
 
   // Next, create the clone prototype and insert it into the module.
-  Clone = new Function(CFTy, GlobalValue::InternalLinkage,
-                       F->getName()+".pc");
+  Clone = Function::Create (CFTy, GlobalValue::InternalLinkage,
+                            F->getName()+".pc");
   F->getParent()->getFunctionList().insert(F, Clone);
 
   // Remember where this clone came from.

Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=49340&r1=49339&r2=49340&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Mon Apr  7 10:09:40 2008
@@ -46,6 +46,7 @@
 
 char PoolAllocate::ID = 0;
 char PoolAllocatePassAllPools::ID = 0;
+char PoolAllocateGroup::ID = 0;
 
 const Type *PoolAllocate::PoolDescPtrTy = 0;
 
@@ -59,9 +60,13 @@
 namespace {
   RegisterPass<PoolAllocate>
   X("poolalloc", "Pool allocate disjoint data structures");
+
   RegisterPass<PoolAllocatePassAllPools>
   Y("poolalloc-passing-all-pools", "Pool allocate disjoint data structures");
 
+  RegisterAnalysisGroup<PoolAllocateGroup> PAGroup ("Pool Allocation Group");
+  RegisterAnalysisGroup<PoolAllocateGroup> PAGroup1(X);
+
   STATISTIC (NumArgsAdded, "Number of function arguments added");
   STATISTIC (MaxArgsAdded, "Maximum function arguments added to one function");
   STATISTIC (NumCloned   , "Number of functions cloned");
@@ -393,7 +398,7 @@
   FunctionType *FuncTy = FunctionType::get(OldFuncTy->getReturnType(), ArgTys,
                                            OldFuncTy->isVarArg());
   // Create the new function...
-  Function *New = new Function(FuncTy, Function::InternalLinkage, F.getName());
+  Function *New = Function::Create(FuncTy, Function::InternalLinkage, F.getName());
   F.getParent()->getFunctionList().insert(&F, New);
   CloneToOrigMap[New] = &F;   // Remember original function.
 
@@ -573,7 +578,7 @@
   Value *ElSize = ConstantInt::get(Type::Int32Ty, RecSize);
   Value *AlignV = ConstantInt::get(Type::Int32Ty, Align);
   Value* Opts[3] = {GV, ElSize, AlignV};
-  new CallInst(PoolInit, Opts, Opts + 3, "", InsertPt);
+  CallInst::Create(PoolInit, Opts, Opts + 3, "", InsertPt);
   ++NumPools;
   return GV;
 }
@@ -914,7 +919,7 @@
 
   for (unsigned i = 0, e = PoolInitPoints.size(); i != e; ++i) {
     Value* Opts[3] = {PD, ElSize, Align};
-    new CallInst(PoolInit, Opts, Opts + 3,  "", PoolInitPoints[i]);
+    CallInst::Create(PoolInit, Opts, Opts + 3,  "", PoolInitPoints[i]);
     DEBUG(std::cerr << PoolInitPoints[i]->getParent()->getName() << " ");
   }
 
@@ -923,7 +928,7 @@
   // Loop over all of the places to insert pooldestroy's...
   for (unsigned i = 0, e = PoolDestroyPoints.size(); i != e; ++i) {
     // Insert the pooldestroy call for this pool.
-    new CallInst(PoolDestroy, PD, "", PoolDestroyPoints[i]);
+    CallInst::Create(PoolDestroy, PD, "", PoolDestroyPoints[i]);
     DEBUG(std::cerr << PoolDestroyPoints[i]->getParent()->getName()<<" ");
   }
   DEBUG(std::cerr << "\n\n");

Modified: poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp?rev=49340&r1=49339&r2=49340&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp Mon Apr  7 10:09:40 2008
@@ -117,7 +117,7 @@
     // poolrealloc(PD, null, X) -> poolalloc(PD, X)
     if (isa<ConstantPointerNull>(CI->getOperand(2))) {
       Value* Opts[2] = {CI->getOperand(1), CI->getOperand(3)};
-      Value *New = new CallInst(PoolAlloc, Opts, Opts + 2,
+      Value *New = CallInst::Create(PoolAlloc, Opts, Opts + 2,
                                 CI->getName(), CI);
       CI->replaceAllUsesWith(New);
       CI->eraseFromParent();
@@ -125,13 +125,13 @@
                cast<Constant>(CI->getOperand(3))->isNullValue()) {
       // poolrealloc(PD, X, 0) -> poolfree(PD, X)
       Value* Opts[2] = {CI->getOperand(1), CI->getOperand(2)};
-      new CallInst(PoolFree, Opts, Opts + 2, "", CI);
+      CallInst::Create(PoolFree, Opts, Opts + 2, "", CI);
       CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
       CI->eraseFromParent();
     } else if (isa<ConstantPointerNull>(CI->getOperand(1))) {
       // poolrealloc(null, X, Y) -> realloc(X, Y)
       Value* Opts[2] = {CI->getOperand(2), CI->getOperand(3)};
-      Value *New = new CallInst(Realloc, Opts, Opts + 2,
+      Value *New = CallInst::Create(Realloc, Opts, Opts + 2,
                                 CI->getName(), CI);
       CI->replaceAllUsesWith(New);
       CI->eraseFromParent();
@@ -159,7 +159,7 @@
     // poolmemalign(null, X, Y) -> memalign(X, Y)
     if (isa<ConstantPointerNull>(CI->getOperand(1))) {
       Value* Opts[2] = {CI->getOperand(2), CI->getOperand(3)};
-      Value *New = new CallInst(MemAlign, Opts, Opts + 2, CI->getName(), CI);
+      Value *New = CallInst::Create(MemAlign, Opts, Opts + 2, CI->getName(), CI);
       CI->replaceAllUsesWith(New);
       CI->eraseFromParent();
     }
@@ -230,18 +230,18 @@
           std::vector<Value*> Args;
           if (CI->getCalledFunction() == PoolAlloc) {
             Args.assign(CI->op_begin()+1, CI->op_end());
-            Value *New = new CallInst(PoolAllocBP, Args.begin(), Args.end(), CI->getName(), CI);
+            Value *New = CallInst::Create(PoolAllocBP, Args.begin(), Args.end(), CI->getName(), CI);
             CI->replaceAllUsesWith(New);
             CI->eraseFromParent();
           } else if (CI->getCalledFunction() == PoolInit) {
             Args.assign(CI->op_begin()+1, CI->op_end());
             Args.erase(Args.begin()+1); // Drop the size argument.
-            new CallInst(PoolInitBP, Args.begin(), Args.end(), "", CI);
+            CallInst::Create(PoolInitBP, Args.begin(), Args.end(), "", CI);
             CI->eraseFromParent();
           } else {
             assert(CI->getCalledFunction() == PoolDestroy);
             Args.assign(CI->op_begin()+1, CI->op_end());
-            new CallInst(PoolDestroyBP, Args.begin(), Args.end(), "", CI);
+            CallInst::Create(PoolDestroyBP, Args.begin(), Args.end(), "", CI);
             CI->eraseFromParent();
           }
         }

Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=49340&r1=49339&r2=49340&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Mon Apr  7 10:09:40 2008
@@ -157,7 +157,7 @@
   Value *PH = getPoolHandle(I);
   
   Value* Opts[2] = {PH, Size};
-  Instruction *V = new CallInst(PAInfo.PoolAlloc, Opts, Opts + 2, Name, I);
+  Instruction *V = CallInst::Create(PAInfo.PoolAlloc, Opts, Opts + 2, Name, I);
 
   AddPoolUse(*V, PH, PoolUses);
 
@@ -181,7 +181,7 @@
 
   // If this was an invoke, fix up the CFG.
   if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
-    new BranchInst(II->getNormalDest(), I);
+    BranchInst::Create (II->getNormalDest(), I);
     II->getUnwindDest()->removePredecessor(II->getParent(), true);
   }
 
@@ -234,7 +234,7 @@
       Casted = CastInst::createPointerCast(AI, PointerType::getUnqual(Type::Int8Ty),
 			      AI->getName()+".casted",aiNext);
     
-    Instruction *V = new CallInst(PAInfo.PoolRegister,
+    Instruction *V = CallInst::Create(PAInfo.PoolRegister,
 				  make_vector(PH, AllocSize, Casted, 0), "", aiNext);
     AddPoolUse(*V, PH, PoolUses);
   }
@@ -270,7 +270,7 @@
     args.push_back (PH);
     args.push_back (Casted);
     args.push_back (AllocSize);
-    Instruction *V = new CallInst(PAInfo.PoolRegister,
+    Instruction *V = CallInst::Create(PAInfo.PoolRegister,
 				  args.begin(), args.end(), "", InsertPt);
     AddPoolUse(*V, PH, PoolUses);
   }
@@ -291,7 +291,7 @@
   }
 
   Value* Opts[2] = {PH, Casted};
-  CallInst *FreeI = new CallInst(PAInfo.PoolFree, Opts, Opts + 2, "", Where);
+  CallInst *FreeI = CallInst::Create(PAInfo.PoolFree, Opts, Opts + 2, "", Where);
   AddPoolUse(*FreeI, PH, PoolFrees);
   return FreeI;
 }
@@ -352,7 +352,7 @@
   // We know that the memory returned by poolalloc is at least 4 byte aligned.
   Value* Opts[4] = {Ptr, ConstantInt::get(Type::Int8Ty, 0),
                     V2,  ConstantInt::get(Type::Int32Ty, 4)};
-  new CallInst(MemSet, Opts, Opts + 4, "", BBI);
+  CallInst::Create(MemSet, Opts, Opts + 4, "", BBI);
 }
 
 
@@ -372,7 +372,7 @@
 
   std::string Name = I->getName(); I->setName("");
   Value* Opts[3] = {PH, OldPtr, Size};
-  Instruction *V = new CallInst(PAInfo.PoolRealloc, Opts, Opts + 3, Name, I);
+  Instruction *V = CallInst::Create(PAInfo.PoolRealloc, Opts, Opts + 3, Name, I);
   Instruction *Casted = V;
   if (V->getType() != I->getType())
     Casted = CastInst::createPointerCast(V, I->getType(), V->getName(), I);
@@ -392,7 +392,7 @@
 
   // If this was an invoke, fix up the CFG.
   if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
-    new BranchInst(II->getNormalDest(), I);
+    BranchInst::Create (II->getNormalDest(), I);
     II->getUnwindDest()->removePredecessor(II->getParent(), true);
   }
 
@@ -440,7 +440,7 @@
 
   std::string Name = I->getName(); I->setName("");
   Value* Opts[3] = {PH, Align, Size};
-  Instruction *V = new CallInst(PAInfo.PoolMemAlign, Opts, Opts + 3, Name, I);
+  Instruction *V = CallInst::Create(PAInfo.PoolMemAlign, Opts, Opts + 3, Name, I);
 
   Instruction *Casted = V;
   if (V->getType() != I->getType())
@@ -463,7 +463,7 @@
 
   // If this was an invoke, fix up the CFG.
   if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
-    new BranchInst(II->getNormalDest(), I);
+    BranchInst::Create (II->getNormalDest(), I);
     II->getUnwindDest()->removePredecessor(II->getParent(), true);
   }
 
@@ -495,7 +495,7 @@
 
   std::string Name = I->getName(); I->setName("");
   Value* Opts[3] = {PH, OldPtr, 0};
-  Instruction *V = new CallInst(PAInfo.PoolStrdup, Opts, Opts + 2, Name, I);
+  Instruction *V = CallInst::Create(PAInfo.PoolStrdup, Opts, Opts + 2, Name, I);
   Instruction *Casted = V;
   if (V->getType() != I->getType())
     Casted = CastInst::createPointerCast(V, I->getType(), V->getName(), I);
@@ -515,7 +515,7 @@
 
   // If this was an invoke, fix up the CFG.
   if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
-    new BranchInst(II->getNormalDest(), I);
+    BranchInst::Create (II->getNormalDest(), I);
     II->getUnwindDest()->removePredecessor(II->getParent(), true);
   }
 
@@ -733,9 +733,9 @@
         Value *ElSize = ConstantInt::get(Type::Int32Ty,0);
         Value *Align  = ConstantInt::get(Type::Int32Ty,0);
         Value* Opts[3] = {ArgVal, ElSize, Align};
-        new CallInst(PAInfo.PoolInit, Opts, Opts + 3,"", TheCall);
+        CallInst::Create(PAInfo.PoolInit, Opts, Opts + 3,"", TheCall);
         BasicBlock::iterator BBI = TheCall;
-        new CallInst(PAInfo.PoolDestroy, ArgVal, "", ++BBI);
+        CallInst::Create(PAInfo.PoolDestroy, ArgVal, "", ++BBI);
       }
 
       //probably need to update DSG
@@ -753,10 +753,12 @@
   std::string Name = TheCall->getName(); TheCall->setName("");
 
   if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
-    NewCall = new InvokeInst(NewCallee, II->getNormalDest(),
-                             II->getUnwindDest(), Args.begin(), Args.end(), Name, TheCall);
+    NewCall = InvokeInst::Create (NewCallee, II->getNormalDest(),
+                                  II->getUnwindDest(),
+                                  Args.begin(), Args.end(), Name, TheCall);
   } else {
-    NewCall = new CallInst(NewCallee, Args.begin(), Args.end(), Name, TheCall);
+    NewCall = CallInst::Create (NewCallee, Args.begin(), Args.end(), Name,
+                                TheCall);
   }
 
   // Add all of the uses of the pool descriptor





More information about the llvm-commits mailing list