[lld] [RISCV][LLD] Zcmt RISC-V extension in lld (PR #183450)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 13 02:08:44 PDT 2026
LukeZhuang wrote:
@MaskRay Thanks for the improvements! I like the idea of using `MapVector` which significantly simplifies `selectEntries` and `writeEntries`, thanks! :)
The only question I have is in the scanning part here:
```
// Use the input instruction size to estimate savings. R_RISCV_CALL/
// CALL_PLT are 8-byte auipc+jalr sequences (saving 6 bytes to cm.jt),
// while R_RISCV_JAL is already 4 bytes (saving 2 bytes). The actual
// saving may be less if the call relaxes to jal first, but this is a
// reasonable upper bound for candidate selection.
int saved = r.type == R_RISCV_JAL ? 2 : 6;
```
If the call could be relaxed to the 4-bytes jal, isn't the further saving to `cm.jalt` ought be 2 bytes instead of 6? In another words, would something like this:
```
int saved = (r.type == R_RISCV_JAL || isInt<21>(displace)) ? 2 : 6;
```
be more precise?
https://github.com/llvm/llvm-project/pull/183450
More information about the llvm-commits
mailing list