diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3986,7 +3986,7 @@ HelpText<"Provide information about a particular module file">; def mthumb : Flag<["-"], "mthumb">, Group; def mtune_EQ : Joined<["-"], "mtune=">, Group, - HelpText<"Only supported on X86, RISC-V and SystemZ. Otherwise accepted for compatibility with GCC.">; + HelpText<"Only supported on AArch64, PowerPC, RISC-V, SystemZ, and X86">; def multi__module : Flag<["-"], "multi_module">; def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">; def multiply__defined : Separate<["-"], "multiply_defined">; diff --git a/clang/lib/Driver/ToolChains/Arch/PPC.cpp b/clang/lib/Driver/ToolChains/Arch/PPC.cpp --- a/clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ b/clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -107,10 +107,6 @@ void ppc::getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple, const ArgList &Args, std::vector &Features) { - // TODO Handle -mtune=. Suppress -Wunused-command-line-argument as a - // longstanding behavior. - (void)Args.getLastArg(options::OPT_mtune_EQ); - if (Triple.getSubArch() == llvm::Triple::PPCSubArch_spe) Features.push_back("+spe"); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2083,6 +2083,14 @@ void Clang::AddPPCTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const { + if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) { + CmdArgs.push_back("-tune-cpu"); + if (strcmp(A->getValue(), "native") == 0) + CmdArgs.push_back(Args.MakeArgString(llvm::sys::getHostCPUName())); + else + CmdArgs.push_back(A->getValue()); + } + // Select the ABI to use. const char *ABIName = nullptr; const llvm::Triple &T = getToolChain().getTriple(); diff --git a/clang/test/Driver/ppc-cpus.c b/clang/test/Driver/ppc-cpus.c --- a/clang/test/Driver/ppc-cpus.c +++ b/clang/test/Driver/ppc-cpus.c @@ -19,3 +19,6 @@ // RUN: %clang -### -c -target powerpc64 %s -mcpu=pwr8 2>&1 | FileCheck %s --check-prefix=NO_PPC64 // NO_PPC64-NOT: "-target-cpu" "ppc64" + +// RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE +// TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9"