[LLVMdev] Run-time optimization using profile data

Evan Cheng evan.cheng at apple.com
Mon Sep 22 12:12:31 PDT 2008


On Sep 20, 2008, at 3:28 PM, Eli Friedman wrote:

>
>> 5. I would then like to have control over the JIT as well. In the  
>> above
>> LLVM->LLVM transform, I would have placed some "special"  
>> instructions (like
>> maybe illegal opcodes, or something like that), and once the JIT is  
>> about to
>> translate those, my routine should get called. I will then  
>> transform those
>> instructions into "special" native instructions.
>
> You want to have the JIT recompile the code as it's running?  The JIT
> doesn't currently support that, and it's relatively tricky to write.

You are not the first user of JIT that wants something like this.  
There is definite interests in having an alternative call back   
mechanism.  I think there are two issues:

1. Replace the default lazy compilation callback, e.g. see  
X86JITInfo.cpp:
static TargetJITInfo::JITCompilerFn JITCompilerFunction

with a custom one that can run dynamic optimization passes which make  
use of the profile data.

2. Add custom logic to determine when a call instruction is replaced  
with a call to a stub which would in turn invoke the compilation  
callback.

Evan

>
>
> Messing with code generation to add platform-specific intrinsics isn't
> too hard; you'd need to provide more details to say anything specific,
> though.
>
>> 6. I then want to execute the newly written binary and remove profile
>> instrumentation, but leave my special native instructions intact.
>
> Stripping out the instrumentation should be a very simple  
> transformation pass.
>
> -Eli
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list