Emit trailing padding on constant vectors when TargetData says that the vector
authorNick Lewycky <nicholas@mxc.ca>
Wed, 22 Jun 2011 18:55:03 +0000 (18:55 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Wed, 22 Jun 2011 18:55:03 +0000 (18:55 +0000)
is larger than the sum of the elements (including per-element padding).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133631 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/AsmPrinter.cpp
test/CodeGen/ARM/constants.ll

index 946018cd1a4d2559c504e0829e1f04003e0889d2..edfb30725c58fe0a16aae6d17139f2e47e623e84 100644 (file)
@@ -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,
index 7893df782054ad508520d75797db6f88384eb9bd..60908957ae4ce46efb29f5834d1801ca679598f6 100644 (file)
@@ -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> <float 1.000000e+00,
+                                    float 2.000000e+00,
+                                    float 3.000000e+00> }, align 16
+; CHECK: const1
+; CHECK: .zero 16
+; CHECK: float 1.0
+; CHECK: float 2.0
+; CHECK: float 3.0
+; CHECK: .zero 4