[PATCH] D120288: [OpenMP] Implement dense map info for device file
Joseph Huber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 14 17:09:15 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG06b336c4cd2c: [OpenMP] Implement dense map info for device file (authored by jhuber6).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120288/new/
https://reviews.llvm.org/D120288
Files:
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===================================================================
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -154,12 +154,33 @@
DeviceFile(StringRef TheTriple, StringRef Arch, StringRef Filename)
: TheTriple(TheTriple), Arch(Arch), Filename(Filename) {}
- const std::string TheTriple;
- const std::string Arch;
- const std::string Filename;
+ std::string TheTriple;
+ std::string Arch;
+ std::string Filename;
+};
- operator std::string() const { return TheTriple + "-" + Arch; }
+namespace llvm {
+/// Helper that allows DeviceFile to be used as a key in a DenseMap.
+template <> struct DenseMapInfo<DeviceFile> {
+ static DeviceFile getEmptyKey() {
+ return {DenseMapInfo<StringRef>::getEmptyKey(),
+ DenseMapInfo<StringRef>::getEmptyKey(),
+ DenseMapInfo<StringRef>::getEmptyKey()};
+ }
+ static DeviceFile getTombstoneKey() {
+ return {DenseMapInfo<StringRef>::getTombstoneKey(),
+ DenseMapInfo<StringRef>::getTombstoneKey(),
+ DenseMapInfo<StringRef>::getTombstoneKey()};
+ }
+ static unsigned getHashValue(const DeviceFile &I) {
+ return DenseMapInfo<StringRef>::getHashValue(I.TheTriple) ^
+ DenseMapInfo<StringRef>::getHashValue(I.Arch);
+ }
+ static bool isEqual(const DeviceFile &LHS, const DeviceFile &RHS) {
+ return LHS.TheTriple == RHS.TheTriple && LHS.Arch == RHS.Arch;
+ }
};
+} // namespace llvm
namespace {
@@ -1063,28 +1084,28 @@
Error linkDeviceFiles(ArrayRef<DeviceFile> DeviceFiles,
SmallVectorImpl<std::string> &LinkedImages) {
// Get the list of inputs for a specific device.
- StringMap<SmallVector<std::string, 4>> LinkerInputMap;
+ DenseMap<DeviceFile, SmallVector<std::string, 4>> LinkerInputMap;
for (auto &File : DeviceFiles)
- LinkerInputMap[StringRef(File)].push_back(File.Filename);
+ LinkerInputMap[File].push_back(File.Filename);
// Try to link each device toolchain.
for (auto &LinkerInput : LinkerInputMap) {
- auto TargetFeatures = LinkerInput.getKey().rsplit('-');
- Triple TheTriple(TargetFeatures.first);
- StringRef Arch(TargetFeatures.second);
+ DeviceFile &File = LinkerInput.getFirst();
+ Triple TheTriple = Triple(File.TheTriple);
// Run LTO on any bitcode files and replace the input with the result.
- if (Error Err = linkBitcodeFiles(LinkerInput.getValue(), TheTriple, Arch))
+ if (Error Err =
+ linkBitcodeFiles(LinkerInput.getSecond(), TheTriple, File.Arch))
return Err;
// If we are embedding bitcode for JIT, skip the final device linking.
if (EmbedBitcode) {
- assert(!LinkerInput.getValue().empty() && "No bitcode image to embed");
- LinkedImages.push_back(LinkerInput.getValue().front());
+ assert(!LinkerInput.getSecond().empty() && "No bitcode image to embed");
+ LinkedImages.push_back(LinkerInput.getSecond().front());
continue;
}
- auto ImageOrErr = linkDevice(LinkerInput.getValue(), TheTriple, Arch);
+ auto ImageOrErr = linkDevice(LinkerInput.getSecond(), TheTriple, File.Arch);
if (!ImageOrErr)
return ImageOrErr.takeError();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120288.415277.patch
Type: text/x-patch
Size: 3295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220315/bde9263b/attachment-0001.bin>
More information about the cfe-commits
mailing list