Oh yeah, there are two of these now, unify both.
authorChris Lattner <sabre@nondot.org>
Tue, 9 May 2006 05:24:50 +0000 (05:24 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 9 May 2006 05:24:50 +0000 (05:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28192 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter.cpp

index dda8fd0d0545db6de355ec0cdb5df876aef202dd..dafad915bb65afd0985a10ca73c0635ae4a359ba 100644 (file)
@@ -65,34 +65,27 @@ AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm)
 void AsmPrinter::SwitchToTextSection(const char *NewSection,
                                      const GlobalValue *GV) {
   std::string NS;
+  if (GV && GV->hasSection())
+    NS = GV->getSection();
+  else
+    NS = NewSection;
+  
+  // If we're already in this section, we're done.
+  if (CurrentSection == NS) return;
 
   // Microsoft ML/MASM has a fundamentally different approach to handling
   // sections.
 
   if (MLSections) {
-    if (GV && GV->hasSection())
-      NS = GV->getSection();
-    else
-      NS = NewSection;
-
-    if (CurrentSection != NS) {
-      if (!CurrentSection.empty())
-        O << CurrentSection << "\tends\n\n";
-      CurrentSection = NS;
-      if (!CurrentSection.empty())
-        O << CurrentSection << "\tsegment 'CODE'\n";
-    }
+    if (!CurrentSection.empty())
+      O << CurrentSection << "\tends\n\n";
+    CurrentSection = NS;
+    if (!CurrentSection.empty())
+      O << CurrentSection << "\tsegment 'CODE'\n";
   } else {
-    if (GV && GV->hasSection())
-      NS = SwitchToSectionDirective + GV->getSection();
-    else
-      NS = std::string("\t")+NewSection;
-    
-    if (CurrentSection != NS) {
-      CurrentSection = NS;
-      if (!CurrentSection.empty())
-        O << CurrentSection << '\n';
-    }
+    CurrentSection = NS;
+    if (!CurrentSection.empty())
+      O << CurrentSection << '\n';
   }
 }