diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-05-13 22:05:45 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-05-13 22:05:45 +0000 |
commit | 40ca913727f914b720b30d4e3ccc66250fb4aba2 (patch) | |
tree | a7b5b6ed63e525333c6fd2d0843082bb697b5537 /clang/lib/CodeGen/MicrosoftCXXABI.cpp | |
parent | b4892cd266dfafb9c6986ee46a8025c8031c3792 (diff) | |
download | bcm5719-llvm-40ca913727f914b720b30d4e3ccc66250fb4aba2.tar.gz bcm5719-llvm-40ca913727f914b720b30d4e3ccc66250fb4aba2.zip |
Push record return type classification into CGCXXABI
In the Microsoft C++ ABI, instance methods always return records
indirectly via the second hidden parameter. This was implemented in
X86_32ABIInfo, but not WinX86_64ABIInfo.
Rather than exposing a handful of boolean methods in the CGCXXABI
interface, we can expose a single method that applies C++ ABI return
value classification rules.
llvm-svn: 208733
Diffstat (limited to 'clang/lib/CodeGen/MicrosoftCXXABI.cpp')
-rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index bd56b732ec4..1b05b93b076 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -39,10 +39,7 @@ public: bool HasThisReturn(GlobalDecl GD) const override; - bool isReturnTypeIndirect(const CXXRecordDecl *RD) const override { - // Structures that are not C++03 PODs are always indirect. - return !RD->isPOD(); - } + bool classifyReturnType(CGFunctionInfo &FI) const override; RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const override; @@ -459,6 +456,27 @@ bool MicrosoftCXXABI::HasThisReturn(GlobalDecl GD) const { return isa<CXXConstructorDecl>(GD.getDecl()); } +bool MicrosoftCXXABI::classifyReturnType(CGFunctionInfo &FI) const { + const CXXRecordDecl *RD = FI.getReturnType()->getAsCXXRecordDecl(); + if (!RD) + return false; + + if (FI.isInstanceMethod()) { + // If it's an instance method, aggregates are always returned indirectly via + // the second parameter. + FI.getReturnInfo() = ABIArgInfo::getIndirect(0, /*ByVal=*/false); + FI.getReturnInfo().setSRetAfterThis(FI.isInstanceMethod()); + return true; + } else if (!RD->isPOD()) { + // If it's a free function, non-POD types are returned indirectly. + FI.getReturnInfo() = ABIArgInfo::getIndirect(0, /*ByVal=*/false); + return true; + } + + // Otherwise, use the C ABI rules. + return false; +} + void MicrosoftCXXABI::BuildConstructorSignature( const CXXConstructorDecl *Ctor, CXXCtorType Type, CanQualType &ResTy, SmallVectorImpl<CanQualType> &ArgTys) { |