diff options
author | Cameron Zwarich <zwarich@apple.com> | 2011-04-13 09:02:43 +0000 |
---|---|---|
committer | Cameron Zwarich <zwarich@apple.com> | 2011-04-13 09:02:43 +0000 |
commit | eb04a33dc778c6520489dff19d394c542d87c6ac (patch) | |
tree | c0bfc32859c2dfebb1964377c3a4ccffb2e1e38b | |
parent | 5876db7a66fcc4ec4444a9f3e387c1cdc8baf9e5 (diff) | |
download | external_llvm-eb04a33dc778c6520489dff19d394c542d87c6ac.zip external_llvm-eb04a33dc778c6520489dff19d394c542d87c6ac.tar.gz external_llvm-eb04a33dc778c6520489dff19d394c542d87c6ac.tar.bz2 |
Fix an obvious problem with an alignment computation. AsmPrinter actually does
the max itself, so it is not easy to write a test case for this, but I added a
test case that would fail if the code in AsmPrinter were removed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129432 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/TargetData.cpp | 2 | ||||
-rw-r--r-- | test/CodeGen/ARM/2011-04-12-AlignBug.ll | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index d15855c..da956d5 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -621,7 +621,7 @@ unsigned TargetData::getPreferredAlignment(const GlobalVariable *GV) const { if (GVAlignment >= Alignment) { Alignment = GVAlignment; } else if (GVAlignment != 0) { - Alignment = std::min(GVAlignment, getABITypeAlignment(ElemType)); + Alignment = std::max(GVAlignment, getABITypeAlignment(ElemType)); } if (GV->hasInitializer()) { diff --git a/test/CodeGen/ARM/2011-04-12-AlignBug.ll b/test/CodeGen/ARM/2011-04-12-AlignBug.ll index c657b79..317be94 100644 --- a/test/CodeGen/ARM/2011-04-12-AlignBug.ll +++ b/test/CodeGen/ARM/2011-04-12-AlignBug.ll @@ -2,6 +2,8 @@ target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32" target triple = "thumbv7-apple-darwin10.0.0" +; CHECK: align 3 +@.v = linker_private unnamed_addr constant <4 x i32> <i32 1, i32 2, i32 3, i32 4>, align 8 ; CHECK: align 2 @.strA = linker_private unnamed_addr constant [4 x i8] c"bar\00" ; CHECK-NOT: align |