[Clang][OpenMP][NVPTX] Fixed failure in openmp-offload-gpu.c if the system has CUDA

https://lists.llvm.org/pipermail/openmp-dev/2021-March/003940.html reports
test failure in `openmp-offload-gpu.c`. The failure is, when using `-S` in the
clang driver, it still reports bitcode library doesn't exist. However, it is not
exposed in my local run and Phabiractor test. The reason it escaped from Phabricator
test is, the test machine doesn't have CUDA, so `LibDeviceFile` is empty. In this
case, the check of `OPT_S` will be hit, and we get "expected" result. However, if
the test machine has CUDA, `LibDeviceFile` will not be empty, then the check will
not be done, and it just proceeds, trying to add the bitcode library. The reason
it escaped from my local run is, I didn't build ALL targets, so this case was
marked UNSUPPORTED.

Reviewed By: kkwli0

Differential Revision: https://reviews.llvm.org/D98902
This commit is contained in:
Shilei Tian 2021-04-13 13:22:24 -04:00
parent f1812a284f
commit 53d474abc9
1 changed files with 4 additions and 5 deletions

View File

@ -696,13 +696,12 @@ void CudaToolChain::addClangTargetOptions(
if (DriverArgs.hasArg(options::OPT_nogpulib))
return;
if (DeviceOffloadingKind == Action::OFK_OpenMP &&
DriverArgs.hasArg(options::OPT_S))
return;
std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
if (LibDeviceFile.empty()) {
if (DeviceOffloadingKind == Action::OFK_OpenMP &&
DriverArgs.hasArg(options::OPT_S))
return;
getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
return;
}