@@ -465,7 +465,7 @@ fatbinary(ArrayRef<std::pair<StringRef, StringRef>> InputFiles,
465
465
466
466
namespace generic {
467
467
Expected<StringRef> clang (ArrayRef<StringRef> InputFiles, const ArgList &Args,
468
- bool HasSYCLOffloadKind = false ) {
468
+ uint16_t ActiveOffloadKindMask ) {
469
469
llvm::TimeTraceScope TimeScope (" Clang" );
470
470
// Use `clang` to invoke the appropriate device tools.
471
471
Expected<std::string> ClangPath =
@@ -559,7 +559,7 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args,
559
559
// required. Passing --sycl-link to clang results in a call to
560
560
// clang-sycl-linker. Additional linker flags required by clang-sycl-linker
561
561
// will be communicated via the -Xlinker option.
562
- if (HasSYCLOffloadKind ) {
562
+ if (ActiveOffloadKindMask & OFK_SYCL ) {
563
563
CmdArgs.push_back (" --sycl-link" );
564
564
CmdArgs.append (
565
565
{" -Xlinker" , Args.MakeArgString (" -triple=" + Triple.getTriple ())});
@@ -580,7 +580,7 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args,
580
580
581
581
Expected<StringRef> linkDevice (ArrayRef<StringRef> InputFiles,
582
582
const ArgList &Args,
583
- bool HasSYCLOffloadKind = false ) {
583
+ uint16_t ActiveOffloadKindMask ) {
584
584
const llvm::Triple Triple (Args.getLastArgValue (OPT_triple_EQ));
585
585
switch (Triple.getArch ()) {
586
586
case Triple::nvptx:
@@ -595,7 +595,7 @@ Expected<StringRef> linkDevice(ArrayRef<StringRef> InputFiles,
595
595
case Triple::spirv64:
596
596
case Triple::systemz:
597
597
case Triple::loongarch64:
598
- return generic::clang (InputFiles, Args, HasSYCLOffloadKind );
598
+ return generic::clang (InputFiles, Args, ActiveOffloadKindMask );
599
599
default :
600
600
return createStringError (Triple.getArchName () +
601
601
" linking is not supported" );
@@ -949,9 +949,13 @@ Expected<SmallVector<StringRef>> linkAndWrapDeviceFiles(
949
949
InputFiles.emplace_back (*FileNameOrErr);
950
950
}
951
951
952
+ // Currently, SYCL device code linking process differs from generic device
953
+ // code linking.
954
+ // TODO: Align SYCL device code linking with generic linking.
952
955
if (ActiveOffloadKindMask & OFK_SYCL) {
953
956
// Link the remaining device files using the device linker.
954
- auto OutputOrErr = linkDevice (InputFiles, LinkerArgs, HasSYCLOffloadKind);
957
+ auto OutputOrErr =
958
+ linkDevice (InputFiles, LinkerArgs, ActiveOffloadKindMask);
955
959
if (!OutputOrErr)
956
960
return OutputOrErr.takeError ();
957
961
// Output is a packaged object of device images. Unpackage the images and
@@ -978,11 +982,12 @@ Expected<SmallVector<StringRef>> linkAndWrapDeviceFiles(
978
982
}
979
983
980
984
// Exit early if no other offload kind found (other than OFK_SYCL).
981
- if ((ActiveOffloadKindMask ^ OFK_SYCL) == 0 ) {
985
+ if ((ActiveOffloadKindMask ^ OFK_SYCL) == 0 )
982
986
return Error::success ();
983
987
984
988
// Link the remaining device files using the device linker.
985
- auto OutputOrErr = linkDevice (InputFiles, LinkerArgs);
989
+ auto OutputOrErr =
990
+ linkDevice (InputFiles, LinkerArgs, ActiveOffloadKindMask);
986
991
if (!OutputOrErr)
987
992
return OutputOrErr.takeError ();
988
993
0 commit comments