diff --git a/clang/lib/Driver/ToolChains/Cuda.h b/clang/lib/Driver/ToolChains/Cuda.h --- a/clang/lib/Driver/ToolChains/Cuda.h +++ b/clang/lib/Driver/ToolChains/Cuda.h @@ -126,8 +126,7 @@ void getNVPTXTargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, - std::vector &Features, - Optional Version = None); + std::vector &Features); } // end namespace NVPTX } // end namespace tools diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -636,23 +636,20 @@ void NVPTX::getNVPTXTargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, - std::vector &Features, - Optional Version) { + std::vector &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 @@ clang::CudaVersion CudaInstallationVersion = CudaInstallation.version(); - std::vector 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"});