Skip to content

Commit 5a3023a

Browse files
committed
[HIP] Return non-zero value for invalid target ID
This is part of https://reviews.llvm.org/D60620
1 parent 187658b commit 5a3023a

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2790,6 +2790,7 @@ class OffloadingActionBuilder final {
27902790
parseTargetID(getHIPOffloadTargetTriple(), IdStr, &Features);
27912791
if (!ArchStr) {
27922792
C.getDriver().Diag(clang::diag::err_drv_bad_target_id) << IdStr;
2793+
C.setContainsError();
27932794
return StringRef();
27942795
}
27952796
auto CanId = getCanonicalTargetID(ArchStr.getValue(), Features);

clang/test/Driver/hip-invalid-target-id.hip

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
// REQUIRES: x86-registered-target
33
// REQUIRES: amdgpu-registered-target
44

5-
// RUN: %clang -### -target x86_64-linux-gnu \
5+
// RUN: not %clang -### -target x86_64-linux-gnu \
66
// RUN: -x hip --offload-arch=gfx908 \
77
// RUN: --offload-arch=gfx908xnack \
88
// RUN: --rocm-path=%S/Inputs/rocm \
99
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPLUS %s
1010

1111
// NOPLUS: error: Invalid target ID: gfx908xnack
1212

13-
// RUN: %clang -### -target x86_64-linux-gnu \
13+
// RUN: not %clang -### -target x86_64-linux-gnu \
1414
// RUN: -x hip --offload-arch=gfx900 \
1515
// RUN: --offload-arch=gfx908:xnack+:xnack+ \
1616
// RUN: --rocm-path=%S/Inputs/rocm \
1717
// RUN: %s 2>&1 | FileCheck -check-prefix=ORDER %s
1818

1919
// ORDER: error: Invalid target ID: gfx908:xnack+:xnack+
2020

21-
// RUN: %clang -### -target x86_64-linux-gnu \
21+
// RUN: not %clang -### -target x86_64-linux-gnu \
2222
// RUN: -x hip --offload-arch=gfx908 \
2323
// RUN: --offload-arch=gfx908:unknown+ \
2424
// RUN: --offload-arch=gfx908+sram-ecc+unknown \
@@ -28,7 +28,7 @@
2828

2929
// UNK: error: Invalid target ID: gfx908:unknown+
3030

31-
// RUN: %clang -### -target x86_64-linux-gnu \
31+
// RUN: not %clang -### -target x86_64-linux-gnu \
3232
// RUN: -x hip --offload-arch=gfx908 \
3333
// RUN: --offload-arch=gfx908:sram-ecc+:unknown+ \
3434
// RUN: --offload-arch=gfx900+xnack \
@@ -37,23 +37,23 @@
3737

3838
// MIXED: error: Invalid target ID: gfx908:sram-ecc+:unknown+
3939

40-
// RUN: %clang -### -target x86_64-linux-gnu \
40+
// RUN: not %clang -### -target x86_64-linux-gnu \
4141
// RUN: -x hip --offload-arch=gfx908 \
4242
// RUN: --offload-arch=gfx900:sram-ecc+ \
4343
// RUN: --rocm-path=%S/Inputs/rocm \
4444
// RUN: %s 2>&1 | FileCheck -check-prefix=UNSUP %s
4545

4646
// UNSUP: error: Invalid target ID: gfx900:sram-ecc+
4747

48-
/ RUN: %clang -### -target x86_64-linux-gnu \
48+
/ RUN: not %clang -### -target x86_64-linux-gnu \
4949
// RUN: -x hip --offload-arch=gfx908 \
5050
// RUN: --offload-arch=gfx900:xnack \
5151
// RUN: --rocm-path=%S/Inputs/rocm \
5252
// RUN: %s 2>&1 | FileCheck -check-prefix=NOSIGN %s
5353

5454
// NOSIGN: error: Invalid target ID: gfx900:xnack
5555

56-
// RUN: %clang -### -target x86_64-linux-gnu \
56+
// RUN: not %clang -### -target x86_64-linux-gnu \
5757
// RUN: -x hip --offload-arch=gfx908 \
5858
// RUN: --offload-arch=gfx900+xnack \
5959
// RUN: --rocm-path=%S/Inputs/rocm \

0 commit comments

Comments
 (0)