[PATCH] D47376: [CUDA][HIP] Do not offload for -M
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 25 08:23:35 PDT 2018
yaxunl created this revision.
yaxunl added a reviewer: tra.
CUDA and HIP action builder currently tries to do offloading for -M, which causes dependency file
not generated.
This patch changes action builder so that only host compilation is performed to generate dependency
file.
This assumes that the header files do not depend on whether it is device compilation or host
compilation. This is not ideal, but at least let projects using -M compile.
Ideally, we should create an offloading action for host dependency file and device dependency file
and merge them to be on dependency file, which will be done in a separate patch.
https://reviews.llvm.org/D47376
Files:
lib/Driver/Driver.cpp
test/Driver/cuda-phases.cu
Index: test/Driver/cuda-phases.cu
===================================================================
--- test/Driver/cuda-phases.cu
+++ test/Driver/cuda-phases.cu
@@ -246,3 +246,14 @@
// DASM2-DAG: [[P7:[0-9]+]]: compiler, {[[P6]]}, ir, (device-[[T]], [[ARCH2]])
// DASM2_NV-DAG: [[P8:[0-9]+]]: backend, {[[P7]]}, assembler, (device-[[T]], [[ARCH2]])
// DASM2_NV-DAG: [[P9:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE]]:[[ARCH2]])" {[[P8]]}, assembler
+
+//
+// Test -M does not cause device input.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -M 2>&1 \
+// RUN: | FileCheck -check-prefixes=DEP %s
+// RUN: %clang -x hip -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s -M 2>&1 \
+// RUN: | FileCheck -check-prefixes=DEP %s
+// DEP-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:.*]], (host-[[T]])
+// DEP-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, dependencies, (host-[[T]])
+
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -2210,7 +2210,10 @@
// Set the flag to true, so that the builder acts on the current input.
IsActive = true;
- if (CompileHostOnly)
+ // ToDo: Handle situations where device compilation and host
+ // compilation have different dependencies. Currently we assume they
+ // are the same therefore device compilation is not performed for -M.
+ if (CompileHostOnly || Args.getLastArg(options::OPT_M))
return ABRT_Success;
// Replicate inputs for each GPU architecture.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47376.148610.patch
Type: text/x-patch
Size: 1708 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180525/466aefa9/attachment.bin>
More information about the cfe-commits
mailing list