Add std:: to sort calls.
[oota-llvm.git] / lib / Transforms / IPO / ArgumentPromotion.cpp
index 78703a40b747d71c86e83d9f2259b17b3ca72dd3..7479c8ee67401725fa6193cc1fbca90d0069e717 100644 (file)
@@ -9,22 +9,22 @@
 //
 // This pass promotes "by reference" arguments to be "by value" arguments.  In
 // practice, this means looking for internal functions that have pointer
-// arguments.  If we can prove, through the use of alias analysis, that an
-// argument is *only* loaded, then we can pass the value into the function
+// arguments.  If it can prove, through the use of alias analysis, that an
+// argument is *only* loaded, then it can pass the value into the function
 // instead of the address of the value.  This can cause recursive simplification
 // of code and lead to the elimination of allocas (especially in C++ template
 // code like the STL).
 //
 // This pass also handles aggregate arguments that are passed into a function,
 // scalarizing them if the elements of the aggregate are only loaded.  Note that
-// we refuse to scalarize aggregates which would require passing in more than
-// three operands to the function, because we don't want to pass thousands of
-// operands for a large array or structure!
+// it refuses to scalarize aggregates which would require passing in more than
+// three operands to the function, because passing thousands of operands for a
+// large array or structure is unprofitable!
 //
 // Note that this transformation could also be done for arguments that are only
-// stored to (returning the value instead), but we do not currently handle that
-// case.  This case would be best handled when and if we start supporting
-// multiple return values from functions.
+// stored to (returning the value instead), but does not currently.  This case
+// would be best handled when and if LLVM begins supporting multiple return
+// values from functions.
 //
 //===----------------------------------------------------------------------===//
 
@@ -277,7 +277,7 @@ bool ArgPromotion::isSafeToPromoteArgument(Argument *Arg) const {
 
     const PointerType *LoadTy =
       cast<PointerType>(Load->getOperand(0)->getType());
-    unsigned LoadSize = (unsigned)TD.getTypeSize(LoadTy->getElementType());
+    unsigned LoadSize = (unsigned)TD.getTypeStoreSize(LoadTy->getElementType());
 
     if (AA.canInstructionRangeModify(BB->front(), *Load, Arg, LoadSize))
       return false;  // Pointer is invalidated!
@@ -376,8 +376,8 @@ Function *ArgPromotion::DoPromotion(Function *F,
       for (ScalarizeTable::iterator SI = ArgIndices.begin(),
              E = ArgIndices.end(); SI != E; ++SI)
         Params.push_back(GetElementPtrInst::getIndexedType(I->getType(),
-                                                           &(*SI)[0],
-                                                           SI->size()));
+                                                           SI->begin(),
+                                                           SI->end()));
 
       if (ArgIndices.size() == 1 && ArgIndices.begin()->empty())
         ++NumArgumentsPromoted;
@@ -428,7 +428,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
           Value *V = *AI;
           LoadInst *OrigLoad = OriginalLoads[*SI];
           if (!SI->empty()) {
-            V = new GetElementPtrInst(V, &(*SI)[0], SI->size(),
+            V = new GetElementPtrInst(V, SI->begin(), SI->end(),
                                       V->getName()+".idx", Call);
             AA.copyValue(OrigLoad->getOperand(0), V);
           }
@@ -447,7 +447,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
     Instruction *New;
     if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
       New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
-                           &Args[0], Args.size(), "", Call);
+                           Args.begin(), Args.end(), "", Call);
       cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
     } else {
       New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
@@ -519,7 +519,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
           std::string NewName = I->getName();
           for (unsigned i = 0, e = Operands.size(); i != e; ++i)
             if (ConstantInt *CI = dyn_cast<ConstantInt>(Operands[i]))
-              NewName += "." + CI->getValue().toString(10);
+              NewName += "." + CI->getValue().toStringUnsigned(10);
             else
               NewName += ".x";
           TheArg->setName(NewName+".val");