diff options
-rw-r--r-- | lib/CodeGen/TargetABIInfo.cpp | 12 | ||||
-rw-r--r-- | test/CodeGenCXX/references.cpp | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/CodeGen/TargetABIInfo.cpp b/lib/CodeGen/TargetABIInfo.cpp index ea1426277d..ad5dbd2276 100644 --- a/lib/CodeGen/TargetABIInfo.cpp +++ b/lib/CodeGen/TargetABIInfo.cpp @@ -353,11 +353,17 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy, return ABIArgInfo::getDirect(); } else if (CodeGenFunction::hasAggregateLLVMType(RetTy)) { - // Structures with flexible arrays are always indirect. - if (const RecordType *RT = RetTy->getAsStructureType()) + if (const RecordType *RT = RetTy->getAsStructureType()) { + // Structures with either a non-trivial destructor or a non-trivial + // copy constructor are always indirect. + if (hasNonTrivialDestructorOrCopyConstructor(RT)) + return ABIArgInfo::getIndirect(0, /*ByVal=*/false); + + // Structures with flexible arrays are always indirect. if (RT->getDecl()->hasFlexibleArrayMember()) return ABIArgInfo::getIndirect(0); - + } + // If specified, structs and unions are always indirect. if (!IsSmallStructInRegABI && !RetTy->isAnyComplexType()) return ABIArgInfo::getIndirect(0); diff --git a/test/CodeGenCXX/references.cpp b/test/CodeGenCXX/references.cpp index 7028ef338b..8e0e1cbe84 100644 --- a/test/CodeGenCXX/references.cpp +++ b/test/CodeGenCXX/references.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -verify -emit-llvm -o - %s | FileCheck %s +// RUN: clang-cc -verify -emit-llvm -o - %s | FileCheck %s void t1() { extern int& a; |