public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tg at mirbsd dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/52306] ICE in cselib_record_set, at cselib.c:2158
Date: Tue, 29 Jan 2013 23:30:00 -0000	[thread overview]
Message-ID: <bug-52306-4-xDj76qJ55G@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-52306-4@http.gcc.gnu.org/bugzilla/>


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

--- Comment #14 from Thorsten Glaser <tg at mirbsd dot org> 2013-01-29 23:29:54 UTC ---
just don’t hit me… I’m trying this now, until someone fixes this PR:

# DP: retry a known ICE with -O1 then -O0 in case it gets better

--- a/src/gcc/diagnostic.c
+++ b/src/gcc/diagnostic.c
@@ -242,6 +242,12 @@ diagnostic_action_after_output (diagnost
            "See %s for instructions.\n", bug_report_url);
       exit (ICE_EXIT_CODE);

+    case DK_TGV:
+      fnotice (stderr, "Retrying with lowered optimisation,\n"
+           "this is a known bug, do not worry. If it'll\n"
+           "still fail, just fail the package build.\n");
+      exit (TGV_EXIT_CODE);
+
     case DK_FATAL:
       if (context->abort_on_error)
     real_abort ();
@@ -426,7 +432,7 @@ diagnostic_report_diagnostic (diagnostic
       /* If we're reporting an ICE in the middle of some other error,
      try to flush out the previous error, then let this one
      through.  Don't do this more than once.  */
-      if (diagnostic->kind == DK_ICE && context->lock == 1)
+      if ((diagnostic->kind == DK_ICE || diagnostic->kind == DK_TGV) &&
context->lock == 1)
     pp_flush (context->printer);
       else
     error_recursion (context);
@@ -494,7 +500,7 @@ diagnostic_report_diagnostic (diagnostic

   context->lock++;

-  if (diagnostic->kind == DK_ICE)
+  if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_TGV)
     {
 #ifndef ENABLE_CHECKING
       /* When not checking, ICEs are converted to fatal errors when an
@@ -507,7 +513,7 @@ diagnostic_report_diagnostic (diagnostic
       expanded_location s = expand_location (diagnostic->location);
       fnotice (stderr, "%s:%d: confused by earlier errors, bailing out\n",
            s.file, s.line);
-      exit (ICE_EXIT_CODE);
+      exit (diagnostic->kind == DK_TGV ? TGV_EXIT_CODE : ICE_EXIT_CODE);
     }
 #endif
       if (context->internal_error)
@@ -902,3 +908,17 @@ real_abort (void)
 {
   abort ();
 }
+
+void
+tgv_abort (const char *gmsgid, ...)
+{
+  diagnostic_info diagnostic;
+  va_list ap;
+
+  va_start (ap, gmsgid);
+  diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location, DK_TGV);
+  report_diagnostic (&diagnostic);
+  va_end (ap);
+
+  gcc_unreachable ();
+}
--- a/src/gcc/diagnostic.def
+++ b/src/gcc/diagnostic.def
@@ -43,3 +43,4 @@ prefix does not matter.  */
 DEFINE_DIAGNOSTIC_KIND (DK_PEDWARN, "pedwarn: ")
 DEFINE_DIAGNOSTIC_KIND (DK_PERMERROR, "permerror: ")

+DEFINE_DIAGNOSTIC_KIND (DK_TGV, "internal compiler error: ")
--- a/src/gcc/system.h
+++ b/src/gcc/system.h
@@ -235,6 +235,7 @@ extern int errno;
 #endif

 #define ICE_EXIT_CODE 4
+#define TGV_EXIT_CODE 23

 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
@@ -642,6 +643,15 @@ extern void fancy_abort (const char *, i
 #define gcc_assert(EXPR) ((void)(0 && (EXPR)))
 #endif

+extern void tgv_abort (const char *, ...) ATTRIBUTE_NORETURN;
+#if ENABLE_ASSERT_CHECKING
+#define gcc_assert_and_retry_with_lowered_optimisation_level(EXPR)     \
+   ((void)(!(EXPR) ? tgv_abort ("in %s, at %s:%d", __FUNCTION__, trim_filename
(__FILE__), __LINE__), 0 : 0))
+#else
+#define gcc_assert_and_retry_with_lowered_optimisation_level(EXPR)    \
+   gcc_assert (EXPR)
+#endif
+
 #ifdef ENABLE_CHECKING
 #define gcc_checking_assert(EXPR) gcc_assert (EXPR)
 #else
--- a/src/gcc/gcc.c
+++ b/src/gcc/gcc.c
@@ -253,6 +253,7 @@ static const char *convert_filename (con
 #if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
 static void retry_ice (const char *prog, const char **argv);
 #endif
+static const char **tgv_argv(const char **);

 static const char *getenv_spec_function (int, const char **);
 static const char *if_exists_spec_function (int, const char **);
@@ -2464,6 +2465,7 @@ execute (void)
 {
   int i;
   int n_commands;        /* # of command.  */
+  int retry_tgv = 0;
   char *string;
   struct pex_obj *pex;
   struct command
@@ -2529,7 +2531,8 @@ execute (void)

   /* If -v, print what we are about to do, and maybe query.  */

-  if (verbose_flag)
+  do {
+  if (verbose_flag || retry_tgv)
     {
       /* For help listings, put a blank line between sub-processes.  */
       if (print_help_list)
@@ -2659,13 +2662,12 @@ execute (void)
           pfatal_with_name (errmsg);
         }
     }
-
-      if (i && string != commands[i].prog)
-    free (CONST_CAST (char *, string));
     }

   execution_count++;

+  retry_tgv &= ~0x80;
+
   /* Wait for all the subprocesses to finish.  */

   {
@@ -2717,6 +2719,26 @@ execute (void)
         /* For ICEs in cc1, cc1obj, cc1plus see if it is
            reproducible or not.  */
         const char *p;
+        if (WEXITSTATUS (status) == TGV_EXIT_CODE
+        && i == 0
+        && (p = strrchr (commands[0].argv[0], DIR_SEPARATOR))
+        && ! strncmp (p + 1, "cc1", 3)) {
+          if (retry_tgv == 0) {
+        commands[0].argv = tgv_argv(commands[0].argv);
+        retry_tgv = 0x81;
+        goto foo_tgv;
+              }
+              if (retry_tgv == 1) {
+        size_t qqq = 0;
+
+        while (commands[0].argv[qqq])
+          ++qqq;
+        commands[0].argv[--qqq] = "-O0";
+        retry_tgv = 0x82;
+        goto foo_tgv;
+              }
+          retry_tgv = 3;
+        }
         if (WEXITSTATUS (status) == ICE_EXIT_CODE
         && i == 0
         && (p = strrchr (commands[0].argv[0], DIR_SEPARATOR))
@@ -2725,6 +2747,7 @@ execute (void)
 #endif
         if (WEXITSTATUS (status) > greatest_status)
           greatest_status = WEXITSTATUS (status);
+ foo_tgv:
         ret_code = -1;
       }

@@ -2779,12 +2802,12 @@ execute (void)
           }
       }
       }
-
-    if (commands[0].argv[0] != commands[0].prog)
-      free (CONST_CAST (char *, commands[0].argv[0]));
-
+   if (!(retry_tgv & 0x80))
     return ret_code;
+   retry_tgv &= ~0x80;
   }
+  } while (retry_tgv < 3);
+  return TGV_EXIT_CODE;
 }

 /* Find all the switches given to us
@@ -8587,3 +8610,22 @@ pass_through_libs_spec_func (int argc, c
     }
   return prepended;
 }
+
+static const char **
+tgv_argv(const char **oargv)
+{
+    size_t qqq = 0;
+    const char **rv;
+
+    while (oargv[qqq])
+        ++qqq;
+    rv = (const char **)xmalloc((qqq + 2) * sizeof(const char *));
+    qqq = 0;
+    while (oargv[qqq]) {
+        rv[qqq] = oargv[qqq];
+        ++qqq;
+    }
+    rv[qqq++] = "-O1";
+    rv[qqq] = NULL;
+    return (rv);
+}
--- a/src/gcc/cselib.c
+++ b/src/gcc/cselib.c
@@ -2155,7 +2155,7 @@ cselib_record_set (rtx dest, cselib_val
       else
     {
       /* The register should have been invalidated.  */
