[clang] 9fcf4f3 - [Hexagon] Fix clang driver to parse -mcpu/-mvXX and -march properly.
Sumanth Gundapaneni via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 14 11:00:15 PST 2019
Author: Sumanth Gundapaneni
Date: 2019-11-14T12:59:15-06:00
New Revision: 9fcf4f372c7e08b7ee64a202cc09860a17da8152
URL: https://github.com/llvm/llvm-project/commit/9fcf4f372c7e08b7ee64a202cc09860a17da8152
DIFF: https://github.com/llvm/llvm-project/commit/9fcf4f372c7e08b7ee64a202cc09860a17da8152.diff
LOG: [Hexagon] Fix clang driver to parse -mcpu/-mvXX and -march properly.
Before this patch if we pass "-mcpu=hexagonv65 -march=hexagon" in this order,
the driver fails to figure out the correct cpu version. This patch fixed this
issue.
Added:
Modified:
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/test/Driver/hexagon-toolchain-elf.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 96cc084e2821..4a735a2a1d59 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -574,7 +574,7 @@ const StringRef HexagonToolChain::GetDefaultCPU() {
const StringRef HexagonToolChain::GetTargetCPUVersion(const ArgList &Args) {
Arg *CpuArg = nullptr;
- if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ, options::OPT_march_EQ))
+ if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
CpuArg = A;
StringRef CPU = CpuArg ? CpuArg->getValue() : GetDefaultCPU();
diff --git a/clang/test/Driver/hexagon-toolchain-elf.c b/clang/test/Driver/hexagon-toolchain-elf.c
index a7eeca0fdb12..237242e7cbf1 100644
--- a/clang/test/Driver/hexagon-toolchain-elf.c
+++ b/clang/test/Driver/hexagon-toolchain-elf.c
@@ -121,6 +121,19 @@
// CHECK028-NOT: "-ffp-contract=fast"
// CHECK028: {{hexagon-link|ld}}
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN: -mcpu=hexagonv65 -march=hexagon\
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK029 %s
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN: -mv65 -march=hexagon\
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK029 %s
+// CHECK029: "-cc1" {{.*}} "-target-cpu" "hexagonv65"
+// CHECK029: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v65/crt0
+
// -----------------------------------------------------------------------------
// Test Linker related args
// -----------------------------------------------------------------------------
More information about the cfe-commits
mailing list