Author: Aaron En Ye Shi Date: 2021-06-11T16:25:03Z New Revision: f2cc0427b13ef10e67eed6eab9eefb58e8aef3d9
URL: https://github.com/llvm/llvm-project/commit/f2cc0427b13ef10e67eed6eab9eefb58e8aef3d9 DIFF: https://github.com/llvm/llvm-project/commit/f2cc0427b13ef10e67eed6eab9eefb58e8aef3d9.diff LOG: [HIP] Fix --hip-version flag with 0 as component Allow the usage of minor version 0, for hip versions such as 4.0. Change the default values when performing version checks. Reviewed By: yaxunl Differential Revision: https://reviews.llvm.org/D104062 Added: Modified: clang/lib/Driver/ToolChains/AMDGPU.cpp clang/test/Driver/hip-version.hip Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index ea3a4b4a8fd1..2e92be51f69e 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -316,8 +316,8 @@ RocmInstallationDetector::RocmInstallationDetector( HIPPathArg = Args.getLastArgValue(clang::driver::options::OPT_hip_path_EQ); if (auto *A = Args.getLastArg(clang::driver::options::OPT_hip_version_EQ)) { HIPVersionArg = A->getValue(); - unsigned Major = 0; - unsigned Minor = 0; + unsigned Major = ~0U; + unsigned Minor = ~0U; SmallVector<StringRef, 3> Parts; HIPVersionArg.split(Parts, '.'); if (Parts.size()) @@ -328,7 +328,9 @@ RocmInstallationDetector::RocmInstallationDetector( VersionPatch = Parts[2].str(); if (VersionPatch.empty()) VersionPatch = "0"; - if (Major == 0 || Minor == 0) + if (Major != ~0U && Minor == ~0U) + Minor = 0; + if (Major == ~0U || Minor == ~0U) D.Diag(diag::err_drv_invalid_value) << A->getAsString(Args) << HIPVersionArg; diff --git a/clang/test/Driver/hip-version.hip b/clang/test/Driver/hip-version.hip index eb1295210cfc..83b8dbddf228 100644 --- a/clang/test/Driver/hip-version.hip +++ b/clang/test/Driver/hip-version.hip @@ -36,6 +36,16 @@ // SPECIFIED2: Found HIP installation: {{.*Driver}}, version 3.7.0 +// RUN: %clang -v --rocm-path=%S --hip-version=4.0.21025 2>&1 \ +// RUN: | FileCheck -check-prefixes=SPECIFIED3 %s + +// SPECIFIED3: Found HIP installation: {{.*Driver}}, version 4.0.21025 + +// RUN: %clang -v --rocm-path=%S --hip-version=4 2>&1 \ +// RUN: | FileCheck -check-prefixes=SPECIFIED4 %s + +// SPECIFIED4: Found HIP installation: {{.*Driver}}, version 4.0.0 + // RUN: not %clang -v --rocm-path=%S --hip-version=x.y 2>&1 \ // RUN: | FileCheck -check-prefixes=INVALID %s _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits