[LLVMdev] use of CallInst()

Gordon Henriksen gordonhenriksen at mac.com
Wed Mar 7 07:06:02 PST 2007

On 2007-03-07, at 06:18, Ryan M. Lefever wrote:

>> Args needs to be an array of the arguments and NumArgs needs to be  
>> the size of the array. If you have a std::vector then you can just:
>> new CallInst(F, &ArgVec[0], ArgVec.size(), ...)
> Doesn't the code above make an assumption about how std::vector is  
> implemented? That should only work if the std::vector<Value*> is  
> implemented using an array of Value*s.  I looked at the  
> documentation for STL and did not see anything about vector being  
> guaranteed to be implemented as an array.

All pertinent implementations of the STL do in fact make this guarantee.

> why was direct support for a std:vector<Value*> removed from the  
> CallInst constructor?

To allow the use of SmallVector instead of std::vector, which avoids  
a temporary heap allocation for a significant speedup.

— Gordon

More information about the llvm-dev mailing list