[llvm-commits] CVS: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp ConstantMerge.cpp DeadArgumentElimination.cpp ExtractFunction.cpp FunctionResolution.cpp GlobalDCE.cpp GlobalOpt.cpp IPConstantPropagation.cpp InlineSimple.cpp Internalize.cpp StripSymbols.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Mar 14 20:55:02 PST 2005



Changes in directory llvm/lib/Transforms/IPO:

ArgumentPromotion.cpp updated: 1.16 -> 1.17
ConstantMerge.cpp updated: 1.28 -> 1.29
DeadArgumentElimination.cpp updated: 1.19 -> 1.20
ExtractFunction.cpp updated: 1.10 -> 1.11
FunctionResolution.cpp updated: 1.55 -> 1.56
GlobalDCE.cpp updated: 1.35 -> 1.36
GlobalOpt.cpp updated: 1.37 -> 1.38
IPConstantPropagation.cpp updated: 1.16 -> 1.17
InlineSimple.cpp updated: 1.68 -> 1.69
Internalize.cpp updated: 1.23 -> 1.24
StripSymbols.cpp updated: 1.2 -> 1.3
---
Log message:

This mega patch converts us from using Function::a{iterator|begin|end} to
using Function::arg_{iterator|begin|end}.  Likewise Module::g* -> Module::global_*.

This patch is contributed by Gabor Greif, thanks!



---
Diffs of the changes:  (+32 -32)

 ArgumentPromotion.cpp       |   14 +++++++-------
 ConstantMerge.cpp           |    2 +-
 DeadArgumentElimination.cpp |   16 ++++++++--------
 ExtractFunction.cpp         |    2 +-
 FunctionResolution.cpp      |    4 ++--
 GlobalDCE.cpp               |    4 ++--
 GlobalOpt.cpp               |    8 ++++----
 IPConstantPropagation.cpp   |    8 ++++----
 InlineSimple.cpp            |    2 +-
 Internalize.cpp             |    2 +-
 StripSymbols.cpp            |    2 +-
 11 files changed, 32 insertions(+), 32 deletions(-)


Index: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
diff -u llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.16 llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.17
--- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.16	Sat Jan  8 13:45:31 2005
+++ llvm/lib/Transforms/IPO/ArgumentPromotion.cpp	Mon Mar 14 22:54:20 2005
@@ -106,7 +106,7 @@
 
   // First check: see if there are any pointer arguments!  If not, quick exit.
   std::vector<Argument*> PointerArgs;
-  for (Function::aiterator I = F->abegin(), E = F->aend(); I != E; ++I)
+  for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
     if (isa<PointerType>(I->getType()))
       PointerArgs.push_back(I);
   if (PointerArgs.empty()) return false;
