[llvm-dev] Quick question: Where to patch function argument b4 LTO inlining?
K Jelesnianski via llvm-dev
llvm-dev at lists.llvm.org
Wed Nov 13 12:27:37 PST 2019
I am building and inserting a function call in IR, but one of my
parameters needs to the address of the current stack address ($RSP).
Also add in that I have LTO inlining this small function call.
My patch worked when we did not have inlining of the function. Just replaced
MOV64ri $RDI, 0x0 with
MOV64rr $RDI, $RSP to set parameter 0 to the stack addr.
With inlining, I currently then have tried to "patch" the UndefValue
to be $RSP except it seems LTO is optimizing out the UndefValue
parameter, so patching via a machine function pass isnt working out.
Question: Where in LLVM code (I assume somewhere in lowering stage,
but would appreciate a little more guidance here) can I update the
function parameter/operand from the undefValue it is via IR level to
be $RSP once LLVM knows we are working with an X86 target??
Thank you in advance,
Christopher Jelesnianski
Graduate Research Assistant
Virginia Tech
------
At the IR level, to my knowledge, there is no way to "build" an
argument Value that represents $RSP. So for the time being I have
tried
** ConstantInt (inlining statically optimizes and adds any int I
provide to the function body integers already there)
** ConstantPointerNull (creates xor code to represent null ptr as 0x0,
but also statically optimizes out the addition in the function body
with the parameter)
** UndefValue. (doesn't add any extra ASM at all so the addition asm is missing)
Undefvalue has gotten me the furthest, but I still need the ASM to
properly be generated such that I can just replace the dummy value
from IR level with RSP register.
More information about the llvm-dev
mailing list