diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 90f80266e809..2615ab4cbab6 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2145,18 +2145,24 @@ def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group; def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group, Flags<[NoArgumentUnused, HelpHidden]>; def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group, - Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; + Flags<[CC1Option, NoArgumentUnused, HelpHidden]>, + MarshallingInfoNegativeFlag, !strconcat("(bool)", fopenmp.KeyPath)>, + ShouldParseIf; def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">, Flags<[NoXarchOption, CC1Option]>, HelpText<"Specify comma-separated list of triples OpenMP offloading targets to be supported">; def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; def fnoopenmp_relocatable_target : Flag<["-"], "fnoopenmp-relocatable-target">, Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; -def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group, Flags<[CC1Option, NoArgumentUnused]>, - HelpText<"Emit OpenMP code only for SIMD-based constructs.">; +defm openmp_simd : BoolFOption<"openmp-simd", + LangOpts<"OpenMPSimd">, DefaultFalse, + PosFlag, + NegFlag, BothFlags<[CC1Option, NoArgumentUnused]>>, + ShouldParseIf; def fopenmp_enable_irbuilder : Flag<["-"], "fopenmp-enable-irbuilder">, Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>, - HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">; -def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, Flags<[CC1Option, NoArgumentUnused]>; + HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">, + MarshallingInfoFlag>, + ShouldParseIf; def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, Group, @@ -5367,9 +5373,12 @@ def fno_cuda_host_device_constexpr : Flag<["-"], "fno-cuda-host-device-constexpr //===----------------------------------------------------------------------===// def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">, - HelpText<"Generate code only for an OpenMP target device.">; + HelpText<"Generate code only for an OpenMP target device.">, + MarshallingInfoFlag>, + ShouldParseIf; def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">, - HelpText<"Path to the IR file produced by the frontend for the host.">; + HelpText<"Path to the IR file produced by the frontend for the host.">, + MarshallingInfoString>; //===----------------------------------------------------------------------===// // SYCL Options diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 4853a70dee1b..d61c3bd46c11 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -477,6 +477,12 @@ static void FixupInvocation(CompilerInvocation &Invocation, << A->getSpelling() << T.getTriple(); } + // Report if OpenMP host file does not exist. + if (!LangOpts.OMPHostIRFile.empty() && + !llvm::sys::fs::exists(LangOpts.OMPHostIRFile)) + Diags.Report(diag::err_drv_omp_host_ir_file_not_found) + << LangOpts.OMPHostIRFile; + if (!CodeGenOpts.ProfileRemappingFile.empty() && CodeGenOpts.LegacyPassManager) Diags.Report(diag::err_drv_argument_only_allowed_with) << Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args) @@ -2382,13 +2388,6 @@ void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, bool IsSimdSpecified = Args.hasFlag(options::OPT_fopenmp_simd, options::OPT_fno_openmp_simd, /*Default=*/false); - Opts.OpenMPSimd = !Opts.OpenMP && IsSimdSpecified; - Opts.OpenMPUseTLS = - Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls); - Opts.OpenMPIsDevice = - Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device); - Opts.OpenMPIRBuilder = - Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_enable_irbuilder); bool IsTargetSpecified = Opts.OpenMPIsDevice || Args.hasArg(options::OPT_fopenmp_targets_EQ); @@ -2462,15 +2461,6 @@ void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, } } - // Get OpenMP host file path if any and report if a non existent file is - // found - if (Arg *A = Args.getLastArg(options::OPT_fopenmp_host_ir_file_path)) { - Opts.OMPHostIRFile = A->getValue(); - if (!llvm::sys::fs::exists(Opts.OMPHostIRFile)) - Diags.Report(diag::err_drv_omp_host_ir_file_not_found) - << Opts.OMPHostIRFile; - } - // Set CUDA mode for OpenMP target NVPTX/AMDGCN if specified in options Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && (T.isNVPTX() || T.isAMDGCN()) && Args.hasArg(options::OPT_fopenmp_cuda_mode);