@@ -163,7 +163,7 @@
 static bool AllCalleesPassInValidPointerForArgument(Argument *Arg) {
   Function *Callee = Arg->getParent();
 
-  unsigned ArgNo = std::distance(Callee->abegin(), Function::aiterator(Arg));
+  unsigned ArgNo = std::distance(Callee->arg_begin(), Function::arg_iterator(Arg));
 
   // Look at all call sites of the function.  At this pointer we know we only
   // have direct callees.
@@ -347,7 +347,7 @@
   // what the new GEP/Load instructions we are inserting look like.
   std::map<std::vector<Value*>, LoadInst*> OriginalLoads;
 
-  for (Function::aiterator I = F->abegin(), E = F->aend(); I != E; ++I)
+  for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
     if (!ArgsToPromote.count(I)) {
       Params.push_back(I->getType());
     } else if (I->use_empty()) {
@@ -411,7 +411,7 @@
     // Loop over the operands, inserting GEP and loads in the caller as
     // appropriate.
     CallSite::arg_iterator AI = CS.arg_begin();
-    for (Function::aiterator I = F->abegin(), E = F->aend(); I != E; ++I, ++AI)
+    for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I, ++AI)
       if (!ArgsToPromote.count(I))
         Args.push_back(*AI);          // Unmodified argument
       else if (!I->use_empty()) {
@@ -470,7 +470,7 @@
   // Loop over the argument list, transfering uses of the old arguments over to
   // the new arguments, also transfering over the names as well.
   //
-  for (Function::aiterator I = F->abegin(), E = F->aend(), I2 = NF->abegin();
+  for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(), I2 = NF->arg_begin();
        I != E; ++I)
     if (!ArgsToPromote.count(I)) {
       // If this is an unmodified argument, move the name and users over to the
@@ -502,7 +502,7 @@
           std::vector<Value*> Operands(GEP->op_begin()+1, GEP->op_end());
 
           unsigned ArgNo = 0;
-          Function::aiterator TheArg = I2;
+          Function::arg_iterator TheArg = I2;
           for (ScalarizeTable::iterator It = ArgIndices.begin();
                *It != Operands; ++It, ++TheArg) {
             assert(It != ArgIndices.end() && "GEP not handled??");
@@ -539,7 +539,7 @@
 
   // Notify the alias analysis implementation that we inserted a new argument.
   if (ExtraArgHack)
-    AA.copyValue(Constant::getNullValue(Type::IntTy), NF->abegin());
+    AA.copyValue(Constant::getNullValue(Type::IntTy), NF->arg_begin());
 
 
   // Tell the alias analysis that the old function is about to disappear.


Index: llvm/lib/Transforms/IPO/ConstantMerge.cpp
diff -u llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.28 llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.29
--- llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.28	Sun Sep 19 23:43:34 2004
+++ llvm/lib/Transforms/IPO/ConstantMerge.cpp	Mon Mar 14 22:54:20 2005
@@ -56,7 +56,7 @@
     // because doing so may cause initializers of other globals to be rewritten,
     // invalidating the Constant* pointers in CMap.
     //
-    for (Module::giterator GV = M.gbegin(), E = M.gend(); GV != E; ++GV)
+    for (Module::global_iterator GV = M.global_begin(), E = M.global_end(); GV != E; ++GV)
       // Only process constants with initializers
       if (GV->isConstant() && GV->hasInitializer()) {
         Constant *Init = GV->getInitializer();


Index: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
diff -u llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.19 llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.20
--- llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.19	Sun Sep 19 23:43:34 2004
+++ llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp	Mon Mar 14 22:54:20 2005
@@ -210,7 +210,7 @@
 
   if (FunctionIntrinsicallyLive) {
     DEBUG(std::cerr << "  Intrinsically live fn: " << F.getName() << "\n");
-    for (Function::aiterator AI = F.abegin(), E = F.aend(); AI != E; ++AI)
+    for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); AI != E; ++AI)
       LiveArguments.insert(AI);
     LiveRetVal.insert(&F);
     return;
@@ -230,7 +230,7 @@
   // if there are any arguments we assume that are dead.
   //
   bool AnyMaybeLiveArgs = false;
-  for (Function::aiterator AI = F.abegin(), E = F.aend(); AI != E; ++AI)
+  for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); AI != E; ++AI)
     switch (getArgumentLiveness(*AI)) {
     case Live:
       DEBUG(std::cerr << "    Arg live by use: " << AI->getName() << "\n");
@@ -284,7 +284,7 @@
     // Loop over all of the arguments (because Arg may be passed into the call
     // multiple times) and check to see if any are now alive...
     CallSite::arg_iterator CSAI = CS.arg_begin();
-    for (Function::aiterator AI = Callee->abegin(), E = Callee->aend();
+    for (Function::arg_iterator AI = Callee->arg_begin(), E = Callee->arg_end();
          AI != E; ++AI, ++CSAI)
       // If this is the argument we are looking for, check to see if it's alive
       if (*CSAI == Arg && LiveArguments.count(AI))
@@ -309,7 +309,7 @@
   // passed in to provide a value for this argument live as necessary.
   //
   Function *Fn = Arg->getParent();
-  unsigned ArgNo = std::distance(Fn->abegin(), Function::aiterator(Arg));
+  unsigned ArgNo = std::distance(Fn->arg_begin(), Function::arg_iterator(Arg));
 
   std::multimap<Function*, CallSite>::iterator I = CallSites.lower_bound(Fn);
   for (; I != CallSites.end() && I->first == Fn; ++I) {
@@ -373,7 +373,7 @@
   const FunctionType *FTy = F->getFunctionType();
   std::vector<const Type*> Params;
 
-  for (Function::aiterator I = F->abegin(), E = F->aend(); I != E; ++I)
+  for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
     if (!DeadArguments.count(I))
       Params.push_back(I->getType());
 
@@ -410,7 +410,7 @@
 
     // Loop over the operands, deleting dead ones...
     CallSite::arg_iterator AI = CS.arg_begin();
-    for (Function::aiterator I = F->abegin(), E = F->aend(); I != E; ++I, ++AI)
+    for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I, ++AI)
       if (!DeadArguments.count(I))      // Remove operands for dead arguments
         Args.push_back(*AI);
 
@@ -455,7 +455,7 @@
   // the new arguments, also transfering over the names as well.  While we're at
   // it, remove the dead arguments from the DeadArguments list.
   //
-  for (Function::aiterator I = F->abegin(), E = F->aend(), I2 = NF->abegin();
+  for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(), I2 = NF->arg_begin();
        I != E; ++I)
     if (!DeadArguments.count(I)) {
       // If this is a live argument, move the name and users over to the new
@@ -519,7 +519,7 @@
       // live, then the return value of the called instruction is now live.
       //
       CallSite::arg_iterator AI = CS.arg_begin();  // ActualIterator
-      for (Function::aiterator FI = Callee->abegin(), E = Callee->aend();
+      for (Function::arg_iterator FI = Callee->arg_begin(), E = Callee->arg_end();
            FI != E; ++AI, ++FI) {
         // If this argument is another call...
         CallSite ArgCS = CallSite::get(*AI);


Index: llvm/lib/Transforms/IPO/ExtractFunction.cpp
diff -u llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.10 llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.11
--- llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.10	Sun Sep 19 23:43:34 2004
+++ llvm/lib/Transforms/IPO/ExtractFunction.cpp	Mon Mar 14 22:54:20 2005
@@ -52,7 +52,7 @@
       Named->setLinkage(GlobalValue::ExternalLinkage);
 
       // Mark all global variables internal
-      for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I)
+      for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
         if (!I->isExternal()) {
           I->setInitializer(0);  // Make all variables external
           I->setLinkage(GlobalValue::ExternalLinkage);


Index: llvm/lib/Transforms/IPO/FunctionResolution.cpp
diff -u llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.55 llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.56
--- llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.55	Mon Jan 31 19:23:31 2005
+++ llvm/lib/Transforms/IPO/FunctionResolution.cpp	Mon Mar 14 22:54:20 2005
@@ -311,7 +311,7 @@
       Globals[F->getName()].push_back(F);
   }
 
-  for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ) {
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ) {
     GlobalVariable *GV = I++;
     if (GV->use_empty() && GV->isExternal()) {
       M.getGlobalList().erase(GV);
@@ -343,7 +343,7 @@
       ++I;
     }
 
-  for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; )
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; )
     if (I->isExternal() && I->use_empty()) {
       GlobalVariable *GV = I;
       ++I;


Index: llvm/lib/Transforms/IPO/GlobalDCE.cpp
diff -u llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.35 llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.36
--- llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.35	Sun Sep 19 23:43:34 2004
+++ llvm/lib/Transforms/IPO/GlobalDCE.cpp	Mon Mar 14 22:54:20 2005
@@ -60,7 +60,7 @@
       GlobalIsNeeded(I);
   }
 
-  for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) {
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) {
     Changed |= RemoveUnusedGlobalValue(*I);
     // Externally visible & appending globals are needed, if they have an
     // initializer.
@@ -76,7 +76,7 @@
 
   // The first pass is to drop initializers of global variables which are dead.
   std::vector<GlobalVariable*> DeadGlobalVars;   // Keep track of dead globals
-  for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I)
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
     if (!AliveGlobals.count(I)) {
       DeadGlobalVars.push_back(I);         // Keep track of dead globals
       I->setInitializer(0);


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.37 llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.38
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.37	Sun Feb 27 12:58:52 2005
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp	Mon Mar 14 22:54:20 2005
@@ -51,7 +51,7 @@
     bool runOnModule(Module &M);
 
   private:
-    bool ProcessInternalGlobal(GlobalVariable *GV, Module::giterator &GVI);
+    bool ProcessInternalGlobal(GlobalVariable *GV, Module::global_iterator &GVI);
   };
 
   RegisterOpt<GlobalOpt> X("globalopt", "Global Variable Optimizer");
@@ -792,7 +792,7 @@
 // OptimizeOnceStoredGlobal - Try to optimize globals based on the knowledge
 // that only one value (besides its initializer) is ever stored to the global.
 static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal,
-                                     Module::giterator &GVI, TargetData &TD) {
+                                     Module::global_iterator &GVI, TargetData &TD) {
   if (CastInst *CI = dyn_cast<CastInst>(StoredOnceVal))
     StoredOnceVal = CI->getOperand(0);
   else if (GetElementPtrInst *GEPI =dyn_cast<GetElementPtrInst>(StoredOnceVal)){
@@ -915,7 +915,7 @@
 /// ProcessInternalGlobal - Analyze the specified global variable and optimize
 /// it if possible.  If we make a change, return true.
 bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV,
-                                      Module::giterator &GVI) {
+                                      Module::global_iterator &GVI) {
   std::set<PHINode*> PHIUsers;
   GlobalStatus GS;
   PHIUsers.clear();
@@ -1063,7 +1063,7 @@
   LocalChange = true;
   while (LocalChange) {
     LocalChange = false;
-    for (Module::giterator GVI = M.gbegin(), E = M.gend(); GVI != E;) {
+    for (Module::global_iterator GVI = M.global_begin(), E = M.global_end(); GVI != E;) {
       GlobalVariable *GV = GVI++;
       if (!GV->isConstant() && GV->hasInternalLinkage() &&
           GV->hasInitializer())


Index: llvm/lib/Transforms/IPO/IPConstantPropagation.cpp
diff -u llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.16 llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.17
--- llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.16	Sat Dec 11 11:00:14 2004
+++ llvm/lib/Transforms/IPO/IPConstantPropagation.cpp	Mon Mar 14 22:54:20 2005
@@ -69,10 +69,10 @@
 /// constant in for an argument, propagate that constant in as the argument.
 ///
 bool IPCP::PropagateConstantsIntoArguments(Function &F) {
-  if (F.aempty() || F.use_empty()) return false;  // No arguments?  Early exit.
+  if (F.arg_empty() || F.use_empty()) return false;  // No arguments?  Early exit.
 
   std::vector<std::pair<Constant*, bool> > ArgumentConstants;
-  ArgumentConstants.resize(F.asize());
+  ArgumentConstants.resize(F.arg_size());
 
   unsigned NumNonconstant = 0;
 
@@ -87,7 +87,7 @@
       
       // Check out all of the potentially constant arguments
       CallSite::arg_iterator AI = CS.arg_begin();
-      Function::aiterator Arg = F.abegin();
+      Function::arg_iterator Arg = F.arg_begin();
       for (unsigned i = 0, e = ArgumentConstants.size(); i != e;
            ++i, ++AI, ++Arg) {
         if (*AI == &F) return false;  // Passes the function into itself
@@ -115,7 +115,7 @@
 
   // If we got to this point, there is a constant argument!
   assert(NumNonconstant != ArgumentConstants.size());
-  Function::aiterator AI = F.abegin();
+  Function::arg_iterator AI = F.arg_begin();
   bool MadeChange = false;
   for (unsigned i = 0, e = ArgumentConstants.size(); i != e; ++i, ++AI)
     // Do we have a constant argument!?


Index: llvm/lib/Transforms/IPO/InlineSimple.cpp
diff -u llvm/lib/Transforms/IPO/InlineSimple.cpp:1.68 llvm/lib/Transforms/IPO/InlineSimple.cpp:1.69
--- llvm/lib/Transforms/IPO/InlineSimple.cpp:1.68	Mon Nov 22 11:21:44 2004
+++ llvm/lib/Transforms/IPO/InlineSimple.cpp	Mon Mar 14 22:54:20 2005
@@ -167,7 +167,7 @@
 
   // Check out all of the arguments to the function, figuring out how much
   // code can be eliminated if one of the arguments is a constant.
-  for (Function::aiterator I = F->abegin(), E = F->aend(); I != E; ++I)
+  for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
     ArgumentWeights.push_back(ArgInfo(CountCodeReductionForConstant(I),
                                       CountCodeReductionForAlloca(I)));
 }


Index: llvm/lib/Transforms/IPO/Internalize.cpp
diff -u llvm/lib/Transforms/IPO/Internalize.cpp:1.23 llvm/lib/Transforms/IPO/Internalize.cpp:1.24
--- llvm/lib/Transforms/IPO/Internalize.cpp:1.23	Sun Sep 19 23:43:34 2004
+++ llvm/lib/Transforms/IPO/Internalize.cpp	Mon Mar 14 22:54:21 2005
@@ -93,7 +93,7 @@
         }
 
       // Mark all global variables with initializers as internal as well...
-      for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I)
+      for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
         if (!I->isExternal() && !I->hasInternalLinkage() &&
             !ExternalNames.count(I->getName())) {
           // Special case handling of the global ctor and dtor list.  When we


Index: llvm/lib/Transforms/IPO/StripSymbols.cpp
diff -u llvm/lib/Transforms/IPO/StripSymbols.cpp:1.2 llvm/lib/Transforms/IPO/StripSymbols.cpp:1.3
--- llvm/lib/Transforms/IPO/StripSymbols.cpp:1.2	Fri Dec  3 10:22:08 2004
+++ llvm/lib/Transforms/IPO/StripSymbols.cpp	Mon Mar 14 22:54:21 2005
@@ -75,7 +75,7 @@
   // If we're not just stripping debug info, strip all symbols from the
   // functions and the names from any internal globals.
   if (!OnlyDebugInfo) {
-    for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I)
+    for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
       if (I->hasInternalLinkage())
         I->setName("");     // Internal symbols can't participate in linkage
 






More information about the llvm-commits mailing list