From f3f1ce4fa9f49c9d862fcc873eed92fee02b0685 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 20 Jul 2020 16:50:00 +0200 Subject: [PATCH] [Driver] Promote SmallSet of enum to a bitset. NFCI. --- clang/lib/Driver/ToolChains/Cuda.cpp | 4 ++-- clang/lib/Driver/ToolChains/Cuda.h | 4 ++-- clang/lib/Driver/ToolChains/ROCm.h | 11 ----------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index 110a0bca9bc1..d7933534a5d3 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -259,13 +259,13 @@ void CudaInstallationDetector::AddCudaIncludeArgs( void CudaInstallationDetector::CheckCudaVersionSupportsArch( CudaArch Arch) const { if (Arch == CudaArch::UNKNOWN || Version == CudaVersion::UNKNOWN || - ArchsWithBadVersion.count(Arch) > 0) + ArchsWithBadVersion[(int)Arch]) return; auto MinVersion = MinVersionForCudaArch(Arch); auto MaxVersion = MaxVersionForCudaArch(Arch); if (Version < MinVersion || Version > MaxVersion) { - ArchsWithBadVersion.insert(Arch); + ArchsWithBadVersion[(int)Arch] = true; D.Diag(diag::err_drv_cuda_version_unsupported) << CudaArchToString(Arch) << CudaVersionToString(MinVersion) << CudaVersionToString(MaxVersion) << InstallPath diff --git a/clang/lib/Driver/ToolChains/Cuda.h b/clang/lib/Driver/ToolChains/Cuda.h index 873eb7338a30..6afc29f7acee 100644 --- a/clang/lib/Driver/ToolChains/Cuda.h +++ b/clang/lib/Driver/ToolChains/Cuda.h @@ -15,9 +15,9 @@ #include "clang/Driver/Tool.h" #include "clang/Driver/ToolChain.h" #include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallSet.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/VersionTuple.h" +#include #include #include @@ -41,7 +41,7 @@ private: // CUDA architectures for which we have raised an error in // CheckCudaVersionSupportsArch. - mutable llvm::SmallSet ArchsWithBadVersion; + mutable std::bitset<(int)CudaArch::LAST> ArchsWithBadVersion; public: CudaInstallationDetector(const Driver &D, const llvm::Triple &HostTriple, diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h index 962c72fedfe0..27c7d8b0ee54 100644 --- a/clang/lib/Driver/ToolChains/ROCm.h +++ b/clang/lib/Driver/ToolChains/ROCm.h @@ -13,7 +13,6 @@ #include "clang/Basic/LLVM.h" #include "clang/Driver/Driver.h" #include "clang/Driver/Options.h" -#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/Triple.h" @@ -103,10 +102,6 @@ private: CorrectlyRoundedSqrt.isValid(); } - // GPU architectures for which we have raised an error in - // CheckRocmVersionSupportsArch. - mutable llvm::SmallSet ArchsWithBadVersion; - void scanLibDevicePath(llvm::StringRef Path); void ParseHIPVersionFile(llvm::StringRef V); SmallVector getInstallationPathCandidates(); @@ -124,12 +119,6 @@ public: bool DAZ, bool FiniteOnly, bool UnsafeMathOpt, bool FastRelaxedMath, bool CorrectSqrt) const; - /// Emit an error if Version does not support the given Arch. - /// - /// If either Version or Arch is unknown, does not emit an error. Emits at - /// most one error per Arch. - void CheckRocmVersionSupportsArch(CudaArch Arch) const; - /// Check whether we detected a valid HIP runtime. bool hasHIPRuntime() const { return HasHIPRuntime; }