[Driver] Move CommonArgs to a location visible by the Frontend Drivers (#142800)

This patch moves the CommonArgs utilities into a location visible by the
Frontend Drivers, so that the Frontend Drivers may share option parsing
code with the Compiler Driver. This is useful when the Frontend Drivers
would like to verify that their incoming options are well-formed and
also not reinvent the option parsing wheel.

We already see code in the Clang/Flang Drivers that is parsing and
verifying its incoming options. E.g. OPT_ffp_contract. This option is
parsed in the Compiler Driver, Clang Driver, and Flang Driver, all with
slightly different parsing code. It would be nice if the Frontend
Drivers were not required to duplicate this Compiler Driver code. That
way there is no/low maintenance burden on keeping all these parsing
functions in sync.

Along those lines, the Frontend Drivers will now have a useful mechanism
to verify their incoming options are well-formed. Currently, the
Frontend Drivers trust that the Compiler Driver is not passing back junk
in some cases. The Language Drivers may even accept junk with no error
at all. E.g.:

  `clang -cc1 -mprefer-vector-width=junk test.c'

With this patch, we'll now be able to tighten up incomming options to
the Frontend drivers in a lightweight way.

---------

Co-authored-by: Cameron McInally <cmcinally@nvidia.com>
Co-authored-by: Shafik Yaghmour <shafik.yaghmour@intel.com>
This commit is contained in:
Cameron McInally 2025-06-06 17:59:24 -04:00 committed by GitHub
parent 347186b259
commit a42bb8b57a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
57 changed files with 95 additions and 89 deletions

View File

@ -270,6 +270,12 @@ void handleVectorizeLoopsArgs(const llvm::opt::ArgList &Args,
/// Enable -fslp-vectorize based on the optimization level selected.
void handleVectorizeSLPArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs);
// Parse -mprefer-vector-width=. Return the Value string if well-formed.
// Otherwise, return an empty string and issue a diagnosic message if needed.
StringRef ParseMPreferVectorWidthOption(clang::DiagnosticsEngine &Diags,
const llvm::opt::ArgList &Args);
} // end namespace tools
} // end namespace driver
} // end namespace clang

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Driver/MultilibBuilder.h"
#include "ToolChains/CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Regex.h"

View File

@ -11,13 +11,13 @@
#include "ToolChains/Arch/ARM.h"
#include "ToolChains/Arch/RISCV.h"
#include "ToolChains/Clang.h"
#include "ToolChains/CommonArgs.h"
#include "ToolChains/Flang.h"
#include "ToolChains/InterfaceStubs.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/Sanitizers.h"
#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Job.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "AIX.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"

View File

@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "AMDGPU.h"
#include "CommonArgs.h"
#include "clang/Basic/TargetID.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "AVR.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "AArch64.h"
#include "../CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "llvm/Option/ArgList.h"

View File

@ -8,8 +8,8 @@
#include "LoongArch.h"
#include "../Clang.h"
#include "ToolChains/CommonArgs.h"
#include "clang/Basic/DiagnosticDriver.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "llvm/TargetParser/Host.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "Mips.h"
#include "ToolChains/CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "llvm/ADT/StringSwitch.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "PPC.h"
#include "ToolChains/CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "llvm/ADT/StringSwitch.h"

View File

@ -8,7 +8,7 @@
#include "RISCV.h"
#include "../Clang.h"
#include "ToolChains/CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "llvm/Option/ArgList.h"

View File

@ -8,8 +8,8 @@
#include "BareMetal.h"
#include "CommonArgs.h"
#include "Gnu.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/InputInfo.h"
#include "Arch/ARM.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CSKYToolChain.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"

View File

@ -14,7 +14,6 @@
#include "Arch/RISCV.h"
#include "Arch/Sparc.h"
#include "Arch/SystemZ.h"
#include "CommonArgs.h"
#include "Hexagon.h"
#include "PS4CPU.h"
#include "clang/Basic/CLWarnings.h"
@ -26,6 +25,7 @@
#include "clang/Basic/Version.h"
#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Distro.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
@ -264,27 +264,6 @@ static void ParseMRecip(const Driver &D, const ArgList &Args,
OutStrings.push_back(Args.MakeArgString(Out));
}
/// The -mprefer-vector-width option accepts either a positive integer
/// or the string "none".
static void ParseMPreferVectorWidth(const Driver &D, const ArgList &Args,
ArgStringList &CmdArgs) {
Arg *A = Args.getLastArg(options::OPT_mprefer_vector_width_EQ);
if (!A)
return;
StringRef Value = A->getValue();
if (Value == "none") {
CmdArgs.push_back("-mprefer-vector-width=none");
} else {
unsigned Width;
if (Value.getAsInteger(10, Width)) {
D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Value;
return;
}
CmdArgs.push_back(Args.MakeArgString("-mprefer-vector-width=" + Value));
}
}
static bool
shouldUseExceptionTablesForObjCExceptions(const ObjCRuntime &runtime,
const llvm::Triple &Triple) {
@ -7607,7 +7586,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
handleVectorizeLoopsArgs(Args, CmdArgs);
handleVectorizeSLPArgs(Args, CmdArgs);
ParseMPreferVectorWidth(D, Args, CmdArgs);
StringRef VecWidth = ParseMPreferVectorWidthOption(D.getDiags(), Args);
if (!VecWidth.empty())
CmdArgs.push_back(Args.MakeArgString("-mprefer-vector-width=" + VecWidth));
Args.AddLastArg(CmdArgs, options::OPT_fshow_overloads_EQ);
Args.AddLastArg(CmdArgs,

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "Arch/AArch64.h"
#include "Arch/ARM.h"
#include "Arch/CSKY.h"
@ -3167,3 +3167,25 @@ void tools::handleInterchangeLoopsArgs(const ArgList &Args,
options::OPT_fno_loop_interchange, EnableInterchange))
CmdArgs.push_back("-floop-interchange");
}
// Parse -mprefer-vector-width=. Return the Value string if well-formed.
// Otherwise, return an empty string and issue a diagnosic message if needed.
StringRef tools::ParseMPreferVectorWidthOption(clang::DiagnosticsEngine &Diags,
const llvm::opt::ArgList &Args) {
Arg *A = Args.getLastArg(clang::driver::options::OPT_mprefer_vector_width_EQ);
if (!A)
return "";
StringRef Value = A->getValue();
unsigned Width LLVM_ATTRIBUTE_UNINITIALIZED;
// Only "none" and Integer values are accepted by
// -mprefer-vector-width=<value>.
if (Value != "none" && Value.getAsInteger(10, Width)) {
Diags.Report(clang::diag::err_drv_invalid_value)
<< A->getOption().getName() << Value;
return "";
}
return Value;
}

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CrossWindows.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "Cuda.h"
#include "CommonArgs.h"
#include "clang/Basic/Cuda.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Distro.h"
#include "clang/Driver/Driver.h"

View File

@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "Cygwin.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "llvm/Support/Path.h"

View File

@ -8,10 +8,10 @@
#include "Darwin.h"
#include "Arch/ARM.h"
#include "CommonArgs.h"
#include "clang/Basic/AlignedAllocation.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "DragonFly.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -8,9 +8,9 @@
#include "Flang.h"
#include "Arch/RISCV.h"
#include "CommonArgs.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Options.h"
#include "llvm/Frontend/Debug/Options.h"
#include "llvm/Support/Path.h"

View File

@ -10,8 +10,8 @@
#include "Arch/ARM.h"
#include "Arch/Mips.h"
#include "Arch/Sparc.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"

View File

@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "Fuchsia.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/MultilibBuilder.h"

View File

@ -15,8 +15,8 @@
#include "Arch/RISCV.h"
#include "Arch/Sparc.h"
#include "Arch/SystemZ.h"
#include "CommonArgs.h"
#include "clang/Config/config.h" // for GCC_INSTALL_PREFIX
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/MultilibBuilder.h"

View File

@ -8,10 +8,10 @@
#include "HIPAMD.h"
#include "AMDGPU.h"
#include "CommonArgs.h"
#include "HIPUtility.h"
#include "SPIRV.h"
#include "clang/Basic/Cuda.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"

View File

@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "HIPSPV.h"
#include "CommonArgs.h"
#include "HIPUtility.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "HIPUtility.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Options.h"
#include "llvm/ADT/StringExtras.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "HLSL.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Job.h"
#include "llvm/ADT/StringSwitch.h"

View File

@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "Haiku.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/SanitizerArgs.h"
#include "llvm/Support/Path.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "Hexagon.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"

View File

@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "Hurd.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "llvm/Support/Path.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "InterfaceStubs.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "llvm/Support/Path.h"

View File

@ -12,8 +12,8 @@
#include "Arch/Mips.h"
#include "Arch/PPC.h"
#include "Arch/RISCV.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Distro.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "MSP430.h"
#include "CommonArgs.h"
#include "Gnu.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Multilib.h"

View File

@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "MSVC.h"
#include "CommonArgs.h"
#include "Darwin.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "MinGW.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "NaCl.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"

View File

@ -10,8 +10,8 @@
#include "Arch/ARM.h"
#include "Arch/Mips.h"
#include "Arch/Sparc.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -8,8 +8,8 @@
#include "OHOS.h"
#include "Arch/ARM.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -10,8 +10,8 @@
#include "Arch/ARM.h"
#include "Arch/Mips.h"
#include "Arch/Sparc.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"

View File

@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "PS4CPU.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "RISCVToolchain.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "SPIRV.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"

View File

@ -6,7 +6,7 @@
//
//==------------------------------------------------------------------------==//
#include "SPIRVOpenMP.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
using namespace clang::driver;
using namespace clang::driver::toolchains;

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "SYCL.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
using namespace clang::driver;
using namespace clang::driver::toolchains;

View File

@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "Solaris.h"
#include "CommonArgs.h"
#include "Gnu.h"
#include "clang/Basic/LangStandard.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "UEFI.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "VEToolchain.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "WebAssembly.h"
#include "CommonArgs.h"
#include "Gnu.h"
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "XCore.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "ZOS.h"
#include "CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Options.h"
#include "llvm/Option/ArgList.h"

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "clang/Driver/XRayArgs.h"
#include "ToolChains/CommonArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/ToolChain.h"

View File

@ -12,9 +12,9 @@
//===----------------------------------------------------------------------===//
#include "clang/Driver/MultilibBuilder.h"
#include "../../lib/Driver/ToolChains/CommonArgs.h"
#include "SimpleDiagnosticConsumer.h"
#include "clang/Basic/LLVM.h"
#include "clang/Driver/CommonArgs.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"

View File

@ -11,10 +11,10 @@
//===----------------------------------------------------------------------===//
#include "clang/Driver/Multilib.h"
#include "../../lib/Driver/ToolChains/CommonArgs.h"
#include "SimpleDiagnosticConsumer.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/Version.h"
#include "clang/Driver/CommonArgs.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"

View File

@ -23,6 +23,7 @@
#include "clang/Basic/AllDiagnostics.h"
#include "clang/Basic/DiagnosticDriver.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/OptionUtils.h"
@ -309,19 +310,8 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
for (auto *a : args.filtered(clang::driver::options::OPT_fpass_plugin_EQ))
opts.LLVMPassPlugins.push_back(a->getValue());
// -mprefer_vector_width option
if (const llvm::opt::Arg *a = args.getLastArg(
clang::driver::options::OPT_mprefer_vector_width_EQ)) {
llvm::StringRef s = a->getValue();
unsigned width;
if (s == "none")
opts.PreferVectorWidth = "none";
else if (s.getAsInteger(10, width))
diags.Report(clang::diag::err_drv_invalid_value)
<< a->getAsString(args) << a->getValue();
else
opts.PreferVectorWidth = s.str();
}
opts.PreferVectorWidth =
clang::driver::tools::ParseMPreferVectorWidthOption(diags, args);
// -fembed-offload-object option
for (auto *a :

View File

@ -15,4 +15,4 @@ end subroutine func
! CHECK-NONE-SAME: "prefer-vector-width"="none"
! CHECK-128-SAME: "prefer-vector-width"="128"
! CHECK-256-SAME: "prefer-vector-width"="256"
! CHECK-INVALID: error: invalid value 'xxx' in '-mprefer-vector-width=xxx'
! CHECK-INVALID: error: invalid value 'xxx' in 'mprefer-vector-width='

View File

@ -238,6 +238,12 @@
#define LLVM_PREFETCH(addr, rw, locality)
#endif
#if __has_attribute(uninitialized)
#define LLVM_ATTRIBUTE_UNINITIALIZED __attribute__((uninitialized))
#else
#define LLVM_ATTRIBUTE_UNINITIALIZED
#endif
#if __has_attribute(used)
#define LLVM_ATTRIBUTE_USED __attribute__((__used__))
#else