[PATCH] D140080: [clang][PPC] Supporting -mcpu=405
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGde8deb5189c9: [clang][PPC] Supporting -mcpu=405 (authored by Qiongsi Wu qiongs...@gmail.com). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140080/new/ https://reviews.llvm.org/D140080 Files: clang/lib/Driver/ToolChains/Arch/PPC.cpp clang/test/Driver/ppc-cpus.c Index: clang/test/Driver/ppc-cpus.c === --- clang/test/Driver/ppc-cpus.c +++ clang/test/Driver/ppc-cpus.c @@ -31,3 +31,9 @@ // RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE // TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9" + +/// Test mcpu options that are equivalent to "generic" +// RUN: %clang -### -c -target powerpc64 %s -mcpu=generic 2>&1 | FileCheck %s --check-prefix=GENERIC +// RUN: %clang -### -c -target powerpc64 %s -mcpu=405 2>&1 | FileCheck %s --check-prefix=GENERIC +// +// GENERIC: "-target-cpu" "ppc64" Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp === --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -39,7 +39,12 @@ if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) { StringRef CPUName = A->getValue(); -if (CPUName == "generic") +// Clang/LLVM does not actually support code generation +// for the 405 CPU. However, there are uses of this CPU ID +// in projects that previously used GCC and rely on Clang +// accepting it. Clang has always ignored it and passed the +// generic CPU ID to the back end. +if (CPUName == "generic" || CPUName == "405") return getPPCGenericTargetCPU(T); if (CPUName == "native") { Index: clang/test/Driver/ppc-cpus.c === --- clang/test/Driver/ppc-cpus.c +++ clang/test/Driver/ppc-cpus.c @@ -31,3 +31,9 @@ // RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE // TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9" + +/// Test mcpu options that are equivalent to "generic" +// RUN: %clang -### -c -target powerpc64 %s -mcpu=generic 2>&1 | FileCheck %s --check-prefix=GENERIC +// RUN: %clang -### -c -target powerpc64 %s -mcpu=405 2>&1 | FileCheck %s --check-prefix=GENERIC +// +// GENERIC: "-target-cpu" "ppc64" Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp === --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -39,7 +39,12 @@ if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) { StringRef CPUName = A->getValue(); -if (CPUName == "generic") +// Clang/LLVM does not actually support code generation +// for the 405 CPU. However, there are uses of this CPU ID +// in projects that previously used GCC and rely on Clang +// accepting it. Clang has always ignored it and passed the +// generic CPU ID to the back end. +if (CPUName == "generic" || CPUName == "405") return getPPCGenericTargetCPU(T); if (CPUName == "native") { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D140080: [clang][PPC] Supporting -mcpu=405
qiongsiwu1 added a comment. The pre-commit CI crashes do not seem to relate to this patch. I will land it soon. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140080/new/ https://reviews.llvm.org/D140080 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D140080: [clang][PPC] Supporting -mcpu=405
qiongsiwu1 updated this revision to Diff 483146. qiongsiwu1 added a comment. Addressing review comments. Thanks for the review @nemanjai !! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140080/new/ https://reviews.llvm.org/D140080 Files: clang/lib/Driver/ToolChains/Arch/PPC.cpp clang/test/Driver/ppc-cpus.c Index: clang/test/Driver/ppc-cpus.c === --- clang/test/Driver/ppc-cpus.c +++ clang/test/Driver/ppc-cpus.c @@ -31,3 +31,9 @@ // RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE // TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9" + +/// Test mcpu options that are equivalent to "generic" +// RUN: %clang -### -c -target powerpc64 %s -mcpu=generic 2>&1 | FileCheck %s --check-prefix=GENERIC +// RUN: %clang -### -c -target powerpc64 %s -mcpu=405 2>&1 | FileCheck %s --check-prefix=GENERIC +// +// GENERIC: "-target-cpu" "ppc64" Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp === --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -39,7 +39,12 @@ if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) { StringRef CPUName = A->getValue(); -if (CPUName == "generic") +// Clang/LLVM does not actually support code generation +// for the 405 CPU. However, there are uses of this CPU ID +// in projects that previously used GCC and rely on Clang +// accepting it. Clang has always ignored it and passed the +// generic CPU ID to the back end. +if (CPUName == "generic" || CPUName == "405") return getPPCGenericTargetCPU(T); if (CPUName == "native") { Index: clang/test/Driver/ppc-cpus.c === --- clang/test/Driver/ppc-cpus.c +++ clang/test/Driver/ppc-cpus.c @@ -31,3 +31,9 @@ // RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE // TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9" + +/// Test mcpu options that are equivalent to "generic" +// RUN: %clang -### -c -target powerpc64 %s -mcpu=generic 2>&1 | FileCheck %s --check-prefix=GENERIC +// RUN: %clang -### -c -target powerpc64 %s -mcpu=405 2>&1 | FileCheck %s --check-prefix=GENERIC +// +// GENERIC: "-target-cpu" "ppc64" Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp === --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -39,7 +39,12 @@ if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) { StringRef CPUName = A->getValue(); -if (CPUName == "generic") +// Clang/LLVM does not actually support code generation +// for the 405 CPU. However, there are uses of this CPU ID +// in projects that previously used GCC and rely on Clang +// accepting it. Clang has always ignored it and passed the +// generic CPU ID to the back end. +if (CPUName == "generic" || CPUName == "405") return getPPCGenericTargetCPU(T); if (CPUName == "native") { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D140080: [clang][PPC] Supporting -mcpu=405
nemanjai accepted this revision. nemanjai added a comment. This revision is now accepted and ready to land. I don't think the comments require another round of review. Thanks for fixing this. Comment at: clang/lib/Driver/ToolChains/Arch/PPC.cpp:23-29 +static constexpr llvm::StringLiteral GenericCPUNames[] = {{"generic"}, {"405"}}; + +/// Check if Name is known to be equivalent to "generic". +static bool isGenericCPUName(const StringRef ) { + return llvm::is_contained(GenericCPUNames, Name); +} + While I understand the motivation here, I think that this is overkill. We in fact hope not to have to grow the set of CPU ID's that we treat as generic. Comment at: clang/lib/Driver/ToolChains/Arch/PPC.cpp:42 -if (CPUName == "generic") return getPPCGenericTargetCPU(T); I think we should change this to check for `generic` or `405` and add a comment similar to the following: ``` // Clang/LLVM does not actually support code generation // for the 405 CPU. However, there are uses of this CPU ID // in projects that previously used GCC and rely on Clang // accepting it. Clang has always ignored it and passed the // generic CPU ID to the back end. ``` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140080/new/ https://reviews.llvm.org/D140080 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D140080: [clang][PPC] Supporting -mcpu=405
qiongsiwu1 updated this revision to Diff 483060. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140080/new/ https://reviews.llvm.org/D140080 Files: clang/lib/Driver/ToolChains/Arch/PPC.cpp clang/test/Driver/ppc-cpus.c Index: clang/test/Driver/ppc-cpus.c === --- clang/test/Driver/ppc-cpus.c +++ clang/test/Driver/ppc-cpus.c @@ -31,3 +31,9 @@ // RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE // TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9" + +/// Test mcpu options that are equivalent to "generic" +// RUN: %clang -### -c -target powerpc64 %s -mcpu=generic 2>&1 | FileCheck %s --check-prefix=GENERIC +// RUN: %clang -### -c -target powerpc64 %s -mcpu=405 2>&1 | FileCheck %s --check-prefix=GENERIC +// +// GENERIC: "-target-cpu" "ppc64" Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp === --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -20,6 +20,13 @@ using namespace clang; using namespace llvm::opt; +static constexpr llvm::StringLiteral GenericCPUNames[] = {{"generic"}, {"405"}}; + +/// Check if Name is known to be equivalent to "generic". +static bool isGenericCPUName(const StringRef ) { + return llvm::is_contained(GenericCPUNames, Name); +} + static std::string getPPCGenericTargetCPU(const llvm::Triple ) { // LLVM may default to generating code for the native CPU, // but, like gcc, we default to a more generic option for @@ -39,7 +46,7 @@ if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) { StringRef CPUName = A->getValue(); -if (CPUName == "generic") +if (isGenericCPUName(CPUName)) return getPPCGenericTargetCPU(T); if (CPUName == "native") { Index: clang/test/Driver/ppc-cpus.c === --- clang/test/Driver/ppc-cpus.c +++ clang/test/Driver/ppc-cpus.c @@ -31,3 +31,9 @@ // RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE // TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9" + +/// Test mcpu options that are equivalent to "generic" +// RUN: %clang -### -c -target powerpc64 %s -mcpu=generic 2>&1 | FileCheck %s --check-prefix=GENERIC +// RUN: %clang -### -c -target powerpc64 %s -mcpu=405 2>&1 | FileCheck %s --check-prefix=GENERIC +// +// GENERIC: "-target-cpu" "ppc64" Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp === --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -20,6 +20,13 @@ using namespace clang; using namespace llvm::opt; +static constexpr llvm::StringLiteral GenericCPUNames[] = {{"generic"}, {"405"}}; + +/// Check if Name is known to be equivalent to "generic". +static bool isGenericCPUName(const StringRef ) { + return llvm::is_contained(GenericCPUNames, Name); +} + static std::string getPPCGenericTargetCPU(const llvm::Triple ) { // LLVM may default to generating code for the native CPU, // but, like gcc, we default to a more generic option for @@ -39,7 +46,7 @@ if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) { StringRef CPUName = A->getValue(); -if (CPUName == "generic") +if (isGenericCPUName(CPUName)) return getPPCGenericTargetCPU(T); if (CPUName == "native") { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D140080: [clang][PPC] Supporting -mcpu=405
qiongsiwu1 created this revision. qiongsiwu1 added a reviewer: nemanjai. qiongsiwu1 added projects: PowerPC, clang. Herald added subscribers: shchenz, kbarton. Herald added a project: All. qiongsiwu1 requested review of this revision. Herald added subscribers: cfe-commits, MaskRay. The ClangBuiltLinux project relies on `-mcpu=405`. Before https://reviews.llvm.org/D139720, `clang` treated `-mcpu=405` implicitly in the same way as `-mcpu=generic`, because `405` was an unknown value and `clang` did not check unknown input values. https://reviews.llvm.org/D139720 added the check of `-mcpu` input value, and `clang` generates an error with `-mcpu=405`. For further details of the problem, see https://github.com/ClangBuiltLinux/linux/issues/1771. This patch adds support of `-mcpu=405` explicitly, and treats it as an equivalent of `-mcpu=generic`. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D140080 Files: clang/lib/Driver/ToolChains/Arch/PPC.cpp clang/test/Driver/ppc-cpus.c Index: clang/test/Driver/ppc-cpus.c === --- clang/test/Driver/ppc-cpus.c +++ clang/test/Driver/ppc-cpus.c @@ -31,3 +31,9 @@ // RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE // TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9" + +/// Test mcpu options that are equivalent to "generic" +// RUN: %clang -### -c -target powerpc64 %s -mcpu=generic 2>&1 | FileCheck %s --check-prefix=GENERIC +// RUN: %clang -### -c -target powerpc64 %s -mcpu=405 2>&1 | FileCheck %s --check-prefix=GENERIC +// +// GENERIC: "-target-cpu" "ppc64" Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp === --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -20,6 +20,14 @@ using namespace clang; using namespace llvm::opt; +static constexpr llvm::StringLiteral GenericPPCTargetNames[] = {{"generic"}, +{"405"}}; + +/// Check if Name is known to be equivalent to "generic". +static bool isGenericPPCTargetName(const StringRef ) { + return llvm::is_contained(GenericPPCTargetNames, Name); +} + static std::string getPPCGenericTargetCPU(const llvm::Triple ) { // LLVM may default to generating code for the native CPU, // but, like gcc, we default to a more generic option for @@ -39,7 +47,7 @@ if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) { StringRef CPUName = A->getValue(); -if (CPUName == "generic") +if (isGenericPPCTargetName(CPUName)) return getPPCGenericTargetCPU(T); if (CPUName == "native") { Index: clang/test/Driver/ppc-cpus.c === --- clang/test/Driver/ppc-cpus.c +++ clang/test/Driver/ppc-cpus.c @@ -31,3 +31,9 @@ // RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE // TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9" + +/// Test mcpu options that are equivalent to "generic" +// RUN: %clang -### -c -target powerpc64 %s -mcpu=generic 2>&1 | FileCheck %s --check-prefix=GENERIC +// RUN: %clang -### -c -target powerpc64 %s -mcpu=405 2>&1 | FileCheck %s --check-prefix=GENERIC +// +// GENERIC: "-target-cpu" "ppc64" Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp === --- clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -20,6 +20,14 @@ using namespace clang; using namespace llvm::opt; +static constexpr llvm::StringLiteral GenericPPCTargetNames[] = {{"generic"}, +{"405"}}; + +/// Check if Name is known to be equivalent to "generic". +static bool isGenericPPCTargetName(const StringRef ) { + return llvm::is_contained(GenericPPCTargetNames, Name); +} + static std::string getPPCGenericTargetCPU(const llvm::Triple ) { // LLVM may default to generating code for the native CPU, // but, like gcc, we default to a more generic option for @@ -39,7 +47,7 @@ if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) { StringRef CPUName = A->getValue(); -if (CPUName == "generic") +if (isGenericPPCTargetName(CPUName)) return getPPCGenericTargetCPU(T); if (CPUName == "native") { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits