[Bug target/61586] ICE on alpha in alpha_handle_trap_shadows, at config/alpha/alpha.c:8724

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 24 17:54:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61586

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Uroš Bizjak from comment #1)
> (In reply to Michael Cree from comment #0)
> 
> > I wonder if this ICE is related in any way to bug 56858.
> 
> No, this one is different. The function trips on (barrier) that follows
> __builtin_trap. Expand will create:
> 
> ;; __builtin_trap ();
> 
> (insn 668 667 669 (trap_if (const_int 1 [0x1])
>         (const_int 0 [0])) -1
>      (nil))
> 
> (barrier 669 668 0)
> 
> 
> (gdb) up
> #2  0x0000000000be59e6 in alpha_handle_trap_shadows () at
> /home/uros/gcc-svn/trunk/gcc/config/alpha/alpha.c:8790
> 8790                          gcc_unreachable ();
> (gdb) list
> 8785                        case CALL_INSN:
> 8786                        case CODE_LABEL:
> 8787                          goto close_shadow;
> 8788
> 8789                        default:
> 8790                          gcc_unreachable ();
> 8791                        }
> 8792                    }
> 8793                  else
> 8794                    {
> 
> (gdb) p debug_rtx (i)
> (barrier 669 668 1514)
> 
> Probably __builtin_trap should close trap shadow here. Let's ask rth.

Something like following (untested) patch:

--cut here--
Index: alpha.c
===================================================================
--- alpha.c     (revision 211941)
+++ alpha.c     (working copy)
@@ -8685,8 +8749,12 @@
                      /* Annoyingly, get_attr_trap will die on these.  */
                      if (GET_CODE (PATTERN (i)) == USE
                          || GET_CODE (PATTERN (i)) == CLOBBER)
-                       break;
+                       continue;

+                     /* This is BUGCHK insn, no need to emit trapb.  */
+                     if (GET_CODE (PATTERN (i)) == TRAP_IF)
+                       goto close_shadow_notrapb;
+
                      summarize_insn (PATTERN (i), &sum, 0);

                      if ((sum.defd.i & shadow.defd.i)
@@ -8732,6 +8800,7 @@
                  n = emit_insn_before (gen_trapb (), i);
                  PUT_MODE (n, TImode);
                  PUT_MODE (i, TImode);
+               close_shadow_notrapb:
                  trap_pending = 0;
                  shadow.used.i = 0;
                  shadow.used.fp = 0;
--cut here--

(I also wonder why we have to break the loop for naked USEs and CLOBBERs. We
should just skip the problematic insn and continue - as proposed in the above
patch).


More information about the Gcc-bugs mailing list