[llvm] MC: Store fragment content and fixups out-of-line (PR #146307)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 29 22:46:04 PDT 2025


================
@@ -449,11 +449,13 @@ void MCELFStreamer::emitInstToData(const MCInst &Inst,
   // Emit instruction directly into data fragment.
   size_t FixupStartIndex = DF->getFixups().size();
   size_t CodeOffset = DF->getContents().size();
-  Assembler.getEmitter().encodeInstruction(Inst, DF->getContents(),
-                                           DF->getFixups(), STI);
+  SmallVector<MCFixup, 1> Fixups;
+  Assembler.getEmitter().encodeInstruction(Inst, DF->getContentsForAppending(),
+                                           Fixups, STI);
+  DF->doneAppending();
+  DF->appendFixups(Fixups);
----------------
aengelke wrote:

Same here. Early return for empty fixups, getFixups below is also out-of-line (setHasInstructions can be moved up).

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


More information about the llvm-commits mailing list