This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Recognize long CPU name for -mtune in Clang
ClosedPublic

Authored by nemanjai on Feb 28 2023, 7:34 AM.

Details

Summary

There are two ways of specifying a CPU on PowerPC: power<N> and pwr<N>. Clang/LLVM traditionally supports the latter and Clang replaces the former with the latter when passing it to the back end for the -mcpu= option. However, when the -mtune= option was introduced, this replacement was not implemented for it.

This leaves us in an inconsistent state of accepting both forms for -mcpu= and and only the latter for -mtune=. Furthermore, it leaves us incompatible with GCC which only understands the power<N> version for both options.

This patch just adds the same handling for the long names for -mtune= as already exists for -mcpu=.

Diff Detail

Event Timeline

nemanjai created this revision.Feb 28 2023, 7:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2023, 7:34 AM
nemanjai requested review of this revision.Feb 28 2023, 7:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2023, 7:34 AM

Thanks for the fix, it appears to work fine for me against the kernel's powernv_defconfig target.

nickdesaulniers accepted this revision.Feb 28 2023, 10:02 AM

Thanks for the patch!

clang/lib/Driver/ToolChains/Arch/PPC.cpp
37–50

The casing of the function name is a bit awkward, consider something perhaps more concise like normalizeCPUName and retaining the comment.

This revision is now accepted and ready to land.Feb 28 2023, 10:02 AM
MaskRay accepted this revision.Feb 28 2023, 12:31 PM
MaskRay added inline comments.
clang/lib/Driver/ToolChains/Arch/PPC.cpp
80–85
87

Could this be merged into main and backported to release/16.x? If this makes 16.0.0 final, I think the kernel can avoid working around this issue altogether, as -mtune was only wired up to do something on PowerPC in during the 16 development cycle; in prior versions, it was ignored so any value was accepted.

Could this be merged into main and backported to release/16.x? If this makes 16.0.0 final, I think the kernel can avoid working around this issue altogether, as -mtune was only wired up to do something on PowerPC in during the 16 development cycle; in prior versions, it was ignored so any value was accepted.

I support the backport into 16.0.0 but we need to be quick :)

I'll provide an updated patch in a few min...

I'll provide an updated patch in a few min...

Ah, what I mean is I will update the patch and push in a few min.

This revision was landed with ongoing or failed builds.Mar 2 2023, 11:30 AM
This revision was automatically updated to reflect the committed changes.
amyk added a subscriber: amyk.Mar 3 2023, 4:26 AM

Could this be merged into main and backported to release/16.x? If this makes 16.0.0 final, I think the kernel can avoid working around this issue altogether, as -mtune was only wired up to do something on PowerPC in during the 16 development cycle; in prior versions, it was ignored so any value was accepted.

@nathanchance Just wanted to let you know that this patch is now backported into release/16.x.

@amyk thank you so much!