Skip to content

Commit 726c69f

Browse files
MaskRaylravenclaw
authored andcommitted
[MC] Chain together fragments only if Subsections.size() > 1
and delete an unneeded setParent call.
1 parent e8a5add commit 726c69f

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

llvm/lib/MC/MCAssembler.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -866,22 +866,23 @@ void MCAssembler::layout(MCAsmLayout &Layout) {
866866
Sec->setLayoutOrder(i);
867867

868868
// Chain together fragments from all subsections.
869-
MCDummyFragment Dummy;
870-
Dummy.setParent(Sec);
871-
MCFragment *Tail = &Dummy;
872-
for (auto &[_, List] : Sec->Subsections) {
873-
if (!List.Head)
874-
continue;
875-
Tail->Next = List.Head;
876-
Tail = List.Tail;
877-
}
878-
Sec->Subsections.clear();
879-
Sec->Subsections.push_back({0u, {Dummy.getNext(), Tail}});
880-
Sec->CurFragList = &Sec->Subsections[0].second;
869+
if (Sec->Subsections.size() > 1) {
870+
MCDummyFragment Dummy;
871+
MCFragment *Tail = &Dummy;
872+
for (auto &[_, List] : Sec->Subsections) {
873+
if (!List.Head)
874+
continue;
875+
Tail->Next = List.Head;
876+
Tail = List.Tail;
877+
}
878+
Sec->Subsections.clear();
879+
Sec->Subsections.push_back({0u, {Dummy.getNext(), Tail}});
880+
Sec->CurFragList = &Sec->Subsections[0].second;
881881

882-
unsigned FragmentIndex = 0;
883-
for (MCFragment &Frag : *Sec)
884-
Frag.setLayoutOrder(FragmentIndex++);
882+
unsigned FragmentIndex = 0;
883+
for (MCFragment &Frag : *Sec)
884+
Frag.setLayoutOrder(FragmentIndex++);
885+
}
885886
}
886887

887888
// Layout until everything fits.

0 commit comments

Comments
 (0)