Skip to content

Commit

Permalink
Revert "Lazyly initialize uncommon toolchain detector"
Browse files Browse the repository at this point in the history
clang/test/Driver/rocm-detect.hip is failing for a number of
configurations, for example:

clang-x86_64-debian-fast
https://lab.llvm.org/buildbot/#/builders/109/builds/57270

clang-debian-cpp20
https://lab.llvm.org/buildbot/#/builders/249/builds/310

clang-with-lto-ubuntu
https://lab.llvm.org/buildbot/#/builders/124/builds/6693

This reverts commit 6fa2abf.
  • Loading branch information
hahnjo committed Feb 6, 2023
1 parent ed8e858 commit b5ee4f7
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 72 deletions.
20 changes: 10 additions & 10 deletions clang/lib/Driver/ToolChains/AMDGPU.cpp
Expand Up @@ -701,7 +701,7 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs,
ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
: AMDGPUToolChain(D, Triple, Args) {
RocmInstallation->detectDeviceLibrary();
RocmInstallation.detectDeviceLibrary();
}

void AMDGPUToolChain::addClangTargetOptions(
Expand Down Expand Up @@ -790,11 +790,11 @@ void ROCMToolChain::addClangTargetOptions(
const StringRef GpuArch = getGPUArch(DriverArgs);
auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);
StringRef LibDeviceFile = RocmInstallation->getLibDeviceFile(CanonArch);
StringRef LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
auto ABIVer = DeviceLibABIVersion::fromCodeObjectVersion(
getAMDGPUCodeObjectVersion(getDriver(), DriverArgs));
if (!RocmInstallation->checkCommonBitcodeLibs(CanonArch, LibDeviceFile,
ABIVer))
if (!RocmInstallation.checkCommonBitcodeLibs(CanonArch, LibDeviceFile,
ABIVer))
return;

bool Wave64 = isWave64(DriverArgs, Kind);
Expand All @@ -813,10 +813,10 @@ void ROCMToolChain::addClangTargetOptions(

// Add the OpenCL specific bitcode library.
llvm::SmallVector<std::string, 12> BCLibs;
BCLibs.push_back(RocmInstallation->getOpenCLPath().str());
BCLibs.push_back(RocmInstallation.getOpenCLPath().str());

// Add the generic set of libraries.
BCLibs.append(RocmInstallation->getCommonBitcodeLibs(
BCLibs.append(RocmInstallation.getCommonBitcodeLibs(
DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
FastRelaxedMath, CorrectSqrt, ABIVer, false));

Expand Down Expand Up @@ -875,11 +875,11 @@ ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
auto Kind = llvm::AMDGPU::parseArchAMDGCN(GPUArch);
const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);

StringRef LibDeviceFile = RocmInstallation->getLibDeviceFile(CanonArch);
StringRef LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
auto ABIVer = DeviceLibABIVersion::fromCodeObjectVersion(
getAMDGPUCodeObjectVersion(getDriver(), DriverArgs));
if (!RocmInstallation->checkCommonBitcodeLibs(CanonArch, LibDeviceFile,
ABIVer))
if (!RocmInstallation.checkCommonBitcodeLibs(CanonArch, LibDeviceFile,
ABIVer))
return {};

// If --hip-device-lib is not set, add the default bitcode libraries.
Expand All @@ -900,7 +900,7 @@ ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt, true);
bool Wave64 = isWave64(DriverArgs, Kind);

return RocmInstallation->getCommonBitcodeLibs(
return RocmInstallation.getCommonBitcodeLibs(
DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
FastRelaxedMath, CorrectSqrt, ABIVer, isOpenMP);
}
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
Expand Up @@ -160,7 +160,7 @@ AMDGPUOpenMPToolChain::getDeviceLibs(const llvm::opt::ArgList &Args) const {
if (Args.hasArg(options::OPT_nogpulib))
return {};

if (!RocmInstallation->hasDeviceLibrary()) {
if (!RocmInstallation.hasDeviceLibrary()) {
getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 0;
return {};
}
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Driver/ToolChains/FreeBSD.cpp
Expand Up @@ -477,12 +477,12 @@ void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,

void FreeBSD::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
}

void FreeBSD::AddHIPIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
}

Tool *FreeBSD::buildAssembler() const {
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Driver/ToolChains/Gnu.cpp
Expand Up @@ -2849,8 +2849,8 @@ Tool *Generic_GCC::buildLinker() const { return new tools::gcc::Linker(*this); }
void Generic_GCC::printVerboseInfo(raw_ostream &OS) const {
// Print the information about how we detected the GCC installation.
GCCInstallation.print(OS);
CudaInstallation->print(OS);
RocmInstallation->print(OS);
CudaInstallation.print(OS);
RocmInstallation.print(OS);
}

ToolChain::UnwindTableLevel
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Driver/ToolChains/Gnu.h
Expand Up @@ -10,7 +10,6 @@
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GNU_H

#include "Cuda.h"
#include "LazyDetector.h"
#include "ROCm.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
Expand Down Expand Up @@ -287,8 +286,8 @@ class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {

protected:
GCCInstallationDetector GCCInstallation;
LazyDetector<CudaInstallationDetector> CudaInstallation;
LazyDetector<RocmInstallationDetector> RocmInstallation;
CudaInstallationDetector CudaInstallation;
RocmInstallationDetector RocmInstallation;

public:
Generic_GCC(const Driver &D, const llvm::Triple &Triple,
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/Driver/ToolChains/HIPAMD.cpp
Expand Up @@ -314,7 +314,7 @@ void HIPAMDToolChain::AddIAMCUIncludeArgs(const ArgList &Args,

void HIPAMDToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
}

SanitizerMask HIPAMDToolChain::getSupportedSanitizers() const {
Expand Down Expand Up @@ -343,7 +343,7 @@ HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
ArgStringList LibraryPaths;

// Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
for (StringRef Path : RocmInstallation->getRocmDeviceLibPathArg())
for (StringRef Path : RocmInstallation.getRocmDeviceLibPathArg())
LibraryPaths.push_back(DriverArgs.MakeArgString(Path));

addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
Expand All @@ -365,7 +365,7 @@ HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
getDriver().Diag(diag::err_drv_no_such_file) << BCName;
});
} else {
if (!RocmInstallation->hasDeviceLibrary()) {
if (!RocmInstallation.hasDeviceLibrary()) {
getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 0;
return {};
}
Expand All @@ -376,7 +376,7 @@ HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
if (DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
options::OPT_fno_gpu_sanitize, true) &&
getSanitizerArgs(DriverArgs).needsAsanRt()) {
auto AsanRTL = RocmInstallation->getAsanRTLPath();
auto AsanRTL = RocmInstallation.getAsanRTLPath();
if (AsanRTL.empty()) {
unsigned DiagID = getDriver().getDiags().getCustomDiagID(
DiagnosticsEngine::Error,
Expand All @@ -390,7 +390,7 @@ HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
}

// Add the HIP specific bitcode library.
BCLibs.push_back(RocmInstallation->getHIPPath());
BCLibs.push_back(RocmInstallation.getHIPPath());

// Add common device libraries like ocml etc.
for (StringRef N : getCommonDeviceLibNames(DriverArgs, GpuArch.str()))
Expand Down
45 changes: 0 additions & 45 deletions clang/lib/Driver/ToolChains/LazyDetector.h

This file was deleted.

8 changes: 4 additions & 4 deletions clang/lib/Driver/ToolChains/Linux.cpp
Expand Up @@ -681,23 +681,23 @@ void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,

void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
}

void Linux::AddHIPIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
}

void Linux::AddHIPRuntimeLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
CmdArgs.push_back(
Args.MakeArgString(StringRef("-L") + RocmInstallation->getLibPath()));
Args.MakeArgString(StringRef("-L") + RocmInstallation.getLibPath()));

if (Args.hasFlag(options::OPT_offload_add_rpath,
options::OPT_no_offload_add_rpath, false))
CmdArgs.append(
{"-rpath", Args.MakeArgString(RocmInstallation->getLibPath())});
{"-rpath", Args.MakeArgString(RocmInstallation.getLibPath())});

CmdArgs.push_back("-lamdhip64");
}
Expand Down

0 comments on commit b5ee4f7

Please sign in to comment.