[LLVMdev] Accessing arguments in a caller

Duncan Sands baldrick at free.fr
Mon Aug 22 02:53:29 PDT 2011


Hi Carlo, rather than declaring individual stack variables
   int x;
   int y;
   int z;
and so on, which requires you to pass each one, or a pointer to each one,
to your function, declare one stack variable of struct type that holds
them all:
   struct StackObjects {
     int x;
     int y;
     int z;
     ...
   };
...
   struct StackObjects stack;
then pass the address of stack to your function, enabling it to access all
of the objects on the callers stack.  This way you only need to copy a single
pointer.  This is what GCC's nested function implementation does for example to
enable child functions to access variables on the parent's stack.

Ciao, Duncan.



More information about the llvm-dev mailing list