From f4bd4d8fe029ca314c2c61edb1d2a65bc18cdbf2 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 5 Jun 2012 19:40:46 +0000 Subject: [PATCH] Fix a bug with va_arg and vectors on Darwin x86-32. . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158017 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetInfo.cpp | 9 +++++++-- test/CodeGen/x86_32-arguments-darwin.c | 13 +++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index 357b3fe537..34c7b428ed 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -626,6 +626,10 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy, ABIArgInfo::getExtend() : ABIArgInfo::getDirect()); } +static bool isSSEVectorType(ASTContext &Context, QualType Ty) { + return Ty->getAs() && Context.getTypeSize(Ty) == 128; +} + static bool isRecordWithSSEVectorType(ASTContext &Context, QualType Ty) { const RecordType *RT = Ty->getAs(); if (!RT) @@ -643,7 +647,7 @@ static bool isRecordWithSSEVectorType(ASTContext &Context, QualType Ty) { i != e; ++i) { QualType FT = i->getType(); - if (FT->getAs() && Context.getTypeSize(FT) == 128) + if (isSSEVectorType(Context, FT)) return true; if (isRecordWithSSEVectorType(Context, FT)) @@ -667,7 +671,8 @@ unsigned X86_32ABIInfo::getTypeStackAlignInBytes(QualType Ty, } // Otherwise, if the type contains an SSE vector type, the alignment is 16. - if (Align >= 16 && isRecordWithSSEVectorType(getContext(), Ty)) + if (Align >= 16 && (isSSEVectorType(getContext(), Ty) || + isRecordWithSSEVectorType(getContext(), Ty))) return 16; return MinABIStackAlignInBytes; diff --git a/test/CodeGen/x86_32-arguments-darwin.c b/test/CodeGen/x86_32-arguments-darwin.c index 0ac18b792f..5bbc80b939 100644 --- a/test/CodeGen/x86_32-arguments-darwin.c +++ b/test/CodeGen/x86_32-arguments-darwin.c @@ -324,3 +324,16 @@ void f64(struct s64 x) {} // CHECK: define float @f65() struct s65 { signed char a[0]; float b; }; struct s65 f65() { return (struct s65){{},2}; } + +// CHECK: define <2 x i64> @f66 +// CHECK: ptrtoint +// CHECK: and {{.*}}, -16 +// CHECK: inttoptr +typedef int T66 __attribute((vector_size(16))); +T66 f66(int i, ...) { + __builtin_va_list ap; + __builtin_va_start(ap, i); + T66 v = __builtin_va_arg(ap, T66); + __builtin_va_end(ap); + return v; +} -- 2.40.0