inline the two MergeableConstSection implementations into their
authorChris Lattner <sabre@nondot.org>
Wed, 22 Jul 2009 00:47:11 +0000 (00:47 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 22 Jul 2009 00:47:11 +0000 (00:47 +0000)
only caller.

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

include/llvm/Target/DarwinTargetAsmInfo.h
include/llvm/Target/ELFTargetAsmInfo.h
lib/Target/DarwinTargetAsmInfo.cpp
lib/Target/ELFTargetAsmInfo.cpp

index edce64096a9728dec1c9c867279d85ec4fb47666..a6f48e1ea3c7a496461a8957eb6664cac2eef71f 100644 (file)
@@ -45,7 +45,6 @@ namespace llvm {
     getSectionForMergableConstant(uint64_t Size, unsigned ReloInfo) const;
     
   private:
-    const Section* MergeableConstSection(const Type *Ty) const;
     const Section* MergeableStringSection(const GlobalVariable *GV) const;
   };
 }
index c06a5a9f287363fef89f93661e7912675eae12c6..dd311c3116ddd1e7f1600a4fdd4a7a1008ceda43 100644 (file)
@@ -42,7 +42,6 @@ namespace llvm {
     const Section* DataRelROLocalSection;
     
   private:
-    const Section* MergeableConstSection(const Type *Ty) const;
     const Section* MergeableStringSection(const GlobalVariable *GV) const;
   };
 }
index ad9dd6884f482bfc0dd33aff40af8efd80a2c296..bc2189e1ef0f511865c485be292c6b040b3d0555 100644 (file)
@@ -131,31 +131,33 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
   bool isNonStatic = TM.getRelocationModel() != Reloc::Static;
 
   switch (Kind) {
-   case SectionKind::Text:
+  case SectionKind::Text:
     if (isWeak)
       return TextCoalSection;
     else
       return TextSection;
-   case SectionKind::Data:
-   case SectionKind::ThreadData:
-   case SectionKind::BSS:
-   case SectionKind::ThreadBSS:
+  case SectionKind::Data:
+  case SectionKind::ThreadData:
+  case SectionKind::BSS:
+  case SectionKind::ThreadBSS:
     if (cast<GlobalVariable>(GV)->isConstant())
       return (isWeak ? ConstDataCoalSection : ConstDataSection);
     else
       return (isWeak ? DataCoalSection : DataSection);
-   case SectionKind::ROData:
+  case SectionKind::ROData:
     return (isWeak ? ConstDataCoalSection :
             (isNonStatic ? ConstDataSection : getReadOnlySection()));
-   case SectionKind::RODataMergeStr:
+  case SectionKind::RODataMergeStr:
     return (isWeak ?
             ConstTextCoalSection :
             MergeableStringSection(cast<GlobalVariable>(GV)));
-   case SectionKind::RODataMergeConst:
+  case SectionKind::RODataMergeConst: {
     if (isWeak) return ConstDataCoalSection;
-    return MergeableConstSection(cast<GlobalVariable>(GV)
-                                 ->getInitializer()->getType());
-   default:
+    const Type *Ty = cast<GlobalVariable>(GV)->getInitializer()->getType();
+    const TargetData *TD = TM.getTargetData();
+    return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
+  }
+  default:
     llvm_unreachable("Unsuported section kind for global");
   }
 
@@ -179,12 +181,6 @@ DarwinTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
   return getReadOnlySection();
 }
 
-const Section*
-DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
-  const TargetData *TD = TM.getTargetData();
-  return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
-}
-
 const Section *
 DarwinTargetAsmInfo::getSectionForMergableConstant(uint64_t Size,
                                                    unsigned ReloInfo) const {
index fe006a3c6072df6178e83be8ab5797ed874805b4..cf4e3a2f1484292dc5416370b0e1a883ce0cfa6d 100644 (file)
@@ -121,8 +121,11 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
         return getReadOnlySection();
       case SectionKind::RODataMergeStr:
         return MergeableStringSection(GVar);
-      case SectionKind::RODataMergeConst:
-        return MergeableConstSection(GVar->getInitializer()->getType());
+      case SectionKind::RODataMergeConst: {
+        const Type *Ty = GVar->getInitializer()->getType();
+        const TargetData *TD = TM.getTargetData();
+        return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
+      }
       case SectionKind::ThreadData:
         // ELF targets usually support TLS stuff
         return TLSDataSection;
@@ -165,12 +168,6 @@ ELFTargetAsmInfo::getSectionForMergableConstant(uint64_t Size,
 }
 
 
-const Section*
-ELFTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
-  const TargetData *TD = TM.getTargetData();
-  return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
-}
-
 const Section*
 ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
   const TargetData *TD = TM.getTargetData();