Skip to content

Commit b0dea47

Browse files
authored
GOFF: Only register sections within MCObjectStreamer::changeSection
registerSection should only be called by MCObjectStreamer::changeSection. This will be utilized by a pending change to move initial fragment allocation from MCContext::createSection to MCStreamer::changeSection, resolving some issues (Fragments should only be created when using MCSteramer, not during `MCContext::getELFSection` calls) Pull Request: #150183
1 parent 3d9cf92 commit b0dea47

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

llvm/lib/MC/MCGOFFStreamer.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,15 @@ GOFFObjectWriter &MCGOFFStreamer::getWriter() {
2626
return static_cast<GOFFObjectWriter &>(getAssembler().getWriter());
2727
}
2828

29-
// Make sure that all section are registered in the correct order.
30-
static void registerSectionHierarchy(MCAssembler &Asm, MCSectionGOFF *Section) {
31-
if (Section->isRegistered())
32-
return;
33-
if (Section->getParent())
34-
registerSectionHierarchy(Asm, Section->getParent());
35-
Asm.registerSection(*Section);
36-
}
37-
3829
void MCGOFFStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
39-
registerSectionHierarchy(getAssembler(),
40-
static_cast<MCSectionGOFF *>(Section));
41-
MCObjectStreamer::changeSection(Section, Subsection);
30+
// Make sure that all section are registered in the correct order.
31+
SmallVector<MCSectionGOFF *> Sections;
32+
for (auto *S = static_cast<MCSectionGOFF *>(Section); S; S = S->getParent())
33+
Sections.push_back(S);
34+
while (!Sections.empty()) {
35+
auto *S = Sections.pop_back_val();
36+
MCObjectStreamer::changeSection(S, Sections.empty() ? Subsection : 0);
37+
}
4238
}
4339

4440
MCStreamer *llvm::createGOFFStreamer(MCContext &Context,

0 commit comments

Comments
 (0)