[Bug target/80035] [nvptx] non-returning function call causes ptxas sigsegv

2017-09-25 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80035

--- Comment #7 from Tom de Vries  ---
Author: vries
Date: Mon Sep 25 10:36:23 2017
New Revision: 253145

URL: https://gcc.gnu.org/viewcvs?rev=253145&root=gcc&view=rev
Log:
[nvptx] Add exit after call to noreturn function

2017-09-25  Tom de Vries  

PR target/80035
PR target/81069
* config/nvptx/nvptx.c (nvptx_output_call_insn): Add exit after call to
noreturn function.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/nvptx/nvptx.c

[Bug target/80035] [nvptx] non-returning function call causes ptxas sigsegv

2017-09-25 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80035

Tom de Vries  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from Tom de Vries  ---
patch committed, marking resolved-fixed.

[Bug target/80035] [nvptx] non-returning function call causes ptxas sigsegv

2017-08-28 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80035

--- Comment #6 from Tom de Vries  ---
(In reply to Tom de Vries from comment #2)
> Replacing trap with exit or ret (or adding it after trap), makes the sigsegv
> go away.

Nvidia suggested a workaround of adding exit after trap for this (PR81069
comment 3) bug report.

[Bug target/80035] [nvptx] non-returning function call causes ptxas sigsegv

2017-03-13 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80035

--- Comment #1 from Tom de Vries  ---
Created attachment 40965
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40965&action=edit
pr58640.s

[Bug target/80035] [nvptx] non-returning function call causes ptxas sigsegv

2017-03-13 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80035

Tom de Vries  changed:

   What|Removed |Added

 CC||tschwinge at gcc dot gnu.org

--- Comment #2 from Tom de Vries  ---
>   {
>   .param.u32 %out_arg1;
>   st.param.u32 [%out_arg1], %r31;
>   call exit, (%out_arg1);
>   trap; // (noreturn)
>   }

At nvptx_output_call_insn, we see:
...
  if (find_reg_note (insn, REG_NORETURN, NULL))
/* No return functions confuse the PTX JIT, as it doesn't realize   
   the flow control barrier they imply.  It can seg fault if it 
   encounters what looks like an unexitable loop.  Emit a trailing  
   trap, which it does grok.  */
fprintf (asm_out_file, "\t\ttrap; // (noreturn)\n");
...

Replacing trap with exit or ret (or adding it after trap), makes the sigsegv go
away.

[Bug target/80035] [nvptx] non-returning function call causes ptxas sigsegv

2017-03-14 Thread amonakov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80035

Alexander Monakov  changed:

   What|Removed |Added

 CC||amonakov at gcc dot gnu.org

--- Comment #3 from Alexander Monakov  ---
Noreturn is a bit of a distraction.  On the one hand, yes, on this and related
testcases it may be possible to workaround things more successfully on the gcc
side, when gcc knows that the callee _never_ returns.  On the other hand, the
real issue is that ptxas gets confused around loops lacking exit edges (and
perhaps other "unusual" CFG structures). They can easily appear even in
original source and do not require presence of noreturn functions:

extern __device__ void g();
extern __device__ void h();
__device__ void f(int v)
{
  if (v) goto L;
  for (;;) {
g();
L:
h();
  }
}

This minimized testcase leads to ptxas segfault with nvcc, so they are not
immune either. And here a compiler can't do anything to make code more
digestible to ptxas, afaict, so it really should be fixed in ptxas.

FWIW, it seems to work with -arch sm_50, so it might be fixed for newer
architectures (I suspect CUDA driver and toolkit carry separate code generators
for sm_3x and sm_5x).

Can you share if you (Mentor Embeddded) reported such issues to NVIDIA in the
past?

[Bug target/80035] [nvptx] non-returning function call causes ptxas sigsegv

2017-03-14 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80035

--- Comment #4 from Tom de Vries  ---
(In reply to Tom de Vries from comment #2)
> Replacing trap with exit or ret (or adding it after trap), makes the sigsegv
> go away.

This problem goes away for ptxas -ori starting cuda 7.0.

[Bug target/80035] [nvptx] non-returning function call causes ptxas sigsegv

2017-03-14 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80035

--- Comment #5 from Tom de Vries  ---
(In reply to Alexander Monakov from comment #3)
> ptxas gets confused around loops lacking
> exit edges (and perhaps other "unusual" CFG structures). They can easily
> appear even in original source and do not require presence of noreturn
> functions:
> 
> extern __device__ void g();
> extern __device__ void h();
> __device__ void f(int v)
> {
>   if (v) goto L;
>   for (;;) {
> g();
> L:
> h();
>   }
> }
> 

This problem goes away for ptxas -ori in cuda 6.5 and later (haven't tried
earlier versions).

[Bug target/80035] [nvptx] non-returning function call causes ptxas sigsegv

2017-03-15 Thread tschwinge at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80035

Thomas Schwinge  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2017-03-15
   Assignee|unassigned at gcc dot gnu.org  |vries at gcc dot gnu.org
 Ever confirmed|0   |1