Skip to content

Commit b5ee4f7

Browse files
committed
Revert "Lazyly initialize uncommon toolchain detector"
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.
1 parent ed8e858 commit b5ee4f7

File tree

8 files changed

+26
-72
lines changed

8 files changed

+26
-72
lines changed

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs,
701701
ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple,
702702
const ArgList &Args)
703703
: AMDGPUToolChain(D, Triple, Args) {
704-
RocmInstallation->detectDeviceLibrary();
704+
RocmInstallation.detectDeviceLibrary();
705705
}
706706

707707
void AMDGPUToolChain::addClangTargetOptions(
@@ -790,11 +790,11 @@ void ROCMToolChain::addClangTargetOptions(
790790
const StringRef GpuArch = getGPUArch(DriverArgs);
791791
auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
792792
const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);
793-
StringRef LibDeviceFile = RocmInstallation->getLibDeviceFile(CanonArch);
793+
StringRef LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
794794
auto ABIVer = DeviceLibABIVersion::fromCodeObjectVersion(
795795
getAMDGPUCodeObjectVersion(getDriver(), DriverArgs));
796-
if (!RocmInstallation->checkCommonBitcodeLibs(CanonArch, LibDeviceFile,
797-
ABIVer))
796+
if (!RocmInstallation.checkCommonBitcodeLibs(CanonArch, LibDeviceFile,
797+
ABIVer))
798798
return;
799799

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

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

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

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

878-
StringRef LibDeviceFile = RocmInstallation->getLibDeviceFile(CanonArch);
878+
StringRef LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
879879
auto ABIVer = DeviceLibABIVersion::fromCodeObjectVersion(
880880
getAMDGPUCodeObjectVersion(getDriver(), DriverArgs));
881-
if (!RocmInstallation->checkCommonBitcodeLibs(CanonArch, LibDeviceFile,
882-
ABIVer))
881+
if (!RocmInstallation.checkCommonBitcodeLibs(CanonArch, LibDeviceFile,
882+
ABIVer))
883883
return {};
884884

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

903-
return RocmInstallation->getCommonBitcodeLibs(
903+
return RocmInstallation.getCommonBitcodeLibs(
904904
DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
905905
FastRelaxedMath, CorrectSqrt, ABIVer, isOpenMP);
906906
}

clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ AMDGPUOpenMPToolChain::getDeviceLibs(const llvm::opt::ArgList &Args) const {
160160
if (Args.hasArg(options::OPT_nogpulib))
161161
return {};
162162

163-
if (!RocmInstallation->hasDeviceLibrary()) {
163+
if (!RocmInstallation.hasDeviceLibrary()) {
164164
getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 0;
165165
return {};
166166
}

clang/lib/Driver/ToolChains/FreeBSD.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,12 @@ void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
477477

478478
void FreeBSD::AddCudaIncludeArgs(const ArgList &DriverArgs,
479479
ArgStringList &CC1Args) const {
480-
CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
480+
CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
481481
}
482482

483483
void FreeBSD::AddHIPIncludeArgs(const ArgList &DriverArgs,
484484
ArgStringList &CC1Args) const {
485-
RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
485+
RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
486486
}
487487

488488
Tool *FreeBSD::buildAssembler() const {

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,8 +2849,8 @@ Tool *Generic_GCC::buildLinker() const { return new tools::gcc::Linker(*this); }
28492849
void Generic_GCC::printVerboseInfo(raw_ostream &OS) const {
28502850
// Print the information about how we detected the GCC installation.
28512851
GCCInstallation.print(OS);
2852-
CudaInstallation->print(OS);
2853-
RocmInstallation->print(OS);
2852+
CudaInstallation.print(OS);
2853+
RocmInstallation.print(OS);
28542854
}
28552855

28562856
ToolChain::UnwindTableLevel

clang/lib/Driver/ToolChains/Gnu.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GNU_H
1111

1212
#include "Cuda.h"
13-
#include "LazyDetector.h"
1413
#include "ROCm.h"
1514
#include "clang/Driver/Tool.h"
1615
#include "clang/Driver/ToolChain.h"
@@ -287,8 +286,8 @@ class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {
287286

288287
protected:
289288
GCCInstallationDetector GCCInstallation;
290-
LazyDetector<CudaInstallationDetector> CudaInstallation;
291-
LazyDetector<RocmInstallationDetector> RocmInstallation;
289+
CudaInstallationDetector CudaInstallation;
290+
RocmInstallationDetector RocmInstallation;
292291

293292
public:
294293
Generic_GCC(const Driver &D, const llvm::Triple &Triple,

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void HIPAMDToolChain::AddIAMCUIncludeArgs(const ArgList &Args,
314314

315315
void HIPAMDToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
316316
ArgStringList &CC1Args) const {
317-
RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
317+
RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
318318
}
319319

320320
SanitizerMask HIPAMDToolChain::getSupportedSanitizers() const {
@@ -343,7 +343,7 @@ HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
343343
ArgStringList LibraryPaths;
344344

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

349349
addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
@@ -365,7 +365,7 @@ HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
365365
getDriver().Diag(diag::err_drv_no_such_file) << BCName;
366366
});
367367
} else {
368-
if (!RocmInstallation->hasDeviceLibrary()) {
368+
if (!RocmInstallation.hasDeviceLibrary()) {
369369
getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 0;
370370
return {};
371371
}
@@ -376,7 +376,7 @@ HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
376376
if (DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
377377
options::OPT_fno_gpu_sanitize, true) &&
378378
getSanitizerArgs(DriverArgs).needsAsanRt()) {
379-
auto AsanRTL = RocmInstallation->getAsanRTLPath();
379+
auto AsanRTL = RocmInstallation.getAsanRTLPath();
380380
if (AsanRTL.empty()) {
381381
unsigned DiagID = getDriver().getDiags().getCustomDiagID(
382382
DiagnosticsEngine::Error,
@@ -390,7 +390,7 @@ HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
390390
}
391391

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

395395
// Add common device libraries like ocml etc.
396396
for (StringRef N : getCommonDeviceLibNames(DriverArgs, GpuArch.str()))

clang/lib/Driver/ToolChains/LazyDetector.h

Lines changed: 0 additions & 45 deletions
This file was deleted.

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,23 +681,23 @@ void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
681681

682682
void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
683683
ArgStringList &CC1Args) const {
684-
CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
684+
CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
685685
}
686686

687687
void Linux::AddHIPIncludeArgs(const ArgList &DriverArgs,
688688
ArgStringList &CC1Args) const {
689-
RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
689+
RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
690690
}
691691

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

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

702702
CmdArgs.push_back("-lamdhip64");
703703
}

0 commit comments

Comments
 (0)