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

Chris Lattner clattner at apple.com
Tue Jun 30 17:45:11 PDT 2009


On Jun 30, 2009, at 4:53 PM, Dale Johannesen wrote:

> Author: johannes
> Date: Tue Jun 30 18:53:04 2009
> New Revision: 74575
>
> URL: http://llvm.org/viewvc/llvm-project?rev=74575&view=rev
> Log:
> Fix buildbreaking nonstandardism.  (And I thought I'd
> never complain C++ doesn't have enough features...)

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.

-Chris

>
>
> Modified:
>    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=74575&r1=74574&r2=74575&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Jun 30 18:53:04 2009
> @@ -4010,11 +4010,12 @@
> {
>   int MaxWeight = 0;
>   unsigned int CommasToSkip = 0;
> -  int Weights[NumChoices];
> +  int *Weights = (int *)alloca(NumChoices * sizeof(int));
>   // RunningConstraints is pointers into the Constraints strings which
>   // are incremented as we go to point to the beginning of each
>   // comma-separated alternative.
> -  const char* RunningConstraints[NumInputs+NumOutputs];
> +  const char** RunningConstraints =
> +    (const char**)alloca((NumInputs+NumOutputs)*sizeof(const char*));
>   memcpy(RunningConstraints, Constraints,
>          (NumInputs+NumOutputs) * sizeof(const char*));
>   // The entire point of this loop is to compute CommasToSkip.
>
>
> _______________________________________________
> 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