Author: Artem Belevich Date: 2022-09-01T15:52:36-07:00 New Revision: 54c47ff9398fbd5fa7e4120b3286adfb4f736ec8
URL: https://github.com/llvm/llvm-project/commit/54c47ff9398fbd5fa7e4120b3286adfb4f736ec8 DIFF: https://github.com/llvm/llvm-project/commit/54c47ff9398fbd5fa7e4120b3286adfb4f736ec8.diff LOG: [CUDA] Allow using -o with -fsyntax-only -fsyntax-only breaks down CUDA compilation pipeline and make it look like multiple independent subcompilations and that trips the multiple arguments check when -o is specified. We do want to allow -fsyntax-only to be used with otherwise unmodified clang options as it's commonly used by various tooling. Differential Revision: https://reviews.llvm.org/D133133 Added: Modified: clang/lib/Driver/Driver.cpp clang/test/Driver/cuda-bindings.cu Removed: ################################################################################ diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index ac8aa8ac8f707..554e6b890281f 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4536,7 +4536,8 @@ void Driver::BuildJobs(Compilation &C) const { // // OffloadClass of type TY_Nothing: device-only output will place many outputs // into a single offloading action. We should count all inputs to the action - // as outputs. + // as outputs. Also ignore device-only outputs if we're compiling with + // -fsyntax-only. if (FinalOutput) { unsigned NumOutputs = 0; unsigned NumIfsOutputs = 0; @@ -4550,7 +4551,8 @@ void Driver::BuildJobs(Compilation &C) const { A->getInputs().front()->getKind() == Action::IfsMergeJobClass))) ++NumOutputs; else if (A->getKind() == Action::OffloadClass && - A->getType() == types::TY_Nothing) + A->getType() == types::TY_Nothing && + !C.getArgs().hasArg(options::OPT_fsyntax_only)) NumOutputs += A->size(); } diff --git a/clang/test/Driver/cuda-bindings.cu b/clang/test/Driver/cuda-bindings.cu index a7aa4c7978859..6c4398b706973 100644 --- a/clang/test/Driver/cuda-bindings.cu +++ b/clang/test/Driver/cuda-bindings.cu @@ -39,9 +39,19 @@ // // Test two gpu architectures with complete compilation. // -// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ -// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --offload-arch=sm_30,sm_35 %s 2>&1 \ -// RUN: | FileCheck -check-prefix=BIN2 %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ +// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=BIN2,AOUT %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ +// RUN: --offload-arch=sm_30,sm_35 %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=BIN2,AOUT %s +// .. same, but with explicitly specified output. +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ +// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -o %t/out 2>&1 \ +// RUN: | FileCheck -check-prefixes=BIN2,TOUT %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \ +// RUN: --offload-arch=sm_30,sm_35 %s -o %t/out 2>&1 \ +// RUN: | FileCheck -check-prefixes=BIN2,TOUT %s // BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: // BIN2-NOT: cuda-bindings-device-cuda-nvptx64 // BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output: @@ -54,7 +64,50 @@ // BIN2-NOT: cuda-bindings-device-cuda-nvptx64 // BIN2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: // BIN2-NOT: cuda-bindings-device-cuda-nvptx64 -// BIN2: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out" +// AOUT: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out" +// TOUT: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "{{.*}}/out" + +// .. same, but with -fsyntax-only +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ +// RUN: | FileCheck -check-prefix=SYN %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --offload-arch=sm_30,sm_35 %s -o %t/out 2>&1 \ +// RUN: | FileCheck -check-prefix=SYN %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ +// RUN: | FileCheck -check-prefix=SYN %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --offload-arch=sm_30,sm_35 %s -o %t/out 2>&1 \ +// RUN: | FileCheck -check-prefix=SYN %s +// SYN-NOT: inputs: +// SYN: # "powerpc64le-ibm-linux-gnu" - "clang", inputs: [{{.*}}], output: (nothing) +// SYN-NEXT: # "nvptx64-nvidia-cuda" - "clang", inputs: [{{.*}}], output: (nothing) +// SYN-NEXT: # "nvptx64-nvidia-cuda" - "clang", inputs: [{{.*}}], output: (nothing) +// SYN-NOT: inputs + +// .. and with --offload-new-driver +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 --offload-new-driver %s 2>&1 \ +// RUN: | FileCheck -check-prefix=NDSYN %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --offload-arch=sm_30,sm_35 %s --offload-new-driver -o %t/out 2>&1 \ +// RUN: | FileCheck -check-prefix=NDSYN %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --offload-new-driver 2>&1 \ +// RUN: | FileCheck -check-prefix=NDSYN %s +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings -fsyntax-only \ +// RUN: --offload-arch=sm_30,sm_35 %s --offload-new-driver -o %t/out 2>&1 \ +// RUN: | FileCheck -check-prefix=NDSYN %s +// NDSYN-NOT: inputs: +// NDSYN: # "nvptx64-nvidia-cuda" - "clang", inputs: [{{.*}}], output: (nothing) +// NDSYN-NEXT: # "nvptx64-nvidia-cuda" - "clang", inputs: [{{.*}}], output: (nothing) +// ! FIXME: new driver erroneously attempts to run linker phase w/ no inputs. +// Remove these checks once the issue is solved. +// NDSYN-NEXT: "nvptx64-nvidia-cuda" - "NVPTX::Linker", inputs: [(nothing), (nothing)], output: "{{.*}}" +// NDSYN-NEXT: # "powerpc64le-ibm-linux-gnu" - "clang", inputs: [{{.*}}], output: (nothing) +// NDSYN-NOT: inputs: + // // Test two gpu architectures up to the assemble phase. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits