[llvm-commits] [llvm-gcc-4.2] r74575 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Dale Johannesen dalej at apple.com
Wed Jul 1 15:55:27 PDT 2009


On Jul 1, 2009, at 4:54 AMPDT, Duncan Sands wrote:

> Hi Dale,
>
>>>> It's not that big of a deal, but please use SmallVector<int, 4> or
>>>> something instead of alloca.  SmallVector works when "N" is more  
>>>> than
>>>> 4 by going to the heap so you won't run out of stack space for  
>>>> large
>>>> N, and is more portable.
>>> I am not a big lover of alloca, but it was used several places in  
>>> this
>>> code before I started working on it so I don't think portability can
>>> be a problem, and the numbers involved cannot be big enough to run  
>>> out
>>> of stack space.
>>
>> Ok, works for me.  Please don't use it in normal llvm code though,
>> llvm-gcc is fine.
>
> it was used in two places in the llvm parts of llvm-gcc before.  Since
> the llvm style is to use SmallVector, can you please modify all places
> to use SmallVector instead of alloca.


There is actually a good reason to use alloca in all these cases.  We  
know the exact number of elements at runtime, but not at compile  
time.  Using SmallVector would either waste stack space, or require  
heap allocations, depending on which way we guessed wrong.   There's  
no good reason to do that, so I'm going to leave it alone.




More information about the llvm-commits mailing list