r285263 - Fix bug when compiling CUDA code with -emit-llvm and -o.

Samuel Antao via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 26 17:53:34 PDT 2016


Author: sfantao
Date: Wed Oct 26 19:53:34 2016
New Revision: 285263

URL: http://llvm.org/viewvc/llvm-project?rev=285263&view=rev
Log:
Fix bug when compiling CUDA code with -emit-llvm and -o. 

In this case the device code is not injected into an host action and therefore the 
user should get an error as -o can't be used when generating two outputs.

Modified:
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/test/Driver/cuda-output-asm.cu

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=285263&r1=285262&r2=285263&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Oct 26 19:53:34 2016
@@ -1611,6 +1611,11 @@ class OffloadingActionBuilder final {
 
         // We avoid creating host action in device-only mode.
         return CompileDeviceOnly ? ABRT_Ignore_Host : ABRT_Success;
+      } else if (CurPhase > phases::Backend) {
+        // If we are past the backend phase and still have a device action, we
+        // don't have to do anything as this action is already a device
+        // top-level action.
+        return ABRT_Success;
       }
 
       assert(CurPhase < phases::Backend && "Generating single CUDA "

Modified: cfe/trunk/test/Driver/cuda-output-asm.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-output-asm.cu?rev=285263&r1=285262&r2=285263&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cuda-output-asm.cu (original)
+++ cfe/trunk/test/Driver/cuda-output-asm.cu Wed Oct 26 19:53:34 2016
@@ -1,4 +1,4 @@
-// Tests CUDA compilation with -S.
+// Tests CUDA compilation with -S and -emit-llvm.
 
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
@@ -26,4 +26,6 @@
 // RUN: %clang -### -S -target x86_64-linux-gnu --cuda-device-only \
 // RUN:   --cuda-gpu-arch=sm_20 --cuda-gpu-arch=sm_30 -o foo.s %s 2>&1 \
 // RUN:   | FileCheck -check-prefix MULTIPLE-OUTPUT-FILES %s
+// RUN: %clang -### -emit-llvm -c -target x86_64-linux-gnu -o foo.s %s 2>&1 \
+// RUN:   | FileCheck -check-prefix MULTIPLE-OUTPUT-FILES %s
 // MULTIPLE-OUTPUT-FILES: error: cannot specify -o when generating multiple output files




More information about the cfe-commits mailing list