llvm-project
dc963db2 - [RISCV][MC] Diagnose symbol differences in instructions under relaxation (#247981)

Commit
1 day ago
[RISCV][MC] Diagnose symbol differences in instructions under relaxation (#247981) With linker relaxation enabled, the distance between two labels that span a relaxable instruction is only known at link time. `addReloc()` handles such a symbol difference by emitting an ADD/SUB relocation pair, but those exist only for data fixups. For an instruction operand, e.g. `li t0, (9f - 0f)`, it hit `llvm_unreachable("unsupported fixup size")`, and release builds emitted bogus relocations. Report an error at the operand instead, as GNU as does. Without relaxation the difference is still folded to a constant. A PC-relative target of the form `sym - .`, where `.` is the instruction itself, is a reference to `sym` and is resolved or relocated as such. The forms that reach this path past the parser are `li`, `qc.e.li`, and branches/`jal` with a label-difference target; all are covered by the new test. Fixes #184854 This change was written with the help of an AI tool (Claude Code); I reviewed and tested it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Author
Parents
Loading