diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-09-16 20:41:56 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-09-16 20:41:56 +0000 |
commit | 8a6c91ff765af7416139e60f7dd442fe2554b700 (patch) | |
tree | 61ed80cf26c7e42afcd71211134995973a73a838 /clang/lib/CodeGen | |
parent | c81256a5952ec95ed8521404d599c63ccda812eb (diff) | |
download | bcm5719-llvm-8a6c91ff765af7416139e60f7dd442fe2554b700.tar.gz bcm5719-llvm-8a6c91ff765af7416139e60f7dd442fe2554b700.zip |
IRgen/x86_32/Linux: Linux seems to align all stack objects to 4 bytes, unlike
Darwin. Checked vs the handiest Linux llvm-gcc I had around, someone on Linux is
welcome to investigate more.
llvm-svn: 114112
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 4d221d4e657..2ae88f3a4cc 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -336,6 +336,8 @@ ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const { /// X86_32ABIInfo - The X86-32 ABI information. class X86_32ABIInfo : public ABIInfo { + static const unsigned MinABIStackAlignInBytes = 4; + bool IsDarwinVectorABI; bool IsSmallStructInRegABI; @@ -349,6 +351,9 @@ class X86_32ABIInfo : public ABIInfo { /// such that the argument will be passed in memory. ABIArgInfo getIndirectResult(QualType Ty, bool ByVal = true) const; + /// \brief Return the alignment to use for the given type on the stack. + unsigned getTypeStackAlignInBytes(QualType Ty) const; + public: ABIArgInfo classifyReturnType(QualType RetTy) const; @@ -547,15 +552,30 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy) const { ABIArgInfo::getExtend() : ABIArgInfo::getDirect()); } +unsigned X86_32ABIInfo::getTypeStackAlignInBytes(QualType Ty) const { + // On non-Darwin, the stack type alignment is always 4. + if (!IsDarwinVectorABI) + return MinABIStackAlignInBytes; + + // Otherwise, if the alignment is less than or equal to 4, use the minimum ABI + // alignment. + unsigned Align = getContext().getTypeAlign(Ty) / 8; + 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; +} + ABIArgInfo X86_32ABIInfo::getIndirectResult(QualType Ty, bool ByVal) const { if (!ByVal) return ABIArgInfo::getIndirect(0, false); // Compute the byval alignment. We trust the back-end to honor the // minimum ABI alignment for byval, to make cleaner IR. - const unsigned MinABIAlign = 4; - unsigned Align = getContext().getTypeAlign(Ty) / 8; - if (Align > MinABIAlign) + unsigned Align = getTypeStackAlignInBytes(Ty); + if (Align > MinABIStackAlignInBytes) return ABIArgInfo::getIndirect(Align); return ABIArgInfo::getIndirect(0); } |