Allow sret on the second parameter as well as the first
authorReid Kleckner <reid@kleckner.net>
Fri, 9 May 2014 22:32:13 +0000 (22:32 +0000)
committerReid Kleckner <reid@kleckner.net>
Fri, 9 May 2014 22:32:13 +0000 (22:32 +0000)
commit805a83c0419aa453b78b2a062f46dc7f72137f79
tree1c220d4b875a82dd2da92df79e139d57f13afc86
parentb3275b9fca1f805fbd93dc6c473e85f533f9b217
Allow sret on the second parameter as well as the first

MSVC always places the implicit sret parameter after the implicit this
parameter of instance methods.  We used to handle this for
x86_thiscallcc by allocating the sret parameter on the stack and leaving
the this pointer in ecx, but that doesn't handle alternative calling
conventions like cdecl, stdcall, fastcall, or the win64 convention.

Instead, change the verifier to allow sret on the second parameter.

This also requires changing the Mips and X86 backends to return the
argument with the sret parameter, instead of assuming that the sret
parameter comes first.

The Sparc backend also returns sret parameters in a register, but I
wasn't able to update it to handle secondary sret parameters.  It
currently calls report_fatal_error if you feed it an sret in the second
parameter.

Reviewers: rafael.espindola, majnemer

Differential Revision: http://reviews.llvm.org/D3617

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208453 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/Function.h
lib/IR/Function.cpp
lib/IR/Verifier.cpp
lib/Target/Mips/MipsISelLowering.cpp
lib/Target/Sparc/SparcISelLowering.cpp
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/Mips/mips64-sret.ll
test/CodeGen/SPARC/sret-secondary.ll [new file with mode: 0644]
test/CodeGen/X86/win32_sret.ll
test/Verifier/sret.ll [new file with mode: 0644]