From 1c411dee4f406e33d70666898f62ab9ba23bb73d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 7 Dec 2006 22:38:06 +0000 Subject: [PATCH] fix alignment git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32337 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMAsmPrinter.cpp | 6 +++--- test/CodeGen/ARM/align.ll | 12 ++++++++++++ test/CodeGen/ARM/constants.ll | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 test/CodeGen/ARM/align.ll diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index e57a7685077..a00e361eb53 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -292,7 +292,7 @@ bool ARMAsmPrinter::doFinalization(Module &M) { std::string name = Mang->getValueName(I); Constant *C = I->getInitializer(); unsigned Size = TD->getTypeSize(C->getType()); - unsigned Align = TD->getTypeAlignment(C->getType()); + unsigned Align = Log2_32(TD->getTypeAlignment(C->getType())); if (C->isNullValue() && !I->hasSection() && @@ -302,8 +302,8 @@ bool ARMAsmPrinter::doFinalization(Module &M) { if (I->hasInternalLinkage()) O << "\t.local " << name << "\n"; - O << "\t.comm " << name << "," << TD->getTypeSize(C->getType()) - << "," << (unsigned)TD->getTypeAlignment(C->getType()); + O << "\t.comm " << name << "," << Size + << "," << (unsigned)Align; O << "\n"; } else { switch (I->getLinkage()) { diff --git a/test/CodeGen/ARM/align.ll b/test/CodeGen/ARM/align.ll new file mode 100644 index 00000000000..bad7c6b8c7a --- /dev/null +++ b/test/CodeGen/ARM/align.ll @@ -0,0 +1,12 @@ +; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm && +; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep align.*1 | wc | grep 1 && +; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep align.*2 | wc | grep 2 && +; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep align.*3 | wc | grep 2 + +%a = global bool true +%b = global sbyte 1 +%c = global short 2 +%d = global int 3 +%e = global long 4 +%f = global float 5.0 +%g = global double 6.0 diff --git a/test/CodeGen/ARM/constants.ll b/test/CodeGen/ARM/constants.ll index 0d69f53585b..21ff39002f2 100644 --- a/test/CodeGen/ARM/constants.ll +++ b/test/CodeGen/ARM/constants.ll @@ -5,7 +5,7 @@ ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep ".word.*257" | wc -l | grep 1 && ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep "mov r0, #-1073741761" | wc -l | grep 1 && ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep "mov r0, #1008" | wc -l | grep 1 && -; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep "\.comm.*a,4,4" | wc -l | grep 1 +; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep "\.comm.*a,4,2" | wc -l | grep 1 %a = internal global int 0