Commit 856745c5 authored by Job Noorman's avatar Job Noorman
Browse files

[RISCV][MC] Relax conditional branches to unresolved symbols

D108961 introduced relaxation for out-of-range conditional branches.
However, relaxation was only performed when the branch target could be
resolved. I believe this has two undesired consequences:

- `b<cc> ... foo`, where `foo` is undefined, would not be relaxed
  although there is no guarantee the offset to `foo` will fit;
- Conditional branches are never relaxed with `-mattr=+relax` because MC
  considers fixups where `shouldForceRelocation` returns true (which
  will be the case with `+relax`) to be unresolved.

Note that binutils performs conditional branch relaxation in both cases.

This patch proposes to perform conditional branch relaxation even when
the target cannot be resolved.

Note on llvm/test/MC/RISCV/long-conditional-jump.s: I've removed the
`.p2align` because this causes alignment nops to be inserted for the
`+relax` tests. This in turn causes all the branch targets to change
compared to the non-`+relax` tests. Since `+relax` shouldn't change
these offsets, I found this confusing and hence chose to remove the
alignment.

Reviewed By: asb, MaskRay, reames

Differential Revision: https://reviews.llvm.org/D154958
parent 57ca62d5
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment