[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-03-25 Thread hubicka at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

--- Comment #21 from Jan Hubicka hubicka at gcc dot gnu.org 2012-03-25 
09:39:38 UTC ---
Author: hubicka
Date: Sun Mar 25 09:39:32 2012
New Revision: 185774

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=185774
Log:
PR middle-end/51737
* cgraph.c (cgraph_remove_node_and_inline_clones): Add FORBIDDEN_NODE
parameter.
* cgraph.h (cgraph_remove_node_and_inline_clones): Update prototype.
* ipa-inline-transform.c (save_inline_function_body): Remove copied clone
if needed.
* tree-inline.c (delete_unreachable_blocks_update_callgraph): Update.

PR middle-end/51737
* g++.dg/torture/pr51737.C: New testcase

Modified:
branches/gcc-4_6-branch/gcc/ChangeLog
branches/gcc-4_6-branch/gcc/cgraph.c
branches/gcc-4_6-branch/gcc/cgraph.h
branches/gcc-4_6-branch/gcc/cgraphunit.c
branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
branches/gcc-4_6-branch/gcc/tree-inline.c


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-03-25 Thread hubicka at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

Jan Hubicka hubicka at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED

--- Comment #22 from Jan Hubicka hubicka at gcc dot gnu.org 2012-03-25 
09:40:05 UTC ---
Fixed.


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-03-25 Thread hubicka at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

--- Comment #23 from Jan Hubicka hubicka at gcc dot gnu.org 2012-03-25 
13:25:56 UTC ---
Author: hubicka
Date: Sun Mar 25 13:25:51 2012
New Revision: 185776

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

PR middle-end/51737
* g++.dg/torture/pr51737.C: New testcase

Added:
trunk/gcc/testsuite/g++.dg/torture/pr51737.C


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

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

--- Comment #19 from Jan Hubicka hubicka at gcc dot gnu.org 2012-03-22 
14:33:37 UTC ---
Author: hubicka
Date: Thu Mar 22 14:33:27 2012
New Revision: 185694

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=185694
Log:
PR middle-end/51737
* cgraph.c (cgraph_remove_node_and_inline_clones): Add FORBIDDEN_NODE
parameter.
* cgraph.h (cgraph_remove_node_and_inline_clones): Update prototype.
* ipa-inline-transform.c (save_inline_function_body): Remove copied clone
if needed.
* tree-inline.c (delete_unreachable_blocks_update_callgraph): Update.

PR middle-end/51737
* g++.dg/torture/pr51737.C: New testcase

Modified:
trunk/gcc/ChangeLog
trunk/gcc/cgraph.c
trunk/gcc/cgraph.h
trunk/gcc/ipa-inline-transform.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-inline.c


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

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

--- Comment #20 from Jan Hubicka hubicka at gcc dot gnu.org 2012-03-22 
17:12:28 UTC ---
I started to look into why the testcase does not fire on mainline.  It seems to
be effect of change in early inliner.  We used to inline intrusive_ptr_release
in early inlining ignoring the code size growth. This leads to large divergence
of inlining decisions.


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-03-20 Thread hubicka at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

--- Comment #18 from Jan Hubicka hubicka at gcc dot gnu.org 2012-03-20 
16:19:55 UTC ---
Created attachment 26932
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26932
patch in testing

I am testing the attached patch.  It basically delays removal of the clone
until after the body saving process is finished.  
The problem is still on trunk, just the testcase passes because we optimize it
too early.


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-03-01 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

   Target Milestone|4.6.3   |4.6.4

--- Comment #17 from Jakub Jelinek jakub at gcc dot gnu.org 2012-03-01 
14:38:29 UTC ---
GCC 4.6.3 is being released.


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-02-29 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

--- Comment #12 from Richard Guenther rguenth at gcc dot gnu.org 2012-02-29 
12:09:19 UTC ---
The question is why we call delete_unreachable_blocks from
tree_function_versioning at all.  We do not bother updating the
callgraph anywhere else.

Honza, you added that beast?


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-02-29 Thread hubicka at ucw dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

--- Comment #13 from Jan Hubicka hubicka at ucw dot cz 2012-02-29 15:01:31 
UTC ---
 The question is why we call delete_unreachable_blocks from
 tree_function_versioning at all.  We do not bother updating the
 callgraph anywhere else.
 
 Honza, you added that beast?

Well, after clonning we alter CFG and we need to update SSA for which we need
to update dominators and those needs unreachable blocks gone.  I will look into
this.

Honza


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-02-29 Thread hubicka at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

Jan Hubicka hubicka at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 AssignedTo|unassigned at gcc dot   |hubicka at gcc dot gnu.org
   |gnu.org |

--- Comment #14 from Jan Hubicka hubicka at gcc dot gnu.org 2012-02-29 
15:15:46 UTC ---
mine.


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-02-29 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

--- Comment #15 from Richard Guenther rguenth at gcc dot gnu.org 2012-02-29 
15:17:33 UTC ---
(In reply to comment #13)
  The question is why we call delete_unreachable_blocks from
  tree_function_versioning at all.  We do not bother updating the
  callgraph anywhere else.
  
  Honza, you added that beast?
 
 Well, after clonning we alter CFG and we need to update SSA for which we need
 to update dominators and those needs unreachable blocks gone.  I will look 
 into
 this.

Ok - but why bother updating the callgraph?


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-02-29 Thread hubicka at ucw dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

--- Comment #16 from Jan Hubicka hubicka at ucw dot cz 2012-02-29 15:24:18 
UTC ---
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737
 
 --- Comment #15 from Richard Guenther rguenth at gcc dot gnu.org 2012-02-29 
 15:17:33 UTC ---
 (In reply to comment #13)
   The question is why we call delete_unreachable_blocks from
   tree_function_versioning at all.  We do not bother updating the
   callgraph anywhere else.
   
   Honza, you added that beast?
  
  Well, after clonning we alter CFG and we need to update SSA for which we 
  need
  to update dominators and those needs unreachable blocks gone.  I will look 
  into
  this.
 
 Ok - but why bother updating the callgraph?

Because the edges still hold important information about inlining and
redirecting, so we can not rebuild callgraph because the info would be lost.
Ignoring the update would result in ill formed callgraph with missing/stale
edges that is probably way to hell, too. So I opted to write code to keep it up
to date.

This is all part of the materialization clones: we do have virtual clones of
single function, each with different parameters and different redirection of
it. With materialization we need to build the bodies in one step, update the
call according to edge redirection in following step and finally inline before
doing the local optimization. Callgrpah needs to stay intact over the whole
process. (and as we discussed, we may want to make it intact even longer ;)

Honza


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-01-09 Thread jamborm at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

--- Comment #11 from Martin Jambor jamborm at gcc dot gnu.org 2012-01-09 
22:42:00 UTC ---
The problem is much more fundamental than just a clone removal while
also walking the clones of the same function although that is the
reason why we segfault.  But that would be almost easy to solve.

The bigger problem is indeed materialization of recursive loads
itself: We have a function that calls itself twice and some of these
calls and their calls are scheduled to be recursively inlined.  When
the decisions are to be carried out, we recognize we need to save a
copy of the body to copy from somewhere and so we call
save_inline_function_body.  That function elects a clone to own the
body copy and calls tree_function_versioning to copy it.  And
tree_function_versioning calls the problematic
delete_unreachable_blocks_update_callgraph which analyzes CFG and
finds some BBs unreachable - I'm not quite sure what made them so
suddenly unreachable, but it almost certainly has something to do with
EH BBs that somehow are stale at that point.  And so the function
begins to nuke respective call graph edges and also call graph nodes
of respective inlined callees and their inlined callees and... and
sure enough it decides to delete the node that
save_inline_function_body chose to hold the new body, in other words
it intends to delete id-dst_node of currently running
tree_function_versioning.

Thus even if we taught delete_unreachable_blocks_update_callgraph to
be more careful about deleted nodes, tree_function_versioning would
fail nevertheless.

I'm wondering whether we could just skip
delete_unreachable_blocks_update_callgraph when
tree_function_versioning is called from within
save_inline_function_body, though I can imagine the verifier could
complain about something.  I have to run now, will experiment more
tomorrow.


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-01-06 Thread jamborm at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

Martin Jambor jamborm at gcc dot gnu.org changed:

   What|Removed |Added

 CC||hubicka at gcc dot gnu.org

--- Comment #10 from Martin Jambor jamborm at gcc dot gnu.org 2012-01-06 
12:02:04 UTC ---
This bug is not triggered when IPA-SRA is switched off, however, from
what I have seen in the debugger, I don't think the bug is in IPA-SRA
but that it is in fact an inlining problem (and also very probably
just latent on trunk).

The immediate reason for the segfault is that one of very many inline
clones of intrusive_ptrT::~intrusive_ptr() [with T = file_info]
have NULL clone_of pointer.  Looking more into why, I noticed that
immediately before the crash id-dst_node-clones is NULL too, which
should not happen since this code is guarded by a condition that this
pointer is not NULL.

Therefore I assume that the real problem is that it is not safe to
call cgraph_remove_node_and_inline_clones on inlined recursive edges
from delete_unreachable_blocks_update_callgraph since it destroys the
clone tree we are traversing.

Currently I do not know what to do about this other than push the
nodes to be deleted on a stack and remove after the traversal.
Honza, do you have a better idea?


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-01-05 Thread jamborm at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

--- Comment #9 from Martin Jambor jamborm at gcc dot gnu.org 2012-01-05 
16:16:29 UTC ---
I can reproduce the segfault when compiling both the testcase from
comment #8 and the original unreduced test case on the 4.6 branch but
not on my trunk checkout (revision 182785).  I will have a look at
what is going on nevertheless.


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-01-03 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2012-01-03
  Component|c++ |tree-optimization
  Known to work||4.5.3
   Target Milestone|--- |4.6.3
Summary|g++ crashes (internal   |[4.6 Regression] g++
   |compiler error: |crashes (internal compiler
   |Segmentation fault) when|error: Segmentation fault)
   |compiling quickbook |when compiling quickbook
 Ever Confirmed|0   |1

--- Comment #7 from Richard Guenther rguenth at gcc dot gnu.org 2012-01-03 
09:21:16 UTC ---
Confirmed (on the unreduced testcase) with 4.6.2 and the 4.6 branch head
with just -O2:

#0  0x00b7f910 in delete_unreachable_blocks_update_callgraph (
id=optimized out)
at /space/rguenther/src/svn/gcc-4_6-branch/gcc/tree-inline.c:4972
#1  0x00b8d2b0 in tree_function_versioning (old_decl=0x71f18f00, 
new_decl=0x70649600, tree_map=optimized out, 
update_clones=128 '\200', args_to_skip=optimized out, 
blocks_to_copy=0x0, new_entry=0x0)
at /space/rguenther/src/svn/gcc-4_6-branch/gcc/tree-inline.c:5232
#2  0x00b52961 in save_inline_function_body (node=0x71886160)
at /space/rguenther/src/svn/gcc-4_6-branch/gcc/cgraphunit.c:2149
#3  0x00b5c1f8 in inline_transform (node=0x71886160)
at /space/rguenther/src/svn/gcc-4_6-branch/gcc/ipa-inline.c:2122
#4  inline_transform (node=0x71886160)
at /space/rguenther/src/svn/gcc-4_6-branch/gcc/ipa-inline.c:2108

does not reproduce on trunk, but that may be artificial.

Re-reducing.


[Bug tree-optimization/51737] [4.6 Regression] g++ crashes (internal compiler error: Segmentation fault) when compiling quickbook

2012-01-03 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51737

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 CC||jamborm at gcc dot gnu.org
  Known to work||4.7.0

--- Comment #8 from Richard Guenther rguenth at gcc dot gnu.org 2012-01-03 
15:59:53 UTC ---
Testcase, ICEs at -O2, works on trunk.  The code we ICE on is the same
on the branch and trunk, so maybe the issue is still latent there or maybe
we fixed it elsewhere.  -fno-ipa-sra fixes it on the branch.

templateclass T class intrusive_ptr {
public:
~intrusive_ptr() { intrusive_ptr_release( px ); }
T * px;
};
template typename T struct intrusive_base {
friend void intrusive_ptr_release(T* ptr) { delete ptr; }
};
struct section_info;
struct file_info : intrusive_basefile_info {
intrusive_ptrfile_info parent;
intrusive_ptrsection_info switched_section;
};
struct section_info : intrusive_basesection_info {
intrusive_ptrsection_info parent;
};
struct id_state {
void * start_file(void);
};
void * id_state::start_file(void) {
intrusive_ptrfile_info parent;
}
struct id_generation_data : intrusive_baseid_generation_data {
void child_length() const {}
};
void generate_id(id_generation_data generation_data)
{
  generation_data.child_length();
}