[llvm-commits] [llvm] r40660 - in /llvm/trunk: include/llvm/ include/llvm/Support/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/ExecutionEngine/JIT/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/ tools/llvm-upgrade/

Chandler Carruth chandlerc at gmail.com
Wed Aug 1 18:43:43 CDT 2007


You missed one client, the indirect usage by llvm2cpp, which _generates_
calls to CallInst, but doesn't make them directly. It is currently
generating calls to the old API, and causes test/Feature/llvm2cpp to fail.

-Chandler

David Greene wrote:
> Author: greened
> Date: Tue Jul 31 22:43:44 2007
> New Revision: 40660
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=40660&view=rev
> Log:
> 
> New CallInst interface to address GLIBCXX_DEBUG errors caused by
> indexing an empty std::vector.
> 
> Updates to all clients.
> 
> Modified:
>     llvm/trunk/include/llvm/Instructions.h
>     llvm/trunk/include/llvm/Support/LLVMBuilder.h
>     llvm/trunk/lib/AsmParser/llvmAsmParser.y
>     llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
>     llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp
>     llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
>     llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
>     llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
>     llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp
>     llvm/trunk/lib/Transforms/IPO/PruneEH.cpp
>     llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp
>     llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp
>     llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
>     llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
>     llvm/trunk/lib/Transforms/Scalar/LowerGC.cpp
>     llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
>     llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
>     llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
>     llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
>     llvm/trunk/lib/VMCore/Instructions.cpp
>     llvm/trunk/tools/bugpoint/Miscompilation.cpp
>     llvm/trunk/tools/llvm-upgrade/UpgradeParser.y
> 
> Modified: llvm/trunk/include/llvm/Instructions.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/include/llvm/Instructions.h (original)
> +++ llvm/trunk/include/llvm/Instructions.h Tue Jul 31 22:43:44 2007
> @@ -16,7 +16,10 @@
>  #ifndef LLVM_INSTRUCTIONS_H
>  #define LLVM_INSTRUCTIONS_H
>  
> +#include <iterator>
> +
>  #include "llvm/InstrTypes.h"
> +#include "llvm/DerivedTypes.h"
>  
>  namespace llvm {
>  
> @@ -735,12 +738,12 @@
>  //===----------------------------------------------------------------------===//
>  //                                 CallInst Class
>  //===----------------------------------------------------------------------===//
> -
>  /// CallInst - This class represents a function call, abstracting a target
>  /// machine's calling convention.  This class uses low bit of the SubClassData
>  /// field to indicate whether or not this is a tail call.  The rest of the bits
>  /// hold the calling convention of the call.
>  ///
> +
>  class CallInst : public Instruction {
>    ParamAttrsList *ParamAttrs; ///< parameter attributes for call
>    CallInst(const CallInst &CI);
> @@ -749,18 +752,73 @@
>    void init(Value *Func, Value *Actual);
>    void init(Value *Func);
>  
> +  template<typename InputIterator>
> +  void init(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
> +            const std::string &Name,
> +            // This argument ensures that we have an iterator we can
> +            // do arithmetic on in constant time
> +            std::random_access_iterator_tag) {
> +    typename std::iterator_traits<InputIterator>::difference_type NumArgs = 
> +      std::distance(ArgBegin, ArgEnd);
> +    
> +    if (NumArgs > 0) {
> +      // This requires that the iterator points to contiguous memory.
> +      init(Func, &*ArgBegin, NumArgs);
> +    }
> +    else {
> +      init(Func, 0, NumArgs);
> +    }
> +    
> +    setName(Name);
> +  }
> +
>  public:
> +  /// Construct a CallInst given a range of arguments.  InputIterator
> +  /// must be a random-access iterator pointing to contiguous storage
> +  /// (e.g. a std::vector<>::iterator).  Checks are made for
> +  /// random-accessness but not for contiguous storage as that would
> +  /// incur runtime overhead.
> +  /// @brief Construct a CallInst from a range of arguments
> +  template<typename InputIterator>
> +  CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
> +           const std::string &Name = "", Instruction *InsertBefore = 0)
> +      : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
> +                                       ->getElementType())->getReturnType(),
> +                    Instruction::Call, 0, 0, InsertBefore) {
> +    init(Func, ArgBegin, ArgEnd, Name, 
> +         typename std::iterator_traits<InputIterator>::iterator_category());
> +  }
> +
> +  /// Construct a CallInst given a range of arguments.  InputIterator
> +  /// must be a random-access iterator pointing to contiguous storage
> +  /// (e.g. a std::vector<>::iterator).  Checks are made for
> +  /// random-accessness but not for contiguous storage as that would
> +  /// incur runtime overhead.
> +  /// @brief Construct a CallInst from a range of arguments
> +  template<typename InputIterator>
> +  CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
> +           const std::string &Name, BasicBlock *InsertAtEnd)
> +      : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
> +                                       ->getElementType())->getReturnType(),
> +                    Instruction::Call, 0, 0, InsertAtEnd) {
> +    init(Func, ArgBegin, ArgEnd, Name,
> +         typename std::iterator_traits<InputIterator>::iterator_category());
> +  }
> +
> +#if 0
> +  // Leave these here for llvm-gcc
>    CallInst(Value *F, Value* const *Args, unsigned NumArgs,
>             const std::string &Name = "", Instruction *InsertBefore = 0);
>    CallInst(Value *F, Value *const *Args, unsigned NumArgs,
>             const std::string &Name, BasicBlock *InsertAtEnd);
> -  
> +
>    // Alternate CallInst ctors w/ two actuals, w/ one actual and no
>    // actuals, respectively.
>    CallInst(Value *F, Value *Actual1, Value *Actual2,
>             const std::string& Name = "", Instruction *InsertBefore = 0);
>    CallInst(Value *F, Value *Actual1, Value *Actual2,
>             const std::string& Name, BasicBlock *InsertAtEnd);
> +#endif
>    CallInst(Value *F, Value *Actual, const std::string& Name = "",
>             Instruction *InsertBefore = 0);
>    CallInst(Value *F, Value *Actual, const std::string& Name,
> 
> Modified: llvm/trunk/include/llvm/Support/LLVMBuilder.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LLVMBuilder.h?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/LLVMBuilder.h (original)
> +++ llvm/trunk/include/llvm/Support/LLVMBuilder.h Tue Jul 31 22:43:44 2007
> @@ -380,22 +380,31 @@
>    }
>  
>    CallInst *CreateCall(Value *Callee, const char *Name = "") {
> -    return Insert(new CallInst(Callee, (Value**)0, 0, Name));
> +    return Insert(new CallInst(Callee, Name));
>    }
>    CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = "") {
> -    return Insert(new CallInst(Callee, &Arg, 1, Name));
> +    return Insert(new CallInst(Callee, Arg, Name));
>    }
> -  CallInst *CreateCall(Value *Callee, Value *Arg0, Value *Arg1,
> +
> +  template<typename InputIterator>
> +  CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, InputIterator ArgEnd,
>                         const char *Name = "") {
> -    Value *Args[] = { Arg0, Arg1 };
> -    return Insert(new CallInst(Callee, Args, 2, Name));
> +    return(Insert(new CallInst(Callee, ArgBegin, ArgEnd, Name)));
>    }
>    
> -  
> +#if 0
> +   CallInst *CreateCall(Value *Callee, Value *Arg0, Value *Arg1,
> +                        const char *Name = "") {
> +     Value *Args[] = { Arg0, Arg1 };
> +     return Insert(new CallInst(Callee, Args, Args+2, Name));
> +   }
> +
> +  // Leave this here for llvm-gcc
>    CallInst *CreateCall(Value *Callee, Value* const *Args, unsigned NumArgs,
>                         const char *Name = "") {
> -    return Insert(new CallInst(Callee, Args, NumArgs, Name));
> +    return Insert(new CallInst(Callee, Args, Args+NumArgs, Name));
>    }
> +#endif
>    
>    SelectInst *CreateSelect(Value *C, Value *True, Value *False,
>                             const char *Name = "") {
> 
> Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original)
> +++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Tue Jul 31 22:43:44 2007
> @@ -2958,7 +2958,7 @@
>          GEN_ERROR("Invalid number of parameters detected");
>      }
>      // Create the call node
> -    CallInst *CI = new CallInst(V, &Args[0], Args.size());
> +    CallInst *CI = new CallInst(V, Args.begin(), Args.end());
>      CI->setTailCall($1);
>      CI->setCallingConv($2);
>      $$ = CI;
> 
> Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jul 31 22:43:44 2007
> @@ -1499,7 +1499,7 @@
>          }
>        }
>        
> -      I = new CallInst(Callee, &Args[0], Args.size());
> +      I = new CallInst(Callee, Args.begin(), Args.end());
>        cast<CallInst>(I)->setCallingConv(CCInfo>>1);
>        cast<CallInst>(I)->setTailCall(CCInfo & 1);
>        break;
> 
> Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original)
> +++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Tue Jul 31 22:43:44 2007
> @@ -53,8 +53,8 @@
>                                      FunctionType::get(RetTy, ParamTys, false));
>    }
>  
> -  SmallVector<Value*, 8> Operands(ArgBegin, ArgEnd);
> -  CallInst *NewCI = new CallInst(FCache, &Operands[0], Operands.size(),
> +  SmallVector<Value *, 8> Args(ArgBegin, ArgEnd);
> +  CallInst *NewCI = new CallInst(FCache, Args.begin(), Args.end(),
>                                   CI->getName(), CI);
>    if (!CI->use_empty())
>      CI->replaceAllUsesWith(NewCI);
> @@ -421,7 +421,7 @@
>      CI->getOperand(2),
>      CI->getOperand(3)
>    };
> -  return new CallInst(F, Args, sizeof(Args)/sizeof(Args[0]), CI->getName(), CI);
> +  return new CallInst(F, Args, Args+sizeof(Args)/sizeof(Args[0]), CI->getName(), CI);
>  }
>  
>  /// Convert the llvm.part.set.iX.iY.iZ intrinsic. This intrinsic takes 
> @@ -587,7 +587,7 @@
>      CI->getOperand(3),
>      CI->getOperand(4)
>    };
> -  return new CallInst(F, Args, sizeof(Args)/sizeof(Args[0]), CI->getName(), CI);
> +  return new CallInst(F, Args, Args+sizeof(Args)/sizeof(Args[0]), CI->getName(), CI);
>  }
>  
>  
> 
> Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Tue Jul 31 22:43:44 2007
> @@ -224,7 +224,7 @@
>      Args.push_back(C);
>    }
>  
> -  CallInst *TheCall = new CallInst(F, &Args[0], Args.size(), "", StubBB);
> +  CallInst *TheCall = new CallInst(F, Args.begin(), Args.end(), "", StubBB);
>    TheCall->setTailCall();
>    if (TheCall->getType() != Type::VoidTy)
>      new ReturnInst(TheCall, StubBB);             // Return result of the call.
> 
> Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Tue Jul 31 22:43:44 2007
> @@ -450,7 +450,7 @@
>                             &Args[0], Args.size(), "", Call);
>        cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
>      } else {
> -      New = new CallInst(NF, &Args[0], Args.size(), "", Call);
> +      New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
>        cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
>        if (cast<CallInst>(Call)->isTailCall())
>          cast<CallInst>(New)->setTailCall();
> 
> Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Tue Jul 31 22:43:44 2007
> @@ -177,7 +177,7 @@
>                             &Args[0], Args.size(), "", Call);
>        cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
>      } else {
> -      New = new CallInst(NF, &Args[0], Args.size(), "", Call);
> +      New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
>        cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
>        if (cast<CallInst>(Call)->isTailCall())
>          cast<CallInst>(New)->setTailCall();
> @@ -543,7 +543,7 @@
>                             &Args[0], Args.size(), "", Call);
>        cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
>      } else {
> -      New = new CallInst(NF, &Args[0], Args.size(), "", Call);
> +      New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
>        cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
>        if (cast<CallInst>(Call)->isTailCall())
>          cast<CallInst>(New)->setTailCall();
> 
> Modified: llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp Tue Jul 31 22:43:44 2007
> @@ -49,6 +49,7 @@
>  #include "llvm/ADT/Statistic.h"
>  #include "llvm/ADT/StringExtras.h"
>  #include "llvm/ADT/VectorExtras.h"
> +#include "llvm/ADT/SmallVector.h"
>  using namespace llvm;
>  
>  STATISTIC(LongJmpsTransformed, "Number of longjmps transformed");
> @@ -263,7 +264,10 @@
>    // Inst's uses and doesn't get a name.
>    CastInst* CI = 
>      new BitCastInst(Inst->getOperand(1), SBPTy, "LJBuf", Inst);
> -  new CallInst(ThrowLongJmp, CI, Inst->getOperand(2), "", Inst);
> +  SmallVector<Value *, 2> Args;
> +  Args.push_back(CI);
> +  Args.push_back(Inst->getOperand(2));
> +  new CallInst(ThrowLongJmp, Args.begin(), Args.end(), "", Inst);
>  
>    SwitchValuePair& SVP = SwitchValMap[Inst->getParent()->getParent()];
>  
> @@ -381,7 +385,7 @@
>      make_vector<Value*>(GetSetJmpMap(Func), BufPtr,
>                          ConstantInt::get(Type::Int32Ty,
>                                           SetJmpIDMap[Func]++), 0);
> -  new CallInst(AddSJToMap, &Args[0], Args.size(), "", Inst);
> +  new CallInst(AddSJToMap, Args.begin(), Args.end(), "", Inst);
>  
>    // We are guaranteed that there are no values live across basic blocks
>    // (because we are "not in SSA form" yet), but there can still be values live
> 
> Modified: llvm/trunk/lib/Transforms/IPO/PruneEH.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PruneEH.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/PruneEH.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/PruneEH.cpp Tue Jul 31 22:43:44 2007
> @@ -153,7 +153,7 @@
>            SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
>            // Insert a call instruction before the invoke.
>            CallInst *Call = new CallInst(II->getCalledValue(),
> -                                        &Args[0], Args.size(), "", II);
> +                                        Args.begin(), Args.end(), "", II);
>            Call->takeName(II);
>            Call->setCallingConv(II->getCallingConv());
>  
> 
> Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Tue Jul 31 22:43:44 2007
> @@ -509,7 +509,7 @@
>        ConstantInt::get(SLC.getIntPtrType(), SrcStr.size()+1), // copy nul byte.
>        ConstantInt::get(Type::Int32Ty, 1)  // alignment
>      };
> -    new CallInst(SLC.get_memcpy(), Vals, 4, "", CI);
> +    new CallInst(SLC.get_memcpy(), Vals, Vals + 4, "", CI);
>  
>      return ReplaceCallWith(CI, Dst);
>    }
> @@ -549,7 +549,7 @@
>          CI->getOperand(2),
>          ConstantInt::get(SLC.getIntPtrType(), Str.size()+1)
>        };
> -      return ReplaceCallWith(CI, new CallInst(SLC.get_memchr(), Args, 3,
> +      return ReplaceCallWith(CI, new CallInst(SLC.get_memchr(), Args, Args + 3,
>                                                CI->getName(), CI));
>      }
>  
> @@ -752,7 +752,7 @@
>        ConstantInt::get(SLC.getIntPtrType(), SrcStr.size()+1),
>        ConstantInt::get(Type::Int32Ty, 1) // alignment
>      };
> -    new CallInst(SLC.get_memcpy(), MemcpyOps, 4, "", CI);
> +    new CallInst(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI);
>  
>      return ReplaceCallWith(CI, Dst);
>    }
> @@ -1294,7 +1294,7 @@
>          ConstantInt::get(SLC.getIntPtrType(), 1),
>          CI->getOperand(1)
>        };
> -      new CallInst(SLC.get_fwrite(FILEty), FWriteArgs, 4, CI->getName(), CI);
> +      new CallInst(SLC.get_fwrite(FILEty), FWriteArgs, FWriteArgs + 4, CI->getName(), CI);
>        return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 
>                                                    FormatStr.size()));
>      }
> @@ -1311,7 +1311,10 @@
>        const Type *FILETy = CI->getOperand(1)->getType();
>        Value *C = CastInst::createZExtOrBitCast(CI->getOperand(3), Type::Int32Ty,
>                                                 CI->getName()+".int", CI);
> -      new CallInst(SLC.get_fputc(FILETy), C, CI->getOperand(1), "", CI);
> +      SmallVector<Value *, 2> Args;
> +      Args.push_back(C);
> +      Args.push_back(CI->getOperand(1));
> +      new CallInst(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
>        return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
>      }
>      case 's': {
> @@ -1323,8 +1326,11 @@
>          return false;
>        
>        // fprintf(file,"%s",str) -> fputs(str,file)
> -      new CallInst(SLC.get_fputs(FILETy), CastToCStr(CI->getOperand(3), CI),
> -                   CI->getOperand(1), CI->getName(), CI);
> +      SmallVector<Value *, 2> Args;
> +      Args.push_back(CastToCStr(CI->getOperand(3), CI));
> +      Args.push_back(CI->getOperand(1));
> +      new CallInst(SLC.get_fputs(FILETy), Args.begin(),
> +                   Args.end(), CI->getName(), CI);
>        return ReplaceCallWith(CI, 0);
>      }
>      default:
> @@ -1375,7 +1381,7 @@
>                           FormatStr.size()+1), // Copy the nul byte.
>          ConstantInt::get(Type::Int32Ty, 1)
>        };
> -      new CallInst(SLC.get_memcpy(), MemCpyArgs, 4, "", CI);
> +      new CallInst(SLC.get_memcpy(), MemCpyArgs, MemCpyArgs + 4, "", CI);
>        return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 
>                                                    FormatStr.size()));
>      }
> @@ -1412,7 +1418,7 @@
>          Len,
>          ConstantInt::get(Type::Int32Ty, 1)
>        };
> -      new CallInst(SLC.get_memcpy(), MemcpyArgs, 4, "", CI);
> +      new CallInst(SLC.get_memcpy(), MemcpyArgs, MemcpyArgs + 4, "", CI);
>        
>        // The strlen result is the unincremented number of bytes in the string.
>        if (!CI->use_empty()) {
> @@ -1464,7 +1470,7 @@
>        ConstantInt::get(SLC.getIntPtrType(), 1),
>        CI->getOperand(2)
>      };
> -    new CallInst(SLC.get_fwrite(FILETy), FWriteParms, 4, "", CI);
> +    new CallInst(SLC.get_fwrite(FILETy), FWriteParms, FWriteParms + 4, "", CI);
>      return ReplaceCallWith(CI, 0);  // Known to have no uses (see above).
>    }
>  } FPutsOptimizer;
> @@ -1505,12 +1511,14 @@
>      
>      // If this is writing one byte, turn it into fputc.
>      if (EltSize == 1 && EltCount == 1) {
> +      SmallVector<Value *, 2> Args;
>        // fwrite(s,1,1,F) -> fputc(s[0],F)
>        Value *Ptr = CI->getOperand(1);
>        Value *Val = new LoadInst(Ptr, Ptr->getName()+".byte", CI);
> -      Val = new ZExtInst(Val, Type::Int32Ty, Val->getName()+".int", CI);
> +      Args.push_back(new ZExtInst(Val, Type::Int32Ty, Val->getName()+".int", CI));
> +      Args.push_back(CI->getOperand(4));
>        const Type *FILETy = CI->getOperand(4)->getType();
> -      new CallInst(SLC.get_fputc(FILETy), Val, CI->getOperand(4), "", CI);
> +      new CallInst(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
>        return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
>      }
>      return false;
> 
> Modified: llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp (original)
> +++ llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp Tue Jul 31 22:43:44 2007
> @@ -54,7 +54,7 @@
>    }
>    Args[3] = ConstantInt::get(Type::Int32Ty, NumElements);
>  
> -  Instruction *InitCall = new CallInst(InitFn, &Args[0], Args.size(),
> +  Instruction *InitCall = new CallInst(InitFn, Args.begin(), Args.end(),
>                                         "newargc", InsertPos);
>  
>    // If argc or argv are not available in main, just pass null values in.
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ADCE.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/ADCE.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/ADCE.cpp Tue Jul 31 22:43:44 2007
> @@ -194,7 +194,7 @@
>            // The function cannot unwind.  Convert it to a call with a branch
>            // after it to the normal destination.
>            SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
> -          CallInst *NewCall = new CallInst(F, &Args[0], Args.size(), "", II);
> +          CallInst *NewCall = new CallInst(F, Args.begin(), Args.end(), "", II);
>            NewCall->takeName(II);
>            NewCall->setCallingConv(II->getCallingConv());
>            II->replaceAllUsesWith(NewCall);
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jul 31 22:43:44 2007
> @@ -7978,7 +7978,7 @@
>                          &Args[0], Args.size(), Caller->getName(), Caller);
>      cast<InvokeInst>(NC)->setCallingConv(II->getCallingConv());
>    } else {
> -    NC = new CallInst(Callee, &Args[0], Args.size(), Caller->getName(), Caller);
> +    NC = new CallInst(Callee, Args.begin(), Args.end(), Caller->getName(), Caller);
>      if (cast<CallInst>(Caller)->isTailCall())
>        cast<CallInst>(NC)->setTailCall();
>     cast<CallInst>(NC)->setCallingConv(cast<CallInst>(Caller)->getCallingConv());
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/LowerGC.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LowerGC.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/LowerGC.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/LowerGC.cpp Tue Jul 31 22:43:44 2007
> @@ -27,6 +27,7 @@
>  #include "llvm/Module.h"
>  #include "llvm/Pass.h"
>  #include "llvm/Support/Compiler.h"
> +#include "llvm/ADT/SmallVector.h"
>  using namespace llvm;
>  
>  namespace {
> @@ -197,8 +198,18 @@
>                  CI->setOperand(0, GCRead);
>                } else {
>                  // Create a whole new call to replace the old one.
> -                CallInst *NC = new CallInst(GCRead, CI->getOperand(1),
> -                                            CI->getOperand(2),
> +                
> +                // It sure would be nice to pass op_begin()+1,
> +                // op_begin()+2 but it runs into trouble with
> +                // CallInst::init's &*ierator, which requires a
> +                // conversion from Use* to Value*.  The conversion
> +                // from Use to Value * is not useful because the
> +                // memory for Value * won't be contiguous.
> +                SmallVector<Value *, 2> Args;
> +                Args.push_back(CI->getOperand(1));
> +                Args.push_back(CI->getOperand(2));
> +                CallInst *NC = new CallInst(GCRead, Args.begin(),
> +                                            Args.end(),
>                                              CI->getName(), CI);
>                  // These functions only deal with ptr type results so BitCast
>                  // is the correct kind of cast (no-op cast).
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Tue Jul 31 22:43:44 2007
> @@ -709,7 +709,7 @@
>            ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size
>            Zero  // Align
>          };
> -        new CallInst(TheFn, Ops, 4, "", MI);
> +        new CallInst(TheFn, Ops, Ops + 4, "", MI);
>        } else {
>          assert(isa<MemSetInst>(MI));
>          Value *Ops[] = {
> @@ -717,7 +717,7 @@
>            ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size
>            Zero  // Align
>          };
> -        new CallInst(TheFn, Ops, 4, "", MI);
> +        new CallInst(TheFn, Ops, Ops + 4, "", MI);
>        }
>      }
>  
> 
> Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Tue Jul 31 22:43:44 2007
> @@ -393,7 +393,7 @@
>    }
>  
>    // Emit the call to the function
> -  CallInst *call = new CallInst(newFunction, &params[0], params.size(),
> +  CallInst *call = new CallInst(newFunction, params.begin(), params.end(),
>                                  NumExitBlocks > 1 ? "targetBlock" : "");
>    codeReplacer->getInstList().push_back(call);
>  
> 
> Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Tue Jul 31 22:43:44 2007
> @@ -212,7 +212,7 @@
>        std::vector<Value*> CallArgs(II->op_begin()+3, II->op_end());
>        // Insert a normal call instruction...
>        CallInst *NewCall = new CallInst(II->getCalledValue(),
> -                                       &CallArgs[0], CallArgs.size(), "", II);
> +                                       CallArgs.begin(), CallArgs.end(), "", II);
>        NewCall->takeName(II);
>        NewCall->setCallingConv(II->getCallingConv());
>        II->replaceAllUsesWith(NewCall);
> @@ -269,7 +269,7 @@
>    // Insert a normal call instruction.
>    std::vector<Value*> CallArgs(II->op_begin()+3, II->op_end());
>    CallInst *NewCall = new CallInst(II->getCalledValue(),
> -                                   &CallArgs[0], CallArgs.size(), "",
> +                                   CallArgs.begin(), CallArgs.end(), "",
>                                     II);
>    NewCall->takeName(II);
>    NewCall->setCallingConv(II->getCallingConv());
> @@ -542,7 +542,7 @@
>    Idx.push_back(ConstantInt::get(Type::Int32Ty, 0));
>    Idx[0] = new GetElementPtrInst(BufPtr, &Idx[0], 2, "JmpBuf", UnwindBlock);
>    Idx[1] = ConstantInt::get(Type::Int32Ty, 1);
> -  new CallInst(LongJmpFn, &Idx[0], Idx.size(), "", UnwindBlock);
> +  new CallInst(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock);
>    new UnreachableInst(UnwindBlock);
>    
>    // Set up the term block ("throw without a catch").
> 
> Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Tue Jul 31 22:43:44 2007
> @@ -1374,7 +1374,7 @@
>            // Insert the call now...
>            SmallVector<Value*,8> Args(II->op_begin()+3, II->op_end());
>            CallInst *CI = new CallInst(II->getCalledValue(),
> -                                      &Args[0], Args.size(), II->getName(), BI);
> +                                      Args.begin(), Args.end(), II->getName(), BI);
>            CI->setCallingConv(II->getCallingConv());
>            // If the invoke produced a value, the Call now does instead
>            II->replaceAllUsesWith(CI);
> @@ -1748,7 +1748,7 @@
>              // Insert the call now...
>              SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
>              CallInst *CI = new CallInst(II->getCalledValue(),
> -                                        &Args[0], Args.size(),
> +                                        Args.begin(), Args.end(),
>                                          II->getName(), BI);
>              CI->setCallingConv(II->getCallingConv());
>              // If the invoke produced a value, the Call does now instead.
> 
> Modified: llvm/trunk/lib/VMCore/Instructions.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/VMCore/Instructions.cpp (original)
> +++ llvm/trunk/lib/VMCore/Instructions.cpp Tue Jul 31 22:43:44 2007
> @@ -267,19 +267,21 @@
>    assert(FTy->getNumParams() == 0 && "Calling a function with bad signature");
>  }
>  
> +#if 0
> +// Leave for llvm-gcc
>  CallInst::CallInst(Value *Func, Value* const *Args, unsigned NumArgs,
>                     const std::string &Name, BasicBlock *InsertAtEnd)
>    : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
> -                                 ->getElementType())->getReturnType(),
> +                                     ->getElementType())->getReturnType(),
>                  Instruction::Call, 0, 0, InsertAtEnd) {
>    init(Func, Args, NumArgs);
>    setName(Name);
>  }
>  CallInst::CallInst(Value *Func, Value* const *Args, unsigned NumArgs,
>                     const std::string &Name, Instruction *InsertBefore)
> -: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
> -                                 ->getElementType())->getReturnType(),
> -              Instruction::Call, 0, 0, InsertBefore) {
> +    : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
> +                                     ->getElementType())->getReturnType(),
> +                  Instruction::Call, 0, 0, InsertBefore) {
>    init(Func, Args, NumArgs);
>    setName(Name);
>  }
> @@ -301,7 +303,7 @@
>    init(Func, Actual1, Actual2);
>    setName(Name);
>  }
> -
> +#endif
>  CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
>                     Instruction *InsertBefore)
>    : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
> @@ -319,7 +321,6 @@
>    init(Func, Actual);
>    setName(Name);
>  }
> -
>  CallInst::CallInst(Value *Func, const std::string &Name,
>                     Instruction *InsertBefore)
>    : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
> 
> Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original)
> +++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Tue Jul 31 22:43:44 2007
> @@ -663,7 +663,7 @@
>  
>        // Call the old main function and return its result
>        BasicBlock *BB = new BasicBlock("entry", newMain);
> -      CallInst *call = new CallInst(oldMainProto, &args[0], args.size(),
> +      CallInst *call = new CallInst(oldMainProto, args.begin(), args.end(),
>                                      "", BB);
>  
>        // If the type of old function wasn't void, return value of call
> @@ -734,8 +734,8 @@
>            // Resolve the call to function F via the JIT API:
>            //
>            // call resolver(GetElementPtr...)
> -          CallInst *Resolver = new CallInst(resolverFunc, &ResolverArgs[0],
> -                                            ResolverArgs.size(),
> +          CallInst *Resolver = new CallInst(resolverFunc, ResolverArgs.begin(),
> +                                            ResolverArgs.end(),
>                                              "resolver", LookupBB);
>            // cast the result from the resolver to correctly-typed function
>            CastInst *CastedResolver = new BitCastInst(Resolver, 
> @@ -757,10 +757,10 @@
>  
>            // Pass on the arguments to the real function, return its result
>            if (F->getReturnType() == Type::VoidTy) {
> -            new CallInst(FuncPtr, &Args[0], Args.size(), "", DoCallBB);
> +            new CallInst(FuncPtr, Args.begin(), Args.end(), "", DoCallBB);
>              new ReturnInst(DoCallBB);
>            } else {
> -            CallInst *Call = new CallInst(FuncPtr, &Args[0], Args.size(),
> +            CallInst *Call = new CallInst(FuncPtr, Args.begin(), Args.end(),
>                                            "retval", DoCallBB);
>              new ReturnInst(Call, DoCallBB);
>            }
> 
> Modified: llvm/trunk/tools/llvm-upgrade/UpgradeParser.y
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-upgrade/UpgradeParser.y?rev=40660&r1=40659&r2=40660&view=diff
> 
> ==============================================================================
> --- llvm/trunk/tools/llvm-upgrade/UpgradeParser.y (original)
> +++ llvm/trunk/tools/llvm-upgrade/UpgradeParser.y Tue Jul 31 22:43:44 2007
> @@ -1513,7 +1513,7 @@
>          const PointerType *PFTy = PointerType::get(FTy);
>          Value* Func = getVal(PFTy, ID);
>          Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
> -        return new CallInst(Func, &Args[0], Args.size());
> +        return new CallInst(Func, Args.begin(), Args.end());
>        } else if (Name == "llvm.va_copy") {
>          if (Args.size() != 2)
>            error("Invalid prototype for " + Name + " prototype");
> @@ -1527,7 +1527,7 @@
>          std::string InstName1(makeNameUnique("va1"));
>          Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
>          Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
> -        return new CallInst(Func, &Args[0], Args.size());
> +        return new CallInst(Func, Args.begin(), Args.end());
>        }
>      }
>    }
> @@ -1751,11 +1751,12 @@
>  
>        while (!F->use_empty()) {
>          CallInst* CI = cast<CallInst>(F->use_back());
> -        AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
> -        AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
> -        new StoreInst(CI->getOperand(1), b, CI);
> -        new CallInst(NF, a, b, "", CI);
> -        Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
> +        SmallVector<Value *, 2> Args;
> +        Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI));
> +        Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI));
> +        new StoreInst(CI->getOperand(1), Args[1], CI);
> +        new CallInst(NF, Args.begin(), Args.end(), "", CI);
> +        Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI);
>          CI->replaceAllUsesWith(foo);
>          CI->getParent()->getInstList().erase(CI);
>        }
> @@ -3806,7 +3807,7 @@
>        }
>  
>        // Create the call instruction
> -      CallInst *CI = new CallInst(V, &Args[0], Args.size());
> +      CallInst *CI = new CallInst(V, Args.begin(), Args.end());
>        CI->setTailCall($1);
>        CI->setCallingConv(upgradeCallingConv($2));
>        $$.I = CI;
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list