r312736 - [CUDA] When compilation fails, print the compilation mode.
Justin Lebar via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 7 11:37:17 PDT 2017
Author: jlebar
Date: Thu Sep 7 11:37:16 2017
New Revision: 312736
URL: http://llvm.org/viewvc/llvm-project?rev=312736&view=rev
Log:
[CUDA] When compilation fails, print the compilation mode.
Summary:
That is, instead of "1 error generated", we now say "1 error generated
when compiling for sm_35".
This (partially) solves a usability foogtun wherein e.g. users call a
function that's only defined on sm_60 when compiling for sm_35, and they
get an unhelpful error message.
Reviewers: tra
Subscribers: sanjoy, cfe-commits
Differential Revision: https://reviews.llvm.org/D37548
Added:
cfe/trunk/test/SemaCUDA/error-includes-mode.cu
Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=312736&r1=312735&r2=312736&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Sep 7 11:37:16 2017
@@ -1003,8 +1003,17 @@ bool CompilerInstance::ExecuteAction(Fro
OS << " and ";
if (NumErrors)
OS << NumErrors << " error" << (NumErrors == 1 ? "" : "s");
- if (NumWarnings || NumErrors)
- OS << " generated.\n";
+ if (NumWarnings || NumErrors) {
+ OS << " generated";
+ if (getLangOpts().CUDA) {
+ if (!getLangOpts().CUDAIsDevice) {
+ OS << " when compiling for host";
+ } else {
+ OS << " when compiling for " << getTargetOpts().CPU;
+ }
+ }
+ OS << ".\n";
+ }
}
if (getFrontendOpts().ShowStats) {
Added: cfe/trunk/test/SemaCUDA/error-includes-mode.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/error-includes-mode.cu?rev=312736&view=auto
==============================================================================
--- cfe/trunk/test/SemaCUDA/error-includes-mode.cu (added)
+++ cfe/trunk/test/SemaCUDA/error-includes-mode.cu Thu Sep 7 11:37:16 2017
@@ -0,0 +1,7 @@
+// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck --check-prefix HOST %s
+// RUN: not %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_35 \
+// RUN: -fcuda-is-device -fsyntax-only %s 2>&1 | FileCheck --check-prefix SM35 %s
+
+// HOST: 1 error generated when compiling for host
+// SM35: 1 error generated when compiling for sm_35
+error;
More information about the cfe-commits
mailing list