[llvm] [MC][DebugInfo] Emit linetable entries with known offsets immediately (PR #134677)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 10 22:16:57 PDT 2025


MaskRay wrote:

The code does exhibit inefficiencies.
I've mitigated the issues and fixed correctness (RISC-V linker relaxation) in commits like 49488490d195591bfc90daef111cd7293f8c80aa (2023-05) and https://reviews.llvm.org/D150004 (2023-06),
(Some general MCFragment performance changes help as well).

Simplifying the code would enhance maintainability and reduce potential errors, particularly for linker relaxation targets like RISC-V, LoongArch, and potentially Xtensa. (My familiarity with those targets is limited. Many non-RISC-V targets probably haven't investigated much in this area yet.)

If we are going to introduce some complexity - yeah, testing `MCDataFragment` should be reliable. Perhaps use `MCDataFragment::isLinkerRelaxable`.
It should be more efficient than `if (AddrDelta->evaluateAsAbsolute(Res, getAssemblerPtr())) {` I removed from https://reviews.llvm.org/D150004 


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


More information about the llvm-commits mailing list