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. This fixes win64 MSVC ABI compatibility for methods returning structs. Reviewers: rsmith, majnemer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3618 llvm-svn: 208458
This commit is contained in:
@@ -622,7 +622,10 @@ void CodeGenFunction::StartFunction(GlobalDecl GD,
|
||||
!hasScalarEvaluationKind(CurFnInfo->getReturnType())) {
|
||||
// Indirect aggregate return; emit returned value directly into sret slot.
|
||||
// This reduces code size, and affects correctness in C++.
|
||||
ReturnValue = CurFn->arg_begin();
|
||||
auto AI = CurFn->arg_begin();
|
||||
if (CurFnInfo->getReturnInfo().isSRetAfterThis())
|
||||
++AI;
|
||||
ReturnValue = AI;
|
||||
} else if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::InAlloca &&
|
||||
!hasScalarEvaluationKind(CurFnInfo->getReturnType())) {
|
||||
// Load the sret pointer from the argument struct and return into that.
|
||||
|
||||
Reference in New Issue
Block a user