diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -6977,7 +6977,9 @@ StringRef InputName = Clang::getBaseInputStem(Args, Inputs); CmdArgs.push_back(Args.MakeArgString( - "-fembed-offload-object=" + File + "," + TC->getTripleString() + "." + + "-fembed-offload-object=" + File + "," + + Action::GetOffloadKindName(Action::OFK_OpenMP) + "." + + TC->getTripleString() + "." + TCArgs.getLastArgValue(options::OPT_march_EQ) + "." + InputName)); } } @@ -8297,9 +8299,10 @@ TC->getTriple()); if (!BitcodeLibrary.empty()) - CmdArgs.push_back( - Args.MakeArgString("-target-library=" + TC->getTripleString() + - "-" + Arch + "=" + BitcodeLibrary.back())); + CmdArgs.push_back(Args.MakeArgString( + "-target-library=" + + Action::GetOffloadKindName(Action::OFK_OpenMP) + "-" + + TC->getTripleString() + "-" + Arch + "=" + BitcodeLibrary.back())); } // Pass in the optimization level to use for LTO. diff --git a/clang/test/Driver/openmp-offload-gpu.c b/clang/test/Driver/openmp-offload-gpu.c --- a/clang/test/Driver/openmp-offload-gpu.c +++ b/clang/test/Driver/openmp-offload-gpu.c @@ -345,4 +345,4 @@ // RUN: -fopenmp-new-driver -no-canonical-prefixes -nogpulib %s -o openmp-offload-gpu 2>&1 \ // RUN: | FileCheck -check-prefix=NEW_DRIVER_EMBEDDING %s -// NEW_DRIVER_EMBEDDING: -fembed-offload-object=[[CUBIN:.*\.cubin]],nvptx64-nvidia-cuda.sm_70 +// NEW_DRIVER_EMBEDDING: -fembed-offload-object=[[CUBIN:.*\.cubin]],openmp.nvptx64-nvidia-cuda.sm_70 diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -151,9 +151,11 @@ /// Information for a device offloading file extracted from the host. struct DeviceFile { - DeviceFile(StringRef TheTriple, StringRef Arch, StringRef Filename) - : TheTriple(TheTriple), Arch(Arch), Filename(Filename) {} + DeviceFile(StringRef Kind, StringRef TheTriple, StringRef Arch, + StringRef Filename) + : Kind(Kind), TheTriple(TheTriple), Arch(Arch), Filename(Filename) {} + std::string Kind; std::string TheTriple; std::string Arch; std::string Filename; @@ -164,11 +166,13 @@ template <> struct DenseMapInfo { static DeviceFile getEmptyKey() { return {DenseMapInfo::getEmptyKey(), + DenseMapInfo::getEmptyKey(), DenseMapInfo::getEmptyKey(), DenseMapInfo::getEmptyKey()}; } static DeviceFile getTombstoneKey() { return {DenseMapInfo::getTombstoneKey(), + DenseMapInfo::getTombstoneKey(), DenseMapInfo::getTombstoneKey(), DenseMapInfo::getTombstoneKey()}; } @@ -213,12 +217,13 @@ return sys::path::parent_path(COWPath).str(); } -/// Extract the device file from the string '-=.bc'. +/// Extract the device file from the string '--='. DeviceFile getBitcodeLibrary(StringRef LibraryStr) { auto DeviceAndPath = StringRef(LibraryStr).split('='); - auto TripleAndArch = DeviceAndPath.first.rsplit('-'); - return DeviceFile(TripleAndArch.first, TripleAndArch.second, - DeviceAndPath.second); + auto StringAndArch = DeviceAndPath.first.rsplit('-'); + auto KindAndTriple = StringAndArch.first.split('-'); + return DeviceFile(KindAndTriple.first, KindAndTriple.second, + StringAndArch.second, DeviceAndPath.second); } /// Get a temporary filename suitable for output. @@ -299,16 +304,17 @@ SmallVector SectionFields; Name->split(SectionFields, '.'); - StringRef DeviceTriple = SectionFields[3]; - StringRef Arch = SectionFields[4]; + StringRef Kind = SectionFields[3]; + StringRef DeviceTriple = SectionFields[4]; + StringRef Arch = SectionFields[5]; if (Expected Contents = Sec.getContents()) { SmallString<128> TempFile; StringRef DeviceExtension = getDeviceFileExtension( DeviceTriple, identify_magic(*Contents) == file_magic::bitcode); - if (Error Err = - createOutputFile(Prefix + "-device-" + DeviceTriple + "-" + Arch, - DeviceExtension, TempFile)) + if (Error Err = createOutputFile(Prefix + "-" + Kind + "-" + + DeviceTriple + "-" + Arch, + DeviceExtension, TempFile)) return std::move(Err); Expected> OutputOrErr = @@ -320,7 +326,7 @@ if (Error E = Output->commit()) return std::move(E); - DeviceFiles.emplace_back(DeviceTriple, Arch, TempFile); + DeviceFiles.emplace_back(Kind, DeviceTriple, Arch, TempFile); ToBeStripped.push_back(*Name); } } @@ -412,16 +418,17 @@ SmallVector SectionFields; GV.getSection().split(SectionFields, '.'); - StringRef DeviceTriple = SectionFields[3]; - StringRef Arch = SectionFields[4]; + StringRef Kind = SectionFields[3]; + StringRef DeviceTriple = SectionFields[4]; + StringRef Arch = SectionFields[5]; StringRef Contents = CDS->getAsString(); SmallString<128> TempFile; StringRef DeviceExtension = getDeviceFileExtension( DeviceTriple, identify_magic(Contents) == file_magic::bitcode); - if (Error Err = - createOutputFile(Prefix + "-device-" + DeviceTriple + "-" + Arch, - DeviceExtension, TempFile)) + if (Error Err = createOutputFile(Prefix + "-" + Kind + "-" + DeviceTriple + + "-" + Arch, + DeviceExtension, TempFile)) return std::move(Err); Expected> OutputOrErr = @@ -433,7 +440,7 @@ if (Error E = Output->commit()) return std::move(E); - DeviceFiles.emplace_back(DeviceTriple, Arch, TempFile); + DeviceFiles.emplace_back(Kind, DeviceTriple, Arch, TempFile); ToBeDeleted.push_back(&GV); }