Bug 41064 - [4.4 Regression]: build breakage for cris-elf building newlib, ICE in extract_insn, from r150726
Summary: [4.4 Regression]: build breakage for cris-elf building newlib, ICE in extract...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Hans-Peter Nilsson
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: build, ice-on-valid-code, patch
Depends on:
Blocks: 40414
  Show dependency treegraph
 
Reported: 2009-08-14 01:21 UTC by Hans-Peter Nilsson
Modified: 2010-05-11 17:17 UTC (History)
3 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: cris-axis-elf
Build:
Known to work: 4.5.0
Known to fail: 4.4.0
Last reconfirmed: 2009-08-14 02:19:34


Attachments
preprocessed, non-reduced test-case (8.39 KB, text/plain)
2009-08-14 01:22 UTC, Hans-Peter Nilsson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Peter Nilsson 2009-08-14 01:21:12 UTC
This bug was hidden at the time of its introduction by PR41031.

With revision 150725 plus the patch at <http://gcc.gnu.org/ml/gcc-patches/2009-08/msg00615.html> a build was successful with reasonable test-results.
From revision 150726 plus the same patch a build failed as follows.
The build failure was fully exposed (no local patches needed) from revision 150702 and on (when the equivalent patch was committed):

/tmp/hpautotest-gcc1/cris-elf/gccobj/./gcc/xgcc -B/tmp/hpautotest-gcc1/cris-elf/gccobj/./gcc/ -nostdinc -B/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/v32/newlib/ -isystem /tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/v32/newlib/targ-include -isystem /tmp/hpautotest-gcc1/gcc/newlib/libc/include -B/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/v32/libgloss/cris -L/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/v32/libgloss/libnosys -L/tmp/hpautotest-gcc1/gcc/libgloss/cris -B/tmp/hpautotest-gcc1/cris-elf/pre/cris-elf/bin/ -B/tmp/hpautotest-gcc1/cris-elf/pre/cris-elf/lib/ -isystem /tmp/hpautotest-gcc1/cris-elf/pre/cris-elf/include -isystem /tmp/hpautotest-gcc1/cris-elf/pre/cris-elf/sys-include  -march=v32 -mbest-lib-options -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"1.17.0\" -DPACKAGE_STRING=\"newlib\ 1.17.0\" -DPACKAGE_BUGREPORT=\"\"  -I. -I/tmp/hpautotest-gcc1/gcc/newlib/libc/search -O2 -DHAVE_RENAME -D_USE_WRITE -DCOMPACT_CTYPE -fno-builtin      -g -O2  -march=v32 -mbest-lib-options -c -o lib_a-hash_bigkey.o `test -f 'hash_bigkey.c' || echo '/tmp/hpautotest-gcc1/gcc/newlib/libc/search/'`hash_bigkey.c
/tmp/hpautotest-gcc1/gcc/newlib/libc/search/hash_bigkey.c: In function '__big_insert':
/tmp/hpautotest-gcc1/gcc/newlib/libc/search/hash_bigkey.c:175:1: error: unrecognizable insn:
(insn 22 392 25 2 /tmp/hpautotest-gcc1/gcc/newlib/libc/search/hash_bigkey.c:105 (set (reg/v/f:SI 8 r8 [orig:41 val_data ] [41])
        (mem/s/f:SI (post_inc:SI (reg:SI 15 acr)) [15 val_30(D)->data+0 S4 A8])) -1 (expr_list:REG_INC (reg:SI 15 acr)
        (nil)))
