r330150 - [Hexagon] Emit a warning when -fvectorize is given without -mhvx
Krzysztof Parzyszek via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 16 12:11:17 PDT 2018
Author: kparzysz
Date: Mon Apr 16 12:11:17 2018
New Revision: 330150
URL: http://llvm.org/viewvc/llvm-project?rev=330150&view=rev
Log:
[Hexagon] Emit a warning when -fvectorize is given without -mhvx
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/lib/Driver/ToolChains/Hexagon.h
cfe/trunk/test/Driver/hexagon-vectorize.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=330150&r1=330149&r2=330150&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Apr 16 12:11:17 2018
@@ -288,6 +288,9 @@ def err_analyzer_config_multiple_values
def err_drv_invalid_hvx_length : Error<
"-mhvx-length is not supported without a -mhvx/-mhvx= flag">;
+def warn_drv_vectorize_needs_hvx : Warning<
+ "auto-vectorization requires HVX, use -mhvx to enable it">,
+ InGroup<OptionIgnored>;
def err_drv_modules_validate_once_requires_timestamp : Error<
"option '-fmodules-validate-once-per-build-session' requires "
Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=330150&r1=330149&r2=330150&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Mon Apr 16 12:11:17 2018
@@ -108,8 +108,11 @@ void hexagon::getHexagonTargetFeatures(c
Features.push_back(UseLongCalls ? "+long-calls" : "-long-calls");
- bool HasHVX(false);
+ bool HasHVX = false;
handleHVXTargetFeatures(D, Args, Features, HasHVX);
+
+ if (HexagonToolChain::isAutoHVXEnabled(Args) && !HasHVX)
+ D.Diag(diag::warn_drv_vectorize_needs_hvx);
}
// Hexagon tools start.
@@ -520,12 +523,9 @@ void HexagonToolChain::addClangTargetOpt
CC1Args.push_back("-target-feature");
CC1Args.push_back("+reserved-r19");
}
- if (Arg *A = DriverArgs.getLastArg(options::OPT_fvectorize,
- options::OPT_fno_vectorize)) {
- if (A->getOption().matches(options::OPT_fvectorize)) {
- CC1Args.push_back("-mllvm");
- CC1Args.push_back("-hexagon-autohvx");
- }
+ if (isAutoHVXEnabled(DriverArgs)) {
+ CC1Args.push_back("-mllvm");
+ CC1Args.push_back("-hexagon-autohvx");
}
}
@@ -564,6 +564,13 @@ HexagonToolChain::GetCXXStdlibType(const
return ToolChain::CST_Libstdcxx;
}
+bool HexagonToolChain::isAutoHVXEnabled(const llvm::opt::ArgList &Args) {
+ if (Arg *A = Args.getLastArg(options::OPT_fvectorize,
+ options::OPT_fno_vectorize))
+ return A->getOption().matches(options::OPT_fvectorize);
+ return false;
+}
+
//
// Returns the default CPU for Hexagon. This is the default compilation target
// if no Hexagon processor is selected at the command-line.
Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.h?rev=330150&r1=330149&r2=330150&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.h Mon Apr 16 12:11:17 2018
@@ -94,6 +94,7 @@ public:
void getHexagonLibraryPaths(const llvm::opt::ArgList &Args,
ToolChain::path_list &LibPaths) const;
+ static bool isAutoHVXEnabled(const llvm::opt::ArgList &Args);
static const StringRef GetDefaultCPU();
static const StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
Modified: cfe/trunk/test/Driver/hexagon-vectorize.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-vectorize.c?rev=330150&r1=330149&r2=330150&view=diff
==============================================================================
--- cfe/trunk/test/Driver/hexagon-vectorize.c (original)
+++ cfe/trunk/test/Driver/hexagon-vectorize.c Mon Apr 16 12:11:17 2018
@@ -1,7 +1,9 @@
// RUN: %clang -target hexagon -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT
// RUN: %clang -target hexagon -fvectorize -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-VECTOR
// RUN: %clang -target hexagon -fvectorize -fno-vectorize -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOVECTOR
+// RUN: %clang -target hexagon -fvectorize -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-NEEDHVX
// CHECK-DEFAULT-NOT: hexagon-autohvx
// CHECK-VECTOR: "-mllvm" "-hexagon-autohvx"
// CHECK-NOVECTOR-NOT: hexagon-autohvx
+// CHECK-NEEDHVX: warning: auto-vectorization requires HVX, use -mhvx to enable it
More information about the cfe-commits
mailing list