minor change to rafael's recent patches: if something is
authorChris Lattner <sabre@nondot.org>
Tue, 18 Jan 2011 01:23:44 +0000 (01:23 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 18 Jan 2011 01:23:44 +0000 (01:23 +0000)
constant but requires a unique address, we can still put it in a
readonly section, just not a mergable one.

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

lib/Target/TargetLoweringObjectFile.cpp

index eab43fb4276498e1ad269e3d755df6621e682da1..681beec636bb63ed20ac31410113d0866c6d6be9 100644 (file)
@@ -162,13 +162,19 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV,
 
   // If the global is marked constant, we can put it into a mergable section,
   // a mergable string section, or general .data if it contains relocations.
-  if (GVar->isConstant() && GVar->hasUnnamedAddr()) {
+  if (GVar->isConstant()) {
     // If the initializer for the global contains something that requires a
     // relocation, then we may have to drop this into a wriable data section
     // even though it is marked const.
     switch (C->getRelocationInfo()) {
     default: assert(0 && "unknown relocation info kind");
     case Constant::NoRelocation:
+      // If the global is required to have a unique address, it can't be put
+      // into a mergable section: just drop it into the general read-only
+      // section instead.
+      if (!GVar->hasUnnamedAddr())
+        return SectionKind::getReadOnly();
+        
       // If initializer is a null-terminated string, put it in a "cstring"
       // section of the right width.
       if (const ArrayType *ATy = dyn_cast<ArrayType>(C->getType())) {