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/ItaniumCXXABI.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/ItaniumCXXABI.cpp')
-rw-r--r-- | clang/lib/CodeGen/ItaniumCXXABI.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 8fdcaee31c9..201a7534776 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -52,11 +52,7 @@ public: CGCXXABI(CGM), UseARMMethodPtrABI(UseARMMethodPtrABI), UseARMGuardVarABI(UseARMGuardVarABI) { } - bool isReturnTypeIndirect(const CXXRecordDecl *RD) const override { - // Structures with either a non-trivial destructor or a non-trivial - // copy constructor are always indirect. - return !RD->hasTrivialDestructor() || RD->hasNonTrivialCopyConstructor(); - } + bool classifyReturnType(CGFunctionInfo &FI) const override; RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const override { // Structures with either a non-trivial destructor or a non-trivial @@ -761,6 +757,21 @@ ItaniumCXXABI::EmitMemberPointerIsNotNull(CodeGenFunction &CGF, return Result; } +bool ItaniumCXXABI::classifyReturnType(CGFunctionInfo &FI) const { + const CXXRecordDecl *RD = FI.getReturnType()->getAsCXXRecordDecl(); + if (!RD) + return false; + + // Return indirectly if we have a non-trivial copy ctor or non-trivial dtor. + if (RD->hasNonTrivialDestructor() || RD->hasNonTrivialCopyConstructor()) { + FI.getReturnInfo() = ABIArgInfo::getIndirect(0, /*ByVal=*/false); + return true; + } + + // Otherwise, use the normal C ABI rules. + return false; +} + /// The Itanium ABI requires non-zero initialization only for data /// member pointers, for which '0' is a valid offset. bool ItaniumCXXABI::isZeroInitializable(const MemberPointerType *MPT) { |