> As far as I know, ObjectFile is either COFF, ELF or MachO format,
> statically compiled. But the pass manager for applying optimisation
> passes works only on llvm-ir.
I would not need to apply optimisations on the parts of the program in
the object file. These are meant to be optimised beforehand. The only
parts I want to run passes on are specific function that I know
beforehand.
> What you can do is to isolate the function you want to jit by
> extracting it to a new module. Load this module during runtime,
> apply your pass and jitting it.
Yes this is exactly what I want to do. The interesting part is to load
it during runtime. It is not sufficient for me to load it during JIT
initialisation, but rather I want to load and JIT it during program
execution. Hence my idea of declaring the function in the module as
extern and load it through the lazy function creator.
Quoting Willy WOLFF <willy.wolff at etu.unistra.fr>:
>
> On 23 May 2014, at 14:55, Jonatan Waern wrote:
>
>> Hello, I am a novice at using the llvm api to do much of anything.
>>
>> I am trying to lazily apply certain optimisation passes on select
>> functions when jitting a large program. It is undesirable to me to
>> load the entire program as IR code and then generate code in memory
>> for it (time concerns). It seems that there is a function in MCJIT
>> "loadObjectFile" that would suit my purposes, allowing me to
>> statically compile the program and then load it into the jit.
>>
>
> As far as I know, ObjectFile is either COFF, ELF or MachO format,
> statically compiled. But the pass manager for applying optimisation
> passes works only on llvm-ir.
>
>> My question is then what would be a good way to callback into the
>> jit for applying the optimisation passes before calling one of the
>> function? My current idea is to make the function extern in the
>> llvm IR prior to static compile, and then use
>> "installLazyFunctionCreator" to generate this function by
loading
>> ircode from an isolated module. Is this a feasible approach?
>>
>
> What you can do is to isolate the function you want to jit by
> extracting it to a new module. Load this module during runtime,
> apply your pass and jitting it.
> --
> Willy WOLFF