[clang] 5a3023a - [HIP] Return non-zero value for invalid target ID
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 28 20:17:15 PDT 2020
Author: Yaxun (Sam) Liu
Date: 2020-09-28T23:07:39-04:00
New Revision: 5a3023a91c0ec82e7272569c5ca7a6eb372b129f
URL: https://github.com/llvm/llvm-project/commit/5a3023a91c0ec82e7272569c5ca7a6eb372b129f
DIFF: https://github.com/llvm/llvm-project/commit/5a3023a91c0ec82e7272569c5ca7a6eb372b129f.diff
LOG: [HIP] Return non-zero value for invalid target ID
This is part of https://reviews.llvm.org/D60620
Added:
Modified:
clang/lib/Driver/Driver.cpp
clang/test/Driver/hip-invalid-target-id.hip
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 69336f6f94b66..9cc4b8212981b 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2790,6 +2790,7 @@ class OffloadingActionBuilder final {
parseTargetID(getHIPOffloadTargetTriple(), IdStr, &Features);
if (!ArchStr) {
C.getDriver().Diag(clang::diag::err_drv_bad_target_id) << IdStr;
+ C.setContainsError();
return StringRef();
}
auto CanId = getCanonicalTargetID(ArchStr.getValue(), Features);
diff --git a/clang/test/Driver/hip-invalid-target-id.hip b/clang/test/Driver/hip-invalid-target-id.hip
index aad29c555b581..cbd6f59b08543 100644
--- a/clang/test/Driver/hip-invalid-target-id.hip
+++ b/clang/test/Driver/hip-invalid-target-id.hip
@@ -2,7 +2,7 @@
// REQUIRES: x86-registered-target
// REQUIRES: amdgpu-registered-target
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
// RUN: -x hip --offload-arch=gfx908 \
// RUN: --offload-arch=gfx908xnack \
// RUN: --rocm-path=%S/Inputs/rocm \
@@ -10,7 +10,7 @@
// NOPLUS: error: Invalid target ID: gfx908xnack
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
// RUN: -x hip --offload-arch=gfx900 \
// RUN: --offload-arch=gfx908:xnack+:xnack+ \
// RUN: --rocm-path=%S/Inputs/rocm \
@@ -18,7 +18,7 @@
// ORDER: error: Invalid target ID: gfx908:xnack+:xnack+
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
// RUN: -x hip --offload-arch=gfx908 \
// RUN: --offload-arch=gfx908:unknown+ \
// RUN: --offload-arch=gfx908+sram-ecc+unknown \
@@ -28,7 +28,7 @@
// UNK: error: Invalid target ID: gfx908:unknown+
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
// RUN: -x hip --offload-arch=gfx908 \
// RUN: --offload-arch=gfx908:sram-ecc+:unknown+ \
// RUN: --offload-arch=gfx900+xnack \
@@ -37,7 +37,7 @@
// MIXED: error: Invalid target ID: gfx908:sram-ecc+:unknown+
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
// RUN: -x hip --offload-arch=gfx908 \
// RUN: --offload-arch=gfx900:sram-ecc+ \
// RUN: --rocm-path=%S/Inputs/rocm \
@@ -45,7 +45,7 @@
// UNSUP: error: Invalid target ID: gfx900:sram-ecc+
-/ RUN: %clang -### -target x86_64-linux-gnu \
+/ RUN: not %clang -### -target x86_64-linux-gnu \
// RUN: -x hip --offload-arch=gfx908 \
// RUN: --offload-arch=gfx900:xnack \
// RUN: --rocm-path=%S/Inputs/rocm \
@@ -53,7 +53,7 @@
// NOSIGN: error: Invalid target ID: gfx900:xnack
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
// RUN: -x hip --offload-arch=gfx908 \
// RUN: --offload-arch=gfx900+xnack \
// RUN: --rocm-path=%S/Inputs/rocm \
More information about the cfe-commits
mailing list