Close unique sections when switching away from them.
[oota-llvm.git] / lib / MC / MCStreamer.cpp
index 27d0355bb1175882fa552e186cbe964ad6deb465..3db2345540424791eeb09f95f83b8da1aed92194 100644 (file)
@@ -669,6 +669,12 @@ void MCStreamer::SwitchSection(const MCSection *Section,
   MCSectionSubPair curSection = SectionStack.back().first;
   SectionStack.back().second = curSection;
   if (MCSectionSubPair(Section, Subsection) != curSection) {
+    const MCSection *CurSec = curSection.first;
+    if (CurSec && CurSec->isUnique()) {
+      MCSymbol *Sym = curSection.first->getEndSymbol(Context);
+      if (!Sym->isInSection())
+        EmitLabel(Sym);
+    }
     SectionStack.back().first = MCSectionSubPair(Section, Subsection);
     assert(!Section->hasEnded() && "Section already ended");
     ChangeSection(Section, Subsection);