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-disable-branch-relaxation,
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.
Drop false.
I think positive option names are more common. Perhaps -riscv-asm-relax-branch=0 since asm and linker relaxation are quite different and the current name can lure users to think the other way.