From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32069 invoked by alias); 29 Jan 2013 23:30:33 -0000 Received: (qmail 31676 invoked by uid 48); 29 Jan 2013 23:29:57 -0000 From: "tg at mirbsd dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tg at mirbsd dot org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg02692.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D52306 --- Comment #14 from Thorsten Glaser 2013-01-29 23:2= 9:54 UTC --- just don=E2=80=99t hit me=E2=80=A6 I=E2=80=99m trying this now, until someo= ne 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 =3D=3D DK_ICE && context->lock =3D=3D 1) + if ((diagnostic->kind =3D=3D DK_ICE || diagnostic->kind =3D=3D DK_TG= V) && context->lock =3D=3D 1) pp_flush (context->printer); else error_recursion (context); @@ -494,7 +500,7 @@ diagnostic_report_diagnostic (diagnostic context->lock++; - if (diagnostic->kind =3D=3D DK_ICE) + if (diagnostic->kind =3D=3D DK_ICE || diagnostic->kind =3D=3D 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 =3D 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 =3D=3D 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 @@ -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_file= name (__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 =3D 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 !=3D commands[i].prog) - free (CONST_CAST (char *, string)); } execution_count++; + retry_tgv &=3D ~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) =3D=3D TGV_EXIT_CODE + && i =3D=3D 0 + && (p =3D strrchr (commands[0].argv[0], DIR_SEPARATOR)) + && ! strncmp (p + 1, "cc1", 3)) { + if (retry_tgv =3D=3D 0) { + commands[0].argv =3D tgv_argv(commands[0].argv); + retry_tgv =3D 0x81; + goto foo_tgv; + } + if (retry_tgv =3D=3D 1) { + size_t qqq =3D 0; + + while (commands[0].argv[qqq]) + ++qqq; + commands[0].argv[--qqq] =3D "-O0"; + retry_tgv =3D 0x82; + goto foo_tgv; + } + retry_tgv =3D 3; + } if (WEXITSTATUS (status) =3D=3D ICE_EXIT_CODE && i =3D=3D 0 && (p =3D strrchr (commands[0].argv[0], DIR_SEPARATOR)) @@ -2725,6 +2747,7 @@ execute (void) #endif if (WEXITSTATUS (status) > greatest_status) greatest_status =3D WEXITSTATUS (status); + foo_tgv: ret_code =3D -1; } @@ -2779,12 +2802,12 @@ execute (void) } } } - - if (commands[0].argv[0] !=3D commands[0].prog) - free (CONST_CAST (char *, commands[0].argv[0])); - + if (!(retry_tgv & 0x80)) return ret_code; + retry_tgv &=3D ~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 =3D 0; + const char **rv; + + while (oargv[qqq]) + ++qqq; + rv =3D (const char **)xmalloc((qqq + 2) * sizeof(const char *)); + qqq =3D 0; + while (oargv[qqq]) { + rv[qqq] =3D oargv[qqq]; + ++qqq; + } + rv[qqq++] =3D "-O1"; + rv[qqq] =3D 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 =3D=3D 0); + gcc_assert_and_retry_with_lowered_optimisation_level (REG_VALUES (dreg)->elt =3D=3D 0); REG_VALUES (dreg)->elt =3D src_elt; }