[all-commits] [llvm/llvm-project] 856745: [RISCV][MC] Relax conditional branches to unresolv...
Job Noorman via All-commits
all-commits at lists.llvm.org
Fri Jul 28 01:56:15 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 856745c5ebe5e3da35c4f08bc6090e2d348ea048
https://github.com/llvm/llvm-project/commit/856745c5ebe5e3da35c4f08bc6090e2d348ea048
Author: Job Noorman <jnoorman at igalia.com>
Date: 2023-07-28 (Fri, 28 Jul 2023)
Changed paths:
M lld/test/ELF/riscv-branch.s
M lld/test/ELF/riscv-undefined-weak.s
M llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
M llvm/test/MC/RISCV/compressed-relocations.s
M llvm/test/MC/RISCV/long-conditional-jump.s
M llvm/test/MC/RISCV/relocations.s
Log Message:
-----------
[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
More information about the All-commits
mailing list