@@ -965,151 +965,6 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
965
965
*HostTC, OFK);
966
966
assert (HIPTC && " Could not create offloading device tool chain." );
967
967
C.addOffloadDeviceToolChain (HIPTC, OFK);
968
- } else if (C.getInputArgs ().hasFlag (options::OPT_offload_new_driver,
969
- options::OPT_no_offload_new_driver,
970
- false )) {
971
- bool IsOpenMPOffloading =
972
- C.getInputArgs ().hasFlag (options::OPT_fopenmp, options::OPT_fopenmp_EQ,
973
- options::OPT_fno_openmp, false ) &&
974
- (C.getInputArgs ().hasArg (options::OPT_fopenmp_targets_EQ) ||
975
- C.getInputArgs ().hasArg (options::OPT_offload_arch_EQ));
976
- if (IsOpenMPOffloading) {
977
- // We expect that -fopenmp-targets is always used in conjunction with the
978
- // option -fopenmp specifying a valid runtime with offloading support,
979
- // i.e. libomp or libiomp.
980
- OpenMPRuntimeKind RuntimeKind = getOpenMPRuntime (C.getInputArgs ());
981
- if (RuntimeKind != OMPRT_OMP && RuntimeKind != OMPRT_IOMP5) {
982
- Diag (clang::diag::Err_drv_expecting_fopenmp_with_fopenmp_targets);
983
- return ;
984
- }
985
-
986
- llvm::StringMap<llvm::DenseSet<StringRef>> DerivedArchs;
987
- llvm::StringMap<StringRef> FoundNormalizedTriples;
988
- llvm::SmallVector<StringRef, 4 > OpenMPTriples;
989
-
990
- // If the user specified -fopenmp-targets= we create a toolchain for each
991
- // valid triple. Otherwise, if only --offload-arch= was specified we
992
- // instead attempt to derive the appropriate toolchains from the
993
- // arguments.
994
- if (Arg *OpenMPTargets =
995
- C.getInputArgs ().getLastArg (options::OPT_fopenmp_targets_EQ)) {
996
- if (OpenMPTargets && !OpenMPTargets->getNumValues ()) {
997
- Diag (clang::diag::warn_drv_empty_joined_argument)
998
- << OpenMPTargets->getAsString (C.getInputArgs ());
999
- return ;
1000
- }
1001
- llvm::copy (OpenMPTargets->getValues (),
1002
- std::back_inserter (OpenMPTriples));
1003
- } else if (C.getInputArgs ().hasArg (options::OPT_offload_arch_EQ) &&
1004
- !IsHIP && !IsCuda) {
1005
- const ToolChain *HostTC =
1006
- C.getSingleOffloadToolChain <Action::OFK_Host>();
1007
- auto AMDTriple = getHIPOffloadTargetTriple (*this , C.getInputArgs ());
1008
- auto NVPTXTriple = getNVIDIAOffloadTargetTriple (*this , C.getInputArgs (),
1009
- HostTC->getTriple ());
1010
-
1011
- // Attempt to deduce the offloading triple from the set of
1012
- // architectures. We can only correctly deduce NVPTX / AMDGPU triples
1013
- // currently. We need to temporarily create these toolchains so that we
1014
- // can access tools for inferring architectures.
1015
- llvm::DenseSet<StringRef> Archs;
1016
- if (NVPTXTriple) {
1017
- auto TempTC = std::make_unique<toolchains::CudaToolChain>(
1018
- *this , *NVPTXTriple, *HostTC, C.getInputArgs ());
1019
- for (StringRef Arch : getOffloadArchs (
1020
- C, C.getArgs (), Action::OFK_OpenMP, &*TempTC, true ))
1021
- Archs.insert (Arch);
1022
- }
1023
- if (AMDTriple) {
1024
- auto TempTC = std::make_unique<toolchains::AMDGPUOpenMPToolChain>(
1025
- *this , *AMDTriple, *HostTC, C.getInputArgs (), Action::OFK_OpenMP);
1026
- for (StringRef Arch : getOffloadArchs (
1027
- C, C.getArgs (), Action::OFK_OpenMP, &*TempTC, true ))
1028
- Archs.insert (Arch);
1029
- }
1030
- if (!AMDTriple && !NVPTXTriple) {
1031
- for (StringRef Arch : getOffloadArchs (
1032
- C, C.getArgs (), Action::OFK_OpenMP, nullptr , true ))
1033
- Archs.insert (Arch);
1034
- }
1035
-
1036
- for (StringRef Arch : Archs) {
1037
- if (NVPTXTriple &&
1038
- IsNVIDIAGpuArch (StringToCudaArch (
1039
- getProcessorFromTargetID (*NVPTXTriple, Arch)))) {
1040
- DerivedArchs[NVPTXTriple->getTriple ()].insert (Arch);
1041
- } else if (AMDTriple &&
1042
- IsAMDGpuArch (StringToCudaArch (
1043
- getProcessorFromTargetID (*AMDTriple, Arch)))) {
1044
- DerivedArchs[AMDTriple->getTriple ()].insert (Arch);
1045
- } else {
1046
- Diag (clang::diag::err_drv_failed_to_deduce_target_from_arch)
1047
- << Arch;
1048
- return ;
1049
- }
1050
- }
1051
-
1052
- // If the set is empty then we failed to find a native architecture.
1053
- if (Archs.empty ()) {
1054
- Diag (clang::diag::err_drv_failed_to_deduce_target_from_arch)
1055
- << " native" ;
1056
- return ;
1057
- }
1058
-
1059
- for (const auto &TripleAndArchs : DerivedArchs)
1060
- OpenMPTriples.push_back (TripleAndArchs.first ());
1061
- }
1062
-
1063
- for (StringRef Val : OpenMPTriples) {
1064
- llvm::Triple TT (ToolChain::getOpenMPTriple (Val));
1065
- std::string NormalizedName = TT.normalize ();
1066
-
1067
- // Make sure we don't have a duplicate triple.
1068
- auto Duplicate = FoundNormalizedTriples.find (NormalizedName);
1069
- if (Duplicate != FoundNormalizedTriples.end ()) {
1070
- Diag (clang::diag::warn_drv_omp_offload_target_duplicate)
1071
- << Val << Duplicate->second ;
1072
- continue ;
1073
- }
1074
-
1075
- // Store the current triple so that we can check for duplicates in the
1076
- // following iterations.
1077
- FoundNormalizedTriples[NormalizedName] = Val;
1078
-
1079
- // If the specified target is invalid, emit a diagnostic.
1080
- if (TT.getArch () == llvm::Triple::UnknownArch)
1081
- Diag (clang::diag::err_drv_invalid_omp_target) << Val;
1082
- else {
1083
- const ToolChain *TC;
1084
- // Device toolchains have to be selected differently. They pair host
1085
- // and device in their implementation.
1086
- if (TT.isNVPTX () || TT.isAMDGCN ()) {
1087
- const ToolChain *HostTC =
1088
- C.getSingleOffloadToolChain <Action::OFK_Host>();
1089
- assert (HostTC && " Host toolchain should be always defined." );
1090
- auto &DeviceTC =
1091
- ToolChains[TT.str () + " /" + HostTC->getTriple ().normalize ()];
1092
- if (!DeviceTC) {
1093
- if (TT.isNVPTX ())
1094
- DeviceTC = std::make_unique<toolchains::CudaToolChain>(
1095
- *this , TT, *HostTC, C.getInputArgs ());
1096
- else if (TT.isAMDGCN ())
1097
- DeviceTC = std::make_unique<toolchains::AMDGPUOpenMPToolChain>(
1098
- *this , TT, *HostTC, C.getInputArgs (), Action::OFK_OpenMP);
1099
- else
1100
- assert (DeviceTC && " Device toolchain not defined." );
1101
- }
1102
-
1103
- TC = DeviceTC.get ();
1104
- } else
1105
- TC = &getToolChain (C.getInputArgs (), TT);
1106
- C.addOffloadDeviceToolChain (TC, Action::OFK_OpenMP);
1107
- if (DerivedArchs.find (TT.getTriple ()) != DerivedArchs.end ())
1108
- KnownArchs[TC] = DerivedArchs[TT.getTriple ()];
1109
- }
1110
- }
1111
- }
1112
-
1113
968
} else {
1114
969
//
1115
970
// OpenMP
@@ -1167,7 +1022,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1167
1022
bool IsHostOffloading =
1168
1023
(OpenMPTargets->getNumValues () == 1 ) &&
1169
1024
StringRef (OpenMPTargets->getValue ())
1170
- .startswith_insensitive (
1025
+ .starts_with_insensitive (
1171
1026
C.getSingleOffloadToolChain <Action::OFK_Host>()
1172
1027
->getTriple ()
1173
1028
.getArchName ());
@@ -4676,9 +4531,9 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
4676
4531
4677
4532
handleArguments (C, Args, Inputs, Actions);
4678
4533
4679
- bool UseNewOffloadingDriver =
4680
- Args. hasFlag ( options::OPT_offload_new_driver,
4681
- options::OPT_no_offload_new_driver, false );
4534
+ bool UseNewOffloadingDriver = Args. hasFlag (
4535
+ options::OPT_offload_new_driver, options::OPT_no_offload_new_driver ,
4536
+ C. isOffloadingHostKind (Action::OFK_OpenMP) );
4682
4537
4683
4538
// Builder to be used to build offloading actions.
4684
4539
std::unique_ptr<OffloadingActionBuilder> OffloadBuilder =
0 commit comments