/tmp/hpautotest-gcc1/gcc/newlib/libc/search/hash_bigkey.c:175:1: internal compiler error: in extract_insn, at recog.c:2089
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[8]: *** [lib_a-hash_bigkey.o] Error 1
make[8]: Leaving directory `/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/v32/newlib/libc/search'

Author of patch CC:ed.  The invalidity is the post_inc on R15, a register which cannot be post-incremented.

A brief look with gdb reveals the immediate cause of the ICE is the extract_insn call in the context of the change of revision 150726. Applying it to a non-recognizable insn, a no-no. I don't quite understand why this didn't also happen before revision 150726 as the same call was there then too, but I'll have another look.

Preprocessed code to be attached.
Comment 1 Hans-Peter Nilsson 2009-08-14 01:22:48 UTC
Created attachment 18362 [details]
preprocessed, non-reduced test-case

Compile with -march=v32 -O2
Comment 2 Hans-Peter Nilsson 2009-08-14 02:19:33 UTC
(In reply to comment #0)
> A brief look with gdb reveals the immediate cause of the ICE is the
> extract_insn call in the context of the change of revision 150726. Applying it
> to a non-recognizable insn, a no-no. I don't quite understand why this didn't
> also happen before revision 150726 as the same call was there then too,

A major difference between validate_replace_rtx (r150725) and
validate_replace_rtx_group (r150726) that's called just before extract_insn for both revisions is that validate_replace_rtx restores replacements if they are seen as invalid, so the extract_insn only happens for a this-far-known valid and recognizable insn.  So, assuming that r150726 is otherwise correct, it needs to be adjusted with this patch (moving the extract_insn call to inside the truth-arm of the validity-test that follows plus a warning comment):

Index: reload1.c
===================================================================
--- reload1.c	(revision 150626)
+++ reload1.c	(working copy)
@@ -4312,10 +4312,15 @@
 			      n = verify_changes (0);
 
 			      /* We must also verify that the constraints
-				 are met after the replacement.  */
-			      extract_insn (p);
+				 are met after the replacement.  Make sure
+				 extract_insn is only called for an insn
+				 where the replacements were found to be
+				 valid so far. */
 			      if (n)
-				n = constrain_operands (1);
+				{
+				  extract_insn (p);
+				  n = constrain_operands (1);
+				}
 
 			      /* If the constraints were not met, then
 				 undo the replacement, else confirm it.  */

I'm going to test this and submit it.
Comment 3 Hans-Peter Nilsson 2009-08-14 10:33:13 UTC
patch posted.
Comment 4 Hans-Peter Nilsson 2009-08-14 11:37:03 UTC
Subject: Bug 41064

Author: hp
Date: Fri Aug 14 11:36:45 2009
New Revision: 150751

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150751
Log:
	PR rtl-optimization/41064
	* reload1.c (reload_as_needed): Don't call extract_insn
	for known invalid replacements after calling
	validate_replace_rtx_group and verify_changes.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/reload1.c

Comment 5 Hans-Peter Nilsson 2009-08-14 11:39:03 UTC
.
Comment 6 Paolo Bonzini 2009-12-29 19:29:42 UTC
Causes PR40414 on GCC 4.4.x, reopening to make the other PR depend on this.
Comment 7 Richard Biener 2010-05-11 13:38:10 UTC
Not sure what's the state here.  Is 4.4 broken now?
Comment 8 Ulrich Weigand 2010-05-11 13:57:12 UTC
(In reply to comment #7)
> Not sure what's the state here.  Is 4.4 broken now?

Here's the status as far as I know.  I had checked in a patch:
http://gcc.gnu.org/ml/gcc-patches/2009-08/msg00254.html
to fix the problem PR 37053.  This patch introduced the regression
described in the current problem, fixed by Hans-Peter's patch above.

Now, *both* my PR 37053 patch and Hans-Peter's patch were checked in
only to mainline (i.e. GCC 4.5); GCC 4.4 should not be affected either
way.  However, this means the original problem in PR 37053 is still
present in GCC 4.4.  And in fact, it may well be the case that the
problem described in PR 40414 is actually a duplicate of PR 37053.

In this case, I guess the way to go would be to apply *both* my patch
and Hans-Peter's patch to the 4.4 branch ...




Comment 9 Hans-Peter Nilsson 2010-05-11 16:48:40 UTC
(In reply to comment #8)
> In this case, I guess the way to go would be to apply *both* my patch
> and Hans-Peter's patch to the 4.4 branch ...

I'm sorry I missed that the committed patch was fingered as a regressor (sp?).  Anyway the above approach sounds right.
The 4.4 branch results looks good for cris-elf in my autotester FWIW.
Comment 10 Hans-Peter Nilsson 2010-05-11 17:06:25 UTC
(In reply to comment #6)
> Causes PR40414 on GCC 4.4.x, reopening to make the other PR depend on this.

Looks like the above statement is wrong: the committed patch for this PR is just (one of the two) required for PR40414.  I'm closing this as there's no reason to hold *this* PR open regardless of the state of PR40414.
Comment 11 Hans-Peter Nilsson 2010-05-11 17:17:04 UTC
Changing back target milestone to reflect the earliest release known to have the fix.