r374470 - [tooling] Teach Tooling to understand compilation with offloading.
Michael Liao via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 10 16:05:56 PDT 2019
Author: hliao
Date: Thu Oct 10 16:05:55 2019
New Revision: 374470
URL: http://llvm.org/viewvc/llvm-project?rev=374470&view=rev
Log:
[tooling] Teach Tooling to understand compilation with offloading.
Summary:
- So far, we only recognize the host compilation with offloading and
skip the offloading part.
Reviewers: tra, yaxunl
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D68660
Added:
cfe/trunk/test/Tooling/clang-check-offload.cpp
Modified:
cfe/trunk/lib/Tooling/Tooling.cpp
Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=374470&r1=374469&r2=374470&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Thu Oct 10 16:05:55 2019
@@ -91,7 +91,29 @@ static const llvm::opt::ArgStringList *g
// We expect to get back exactly one Command job, if we didn't something
// failed. Extract that job from the Compilation.
const driver::JobList &Jobs = Compilation->getJobs();
- if (Jobs.size() != 1 || !isa<driver::Command>(*Jobs.begin())) {
+ const driver::ActionList &Actions = Compilation->getActions();
+ bool OffloadCompilation = false;
+ if (Jobs.size() > 1) {
+ for (auto A : Actions){
+ // On MacOSX real actions may end up being wrapped in BindArchAction
+ if (isa<driver::BindArchAction>(A))
+ A = *A->input_begin();
+ if (isa<driver::OffloadAction>(A)) {
+ // Offload compilation has 2 top-level actions, one (at the front) is
+ // the original host compilation and the other is offload action
+ // composed of at least one device compilation. For such case, general
+ // tooling will consider host-compilation only. For tooling on device
+ // compilation, device compilation only option, such as
+ // `--cuda-device-only`, needs specifying.
+ assert(Actions.size() == 2);
+ assert(isa<driver::CompileJobAction>(Actions.front()));
+ OffloadCompilation = true;
+ break;
+ }
+ }
+ }
+ if (Jobs.size() == 0 || !isa<driver::Command>(*Jobs.begin()) ||
+ (Jobs.size() > 1 && !OffloadCompilation)) {
SmallString<256> error_msg;
llvm::raw_svector_ostream error_stream(error_msg);
Jobs.Print(error_stream, "; ", true);
Added: cfe/trunk/test/Tooling/clang-check-offload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-offload.cpp?rev=374470&view=auto
==============================================================================
--- cfe/trunk/test/Tooling/clang-check-offload.cpp (added)
+++ cfe/trunk/test/Tooling/clang-check-offload.cpp Thu Oct 10 16:05:55 2019
@@ -0,0 +1,4 @@
+// RUN: not clang-check "%s" -- -c -x hip -nogpulib 2>&1 | FileCheck %s
+
+// CHECK: C++ requires
+invalid;
More information about the cfe-commits
mailing list