This is an archive of the discontinued LLVM Phabricator instance.

[clang][Arm] Fix handling of -Wa,-implicit-it=
ClosedPublic

Authored by nickdesaulniers on Feb 8 2021, 12:27 PM.

Details

Summary

Similiar to D95872, this flag can be set for the assembler directly.
Move validation code into a reusable helper function.

Link: https://bugs.llvm.org/show_bug.cgi?id=49023
Link: https://github.com/ClangBuiltLinux/linux/issues/1270
Reported-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Diff Detail

Event Timeline

nickdesaulniers requested review of this revision.Feb 8 2021, 12:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2021, 12:27 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
DavidSpickett added inline comments.Feb 9 2021, 1:59 AM
clang/lib/Driver/ToolChains/Clang.cpp
2307

I would rename this AddARMImplicitITArgs to match AddARMTargetArgs.

2386

You could merge the two ifs with &&

clang/test/Driver/arm-target-as-mimplicit-it.s
14

For these multiple option tests, we're checking that the last -mimplicit-it wins, so I think the first argument should be another different value. E.g.
-Wa,-mimplicit-it=thumb -Wa,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS

Then if we got our logic wrong, we'll see "=thumb" in the result and fail.
(afaik -mthumb doesn't set implicit-it to anything)

27

Does it make sense to check which wins of -mimplicit-it and -Wa,-mimplicit-it for assembler and c inputs?

I guess right now we would have the first for C files, and both for assembler files but the last -mllvm implicit-it wins, and it'd be the assembler's option. Either way some tests to confirm that would be good.

You can use any old C file, my change that you reviewed does the same thing to check this. (but in that case, since it was earlier it could tell whether we had both kinds of option which I don't think can be done here)

nickdesaulniers marked 2 inline comments as done.
  • address code review comments, add moar tests
nickdesaulniers marked an inline comment as done.Feb 9 2021, 10:35 AM
nickdesaulniers marked an inline comment as done.
DavidSpickett added inline comments.Feb 10 2021, 2:58 AM
clang/test/Driver/arm-target-as-mimplicit-it.s
27

I'm confused why this generates two -arm-implicit-it.

I'd expect that:
A c file only uses the compiler's argument
An assembler file uses the compiler and assembler argument, with the assembler argument last

Are we calling CollectArgsForIntegratedAssembler even for a C file?

44

I'd put these last two before the unsupported argument lines, to match the test order.

nickdesaulniers marked an inline comment as done.
  • reorder test checks
clang/test/Driver/arm-target-as-mimplicit-it.s
27

I don't think this is an issue.

I'm confused why this generates two -arm-implicit-it.

If you check the implementation of CollectArgsForIntegratedAssembler, it will call my added helper (AddARMImplicitITArgs) for -mimplicit-it=, then check for -Wa,-implicit-it=. If both are present, then both will be generated for the assembler, with the latter taking preference.

Are we calling CollectArgsForIntegratedAssembler even for a C file?

Yes. Unless -no-integrated-as or -S was used, we need to be able to modify how assembler is handled both in generating it from C code, but also for inline assembly that may be in a C source.

DavidSpickett accepted this revision.Feb 11 2021, 1:23 AM

LGTM

clang/test/Driver/arm-target-as-mimplicit-it.s
27

Right, I forgot about the inline assembly scenario.

This revision is now accepted and ready to land.Feb 11 2021, 1:23 AM
nickdesaulniers marked 2 inline comments as done.Feb 11 2021, 8:58 AM

Thanks for the review (here and D96304)!

This revision was landed with ongoing or failed builds.Feb 11 2021, 10:51 AM
This revision was automatically updated to reflect the committed changes.