[llvm-commits] [poolalloc] r137557 - in /poolalloc/trunk: include/dsa/DataStructure.h include/poolalloc/Heuristic.h include/poolalloc/PoolAllocate.h include/poolalloc/RunTimeAssociate.h lib/Makefile lib/PoolAllocate/AccessTrace.cpp lib/PoolAllocate/Heuristic.cpp lib/PoolAllocate/PAMultipleGlobalPool.cpp lib/PoolAllocate/PASimple.cpp lib/PoolAllocate/PointerCompress.cpp lib/PoolAllocate/PoolAllocate.cpp lib/PoolAllocate/PoolOptimize.cpp lib/PoolAllocate/RunTimeAssociate.cpp lib/PoolAllocate/TransformFunctionBody.cpp

Will Dietz wdietz2 at illinois.edu
Sat Aug 13 10:22:11 PDT 2011


Author: wdietz2
Date: Sat Aug 13 12:22:11 2011
New Revision: 137557

URL: http://llvm.org/viewvc/llvm-project?rev=137557&view=rev
Log:
Update PA to build on mainline, compile it by default.

Doesn't work yet.

Modified:
    poolalloc/trunk/include/dsa/DataStructure.h
    poolalloc/trunk/include/poolalloc/Heuristic.h
    poolalloc/trunk/include/poolalloc/PoolAllocate.h
    poolalloc/trunk/include/poolalloc/RunTimeAssociate.h
    poolalloc/trunk/lib/Makefile
    poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp
    poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp
    poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.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/RunTimeAssociate.cpp
    poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp

Modified: poolalloc/trunk/include/dsa/DataStructure.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Sat Aug 13 12:22:11 2011
@@ -401,52 +401,6 @@
   ~EQTDDataStructures();
 };
 
-/// SteensgaardsDataStructures - Analysis that computes a context-insensitive
-/// data structure graphs for the whole program.
-///
-class SteensgaardDataStructures : public DataStructures {
-  DSGraph * ResultGraph;
-  DataStructures * DS;
-  void ResolveFunctionCall(const Function *F, const DSCallSite &Call,
-                             DSNodeHandle &RetVal);
-  bool runOnModuleInternal(Module &M);
-
-public:
-  static char ID;
-  SteensgaardDataStructures() : 
-    DataStructures(ID, "steensgaard."),
-    ResultGraph(NULL) {}
-  ~SteensgaardDataStructures();
-  virtual bool runOnModule(Module &M);
-  virtual void releaseMemory();
-
-  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-    AU.addRequired<TargetData>();
-    AU.addRequired<StdLibDataStructures>();
-    AU.setPreservesAll();
-  }
-  
-  /// getDSGraph - Return the data structure graph for the specified function.
-  ///
-  virtual DSGraph *getDSGraph(const Function &F) const {
-    return getResultGraph();
-  }
-  
-  virtual bool hasDSGraph(const Function &F) const {
-    return true;
-  }
-
-  /// getDSGraph - Return the data structure graph for the whole program.
-  ///
-  DSGraph *getResultGraph() const {
-    return ResultGraph;
-  }
-
-  void print(llvm::raw_ostream &O, const Module *M) const;
-
-};
-
-
 } // End llvm namespace
 
 #endif

Modified: poolalloc/trunk/include/poolalloc/Heuristic.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/Heuristic.h?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/include/poolalloc/Heuristic.h (original)
+++ poolalloc/trunk/include/poolalloc/Heuristic.h Sat Aug 13 12:22:11 2011
@@ -127,7 +127,7 @@
     /// this DSNode.
     ///
     static unsigned getRecommendedAlignment(const DSNode *N);
-    static unsigned getRecommendedAlignment(const Type *Ty,
+    static unsigned getRecommendedAlignment(Type *Ty,
                                             const TargetData &TD);
   };
 
@@ -154,13 +154,13 @@
       static char ID;
 
       // Method used to implement analysis groups without C++ inheritance
-      virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
-        if (PI->isPassID(&Heuristic::ID))
+      virtual void *getAdjustedAnalysisPointer(AnalysisID ID) {
+        if (ID == &Heuristic::ID)
           return (Heuristic*)this;
         return this;
       }
 
