[llvm-branch-commits] GOFF: Only register sections within MCObjectStreamer::changeSection (PR #150183)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 23 00:54:20 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mc
Author: Fangrui Song (MaskRay)
<details>
<summary>Changes</summary>
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)
---
Full diff: https://github.com/llvm/llvm-project/pull/150183.diff
1 Files Affected:
- (modified) llvm/lib/MC/MCGOFFStreamer.cpp (+8-12)
``````````diff
diff --git a/llvm/lib/MC/MCGOFFStreamer.cpp b/llvm/lib/MC/MCGOFFStreamer.cpp
index b7021915e7b70..7828065a7f360 100644
--- a/llvm/lib/MC/MCGOFFStreamer.cpp
+++ b/llvm/lib/MC/MCGOFFStreamer.cpp
@@ -26,19 +26,15 @@ GOFFObjectWriter &MCGOFFStreamer::getWriter() {
return static_cast<GOFFObjectWriter &>(getAssembler().getWriter());
}
-// Make sure that all section are registered in the correct order.
-static void registerSectionHierarchy(MCAssembler &Asm, MCSectionGOFF *Section) {
- if (Section->isRegistered())
- return;
- if (Section->getParent())
- registerSectionHierarchy(Asm, Section->getParent());
- Asm.registerSection(*Section);
-}
-
void MCGOFFStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
- registerSectionHierarchy(getAssembler(),
- static_cast<MCSectionGOFF *>(Section));
- MCObjectStreamer::changeSection(Section, Subsection);
+ // Make sure that all section are registered in the correct order.
+ SmallVector<MCSectionGOFF *> Sections;
+ for (auto *S = static_cast<MCSectionGOFF *>(Section); S; S = S->getParent())
+ Sections.push_back(S);
+ while (!Sections.empty()) {
+ auto *S = Sections.pop_back_val();
+ MCObjectStreamer::changeSection(S, 0);
+ }
}
MCStreamer *llvm::createGOFFStreamer(MCContext &Context,
``````````
</details>
https://github.com/llvm/llvm-project/pull/150183
More information about the llvm-branch-commits
mailing list