Author: Joseph Huber Date: 2022-06-29T09:34:09-04:00 New Revision: 56ab966a04dd22570fcb18276e2409c94e82c571
URL: https://github.com/llvm/llvm-project/commit/56ab966a04dd22570fcb18276e2409c94e82c571 DIFF: https://github.com/llvm/llvm-project/commit/56ab966a04dd22570fcb18276e2409c94e82c571.diff LOG: [CUDA] Stop adding CUDA features twice We currently call the `addNVPTXFeatures` function in two places, inside of the CUDA Toolchain and inside of Clang in the standard entry point. We normally add features to the job in Clang, so the call inside of the CUDA toolchain is redundant and results in `+ptx` features being added. Since we remove this call, we no longer will have a cached CUDA installation so we will usually create it twice. Reviewed By: tra Differential Revision: https://reviews.llvm.org/D128752 Added: Modified: clang/lib/Driver/ToolChains/Cuda.cpp clang/lib/Driver/ToolChains/Cuda.h Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index 0e87540d1615d..5e59677947e62 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -636,23 +636,20 @@ void NVPTX::OpenMPLinker::ConstructJob(Compilation &C, const JobAction &JA, void NVPTX::getNVPTXTargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, - std::vector<StringRef> &Features, - Optional<clang::CudaVersion> Version) { + std::vector<StringRef> &Features) { if (Args.hasArg(options::OPT_cuda_feature_EQ)) { StringRef PtxFeature = Args.getLastArgValue(options::OPT_cuda_feature_EQ, "+ptx42"); Features.push_back(Args.MakeArgString(PtxFeature)); return; - } else if (!Version) { - CudaInstallationDetector CudaInstallation(D, Triple, Args); - Version = CudaInstallation.version(); } + CudaInstallationDetector CudaInstallation(D, Triple, Args); // New CUDA versions often introduce new instructions that are only supported // by new PTX version, so we need to raise PTX level to enable them in NVPTX // back-end. const char *PtxFeature = nullptr; - switch (*Version) { + switch (CudaInstallation.version()) { #define CASE_CUDA_VERSION(CUDA_VER, PTX_VER) \ case CudaVersion::CUDA_##CUDA_VER: \ PtxFeature = "+ptx" #PTX_VER; \ @@ -746,11 +743,6 @@ void CudaToolChain::addClangTargetOptions( clang::CudaVersion CudaInstallationVersion = CudaInstallation.version(); - std::vector<StringRef> Features; - NVPTX::getNVPTXTargetFeatures(getDriver(), getTriple(), DriverArgs, Features, - CudaInstallationVersion); - for (StringRef PtxFeature : Features) - CC1Args.append({"-target-feature", DriverArgs.MakeArgString(PtxFeature)}); if (DriverArgs.hasFlag(options::OPT_fcuda_short_ptr, options::OPT_fno_cuda_short_ptr, false)) CC1Args.append({"-mllvm", "--nvptx-short-ptr"}); diff --git a/clang/lib/Driver/ToolChains/Cuda.h b/clang/lib/Driver/ToolChains/Cuda.h index f2517a9b38d1e..809a25227ac49 100644 --- a/clang/lib/Driver/ToolChains/Cuda.h +++ b/clang/lib/Driver/ToolChains/Cuda.h @@ -126,8 +126,7 @@ class LLVM_LIBRARY_VISIBILITY OpenMPLinker : public Tool { void getNVPTXTargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, - std::vector<StringRef> &Features, - Optional<clang::CudaVersion> Version = None); + std::vector<StringRef> &Features); } // end namespace NVPTX } // end namespace tools _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits