r208458 - MS ABI: Pass 'sret' as the second parameter of instance methods

John McCall rjmccall at apple.com
Fri Oct 17 19:55:09 PDT 2014


On May 9, 2014, at 3:46 PM, Reid Kleckner <reid at kleckner.net> wrote:
> Author: rnk
> Date: Fri May  9 17:46:15 2014
> New Revision: 208458
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=208458&view=rev
> Log:
> MS ABI: Pass 'sret' as the second parameter of instance methods
> 
> Summary:
> MSVC always passes 'sret' after 'this', unlike GCC.  This required
> changing a number of places in Clang that assumed the sret parameter was
> always first in LLVM IR.

I apologize for the extremely late review, but this does not seem like the correct solution to me.  Having the sret argument always be the first argument seems like an extremely reasonable IR invariant, and changing it makes it unnecessarily more complicated to implement frontends.  I’m currently attempting to provide a better and more general interface to Clang’s CC lowering, and I would rather not have to tell all clients that they have to handle this one special-case rule.

A much better fix would be for the x86-64 backend to provide a calling convention — perhaps still called x86_thiscallcc — which passes sret in a different register, and which can ape any other distinctive features of thiscall which we can find.

Also, as far as I can tell, this behavior is specific to using thiscall, which I believe it’s supported to opt out of on member functions by explicitly using cdecl.

John.



More information about the cfe-commits mailing list