diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-03-23 21:22:04 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-03-23 21:22:04 +0000 |
commit | f2b408c64e3d1503a3e7c63b3b48fb9c42e7aff6 (patch) | |
tree | 45e4c02585d401dc3d72cfa3d5954af80293ced0 /llvm/lib/MC/MCStreamer.cpp | |
parent | 328c0c11a8033fa6b8d716e6a08be3e07a20a1af (diff) | |
download | llvm-f2b408c64e3d1503a3e7c63b3b48fb9c42e7aff6.zip llvm-f2b408c64e3d1503a3e7c63b3b48fb9c42e7aff6.tar.gz llvm-f2b408c64e3d1503a3e7c63b3b48fb9c42e7aff6.tar.bz2 |
Refactor how passes get a symbol at the end of a section.
There is now a canonical symbol at the end of a section that different
passes can request.
This also allows us to assert that we don't switch back to a section whose
end symbol has already been printed.
llvm-svn: 233026
Diffstat (limited to 'llvm/lib/MC/MCStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCStreamer.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index 63b0bf2..27d0355 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -670,9 +670,22 @@ void MCStreamer::SwitchSection(const MCSection *Section, SectionStack.back().second = curSection; if (MCSectionSubPair(Section, Subsection) != curSection) { SectionStack.back().first = MCSectionSubPair(Section, Subsection); + assert(!Section->hasEnded() && "Section already ended"); ChangeSection(Section, Subsection); MCSymbol *Sym = Section->getBeginSymbol(); if (Sym && !Sym->isInSection()) EmitLabel(Sym); } } + +MCSymbol *MCStreamer::endSection(const MCSection *Section) { + // TODO: keep track of the last subsection so that this symbol appears in the + // correct place. + MCSymbol *Sym = Section->getEndSymbol(Context); + if (Sym->isInSection()) + return Sym; + + SwitchSection(Section); + EmitLabel(Sym); + return Sym; +} |