[LLVMdev] Stack Management in LLVM

Joshua Moore-Oliva llvm-dev at chatgris.com
Wed Aug 5 03:56:39 PDT 2009


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?

Thanks, Josh

On July 23, 2009 08:03:23 pm Eli Friedman wrote:
> Messing with the prologue and epilogue should be feasible, although
> you'll have to modify the code, and it's very platform-specific; see
> X86RegisterInfo::emitPrologue in lib/Target/X86/X86RegisterInfo.cpp in
> the source tree.
>
> -Eli




More information about the llvm-dev mailing list