Fix a regression caused by r102515 where explicit alignment on globals is
authorCameron Zwarich <zwarich@apple.com>
Wed, 13 Apr 2011 20:36:04 +0000 (20:36 +0000)
committerCameron Zwarich <zwarich@apple.com>
Wed, 13 Apr 2011 20:36:04 +0000 (20:36 +0000)
ignored. There was a test to catch this, but it was just blindly updated in
a large change. This fixes another part of <rdar://problem/9275290>.

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

lib/Target/TargetData.cpp
test/CodeGen/X86/alignment.ll
test/CodeGen/X86/unaligned-load.ll

index da956d5fed96c0ac8115f0cf5daca81908f8418e..1990bc7b929ca8b5ff02363cdbc43fa7440cadaa 100644 (file)
@@ -624,7 +624,7 @@ unsigned TargetData::getPreferredAlignment(const GlobalVariable *GV) const {
     Alignment = std::max(GVAlignment, getABITypeAlignment(ElemType));
   }
 
-  if (GV->hasInitializer()) {
+  if (GV->hasInitializer() && GVAlignment == 0) {
     if (Alignment < 16) {
       // If the global is not external, see if it is large.  If so, give it a
       // larger alignment.
index 9678e6df740ed5614766289dc468eb8dd516bac0..7e911159790b0a8c7b42bcea48f084bf174ed2bb 100644 (file)
@@ -6,7 +6,7 @@
 
 ; CHECK:       .bss
 ; CHECK:       .globl  GlobalA
-; CHECK:       .align  16
+; CHECK:       .align  8
 ; CHECK: GlobalA:
 ; CHECK:       .zero   384
 
 ; PR6921
 @GlobalB = common global { [384 x i8] } zeroinitializer, align 8
 
-; CHECK:       .comm   GlobalB,384,16
+; CHECK:       .comm   GlobalB,384,8
 
 
 @GlobalC = common global { [384 x i8] } zeroinitializer, align 2
 
-; CHECK:       .comm   GlobalC,384,16
+; CHECK:       .comm   GlobalC,384,2
 
 
 
index 6a493c0594de352fc819d6ce57be999a2a6704e6..9f704898d688831e230ed21b1ab306c0228deacc 100644 (file)
@@ -29,8 +29,8 @@ return:
 declare void @llvm.memcpy.i64(i8* nocapture, i8* nocapture, i64, i32) nounwind
 
 ; CORE2: .section
-; CORE2: .align  4
+; CORE2: .align  3
 ; CORE2-NEXT: _.str1:
 ; CORE2-NEXT: .asciz "DHRYSTONE PROGRAM, SOME STRING"
-; CORE2: .align 4
+; CORE2: .align 3
 ; CORE2-NEXT: _.str3: