[llvm-commits] [llvm] r119566 - in /llvm/trunk: lib/Target/ARM/ARMGlobalMerge.cpp test/CodeGen/ARM/global-merge.ll

Bob Wilson bob.wilson at apple.com
Wed Nov 17 13:25:39 PST 2010


Author: bwilson
Date: Wed Nov 17 15:25:39 2010
New Revision: 119566

URL: http://llvm.org/viewvc/llvm-project?rev=119566&view=rev
Log:
Change ARMGlobalMerge to keep BSS globals in separate pools.
This completes the fixes for Radar 8673120.

Modified:
    llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp
    llvm/trunk/test/CodeGen/ARM/global-merge.ll

Modified: llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp?rev=119566&r1=119565&r2=119566&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp Wed Nov 17 15:25:39 2010
@@ -65,6 +65,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetLowering.h"
+#include "llvm/Target/TargetLoweringObjectFile.h"
 using namespace llvm;
 
 namespace {
@@ -74,7 +75,7 @@
     const TargetLowering *TLI;
 
     bool doMerge(SmallVectorImpl<GlobalVariable*> &Globals,
-                 Module &M, bool) const;
+                 Module &M, bool isConst) const;
 
   public:
     static char ID;             // Pass identification, replacement for typeid.
@@ -161,7 +162,7 @@
 
 
 bool ARMGlobalMerge::doInitialization(Module &M) {
-  SmallVector<GlobalVariable*, 16> Globals, ConstGlobals;
+  SmallVector<GlobalVariable*, 16> Globals, ConstGlobals, BSSGlobals;
   const TargetData *TD = TLI->getTargetData();
   unsigned MaxOffset = TLI->getMaximalGlobalOffset();
   bool Changed = false;
@@ -183,7 +184,10 @@
       continue;
 
     if (TD->getTypeAllocSize(I->getType()->getElementType()) < MaxOffset) {
-      if (I->isConstant())
+      const TargetLoweringObjectFile &TLOF = TLI->getObjFileLowering();
+      if (TLOF.getKindForGlobal(I, TLI->getTargetMachine()).isBSSLocal())
+        BSSGlobals.push_back(I);
+      else if (I->isConstant())
         ConstGlobals.push_back(I);
       else
         Globals.push_back(I);
@@ -192,10 +196,12 @@
 
   if (Globals.size() > 1)
     Changed |= doMerge(Globals, M, false);
+  if (BSSGlobals.size() > 1)
+    Changed |= doMerge(BSSGlobals, M, false);
+
   // FIXME: This currently breaks the EH processing due to way how the 
   // typeinfo detection works. We might want to detect the TIs and ignore 
   // them in the future.
-  
   // if (ConstGlobals.size() > 1)
   //  Changed |= doMerge(ConstGlobals, M, true);
 

Modified: llvm/trunk/test/CodeGen/ARM/global-merge.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/global-merge.ll?rev=119566&r1=119565&r2=119566&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/global-merge.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/global-merge.ll Wed Nov 17 15:25:39 2010
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=thumb | FileCheck %s
+; RUN: llc < %s -mtriple=thumb-apple-darwin | FileCheck %s
 ; Test the ARMGlobalMerge pass.  Use -march=thumb because it has a small
 ; value for the maximum offset (127).
 
@@ -15,3 +15,9 @@
 ; When this works properly, @g3 is placed in a separate chunk of merged globals.
 ; CHECK: _MergedGlobals1:
 @g3 = internal global [30 x i32] [ i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10 ]
+
+; Global variables that can be placed in BSS should be kept together in a
+; separate pool of merged globals.
+; CHECK: _MergedGlobals2
+ at g4 = internal global i32 0
+ at g5 = internal global i32 0





More information about the llvm-commits mailing list