[PATCH] D46423: [RISCV] Support .option relax and .option norelax

Lewis Revill via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 24 07:38:52 PDT 2018


lewis-revill added a comment.

In https://reviews.llvm.org/D46423#1274042, @jrtc27 wrote:

> In https://reviews.llvm.org/D46423#1268188, @lewis-revill wrote:
>
> > Apologies for the delay, I was away for the week. The solution is to simply not bother updating the backend when the assembler pointer is null, since getAssemblerPtr returning nullptr implies that we are emitting textual assembly, not an object stream, so we don't need to worry about relaxation or relocation anyway.
>
>
> I don't think that's true? The implementation of `getAssemblerPtr` is gated on `getUseAssemblerInfoForParsing`, which is only ever set to true by llvm-mc. Thus, if you have a `-mno-relax` C file that sets `.option relax` in inline assembly, the sticky flag won't be set, so things may break with `-integrated-as`. Now maybe we don't care about that case, but it's not so simple. Perhaps we could avoid this altogether by moving this flag to the RISCV subtarget instance (which will be copied just fine on push/pop as that's done via a clone-and-restore-feature-bits)?


What happens is that when you go directly from C/IR straight to an object file the directives in inline assembly have no effect, since `RISCVTargetELFStreamer::emitDirectiveOptionRelax` is a no-op. All relax logic is done when actually parsing assembly files containing the directive.

This is consistent with the behaviour for `.option rvc`. I will add a test to make this explicit.


Repository:
  rL LLVM

https://reviews.llvm.org/D46423





More information about the llvm-commits mailing list