-      AllNodesHeuristic (intptr_t IDp = (intptr_t) (&ID)): ModulePass (IDp) { }
+      AllNodesHeuristic (char * IDp = &ID): ModulePass (*IDp) { }
       virtual ~AllNodesHeuristic () {return;}
       virtual bool runOnModule (Module & M);
       virtual const char * getPassName () const {
@@ -205,14 +205,13 @@
                                                public ModulePass {
     public:
       static char ID;
-      virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
-        if (PI->isPassID(&Heuristic::ID))
+      virtual void *getAdjustedAnalysisPointer(AnalysisID ID) {
+        if (ID == &Heuristic::ID)
           return (Heuristic*)this;
         return this;
       }
 
-      AllButUnreachableFromMemoryHeuristic (intptr_t IDp = (intptr_t) (&ID)) :
-        ModulePass (IDp) { }
+      AllButUnreachableFromMemoryHeuristic (char * IDp = &ID) : ModulePass (*IDp) { }
       virtual ~AllButUnreachableFromMemoryHeuristic () {return;}
       virtual bool runOnModule (Module & M);
 
@@ -240,14 +239,14 @@
   class CyclicNodesHeuristic : public Heuristic, public ModulePass {
     public:
       static char ID;
-      virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
-        if (PI->isPassID(&Heuristic::ID))
+      virtual void *getAdjustedAnalysisPointer(AnalysisID ID) {
+        if (ID == &Heuristic::ID)
           return (Heuristic*)this;
         return this;
       }
 
 
-      CyclicNodesHeuristic (intptr_t IDp=(intptr_t) (&ID)): ModulePass (IDp) { }
+      CyclicNodesHeuristic (char * IDp=&ID): ModulePass (*IDp) { }
       virtual ~CyclicNodesHeuristic () {return;}
       virtual bool runOnModule (Module & M);
 
@@ -276,14 +275,13 @@
   class SmartCoallesceNodesHeuristic : public Heuristic, public ModulePass {
     public:
       static char ID;
-      virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
-        if (PI->isPassID(&Heuristic::ID))
+      virtual void *getAdjustedAnalysisPointer(AnalysisID ID) {
+        if (ID == &Heuristic::ID)
           return (Heuristic*)this;
         return this;
       }
 
-      SmartCoallesceNodesHeuristic (intptr_t IDp = (intptr_t) (&ID)) :
-        ModulePass (IDp) { }
+      SmartCoallesceNodesHeuristic (char * IDp = &ID) : ModulePass (*IDp) { }
       virtual ~SmartCoallesceNodesHeuristic () {return;}
       virtual bool runOnModule (Module & M);
 
@@ -319,14 +317,14 @@
 
     public:
       static char ID;
-      virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
-        if (PI->isPassID(&Heuristic::ID))
+      virtual void *getAdjustedAnalysisPointer(AnalysisID ID) {
+        if (ID == &Heuristic::ID)
           return (Heuristic*)this;
         return this;
       }
 
-      AllInOneGlobalPoolHeuristic(intptr_t IDp = (intptr_t) (&ID)) :
-        ModulePass (IDp), TheGlobalPD(0) {}
+      AllInOneGlobalPoolHeuristic(char * IDp = &ID) :
+        ModulePass (*IDp), TheGlobalPD(0) {}
 
       virtual bool runOnModule (Module & M);
       virtual void getAnalysisUsage(AnalysisUsage &AU) const {
@@ -356,14 +354,13 @@
   class OnlyOverheadHeuristic : public Heuristic, public ModulePass {
     public:
       static char ID;
-      virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
-        if (PI->isPassID(&Heuristic::ID))
+      virtual void *getAdjustedAnalysisPointer(AnalysisID ID) {
+        if (ID == &Heuristic::ID)
           return (Heuristic*)this;
         return this;
       }
 
-      OnlyOverheadHeuristic(intptr_t IDp = (intptr_t) (&ID)) :
-        ModulePass (IDp) {}
+      OnlyOverheadHeuristic(char * IDp = &ID) : ModulePass (*IDp) {}
 
       virtual bool runOnModule (Module & M);
       virtual void getAnalysisUsage(AnalysisUsage &AU) const {
@@ -392,13 +389,13 @@
   class NoNodesHeuristic : public Heuristic, public ImmutablePass {
     public:
       static char ID;
-      virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
-        if (PI->isPassID(&Heuristic::ID))
+      virtual void *getAdjustedAnalysisPointer(AnalysisID ID) {
+        if (ID == &Heuristic::ID)
           return (Heuristic*)this;
         return this;
       }
 
-      NoNodesHeuristic(intptr_t IDp = (intptr_t) (&ID)) : ImmutablePass (IDp) {}
+      NoNodesHeuristic(char * IDp = &ID) : ImmutablePass (*IDp) {}
 
       virtual bool runOnModule (Module & M);
       virtual void getAnalysisUsage(AnalysisUsage &AU) const {

Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original)
+++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Sat Aug 13 12:22:11 2011
@@ -140,9 +140,9 @@
 class PoolAllocateGroup : public ModulePass {
 protected:
   DataStructures *Graphs;
-  const Type * VoidType;
-  const Type * Int8Type;
-  const Type * Int32Type;
+  Type * VoidType;
+  Type * Int8Type;
+  Type * Int32Type;
 
 public:
   static char ID;
@@ -160,7 +160,7 @@
   PASS_TYPE dsa_pass_to_use;
 
                 
-  PoolAllocateGroup  (intptr_t IDp = (intptr_t) (&ID)) : ModulePass (IDp) { }
+  PoolAllocateGroup  (char * IDp = &ID) : ModulePass (*IDp) { }
   virtual ~PoolAllocateGroup () {return;}
 
   virtual PA::FuncInfo *getFuncInfo(const Function &F) { return 0;}
@@ -168,7 +168,7 @@
   virtual Function *getOrigFunctionFromClone(const Function *F) const {return 0;}
 
   // FIXME: Clients should be able to specialize pool descriptor type
-  virtual const Type * getPoolType(LLVMContext*) {return 0;}
+  virtual Type * getPoolType(LLVMContext*) {return 0;}
 
   virtual bool hasDSGraph (const Function & F) const {
     return Graphs->hasDSGraph (F);
@@ -221,7 +221,7 @@
   // Function which will initialize global pools
   Function * GlobalPoolCtor;
   
-  static const Type *PoolDescPtrTy;
+  static Type *PoolDescPtrTy;
 
   PA::Heuristic *CurHeuristic;
 
@@ -238,8 +238,8 @@
 
   PoolAllocate (bool passAllArguments,
                 bool SAFECode = true,
-                intptr_t IDp = (intptr_t) (&ID))
-    : PoolAllocateGroup ((intptr_t)IDp),
+                char * IDp = &ID)
+    : PoolAllocateGroup (IDp),
       PassAllArguments(passAllArguments)
       {
 		  SAFECodeEnabled = SAFECode |  PA::PA_SAFECODE;
@@ -253,8 +253,8 @@
 				LIE_TYPE lie_preserve_passes_ = LIE_PRESERVE_DEFAULT,
 				bool passAllArguments = false,
 				bool SAFECode = true,
-                intptr_t IDp = (intptr_t) (&ID))
-      : PoolAllocateGroup ((intptr_t)IDp),
+                char * IDp = &ID)
+      : PoolAllocateGroup (IDp),
         PassAllArguments(passAllArguments)
         {
   		  SAFECodeEnabled = SAFECode |  PA::PA_SAFECODE;
@@ -327,8 +327,8 @@
 
   /// getPoolType - Return the type of a pool descriptor
   /// FIXME: These constants should be chosen by the client
-  const Type * getPoolType(LLVMContext* C) {
-    const IntegerType * IT = IntegerType::getInt8Ty(*C);
+  Type * getPoolType(LLVMContext* C) {
+    IntegerType * IT = IntegerType::getInt8Ty(*C);
     Type * VoidPtrType = PointerType::getUnqual(IT);
     if (SAFECodeEnabled)
       return ArrayType::get(VoidPtrType, 92);
@@ -511,7 +511,7 @@
 /// load or store to that pool is performed.
 struct PoolAllocatePassAllPools : public PoolAllocate {
   static char ID;
-  PoolAllocatePassAllPools() : PoolAllocate(PASS_DEFAULT, LIE_PRESERVE_DEFAULT, true, false, (intptr_t) &ID) {}
+  PoolAllocatePassAllPools() : PoolAllocate(PASS_DEFAULT, LIE_PRESERVE_DEFAULT, true, false, &ID) {}
 };
 
 /// PoolAllocateSimple - This class modifies the heap allocations so that they
@@ -527,7 +527,7 @@
 public:
   static char ID;
   PoolAllocateSimple(bool passAllArgs=false, bool SAFECode = true, bool CompleteDSA = true)
-    : PoolAllocate (PASS_DEFAULT, LIE_PRESERVE_DEFAULT, passAllArgs, SAFECode, (intptr_t)&ID), CompleteDSA(CompleteDSA) {}
+    : PoolAllocate (PASS_DEFAULT, LIE_PRESERVE_DEFAULT, passAllArgs, SAFECode, &ID), CompleteDSA(CompleteDSA) {}
   ~PoolAllocateSimple() {return;}
   void getAnalysisUsage(AnalysisUsage &AU) const;
   bool runOnModule(Module &M);
@@ -577,7 +577,7 @@
 public:
   static char ID;
   PoolAllocateMultipleGlobalPool(bool passAllArgs=false, bool SAFECode = true)
-    : PoolAllocate (PASS_DEFAULT, LIE_PRESERVE_DEFAULT, passAllArgs, SAFECode, (intptr_t)&ID) {}
+    : PoolAllocate (PASS_DEFAULT, LIE_PRESERVE_DEFAULT, passAllArgs, SAFECode, &ID) {}
   ~PoolAllocateMultipleGlobalPool();
   virtual void getAnalysisUsage(AnalysisUsage &AU) const;
   virtual bool runOnModule(Module &M);

Modified: poolalloc/trunk/include/poolalloc/RunTimeAssociate.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/RunTimeAssociate.h?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/include/poolalloc/RunTimeAssociate.h (original)
+++ poolalloc/trunk/include/poolalloc/RunTimeAssociate.h Sat Aug 13 12:22:11 2011
@@ -138,7 +138,7 @@
 class RTAssociate : public ModulePass {
 
   // Type used to represent the pool, will be opaque in this pass
-  const Type *PoolDescPtrTy, *PoolDescType;
+  Type *PoolDescPtrTy, *PoolDescType;
 
   /// Special Values - Values created by this pass which should be ignored
   std::set<const Value*> SpecialValues;

Modified: poolalloc/trunk/lib/Makefile
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/Makefile?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/lib/Makefile (original)
+++ poolalloc/trunk/lib/Makefile Sat Aug 13 12:22:11 2011
@@ -7,6 +7,6 @@
 # List all of the subdirectories that we will compile.
 #
 #DIRS=DSA PoolAllocate AssistDS
-DIRS=DSA
+DIRS=DSA PoolAllocate
 
 include $(LEVEL)/Makefile.common

Modified: poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp Sat Aug 13 12:22:11 2011
@@ -29,10 +29,10 @@
     PoolAllocate *PoolAlloc;
     DataStructures *G;
     Constant *AccessTraceInitFn, *PoolAccessTraceFn;
-    const PointerType *VoidPtrTy;
+    PointerType *VoidPtrTy;
   public:
 
-    PoolAccessTrace() : ModulePass((intptr_t)&ID) {}
+    PoolAccessTrace() : ModulePass(ID) {}
 
     bool runOnModule(Module &M);
 
@@ -63,8 +63,8 @@
 }
 
 void PoolAccessTrace::InitializeLibraryFunctions(Module &M) {
-  const IntegerType * IT = IntegerType::getInt8Ty(M.getContext());
-  const Type * VoidType = Type::getVoidTy(M.getContext());
+  IntegerType * IT = IntegerType::getInt8Ty(M.getContext());
+  Type * VoidType = Type::getVoidTy(M.getContext());
   VoidPtrTy = PointerType::getUnqual(IT);
 
   AccessTraceInitFn = M.getOrInsertFunction("poolaccesstraceinit",
@@ -97,7 +97,7 @@
 
   // Insert the trace call.
   Value *Opts[2] = {Ptr, PD};
-  CallInst::Create (PoolAccessTraceFn, Opts, Opts + 2, "", I);
+  CallInst::Create (PoolAccessTraceFn, ArrayRef<Value*>(Opts), "", I);
 }
 
 bool PoolAccessTrace::runOnModule(Module &M) {

Modified: poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp Sat Aug 13 12:22:11 2011
@@ -97,7 +97,7 @@
 //  FIXME: This code needs to handle LLVM first-class structures and vectors.
 //
 static bool
-Wants8ByteAlignment(const Type *Ty, unsigned Offs, const TargetData &TD) {
+Wants8ByteAlignment(Type *Ty, unsigned Offs, const TargetData &TD) {
   //
   // If the user has requested this optimization to be turned off, don't bother
   // doing it.
@@ -136,14 +136,14 @@
   // 8-byte alignment desire to have 8-byte alignment.  If so, then the entire
   // object wants 8-byte alignment.
   //
-  if (const StructType *STy = dyn_cast<StructType>(Ty)) {
+  if (StructType *STy = dyn_cast<StructType>(Ty)) {
     const StructLayout *SL = TD.getStructLayout(STy);
     for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
       if (Wants8ByteAlignment(STy->getElementType(i),
                               Offs+SL->getElementOffset(i), TD))
         return true;
     }
-  } else if (const SequentialType *STy = dyn_cast<SequentialType>(Ty)) {
+  } else if (SequentialType *STy = dyn_cast<SequentialType>(Ty)) {
     return Wants8ByteAlignment(STy->getElementType(), Offs, TD);
   } else {
     errs() << *Ty << "\n";
@@ -153,7 +153,7 @@
   return false;
 }
 
-unsigned Heuristic::getRecommendedAlignment(const Type *Ty,
+unsigned Heuristic::getRecommendedAlignment(Type *Ty,
                                             const TargetData &TD) {
   if (!Ty || Ty->isVoidTy())  // Is this void or collapsed?
     return 0;  // No known alignment, let runtime decide.
@@ -185,13 +185,13 @@
   //
   DSNode::const_type_iterator tyi;
   for (tyi = Node->type_begin(); tyi != Node->type_end(); ++tyi) {
-    for (svset<const Type*>::const_iterator tyii = tyi->second->begin(),
+    for (svset<Type*>::const_iterator tyii = tyi->second->begin(),
          tyee = tyi->second->end(); tyii != tyee; ++tyii) {
       //
       // Get the type of object allocated.  If there is no type, then it is
       // implicitly of void type.
       //
-      const Type * TypeCreated = *tyii;
+      Type * TypeCreated = *tyii;
       if (TypeCreated) {
         //
         // If the type contains a pointer, it must be changed.
@@ -845,7 +845,7 @@
   static Value *NullGlobal = 0;
   if (!NullGlobal) {
     Module *M = I->getParent()->getParent()->getParent();
-    const Type * PoolTy = PoolAllocate::PoolDescPtrTy;
+    Type * PoolTy = PoolAllocate::PoolDescPtrTy;
     Constant * Init = ConstantPointerNull::get(cast<PointerType>(PoolTy));
     NullGlobal = new GlobalVariable(*M,
                                     PoolAllocate::PoolDescPtrTy, false,
@@ -873,7 +873,7 @@
     Value *OldPD = PDI->second;
     std::vector<User*> OldPDUsers(OldPD->use_begin(), OldPD->use_end());
     for (unsigned i = 0, e = OldPDUsers.size(); i != e; ++i) {
-      CallSite PDUser = CallSite::get(cast<Instruction>(OldPDUsers[i]));
+      CallSite PDUser(cast<Instruction>(OldPDUsers[i]));
       if (PDUser.getCalledValue() != PoolInit &&
           PDUser.getCalledValue() != PoolDestroy) {
         assert(PDUser.getInstruction()->getParent()->getParent() == &F &&

Modified: poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp Sat Aug 13 12:22:11 2011
@@ -52,7 +52,7 @@
 }
 
 static inline Value *
-castTo (Value * V, const Type * Ty, const std::string & Name, Instruction * InsertPt) {
+castTo (Value * V, Type * Ty, const std::string & Name, Instruction * InsertPt) {
   //
   // Don't bother creating a cast if it's already the correct type.
   //
@@ -75,7 +75,8 @@
 
 void PoolAllocateMultipleGlobalPool::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addRequired<TargetData>();
-  AU.addRequiredTransitive<SteensgaardDataStructures>();
+  assert(0 && "PoolAllocateMultipleGlobalPool doesn't work! Needs Steensgard-like analysis, which was removed!");
+  //AU.addRequiredTransitive<SteensgaardDataStructures>();
   // It is a big lie.
   AU.setPreservesAll();
 }
@@ -91,7 +92,8 @@
   Int8Type  = IntegerType::getInt8Ty(getGlobalContext());
   Int32Type = IntegerType::getInt32Ty(getGlobalContext());
 
-  Graphs = &getAnalysis<SteensgaardDataStructures>();
+  //Graphs = &getAnalysis<SteensgaardDataStructures>();
+  Graphs = NULL;
   assert (Graphs && "No DSA pass available!\n");
 
   TargetData & TD = getAnalysis<TargetData>();
@@ -214,8 +216,7 @@
           std::string Name = CI->getName(); CI->setName("");
           Value* Opts[3] = {Pool, OldPtr, Size};
           Instruction *V = CallInst::Create (PoolRealloc,
-                                         Opts,
-                                         Opts + 3,
+                                         ArrayRef<Value*>(Opts),
                                          Name,
                                          InsertPt);
           Value *Casted = castTo(V, CI->getType(), V->getName(), InsertPt);
@@ -259,8 +260,7 @@
           std::string Name = CI->getName(); CI->setName("");
           Value* Opts[3] = {Pool, NumElements, Size};
           Instruction *V = CallInst::Create (PoolCalloc,
-                                             Opts,
-                                             Opts + 3,
+                                             ArrayRef<Value*>(Opts),
                                              Name,
                                              InsertPt);
 
@@ -297,8 +297,7 @@
           std::string Name = CI->getName(); CI->setName("");
           Value* Opts[2] = {Pool, OldPtr};
           Instruction *V = CallInst::Create (PoolStrdup,
-                                         Opts,
-                                         Opts + 2,
+                                         ArrayRef<Value*>(Opts),
                                          Name,
                                          InsertPt);
           Value *Casted = castTo(V, CI->getType(), V->getName(), InsertPt);
@@ -345,7 +344,7 @@
                                       Module& M) {
 
   Function *InitFunc = Function::Create
-    (FunctionType::get(VoidType, std::vector<const Type*>(), false),
+    (FunctionType::get(VoidType, std::vector<Type*>(), false),
     GlobalValue::ExternalLinkage, "__poolalloc_init", &M);
 
   // put it into llvm.used so that it won't get killed.
@@ -361,8 +360,8 @@
       NewInit, "llvm.used");
 
 
-  BasicBlock * BB = BasicBlock::Create(getGlobalContext(), "entry", InitFunc);
-  
+  assert(0 && "Not implemented!");
+#if 0
   SteensgaardDataStructures * DS = (SteensgaardDataStructures*)Graphs;
   
   assert (DS && "PoolAllocateMultipleGlobalPools requires Steensgaard Data Structure!");
@@ -391,6 +390,7 @@
   }
 
   ReturnInst::Create(getGlobalContext(), BB);
+#endif
 }
 
 void
@@ -411,7 +411,7 @@
     Value *AlignV = ConstantInt::get(Int32Type, Align);
     Value* Opts[3] = {GV, ElSize, AlignV};
     
-    CallInst::Create(PoolInit, Opts, Opts + 3, "", InsertAtEnd);
+    CallInst::Create(PoolInit, ArrayRef<Value*>(Opts), "", InsertAtEnd);
     PoolMap[Node] = GV;
   }
 }

Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Sat Aug 13 12:22:11 2011
@@ -49,7 +49,7 @@
 }
 
 static inline Value *
-castTo (Value * V, const Type * Ty, std::string Name, Instruction * InsertPt) {
+castTo (Value * V, Type * Ty, std::string Name, Instruction * InsertPt) {
   //
   // Don't bother creating a cast if it's already the correct type.
   //
@@ -292,8 +292,7 @@
           //
           Value* Opts[3] = {TheGlobalPool, Size};
           Instruction *V = CallInst::Create (PoolAlloc,
-                                             Opts,
-                                             Opts + 2,
+                                             ArrayRef<Value*>(Opts),
                                              Name,
                                              InsertPt);
 
@@ -344,8 +343,7 @@
           //
           Value* Opts[3] = {TheGlobalPool, Align, Size};
           Instruction *V = CallInst::Create (PoolMemAlign,
-                                             Opts,
-                                             Opts + 3,
+                                             ArrayRef<Value*>(Opts),
                                              Name,
                                              InsertPt);
 
@@ -391,8 +389,7 @@
           std::string Name = CI->getName(); CI->setName("");
           Value* Opts[3] = {TheGlobalPool, OldPtr, Size};
           Instruction *V = CallInst::Create (PoolRealloc,
-                                         Opts,
-                                         Opts + 3,
+                                         ArrayRef<Value*>(Opts),
                                          Name,
                                          InsertPt);
           //
@@ -437,8 +434,7 @@
           std::string Name = CI->getName(); CI->setName("");
           Value* Opts[3] = {TheGlobalPool, NumElements, Size};
           Instruction *V = CallInst::Create (PoolCalloc,
-                                             Opts,
-                                             Opts + 3,
+                                             ArrayRef<Value*>(Opts),
                                              Name,
                                              InsertPt);
 
@@ -476,8 +472,7 @@
           std::string Name = CI->getName(); CI->setName("");
           Value* Opts[2] = {TheGlobalPool, OldPtr};
           Instruction *V = CallInst::Create (PoolStrdup,
-                                         Opts,
-                                         Opts + 2,
+                                         ArrayRef<Value*>(Opts),
                                          Name,
                                          InsertPt);
 
@@ -497,7 +492,7 @@
           Value * FreedNode = castTo (CI->getOperand(1), VoidPtrTy, "cast", ii);
           toDelete.push_back(ii);
           Value* args[] = {TheGlobalPool, FreedNode};
-          CallInst::Create(PoolFree, &args[0], &args[2], "", ii);
+          CallInst::Create(PoolFree, ArrayRef<Value*>(args), "", ii);
         }
 
         //
@@ -559,14 +554,14 @@
 		       "__poolalloc_GlobalPool");
 
   Function *InitFunc = Function::Create
-    (FunctionType::get(VoidType, std::vector<const Type*>(), false),
+    (FunctionType::get(VoidType, std::vector<Type*>(), false),
     GlobalValue::ExternalLinkage, "__poolalloc_init", &M);
 
   BasicBlock * BB = BasicBlock::Create(M.getContext(), "entry", InitFunc);
   Value *ElSize = ConstantInt::get(Int32Type, RecSize);
   Value *AlignV = ConstantInt::get(Int32Type, Align);
   Value* Opts[3] = {GV, ElSize, AlignV};
-  CallInst::Create(PoolInit, Opts, Opts + 3, "", BB);
+  CallInst::Create(PoolInit, ArrayRef<Value*>(Opts), "", BB);
 
   ReturnInst::Create(M.getContext(), BB);
   return GV;

Modified: poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp Sat Aug 13 12:22:11 2011
@@ -35,17 +35,17 @@
 /// MEMUINTTYPE - This is the actual type we are compressing to.  This is really
 /// only capable of being Int32Ty, except when we are doing tests for 16-bit
 /// integers, when it's Int16Ty.
-static const Type *MEMUINTTYPE;
+static Type *MEMUINTTYPE;
 
 /// SCALARUINTTYPE - We keep scalars the same size as the machine word on the
 /// system (e.g. 64-bits), only keeping memory objects in MEMUINTTYPE.
-static const Type *SCALARUINTTYPE;
+static Type *SCALARUINTTYPE;
 
-static const Type * VoidType  = 0;
-static const Type * Int8Type  = 0;
-static const Type * Int16Type = 0;
-static const Type * Int32Type = 0;
-static const Type * Int64Type = 0;
+static Type * VoidType  = 0;
+static Type * Int8Type  = 0;
+static Type * Int16Type = 0;
+static Type * Int32Type = 0;
+static Type * Int64Type = 0;
 
 namespace {
   cl::opt<bool>
@@ -124,7 +124,7 @@
     typedef std::map<const DSNode*, CompressedPoolInfo> PoolInfoMap;
     static char ID;
 
-    PointerCompress() : ModulePass((intptr_t)&ID) {}
+    PointerCompress() : ModulePass(ID) {}
     /// NoArgFunctionsCalled - When we are walking the call graph, keep track of
     /// which functions are called that don't need their prototype to be
     /// changed.
@@ -184,7 +184,7 @@
   class CompressedPoolInfo {
     const DSNode *Pool;
     Value *PoolDesc;
-    const Type *NewTy;
+    Type *NewTy;
     unsigned NewSize;
     mutable Value *PoolBase;
   public:
@@ -197,7 +197,7 @@
                     const TargetData &TD);
 
     const DSNode *getNode() const { return Pool; }
-    const Type *getNewType() const { return NewTy; }
+    Type *getNewType() const { return NewTy; }
 
     /// getNewSize - Return the size of each node after compression.
     ///
@@ -216,7 +216,7 @@
     void dump() const;
 
   private:
-    const Type *ComputeCompressedType(const Type *OrigTy, unsigned NodeOffset,
+    Type *ComputeCompressedType(Type *OrigTy, unsigned NodeOffset,
                            std::map<const DSNode*, CompressedPoolInfo> &Nodes);
   };
 }
@@ -241,8 +241,8 @@
 /// ComputeCompressedType - Recursively compute the new type for this node after
 /// pointer compression.  This involves compressing any pointers that point into
 /// compressed pools.
-const Type *CompressedPoolInfo::
-ComputeCompressedType(const Type *OrigTy, unsigned NodeOffset,
+Type *CompressedPoolInfo::
+ComputeCompressedType(Type *OrigTy, unsigned NodeOffset,
                       std::map<const DSNode*, CompressedPoolInfo> &Nodes) {
   if (dyn_cast<PointerType>(OrigTy)) {
     if (ADLFix) {
@@ -266,8 +266,8 @@
   const TargetData &TD = getNode()->getParentGraph()->getTargetData();
 
   // Okay, we have an aggregate type.
-  if (const StructType *STy = dyn_cast<StructType>(OrigTy)) {
-    std::vector<const Type*> Elements;
+  if (StructType *STy = dyn_cast<StructType>(OrigTy)) {
+    std::vector<Type*> Elements;
     Elements.reserve(STy->getNumElements());
 
     const StructLayout *SL = TD.getStructLayout(STy);
@@ -277,7 +277,7 @@
                                                NodeOffset+SL->getElementOffset(i),
                                                Nodes));
     return StructType::get(STy->getContext(),Elements);
-  } else if (const ArrayType *ATy = dyn_cast<ArrayType>(OrigTy)) {
+  } else if (ArrayType *ATy = dyn_cast<ArrayType>(OrigTy)) {
     return ArrayType::get(ComputeCompressedType(ATy->getElementType(),
                                                 NodeOffset, Nodes),
                           ATy->getNumElements());
@@ -297,7 +297,7 @@
     // Get the pool base pointer.
     Constant *Zero = ConstantInt::get(Int32Type, 0);
     Value *Opts[2] = {Zero, Zero};
-    Value *BasePtrPtr = GetElementPtrInst::Create(getPoolDesc(), Opts, Opts + 2,
+    Value *BasePtrPtr = GetElementPtrInst::Create(getPoolDesc(), ArrayRef<Value*>(Opts),
                                               "poolbaseptrptr", &I);
     return new LoadInst(BasePtrPtr, "poolbaseptr", &I);
   } else {
@@ -309,7 +309,7 @@
       while (isa<AllocaInst>(IP)) ++IP;
       Constant *Zero = ConstantInt::get(Int32Type, 0);
       Value *Opts[2] = {Zero, Zero};
-      Value *BasePtrPtr = GetElementPtrInst::Create(getPoolDesc(), Opts, Opts + 2,
+      Value *BasePtrPtr = GetElementPtrInst::Create(getPoolDesc(), ArrayRef<Value*>(Opts),
                                                 "poolbaseptrptr", IP);
       PoolBase = new LoadInst(BasePtrPtr, "poolbaseptr", IP);
     }
@@ -614,8 +614,7 @@
   const CompressedPoolInfo *DestPI = getPoolInfo(&PN);
   if (DestPI == 0) return;
 
-  PHINode *New = PHINode::Create (SCALARUINTTYPE, PN.getName(), &PN);
-  New->reserveOperandSpace(PN.getNumIncomingValues());
+  PHINode *New = PHINode::Create (SCALARUINTTYPE, PN.getNumIncomingValues(), PN.getName(), &PN);
 
   for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
     New->addIncoming(getTransformedValue(PN.getIncomingValue(i)),
@@ -700,12 +699,12 @@
 
   // The compressed type for the pool.  FIXME: NOTE: This only works if 'Val'
   // pointed to the start of a node!
-  const Type *NTy = PointerType::getUnqual(PI->getNewType());
+  Type *NTy = PointerType::getUnqual(PI->getNewType());
 
   //Check if we have a pointer to an array of Original Types this happens if
   //you do a malloc of [n x OrigTy] for a pool of Type OrigTy
   if(isa<PointerType>(GEPI.getOperand(0)->getType())) {
-    const Type* PT =
+    Type* PT =
       cast<PointerType>(GEPI.getOperand(0)->getType())->getElementType();
     if(isa<ArrayType>(PT)) {
       //FIXME: TYPE
@@ -719,7 +718,7 @@
   gep_type_iterator GTI = gep_type_begin(GEPI), E = gep_type_end(GEPI);
   for (unsigned i = 1, e = GEPI.getNumOperands(); i != e; ++i, ++GTI) {
     Value *Idx = GEPI.getOperand(i);
-    if (const StructType *STy = dyn_cast<StructType>(*GTI)) {
+    if (StructType *STy = dyn_cast<StructType>(*GTI)) {
       uint64_t Field = (unsigned)cast<ConstantInt>(Idx)->getZExtValue();
       if (Field) {
         uint64_t FieldOffs = TD.getStructLayout(cast<StructType>(NTy))
@@ -736,10 +735,10 @@
         NTy = cast<StructType>(NTy)->getElementType(Field);
     } else {
       assert(isa<SequentialType>(*GTI) && "Not struct or sequential?");
-      const SequentialType *STy = cast<SequentialType>(*GTI);
+      SequentialType *SeqTy = cast<SequentialType>(*GTI);
       if (!isa<Constant>(Idx) || !cast<Constant>(Idx)->isNullValue()) {
         // Add Idx*sizeof(NewElementType) to the index.
-        const Type *ElTy = cast<SequentialType>(NTy)->getElementType();
+        Type *ElTy = cast<SequentialType>(NTy)->getElementType();
         if (Idx->getType() != SCALARUINTTYPE)
           Idx = CastInst::CreateSExtOrBitCast(Idx, SCALARUINTTYPE, Idx->getName(), &GEPI);
 
@@ -750,7 +749,7 @@
       }
 
       // If this is a one element array type, NTy may not reflect the array.
-      if (!isa<ArrayType>(STy) || cast<ArrayType>(STy)->getNumElements() != 1 ||
+      if (!isa<ArrayType>(SeqTy) || cast<ArrayType>(SeqTy)->getNumElements() != 1 ||
           (isa<ArrayType>(NTy) && cast<ArrayType>(NTy)->getNumElements() == 1))
         NTy = cast<SequentialType>(NTy)->getElementType();
     }
@@ -786,7 +785,7 @@
     Ops = CastInst::CreateZExtOrBitCast(Ops, Int32Type, "extend_idx", &LI);
   Value *SrcPtr = GetElementPtrInst::Create(BasePtr, Ops,
                                         LI.getOperand(0)->getName()+".pp", &LI);
-  const Type *DestTy = LoadingCompressedPtr ? MEMUINTTYPE : LI.getType();
+  Type *DestTy = LoadingCompressedPtr ? MEMUINTTYPE : LI.getType();
   SrcPtr = CastInst::CreatePointerCast(SrcPtr, PointerType::getUnqual(DestTy),
                                       SrcPtr->getName(), &LI);
   std::string OldName = LI.getName(); LI.setName("");
@@ -880,7 +879,7 @@
   Ops.push_back(ConstantInt::get(Int32Type,
              PA::Heuristic::getRecommendedAlignment(PI->getNewType(), TD)));
   // TODO: Compression could reduce the alignment restriction for the pool!
-  Value *PB = CallInst::Create(PtrComp.PoolInitPC, Ops.begin(), Ops.end(), "", &CI);
+  Value *PB = CallInst::Create(PtrComp.PoolInitPC, Ops, "", &CI);
 
   if (!DisablePoolBaseASR) { // Load the pool base immediately.
     PB->setName(CI.getOperand(1)->getName()+".poolbase");
@@ -924,7 +923,7 @@
     }
 
   Value *Opts[2] = {CI.getOperand(1), Size};
-  Value *NC = CallInst::Create(PtrComp.PoolAllocPC, Opts, Opts + 2, CI.getName(), &CI);
+  Value *NC = CallInst::Create(PtrComp.PoolAllocPC, ArrayRef<Value*>(Opts), CI.getName(), &CI);
   setTransformedValue(CI, NC);
 }
 
@@ -1050,7 +1049,7 @@
     }
 
     Function *Clone = PtrComp.GetExtFunctionClone(Callee, CompressedArgs);
-    Value *NC = CallInst::Create(Clone, Operands.begin(), Operands.end(), CI.getName(), &CI);
+    Value *NC = CallInst::Create(Clone, Operands, CI.getName(), &CI);
     if (NC->getType() != CI.getType())      // Compressing return value?
       setTransformedValue(CI, NC);
     else {
@@ -1127,7 +1126,7 @@
     else
       Operands.push_back(CI.getOperand(i));
 
-  Value *NC = CallInst::Create(Clone, Operands.begin(), Operands.end(), CI.getName(), &CI);
+  Value *NC = CallInst::Create(Clone, Operands, CI.getName(), &CI);
   if (NC->getType() != CI.getType())      // Compressing return value?
     setTransformedValue(CI, NC);
   else {
@@ -1346,15 +1345,15 @@
   Function *&Clone = ExtCloneFunctionMap[std::make_pair(F, ArgsToComp)];
   if (Clone) return Clone;
 
-  const FunctionType *FTy = F->getFunctionType();
-  const Type *RetTy = FTy->getReturnType();
+  FunctionType *FTy = F->getFunctionType();
+  Type *RetTy = FTy->getReturnType();
   unsigned ArgIdx = 0;
   if (isa<PointerType>(RetTy) && ArgsToComp[0] == 0) {
     RetTy = SCALARUINTTYPE;
     ++ArgIdx;
   }
 
-  std::vector<const Type*> ParamTypes;
+  std::vector<Type*> ParamTypes;
 
   for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
     if (ArgIdx < ArgsToComp.size() && ArgsToComp[ArgIdx]-1 == i) {
@@ -1388,13 +1387,13 @@
   if (Clone) return Clone;
 
   // First step, construct the new function prototype.
-  const FunctionType *FTy = F->getFunctionType();
-  const Type *RetTy = FTy->getReturnType();
+  FunctionType *FTy = F->getFunctionType();
+  Type *RetTy = FTy->getReturnType();
   if (isa<PointerType>(RetTy) &&
       PoolsToCompress.count(CG.getReturnNodeFor(FI.F).getNode())) {
     RetTy = SCALARUINTTYPE;
   }
-  std::vector<const Type*> ParamTypes;
+  std::vector<Type*> ParamTypes;
   unsigned NumPoolArgs = FI.ArgNodes.size();
 
   // Pass all pool args unmodified.
@@ -1430,7 +1429,7 @@
     return Clone;
   }
 
-  DenseMap<const Value*, Value*> ValueMap;
+  ValueToValueMapTy ValueMap;
 
   // Create dummy Value*'s of pointer type for any arguments that are
   // compressed.  These are needed to satisfy typing constraints before the
@@ -1459,12 +1458,13 @@
 
   // Clone the actual function body over.
   SmallVector<ReturnInst*,100> Returns;
-  CloneFunctionInto(Clone, F, ValueMap, Returns);
+  // TODO: Should the 'ModuleLevelChanges' flag be true or false here?
+  CloneFunctionInto(Clone, F, ValueMap, true, Returns);
   Returns.clear();  // Don't need this.
   
   // Invert the ValueMap into the NewToOldValueMap
   std::map<Value*, const Value*> &NewToOldValueMap = CFI.NewToOldValueMap;
-  for (DenseMap<const Value*, Value*>::iterator I = ValueMap.begin(),
+  for (ValueToValueMapTy::iterator I = ValueMap.begin(),
          E = ValueMap.end(); I != E; ++I)
     NewToOldValueMap.insert(std::make_pair(I->second, I->first));
 
@@ -1513,8 +1513,8 @@
 /// InitializePoolLibraryFunctions - Create the function prototypes for pointer
 /// compress runtime library functions.
 void PointerCompress::InitializePoolLibraryFunctions(Module &M) {
-  const Type *VoidPtrTy = PointerType::getUnqual(Int8Type);
-  const Type *PoolDescPtrTy = PointerType::getUnqual(ArrayType::get(VoidPtrTy, 16));
+  Type *VoidPtrTy = PointerType::getUnqual(Int8Type);
+  Type *PoolDescPtrTy = PointerType::getUnqual(ArrayType::get(VoidPtrTy, 16));
 
   PoolInitPC = M.getOrInsertFunction("poolinit_pc", VoidPtrTy, PoolDescPtrTy, 
                                      Int32Type, Int32Type, NULL);

Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Sat Aug 13 12:22:11 2011
@@ -46,7 +46,7 @@
 char PoolAllocatePassAllPools::ID = 0;
 char PoolAllocateGroup::ID = 0;
 
-const Type *PoolAllocate::PoolDescPtrTy = 0;
+Type *PoolAllocate::PoolDescPtrTy = 0;
 
 cl::opt<bool> PA::PA_SAFECODE("pa-safecode", cl::ReallyHidden);
 
@@ -69,10 +69,10 @@
   STATISTIC (NumNonprofit, "Number of DSNodes not profitable");
   //  STATISTIC (NumColocated, "Number of DSNodes colocated");
 
-  const Type *VoidPtrTy;
+  Type *VoidPtrTy;
 
   // The type to allocate for a pool descriptor.
-  const Type *PoolDescType;
+  Type *PoolDescType;
 
   cl::opt<bool>
   DisableInitDestroyOpt("poolalloc-force-simple-pool-init",
@@ -88,9 +88,9 @@
   //
   // Create the __poolalloc_init() function.
   //
-  const Type * VoidType = Type::getVoidTy(M.getContext());
+  Type * VoidType = Type::getVoidTy(M.getContext());
   FunctionType * FTy = FunctionType::get(VoidType,
-                                         std::vector<const Type*>(),
+                                         std::vector<Type*>(),
                                          false);
   Function *InitFunc = Function::Create (FTy,
                                          GlobalValue::ExternalLinkage,
@@ -120,9 +120,9 @@
   // Create the global pool ctor function.
   //
   LLVMContext & Context = M.getContext();
-  const Type * VoidType = Type::getVoidTy (Context);
+  Type * VoidType = Type::getVoidTy (Context);
   FunctionType * FTy = FunctionType::get(VoidType,
-                                         std::vector<const Type*>(),
+                                         std::vector<Type*>(),
                                          false);
   Function *InitFunc = Function::Create (FTy,
                                          GlobalValue::ExternalLinkage,
@@ -138,11 +138,11 @@
   //
   // Insert the run-time ctor into the ctor list.
   //
-  const Type * Int32Type = IntegerType::getInt32Ty(Context);
+  Type * Int32Type = IntegerType::getInt32Ty(Context);
   std::vector<Constant *> CtorInits;
   CtorInits.push_back (ConstantInt::get (Int32Type, 65535));
   CtorInits.push_back (InitFunc);
-  Constant * RuntimeCtorInit = ConstantStruct::get(Context, CtorInits, false);
+  Constant * RuntimeCtorInit = ConstantStruct::getAnon(Context, ArrayRef<Constant*>(CtorInits));
 
   //
   // Get the current set of static global constructors and add the new ctor
@@ -177,7 +177,7 @@
   //
   // Create a new initializer.
   //
-  const ArrayType * AT = ArrayType::get (RuntimeCtorInit-> getType(),
+  ArrayType * AT = ArrayType::get (RuntimeCtorInit-> getType(),
                                          CurrentCtors.size());
   Constant * NewInit=ConstantArray::get (AT, CurrentCtors);
 
@@ -200,13 +200,13 @@
   AU.addRequired<Heuristic>();
   AU.addPreserved<Heuristic>();
   if (dsa_pass_to_use == PASS_EQTD) {
-    AU.addRequiredTransitive<EQTDDataStructures>();
+    AU.addRequired<EQTDDataStructures>();
     if(lie_preserve_passes != LIE_NONE)
-    	AU.addPreserved<EQTDDataStructures>();
+      AU.addPreserved<EQTDDataStructures>();
   } else {
-    AU.addRequiredTransitive<EquivBUDataStructures>();
+    AU.addRequired<EquivBUDataStructures>();
     if(lie_preserve_passes != LIE_NONE)
-    	AU.addPreserved<EquivBUDataStructures>();
+      AU.addPreserved<EquivBUDataStructures>();
   }
 
   // Preserve the pool information across passes
@@ -347,13 +347,13 @@
     for (Function::use_iterator User = F->use_begin();
                                 User != F->use_end();
                                 ++User) {
-      if (CallInst * CI = dyn_cast<CallInst>(User)) {
+      if (CallInst * CI = dyn_cast<CallInst>(*User)) {
         if (CI->getCalledFunction() == F)
           if ((FuncMap.find(CI->getParent()->getParent())) != FuncMap.end())
             continue;
       }
 
-      if (InvokeInst * CI = dyn_cast<InvokeInst>(User)) {
+      if (InvokeInst * CI = dyn_cast<InvokeInst>(*User)) {
         if (CI->getCalledFunction() == F)
           if ((FuncMap.find(CI->getParent()->getParent())) != FuncMap.end())
             continue;
@@ -440,7 +440,9 @@
     PoolDescPtrTy = PointerType::getUnqual(PoolDescType);
   }
 
-  M->addTypeName("PoolDescriptor", PoolDescType);
+  // TODO: I'm not sure how to do this on mainline.
+  //M->addTypeName("PoolDescriptor", PoolDescType);
+
   
   // Get poolinit function.
   PoolInit = M->getOrInsertFunction("poolinit", VoidType,
@@ -488,7 +490,7 @@
   if(pthread_create_func)
   {
       Function::arg_iterator i = pthread_create_func->arg_begin();
-      std::vector<const Type*> non_vararg_params;
+      std::vector<Type*> non_vararg_params;
       non_vararg_params.push_back(i++->getType());
       non_vararg_params.push_back(i++->getType());
       non_vararg_params.push_back(i++->getType());
@@ -529,7 +531,7 @@
       if (isa<Constant>(User->getOperand(1)) && 
           cast<Constant>(User->getOperand(1))->isNullValue()) {
         bool CondIsTrue = ICI->getPredicate() == ICmpInst::ICMP_NE;
-        const Type * Int1Type  = IntegerType::getInt1Ty(*Context);
+        Type * Int1Type  = IntegerType::getInt1Ty(*Context);
         User->replaceAllUsesWith(ConstantInt::get(Int1Type, CondIsTrue));
       }
     } else if ((User->getOpcode() == Instruction::Trunc) ||
@@ -723,13 +725,17 @@
         // internal function or the external ones. 
         // FIXME: Solve this by devirtualizing the call site.
         for (unsigned index = 0; index < Functions.size(); ++index) {
-          Function * F = (Function *) Functions[index];
+          Function * F = const_cast<Function*>(Functions[index]);
           if (FunctionInfo.find (F) != FunctionInfo.end()) {
             FuncInfo & FI =  FunctionInfo.find(F)->second;
             assert(FI.ArgNodes.size() == 0);
             continue;
           }
-          FunctionInfo.insert(std::make_pair(F, FuncInfo(*F))).first->second;
+          // TODO: Original code was:
+          // FunctionInfo.insert(std::make_pair(F, FuncInfo(*F))).first->second;
+          // But this has unused components.. (.first->second?)
+          // So just inserting the function info, and hoping for the best.
+          FunctionInfo.insert(std::make_pair(F, FuncInfo(*F)));
         }
       } else {
         FindFunctionPoolArgs (Functions);
@@ -849,7 +855,7 @@
   // the same set of DSNodes passed in.
   //
   for (unsigned index = 0; index < Functions.size(); ++index) {
-    Function * F = (Function *) Functions[index];
+    Function * F = const_cast<Function*>(Functions[index]);
     if (FunctionInfo.find (F) != FunctionInfo.end()) {
       FuncInfo & FI =  FunctionInfo.find(F)->second;
       assert(FI.ArgNodes.size() == MarkedNodes.size());
@@ -910,8 +916,8 @@
   // for the pools to pass into the function, and then we will insert the
   // original parameter values after that.
   //
-  std::vector<const Type*> ArgTys(FI.ArgNodes.size(), PoolDescPtrTy);
-  const FunctionType *OldFuncTy = F.getFunctionType();
+  std::vector<Type*> ArgTys(FI.ArgNodes.size(), PoolDescPtrTy);
+  FunctionType *OldFuncTy = F.getFunctionType();
   ArgTys.reserve(OldFuncTy->getNumParams() + FI.ArgNodes.size());
   ArgTys.insert(ArgTys.end(), OldFuncTy->param_begin(), OldFuncTy->param_end());
 
@@ -942,7 +948,7 @@
   // arguments of the new function, and copy over the names.
   //
   //
-  DenseMap<const Value*, Value*> ValueMap;
+  ValueToValueMapTy ValueMap;
   // FIXME: Remove use of SAFECodeEnabled flag
   // FIXME: Is FI.ValueMap empty?  We should put an assert to verify that it
   //        is.
@@ -959,13 +965,14 @@
 
   // Perform the cloning.
   SmallVector<ReturnInst*,100> Returns;
-  CloneFunctionInto(New, &F, ValueMap, Returns);
+  // TODO: Evalute the boolean parameter here...
+  CloneFunctionInto(New, &F, ValueMap, true, Returns);
 
   //
   // Invert the ValueMap into the NewToOldValueMap.
   //
   std::map<Value*, const Value*> &NewToOldValueMap = FI.NewToOldValueMap;
-  for (DenseMap<const Value*, Value*>::iterator I = ValueMap.begin(),
+  for (ValueToValueMapTy::iterator I = ValueMap.begin(),
          E = ValueMap.end(); I != E; ++I)
     NewToOldValueMap.insert(std::make_pair(I->second, I->first));
 
@@ -1084,7 +1091,7 @@
   Value *ElSize = ConstantInt::get(Int32Type, RecSize);
   Value *AlignV = ConstantInt::get(Int32Type, Align);
   Value* Opts[3] = {GV, ElSize, AlignV};
-  CallInst::Create(PoolInit, Opts, Opts + 3, "", InsertPt);
+  CallInst::Create(PoolInit, ArrayRef<Value*>(Opts), "", InsertPt);
   ++NumPools;
   return GV;
 }
@@ -1307,7 +1314,7 @@
     // cast pool handles, so if we see a non-call instruction, we know it's not
     // used in a poolfree() or pooldestroy() call.
     //
-    if (Instruction * Inst = dyn_cast<Instruction>(I)) {
+    if (Instruction * Inst = dyn_cast<Instruction>(*I)) {
       if (!isa<CallInst>(*I)) {
         // This block and every block that can reach this block must keep pool
         // frees.
@@ -1320,7 +1327,7 @@
       }
     }
 
-    CallSite U = CallSite::get(I->stripPointerCasts());
+    CallSite U = CallSite(I->stripPointerCasts());
     if (U.getCalledValue() != PoolFree && U.getCalledValue() != PoolDestroy) {
       // This block and every block that can reach this block must keep pool
       // frees.
@@ -1493,7 +1500,7 @@
 
   for (unsigned i = 0, e = PoolInitPoints.size(); i != e; ++i) {
     Value* Opts[3] = {PD, ElSize, Align};
-    CallInst::Create(PoolInit, Opts, Opts + 3,  "", PoolInitPoints[i]);
+    CallInst::Create(PoolInit, ArrayRef<Value*>(Opts),  "", PoolInitPoints[i]);
     DEBUG(errs() << PoolInitPoints[i]->getParent()->getNameStr() << " ");
   }
 

Modified: poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp Sat Aug 13 12:22:11 2011
@@ -21,9 +21,9 @@
 #include <set>
 using namespace llvm;
 
-static const Type * VoidType  = 0;
-static const Type * Int8Type  = 0;
-static const Type * Int32Type = 0;
+static Type * VoidType  = 0;
+static Type * Int8Type  = 0;
+static Type * Int32Type = 0;
 
 namespace {
   STATISTIC (NumBumpPtr, "Number of bump pointer pools");
@@ -32,7 +32,7 @@
     static char ID;
     bool SAFECodeEnabled;
 
-    PoolOptimize(bool SAFECode = true) : ModulePass((intptr_t)&ID) {
+    PoolOptimize(bool SAFECode = true) : ModulePass(ID) {
       SAFECodeEnabled = SAFECode;
     }
     bool runOnModule(Module &M);
@@ -69,8 +69,8 @@
   //
   // Create LLVM types used by the pool allocation passes.
   //
-  const Type *VoidPtrTy = PointerType::getUnqual(Int8Type);
-  const Type *PoolDescPtrTy;
+  Type *VoidPtrTy = PointerType::getUnqual(Int8Type);
+  Type *PoolDescPtrTy;
   if (SAFECodeEnabled)
     PoolDescPtrTy = PointerType::getUnqual(ArrayType::get(VoidPtrTy, 92));
   else
@@ -135,7 +135,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 = CallInst::Create(PoolAlloc, Opts, Opts + 2,
+      Value *New = CallInst::Create(PoolAlloc, ArrayRef<Value*>(Opts),
                                 CI->getName(), CI);
       CI->replaceAllUsesWith(New);
       CI->eraseFromParent();
@@ -143,15 +143,15 @@
                cast<Constant>(CI->getOperand(3))->isNullValue()) {
       // poolrealloc(PD, X, 0) -> poolfree(PD, X)
       Value* Opts[2] = {CI->getOperand(1), CI->getOperand(2)};
-      CallInst::Create(PoolFree, Opts, Opts + 2, "", CI);
-      const PointerType * PT = dyn_cast<PointerType>(CI->getType());
+      CallInst::Create(PoolFree, ArrayRef<Value*>(Opts), "", CI);
+      PointerType * PT = dyn_cast<PointerType>(CI->getType());
       assert (PT && "poolrealloc call does not return a pointer!\n");
       CI->replaceAllUsesWith(ConstantPointerNull::get(PT));
       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 = CallInst::Create(Realloc, Opts, Opts + 2,
+      Value *New = CallInst::Create(Realloc, ArrayRef<Value*>(Opts),
                                 CI->getName(), CI);
       CI->replaceAllUsesWith(New);
       CI->eraseFromParent();
@@ -182,7 +182,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 = CallInst::Create(MemAlign, Opts, Opts + 2, CI->getName(), CI);
+      Value *New = CallInst::Create(MemAlign, ArrayRef<Value*>(Opts), CI->getName(), CI);
       CI->replaceAllUsesWith(New);
       CI->eraseFromParent();
     }
@@ -254,18 +254,18 @@
           std::vector<Value*> Args;
           if (CI->getCalledFunction() == PoolAlloc) {
             Args.assign(CI->op_begin()+1, CI->op_end());
-            Value *New = CallInst::Create(PoolAllocBP, Args.begin(), Args.end(), CI->getName(), CI);
+            Value *New = CallInst::Create(PoolAllocBP, Args, 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.
-            CallInst::Create(PoolInitBP, Args.begin(), Args.end(), "", CI);
+            CallInst::Create(PoolInitBP, Args, "", CI);
             CI->eraseFromParent();
           } else {
             assert(CI->getCalledFunction() == PoolDestroy);
             Args.assign(CI->op_begin()+1, CI->op_end());
-            CallInst::Create(PoolDestroyBP, Args.begin(), Args.end(), "", CI);
+            CallInst::Create(PoolDestroyBP, Args, "", CI);
             CI->eraseFromParent();
           }
         }

Modified: poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp Sat Aug 13 12:22:11 2011
@@ -141,8 +141,8 @@
 
   // Figure out what the arguments are to be for the new version of the
   // function
-  const FunctionType *OldFuncTy = F.getFunctionType();
-  std::vector<const Type*> ArgTys(FI.ArgNodes.size(), PoolDescPtrTy);
+  FunctionType *OldFuncTy = F.getFunctionType();
+  std::vector<Type*> ArgTys(FI.ArgNodes.size(), PoolDescPtrTy);
   ArgTys.reserve(OldFuncTy->getNumParams() + FI.ArgNodes.size());
 
   ArgTys.insert(ArgTys.end(), OldFuncTy->param_begin(), OldFuncTy->param_end());
@@ -165,7 +165,7 @@
 
   // Map the existing arguments of the old function to the corresponding
   // arguments of the new function, and copy over the names.
-  DenseMap<const Value*, Value*> ValueMap;
+  ValueToValueMapTy ValueMap;
   for (Function::arg_iterator I = F.arg_begin();
           NI != New->arg_end(); ++I, ++NI) {
     ValueMap[I] = NI;
@@ -174,7 +174,8 @@
 
   // Perform the cloning.
   SmallVector<ReturnInst*,100> Returns;
-  CloneFunctionInto(New, &F, ValueMap, Returns);
+  // TODO: review the boolean flag here
+  CloneFunctionInto(New, &F, ValueMap, true, Returns);
 
   //
   // The CloneFunctionInto() function will copy the parameter attributes
@@ -200,15 +201,15 @@
     New->setAttributes(NewAttrsVector);
   }
 
-  for (DenseMap<const Value*, Value*>::iterator I = ValueMap.begin(),
+  for (ValueToValueMapTy::iterator I = ValueMap.begin(),
           E = ValueMap.end(); I != E; ++I)
-    FI.NewToOldValueMap.insert(std::make_pair(I->second, (Value*)I->first));
+    FI.NewToOldValueMap.insert(std::make_pair(I->second, const_cast<Value*>(I->first)));
 
   return FI.Clone = New;
 }
 
 RTAssociate::RTAssociate()
-: ModulePass((intptr_t) & ID) { }
+: ModulePass(ID) { }
 
 void RTAssociate::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addRequiredTransitive<CompleteBUDataStructures > ();
@@ -229,7 +230,8 @@
   //  PoolDescType = OpaqueType::get(M.getContext());
   PoolDescType = Type::getInt32Ty(M.getContext());
   PoolDescPtrTy = PointerType::getUnqual(PoolDescType);
-  M.addTypeName("PoolDescriptor", PoolDescType);
+  // TODO: Not sure how to do this anymore, commenting out.
+  //M.addTypeName("PoolDescriptor", PoolDescType);
 
   // Create the pools for memory objects reachable by global variables.
   SetupGlobalPools(&M, Graphs-> getGlobalsGraph());
@@ -524,7 +526,7 @@
       return;           // No arguments to add?  Transformation is a noop!
 
     // Cast the function pointer to an appropriate type!
-    std::vector<const Type*> ArgTys(ArgNodes.size(), PoolDescPtrTy);
+    std::vector<Type*> ArgTys(ArgNodes.size(), PoolDescPtrTy);
     for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end();
          I != E; ++I)
       ArgTys.push_back((*I)->getType());
@@ -573,9 +575,9 @@
   // type doesn't match the number of arguments.
   //
   if (Function * NewFunction = dyn_cast<Function>(NewCallee)) {
-    const FunctionType * NewCalleeType = NewFunction->getFunctionType();
+    FunctionType * NewCalleeType = NewFunction->getFunctionType();
     if (NewCalleeType->getNumParams() != Args.size()) {
-      std::vector<const Type *> Types;
+      std::vector<Type *> Types;
       Type * FuncTy = FunctionType::get (NewCalleeType->getReturnType(),
                                          Types,
                                          true);
@@ -589,9 +591,9 @@
   if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
     NewCall = InvokeInst::Create (NewCallee, II->getNormalDest(),
                                   II->getUnwindDest(),
-                                  Args.begin(), Args.end(), Name, TheCall);
+                                  Args, Name, TheCall);
   } else {
-    NewCall = CallInst::Create (NewCallee, Args.begin(), Args.end(), Name,
+    NewCall = CallInst::Create (NewCallee, Args, Name,
                                 TheCall);
   }
 

Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=137557&r1=137556&r2=137557&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Sat Aug 13 12:22:11 2011
@@ -114,7 +114,7 @@
         // If the NewToOldValueMap is in effect, use it.
         std::map<Value*,const Value*>::iterator I = FI.NewToOldValueMap.find(V);
         if (I != FI.NewToOldValueMap.end())
-          V = (Value*)I->second;
+          V = const_cast<Value*>(I->second);
       }
       return V;
     }
@@ -139,7 +139,7 @@
 }
 
 static inline Value *
-castTo (Value * V, const Type * Ty, std::string Name, Instruction * InsertPt) {
+castTo (Value * V, Type * Ty, std::string Name, Instruction * InsertPt) {
   //
   // Don't bother creating a cast if it's already the correct type.
   //
@@ -282,7 +282,7 @@
 
   // Create call to poolalloc, and record the use of the pool
   Value* Opts[2] = {PH, Size};
-  Instruction *V = CallInst::Create(PAInfo.PoolAlloc, Opts, Opts + 2, Name, I);
+  Instruction *V = CallInst::Create(PAInfo.PoolAlloc, ArrayRef<Value*>(Opts), Name, I);
   AddPoolUse(*V, PH, PoolUses);
 
   // Cast to the appropriate type if necessary
@@ -377,7 +377,7 @@
   // Insert a call to poolfree(), and mark that memory was deallocated from the pool.
   //
   Value* Opts[2] = {PH, Casted};
-  CallInst *FreeI = CallInst::Create(PAInfo.PoolFree, Opts, Opts + 2, "", Where);
+  CallInst *FreeI = CallInst::Create(PAInfo.PoolFree, ArrayRef<Value*>(Opts), "", Where);
   AddPoolUse(*FreeI, PH, PoolFrees);
   return FreeI;
 }
@@ -472,7 +472,7 @@
   Instruction * I = CS.getInstruction();
   std::string Name = I->getName(); I->setName("");
 
-  const Type* Int32Type = Type::getInt32Ty(CS.getInstruction()->getContext());
+  Type* Int32Type = Type::getInt32Ty(CS.getInstruction()->getContext());
 
   // FIXME: Ensure that we use 32/64-bit object length sizes consistently
   // FIXME: Introduce 'ObjectAllocationSize' variable
@@ -494,7 +494,7 @@
   // Create call to poolcalloc, and record the use of the pool
   //
   Value* Opts[3] = {PH, V1, V2};
-  Instruction *V = CallInst::Create(PAInfo.PoolCalloc, Opts, Opts + 3, Name, I);
+  Instruction *V = CallInst::Create(PAInfo.PoolCalloc, ArrayRef<Value*>(Opts), Name, I);
   AddPoolUse(*V, PH, PoolUses);
 
   // Cast to the appropriate type if necessary
@@ -548,7 +548,7 @@
 
   std::string Name = I->getName(); I->setName("");
   Value* Opts[3] = {PH, OldPtr, Size};
-  Instruction *V = CallInst::Create(PAInfo.PoolRealloc, Opts, Opts + 3, Name, I);
+  Instruction *V = CallInst::Create(PAInfo.PoolRealloc, ArrayRef<Value*>(Opts), Name, I);
   Instruction *Casted = V;
   if (V->getType() != I->getType())
     Casted = CastInst::CreatePointerCast(V, I->getType(), V->getName(), I);
@@ -586,8 +586,8 @@
   Value *Size = 0;
   Value *PH;
 
-  const Type* Int8Type = Type::getInt8Ty(CS.getInstruction()->getContext());
-  const Type* Int32Type = Type::getInt32Ty(CS.getInstruction()->getContext());
+  Type* Int8Type = Type::getInt8Ty(CS.getInstruction()->getContext());
+  Type* Int32Type = Type::getInt32Ty(CS.getInstruction()->getContext());
 
 
   if (CS.getCalledFunction()->getName() == "memalign") {
@@ -605,12 +605,12 @@
     PH = getPoolHandle(I);
 
     // Return success always.
-    const PointerType * PT = dyn_cast<PointerType>(I->getType());
+    PointerType * PT = dyn_cast<PointerType>(I->getType());
     assert (PT && "memalign() does not return pointer type!\n");
     Value *RetVal = ConstantPointerNull::get(PT);
     I->replaceAllUsesWith(RetVal);
 
-    static const Type *PtrPtr=PointerType::getUnqual(PointerType::getUnqual(Int8Type));
+    static Type *PtrPtr=PointerType::getUnqual(PointerType::getUnqual(Int8Type));
     if (ResultDest->getType() != PtrPtr)
       ResultDest = CastInst::CreatePointerCast(ResultDest, PtrPtr, ResultDest->getName(), I);
   }
@@ -622,7 +622,7 @@
 
   std::string Name = I->getName(); I->setName("");
   Value* Opts[3] = {PH, Align, Size};
-  Instruction *V = CallInst::Create(PAInfo.PoolMemAlign, Opts, Opts + 3, Name, I);
+  Instruction *V = CallInst::Create(PAInfo.PoolMemAlign, ArrayRef<Value*>(Opts), Name, I);
 
   Instruction *Casted = V;
   if (V->getType() != I->getType())
@@ -662,7 +662,7 @@
   assert (Node && "strdup has NULL DSNode!\n");
   Value *PH = getPoolHandle(I);
 
-  const Type* Int8Type = Type::getInt8Ty(CS.getInstruction()->getContext());
+  Type* Int8Type = Type::getInt8Ty(CS.getInstruction()->getContext());
 
 
 #if 0
@@ -681,7 +681,7 @@
 
   std::string Name = I->getName(); I->setName("");
   Value* Opts[3] = {PH, OldPtr, 0};
-  Instruction *V = CallInst::Create(PAInfo.PoolStrdup, Opts, Opts + 2, Name, I);
+  Instruction *V = CallInst::Create(PAInfo.PoolStrdup, ArrayRef<Value*>(Opts), Name, I);
   Instruction *Casted = V;
   if (V->getType() != I->getType())
     Casted = CastInst::CreatePointerCast(V, I->getType(), V->getName(), I);
@@ -731,8 +731,8 @@
   // Insert the pool handle into the run-time check.
   //
   if (PH) {
-    const Type * Int8Type  = Type::getInt8Ty(CS.getInstruction()->getContext());
-    const Type * VoidPtrTy = PointerType::getUnqual(Int8Type);
+    Type * Int8Type  = Type::getInt8Ty(CS.getInstruction()->getContext());
+    Type * VoidPtrTy = PointerType::getUnqual(Int8Type);
     PH = castTo (PH, VoidPtrTy, PH->getName(), CS.getInstruction());
     CS.setArgument (0, PH);
 
@@ -752,8 +752,8 @@
   // Check for the correct number of pool arguments
   assert ((CS.arg_size() > argc) && "Incorrect number of pool arguments!");
 
-  const Type *Int8Ty = Type::getInt8Ty(CS.getInstruction()->getContext());
-  const Type *VoidPtrTy = PointerType::getUnqual(Int8Ty);
+  Type *Int8Ty = Type::getInt8Ty(CS.getInstruction()->getContext());
+  Type *VoidPtrTy = PointerType::getUnqual(Int8Ty);
 
   if (argc == 1) {
     // Get the pool handle for the pointer argument
@@ -1068,7 +1068,7 @@
       return;           // No arguments to add?  Transformation is a noop!
 
     // Cast the function pointer to an appropriate type!
-    std::vector<const Type*> ArgTys(ArgNodes.size(),
+    std::vector<Type*> ArgTys(ArgNodes.size(),
                                     PoolAllocate::PoolDescPtrTy);
     for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end();
          I != E; ++I)
@@ -1152,9 +1152,9 @@
   // type doesn't match the number of arguments.
   //
   if (Function * NewFunction = dyn_cast<Function>(NewCallee)) {
-    const FunctionType * NewCalleeType = NewFunction->getFunctionType();
+    FunctionType * NewCalleeType = NewFunction->getFunctionType();
     if (NewCalleeType->getNumParams() != Args.size()) {
-      std::vector<const Type *> Types;
+      std::vector<Type *> Types;
       Type * FuncTy = FunctionType::get (NewCalleeType->getReturnType(),
                                          Types,
                                          true);
@@ -1182,15 +1182,15 @@
 
 	//Make the thread creation call
 	NewCall = CallInst::Create(pthread_replacement,
-							   thread_args.begin(),thread_args.end(),
+							   thread_args,
 							   Name,TheCall);
   }
   else if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
     NewCall = InvokeInst::Create (NewCallee, II->getNormalDest(),
                                   II->getUnwindDest(),
-                                  Args.begin(), Args.end(), Name, TheCall);
+                                  Args, Name, TheCall);
   } else {
-    NewCall = CallInst::Create (NewCallee, Args.begin(), Args.end(), Name,
+    NewCall = CallInst::Create (NewCallee, Args, Name,
                                 TheCall);
   }
 





More information about the llvm-commits mailing list