diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-09-16 20:42:00 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-09-16 20:42:00 +0000 |
commit | 93ae947df36133c7a26a0c7d325c0679916ed2ed (patch) | |
tree | f63615cf33ee809d4b2b34147cf96a497cb52579 /lib/CodeGen/TargetInfo.cpp | |
parent | fb67d6c3814524fdd43bd2fb159f7c594eae581c (diff) |
IRgen/ABI/x86_32/Darwin: On Darwin, only structures with SSE vector types get passed
with a non-default-stack-ABI-alignment (of 16).
- This fixes the ABI convenient, but breaks codegen since we now have
underaligned arguments. Marginal improvement overall though, and will be
fixed in next commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114113 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TargetInfo.cpp')
-rw-r--r-- | lib/CodeGen/TargetInfo.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index 2ae88f3a4c..ab6f7c7dd0 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -552,6 +552,33 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy) const { ABIArgInfo::getExtend() : ABIArgInfo::getDirect()); } +static bool isRecordWithSSEVectorType(ASTContext &Context, QualType Ty) { + const RecordType *RT = Ty->getAs<RecordType>(); + if (!RT) + return 0; + const RecordDecl *RD = RT->getDecl(); + + // If this is a C++ record, check the bases first. + if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) + for (CXXRecordDecl::base_class_const_iterator i = CXXRD->bases_begin(), + e = CXXRD->bases_end(); i != e; ++i) + if (!isRecordWithSSEVectorType(Context, i->getType())) + return false; + + for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end(); + i != e; ++i) { + QualType FT = i->getType(); + + if (FT->getAs<VectorType>() && Context.getTypeSize(Ty) == 128) + return true; + + if (isRecordWithSSEVectorType(Context, FT)) + return true; + } + + return false; +} + unsigned X86_32ABIInfo::getTypeStackAlignInBytes(QualType Ty) const { // On non-Darwin, the stack type alignment is always 4. if (!IsDarwinVectorABI) @@ -563,9 +590,11 @@ unsigned X86_32ABIInfo::getTypeStackAlignInBytes(QualType Ty) const { if (Align <= MinABIStackAlignInBytes) return MinABIStackAlignInBytes; - // Otherwise, if the type contains SSE or MMX vector types, then the alignment - // matches that of the struct. - return Align; + // Otherwise, if the type contains an SSE vector type, the alignment is 16. + if (isRecordWithSSEVectorType(getContext(), Ty)) + return 16; + + return MinABIStackAlignInBytes; } ABIArgInfo X86_32ABIInfo::getIndirectResult(QualType Ty, bool ByVal) const { |