From bf55e4b776489b1eaa82309cfcd0ecb1cfb0dade Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 22 Jun 2011 18:55:03 +0000 Subject: [PATCH] Emit trailing padding on constant vectors when TargetData says that the vector is larger than the sum of the elements (including per-element padding). llvm-svn: 133631 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 7 +++++++ test/CodeGen/ARM/constants.ll | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 946018cd1a4..edfb30725c5 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1516,6 +1516,13 @@ static void EmitGlobalConstantVector(const ConstantVector *CV, unsigned AddrSpace, AsmPrinter &AP) { for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) EmitGlobalConstantImpl(CV->getOperand(i), AddrSpace, AP); + + const TargetData &TD = *AP.TM.getTargetData(); + unsigned Size = TD.getTypeAllocSize(CV->getType()); + unsigned EmittedSize = TD.getTypeAllocSize(CV->getType()->getElementType()) * + CV->getType()->getNumElements(); + if (unsigned Padding = Size - EmittedSize) + AP.OutStreamer.EmitZeros(Padding, AddrSpace); } static void EmitGlobalConstantStruct(const ConstantStruct *CS, diff --git a/test/CodeGen/ARM/constants.ll b/test/CodeGen/ARM/constants.ll index 7893df78205..60908957ae4 100644 --- a/test/CodeGen/ARM/constants.ll +++ b/test/CodeGen/ARM/constants.ll @@ -44,3 +44,16 @@ define void @f7(i32 %a) { r: ret void } + +%t1 = type { <3 x float>, <3 x float> } + +@const1 = global %t1 { <3 x float> zeroinitializer, + <3 x float> }, align 16 +; CHECK: const1 +; CHECK: .zero 16 +; CHECK: float 1.0 +; CHECK: float 2.0 +; CHECK: float 3.0 +; CHECK: .zero 4