[LLVMdev] PHP Zend LLVM extension (SoC)

Chris Lattner sabre at nondot.org
Wed Apr 23 22:54:38 PDT 2008

On Apr 23, 2008, at 10:49 PM, Owen Anderson wrote:

> On Apr 23, 2008, at 1:44 PM, Nuno Lopes wrote:
>> Thank you both for your answers!
>> That part of type inference was my second question. PHP uses a  
>> structure
>> with a union to represent a variable (because a variable can have  
>> different
>> types, like a long, a double, a stream, etc..), but often a single  
>> variable
>> will only have one type throughout the program (e.g. iterating  
>> through $i in
>> a loop). Will LLVM automagically see that we always use the same  
>> type for a
>> certain variable and discard the whole union and use a single  
>> scalar (and
>> also discard all the type checking done in the opcode handlers)? We  
>> can do
>> some type inference on our side if we do a pass on the bytecode,  
>> but I would
>> like to be sure if that's needed or if LLVM will do it on its own.
> LLVM likely won't be able to do type inference for you.

I'd put it another way: an existing llvm pass won't do type inference  
for you.  The right way to tackle this is to write an language- 
specific pass on LLVM IR that knows your runtime and can propagate  
types around.


More information about the llvm-dev mailing list