On Thu, Jul 23, 2009 at 4:06 PM, Joshua Moore-Oliva<llvm-dev at chatgris.com> wrote:> If I could reduce my requirements to the ability to the following: > * Ability to know how much stack space a function requires > * Move the stack pointer arbitrarily (the ability to write my own function > prologue and epilogue, would need to be able to insert assembly/low level > code here) before and after a method call > > could LLVM do that for me, using the system stack, (not continuations with > malloc)? Or am I barking up the wrong tree with this tool?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
First off, thanks for the help so far.>From what I have been able to tell, emitPrologue kicks in after the argumentsfor 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
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
Possibly Parallel Threads
- [LLVMdev] Stack Management in LLVM
- [LLVMdev] Stack Management in LLVM
- [LLVMdev] Stack Management in LLVM
- [LLVMdev] Purpose of PROLOG_LABEL in function prologue?
- [LLVMdev] What does this error mean: psuedo instructions should be removed before code emission?