-      gcc_assert (REG_VALUES (dreg)->elt == 0);
+      gcc_assert_and_retry_with_lowered_optimisation_level (REG_VALUES
(dreg)->elt == 0);
       REG_VALUES (dreg)->elt = src_elt;
     }


  parent reply	other threads:[~2013-01-29 23:30 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-18 23:32 [Bug middle-end/52306] New: ICE in CSE tg at mirbsd dot org
2012-03-25 12:47 ` [Bug middle-end/52306] " aoliva at gcc dot gnu.org
2012-03-25 13:51 ` aoliva at gcc dot gnu.org
2012-05-06 14:29 ` tg at mirbsd dot org
2012-05-06 17:05 ` tg at mirbsd dot org
2012-12-04  9:27 ` tg at mirbsd dot org
2012-12-04 10:29 ` mikpe at it dot uu.se
2012-12-04 12:59 ` tg at mirbsd dot org
2012-12-04 22:06 ` mikpe at it dot uu.se
2012-12-06  9:50 ` mikpe at it dot uu.se
2012-12-06  9:53 ` jakub at gcc dot gnu.org
2012-12-24  0:53 ` tg at mirbsd dot org
2013-01-29 21:17 ` [Bug middle-end/52306] ICE in cselib_record_set, at cselib.c:2158 tg at mirbsd dot org
2013-01-29 21:26 ` tg at mirbsd dot org
2013-01-29 23:30 ` tg at mirbsd dot org [this message]
2013-01-30 17:34 ` mikpe at it dot uu.se
2013-01-30 17:50 ` mikpe at it dot uu.se
2013-02-06 23:25 ` mikpe at it dot uu.se
2013-02-07  8:14 ` jakub at gcc dot gnu.org
2013-08-17 17:31 ` tg at mirbsd dot org
2013-08-17 18:44 ` tg at mirbsd dot org
2013-08-22 16:28 ` tg at mirbsd dot org
2013-12-19  9:02 ` schwab@linux-m68k.org
2013-12-19 10:40 ` mikpelinux at gmail dot com
2013-12-19 11:12 ` [Bug middle-end/52306] [4.8/4.9 regression] " ebotcazou at gcc dot gnu.org
2013-12-19 11:22 ` schwab@linux-m68k.org
2013-12-19 11:28 ` amker.cheng at gmail dot com
2013-12-19 15:18 ` rguenth at gcc dot gnu.org
2014-02-10  5:37 ` law at redhat dot com
2014-02-10 16:26 ` [Bug middle-end/52306] [4.8 " law at redhat dot com
2014-02-10 16:26 ` [Bug middle-end/52306] [4.8/4.9 " law at gcc dot gnu.org
2014-02-19 22:02 ` [Bug middle-end/52306] [4.8 " schwab@linux-m68k.org
2014-02-23 14:21 ` mikpelinux at gmail dot com
2014-05-22  9:07 ` rguenth at gcc dot gnu.org
2014-12-19 13:44 ` jakub at gcc dot gnu.org
2015-01-19 22:34 ` law at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-52306-4-xDj76qJ55G@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).