[all-commits] [llvm/llvm-project] afb2e9: [RISCV][MC] Add CLI option to disable branch relax...

Job Noorman via All-commits all-commits at lists.llvm.org
Fri Jul 28 01:42:28 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: afb2e9f44c13101c7b22c99e080b0beb0cd5b01e
      https://github.com/llvm/llvm-project/commit/afb2e9f44c13101c7b22c99e080b0beb0cd5b01e
  Author: Job Noorman <jnoorman at igalia.com>
  Date:   2023-07-28 (Fri, 28 Jul 2023)

  Changed paths:
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
    A llvm/test/MC/RISCV/long-jump-disable-relax.s

  Log Message:
  -----------
  [RISCV][MC] Add CLI option to disable branch relaxation

D154958 enables branch relaxation for unresolved symbols. This has an
interesting consequence for some LLD tests: branch relocations are
tested by using branches to undefined symbols and defining them, with
different values, on the LLD command line. These tests broke and there
doesn't seem to be an easy workaround: as far as I can tell, there is no
way to convince llvm-mc to emit a branch relocation to an undefined
symbol without branch relaxation kicking in.

This patch proposes to add a flag, `-riscv-asm-relax-branches=0`, to do
just that. The main purpose for this flag is for testing but it might be
seen as a first step to some kind of "strict" or WYSIWYG mode (i.e.,
what you give to the assembler is exactly what comes out). The need for
this has been mentioned in, for example, D108961. However, I suspect
there will be a lot of discussion around what exactly such a strict mode
would look like. Therefore, I gated this feature behind a CLI flag
instead of adding a new target feature.

Reviewed By: asb, MaskRay

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




More information about the All-commits mailing list