[all-commits] [llvm/llvm-project] 9beb46: MC: Store fragment content and fixups out-of-line

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Jul 1 00:21:34 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9beb467d9213fe2becdb0f1469d99ca058189ac7
      https://github.com/llvm/llvm-project/commit/9beb467d9213fe2becdb0f1469d99ca058189ac7
  Author: Fangrui Song <i at maskray.me>
  Date:   2025-07-01 (Tue, 01 Jul 2025)

  Changed paths:
    M llvm/include/llvm/MC/MCSection.h
    M llvm/lib/MC/MCAssembler.cpp
    M llvm/lib/MC/MCCodeView.cpp
    M llvm/lib/MC/MCELFStreamer.cpp
    M llvm/lib/MC/MCFragment.cpp
    M llvm/lib/MC/MCObjectStreamer.cpp
    M llvm/lib/MC/MCSection.cpp
    M llvm/lib/MC/MachObjectWriter.cpp
    M llvm/lib/MC/WinCOFFObjectWriter.cpp
    M llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
    M llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

  Log Message:
  -----------
  MC: Store fragment content and fixups out-of-line

Moved `Contents` and `Fixups` SmallVector storage to MCSection, enabling
trivial destructors for most fragment subclasses and eliminating the need
for MCFragment::destroy in ~MCSection.

For appending content to the current section, use
getContentsForAppending. During assembler relaxation, prefer
setContents/setFixups, which may involve copying and reduce the benefits
of https://reviews.llvm.org/D145791.

Moving only Contents out-of-line caused a slight performance regression
(Alexis Engelke's 2024 prototype). By also moving Fragments out-of-line,
fragment destructors become trivial, resulting in
neglgible instructions:u increase for "stage2-O0-g" and [large max-rss decrease](https://llvm-compile-time-tracker.com/compare.php?from=84e82746c3ff63ec23a8b85e9efd4f7fccf92590&to=555a28c0b2f8250a9cf86fd267a04b0460283e15&stat=max-rss&linkStats=on)
for the "stage1-ReleaseLTO-g (link only)" benchmark.
(
An older version using fewer inline functions: https://llvm-compile-time-tracker.com/compare.php?from=bb982e733cfcda7e4cfb0583544f68af65211ed1&to=f12d55f97c47717d438951ecddecf8ebd28c296b&linkStats=on
)

Now using plain SmallVector in MCSection for storage, with potential for
future allocator optimizations, such as allocating `Contents` as the
trailing object of MCDataFragment. (GNU Assembler uses gnulib's obstack
for fragment management.)

Co-authored-by: Alexis Engelke <engelke at in.tum.de>

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



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list