[llvm] [MC] Fix quadratic runtime within alignment boundary fragment relaxation (PR #176535)
Rafael Auler via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 21 12:05:27 PST 2026
rafaelauler wrote:
Elaborating on the use case here, this is not just about spectre/meltdown mitigation. Being able to align instructions is necessary for JIT engines that rely on MC assembler and for BOLT.
1) BOLT used to have an optimization that optimized for enhanced macroop fusion statistics (by avoiding straddling the cache line in CMP+JCC pairs, which would be fused in a single uop by the x86 decoder). This optimization was removed from open-source because there was no clear agreement on how MC assembler should support this. Properly supporting this might pave the way to bring this optimization back, if it shows good numbers on benchmarks.
2) In an x86 JIT engine, we want to patch at runtime a CALL target while program is running. The only safe way to do that in x86 is to align calls so they do not straddle cache lines, ensuring the target replacement is atomic. The MC assembler in its current shape can kill the performance of a JIT system if it reaches a quadratic runtime while trying to JIT code whose branch targets are patchable at runtime.
https://github.com/llvm/llvm-project/pull/176535
More information about the llvm-commits
mailing list