[llvm-dev] Disabling prolog/epilog emitters

Mattias Holm via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 14 02:13:22 PDT 2019


Hi,

I am working on something where I would like to disable the prolog and epilog emitters in the ORC JIT layer and move these into a custom trampoline written in manual assembler, mostly because the prolog and epilogues actually interfering with the chaining / tail calling of emitted functions.

Is there some way to get this done easily, the TargetPassConfig::addMachinePasses() function seem to point at that the the prolog pass can be overridden/substituted if needed. But I have a hard time figuring out where to do that.

Is there some documentation about this or does someone have a clue how to do this?

Basically in case it explains a bit better, I have a generated code block like this:

Func1: 
  <prolog>
  <code>
  <patchpoint>
  <epilogue>

Where I want to override the patch point to jump directly to another function (that is luckily trivial), my aiming point is to get to something like this:

Trampoline:
  <prolog>
  Jump to Func1
  <epilogue>

Func1: 
  <code>
  Jump to Func2 
  Ret to trampoline

Func2:
  <code>
  <patchpoint>
  Ret to trampoline

Currently I am analysing the machine code that has been emitted in order to get the prolog/epilogue handling compatible and actually handle the jumping to the next function correctly, but this is less then ideal and not overly robust. My, so my initial thought was to see if the prolog and epilog pass can be disabled, but maybe there is a better way to do this?

Cheers,
Mattias


More information about the llvm-dev mailing list