This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified
ClosedPublic

Authored by StephenFan on Feb 27 2022, 7:02 PM.

Details

Summary

In the past, clang --target=riscv64-unknown-linux-gnu -mno-relax -c hello.s will assemble hello.s without relaxation, but clang --target=riscv64-unknown-linux-gnu -mno-relax -fno-integrated-as -c hello.s doesn't pass the -mno-relax option to assembler, and assemble with relaxation
This patch pass the -mno-relax option to assembler when -fno-integrated-as is specified.

Diff Detail

Event Timeline

StephenFan created this revision.Feb 27 2022, 7:02 PM
StephenFan requested review of this revision.Feb 27 2022, 7:02 PM
jrtc27 added inline comments.Feb 27 2022, 7:49 PM
clang/lib/Driver/ToolChains/Gnu.cpp
767

I doubt this does the right thing for -mrelax -mno-relax? I imagine you want Args.hasFlag.

clang/test/Driver/riscv-gnutools.c
19

All of these tests are using -fno-integrated-as, calling it out specifically for this one is misleading

Address @jrtc27 's comments

Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2022, 2:19 PM
kito-cheng added inline comments.Mar 2 2022, 7:03 PM
clang/test/Driver/riscv-gnutools.c
19

Yeah, the comment is kind of misleading, actually we didn't check *default* value for -march or -mabi like other two checks(CHECK-RV32IMAC-ILP32/CHECK-RV32IMAFDC-ILP32D).

Maybe like this?

// Check -mno-relax has passed when `-fno-integrated-as` specified
StephenFan updated this revision to Diff 413774.Mar 8 2022, 5:22 AM

Address @kito-cheng 's comments

asb accepted this revision.Mar 17 2022, 6:37 AM

It would be good to have someone else who's reviewed earlier versions of this patch to confirm, but this LGTM. Thanks.

If you were editing it anyway, you could change "has passed" to "is passed" (though it's not a particularly important grammatical fix).

This revision is now accepted and ready to land.Mar 17 2022, 6:37 AM

Grammatical fix

@jrtc27, @kito-cheng Do you have any other comments ? :)

MaskRay added inline comments.Mar 25 2022, 11:47 PM
clang/lib/Driver/ToolChains/Gnu.cpp
767

Avoid using the error-prone default argument true.

clang/test/Driver/riscv-gnutools.c
44

I don't think repeating this for 64-bit adds value.

It may be more useful to change this to test -mno-relax -mrelax instead.

-target riscv64 should be --target=riscv64-unknown-elf, matching the triple name in %S/Inputs/basic_riscv64_tree .

StephenFan updated this revision to Diff 418774.EditedMar 28 2022, 8:45 PM

Address @MaskRay 's comments.

  1. explicit default-argument to avoid error-prone
  2. change riscv64 test to test the case when -mno-relax -mrelax specified.

Is the change of riscv64 test match your @MaskRay requirements?

asb added a comment.Apr 14 2022, 1:37 AM

@MaskRay: Are you happy all your comments are addressed?

MaskRay accepted this revision.Apr 14 2022, 5:38 PM

LGTM if you use addOptOutFlag

clang/lib/Driver/ToolChains/Gnu.cpp
767

Args.addOptOutFlag(CmdArgs, options::OPT_mrelax, options::OPT_mno_relax)

This revision was landed with ongoing or failed builds.Apr 17 2022, 8:17 PM
This revision was automatically updated to reflect the committed changes.