[lld] [RISCV][LLD] Zcmt RISC-V extension in lld (PR #183450)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu May 7 23:36:57 PDT 2026
================
@@ -912,6 +987,9 @@ static void relaxCall(Ctx &ctx, const InputSection &sec, size_t i, uint64_t loc,
sec.relaxAux->relocTypes[i] = R_RISCV_RVC_JUMP;
sec.relaxAux->writes.push_back(0x2001); // c.jal
remove = 6;
+ } else if (remove >= (r.type == R_RISCV_JAL ? 2 : 6) &&
----------------
MaskRay wrote:
The `r.type == R_RISCV_JAL ? 2 : 6` ternary is unreachable: `relaxCall` is dispatched only from the `case R_RISCV_CALL: case R_RISCV_CALL_PLT:` arm in `relax()`. The `case R_RISCV_JAL:` arm calls `relaxTableJump` directly, bypassing `relaxCall`. `r.type`
here is always `R_RISCV_CALL`/`R_RISCV_CALL_PLT`, so the threshold is always 6. Replace with `remove >= 6` and drop the dead branch.
https://github.com/llvm/llvm-project/pull/183450
More information about the llvm-commits
mailing list