Bug 21638 - [4.1 regression] ADDR_EXPR invariancy not recomputed
Summary: [4.1 regression] ADDR_EXPR invariancy not recomputed
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Andrew Pinski
URL:
Keywords: ice-on-valid-code
: 21648 21780 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-05-17 23:35 UTC by Hans-Peter Nilsson
Modified: 2005-06-05 07:56 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-05-18 12:34:06


Attachments
Preprocessed code (11.38 KB, text/plain)
2005-05-18 09:34 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 2005-05-17 23:35:11 UTC
With LAST_UPDATED: "Tue May 17 13:57:35 UTC 2005" in a unified tree, it
built (with one new test failing compared to "Tue May 17 06:38:21 UTC 2005").
With "Tue May 17 19:08:13 UTC 2005", I get:
...
/home/hp/combined/cris-sim/./gcc/xgcc -B/home/hp/combined/cris-sim/./gcc/
-nostdinc -B/home/hp/combined/cris-sim/cris-elf/v10/new\
lib/ -isystem /home/hp/combined/cris-sim/cris-elf/v10/newlib/targ-include
-isystem /home/hp/combined/combined/newlib/libc/include\
 -B/usr/local/cris-elf/bin/ -B/usr/local/cris-elf/lib/ -isystem
/usr/local/cris-elf/include -isystem /usr/local/cris-elf/sys-incl\
ude -L/home/hp/combined/cris-sim/./ld  -march=v10 -mbest-lib-options
-DPACKAGE=\"newlib\" -DVERSION=\"1.13.0\"  -I. -I/home/hp/co\
mbined/combined/newlib/libc/search  -O2 -DHAVE_RENAME -DHAVE_GETTIMEOFDAY
-D_USE_WRITE -DCOMPACT_CTYPE -fno-builtin      -O2 -g -\
O2  -march=v10 -mbest-lib-options -c
/home/hp/combined/combined/newlib/libc/search/hash.c
/home/hp/combined/combined/newlib/libc/search/hash.c: In function 'flush_meta':
/home/hp/combined/combined/newlib/libc/search/hash.c:515: internal compiler
error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make[9]: *** [hash.o] Error 1
make[9]: Leaving directory
`/home/hp/combined/cris-sim/cris-elf/v10/newlib/libc/search'

In gdb:
Program received signal SIGSEGV, Segmentation fault.
0x080bb70a in is_gimple_reg_type (type=0x0) at
/home/hp/combined/combined/gcc/tree-gimple.c:263
(gdb) bt
#0  0x080bb70a in is_gimple_reg_type (type=0x0) at
/home/hp/combined/combined/gcc/tree-gimple.c:263
#1  0x080bb897 in is_gimple_val (t=0xb7ec0200) at
/home/hp/combined/combined/gcc/tree-gimple.c:353
#2  0x080a9c11 in verify_expr (tp=0xb7ecad7c, walk_subtrees=0xbffff784,
data=0x0)
    at /home/hp/combined/combined/gcc/tree-cfg.c:3403
#3  0x082a5d93 in walk_tree (tp=0xb7ecad7c, func=0x80a9730 <verify_expr>,
data=0x0, pset=0x0)
    at /home/hp/combined/combined/gcc/tree.c:6473
#4  0x080aa17f in verify_stmt (stmt=0xb7ea21b0, last_in_block=0 '\0') at
/home/hp/combined/combined/gcc/tree-cfg.c:3489
#5  0x080aa5fa in verify_stmts () at tree-flow-inline.h:710
#6  0x080b8586 in verify_ssa (check_modified_stmt=1 '\001') at
/home/hp/combined/combined/gcc/tree-ssa.c:649
#7  0x080ba9c2 in execute_todo (pass=0x83f8350, flags=295, use_required=0 '\0')
    at /home/hp/combined/combined/gcc/tree-optimize.c:558
#8  0x080babba in execute_one_pass (pass=0x83f8350) at
/home/hp/combined/combined/gcc/tree-optimize.c:634
#9  0x080bace1 in execute_pass_list (pass=0x83f8350) at
/home/hp/combined/combined/gcc/tree-optimize.c:656
#10 0x080bad05 in execute_pass_list (pass=0x83c2b00) at
/home/hp/combined/combined/gcc/tree-optimize.c:657
#11 0x080baf5a in tree_rest_of_compilation (fndecl=0xb7fc2a8c) at
/home/hp/combined/combined/gcc/tree-optimize.c:787
#12 0x08059766 in c_expand_body (fndecl=0xb7fc2a8c) at
/home/hp/combined/combined/gcc/c-decl.c:6572
#13 0x082d2bc0 in cgraph_expand_function (node=0xb7fdb144) at
/home/hp/combined/combined/gcc/cgraphunit.c:993
#14 0x082d2d34 in cgraph_expand_all_functions () at
/home/hp/combined/combined/gcc/cgraphunit.c:1057
#15 0x082d2f6d in cgraph_optimize () at
/home/hp/combined/combined/gcc/cgraphunit.c:1159
#16 0x08295966 in compile_file () at
/home/hp/combined/combined/gcc/toplev.c:1013
#17 0x08296c33 in do_compile () at /home/hp/combined/combined/gcc/toplev.c:2123
#18 0x08296c95 in toplev_main (argc=23, argv=0xbffffb74) at
/home/hp/combined/combined/gcc/toplev.c:2155
#19 0x0809dfe3 in main (argc=23, argv=0xbffffb74) at
/home/hp/combined/combined/gcc/main.c:35

With a few "During symbol reading, Incomplete CFI data; unspecified registers at
0x..." pruned.
Comment 1 Andrew Pinski 2005-05-18 06:11:57 UTC
There were two major patches which went in during this time.  The CFG inliner and the Jeff Law's patch, 
either could have caused this.
Comment 2 Giovanni Bajo 2005-05-18 09:09:22 UTC
We obviously need the preprocessed source.
Comment 3 Hans-Peter Nilsson 2005-05-18 09:28:49 UTC
In response to comment #2, this is a combined tree, so the sources are trivially
available for all and you shouldn't need to be handed preprocessed code
separately.  Having said that, I'll attach preprocessed versions hoping for a
quick resolution.
Comment 4 Hans-Peter Nilsson 2005-05-18 09:34:19 UTC
Created attachment 8919 [details]
Preprocessed code

Options to cc1 from -v: -fpreprocessed hash.i -melf -ffunction-sections
-fdata-sections -quiet -dumpbase hash.c -march=v10 -mbest-lib-options
-march=v10 -mbest-lib-options -auxbase hash -g -O2 -O2 -O2 -version
-fno-builtin -o hash.s

Shorter: -march=v10 -O2 -o hash.s -fpreprocessed hash.i
Comment 5 Giovanni Bajo 2005-05-18 12:02:34 UTC
(In reply to comment #3)

> In response to comment #2, this is a combined tree, so the
> sources are trivially available for all and you shouldn't need 
> to be handed preprocessed code separately.  

I am sorry but this is what our rules say. There is no exception for free code 
bases where the bugmaster/bugfixer could potentially download and build the 
package himself. Whoever reported the bug can surely build the preprocessed 
source much faster than who happens to see the report. I believe this is a 
sound rule.

> Having said that, I'll attach preprocessed versions hoping for a
> quick resolution.

Thanks.
Comment 6 Andrew Pinski 2005-05-18 12:11:26 UTC
Hmm, the SSA_NAME is in the free list for some reason.  
Comment 7 Andrew Pinski 2005-05-18 12:34:05 UTC
Confirmed, reduced testcase:
typedef struct hashhdr {
 int bitmaps[32];
} HASHHDR;

static void
swap_header_copy(HASHHDR *srcp, HASHHDR *destp)
{
  int i;
  for (i = 0; i < 32; i++)
    ((char *)&(destp->bitmaps[i]))[0] = ((char *)&(srcp->bitmaps[i]))[1];
}

int
flush_meta(HASHHDR *whdrp1)
{
 HASHHDR *whdrp;
 HASHHDR whdr;
 whdrp = &whdr;
 swap_header_copy(whdrp1, whdrp);
 return (0);
}
Comment 8 Andrew Pinski 2005-05-18 12:36:10 UTC
This is independent of target/host.  My testcase gives a different ICE:
pr21638.c:15: error: Definition in block 1 does not dominate use in block 0
for SSA_NAME: i.0_10 in statement:
D.1281_1 = &whdr.bitmaps[i.0_10];
pr21638.c:15: internal compiler error: verify_ssa failed.
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 9 Hans-Peter Nilsson 2005-05-18 16:01:42 UTC
In reply to comment #3:
No, I don't think your reading of what rules you refer to is "sane",
but then perhaps you're not used to building a unified tree for cross
toolchains, re: simtest-howto.html.  If you'd done that with any regularity,
then you'd have all the bits and would not see newlib as "free code bases to
download yourself".  I stand by this; I think it can be expected that people
test with cross toolchains, for better test coverage than just their "native"
machines.
Comment 10 Andrew Pinski 2005-05-18 18:09:56 UTC
(In reply to comment #9)
> In reply to comment #3:
Usually I just say "please attach it because I am too lazy to build an unified tree" instead of saying this 
goes against our rules.  Anyways I am trying to figure out a way to fix this, the problem is that forward 
prograte is making an ADDR_EXPR still invariant when it is obviously not.
Comment 11 Andrew Pinski 2005-05-18 18:13:49 UTC
Mine, I have a fix.
Comment 12 Andrew Pinski 2005-05-18 18:18:19 UTC
*** Bug 21648 has been marked as a duplicate of this bug. ***
Comment 13 Andrew Pinski 2005-05-18 22:02:32 UTC
Index: tree-ssa-forwprop.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-forwprop.c,v
retrieving revision 2.17
diff -u -p -r2.17 tree-ssa-forwprop.c
--- tree-ssa-forwprop.c	18 May 2005 16:49:49 -0000	2.17
+++ tree-ssa-forwprop.c	18 May 2005 22:02:21 -0000
@@ -495,6 +495,7 @@ forward_propagate_addr_into_variable_arr
   /* Replace the pointer addition with array indexing.  */
   TREE_OPERAND (use_stmt, 1) = unshare_expr (TREE_OPERAND (stmt, 1));
   TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (use_stmt, 1), 0), 1) = index;
+  recompute_tree_invarant_for_addr_expr (TREE_OPERAND (use_stmt, 1));
 
   /* That should have created gimple, so there is no need to
      record information to undo the propagation.  */
@@ -623,6 +624,8 @@ forward_propagate_addr_expr (tree stmt)
 	{
 	  mark_new_vars_to_rename (use_stmt);
 	  update_stmt (use_stmt);
+	  if (TREE_CODE (rhs) == ADDR_EXPR)
+	    recompute_tree_invarant_for_addr_expr (rhs);
 	  return true;
 	}
       else
Comment 14 Hans-Peter Nilsson 2005-05-19 03:42:28 UTC
The patch in comment #13 works; build completes for cris-elf and testsuite
results seem sane (same "new failures" as cris-axis-linux-gnu before this
patch).  Also tested on mmix-knuth-mmixware, no regressions (no changes at all).
Comment 15 Giovanni Bajo 2005-05-19 10:10:05 UTC
HP: people are expected to provide preprocessed source code even for bootstrap 
failures, let alone unified source tree builds for fancy platforms. This very 
bug shows how providing a preprocessed source made a quick fix possible.

So what are you exactly complaining for? If you want a bug fixed, be helpful 
like everybody does. The fact that you are a maintainer does not buy you to 
shortcut rules and expect people to do the work in your place.
Comment 16 Hans-Peter Nilsson 2005-05-19 14:07:10 UTC
Subject: Re:  [4.1 regression] ADDR_EXPR invariancy
 not recomputed

On Thu, 19 May 2005, giovannibajo at libero dot it wrote:
> ------- Additional Comments From giovannibajo at libero dot it  2005-05-19 10:10 -------
> HP: people are expected to provide preprocessed source code even for bootstrap
> failures, let alone unified source tree builds for fancy platforms. This very
> bug shows how providing a preprocessed source made a quick fix possible.

Certainly, but it would have been even quicker if people were
already having simulator toolchains at hand, for testing their
patches or to verify bugs.  Thus I somewhat thought all
"bugmasters" would be familiar enough with them; hopefully using
them, but at least not one accusing me that I "shortcut rules"
when not immediately providing preprocessed source for a target
library there.

Newlib *is* special; it's part of the toolchain and builds
naturally together with simulator, binutils and gcc in one fell
swoop.  Much like one of the target libraries provided with gcc.
Would you ask people for preprocessed source for, say, libgcc?
Hm, maybe you would, by your indication of "bootstrap failures".

> So what are you exactly complaining for?

What complaint?  I'm replying to *your* complaint, and attempt
to lecture me on your interpretation of some "rule" you read,
presumably that we ask people for preprocessed source when
reporting bugs.

> If you want a bug fixed, be helpful
> like everybody does.

Eh, I think I was/did. :-)

> The fact that you are a maintainer does not buy you to
> shortcut rules and expect people to do the work in your place.

What?  Where did you get *that* from?  I resent that accusation!
I certainly don't expect bugs to be fixed just because I report
them in bugzilla.  I also don't expect a bugmaster to start an
inproductive argument, but that might be just because I'm a
maintainer. ;-)

I never expect people to fix a bug exposed by the targets I
maintain unless they're the one that made the bug or to some
extent when they write code that expose a bug.  So many thanks
to pinskia!  Much unexpected, very much appreciated.

Worth the enormous amount of work it takes to upload the
preprocessed sources. ;-)

brgds, H-P
Comment 17 Giovanni Bajo 2005-05-20 09:54:27 UTC
A patch was posted by Richard Sandiford:
http://gcc.gnu.org/ml/gcc-patches/2005-05/msg02029.html
Comment 18 Andrew Pinski 2005-05-24 15:57:35 UTC
Fixed.
Comment 19 Andrew Pinski 2005-06-05 07:56:00 UTC
*** Bug 21780 has been marked as a duplicate of this bug. ***