[og7] Backport "[nvptx] Add exit after call to noreturn function"

Message ID 289216ae-113e-282d-116b-e35443c511da@mentor.com
State New
Headers show
Series
  • [og7] Backport "[nvptx] Add exit after call to noreturn function"
Related show

Commit Message

Tom de Vries April 16, 2018, 8:07 p.m.
Hi,

while investigating PR85381 - "[og7, nvptx, openacc] parallel-loop-1.c 
fails with default vector length 128", I ran into PR 80035/81069.

I've backported the fix to the og7 branch.

Thanks,
- Tom

Patch

Backport "[nvptx] Add exit after call to noreturn function"

2018-04-16  Tom de Vries  <tom@codesourcery.com>

	backport from trunk:
	2017-09-25  Tom de Vries  <tom@codesourcery.com>

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

---
 gcc/config/nvptx/nvptx.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 9d011eb..8c478c8 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -2387,11 +2387,14 @@  nvptx_output_call_insn (rtx_insn *insn, rtx result, rtx callee)
   fprintf (asm_out_file, ";\n");
 
   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");
+    {
+      /* 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 and exit, which it does grok.  */
+      fprintf (asm_out_file, "\t\ttrap; // (noreturn)\n");
+      fprintf (asm_out_file, "\t\texit; // (noreturn)\n");
+    }
 
   if (result)
     {