<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/202171>202171</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISC-V][lld] ld.lld general call relaxation missing (before LLVM 15)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
XiaobingHou1219
</td>
</tr>
</table>
<pre>
I ran into this while reducing a RISC-V linker testcase. The reproducer is small, and I have been seeing the same result consistently across three reruns.
### Summary
ld.lld 14.0.6 links the legal input successfully but leaves the ordinary in-range call and jump sites as long `auipc+jalr` sequences. ld.lld 15.0.7 and 22.1.0 relax the same sites to shorter `jal` and `c.j` instructions.
### Expected behavior
Link a fixed-layout RV64 executable whose startup path and helper section contain several ordinary in-range `jump` and `call` sites. A correct final linker should rewrite the legal `auipc+jalr` sequences to `jal` or `c.j` where the final displacement allows it.
### Environment
- linker route: llvm-mc 22 plus ld.lld version replay
- march: rv64imac
- mabi: lp64
- first failing stage: link
- local stability check: True
### Reduced testcase
These are the reduced input files from the minimized reproducer I used locally:
#### `a.s`
```asm
.global _start, ifunc
_start:
jump abs, t2
jump abs, t3
call abs
tail abs
.section .mid,"ax",@progbits
.balign 16
tail ifunc@plt
tail ifunc@plt
.type ifunc, @gnu_indirect_function
ifunc:
ret
```
### Reproduction notes
- This packaged root does not have a single canonical `run.ps1` wrapper.
- Use the reduced inputs under `case/` and follow the commands documented in `case/README.md`.
- Stable witness outputs, when present, are preserved under `verify/run1..run3/`.
### What I checked
- Reduced inputs are preserved under case/.
- Stable witness outputs are preserved under verify/run1..run3/.
- The strict recheck says stable normalized run signatures across three runs: True.
- Tracker guidance link: https://llvm.org/docs/HowToSubmitABug.html
- evidence summary: 3 clean reproductions under hunt/verify/lld_general_call_relaxation_missing_before_15/run1..run3 show stable assembly success for `a.o`, stable 14.0.6 outputs whose `_start` and `.mid` sites remain `auipc+jalr`, and stable 15.0.7/22.1.0 outputs whose corresponding sites are rewritten to `jal` or `c.j`. This root is distinct from the no-`c` mixed-input bug because the issue here is missing legal relaxation, not choosing an over-compressed encoding for a no-`c` file.
### Notes
upstream/llvm-project/lld/test/ELF/riscv-relax-call2.s
Root key: `lld.riscv.general_call_relaxation_missing_before_15`
Case id: `20260528-lld-general-call-relaxation-missing`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMV81u67gVfhplc2BBlm1de-FFbnKDCXCni9x02p1BkccSE4pUeUgn7tMXh5TiZJpMCxhBRJ3_n--jBJHuLOK-2HwvNrdXIobe-f0_tXCttt1vLi7r5e6qdeq8vwcvLGgbHIReE7z02iB4VFFq24GAh_tfN4s_wGj7jB4CUpCCsITHnsVG71SU6EET0CCMKeobEFbBPfTihNAiWiBEthV6BBIDq1E0AaSzpCmgDeYMQnpHBKH3yAI-WiqL6raorqe_9Sr_4FccBuHP-dio0hgFy3VZlU0KkpIfg50woO0YA1CUEomO0ZgztDGAQXHCLOe80lb4M2i78MJ2CFIYkzJ4isMIpAMSCALjbAdFU4moR1nU35-E8UVTAeG_IlqJVMIcy6asym_JRF2Xy7ICj0a8XtLPNoMD6p0P6NnskzBsjZWKppLlEz9pS8FHGbT7shg_XkeUARW02IuTdj4L_NT2GQQc9SuqhRFnFwM8_NGsAV9RxiBag_DSO0KgIHyII4wi9Ml9j2ZED4TJLzcpCM09PKEX5pOCcfRxGN-Hz3PAteFES7gG6bxHGeCorTDzKFHvolHg8cXrgO-69ldV5rJdyuX8u2q99OizmexGaRqNkDigDSCMcS8EOnxVR3vS3lmWza8Wc5jexYDF6hqMOQ2LQUJdw2gize0-oSculMfRiPOsPAgve9byp2atByEvL1qdrI3Nej47ak8BjkIbXhMKossOtX1-C8ZJYfhVq40OZ5A9ymcWevQRP0_pgXcY1dvK5vePPRKCmCrlJ5m8KEdtkODo3ZBeDtrqQf8b1fs9v4dIqHI85lysrj91zv65jSUVTTW9a6r8EzTkk7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