[LLVMdev] Newbie JITter

Evan Cheng evan.cheng at apple.com
Fri Nov 9 11:52:39 PST 2007


On Nov 9, 2007, at 1:58 AM, Antony Blakey wrote:

> 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.

Right. Optimization is done on llvm bitcode and is separate from the  
codegen process.

>
>
>> 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.

There is nothing readily available but it's not terrible hard to get  
IMO.  Take a look at LLVMTargetMachine.cpp. addPassesToEmitFile is the  
normal static compilation path while addPassesToEmitMachineCode is the  
JIT path. So it's possible for you to add addAssemblyEmitter to print  
out the assembly before machine code emitter pass.

Evan

>
>
> 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