This revision was automatically updated to reflect the committed changes. Closed by commit rL264965: [CUDA] Don't initialize the CUDA toolchain if we don't have any CUDA inputs. (authored by jlebar).
Changed prior to commit: http://reviews.llvm.org/D18629?vs=52146&id=52153#toc Repository: rL LLVM http://reviews.llvm.org/D18629 Files: cfe/trunk/lib/Driver/Driver.cpp Index: cfe/trunk/lib/Driver/Driver.cpp =================================================================== --- cfe/trunk/lib/Driver/Driver.cpp +++ cfe/trunk/lib/Driver/Driver.cpp @@ -507,17 +507,26 @@ // The compilation takes ownership of Args. Compilation *C = new Compilation(*this, TC, UArgs.release(), TranslatedArgs); - C->setCudaDeviceToolChain( - &getToolChain(C->getArgs(), llvm::Triple(TC.getTriple().isArch64Bit() - ? "nvptx64-nvidia-cuda" - : "nvptx-nvidia-cuda"))); if (!HandleImmediateArgs(*C)) return C; // Construct the list of inputs. InputList Inputs; BuildInputs(C->getDefaultToolChain(), *TranslatedArgs, Inputs); + // Initialize the CUDA device TC only if we have any CUDA Inputs. This is + // necessary so that we don't break compilations that pass flags that are + // incompatible with the NVPTX TC (e.g. -mthread-model single). + if (llvm::any_of(Inputs, [](const std::pair<types::ID, const Arg *> &I) { + return I.first == types::TY_CUDA || I.first == types::TY_PP_CUDA || + I.first == types::TY_CUDA_DEVICE; + })) { + C->setCudaDeviceToolChain( + &getToolChain(C->getArgs(), llvm::Triple(TC.getTriple().isArch64Bit() + ? "nvptx64-nvidia-cuda" + : "nvptx-nvidia-cuda"))); + } + // Construct the list of abstract actions to perform for this compilation. On // MachO targets this uses the driver-driver and universal actions. if (TC.getTriple().isOSBinFormatMachO())
Index: cfe/trunk/lib/Driver/Driver.cpp =================================================================== --- cfe/trunk/lib/Driver/Driver.cpp +++ cfe/trunk/lib/Driver/Driver.cpp @@ -507,17 +507,26 @@ // The compilation takes ownership of Args. Compilation *C = new Compilation(*this, TC, UArgs.release(), TranslatedArgs); - C->setCudaDeviceToolChain( - &getToolChain(C->getArgs(), llvm::Triple(TC.getTriple().isArch64Bit() - ? "nvptx64-nvidia-cuda" - : "nvptx-nvidia-cuda"))); if (!HandleImmediateArgs(*C)) return C; // Construct the list of inputs. InputList Inputs; BuildInputs(C->getDefaultToolChain(), *TranslatedArgs, Inputs); + // Initialize the CUDA device TC only if we have any CUDA Inputs. This is + // necessary so that we don't break compilations that pass flags that are + // incompatible with the NVPTX TC (e.g. -mthread-model single). + if (llvm::any_of(Inputs, [](const std::pair<types::ID, const Arg *> &I) { + return I.first == types::TY_CUDA || I.first == types::TY_PP_CUDA || + I.first == types::TY_CUDA_DEVICE; + })) { + C->setCudaDeviceToolChain( + &getToolChain(C->getArgs(), llvm::Triple(TC.getTriple().isArch64Bit() + ? "nvptx64-nvidia-cuda" + : "nvptx-nvidia-cuda"))); + } + // Construct the list of abstract actions to perform for this compilation. On // MachO targets this uses the driver-driver and universal actions. if (TC.getTriple().isOSBinFormatMachO())
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits