[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-04-18 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330272: [NVPTX] Emit debug info in DWARF-2 by default for 
Cuda devices. (authored by ABataev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42581?vs=132016=142954#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42581

Files:
  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/cuda-external-tools.cu
  cfe/trunk/test/Driver/openmp-offload-gpu.c

Index: cfe/trunk/test/Driver/openmp-offload-gpu.c
===
--- cfe/trunk/test/Driver/openmp-offload-gpu.c
+++ cfe/trunk/test/Driver/openmp-offload-gpu.c
@@ -165,3 +165,51 @@
 // RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
 
 // 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 -O3 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 -O3 --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 -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
+
+// NO_DEBUG: 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 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 \
+// 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 -O3 --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 -g2 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 -ggdb2 -O0 --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 -g3 -O3 --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 -ggdb3 -O2 --cuda-noopt-device-debug 2>&1 \
+// RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
+
+// HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda"
+// HAS_DEBUG-SAME: "-dwarf-version=2"
+// HAS_DEBUG-SAME: "-fopenmp-is-device"
+// HAS_DEBUG: ptxas
+// HAS_DEBUG-SAME: "-g"
+// HAS_DEBUG-SAME: "--dont-merge-basicblocks"
+// HAS_DEBUG-SAME: "--return-at-end"
+// HAS_DEBUG: nvlink
+// HAS_DEBUG-SAME: "-g"
+
Index: cfe/trunk/test/Driver/cuda-external-tools.cu
===
--- cfe/trunk/test/Driver/cuda-external-tools.cu
+++ cfe/trunk/test/Driver/cuda-external-tools.cu
@@ -23,7 +23,7 @@
 // RUN: | FileCheck -check-prefixes=CHECK,ARCH64,SM20,RDC %s
 
 // With debugging enabled, ptxas should be run with with no ptxas optimizations.

[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

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

Thanks, will commit it after the commit of the LLVM part


Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-02-08 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.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-02-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:436-437
 assert(Output.isNothing() && "Invalid output.");
-  if (Args.hasArg(options::OPT_g_Flag))
+  if (mustEmitDebugInfo(Args) == FullDebug)
 CmdArgs.push_back("-g");
 

tra wrote:
> Do we need to pass -g to make lineinfo debugging work?
I checked with nvcc, it does not send `-g` in line table only mode.


Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-01-30 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:436-437
 assert(Output.isNothing() && "Invalid output.");
-  if (Args.hasArg(options::OPT_g_Flag))
+  if (mustEmitDebugInfo(Args) == FullDebug)
 CmdArgs.push_back("-g");
 

Do we need to pass -g to make lineinfo debugging work?


Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-01-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 132016.
ABataev added a comment.

1. Updated after review.
2. Changed the default behavior of --[no]cuda-noopt-device-debug. If the 
optimization level is not specified or is O0 and debug info must be emitted, 
the device debug info is emitted. If optimization level is specified and >O0 
and debug info must be emitted, the debug info for device is emitted only if 
--cuda-noopt-device-debug is specified.


Repository:
  rC Clang

https://reviews.llvm.org/D42581

Files:
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  test/Driver/cuda-dwarf-2.cu
  test/Driver/cuda-external-tools.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
@@ -142,3 +142,53 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that dbug 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 -O3 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 -O3 --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 -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
+
+// NO_DEBUG: 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 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 \
+// 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 -O3 --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 -g2 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 -ggdb2 -O0 --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 -g3 -O3 --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 -ggdb3 -O2 --cuda-noopt-device-debug 2>&1 \
+// RUN:   | FileCheck -check-prefix=HAS_DEBUG %s
+
+// HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda"
+// HAS_DEBUG-SAME: "-dwarf-version=2"
+// HAS_DEBUG-SAME: "-fopenmp-is-device"
+// HAS_DEBUG: ptxas
+// HAS_DEBUG-SAME: "-g"
+// HAS_DEBUG-SAME: "--dont-merge-basicblocks"
+// HAS_DEBUG-SAME: "--return-at-end"
+// HAS_DEBUG: nvlink
+// HAS_DEBUG-SAME: "-g"
+
Index: test/Driver/cuda-external-tools.cu
===
--- test/Driver/cuda-external-tools.cu
+++ test/Driver/cuda-external-tools.cu
@@ -20,7 +20,7 @@
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 %s
 
 // With debugging enabled, ptxas should be run with with no ptxas optimizations.
-// RUN: %clang -### -target x86_64-linux-gnu 

[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-01-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:353
   CmdArgs.push_back(Args.MakeArgString(Output.getFilename()));
+  if (mustEmitDebugInfo(Args) && Args.hasArg(options::OPT_g_Flag))
+CmdArgs.push_back("-g");

tra wrote:
> ABataev wrote:
> > tra wrote:
> > > ABataev wrote:
> > > > tra wrote:
> > > > > There's more than one -g option. Presumably you still want -g here 
> > > > > for -g{1,2,3} or -ggdb{1,2,3} or -gdwarf2.
> > > > > 
> > > > > Speaking of dwarf, what's going to happen if someone passes -gdwarf5? 
> > > > >  Should we downgrade it to -gdwarf2 on device side and issue a 
> > > > > warning?
> > > > > 
> > > > That's exactly what I want to avoid. I think we can ignore these 
> > > > options and handle only `-g` option.
> > > > Or I can add a function to ToolChain class to force using the default 
> > > > settings for debugger tuning and DWARF version rather than take them 
> > > > from the driver options.
> > > You should handle at least -gN/-gline-tables-only/-g. Now that we can 
> > > emit dwarf debug info, I would want to be able to control it to some 
> > > degree -- off/line-info-only/full.
> > > 
> > > I'm still not sure what's the plan for -gdwarfN unsupported on device 
> > > side? 
> > > - do we ignore it and always emit dwarf2?
> > > - do we accept it, emit requested version and let user stare at ptxas (or 
> > > cuda-gdb) errors when it fails to deal with it?
> > > 
> > > 
> > > 
> > > 
> > 1. Ok, will look at this
> > 2. -gdwarfN should be ignored, we should always emit DWARF2, otherwise, it 
> > will break ptxas.
> Works for me. Please add a test to verify that it's always dwarf2 on device 
> side.
After some thoughts, I think it would better to follow Paul's suggestion, i.e. 
force DWARF2 for NVPTX in the backend. In this case, -gdwarfN will not break 
anything in the debug info for NVPTX.


Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-01-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D42581#989760, @probinson wrote:

> If you want to force DWARF 2, probably clamping the version in LLVM would be 
> simpler?  Although most of the debug-info tests are architecture-specific and 
> wouldn't run for an NVPTX target anyway.


Hi, I think it would be better to do both: make it default in the frontend and 
in the backend.


Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-01-26 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

If you want to force DWARF 2, probably clamping the version in LLVM would be 
simpler?  Although most of the debug-info tests are architecture-specific and 
wouldn't run for an NVPTX target anyway.


Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-01-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:353
   CmdArgs.push_back(Args.MakeArgString(Output.getFilename()));
+  if (mustEmitDebugInfo(Args) && Args.hasArg(options::OPT_g_Flag))
+CmdArgs.push_back("-g");

ABataev wrote:
> tra wrote:
> > ABataev wrote:
> > > tra wrote:
> > > > There's more than one -g option. Presumably you still want -g here for 
> > > > -g{1,2,3} or -ggdb{1,2,3} or -gdwarf2.
> > > > 
> > > > Speaking of dwarf, what's going to happen if someone passes -gdwarf5?  
> > > > Should we downgrade it to -gdwarf2 on device side and issue a warning?
> > > > 
> > > That's exactly what I want to avoid. I think we can ignore these options 
> > > and handle only `-g` option.
> > > Or I can add a function to ToolChain class to force using the default 
> > > settings for debugger tuning and DWARF version rather than take them from 
> > > the driver options.
> > You should handle at least -gN/-gline-tables-only/-g. Now that we can emit 
> > dwarf debug info, I would want to be able to control it to some degree -- 
> > off/line-info-only/full.
> > 
> > I'm still not sure what's the plan for -gdwarfN unsupported on device side? 
> > - do we ignore it and always emit dwarf2?
> > - do we accept it, emit requested version and let user stare at ptxas (or 
> > cuda-gdb) errors when it fails to deal with it?
> > 
> > 
> > 
> > 
> 1. Ok, will look at this
> 2. -gdwarfN should be ignored, we should always emit DWARF2, otherwise, it 
> will break ptxas.
Works for me. Please add a test to verify that it's always dwarf2 on device 
side.


Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-01-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:353
   CmdArgs.push_back(Args.MakeArgString(Output.getFilename()));
+  if (mustEmitDebugInfo(Args) && Args.hasArg(options::OPT_g_Flag))
+CmdArgs.push_back("-g");

tra wrote:
> ABataev wrote:
> > tra wrote:
> > > There's more than one -g option. Presumably you still want -g here for 
> > > -g{1,2,3} or -ggdb{1,2,3} or -gdwarf2.
> > > 
> > > Speaking of dwarf, what's going to happen if someone passes -gdwarf5?  
> > > Should we downgrade it to -gdwarf2 on device side and issue a warning?
> > > 
> > That's exactly what I want to avoid. I think we can ignore these options 
> > and handle only `-g` option.
> > Or I can add a function to ToolChain class to force using the default 
> > settings for debugger tuning and DWARF version rather than take them from 
> > the driver options.
> You should handle at least -gN/-gline-tables-only/-g. Now that we can emit 
> dwarf debug info, I would want to be able to control it to some degree -- 
> off/line-info-only/full.
> 
> I'm still not sure what's the plan for -gdwarfN unsupported on device side? 
> - do we ignore it and always emit dwarf2?
> - do we accept it, emit requested version and let user stare at ptxas (or 
> cuda-gdb) errors when it fails to deal with it?
> 
> 
> 
> 
1. Ok, will look at this
2. -gdwarfN should be ignored, we should always emit DWARF2, otherwise, it will 
break ptxas.


Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-01-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:353
   CmdArgs.push_back(Args.MakeArgString(Output.getFilename()));
+  if (mustEmitDebugInfo(Args) && Args.hasArg(options::OPT_g_Flag))
+CmdArgs.push_back("-g");

ABataev wrote:
> tra wrote:
> > There's more than one -g option. Presumably you still want -g here for 
> > -g{1,2,3} or -ggdb{1,2,3} or -gdwarf2.
> > 
> > Speaking of dwarf, what's going to happen if someone passes -gdwarf5?  
> > Should we downgrade it to -gdwarf2 on device side and issue a warning?
> > 
> That's exactly what I want to avoid. I think we can ignore these options and 
> handle only `-g` option.
> Or I can add a function to ToolChain class to force using the default 
> settings for debugger tuning and DWARF version rather than take them from the 
> driver options.
You should handle at least -gN/-gline-tables-only/-g. Now that we can emit 
dwarf debug info, I would want to be able to control it to some degree -- 
off/line-info-only/full.

I'm still not sure what's the plan for -gdwarfN unsupported on device side? 
- do we ignore it and always emit dwarf2?
- do we accept it, emit requested version and let user stare at ptxas (or 
cuda-gdb) errors when it fails to deal with it?






Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-01-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:353
   CmdArgs.push_back(Args.MakeArgString(Output.getFilename()));
+  if (mustEmitDebugInfo(Args) && Args.hasArg(options::OPT_g_Flag))
+CmdArgs.push_back("-g");

tra wrote:
> There's more than one -g option. Presumably you still want -g here for 
> -g{1,2,3} or -ggdb{1,2,3} or -gdwarf2.
> 
> Speaking of dwarf, what's going to happen if someone passes -gdwarf5?  Should 
> we downgrade it to -gdwarf2 on device side and issue a warning?
> 
That's exactly what I want to avoid. I think we can ignore these options and 
handle only `-g` option.
Or I can add a function to ToolChain class to force using the default settings 
for debugger tuning and DWARF version rather than take them from the driver 
options.



Comment at: test/Driver/cuda-dwarf-2.cu:6-11
+// DEFAULT: "-fcuda-is-device"
+// DEFAULT-SAME: "-dwarf-version=2"
+// DEFAULT: ptxas
+// DEFAULT-NOT: "-g"
+// DEFAULT: fatbinary
+// DEFAULT-NOT: "-g"

tra wrote:
> Nit: you could probably collapse all test cases into two: HAS_DEBUG/NO_DEBUG
Ok, will do


Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-01-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:353
   CmdArgs.push_back(Args.MakeArgString(Output.getFilename()));
+  if (mustEmitDebugInfo(Args) && Args.hasArg(options::OPT_g_Flag))
+CmdArgs.push_back("-g");

There's more than one -g option. Presumably you still want -g here for 
-g{1,2,3} or -ggdb{1,2,3} or -gdwarf2.

Speaking of dwarf, what's going to happen if someone passes -gdwarf5?  Should 
we downgrade it to -gdwarf2 on device side and issue a warning?




Comment at: test/Driver/cuda-dwarf-2.cu:6-11
+// DEFAULT: "-fcuda-is-device"
+// DEFAULT-SAME: "-dwarf-version=2"
+// DEFAULT: ptxas
+// DEFAULT-NOT: "-g"
+// DEFAULT: fatbinary
+// DEFAULT-NOT: "-g"

Nit: you could probably collapse all test cases into two: HAS_DEBUG/NO_DEBUG


Repository:
  rC Clang

https://reviews.llvm.org/D42581



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


[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.

2018-01-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: tra, jlebar.
Herald added subscribers: JDevlieghere, aprantl.

NVPTX target supports debug info in DWARF-2 format. Patch adds emission
of debug info in DWARF-2 by default.


Repository:
  rC Clang

https://reviews.llvm.org/D42581

Files:
  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
@@ -142,3 +142,77 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that dbug 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 2>&1 \
+// RUN:   | FileCheck -check-prefix=DEFAULT_DEBUG %s
+
+// DEFAULT_DEBUG: "-triple" "nvptx64-nvidia-cuda"
+// DEFAULT_DEBUG-SAME: "-dwarf-version=2"
+// DEFAULT_DEBUG-SAME: "-fopenmp-is-device"
+// DEFAULT_DEBUG: ptxas
+// DEFAULT_DEBUG-NOT: "-g"
+// DEFAULT_DEBUG: nvlink
+// DEFAULT_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=O0_NO_DEBUG %s
+
+// O0_NO_DEBUG: "-triple" "nvptx64-nvidia-cuda"
+// O0_NO_DEBUG-SAME: "-dwarf-version=2"
+// O0_NO_DEBUG-SAME: "-fopenmp-is-device"
+// O0_NO_DEBUG: ptxas
+// O0_NO_DEBUG-NOT: "-g"
+// O0_NO_DEBUG: nvlink
+// O0_NO_DEBUG-NOT: "-g"
+
+// 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 \
+// RUN:   | FileCheck -check-prefix=O0_DEBUG %s
+
+// O0_DEBUG: "-triple" "nvptx64-nvidia-cuda"
+// O0_DEBUG-SAME: "-dwarf-version=2"
+// O0_DEBUG-SAME: "-fopenmp-is-device"
+// O0_DEBUG: ptxas
+// O0_DEBUG-SAME: "-g"
+// O0_DEBUG-SAME: "--dont-merge-basicblocks"
+// O0_DEBUG-SAME: "--return-at-end"
+// O0_DEBUG: nvlink
+// O0_DEBUG-SAME: "-g"
+
+// 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=DEFAULT_O3_DEBUG %s
+
+// DEFAULT_O3_DEBUG: "-triple" "nvptx64-nvidia-cuda"
+// DEFAULT_O3_DEBUG-SAME: "-dwarf-version=2"
+// DEFAULT_O3_DEBUG-SAME: "-fopenmp-is-device"
+// DEFAULT_O3_DEBUG: ptxas
+// DEFAULT_O3_DEBUG-NOT: "-g"
+// DEFAULT_O3_DEBUG: nvlink
+// DEFAULT_O3_DEBUG-NOT: "-g"
+
+// 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=O3_NO_DEBUG %s
+
+// O3_NO_DEBUG: "-triple" "nvptx64-nvidia-cuda"
+// O3_NO_DEBUG-SAME: "-dwarf-version=2"
+// O3_NO_DEBUG-SAME: "-fopenmp-is-device"
+// O3_NO_DEBUG: ptxas
+// O3_NO_DEBUG-NOT: "-g"
+// O3_NO_DEBUG: nvlink
+// O3_NO_DEBUG-NOT: "-g"
+
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --cuda-noopt-device-debug 2>&1 \
+// RUN:   | FileCheck -check-prefix=O3_DEBUG %s
+
+// O3_DEBUG: "-triple" "nvptx64-nvidia-cuda"
+// O3_DEBUG-SAME: "-dwarf-version=2"
+// O3_DEBUG-SAME: "-fopenmp-is-device"
+// O3_DEBUG: ptxas
+// O3_DEBUG-SAME: "-g"
+// O3_DEBUG-SAME: "--dont-merge-basicblocks"
+// O3_DEBUG-SAME: "--return-at-end"
+// O3_DEBUG: nvlink
+// O3_DEBUG-SAME: "-g"
+
Index: test/Driver/cuda-dwarf-2.cu
===
--- /dev/null
+++ test/Driver/cuda-dwarf-2.cu
@@ -0,0 +1,66 @@
+// REQUIRES: clang-driver
+//
+// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -g 2>&1 | \
+// RUN:   FileCheck %s -check-prefix DEFAULT
+
+// DEFAULT: "-fcuda-is-device"
+// DEFAULT-SAME: "-dwarf-version=2"
+// DEFAULT: ptxas
+// DEFAULT-NOT: "-g"
+// DEFAULT: fatbinary
+// DEFAULT-NOT: "-g"
+
+// 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 O0_NO_DEBUG
+
+// O0_NO_DEBUG: "-fcuda-is-device"
+// O0_NO_DEBUG-SAME: "-dwarf-version=2"
+// O0_NO_DEBUG: ptxas
+// O0_NO_DEBUG-NOT: "-g"
+// O0_NO_DEBUG: fatbinary
+// O0_NO_DEBUG-NOT: "-g"
+
+// 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 O0_DEBUG
+
+// O0_DEBUG: "-fcuda-is-device"
+// O0_DEBUG-SAME: "-dwarf-version=2"
+// O0_DEBUG: ptxas
+// O0_DEBUG-SAME: "-g"
+// O0_DEBUG-SAME: "--dont-merge-basicblocks"
+// O0_DEBUG-SAME: "--return-at-end"
+// O0_DEBUG: fatbinary
+// O0_DEBUG-SAME: "-g"
+