diff options
author | Fangrui Song <i@maskray.me> | 2025-07-19 16:55:29 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2025-07-19 16:55:30 -0700 |
commit | 39c8cfb70d203439e3296dfdfe3d41f1cb2ec551 (patch) | |
tree | d5cc9405d2e382022f7a641b0bf7606a1e5262e2 /llvm/lib/MC/MCStreamer.cpp | |
parent | 54492c231c5d9091d086bfb767423415ea6bd0bc (diff) | |
download | llvm-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.cpp | 11 |
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 |