[RISCV][clang] Don't enable -mrelax-all for -O0 on RISC-V (#88538)

-O0 implies -mrelax-all as an assembler compile time optimization.
-mrelax-all allows the assembler to complete layout in 2 passes instead
of doing iterative branch relaxation.

Jump offsets larger than +/-1MiB require an indirect jump on RISC-V.
This can't be done by the assembler, so we use a branch relaxation MIR
pass and use register scavenging to find a free register.

The conditional branch offsets for RISC-V are also somewhat small so we
support MC layer branch relaxation to make life easier for assembly
programmers. This may also cover up bugs in our function size estimation
in MachineIR.

Enabling -mrelax-all causes the MC layer relaxation to agressively relax
branches. This increases code size and can create cases where we need an
indirect jump, but we can't create one. This leads to linker failures.

The easiest way to avoid this is to not default to -mrelax-all for -O0
and sacrifice the compile time optimization. That's what this patch
does.

Fixes #87127

GitOrigin-RevId: 6b1b4c1c54d4276409c336eaf6d47b3bc04035c3
2 files changed