[PATCH] D68660: [tooling] Teach Tooling to understand compilation with offloading.

Michael Liao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 10 12:20:05 PDT 2019


hliao marked an inline comment as done.
hliao added inline comments.


================
Comment at: clang/lib/Tooling/Tooling.cpp:117
   // The one job we find should be to invoke clang again.
   const auto &Cmd = cast<driver::Command>(*Jobs.begin());
   if (StringRef(Cmd.getCreator().getName()) != "clang") {
----------------
klimek wrote:
> tra wrote:
> > hliao wrote:
> > > tra wrote:
> > > > hliao wrote:
> > > > > tra wrote:
> > > > > > Is this still the right job for us to pick? I think we want this to be the host compilation. 
> > > > > > 
> > > > > > As things are right now my guess is that we're probably picking the first device-side compilation.
> > > > > yes, OffloadAction is appended to the original host action. The corresponding first job is the host compilation. The frontend has similar handling in `lib/Frontend/CreateInvocationFromCommandLine.cpp`
> > > > Can we add an assert or diagnostics for that? I think the check below would not always be able to tell if it unintentionally picked a wrong kind of job.
> > > It seems to me that the `cast<>` and check against "clang" @ L118 already did what I asked. 
> > Device-side compilation would also use clang, so the check for `clang` is insufficient for  ensuring that it's a *host* compilation. 
> > 
> > Furthermore, the order of jobs *will* change depending on whether  -fsyntax-only is in effect.
> > 
> > @klimek -- Manuel, Is tooling allowed to create an invocation w/o `-fsyntax-only`? AFAICT, `runToolOnCodeWithArgs` always adds it, but one could technically create an `Invocation` without it.
> Generally, tooling is allowed to do it, but it's not super well supported or tested.
I added more offload compilation based on actions, which is more reliable that jobs. Is that sufficient?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68660/new/

https://reviews.llvm.org/D68660





More information about the cfe-commits mailing list