<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Il 21/08/2011 19:31, Jordy Rose ha scritto:
<blockquote class=" cite"
id="mid_EAD629DC-0CB1-4CD9-819B-121474178DB3_belkadan_com"
cite="mid:EAD629DC-0CB1-4CD9-819B-121474178DB3@belkadan.com"
type="cite">
<pre wrap="">What I can think of:
1. Anonymous struct, to avoid a copy.
2. Use stdarg.h...dangerous but accomplishes what you're looking for.</pre>
</blockquote>
probably it wasn't clear from my first post: I'm talking about
LLVM-IR, not C or C++.<br>
<blockquote class=" cite"
id="mid_EAD629DC-0CB1-4CD9-819B-121474178DB3_belkadan_com"
cite="mid:EAD629DC-0CB1-4CD9-819B-121474178DB3@belkadan.com"
type="cite">
<pre wrap="">
3. Split up F: giant switch statements often indicate that your function is doing several different things. (IMHO...)</pre>
</blockquote>
The whole point of the work I'm doing is having a single function;
there's no way around that.<br>
<blockquote class=" cite"
id="mid_EAD629DC-0CB1-4CD9-819B-121474178DB3_belkadan_com"
cite="mid:EAD629DC-0CB1-4CD9-819B-121474178DB3@belkadan.com"
type="cite">
<pre wrap="">4. Don't worry about it, it's probably not a bottleneck. (Or rather, profile first...)</pre>
</blockquote>
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.<br>
<br>
<blockquote class=" cite"
id="mid_EAD629DC-0CB1-4CD9-819B-121474178DB3_belkadan_com"
cite="mid:EAD629DC-0CB1-4CD9-819B-121474178DB3@belkadan.com"
type="cite">
<pre wrap="">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.)</pre>
</blockquote>
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).<br>
<br>
BTW, I posted the same question on SO, along with some (pseudo-)
code to explain what I'm doing right now:
<a class="moz-txt-link-freetext" href="http://stackoverflow.com/questions/7144733/argument-forwarding-in-llvm">http://stackoverflow.com/questions/7144733/argument-forwarding-in-llvm</a><br>
</body>
</html>