[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-12-12 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348930: [CUDA][OPENMP][NVPTX]Improve logic of the debug info 
support. (authored by ABataev, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D51554/new/

https://reviews.llvm.org/D51554

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
  cfe/trunk/lib/Driver/ToolChains/Cuda.h
  cfe/trunk/test/Driver/cuda-dwarf-2.cu
  cfe/trunk/test/Driver/openmp-offload-gpu.c

Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -10,6 +10,7 @@
 #ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H
 #define LLVM_CLANG_DRIVER_TOOLCHAIN_H
 
+#include "clang/Basic/DebugInfoOptions.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/Sanitizers.h"
 #include "clang/Basic/DebugInfoOptions.h"
@@ -435,6 +436,10 @@
 return true;
   }
 
+  /// Adjust debug information kind considering all passed options.
+  virtual void adjustDebugInfoKind(codegenoptions::DebugInfoKind ,
+   const llvm::opt::ArgList ) const {}
+
   /// GetExceptionModel - Return the tool chain exception model.
   virtual llvm::ExceptionHandling
   GetExceptionModel(const llvm::opt::ArgList ) const;
Index: cfe/trunk/test/Driver/cuda-dwarf-2.cu
===
--- cfe/trunk/test/Driver/cuda-dwarf-2.cu
+++ cfe/trunk/test/Driver/cuda-dwarf-2.cu
@@ -1,25 +1,28 @@
 // REQUIRES: clang-driver
 //
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 | \
-// RUN:   FileCheck %s -check-prefix NO_DEBUG
+// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O1 --no-cuda-noopt-device-debug 2>&1 | \
+// RUN:   FileCheck %s -check-prefix DEBUG_DIRECTIVES
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O3 2>&1 | \
-// RUN:   FileCheck %s -check-prefix NO_DEBUG
+// RUN:   FileCheck %s -check-prefix DEBUG_DIRECTIVES
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O3 --no-cuda-noopt-device-debug 2>&1 | \
-// RUN:   FileCheck %s -check-prefix NO_DEBUG
+// RUN:   FileCheck %s -check-prefix DEBUG_DIRECTIVES
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g0 2>&1 | \
 // RUN:   FileCheck %s -check-prefix NO_DEBUG
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -ggdb0 -O3 --cuda-noopt-device-debug 2>&1 | \
 // RUN:   FileCheck %s -check-prefix NO_DEBUG
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -ggdb1 2>&1 | \
-// RUN:   FileCheck %s -check-prefix NO_DEBUG -check-prefix LINE_TABLE
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -gline-tables-only -O2 --cuda-noopt-device-debug 2>&1 | \
-// RUN:   FileCheck %s -check-prefix NO_DEBUG -check-prefix LINE_TABLE
+// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -gline-directives-only -O2 --cuda-noopt-device-debug 2>&1 | \
+// RUN:   FileCheck %s -check-prefix DEBUG_DIRECTIVES
 
 // NO_DEBUG-NOT: warning: debug
-// LINE_TABLE-NOT: warning: debug
+// DEBUG_DIRECTIVES-NOT: warning: debug
+// NO_DEBUG: "-fcuda-is-device"
+// NO_DEBUG-NOT: "-debug-info-kind=
 // NO_DEBUG: ptxas
 // NO_DEBUG-NOT: "-g"
-// LINE_TABLE: "-lineinfo"
+// DEBUG_DIRECTIVES: "-fcuda-is-device"
+// DEBUG_DIRECTIVES-SAME: "-debug-info-kind=line-directives-only"
+// DEBUG_DIRECTIVES: ptxas
+// DEBUG_DIRECTIVES-SAME: "-lineinfo"
 // NO_DEBUG: fatbinary
 // NO_DEBUG-NOT: "-g"
 
@@ -27,6 +30,8 @@
 // RUN:   FileCheck %s -check-prefix HAS_DEBUG
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O0 --cuda-noopt-device-debug 2>&1 | \
 // RUN:   FileCheck %s -check-prefix HAS_DEBUG
+// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 | \
+// RUN:   FileCheck %s -check-prefix HAS_DEBUG
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g -O3 --cuda-noopt-device-debug 2>&1 | \
 // RUN:   FileCheck %s -check-prefix HAS_DEBUG
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g2 2>&1 | \
@@ -37,9 +42,14 @@
 // RUN:   FileCheck %s -check-prefix HAS_DEBUG
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -ggdb3 -O3 --cuda-noopt-device-debug 2>&1 | \
 // RUN:   FileCheck %s -check-prefix HAS_DEBUG
+// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -ggdb1 2>&1 | \
+// RUN:   FileCheck %s -check-prefix HAS_DEBUG
+// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -gline-tables-only -O2 --cuda-noopt-device-debug 2>&1 | \
+// 

[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-12-11 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.

LGTM. I'm quite a bit happier with this now. Thanks for going through the back 
and forth.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D51554/new/

https://reviews.llvm.org/D51554



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-12-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 176993.
ABataev marked an inline comment as done.
ABataev added a comment.

Reworked according to the latest comments from Eric.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D51554/new/

https://reviews.llvm.org/D51554

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  test/Driver/cuda-dwarf-2.cu
  test/Driver/openmp-offload-gpu.c

Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -190,29 +190,35 @@
 // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.
 
 /// Check that debug info is emitted in dwarf-2
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O1 --no-cuda-noopt-device-debug 2>&1 \
+// RUN:   | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG %s
+// RUN:   | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --no-cuda-noopt-device-debug 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG %s
+// RUN:   | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g0 2>&1 \
 // RUN:   | FileCheck -check-prefix=NO_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb0 -O3 --cuda-noopt-device-debug 2>&1 \
 // RUN:   | FileCheck -check-prefix=NO_DEBUG %s
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-tables-only 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-directives-only 2>&1 \
+// RUN:   | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
 
-// LINE_TABLE-NOT: warning: debug
+// DEBUG_DIRECTIVES-NOT: warning: debug
 // NO_DEBUG-NOT: warning: debug
+// NO_DEBUG: "-fopenmp-is-device"
+// NO_DEBUG-NOT: "-debug-info-kind=
 // NO_DEBUG: ptxas
-// LINE_TABLE: "-lineinfo"
+// DEBUG_DIRECTIVES: "-triple" "nvptx64-nvidia-cuda"
+// DEBUG_DIRECTIVES-SAME: "-debug-info-kind=line-directives-only"
+// DEBUG_DIRECTIVES-SAME: "-fopenmp-is-device"
+// DEBUG_DIRECTIVES: ptxas
+// DEBUG_DIRECTIVES: "-lineinfo"
 // NO_DEBUG-NOT: "-g"
 // NO_DEBUG: nvlink
 // NO_DEBUG-NOT: "-g"
 
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \
+// RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g 2>&1 \
 // RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --cuda-noopt-device-debug 2>&1 \
@@ -227,9 +233,14 @@
 // RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb3 -O2 --cuda-noopt-device-debug 2>&1 \
 // RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-tables-only 2>&1 \
+// RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \
+// RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
 
 // HAS_DEBUG-NOT: warning: debug
 // HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda"
+// 

[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-12-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked 4 inline comments as done.
ABataev added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:282-285
 enum DebugInfoKind {
-  NoDebug,   /// No debug info.
-  LineTableOnly, /// Line tables only.
-  FullDebug  /// Full debug info.
+  NoDebug, /// No debug info.
+  DebugDirectivesOnly, /// Line tables only.
+  FullDebug,   /// Full debug info.

echristo wrote:
> This enum doesn't appear to be complete? Either way can you make it match the 
> other and document what each thing means a bit more?
No, it is complete, but probably has some wrong names. I reworked it. Actually, 
this enum is intended to track the debug info emitted for the device. It may be 
disabled, debug directives only or same debug info as for the host.



Comment at: lib/Driver/ToolChains/Cuda.cpp:289
 
 static DebugInfoKind mustEmitDebugInfo(const ArgList ) {
+  const Arg *A = Args.getLastArg(options::OPT_O_Group);

echristo wrote:
> Please document this routine in prose.
Added description.



Comment at: lib/Driver/ToolChains/Cuda.cpp:706-708
+void CudaToolChain::adjustDebugInfoKind(
+codegenoptions::DebugInfoKind , const ArgList ) const {
+  switch (mustEmitDebugInfo(Args)) {

echristo wrote:
> Is this really doing anything?
Yes, actually it does. Currently, when we need to emit the code for the device, 
we use the same debug info level just like for the host. But in some 
situations, we need to disable it or emit only debug directives for the device, 
while keeping the original debug info for the host. This function allows us to 
change the debug info level for the device and force clang to emit required 
debug info data during codegen for the NVPTX devices.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D51554/new/

https://reviews.llvm.org/D51554



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-12-05 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:282-285
 enum DebugInfoKind {
-  NoDebug,   /// No debug info.
-  LineTableOnly, /// Line tables only.
-  FullDebug  /// Full debug info.
+  NoDebug, /// No debug info.
+  DebugDirectivesOnly, /// Line tables only.
+  FullDebug,   /// Full debug info.

This enum doesn't appear to be complete? Either way can you make it match the 
other and document what each thing means a bit more?



Comment at: lib/Driver/ToolChains/Cuda.cpp:289
 
 static DebugInfoKind mustEmitDebugInfo(const ArgList ) {
+  const Arg *A = Args.getLastArg(options::OPT_O_Group);

Please document this routine in prose.



Comment at: lib/Driver/ToolChains/Cuda.cpp:292
+  bool IsDebugEnabled = !A || A->getOption().matches(options::OPT_O0) ||
+Args.hasFlag(options::OPT_cuda_noopt_device_debug,
+ options::OPT_no_cuda_noopt_device_debug,

ABataev wrote:
> echristo wrote:
> > Is this an nvcc compatibility flag?
> No, nvcc uses different set of flags. It uses `-g` for the debug info for the 
> host code and `-G` for the device code. I'm not the original author of this 
> option. clang uses it to control emission of the debug info for the device.
> The bad thing about nvcc that it disables optimizations when `-G` is used. 
> Using this option we can use LLVM optimizations and disable the optimizations 
> only when we call `ptxas` tool.
OK.



Comment at: lib/Driver/ToolChains/Cuda.cpp:706-708
+void CudaToolChain::adjustDebugInfoKind(
+codegenoptions::DebugInfoKind , const ArgList ) const {
+  switch (mustEmitDebugInfo(Args)) {

Is this really doing anything?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D51554/new/

https://reviews.llvm.org/D51554



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-11-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:292
+  bool IsDebugEnabled = !A || A->getOption().matches(options::OPT_O0) ||
+Args.hasFlag(options::OPT_cuda_noopt_device_debug,
+ options::OPT_no_cuda_noopt_device_debug,

echristo wrote:
> Is this an nvcc compatibility flag?
No, nvcc uses different set of flags. It uses `-g` for the debug info for the 
host code and `-G` for the device code. I'm not the original author of this 
option. clang uses it to control emission of the debug info for the device.
The bad thing about nvcc that it disables optimizations when `-G` is used. 
Using this option we can use LLVM optimizations and disable the optimizations 
only when we call `ptxas` tool.


Repository:
  rC Clang

https://reviews.llvm.org/D51554



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-11-08 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

The llvm backend patch here has discussion around debug info kinds that we 
should iron out first.




Comment at: lib/Driver/ToolChains/Cuda.cpp:292
+  bool IsDebugEnabled = !A || A->getOption().matches(options::OPT_O0) ||
+Args.hasFlag(options::OPT_cuda_noopt_device_debug,
+ options::OPT_no_cuda_noopt_device_debug,

Is this an nvcc compatibility flag?


Repository:
  rC Clang

https://reviews.llvm.org/D51554



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-10-31 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 172003.
ABataev added a comment.

Updated processing of the debug options. -g1 (line-tables) is considered as the 
regular debug directive, which may emit some useful debug info.


Repository:
  rC Clang

https://reviews.llvm.org/D51554

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  test/Driver/cuda-dwarf-2.cu
  test/Driver/openmp-offload-gpu.c

Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -190,29 +190,35 @@
 // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.
 
 /// Check that debug info is emitted in dwarf-2
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O1 --no-cuda-noopt-device-debug 2>&1 \
+// RUN:   | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG %s
+// RUN:   | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --no-cuda-noopt-device-debug 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG %s
+// RUN:   | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g0 2>&1 \
 // RUN:   | FileCheck -check-prefix=NO_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb0 -O3 --cuda-noopt-device-debug 2>&1 \
 // RUN:   | FileCheck -check-prefix=NO_DEBUG %s
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-tables-only 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-directives-only 2>&1 \
+// RUN:   | FileCheck -check-prefix=DEBUG_DIRECTIVES %s
 
-// LINE_TABLE-NOT: warning: debug
+// DEBUG_DIRECTIVES-NOT: warning: debug
 // NO_DEBUG-NOT: warning: debug
+// NO_DEBUG: "-fopenmp-is-device"
+// NO_DEBUG-NOT: "-debug-info-kind=
 // NO_DEBUG: ptxas
-// LINE_TABLE: "-lineinfo"
+// DEBUG_DIRECTIVES: "-triple" "nvptx64-nvidia-cuda"
+// DEBUG_DIRECTIVES-SAME: "-debug-info-kind=line-directives-only"
+// DEBUG_DIRECTIVES-SAME: "-fopenmp-is-device"
+// DEBUG_DIRECTIVES: ptxas
+// DEBUG_DIRECTIVES: "-lineinfo"
 // NO_DEBUG-NOT: "-g"
 // NO_DEBUG: nvlink
 // NO_DEBUG-NOT: "-g"
 
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \
+// RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g 2>&1 \
 // RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --cuda-noopt-device-debug 2>&1 \
@@ -227,9 +233,14 @@
 // RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb3 -O2 --cuda-noopt-device-debug 2>&1 \
 // RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-tables-only 2>&1 \
+// RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \
+// RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
 
 // HAS_DEBUG-NOT: warning: debug
 // HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda"
+// HAS_DEBUG-SAME: 

[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-10-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Ping!


Repository:
  rC Clang

https://reviews.llvm.org/D51554



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-09-05 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D51554#1224049, @echristo wrote:

> The change in name here from "line tables" to "directives only" feels a bit 
> confusing.  "Limited" seems to be a bit more clear, or even remaining line 
> tables only. Can you explain where you were going with this particular set of 
> changes in a bit more detail please?
>
> Thanks!
>
> -eric


CUDA/NVPTX supports only 3 types of the debug info: limited/full, debug 
directives and no debug info at all. It does not support debug tables, so I 
just convert this into debug directives only.
The main idea is to mimic what nvcc does. It behaves absolutely the same way. 
If the opt level is O0, we can use full debug info. if opt level is >O0, we can 
use only lineinfo(debug directives) or no debug info. If we enabling debug info 
for the device code using `--cuda-noopt-device-debug`, the opt level for the 
device code is lowered to O0 and we enable full debug info. The host code will 
be optimized still.


Repository:
  rC Clang

https://reviews.llvm.org/D51554



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-09-04 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In https://reviews.llvm.org/D51554#1224049, @echristo wrote:

> The change in name here from "line tables" to "directives only" feels a bit 
> confusing.  "Limited" seems to be a bit more clear, or even remaining line 
> tables only. Can you explain where you were going with this particular set of 
> changes in a bit more detail please?


Can't say I have much of an informed opinion about the parts that are only in 
the CUDA code. The "line directives only" terminology did come from a 
suggestion I made in one of the other reviews I can't seem to find right now.. 
ah, here: https://reviews.llvm.org/D51177 - whether or not that matches up with 
the use in the CUDA ToolChain code, I'm not sure.


Repository:
  rC Clang

https://reviews.llvm.org/D51554



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-09-04 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a reviewer: dblaikie.
echristo added a comment.

The change in name here from "line tables" to "directives only" feels a bit 
confusing.  "Limited" seems to be a bit more clear, or even remaining line 
tables only. Can you explain where you were going with this particular set of 
changes in a bit more detail please?

Thanks!

-eric


Repository:
  rC Clang

https://reviews.llvm.org/D51554



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-08-31 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Nice. So, in effect, for optimized builds we'll generate pre-DWARF line info 
only, unless --cuda-noopt-device-debug is specified.
Will this deal with the warnings about back-end being unable to handle 
particular debug options?

On a side note, when DWARF is functional in NVPTX we need to seriously consider 
per-GPU control for it. Enabling debug info blows up cubin size (ptxas 
apparently packs compressed PTX inside *cubin*) and we run into ELF reloc 
overflows in some tensorflow builds if all GPU variants carry it.


Repository:
  rC Clang

https://reviews.llvm.org/D51554



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-08-31 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: tra, echristo.
Herald added subscribers: JDevlieghere, guansong, aprantl.

Added support for the -gline-directives-only option + fixed logic of the
debug info for CUDA devices. If optimization level is O0, then options
--[no-]cuda-noopt-device-debug do not affect the debug info level. If
the optimization level is >O0, debug info options are used +
--no-cuda-noopt-device-debug is used or no --cuda-noopt-device-debug is
used, the optimization level for the device code is kept and the
emission of the debug directives is used.
If the opt level is > O0, debug info is requested +
--cuda-noopt-device-debug option is used, the optimization is disabled
for the device code + required debug info is emitted.


Repository:
  rC Clang

https://reviews.llvm.org/D51554

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  test/Driver/cuda-dwarf-2.cu
  test/Driver/openmp-offload-gpu.c

Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -167,29 +167,39 @@
 // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.
 
 /// Check that debug info is emitted in dwarf-2
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O1 --no-cuda-noopt-device-debug 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINE_TABLE %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG %s
+// RUN:   | FileCheck -check-prefix=LINE_TABLE %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --no-cuda-noopt-device-debug 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG %s
+// RUN:   | FileCheck -check-prefix=LINE_TABLE %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g0 2>&1 \
 // RUN:   | FileCheck -check-prefix=NO_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb0 -O3 --cuda-noopt-device-debug 2>&1 \
 // RUN:   | FileCheck -check-prefix=NO_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-tables-only 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s
+// RUN:   | FileCheck -check-prefix=LINE_TABLE %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-directives-only 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINE_TABLE %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \
-// RUN:   | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s
+// RUN:   | FileCheck -check-prefix=LINE_TABLE %s
 
 // LINE_TABLE-NOT: warning: debug
 // NO_DEBUG-NOT: warning: debug
+// NO_DEBUG: "-fopenmp-is-device"
+// NO_DEBUG-NOT: "-debug-info-kind=
 // NO_DEBUG: ptxas
+// LINE_TABLE: "-triple" "nvptx64-nvidia-cuda"
+// LINE_TABLE-SAME: "-debug-info-kind=line-directives-only"
+// LINE_TABLE-SAME: "-fopenmp-is-device"
+// LINE_TABLE: ptxas
 // LINE_TABLE: "-lineinfo"
 // NO_DEBUG-NOT: "-g"
 // NO_DEBUG: nvlink
 // NO_DEBUG-NOT: "-g"
 
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \
+// RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g 2>&1 \
 // RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --cuda-noopt-device-debug 2>&1 \
@@ -207,6 +217,7 @@
 
 // HAS_DEBUG-NOT: warning: debug
 // HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda"
+// HAS_DEBUG-SAME: "-debug-info-kind=limited"
 // HAS_DEBUG-SAME: "-dwarf-version=2"
 // HAS_DEBUG-SAME: "-fopenmp-is-device"
 // HAS_DEBUG: ptxas
Index: test/Driver/cuda-dwarf-2.cu