[clang] 5d2c3e0 - Fix regression due to test hip-version.hip
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 11 09:48:55 PDT 2020
Author: Yaxun (Sam) Liu
Date: 2020-07-11T12:45:29-04:00
New Revision: 5d2c3e031a6861b3e95673d0e238c09938dd9c0d
URL: https://github.com/llvm/llvm-project/commit/5d2c3e031a6861b3e95673d0e238c09938dd9c0d
DIFF: https://github.com/llvm/llvm-project/commit/5d2c3e031a6861b3e95673d0e238c09938dd9c0d.diff
LOG: Fix regression due to test hip-version.hip
Added RocmInstallationDetector to Darwin and MinGW.
Fixed duplicate ROCm detector in ROCm toolchain.
Added:
Modified:
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/FreeBSD.h
clang/lib/Driver/ToolChains/HIP.cpp
clang/lib/Driver/ToolChains/MinGW.cpp
clang/lib/Driver/ToolChains/MinGW.h
clang/test/Driver/hip-version.hip
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index cfc71d7810b4..bc6d1fcd4a00 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -489,9 +489,9 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs,
/// ROCM Toolchain
ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
- : AMDGPUToolChain(D, Triple, Args),
- RocmInstallation(D, Triple, Args, /*DetectHIPRuntime=*/false,
- /*DetectDeviceLib=*/true) {}
+ : AMDGPUToolChain(D, Triple, Args) {
+ RocmInstallation.detectDeviceLibrary();
+}
void AMDGPUToolChain::addClangTargetOptions(
const llvm::opt::ArgList &DriverArgs,
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h
index 71c66188b045..5d44faf28b05 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.h
+++ b/clang/lib/Driver/ToolChains/AMDGPU.h
@@ -90,9 +90,6 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF {
};
class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain {
-protected:
- RocmInstallationDetector RocmInstallation;
-
public:
ROCMToolChain(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 6bf42e6029eb..2e1190c34ea7 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -779,7 +779,7 @@ MachO::MachO(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
/// Darwin - Darwin tool chain for i386 and x86_64.
Darwin::Darwin(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
: MachO(D, Triple, Args), TargetInitialized(false),
- CudaInstallation(D, Triple, Args) {}
+ CudaInstallation(D, Triple, Args), RocmInstallation(D, Triple, Args) {}
types::ID MachO::LookupTypeForExtension(StringRef Ext) const {
types::ID Ty = ToolChain::LookupTypeForExtension(Ext);
@@ -831,6 +831,11 @@ void Darwin::AddCudaIncludeArgs(const ArgList &DriverArgs,
CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
}
+void Darwin::AddHIPIncludeArgs(const ArgList &DriverArgs,
+ ArgStringList &CC1Args) const {
+ RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
+}
+
// This is just a MachO name translation routine and there's no
// way to join this into ARMTargetParser without breaking all
// other assumptions. Maybe MachO should consider standardising
@@ -2736,4 +2741,5 @@ SanitizerMask Darwin::getSupportedSanitizers() const {
void Darwin::printVerboseInfo(raw_ostream &OS) const {
CudaInstallation.print(OS);
+ RocmInstallation.print(OS);
}
diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h
index a543a8fc27b9..64c252efea7d 100644
--- a/clang/lib/Driver/ToolChains/Darwin.h
+++ b/clang/lib/Driver/ToolChains/Darwin.h
@@ -10,6 +10,7 @@
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_DARWIN_H
#include "Cuda.h"
+#include "ROCm.h"
#include "clang/Driver/DarwinSDKInfo.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
@@ -293,6 +294,7 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
mutable Optional<DarwinSDKInfo> SDKInfo;
CudaInstallationDetector CudaInstallation;
+ RocmInstallationDetector RocmInstallation;
private:
void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const;
@@ -475,6 +477,8 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
+ void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
bool UseObjCMixedDispatch() const override {
// This is only used with the non-fragile ABI and non-legacy dispatch.
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index 14cf278c19d9..909ac5e99212 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -425,6 +425,11 @@ void FreeBSD::AddCudaIncludeArgs(const ArgList &DriverArgs,
CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
}
+void FreeBSD::AddHIPIncludeArgs(const ArgList &DriverArgs,
+ ArgStringList &CC1Args) const {
+ RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
+}
+
Tool *FreeBSD::buildAssembler() const {
return new tools::freebsd::Assembler(*this);
}
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.h b/clang/lib/Driver/ToolChains/FreeBSD.h
index bca3f6b741b6..abc0876cef26 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.h
+++ b/clang/lib/Driver/ToolChains/FreeBSD.h
@@ -68,6 +68,8 @@ class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
llvm::opt::ArgStringList &CmdArgs) const override;
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
+ void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
llvm::ExceptionHandling
GetExceptionModel(const llvm::opt::ArgList &Args) const override;
diff --git a/clang/lib/Driver/ToolChains/HIP.cpp b/clang/lib/Driver/ToolChains/HIP.cpp
index 32734f5c1180..7d17f809690e 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -224,7 +224,6 @@ HIPToolChain::HIPToolChain(const Driver &D, const llvm::Triple &Triple,
// Lookup binaries into the driver directory, this is used to
// discover the clang-offload-bundler executable.
getProgramPaths().push_back(getDriver().Dir);
- RocmInstallation.detectHIPRuntime();
}
void HIPToolChain::addClangTargetOptions(
diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp
index b233e210d889..a1a1b413fb6c 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -398,7 +398,8 @@ llvm::ErrorOr<std::string> toolchains::MinGW::findClangRelativeSysroot() {
toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
- : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
+ : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args),
+ RocmInstallation(D, Triple, Args) {
getProgramPaths().push_back(getDriver().getInstalledDir());
if (getDriver().SysRoot.size())
@@ -500,8 +501,14 @@ void toolchains::MinGW::AddCudaIncludeArgs(const ArgList &DriverArgs,
CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
}
+void toolchains::MinGW::AddHIPIncludeArgs(const ArgList &DriverArgs,
+ ArgStringList &CC1Args) const {
+ RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
+}
+
void toolchains::MinGW::printVerboseInfo(raw_ostream &OS) const {
CudaInstallation.print(OS);
+ RocmInstallation.print(OS);
}
// Include directories for various hosts:
diff --git a/clang/lib/Driver/ToolChains/MinGW.h b/clang/lib/Driver/ToolChains/MinGW.h
index 46264a55cfc7..2f1559fcf34c 100644
--- a/clang/lib/Driver/ToolChains/MinGW.h
+++ b/clang/lib/Driver/ToolChains/MinGW.h
@@ -11,6 +11,7 @@
#include "Cuda.h"
#include "Gnu.h"
+#include "ROCm.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "llvm/Support/ErrorOr.h"
@@ -81,6 +82,8 @@ class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
+ void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
void printVerboseInfo(raw_ostream &OS) const override;
@@ -91,6 +94,7 @@ class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
private:
CudaInstallationDetector CudaInstallation;
+ RocmInstallationDetector RocmInstallation;
std::string Base;
std::string GccLibDir;
diff --git a/clang/test/Driver/hip-version.hip b/clang/test/Driver/hip-version.hip
index cf80ae15ac6d..eb1295210cfc 100644
--- a/clang/test/Driver/hip-version.hip
+++ b/clang/test/Driver/hip-version.hip
@@ -5,6 +5,10 @@
// RUN: %clang -v --rocm-path=%S/Inputs/rocm 2>&1 \
// RUN: | FileCheck -check-prefixes=FOUND %s
+// RUN: %clang -v --rocm-path=%S/Inputs/rocm 2>&1 \
+// RUN: -target amdgcn-amd-amdhsa \
+// RUN: | FileCheck -check-prefixes=FOUND %s
+
// FOUND: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd
// When --rocm-path is set and .hipVersion is not found, use default version
@@ -12,11 +16,19 @@
// RUN: %clang -v --rocm-path=%S 2>&1 \
// RUN: | FileCheck -check-prefixes=DEFAULT %s
+// RUN: %clang -v --rocm-path=%S 2>&1 \
+// RUN: -target amdgcn-amd-amdhsa \
+// RUN: | FileCheck -check-prefixes=DEFAULT %s
+
// DEFAULT: Found HIP installation: {{.*Driver}}, version 3.5.
// RUN: %clang -v --rocm-path=%S --hip-version=3.7.0 2>&1 \
// RUN: | FileCheck -check-prefixes=SPECIFIED %s
+// RUN: %clang -v --rocm-path=%S --hip-version=3.7.0 2>&1 \
+// RUN: -target amdgcn-amd-amdhsa \
+// RUN: | FileCheck -check-prefixes=SPECIFIED %s
+
// SPECIFIED: Found HIP installation: {{.*Driver}}, version 3.7.0
// RUN: %clang -v --rocm-path=%S --hip-version=3.7 2>&1 \
More information about the cfe-commits
mailing list