aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-05-09 22:46:15 +0000
committerReid Kleckner <reid@kleckner.net>2014-05-09 22:46:15 +0000
commit37abaca3c26a4f89e34df356c3ad6018f42580ce (patch)
tree5c1cceb3a6330f0477c8a155faa4989ac0832d12 /clang/lib/CodeGen/CodeGenFunction.cpp
parent46e1ecdecc9b6e6809fd85d9a2f7ae707e1aadd0 (diff)
downloadllvm-37abaca3c26a4f89e34df356c3ad6018f42580ce.zip
llvm-37abaca3c26a4f89e34df356c3ad6018f42580ce.tar.gz
llvm-37abaca3c26a4f89e34df356c3ad6018f42580ce.tar.bz2
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index f3ea8eb..178cf9f 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -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.