[all-commits] [llvm/llvm-project] 9d37ea: [lld][RISCV] Handle relaxation reductions of more ...

Roland McGrath via All-commits all-commits at lists.llvm.org
Tue May 16 15:00:02 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9d37ea95df1b84cca9b5e954d8964c976a5e303e
      https://github.com/llvm/llvm-project/commit/9d37ea95df1b84cca9b5e954d8964c976a5e303e
  Author: Roland McGrath <mcgrathr at google.com>
  Date:   2023-05-16 (Tue, 16 May 2023)

  Changed paths:
    M lld/ELF/Arch/RISCV.cpp
    M lld/ELF/InputSection.h

  Log Message:
  -----------
  [lld][RISCV] Handle relaxation reductions of more than 65536 bytes

In a real-world case with functions that have many, many
R_RISCV_CALL_PLT relocations due to asan and ubsan
instrumentation, all these can be relaxed by an instruction and
the net result is more than 65536 bytes of reduction in the
output .text section that totals about 1.2MiB in final size.

This changes InputSection to use a 32-bit field for bytesDropped.
The RISCV relaxation keeps track in a 64-bit field and detects
32-bit overflow as it previously detected 16-bit overflow. It
doesn't seem likely that 32-bit overflow will arise, but it's not
inconceivable and it's cheap enough to detect it.

This unfortunately increases the size of InputSection on 64-bit
hosts by a word, but that seems hard to avoid.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D150722




More information about the All-commits mailing list