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