http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48178

           Summary: ICE in dwarf2out_var_location, at dwarf2out.c:21969
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: kkoj...@gcc.gnu.org


On SH, gcc.c-torture/compile/sync-2.c fails with

  internal compiler error: in dwarf2out_var_location, at dwarf2out.c:21969

It seems that dwarf2out_var_location assumes the previous insn
of the loc_note insn is a call or sequence insn, but for
the problematic case, it's an unspec insn for the constant pool:

(gdb) call debug_rtx(prev)
(insn 603 602 604 (unspec_volatile [
            (const_int 0 [0])
        ] 11) 295 {consttable_end}
     (nil))

at the failed gcc_assert

21965          gcc_assert (prev
21966              && (CALL_P (prev)
21967                  || (NONJUMP_INSN_P (prev)
21968                  && GET_CODE (PATTERN (prev)) == SEQUENCE
21969                  && CALL_P (XVECEXP (PATTERN (prev), 0, 0)))));

The patch below looks to work for me, though I'm not sure that
it's the right thing to do.

--- ORIG/trunk/gcc/dwarf2out.c    2011-03-17 09:06:42.000000000 +0900
+++ LOCAL/trunk/gcc/dwarf2out.c    2011-03-17 13:03:39.000000000 +0900
@@ -21962,11 +21962,17 @@ dwarf2out_var_location (rtx loc_note)
       ca_loc->call_arg_loc_note = loc_note;
       ca_loc->next = NULL;
       ca_loc->label = last_label;
-      gcc_assert (prev
-          && (CALL_P (prev)
-              || (NONJUMP_INSN_P (prev)
-              && GET_CODE (PATTERN (prev)) == SEQUENCE
-              && CALL_P (XVECEXP (PATTERN (prev), 0, 0)))));
+      while (prev)
+    {
+      if (CALL_P (prev)
+          || (NONJUMP_INSN_P (prev)
+          && GET_CODE (PATTERN (prev)) == SEQUENCE
+          && CALL_P (XVECEXP (PATTERN (prev), 0, 0))))
+        break;
+      else
+        prev = prev_real_insn (prev);
+    }
+      gcc_assert (prev);
       if (!CALL_P (prev))
     prev = XVECEXP (PATTERN (prev), 0, 0);
       ca_loc->tail_call_p = SIBLING_CALL_P (prev);

Reply via email to