[LLVMdev] Accessing arguments in a caller

Carlo Alberto Ferraris cafxx at strayorange.com
Thu Aug 18 00:11:36 PDT 2011


I need some advice on "forwarding" arguments to a callee. Suppose I have 
a function F that is called at the beginning of all other functions in 
the module. From F I need to access (read) the arguments passed to its 
immediate caller. Right now I do something like boxing all arguments in 
the caller inside a struct and passing a pointer to the struct to F, 
alongside an identifier telling which caller F is being called from. F 
has then a giant switch that branches to the appropriate unboxing code. 
This is obviously suboptimal because I need to allocate the struct on 
the stack, copy the arguments inside of it and then passing an 
additional pointer to F.
I was wondering if there's a better way to do this, e.g. a way to access 
the stack frame of the caller (knowing, thanks to the identifier, which 
caller F was called from) or, more in general, arbitrary values defined 
in the caller. Any suggestions?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110818/aec20d75/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cafxx.vcf
Type: text/x-vcard
Size: 230 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110818/aec20d75/attachment.vcf>


More information about the llvm-dev mailing list