Skip to content

Commit eefa8a9

Browse files
committed
Revert "[clang][cli] Port OpenMP-related LangOpts to marshalling system"
This reverts commit 9ad94c1 It turns out that to correctly generate command line flags for LangOptions::OpenMP and LangOptions::OpenMPSimd, we need the flexibility of C++.
1 parent 11e74e5 commit eefa8a9

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,24 +2145,18 @@ def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group<f_Group>;
21452145
def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group<f_Group>,
21462146
Flags<[NoArgumentUnused, HelpHidden]>;
21472147
def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group<f_Group>,
2148-
Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
2149-
MarshallingInfoNegativeFlag<LangOpts<"OpenMPUseTLS">, !strconcat("(bool)", fopenmp.KeyPath)>,
2150-
ShouldParseIf<fopenmp.KeyPath>;
2148+
Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
21512149
def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">, Flags<[NoXarchOption, CC1Option]>,
21522150
HelpText<"Specify comma-separated list of triples OpenMP offloading targets to be supported">;
21532151
def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">,
21542152
Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
21552153
def fnoopenmp_relocatable_target : Flag<["-"], "fnoopenmp-relocatable-target">,
21562154
Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
2157-
defm openmp_simd : BoolFOption<"openmp-simd",
2158-
LangOpts<"OpenMPSimd">, DefaultFalse,
2159-
PosFlag<SetTrue, [], "Emit OpenMP code only for SIMD-based constructs.">,
2160-
NegFlag<SetFalse>, BothFlags<[CC1Option, NoArgumentUnused]>>,
2161-
ShouldParseIf<!strconcat("!", fopenmp.KeyPath)>;
2155+
def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>,
2156+
HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
21622157
def fopenmp_enable_irbuilder : Flag<["-"], "fopenmp-enable-irbuilder">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
2163-
HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">,
2164-
MarshallingInfoFlag<LangOpts<"OpenMPIRBuilder">>,
2165-
ShouldParseIf<fopenmp.KeyPath>;
2158+
HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">;
2159+
def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>;
21662160
def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group<f_Group>,
21672161
Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
21682162
def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, Group<f_Group>,
@@ -5373,12 +5367,9 @@ def fno_cuda_host_device_constexpr : Flag<["-"], "fno-cuda-host-device-constexpr
53735367
//===----------------------------------------------------------------------===//
53745368

53755369
def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">,
5376-
HelpText<"Generate code only for an OpenMP target device.">,
5377-
MarshallingInfoFlag<LangOpts<"OpenMPIsDevice">>,
5378-
ShouldParseIf<fopenmp.KeyPath>;
5370+
HelpText<"Generate code only for an OpenMP target device.">;
53795371
def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">,
5380-
HelpText<"Path to the IR file produced by the frontend for the host.">,
5381-
MarshallingInfoString<LangOpts<"OMPHostIRFile">>;
5372+
HelpText<"Path to the IR file produced by the frontend for the host.">;
53825373

53835374
//===----------------------------------------------------------------------===//
53845375
// SYCL Options

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,6 @@ static void FixupInvocation(CompilerInvocation &Invocation,
494494
<< A->getSpelling() << T.getTriple();
495495
}
496496

497-
// Report if OpenMP host file does not exist.
498-
if (!LangOpts.OMPHostIRFile.empty() &&
499-
!llvm::sys::fs::exists(LangOpts.OMPHostIRFile))
500-
Diags.Report(diag::err_drv_omp_host_ir_file_not_found)
501-
<< LangOpts.OMPHostIRFile;
502-
503497
if (!CodeGenOpts.ProfileRemappingFile.empty() && CodeGenOpts.LegacyPassManager)
504498
Diags.Report(diag::err_drv_argument_only_allowed_with)
505499
<< Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
@@ -2437,6 +2431,13 @@ void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
24372431
bool IsSimdSpecified =
24382432
Args.hasFlag(options::OPT_fopenmp_simd, options::OPT_fno_openmp_simd,
24392433
/*Default=*/false);
2434+
Opts.OpenMPSimd = !Opts.OpenMP && IsSimdSpecified;
2435+
Opts.OpenMPUseTLS =
2436+
Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls);
2437+
Opts.OpenMPIsDevice =
2438+
Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
2439+
Opts.OpenMPIRBuilder =
2440+
Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_enable_irbuilder);
24402441
bool IsTargetSpecified =
24412442
Opts.OpenMPIsDevice || Args.hasArg(options::OPT_fopenmp_targets_EQ);
24422443

@@ -2510,6 +2511,15 @@ void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
25102511
}
25112512
}
25122513

2514+
// Get OpenMP host file path if any and report if a non existent file is
2515+
// found
2516+
if (Arg *A = Args.getLastArg(options::OPT_fopenmp_host_ir_file_path)) {
2517+
Opts.OMPHostIRFile = A->getValue();
2518+
if (!llvm::sys::fs::exists(Opts.OMPHostIRFile))
2519+
Diags.Report(diag::err_drv_omp_host_ir_file_not_found)
2520+
<< Opts.OMPHostIRFile;
2521+
}
2522+
25132523
// Set CUDA mode for OpenMP target NVPTX/AMDGCN if specified in options
25142524
Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && (T.isNVPTX() || T.isAMDGCN()) &&
25152525
Args.hasArg(options::OPT_fopenmp_cuda_mode);

0 commit comments

Comments
 (0)