[LLVMdev] Accessing arguments in a caller

Carlo Alberto Ferraris cafxx at strayorange.com
Mon Aug 22 02:29:31 PDT 2011


Il 21/08/2011 19:31, Jordy Rose ha scritto:
> What I can think of:
> 1. Anonymous struct, to avoid a copy.
> 2. Use stdarg.h...dangerous but accomplishes what you're looking for.
probably it wasn't clear from my first post: I'm talking about LLVM-IR, 
not C or C++.
> 3. Split up F: giant switch statements often indicate that your function is doing several different things. (IMHO...)
The whole point of the work I'm doing is having a single function; 
there's no way around that.
> 4. Don't worry about it, it's probably not a bottleneck. (Or rather, profile first...)
It might not be the most important thing right now, but it will quickly 
become important the further the project moves. By disassembling the 
genereated executable there's a lot of things that pop out as inefficient.

> But no, there's no standard way to do this. Even C++11's variadic templates don't avoid the copy, and initializer lists are pretty much equivalent to an anonymous struct / const struct reference.
>
> (Why not? Because calling conventions differ from platform to platform; often the first few arguments of a function are passed in registers, not on the stack.)
That's why I was hoping that LLVM-IR had a better way of doing such 
things (I mean, telling the backend that I need to access the stack 
frame of the caller).

BTW, I posted the same question on SO, along with some (pseudo-) code to 
explain what I'm doing right now: 
http://stackoverflow.com/questions/7144733/argument-forwarding-in-llvm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110822/8b21ac8e/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/20110822/8b21ac8e/attachment.vcf>


More information about the llvm-dev mailing list