Add hook for constant pool section selection for darwin.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54449 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/DarwinTargetAsmInfo.cpp b/lib/Target/DarwinTargetAsmInfo.cpp
index 564d1a1..749cb71 100644
--- a/lib/Target/DarwinTargetAsmInfo.cpp
+++ b/lib/Target/DarwinTargetAsmInfo.cpp
@@ -107,10 +107,16 @@
 
 const Section*
 DarwinTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const {
-  const TargetData *TD = DTM->getTargetData();
   Constant *C = cast<GlobalVariable>(GV)->getInitializer();
 
-  unsigned Size = TD->getABITypeSize(C->getType());
+  return MergeableConstSection(C->getType());
+}
+
+inline const Section*
+DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
+  const TargetData *TD = DTM->getTargetData();
+
+  unsigned Size = TD->getABITypeSize(Ty);
   if (Size == 4)
     return FourByteConstantSection_;
   else if (Size == 8)
@@ -121,6 +127,18 @@
   return getReadOnlySection_();
 }
 
+const Section*
+DarwinTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const {
+  const Section* S = MergeableConstSection(Ty);
+
+  // Handle weird special case, when compiling PIC stuff.
+  if (S == getReadOnlySection_() &&
+      DTM->getRelocationModel() != Reloc::Static)
+    return ConstDataSection;
+
+  return S;
+}
+
 std::string
 DarwinTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
                                                SectionKind::Kind kind) const {