aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCObjectStreamer.cpp
diff options
context:
space:
mode:
authordyung <douglas.yung@sony.com>2025-07-25 23:21:59 -0400
committerGitHub <noreply@github.com>2025-07-25 20:21:59 -0700
commitcb37916a2596e0936c76bbd9927f8353faac9fa8 (patch)
tree8b4dce8ecf8199bfe52f9625b6062d10e1a7d38c /llvm/lib/MC/MCObjectStreamer.cpp
parent3f8a05893f98989630b6f498c6c5f382afe24561 (diff)
downloadllvm-cb37916a2596e0936c76bbd9927f8353faac9fa8.zip
llvm-cb37916a2596e0936c76bbd9927f8353faac9fa8.tar.gz
llvm-cb37916a2596e0936c76bbd9927f8353faac9fa8.tar.bz2
Revert "MC: Allocate initial fragment and define section symbol in changeSection" (#150736)
Reverts llvm/llvm-project#150574 This is causing a test failure on AArch64 MacOS bots: https://lab.llvm.org/buildbot/#/builders/190/builds/24187
Diffstat (limited to 'llvm/lib/MC/MCObjectStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp25
1 files changed, 5 insertions, 20 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index 37b6629..fcd5cbf 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -185,10 +185,10 @@ void MCObjectStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
getAssembler().registerSymbol(*Symbol);
- // Set the fragment and offset. This function might be called by
- // changeSection, when the section stack top hasn't been changed to the new
- // section.
- MCFragment *F = CurFrag;
+ // If there is a current fragment, mark the symbol as pointing into it.
+ // Otherwise queue the label and set its fragment pointer when we emit the
+ // next fragment.
+ MCFragment *F = getCurrentFragment();
Symbol->setFragment(F);
Symbol->setOffset(F->getContents().size());
@@ -247,15 +247,6 @@ void MCObjectStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
assert(Section && "Cannot switch to a null section!");
getContext().clearDwarfLocSeen();
- // Register the section and create an initial fragment for subsection 0
- // if `Subsection` is non-zero.
- bool NewSec = getAssembler().registerSection(*Section);
- MCFragment *F0 = nullptr;
- if (NewSec && Subsection) {
- changeSection(Section, 0);
- F0 = CurFrag;
- }
-
auto &Subsections = Section->Subsections;
size_t I = 0, E = Subsections.size();
while (I != E && Subsections[I].first < Subsection)
@@ -271,13 +262,7 @@ void MCObjectStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
Section->CurFragList = &Subsections[I].second;
CurFrag = Section->CurFragList->Tail;
- // Define the section symbol at subsection 0's initial fragment if required.
- if (!NewSec)
- return;
- if (auto *Sym = Section->getBeginSymbol()) {
- Sym->setFragment(Subsection ? F0 : CurFrag);
- getAssembler().registerSymbol(*Sym);
- }
+ getAssembler().registerSection(*Section);
}
void MCObjectStreamer::switchSectionNoPrint(MCSection *Section) {