Skip to content

Commit 65077c7

Browse files
authored
[RISCV] Remove -riscv-asm-relax-branches flag (#142855)
This flag has been superseded by `.option exact`, as the test updates show. Given the flag was always hidden, it makes sense to me to remove it, and move tests that required it to use `.option exact`.
1 parent 70e78be commit 65077c7

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

lld/test/ELF/riscv-branch.s

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# REQUIRES: riscv
22

3-
# RUN: llvm-mc -filetype=obj -triple=riscv32-unknown-elf -mattr=-relax -riscv-asm-relax-branches=0 %s -o %t.rv32.o
4-
# RUN: llvm-mc -filetype=obj -triple=riscv64-unknown-elf -mattr=-relax -riscv-asm-relax-branches=0 %s -o %t.rv64.o
3+
# RUN: llvm-mc -filetype=obj -triple=riscv32-unknown-elf %s -o %t.rv32.o
4+
# RUN: llvm-mc -filetype=obj -triple=riscv64-unknown-elf %s -o %t.rv64.o
55

66
# RUN: ld.lld %t.rv32.o --defsym foo=_start+4 --defsym bar=_start -o %t.rv32
77
# RUN: ld.lld %t.rv64.o --defsym foo=_start+4 --defsym bar=_start -o %t.rv64
@@ -30,6 +30,8 @@
3030
# RUN: not ld.lld %t.rv64.o --defsym foo=_start+1 --defsym bar=_start-1 -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR-ALIGN %s
3131
# ERROR-ALIGN: improper alignment for relocation R_RISCV_BRANCH: 0x1 is not aligned to 2 bytes
3232

33+
.option exact
34+
3335
.global _start
3436
_start:
3537
beq x0, x0, foo

lld/test/ELF/riscv-undefined-weak.s

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# REQUIRES: riscv
22
# RUN: llvm-mc -filetype=obj -triple=riscv64 /dev/null -o %t2.o
33
# RUN: ld.lld -shared -soname=t2 %t2.o -o %t2.so
4-
# RUN: llvm-mc -filetype=obj -triple=riscv64 -riscv-asm-relax-branches=0 %s -o %t.o
4+
# RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t.o
55
# RUN: llvm-readobj -r %t.o | FileCheck --check-prefix=RELOC %s
66

77
# RUN: ld.lld -e absolute %t.o -o %t
@@ -12,6 +12,8 @@
1212
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefixes=CHECK,PLT %s
1313
# RUN: llvm-readelf -x .data %t | FileCheck --check-prefixes=HEX,HEX-WITH-PLT %s
1414

15+
.option exact
16+
1517
.weak target
1618
.global absolute, relative, branch
1719

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
using namespace llvm;
2929

30-
static cl::opt<bool> RelaxBranches("riscv-asm-relax-branches", cl::init(true),
31-
cl::Hidden);
3230
// Temporary workaround for old linkers that do not support ULEB128 relocations,
3331
// which are abused by DWARF v5 DW_LLE_offset_pair/DW_RLE_offset_pair
3432
// implemented in Clang/LLVM.
@@ -110,9 +108,6 @@ bool RISCVAsmBackend::fixupNeedsRelaxationAdvanced(const MCFixup &Fixup,
110108
const MCValue &,
111109
uint64_t Value,
112110
bool Resolved) const {
113-
if (!RelaxBranches)
114-
return false;
115-
116111
int64_t Offset = int64_t(Value);
117112
unsigned Kind = Fixup.getTargetKind();
118113

llvm/test/ExecutionEngine/JITLink/RISCV/ELF_branch.s

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RUN: rm -rf %t && mkdir -p %t
2-
# RUN: llvm-mc -triple=riscv64 -filetype=obj -riscv-asm-relax-branches=0 \
2+
# RUN: llvm-mc -triple=riscv64 -filetype=obj \
33
# RUN: -o %t/elf_riscv64_branch.o %s
4-
# RUN: llvm-mc -triple=riscv32 -filetype=obj -riscv-asm-relax-branches=0 \
4+
# RUN: llvm-mc -triple=riscv32 -filetype=obj \
55
# RUN: -o %t/elf_riscv32_branch.o %s
66
# RUN: llvm-jitlink -noexec \
77
# RUN: -slab-allocate 100Kb -slab-address 0xfff00ff4 -slab-page-size 4096 \
@@ -13,6 +13,8 @@
1313
# RUN: -check %s %t/elf_riscv32_branch.o
1414
#
1515

16+
.option exact
17+
1618
.text
1719
# Empty main entry point.
1820
.globl main

llvm/test/MC/RISCV/long-jump-disable-relax.s renamed to llvm/test/MC/RISCV/option-exact-long-jump-disable.s

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
## Test that long branches are not relaxed with -riscv-asm-relax-branches=0
1+
## Test that long branches are not relaxed with .option exact
22
# RUN: split-file %s %t
33
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+c \
4-
# RUN: -riscv-asm-relax-branches=0 %t/pass.s \
4+
# RUN: %t/pass.s \
55
# RUN: | llvm-objdump -dr -M no-aliases - \
66
# RUN: | FileCheck %t/pass.s
77
# RUN: not llvm-mc -filetype=obj -triple=riscv64 -mattr=+c -o /dev/null \
8-
# RUN: -riscv-asm-relax-branches=0 %t/fail.s 2>&1 \
8+
# RUN: %t/fail.s 2>&1 \
99
# RUN: | FileCheck %t/fail.s
1010

1111
#--- pass.s
12+
.option exact
13+
1214
.text
1315
test_undefined:
1416
## Branches to undefined symbols should not be relaxed
@@ -33,6 +35,8 @@ test_defined_in_range:
3335
bar:
3436

3537
#--- fail.s
38+
.option exact
39+
3640
.text
3741
## Branches to defined out-of-range symbols should report an error
3842
test_defined_out_of_range:

0 commit comments

Comments
 (0)