[llvm] MC: Restructure MCFragment as a fixed part and a variable tail (PR #148544)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 02:52:08 PDT 2025


================
@@ -256,7 +261,10 @@ void MCObjectStreamer::emitULEB128Value(const MCExpr *Value) {
     emitULEB128IntValue(IntValue);
     return;
   }
-  insert(getContext().allocFragment<MCLEBFragment>(*Value, false));
+  auto *F = getOrCreateDataFragment();
+  F->Kind = MCFragment::FT_LEB;
----------------
aengelke wrote:

Note for future refactorings: getOrCreateDataFragment is hot code (called once per instruction). Changes to fragment types occur more rarely. We could eagerly allocate a new current fragment in these places and simplify the check. (Actually, the STI also changes rarely, maybe at some point we could avoid the check entirely?)

https://github.com/llvm/llvm-project/pull/148544


More information about the llvm-commits mailing list