@@ -1366,25 +1366,14 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1366
1366
// Get the list of requested offloading toolchains. If they were not
1367
1367
// explicitly specified we will infer them based on the offloading language
1368
1368
// and requested architectures.
1369
- llvm::StringMap<StringRef> FoundNormalizedTriples;
1370
- auto isDuplicateTargetTripleString = [&](llvm::StringRef Target) -> bool {
1371
- std::string NormalizedName =
1372
- C.getDriver ().getSYCLDeviceTriple (Target).normalize ();
1373
- auto [TripleIt, Inserted] =
1374
- FoundNormalizedTriples.try_emplace (NormalizedName, Target);
1375
- if (!Inserted) {
1376
- Diag (clang::diag::warn_drv_offload_target_duplicate)
1377
- << Target << TripleIt->second ;
1378
- return true ;
1379
- }
1380
- return false ;
1381
- };
1382
1369
1383
1370
std::multiset<llvm::StringRef> Triples;
1371
+ llvm::StringMap<StringRef> FoundNormalizedTriples;
1384
1372
if (C.getInputArgs ().hasArg (options::OPT_offload_targets_EQ)) {
1385
1373
std::vector<std::string> ArgValues =
1386
1374
C.getInputArgs ().getAllArgValues (options::OPT_offload_targets_EQ);
1387
1375
llvm::Triple TT;
1376
+
1388
1377
for (llvm::StringRef Target : ArgValues) {
1389
1378
if (IsSYCL) {
1390
1379
StringRef TargetTripleString (Target);
@@ -1394,14 +1383,20 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1394
1383
TargetTripleString = " nvptx64-nvidia-cuda" ;
1395
1384
else if (Target.starts_with (" amd_gpu_" ))
1396
1385
TargetTripleString = " amdgcn-amd-amdhsa" ;
1397
-
1398
- // Check for duplicate target triple strings
1399
- // before inserting in Triples.
1400
- if (isDuplicateTargetTripleString (Target))
1386
+ std::string NormalizedName =
1387
+ getSYCLDeviceTriple (TargetTripleString).normalize ();
1388
+ auto [TripleIt, Inserted] =
1389
+ FoundNormalizedTriples.try_emplace (NormalizedName, Target);
1390
+ if (!Inserted) {
1391
+ if (Target == TripleIt->second )
1392
+ Diag (clang::diag::warn_drv_offload_target_duplicate)
1393
+ << Target << TripleIt->second ;
1401
1394
continue ;
1395
+ }
1402
1396
Triples.insert (C.getInputArgs ().MakeArgString (TargetTripleString));
1403
- } else
1397
+ } else {
1404
1398
Triples.insert (C.getInputArgs ().MakeArgString (Target));
1399
+ }
1405
1400
}
1406
1401
1407
1402
if (ArgValues.empty ())
@@ -1415,7 +1410,6 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1415
1410
Triples.insert (Derived.begin (), Derived.end ());
1416
1411
}
1417
1412
}
1418
-
1419
1413
FoundNormalizedTriples.clear ();
1420
1414
// Build an offloading toolchain for every requested target and kind.
1421
1415
for (StringRef Target : Triples) {
@@ -1459,10 +1453,17 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1459
1453
Diag (diag::err_drv_invalid_or_unsupported_offload_target) << TT.str ();
1460
1454
continue ;
1461
1455
}
1462
- // Check for duplicate target triple strings.
1463
- if ((Kind == Action::OFK_OpenMP || Kind == Action::OFK_SYCL) &&
1464
- isDuplicateTargetTripleString (Target))
1465
- continue ;
1456
+
1457
+ if (Kind == Action::OFK_OpenMP || Kind == Action::OFK_SYCL) {
1458
+ std::string NormalizedName = TT.normalize ();
1459
+ auto [TripleIt, Inserted] =
1460
+ FoundNormalizedTriples.try_emplace (NormalizedName, Target);
1461
+ if (!Inserted) {
1462
+ Diag (clang::diag::warn_drv_offload_target_duplicate)
1463
+ << Target << TripleIt->second ;
1464
+ continue ;
1465
+ }
1466
+ }
1466
1467
1467
1468
auto &TC = getOffloadToolChain (C.getInputArgs (), Kind, TT,
1468
1469
C.getDefaultToolChain ().getTriple ());
0 commit comments