[all-commits] [llvm/llvm-project] 6c207e: [RISCV] Force relocations if initial MCSubtargetIn...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Jan 9 11:24:32 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6c207ee5d20d2b054509123e6d0507df1332b376
      https://github.com/llvm/llvm-project/commit/6c207ee5d20d2b054509123e6d0507df1332b376
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-01-09 (Tue, 09 Jan 2024)

  Changed paths:
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
    A llvm/test/CodeGen/RISCV/option-relax-relocation.ll

  Log Message:
  -----------
  [RISCV] Force relocations if initial MCSubtargetInfo contains FeatureRelax (#77436)

Regarding
```
.option norelax
j label
.option relax
// relaxable instructions
// For assembly input, RISCVAsmParser::ParseInstruction will set ForceRelocs (https://reviews.llvm.org/D46423).
// For direct object emission, ForceRelocs is not set after https://github.com/llvm/llvm-project/pull/73721
label:
```

The J instruction needs a relocation to ensure the target is correct
after linker relaxation. This is related a limitation in the assembler:
RISCVAsmBackend::shouldForceRelocation decides upfront whether a
relocation is needed, instead of checking more information (whether
there are relaxable fragments in between).

Despite the limitation, `j label` produces a relocation in direct object
emission mode, but was broken by #73721 due to the shouldForceRelocation
limitation.

Add a workaround to RISCVTargetELFStreamer to emulate the previous
behavior.

Link: https://github.com/ClangBuiltLinux/linux/issues/1965




More information about the All-commits mailing list