[all-commits] [llvm/llvm-project] 8957e6: [ELF, RISCV] Fix oscillation due to call relaxation

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Jun 10 09:29:09 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8957e64a20fc7f4277565c6cfe3e555c119783ce
      https://github.com/llvm/llvm-project/commit/8957e64a20fc7f4277565c6cfe3e555c119783ce
  Author: Fangrui Song <i at maskray.me>
  Date:   2025-06-10 (Tue, 10 Jun 2025)

  Changed paths:
    M lld/ELF/Arch/RISCV.cpp
    A lld/test/ELF/riscv-relax-call-stress.s

  Log Message:
  -----------
  [ELF,RISCV] Fix oscillation due to call relaxation

The new test (derived from riscv32 openssl/test/cmp_msg_test.c) revealed
oscillation in two R_RISCV_CALL_PLT jumps:

- First jump (~2^11 bytes away): alternated between 4 and 8 bytes.
- Second jump (~2^20 bytes away): alternated between 2 and 8 bytes.

The issue is not related to alignment. In 2019, GNU ld addressed a
similar problem by reducing the relaxation allowance for cross-section
relaxation (https://sourceware.org/bugzilla/show_bug.cgi?id=25181).
This approach would result in a suboptimal layout for the tight range
tested by riscv-relax-call.s.

This patch stabilizes the process by preventing `remove` increment after
a few passes, similar to integrated assembler's fragment relaxation.
(For the Android bit reproduce, `pass < 2` leads to non-optimal layout
while `pass < 3` and `pass < 4` output is identical.)

Fix https://github.com/llvm/llvm-project/issues/113838
Possibly fix https://github.com/llvm/llvm-project/issues/123248 (inputs
are bitcode, subject to ever-changing code generation, not reproducible)

Pull Request: https://github.com/llvm/llvm-project/pull/142899



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list