remove the SelectSectionForMachineConst hook, replacing it with
a new getSectionForMergableConstant hook.  This removes one dependence
of TAI on Type, and provides the hook with enough info to make the 
right decision based on whether the global has relocations etc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76705 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/DarwinTargetAsmInfo.cpp b/lib/Target/DarwinTargetAsmInfo.cpp
index 30468ef..ad9dd68 100644
--- a/lib/Target/DarwinTargetAsmInfo.cpp
+++ b/lib/Target/DarwinTargetAsmInfo.cpp
@@ -29,7 +29,7 @@
   : TargetAsmInfo(TM) {
 
   CStringSection_ = getUnnamedSection("\t.cstring",
-                                SectionFlags::Mergeable | SectionFlags::Strings);
+                                SectionFlags::Mergeable |SectionFlags::Strings);
   FourByteConstantSection = getUnnamedSection("\t.literal4\n",
                                               SectionFlags::Mergeable);
   EightByteConstantSection = getUnnamedSection("\t.literal8\n",
@@ -182,28 +182,30 @@
 const Section*
 DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
   const TargetData *TD = TM.getTargetData();
-
-  unsigned Size = TD->getTypeAllocSize(Ty);
-  if (Size == 4)
-    return FourByteConstantSection;
-  else if (Size == 8)
-    return EightByteConstantSection;
-  else if (Size == 16 && SixteenByteConstantSection)
-    return SixteenByteConstantSection;
-
-  return getReadOnlySection();
+  return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
 }
 
-const Section*
-DarwinTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
-  const Section* S = MergeableConstSection(Ty);
-
-  // Handle weird special case, when compiling PIC stuff.
-  if (S == getReadOnlySection() &&
-      TM.getRelocationModel() != Reloc::Static)
+const Section *
+DarwinTargetAsmInfo::getSectionForMergableConstant(uint64_t Size,
+                                                   unsigned ReloInfo) const {
+  // If this constant requires a relocation, we have to put it in the data
+  // segment, not in the text segment.
+  if (ReloInfo != 0)
     return ConstDataSection;
-
-  return S;
+  
+  switch (Size) {
+  default: break;
+  case 4:
+    return FourByteConstantSection;
+  case 8:
+    return EightByteConstantSection;
+  case 16:
+    if (SixteenByteConstantSection)
+      return SixteenByteConstantSection;
+    break;
+  }
+  
+  return ReadOnlySection;  // .const
 }
 
 std::string