This is an archive of the discontinued LLVM Phabricator instance.

Refactor how include paths are appended to the command arguments.
ClosedPublic

Authored by sfantao on Jul 19 2016, 8:14 AM.

Details

Summary

This patch aims at removing redundancy in the way include paths for the regular and offloading toolchains are appended to the arguments list in the clang tool.

This was suggested by @rsmith in response to r275931.

Diff Detail

Event Timeline

sfantao updated this revision to Diff 64505.Jul 19 2016, 8:14 AM
sfantao retitled this revision from to Refactor how include paths are appended to the command arguments..
sfantao updated this object.
sfantao added reviewers: tra, rsmith.
sfantao added subscribers: cfe-commits, rsmith.
tra accepted this revision.Jul 19 2016, 10:01 AM
tra edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Jul 19 2016, 10:01 AM
rsmith added inline comments.Jul 20 2016, 5:40 PM
lib/Driver/Tools.cpp
324–351

There's no point in building a SmallVector here, just directly call Work when you find a toolchain that should be used.

333–334

What is this ActiveOffloadingKind parameter for? Both values that we actually pass in here do the exact same thing.

341–346

The OFK_Host / OFK_Cuda arguments here are reversed from the other two cases. Is that a bug that's fixed by this change, or a bug that's introduced by this change? :)

Either way it seems that we're missing test coverage.

sfantao updated this revision to Diff 65747.Jul 27 2016, 8:30 AM
sfantao marked 3 inline comments as done.
sfantao edited edge metadata.
  • Remove of use of SmallVector and include CUDA args only for the regular toolchain.

Hi Art, Richard,

Thanks for looking at this patch. I tried to address Richard concerns in the last diff.

Let me know your thoughts,

Thanks again,
Samuel

lib/Driver/Tools.cpp
324–351

Ok, I'm doing as you suggest.

333–334

ActiveOffloadingKind was meant to signal the offloading model in use. Its true right now we only have CUDA kind. We are proposing the OpenMP kind in https://reviews.llvm.org/D21843 (one of the depending patches of the patch that inserted this modification), so the goal was to pave the way for that.

In any case, I'm removing the ActiveOffloadingKind check, as I am calling AddCudaIncludeArgs directly in the caller of this function. Let me know if you'd like to fix this in a different way.

341–346

As per the implementation before my change, AddCudaIncludeArgs should be called on the current toolchain. The outcome of using one toolchain or the other is similar except that for a CUDA toolchain there is an extra check. So, we'd always get the check if producing commands for both toolchains except if compiling with host/device-only mode. I fixed the issue here and added regression tests for host/device only .

tra added a comment.Jul 27 2016, 9:50 AM

Looks good.

sfantao closed this revision.Jul 27 2016, 3:54 PM
tra added a comment.EditedJul 28 2016, 3:18 PM

Samuel, the patch breaks CUDA. With the patch clang no longer adds include paths to standard c++ library during device-side compilation.
if you run "clang++ -### -c -x cuda /dev/null" you will see that host side gets "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8" but device-side compilation does not.

In D22518#500066, @tra wrote:

Samuel, the patch breaks CUDA. With the patch clang no longer adds include paths to standard c++ library during device-side compilation.
if you run "clang++ -### -c -x cuda /dev/null" you will see that host side gets "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8" but device-side compilation does not.

Hi Art,

The enumerators were switched... It should be fixed in r277064. I'll post a patch with regression test to catch the issue.

Sorry for the trouble,
Samuel