[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-23 Thread vincenzo.innocente at cern dot ch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

--- Comment #11 from vincenzo Innocente vincenzo.innocente at cern dot ch 
2012-05-23 08:03:54 UTC ---
sorry I cannot test the patch on the original failing files as at revision
187789 I get
cat  ipa.patch
--- tree-ssa-structalias.c  (revision 187695)
+++ tree-ssa-structalias.c  (working copy)
@@ -5583,7 +5583,8 @@ create_variable_info_for (tree decl, con

  /* If this is a global variable with an initializer and we are in
 IPA mode generate constraints for it.  */
- if (DECL_INITIAL (decl))
+ if (DECL_INITIAL (decl)
+  vnode-analyzed)
{
  VEC (ce_s, heap) *rhsc = NULL;
  struct constraint_expr lhs, *rhsp;
[vocms123] /build/vin/gcc-trunk $ cd gcc
[vocms123] /build/vin/gcc-trunk/gcc $ patch -p0  ../ipa.patch 
patching file tree-ssa-structalias.c
Hunk #1 FAILED at 5583.
1 out of 1 hunk FAILED -- saving rejects to file tree-ssa-structalias.c.rej


[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-23 Thread hubicka at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

--- Comment #12 from Jan Hubicka hubicka at gcc dot gnu.org 2012-05-23 
09:47:14 UTC ---
Author: hubicka
Date: Wed May 23 09:47:10 2012
New Revision: 187799

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=187799
Log:

PR middle-end/53426
* tree-ssa-structalias.c (create_variable_info_for): Skip constructors from
other partitions.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/tree-ssa-structalias.c


[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-23 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED

--- Comment #13 from Richard Guenther rguenth at gcc dot gnu.org 2012-05-23 
10:49:20 UTC ---
Fixed.


[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-23 Thread vincenzo.innocente at cern dot ch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

--- Comment #14 from vincenzo Innocente vincenzo.innocente at cern dot ch 
2012-05-23 11:53:13 UTC ---
fix confirmed
trunk revision 187799
compiles again my large application


[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-22 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

--- Comment #5 from Richard Guenther rguenth at gcc dot gnu.org 2012-05-22 
09:44:41 UTC ---
(In reply to comment #4)
  Hum. IPA-PTA ... yeah ... :/
  
  Mine I guess (note ipa-pta is experimental).
  
  Honza - we are trying to access the varinfo for
  _ZTIN5boost16exception_detail19error_info_injectorISt13runtime_errorEE
  which is mentioned in the initializer of
  _ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE
  but that variable, despite mentioned, does not have a varpool entry.  Is
  that by design?  Can we not look at the initializer of a decl via
 
 I suppose it is the case where
 _ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE is
 external but with constructor known.  I recently fixed that on mainline by
 making those analyzed, too.
 
 So if this still reproduce on mainline, it is possible that you arrive to the
 constructor in some way that is not visible by varpool?

I'm arriving at it by walking all of varpool via FOR_EACH_VARIABLE, reaching
_ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE which is

readonly addressable used public ignored external virtual BLK file
/afs/cern.ch/cms/slc5_amd64_gcc470/external/boost/1.49.0/include/boost/exception/exception.hpp
line 315 col 9 size integer_cst 0x75c07640 576 unit size integer_cst
0x75c07740 72
align 256 context record_type 0x75c70930 error_info_injector initial
constructor 0x75c6f078

looking at its DECL_INITIAL which contains an address of
_ZTIN5boost16exception_detail19error_info_injectorISt13runtime_errorEE
which does not have a varpool entry and is

readonly addressable used public ignored external weak BLK file
/afs/cern.ch/cms/slc5_amd64_gcc470/external/boost/1.49.0/include/boost/exception/exception.hpp
line 315 col 9 size integer_cst 0x75c07460 448 unit size integer_cst
0x75c074c0 56
align 256 initial error_mark 0x75ad4bb8

it's the pointer to the typeinfo struct, so I'm not sure we ever create
varpool entries for that.

I can of course simply guard the code doing

  struct varpool_node *vnode = varpool_get_node (decl);

  /* For escaped variables initialize them from nonlocal.  */
  if (!varpool_all_refs_explicit_p (vnode))
make_copy_constraint (vi, nonlocal_id);

by changing it to

  if (!vnode
  || DECL_INITIAL (vnode) == error_mark_node
  || !varpool_all_refs_explicit_p (vnode))
make_copy_constraint (vi, nonlocal_id);

also noting the special error_mark_node DECL_INITIAL (what's that coming
from!?)


[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-22 Thread hubicka at ucw dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

--- Comment #6 from Jan Hubicka hubicka at ucw dot cz 2012-05-22 12:19:55 UTC 
---
 by changing it to
 
   if (!vnode
   || DECL_INITIAL (vnode) == error_mark_node
   || !varpool_all_refs_explicit_p (vnode))
 make_copy_constraint (vi, nonlocal_id);
 
 also noting the special error_mark_node DECL_INITIAL (what's that coming
 from!?)

DECL_INITIAL is replaced by error mark when the variable is removed from
varpool
(so we know it is no longer going to be referenced or emit in some way) to
conserve
memory.

Other case is the partitioning, when the variable is in the other partition 
and thus there is no need to sream the DECL_INITIAL (we stream DECL_INITIAL for
variables from other partitions only when we think it may be useful for
constant
folding: that is variables passes const_value_known_p).  This is probably the
case
here.

If you only need to collect all things that escape, you can safely ignore
DECL_INITIAL of DECLs with in_ohter_partition set: all vars that are in current
partition referenced by the constructor from other partition
used_from_other_partition set anyway, so they won't pass
varpool_all_refs_explicit_p.

You only need to worry about local constructors.

Honza


[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-22 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

--- Comment #7 from Richard Guenther rguenth at gcc dot gnu.org 2012-05-22 
12:47:04 UTC ---
(In reply to comment #6)
  by changing it to
  
if (!vnode
|| DECL_INITIAL (vnode) == error_mark_node
|| !varpool_all_refs_explicit_p (vnode))
  make_copy_constraint (vi, nonlocal_id);
  
  also noting the special error_mark_node DECL_INITIAL (what's that coming
  from!?)
 
 DECL_INITIAL is replaced by error mark when the variable is removed from
 varpool
 (so we know it is no longer going to be referenced or emit in some way) to
 conserve
 memory.
 
 Other case is the partitioning, when the variable is in the other partition 
 and thus there is no need to sream the DECL_INITIAL (we stream DECL_INITIAL 
 for
 variables from other partitions only when we think it may be useful for
 constant
 folding: that is variables passes const_value_known_p).  This is probably the
 case
 here.
 
 If you only need to collect all things that escape, you can safely ignore
 DECL_INITIAL of DECLs with in_ohter_partition set: all vars that are in 
 current
 partition referenced by the constructor from other partition
 used_from_other_partition set anyway, so they won't pass
 varpool_all_refs_explicit_p.
 
 You only need to worry about local constructors.

But I have a variable that fulfills varpool_all_refs_explicit_p but still
its DECL_INITIAL contains X where I have no varpool node for X for.  So
if I constant fold from it I can get an explicit reference to a global
variable X that has no varpool node assigned.  How can that be ok?


[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-22 Thread hubicka at ucw dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

--- Comment #8 from Jan Hubicka hubicka at ucw dot cz 2012-05-22 12:53:43 UTC 
---
 But I have a variable that fulfills varpool_all_refs_explicit_p but still
 its DECL_INITIAL contains X where I have no varpool node for X for.  So
 if I constant fold from it I can get an explicit reference to a global
 variable X that has no varpool node assigned.  How can that be ok?

We bring the references only for vars that pass const_value_known_p, but from
what you quote it looks like it should pass the check.  I am now tracking
memory
corruption in other PR, so i will look into this next.


[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-22 Thread hubicka at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

--- Comment #9 from Jan Hubicka hubicka at gcc dot gnu.org 2012-05-22 
13:31:28 UTC ---
OK,
I see the following:
6882  FOR_EACH_VARIABLE (var)
6883{
6884  if (var-alias)
6885continue;
6886
6887  get_vi_for_tree (var-symbol.decl);
6888}

(gdb) p dump_varpool_node (stderr, var)
_ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE.local.230/1658
(_ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE)
@0x775f1e88
  Type: variable
  Visibility: in_other_partition used_from_other_partition
prevailing_def_ironly external public visibility_specified visibility:hidden
virtual artificial
  References: 
  Referring:
_ZNK5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEE5cloneEv.local.151/2414
(addr)_ZNK5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEE5cloneEv.local.151/2414
(addr)
  Availability: overwritable
  Varpool flags: initialized finalized

this var won't pass varpool_all_refs_explicit: it is from other partition and
used from elsewhere.

Partitioning should have put the variables referred by this constructor into a
boundary and it is not doing it - I will fix that.
(it gets that right at my internal symbol table tree)

On the other hand, is ipa-pta able to take advantage of fact that the variable
is readonly? I would propose:
Index: tree-ssa-structalias.c
===
--- tree-ssa-structalias.c  (revision 187695)
+++ tree-ssa-structalias.c  (working copy)
@@ -5583,7 +5583,8 @@ create_variable_info_for (tree decl, con

  /* If this is a global variable with an initializer and we are in
 IPA mode generate constraints for it.  */
- if (DECL_INITIAL (decl))
+ if (DECL_INITIAL (decl)
+  vnode-analyzed)
{
  VEC (ce_s, heap) *rhsc = NULL;
  struct constraint_expr lhs, *rhsp;

I.e. to care only about constructors of vars from current partition.
This function does not check varpool_all_refs_explicit as you suggested in
previous comment.


[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-22 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

--- Comment #10 from Richard Guenther rguenth at gcc dot gnu.org 2012-05-22 
13:52:49 UTC ---
(In reply to comment #9)
 OK,
 I see the following:
 6882  FOR_EACH_VARIABLE (var)
 6883{
 6884  if (var-alias)
 6885continue;
 6886
 6887  get_vi_for_tree (var-symbol.decl);
 6888}
 
 (gdb) p dump_varpool_node (stderr, var)
 _ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE.local.230/1658
 (_ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE)
 @0x775f1e88
   Type: variable
   Visibility: in_other_partition used_from_other_partition
 prevailing_def_ironly external public visibility_specified visibility:hidden
 virtual artificial
   References: 
   Referring:
 _ZNK5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEE5cloneEv.local.151/2414
 (addr)_ZNK5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEE5cloneEv.local.151/2414
 (addr)
   Availability: overwritable
   Varpool flags: initialized finalized
 
 this var won't pass varpool_all_refs_explicit: it is from other partition and
 used from elsewhere.
 
 Partitioning should have put the variables referred by this constructor into a
 boundary and it is not doing it - I will fix that.
 (it gets that right at my internal symbol table tree)
 
 On the other hand, is ipa-pta able to take advantage of fact that the variable
 is readonly? I would propose:
 Index: tree-ssa-structalias.c
 ===
 --- tree-ssa-structalias.c  (revision 187695)
 +++ tree-ssa-structalias.c  (working copy)
 @@ -5583,7 +5583,8 @@ create_variable_info_for (tree decl, con
 
   /* If this is a global variable with an initializer and we are in
  IPA mode generate constraints for it.  */
 - if (DECL_INITIAL (decl))
 + if (DECL_INITIAL (decl)
 +  vnode-analyzed)
 {
   VEC (ce_s, heap) *rhsc = NULL;
   struct constraint_expr lhs, *rhsp;
 
 I.e. to care only about constructors of vars from current partition.
 This function does not check varpool_all_refs_explicit as you suggested in
 previous comment.

Ok, this fixes it.  You explained DECL_INITIAL of a !vnode-analyzed can
never refer to a varpool_all_refs_explicit_p () decl.


[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-21 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||lto
 Status|WAITING |ASSIGNED
 CC||hubicka at gcc dot gnu.org
  Component|lto |tree-optimization
 AssignedTo|unassigned at gcc dot   |rguenth at gcc dot gnu.org
   |gnu.org |
   Target Milestone|--- |4.8.0
Summary|[lto with ipa-pta]: |[4.8 Regression]
   |ICE:create_variable_info_fo |ICE:create_variable_info_fo
   |r  at   |r  at
   |../../gcc-trunk/gcc/tree-ss |../../gcc-trunk/gcc/tree-ss
   |a-structalias.c:5581|a-structalias.c:5581

--- Comment #3 from Richard Guenther rguenth at gcc dot gnu.org 2012-05-21 
11:45:14 UTC ---
Hum. IPA-PTA ... yeah ... :/

Mine I guess (note ipa-pta is experimental).

Honza - we are trying to access the varinfo for
_ZTIN5boost16exception_detail19error_info_injectorISt13runtime_errorEE
which is mentioned in the initializer of
_ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE
but that variable, despite mentioned, does not have a varpool entry.  Is
that by design?  Can we not look at the initializer of a decl via

  /* In IPA mode parse the initializer and generate proper constraints
 for it.  */
  else
{
  struct varpool_node *vnode = varpool_get_node (decl);

  /* For escaped variables initialize them from nonlocal.  */
  if (!varpool_all_refs_explicit_p (vnode))
make_copy_constraint (vi, nonlocal_id);

  /* If this is a global variable with an initializer and we are in
 IPA mode generate constraints for it.  */
  if (DECL_INITIAL (decl))
{
...

?  Or is varpool_all_refs_explicit_p not the correct predicate to check
here?


[Bug tree-optimization/53426] [4.8 Regression] ICE:create_variable_info_for at ../../gcc-trunk/gcc/tree-ssa-structalias.c:5581

2012-05-21 Thread hubicka at ucw dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53426

--- Comment #4 from Jan Hubicka hubicka at ucw dot cz 2012-05-21 13:40:05 UTC 
---
 Hum. IPA-PTA ... yeah ... :/
 
 Mine I guess (note ipa-pta is experimental).
 
 Honza - we are trying to access the varinfo for
 _ZTIN5boost16exception_detail19error_info_injectorISt13runtime_errorEE
 which is mentioned in the initializer of
 _ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE
 but that variable, despite mentioned, does not have a varpool entry.  Is
 that by design?  Can we not look at the initializer of a decl via

I suppose it is the case where
_ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE is
external but with constructor known.  I recently fixed that on mainline by
making those analyzed, too.

So if this still reproduce on mainline, it is possible that you arrive to the
constructor in some way that is not visible by varpool?

Honza