From 9f061a37bb6e27314cb95c1750704d68403971f9 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Fri, 18 Nov 2011 00:28:11 +0000 Subject: [PATCH] Ignore empty unions in argument lowering on x86-32. From gcc struct layout tests. llvm-svn: 144944 --- clang/lib/CodeGen/TargetInfo.cpp | 4 ++-- clang/test/CodeGen/x86_32-arguments-darwin.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index c3d5ee19d682..b23ae304a822 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -700,8 +700,8 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty) const { return getIndirectResult(Ty); } - // Ignore empty structs. - if (Ty->isStructureType() && getContext().getTypeSize(Ty) == 0) + // Ignore empty structs/unions. + if (Ty->isRecordType() && getContext().getTypeSize(Ty) == 0) return ABIArgInfo::getIgnore(); // Expand small (<= 128-bit) record types when we know that the stack layout diff --git a/clang/test/CodeGen/x86_32-arguments-darwin.c b/clang/test/CodeGen/x86_32-arguments-darwin.c index c3af7fbc0473..b31262fc96c0 100644 --- a/clang/test/CodeGen/x86_32-arguments-darwin.c +++ b/clang/test/CodeGen/x86_32-arguments-darwin.c @@ -280,3 +280,7 @@ void f56(char a0, struct s56_0 a1, // CHECK: call void @f57( struct s57 { _Complex int x; }; void f57(struct s57 x) {} void f57a(void) { f57((struct s57){1}); } + +union u58 {}; +void f58(union u58 x) {} +// CHECK: define void @f58()