Hello,
I now have a working installation of LLVM under Vista/Cygwin and I can play with it. First of all, I'd like to say that I'm impressed by the elegance of the APIs and the overall quality of the project.
What we'd like to do is to compile textual LLVM code in memory and execute it immediately. The code would take some time to run, and so we'd like to fully optimize it. I've started with the JIT compiler and it works fine. I have several questions.
1. It seems to me (correct me if I'm wrong) that the JIT does not use all the optimization passes. Is there a way to use the JIT and still get optimized code?
2. I'm not interested in lazy compilation because I know that all the functions will be called. Is there a way to compile all the functions immediately (I guess this would be slightly more efficient)?
3. The compiled code needs to call functions in the host application. Dynamic linking is not an option (Windows). I'm now using the ExecutionEngine's FindFunctionNamed and addGlobalMapping method to bind declared external functions in the compiled code to host functions. Is this the best way to do it?
Thanks!
Alain
Hello,
I now have a working installation of LLVM under Vista/Cygwin and I can
play with it. First of all, I'd like to say that I'm impressed by the
elegance of the APIs and the overall quality of the project.
What we'd like to do is to compile textual LLVM code in memory and
execute it immediately. The code would take some time to run, and so
we'd like to fully optimize it. I've started with the JIT compiler and
it works fine. I have several questions.
1. It seems to me (correct me if I'm wrong) that the JIT does not use
all the optimization passes. Is there a way to use the JIT and still get
optimized code?
Target independent optimizations happen before JIT. So optimize with opt before feeding the bytecode to lli. There are some codegen optimization passes, e.g. lsr. These are run as well. In general, apart from relocation model differences, JIT codegen is basically identical to static compilation codegen.
2. I'm not interested in lazy compilation because I know that all the
functions will be called. Is there a way to compile all the functions
immediately (I guess this would be slightly more efficient)?
See ExecutionEngine.h. You can call DisableLazyCompilation() to disable it.
3. The compiled code needs to call functions in the host application.
Dynamic linking is not an option (Windows). I'm now using the
ExecutionEngine's FindFunctionNamed and addGlobalMapping method to bind
declared external functions in the compiled code to host functions. Is
this the best way to do it?
Perhaps someone who knows Windows better can answer this.
Evan