[LLVMdev] Stack Management in LLVM

Eli Friedman eli.friedman at gmail.com
Wed Aug 5 12:17:21 PDT 2009


On Wed, Aug 5, 2009 at 3:56 AM, Joshua Moore-Oliva<llvm-dev at chatgris.com> wrote:
> First off, thanks for the help so far.
>
> From what I have been able to tell, emitPrologue kicks in after the arguments
> for the function have been copied.  For example, consider the function
>
> int testfunc( int foo, int bar );
>
> Emitting assembly code from the llvm-gcc frontend in a small test program
> gives the following for the call to testfunc
>
> movl    $1338, (%esp)
> movl    $1339, 4(%esp)
> call    testfunc
>
> Correct me if I am wrong, but I believe that the hook emitPrologue gives is
> before "call testfunc".  The issue I have is that if I am going to move the
> stack pointer, I need to do it before "movl    $1338, (%esp)" so that the
> called function can access its arguments where it expects them to be.
>
> Is there anywhere in the compiler I could feasibly hook before arguments are
> pushed to the stack for a function call?

EmitPrologue is not even related to that location; it's at the
beginning and end of a function.

Basically the only place you can catch the manipulations for a call is
X86TargetLowering::LowerCall.

-Eli




More information about the llvm-dev mailing list