[LLVMdev] Newbie JITter

Antony Blakey antony.blakey at gmail.com
Fri Nov 9 01:58:10 PST 2007


Thanks Evan.

On 09/11/2007, at 6:50 PM, Evan Cheng wrote:

>> 1. What optimization passes, if any, should I run on the module
>> before I pass it to the ExecutionEngine.
>
> The default JIt driver, lli, runs everything.

My reading of the lli source indicates that it's not explicitly doing  
any opt passes - is that happening implicitly in the ExecutionEngine?  
I can see that I should probably copy the opt source to get all of  
the optimisations, before passing the module to the ExecutionEngine.  
It's difficult to know because I currently can't get a disassembly of  
the JITed code.

> I don't think it's safe to free Module early if you are using lazy
> compilation. If that's disabled, I suppose it's safe to delete Module
> once all references are resolved and relocated. Chris, can you  
> confirm?
>
> Don't understand your last question.

I solved this - I hadn't noticed the comments about ownership  
transfers in the documentation. Also I didn't realize that I should  
have a single long-lived ExecutionEngine and then dynamically add my  
modules to it, and I didn't understand the significance of  
ExecutionEngine::getPointerToFunction, which solved my last question.

>> An unrelated question: I want to dump the native assembler form of
>> the code generated by the JIT. Currently I dump it using some code I
>> adapted from llc, but that's not actually showing what the JIT is
>> generating. How can I dump the JIT generated code, as native
>> assembler? It's a debugging requirement only.
>
> I think there is disassembly capability built-in. See JITEmitter.cpp

That's only for x86, and only if you have udis86. I was using  
(indirectly) an AsmEmitter that is added by  
TargetMachine::addPassesToEmitFile, and now that I have a better  
understanding of what's going on, I realise there isn't really any  
facility to do what I need.

Antony Blakey
-------------
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787

One should respect public opinion insofar as is necessary to avoid  
starvation and keep out of prison, but anything that goes beyond this  
is voluntary submission to an unnecessary tyranny.
   -- Bertrand Russell





More information about the llvm-dev mailing list