aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCStreamer.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2025-07-19 16:55:29 -0700
committerFangrui Song <i@maskray.me>2025-07-19 16:55:30 -0700
commit39c8cfb70d203439e3296dfdfe3d41f1cb2ec551 (patch)
treed5cc9405d2e382022f7a641b0bf7606a1e5262e2 /llvm/lib/MC/MCStreamer.cpp
parent54492c231c5d9091d086bfb767423415ea6bd0bc (diff)
downloadllvm-39c8cfb70d203439e3296dfdfe3d41f1cb2ec551.zip
llvm-39c8cfb70d203439e3296dfdfe3d41f1cb2ec551.tar.gz
llvm-39c8cfb70d203439e3296dfdfe3d41f1cb2ec551.tar.bz2
MC: Optimize getOrCreateDataFragment
... by eagerly allocating an empty fragment when adding a fragment with a variable-size tail. X86AsmBackend, The JCC erratum mitigation and x86-pad-for-align set a flag for FT_Relaxable, which needs to be moved to emitInstructionBegin. ``` if (CF->getKind() == MCFragment::FT_Relaxable) CF->setAllowAutoPadding(canPadInst(Inst, OS)); ``` Follow-up to #148544
Diffstat (limited to 'llvm/lib/MC/MCStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCStreamer.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index c3ecf8f..b0e52bf 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -1404,7 +1404,7 @@ MCSymbol *MCStreamer::endSection(MCSection *Section) {
return Sym;
}
-void MCStreamer::insert(MCFragment *F) {
+void MCStreamer::addFragment(MCFragment *F) {
auto *Sec = CurFrag->getParent();
F->setParent(Sec);
F->setLayoutOrder(CurFrag->getLayoutOrder() + 1);
@@ -1414,7 +1414,14 @@ void MCStreamer::insert(MCFragment *F) {
}
void MCStreamer::newFragment() {
- insert(getContext().allocFragment<MCFragment>());
+ addFragment(getContext().allocFragment<MCFragment>());
+}
+
+void MCStreamer::insert(MCFragment *F) {
+ assert(F->getKind() != MCFragment::FT_Data &&
+ "F should have a variable-size tail");
+ addFragment(F);
+ newFragment();
}
static VersionTuple