[llvm-commits] [llvm] r134106 - in /llvm/trunk: lib/Target/ARM/ARMGlobalMerge.cpp test/CodeGen/ARM/2011-06-29-MergeGlobalsAlign.ll

Cameron Zwarich zwarich at apple.com
Wed Jun 29 15:24:25 PDT 2011


Author: zwarich
Date: Wed Jun 29 17:24:25 2011
New Revision: 134106

URL: http://llvm.org/viewvc/llvm-project?rev=134106&view=rev
Log:
In the ARM global merging pass, allow extraneous alignment specifiers. This pass
already makes the assumption, which is correct on ARM, that a type's alignment is
less than its alloc size. This improves codegen with Clang (which inserts a lot of
extraneous alignment specifiers) and fixes <rdar://problem/9695089>.

Added:
    llvm/trunk/test/CodeGen/ARM/2011-06-29-MergeGlobalsAlign.ll
Modified:
    llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp?rev=134106&r1=134105&r2=134106&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp Wed Jun 29 17:24:25 2011
@@ -175,7 +175,9 @@
       continue;
 
     // Ignore fancy-aligned globals for now.
-    if (I->getAlignment() != 0)
+    unsigned Alignment = I->getAlignment();
+    unsigned AllocSize = TD->getTypeAllocSize(I->getType()->getElementType());
+    if (Alignment > AllocSize)
       continue;
 
     // Ignore all 'special' globals.
@@ -183,7 +185,7 @@
         I->getName().startswith(".llvm."))
       continue;
 
-    if (TD->getTypeAllocSize(I->getType()->getElementType()) < MaxOffset) {
+    if (AllocSize < MaxOffset) {
       const TargetLoweringObjectFile &TLOF = TLI->getObjFileLowering();
       if (TLOF.getKindForGlobal(I, TLI->getTargetMachine()).isBSSLocal())
         BSSGlobals.push_back(I);

Added: llvm/trunk/test/CodeGen/ARM/2011-06-29-MergeGlobalsAlign.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2011-06-29-MergeGlobalsAlign.ll?rev=134106&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/2011-06-29-MergeGlobalsAlign.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/2011-06-29-MergeGlobalsAlign.ll Wed Jun 29 17:24:25 2011
@@ -0,0 +1,12 @@
+; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 | FileCheck %s
+; CHECK: .zerofill __DATA,__bss,__MergedGlobals,16,2
+
+%struct.config = type { i16, i16, i16, i16 }
+
+ at prev = external global [0 x i16]
+ at max_lazy_match = internal unnamed_addr global i32 0, align 4
+ at read_buf = external global i32 (i8*, i32)*
+ at window = external global [0 x i8]
+ at lookahead = internal unnamed_addr global i32 0, align 4
+ at eofile.b = internal unnamed_addr global i1 false
+ at ins_h = internal unnamed_addr global i32 0, align 4





More information about the llvm-commits mailing list