[LLVMdev] Fix for non-standard variable length array

Morten Ofstad morten at hue.no
Mon Oct 18 06:12:06 PDT 2004


In lib/CodeGen/LiveVariables.cpp a variable length array is created. 
Since this is not standard C++, it won't compile with Visual Studio (for 
interested readers, there is a discussion of why the C99 style variable 
length array is a bad idea in C++ here: 
http://www.cuj.com/documents/s=8191/cuj0209stroustr/) I have made a 
patch that uses 'new' and 'delete' instead - if this is unacceptable for 
performance reasons, I suggest just choosing some fixed size for the 
arrays (128 for example) and asserting that the actual number of 
registers is smaller than this. Patch follows.

On a side note I can now run the fibonacci example with the x86 backend 
compiled with Visual C -- For fun I compiled the fibonacci function also 
with Visual C with max. optimizes, and the LLVM compiled version is 
slightly faster! I'm impressed! More patches will follow, sorry for 
flooding...

m.





More information about the llvm-dev mailing list