From 98c21289f1d239f39fa549ae01b17efffce6a7c0 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Tue, 19 Jan 2021 17:35:23 -0500 Subject: [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/lib/Frontend/CompilerInvocation.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index e131804..189e7c6 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2741,6 +2741,11 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, } } + + if (auto *A = Args.getLastArg(OPT_cuid_EQ)) { + Opts.CUID = std::string(A->getValue()); + } + if (Opts.ObjC) { if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) { StringRef value = arg->getValue(); -- cgit v1.1