[PATCH] D104062: [HIP] Fix --hip-version flag with 0 as component

Aaron Enye Shi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 11 09:25:49 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf2cc0427b13e: [HIP] Fix --hip-version flag with 0 as component (authored by ashi1).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104062/new/

https://reviews.llvm.org/D104062

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/hip-version.hip


Index: clang/test/Driver/hip-version.hip
===================================================================
--- clang/test/Driver/hip-version.hip
+++ 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
 
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -316,8 +316,8 @@
   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 @@
       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;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104062.351473.patch
Type: text/x-patch
Size: 1730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210611/d787f5cd/attachment-0001.bin>


More information about the cfe-commits mailing list