aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCMachOStreamer.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-06-23 10:08:51 -0700
committerFangrui Song <i@maskray.me>2024-06-23 10:08:52 -0700
commit21fac2d1d060b0f9b11a746718e58d4cd1ee97e5 (patch)
treee2f32591d8e4044b6a32d8691beb6330b81e4ee9 /llvm/lib/MC/MCMachOStreamer.cpp
parent6dc8de7a0abc7df8295273694fd9b951ed33708f (diff)
downloadllvm-21fac2d1d060b0f9b11a746718e58d4cd1ee97e5.zip
llvm-21fac2d1d060b0f9b11a746718e58d4cd1ee97e5.tar.gz
llvm-21fac2d1d060b0f9b11a746718e58d4cd1ee97e5.tar.bz2
[MC] Ensure all new sections have a MCDataFragment
MCAssembler::layout ensures that every section has at least one fragment, which simplifies MCAsmLayout::getSectionAddressSize (see e73353c7201a3080851d99a16f5fe2c17f7697c6 from 2010). It's better to ensure the condition is satisfied at create time (COFF, GOFF, Mach-O) to simplify more fragment processing.
Diffstat (limited to 'llvm/lib/MC/MCMachOStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCMachOStreamer.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index c0a36ae..18bfd08 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -554,13 +554,12 @@ void MCMachOStreamer::finalizeCGProfile() {
MCSection *CGProfileSection = Asm.getContext().getMachOSection(
"__LLVM", "__cg_profile", 0, SectionKind::getMetadata());
Asm.registerSection(*CGProfileSection);
- auto *Frag = getContext().allocFragment<MCDataFragment>();
- Frag->setParent(CGProfileSection);
- CGProfileSection->addFragment(*Frag);
// For each entry, reserve space for 2 32-bit indices and a 64-bit count.
size_t SectionBytes =
Asm.CGProfile.size() * (2 * sizeof(uint32_t) + sizeof(uint64_t));
- Frag->getContents().resize(SectionBytes);
+ cast<MCDataFragment>(*CGProfileSection->begin())
+ .getContents()
+ .resize(SectionBytes);
}
MCStreamer *llvm::createMachOStreamer(MCContext &Context,