[LLVMdev] Stack Management in LLVM

Joshua Moore-Oliva llvm-dev at chatgris.com
Thu Jul 16 21:14:23 PDT 2009

Hi, going through the tutorial (http://llvm.org/docs/tutorial/LangImpl8.html) 
it linked to a post from 2004 
(http://nondot.org/sabre/LLVMNotes/ExplicitlyManagedStackFrames.txt) stating 
that LLVM does not allow explicit stack management.  It also mentioned that 
this was a deficiency in LLVM, leading me to think that there is a 
possibility that things have changed since them.

I'm not just looking to implement garbage collection that may have been done 
already in a better way, I will be conducting research into stack handling 
routines for multi-threaded programs.  As such, I will need to have complete 
control over the stack, including the ability to
    *  Add memprotected regions before and after stack pages, with the 
intention to catch the interrupt/signal and modify the stack
    * Hook before functions place data on stack, possibly moving the stack 
pointer before data is placed
    * Hook before functions return with explicit control over where the new 
stack pointer will be
    * Ability to resize stack (e.g. on a method call if local variables at the 
end of the stack are dead, new stack will overwrite the dead space)
    * Ability to MOVE stack pages around (yes, I know this requires a language 
that will not allow for pointers to a stack variable)
    * Ability to arbitrarily change the value of the stack pointer 

Are there now explicit stack management hooks in LLVM? Or am I safer staying 
away from LLVM if I need to manage the stack explicitly?  

Thanks for your time, Joshua Moore-Oliva

More information about the llvm-dev mailing list