Skip to content

Commit

Permalink
[MC] Chain together fragments only if Subsections.size() > 1
Browse files Browse the repository at this point in the history
and delete an unneeded setParent call.
  • Loading branch information
MaskRay authored and AlexisPerry committed Jun 27, 2024
1 parent b558f0c commit f038493
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions llvm/lib/MC/MCAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,22 +866,23 @@ void MCAssembler::layout(MCAsmLayout &Layout) {
Sec->setLayoutOrder(i);

// Chain together fragments from all subsections.
MCDummyFragment Dummy;
Dummy.setParent(Sec);
MCFragment *Tail = &Dummy;
for (auto &[_, List] : Sec->Subsections) {
if (!List.Head)
continue;
Tail->Next = List.Head;
Tail = List.Tail;
}
Sec->Subsections.clear();
Sec->Subsections.push_back({0u, {Dummy.getNext(), Tail}});
Sec->CurFragList = &Sec->Subsections[0].second;
if (Sec->Subsections.size() > 1) {
MCDummyFragment Dummy;
MCFragment *Tail = &Dummy;
for (auto &[_, List] : Sec->Subsections) {
if (!List.Head)
continue;
Tail->Next = List.Head;
Tail = List.Tail;
}
Sec->Subsections.clear();
Sec->Subsections.push_back({0u, {Dummy.getNext(), Tail}});
Sec->CurFragList = &Sec->Subsections[0].second;

unsigned FragmentIndex = 0;
for (MCFragment &Frag : *Sec)
Frag.setLayoutOrder(FragmentIndex++);
unsigned FragmentIndex = 0;
for (MCFragment &Frag : *Sec)
Frag.setLayoutOrder(FragmentIndex++);
}
}

// Layout until everything fits.
Expand Down

0 comments on commit f038493

Please sign in to comment.