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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 00:38:45 PDT 2025


MaskRay wrote:

> Just to add an observation here. I have been debugging a breakage in downstream code due to this change and it turned out it was due to `setContents/clearContents/getContents`, etc [ there are many, also fixups ] changing their meaning. Previously, these members were used to access a relaxable fragment content. Now this content is in a variable part, and one must switch to `getVarContents` to keep the same behavior. I wonder if bundling two unrelated fragments into one for minor performance reasons is worth the confusion and how well it's aligned with one of the stated goals of making the assembler design "less poor".

This change enhances performance on its own while paving the way for additional optimization opportunities, including: https://maskray.me/blog/2025-07-27-llvm-integrated-assembler-engineering-better-fragments

* Eager fragment creation: Optimization as well as simplification
* Fragment content in trailing data

Downstream users relying on `setContents, clearContents, or getContents` will need to adapt, likely transitioning to the `setVar*` family of functions. However, this should not a reason to block optimization and interface improvement.

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


More information about the llvm-commits mailing list