[CUDA][HIP] Add -fuse-cuid
authorYaxun (Sam) Liu <yaxun.liu@amd.com>
Tue, 19 Jan 2021 22:35:23 +0000 (17:35 -0500)
committerYaxun (Sam) Liu <yaxun.liu@amd.com>
Tue, 9 Feb 2021 03:26:12 +0000 (22:26 -0500)
commit98c21289f1d239f39fa549ae01b17efffce6a7c0
treecc8eb3680295790b767180801402c32caf6a1bbf
parent7dc324aafa2b17a4f9a992b9727a3642505053a6
[CUDA][HIP] Add -fuse-cuid

This patch added a distinct CUID for each input file, which is represented by InputAction.
clang initially creates an InputAction for each input file for the host compilation. In CUDA/HIP action
builder, each InputAction is given a CUID and cloned for each GPU arch, and the CUID is also cloned. In this way,
we guarantee the corresponding device and host compilation for the same file shared the
same CUID. On the other hand, different compilation units have different CUID.

-fuse-cuid=random|hash|none is added to control the method to generate CUID. The default
is hash. -cuid=X is also added to specify CUID explicitly, which overrides -fuse-cuid.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D95007
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Action.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/Action.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/hip-cuid-hash.hip [new file with mode: 0644]
clang/test/Driver/hip-cuid.hip [new file with mode: 0644]