[LLVMdev] Structure returns to-do or not-to-do?

roger roger roger83 at hotmail.co.uk
Wed Oct 20 14:56:06 PDT 2010


I notice that using the online demo, functions which return structures are converted to be void, and instead take an extra argument which is the a pointer to the returned structure, and the allocation is made by the caller.
Even declared, but undefined functions are converted like this, presumably this doesn't cause a problem during linking?

I had a look back through the previous releases and saw that this was required before version 2.3 because return types could not be structures (structures weren't considered first class). However, since then it is legal to return a structure, and that there is an optimization pass which looks specifically for the type of functions which have an 'sret' argument and tries to return the structure in registers if it fits.
I can imagine that the above behavior could be an artifact of the old system, but obviously, when the structure is too large, it's going to have to be return via pointer anyway.

So my question is, should I be following the demo's example for IR generation or just generate IR which returns structures, even if they could be too large to fit in registers? 

Thanks,
Roger
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101020/b6ac08e2/attachment.html>


More information about the llvm-dev mailing list