[LLVMdev] Issues with IPO optimization passes and JIT

Samit Basu basu.samit at gmail.com
Tue Jan 22 22:55:05 PST 2008


I am working on an LLVM-based JIT for a dynamically typed language
(freemat.sf.net), and would like to commend the LLVM team on an
awesome piece of work.  One issue I ran into that I was hoping for
some clarification.  Nominally, I had started out by performing code
generation from the AST into a function that was added to the current
module.  I then ran a PassManager on that module to optimize the
function -- this included several IPO passes (the entire list from -O3
for opt, in fact).  I ran the optimizer after each function was
generated.   I found that when I tried to execute functions via the
JIT, I got unexpected and incorrect results -- for example, calling
Invoke on a function would execute the wrong function.  The only
solution was to replace the PassManager with a FunctionPassManager
(following the example in the tutorial), and keep only basic block and
function-level optimization steps.  Is this expected behavior?  Is it
documented?  Should it be considered a bug?

Thanks in advance for any clarification.

More information about the llvm-dev mailing list