Skip to content

Commit 16ca2eb

Browse files
authored
[NFC][CUDA][HIP] Print the triple when there's no mcpu (llvm#166565)
It is possible to run into situations where no mcpu is specified for an offload device side compilation. Currently, this'd lead to a rather uninformative blank being presented as the target for a failing compilation, when messaging the error count. This patch changes things so that if there is no `-mcpu` we print the triple, which is slightly more helpful, especially when there are multiple offload targets for a single compilation.
1 parent 995b0f1 commit 16ca2eb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,9 @@ void CompilerInstance::printDiagnosticStats() {
10581058
if (!getLangOpts().CUDAIsDevice) {
10591059
OS << " when compiling for host";
10601060
} else {
1061-
OS << " when compiling for " << getTargetOpts().CPU;
1061+
OS << " when compiling for "
1062+
<< (!getTargetOpts().CPU.empty() ? getTargetOpts().CPU
1063+
: getTarget().getTriple().str());
10621064
}
10631065
}
10641066
OS << ".\n";
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck --check-prefix HOST %s
22
// RUN: not %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_35 \
33
// RUN: -fcuda-is-device -fsyntax-only %s 2>&1 | FileCheck --check-prefix SM35 %s
4+
// RUN: not %clang_cc1 -triple spirv64-unknown-unknown \
5+
// RUN: -fcuda-is-device -fsyntax-only %s 2>&1 | FileCheck --check-prefix SPIRV %s
6+
// RUN: not %clang_cc1 -triple spirv64-amd-amdhsa \
7+
// RUN: -fcuda-is-device -fsyntax-only %s 2>&1 | FileCheck --check-prefix AMDGCNSPIRV %s
8+
// RUN: not %clang_cc1 -triple spirv64-intel-unknown \
9+
// RUN: -fcuda-is-device -fsyntax-only %s 2>&1 | FileCheck --check-prefix INTELSPIRV %s
410

511
// HOST: 1 error generated when compiling for host
612
// SM35: 1 error generated when compiling for sm_35
13+
// SPIRV: 1 error generated when compiling for spirv64-unknown-unknown
14+
// AMDGCNSPIRV: 1 error generated when compiling for spirv64-amd-amdhsa
15+
// INTELSPIRV: 1 error generated when compiling for spirv64-intel-unknown
716
error;

0 commit comments

Comments
 (0)