Can someone help me understand why this detail needs to be understood by the frontend, and isn't handled by maybe annotating the C function with some attribute that says it should conform to a certain calling convention - then just having the signature be to naturally return the struct by value, but the backend knows how to transform it to what it should be?
Cheers
-Mike
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Many of the backends can do automatic demotion to sret, but the
front-end still needs to be aware of the issues (particularly around
unions, since whether demotion is necessary can depend on more than
just the size of the type).
I'd also expect marginally better code in some cases by using sret
explicitly: the demotion occurs pretty late on and a "%type *sret"
parameter better represents what will actually be happening later on.
Cheers.
Tim.
Thanks for the explanation. It's good to hear the situation isn't felt to be ideal.The details here are going to be sensitive to the OS + target that I'm compiling for, right? So the effort here will be to understand and get right the calling convention details for each supported target, yes?
Is there any current plan to change the way this works, or is it more of a dreamy cleanup item that maybe will get addressed some day?
Appreciate the tip.On Mon, Mar 28, 2016 at 9:28 AM, Tim Northover <t.p.no...@gmail.com> wrote:On 27 March 2016 at 21:48, Michael Nicolella via llvm-dev
<llvm...@lists.llvm.org> wrote:
> Can someone help me understand why this detail needs to be understood by the frontend,
Many of the backends can do automatic demotion to sret, but the
front-end still needs to be aware of the issues (particularly around
unions, since whether demotion is necessary can depend on more than
just the size of the type).
I'd also expect marginally better code in some cases by using sret
explicitly: the demotion occurs pretty late on and a "%type *sret"
parameter better represents what will actually be happening later on.
Cheers.
Tim.
I think this is what Swift does, so a poke around their repository
could be interesting.
There was an interesting talk a couple years ago about how Swift embeds clang:
http://llvm.org/devmtg/2014-10/Slides/Skip%20the%20FFI.pdf
Now that it's open-source the code might be of interest.
-Ahmed
Cheers