Eliminate getNamed/getUnnamedSection, adding a new and unified getOrCreateSection
instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77186 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp
index 604c54e..de333a8 100644
--- a/lib/Target/TargetAsmInfo.cpp
+++ b/lib/Target/TargetAsmInfo.cpp
@@ -122,8 +122,8 @@
   DwarfEHFrameSection = ".eh_frame";
   DwarfExceptionSection = ".gcc_except_table";
   AsmTransCBE = 0;
-  TextSection = getUnnamedSection("\t.text", SectionKind::Text);
-  DataSection = getUnnamedSection("\t.data", SectionKind::DataRel);
+  TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
+  DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel);
 }
 
 TargetAsmInfo::~TargetAsmInfo() {
@@ -314,7 +314,7 @@
     // section and still get the appropriate section flags printed.
     GVKind = getKindForNamedSection(GV->getSection().c_str(), GVKind);
     
-    return getNamedSection(GV->getSection().c_str(), GVKind);
+    return getOrCreateSection(GV->getSection().c_str(), false, GVKind);
   }
 
   // If this global is linkonce/weak and the target handles this by emitting it
@@ -323,7 +323,7 @@
     if (const char *Prefix = getSectionPrefixForUniqueGlobal(Kind)) {
       // FIXME: Use mangler interface (PR4584).
       std::string Name = Prefix+GV->getNameStr();
-      return getNamedSection(Name.c_str(), GVKind);
+      return getOrCreateSection(Name.c_str(), false, GVKind);
     }
   }
   
@@ -364,33 +364,20 @@
 }
 
 
-const Section *TargetAsmInfo::getNamedSection(const char *Name,
-                                              SectionKind::Kind Kind) const {
+const Section *TargetAsmInfo::getOrCreateSection(const char *Name,
+                                                 bool isDirective,
+                                                 SectionKind::Kind Kind) const {
   Section &S = Sections[Name];
 
   // This is newly-created section, set it up properly.
   if (S.Name.empty()) {
-    S.Kind = SectionKind::get(Kind, false /*weak*/, true /*Named*/);
+    S.Kind = SectionKind::get(Kind, false /*weak*/, !isDirective);
     S.Name = Name;
   }
 
   return &S;
 }
 
-const Section*
-TargetAsmInfo::getUnnamedSection(const char *Directive,
-                                 SectionKind::Kind Kind) const {
-  Section& S = Sections[Directive];
-
-  // This is newly-created section, set it up properly.
-  if (S.Name.empty()) {
-    S.Kind = SectionKind::get(Kind, false /*weak*/, false /*Named*/);
-    S.Name = Directive;
-  }
-
-  return &S;
-}
-
 unsigned TargetAsmInfo::getULEB128Size(unsigned Value) {
   unsigned Size = 0;
   do {