[LLVMbugs] [Bug 1937] New: The StructReturn attribute should imply a copy

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Jan 20 11:37:57 PST 2008


           Summary: The StructReturn attribute should imply a copy
           Product: new-bugs
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: baldrick at free.fr
                CC: llvmbugs at cs.uiuc.edu

ByVal for parameters and StructReturn for results are closely
related.  They are both for passing structures by copy: into
the function for ByVal, and out of the function for StructReturn.
Yet while ByVal implies that a hidden copy is made, this is not
the case for StructReturn - whoever generates the StructReturn
has to create and use a temporary for the return value and explicitly
copy it to the sret parameter at the end, see EmitMODIFY_EXPR in
llvm-gcc (if you don't make a copy then you get wrong code).

I think it would be better to have the same semantics as for byval:
an implied copy is performed.  On x86-32 the ABI results in a copy
anyway (so here two copies are currently made), while on x86-64
a copy would need to be generated by the code generators.

The arguments for an implicit copy are the same as for byval, and
since they triumphed there they should triumph for struct-return too!

Of course implementing this would mean:
(1) modifying the inliner
(2) adjust argpromotion
(3) generating a copy for those targets that don't do so already for ABI
(4) whatever else needed to be done for byval
It would also be possible to teach alias analysis to do a better job
for sret and for byval.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list