Bug 40556

Summary: [4.5 Regression] ICE in IPA-CP with recursion
Product: gcc Reporter: Volker Reichelt <reichelt>
Component: tree-optimizationAssignee: Jan Hubicka <jh>
Status: RESOLVED FIXED    
Severity: normal CC: denis.onischenko, gcc-bugs, jamborm, jh
Priority: P1 Keywords: ice-on-valid-code, monitored
Version: 4.5.0   
Target Milestone: 4.5.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2009-09-18 04:20:12

Description Volker Reichelt 2009-06-26 05:53:43 UTC
The following valid code snippet triggers an ICE when compiled with "-O2":

===================
struct A {};

struct A foo()
{
  return foo();
}

void bar()
{
  foo();
}
===================

bug.c:11:1: internal compiler error: in ipcp_analyze_node, at ipa-cp.c:183
Please submit a full bug report, [etc.]

The regression appeared between 2009-05-09 and 2009-05-22.
Comment 1 Steven Bosscher 2009-06-26 06:12:22 UTC
Adding IPA-CP to CC...
Comment 2 Martin Jambor 2009-06-26 13:53:20 UTC
This is some sort of cgraph consistency check.  Honza added it and he also said he will look into this :-)
Comment 3 Jan Hubicka 2009-10-21 23:58:40 UTC
Actually it catch quite interesting thinko in early inliner.  We cut iterations of early inliner after fixed point of iterations but because of way the exit condition is written we end up not applying the inline plan after last iteration.

Testing patch.
Comment 4 Jan Hubicka 2009-10-22 11:40:35 UTC
Subject: Bug 40556

Author: hubicka
Date: Thu Oct 22 11:40:18 2009
New Revision: 153450

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153450
Log:

	PR tree-optimize/40556                                                                                                                                         
	* ipa-reference.c (has_proper_scope_for_analysis): Add fixme about global vars.                                                                                
	(check_call): Handle only indirect calls.                                                                                                                      
	(propagate_bits): Update comment.                                                                                                                              
	(write_node_summary_p): Turn bogus check to assert.                                                                                                            
	(ipa_reference_write_summary): Stream calls_read_all properly.                                                                                                 
	(ipa_reference_read_summary): Stream in calls_read_all properly.                                                                                               
	(read_write_all_from_decl): New function.                                                                                                                      
	(propagate): Handle OVERWRITABLE nodes and external calls here.                                                                                                
	* ipa-pre-const.c (check_call): In IPA mode handle indirect calls                                                                                              
	only.                                                                                                                                                          
	(analyze_function): Do not check visibility here.                                                                                                              
	(add_new_function): We summary OVERWRITABLE too.                                                                                                               
	(generate_summary): Stream OVERWRITABLE nodes too.                                                                                                             
	(propagate): Handle external calls and OVERWRITABLE nodes here.                                                                                                
	(local_pure_const): Check visibility here.                                                                                                                     

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr40556.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-pure-const.c
    trunk/gcc/ipa-reference.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 Richard Biener 2009-10-22 12:48:48 UTC
Still ICEs for me.
Comment 6 Jan Hubicka 2009-10-22 13:32:07 UTC
Subject: Bug 40556

Author: hubicka
Date: Thu Oct 22 13:31:48 2009
New Revision: 153456

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153456
Log:

	* ipa-cp.c (ipcp_read_summary): Remove now invalid FIXME and
	flag_ltrans check.
	* ipa-inline.c (cgraph_mark_inline_edge,
	cgraph_decide_inlining_of_small_function,
	cgraph_decide_inlining, inline_read_summary): Disable indirect inlining
	for WPA for time being.

	PR tree-optimize/40556                                                                                                                                         
	* ipa-inline.c (cgraph_early_inlining): Fix iterations condition.

Fix PR number for earlier patch to:
	PR lto/41730

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-cp.c
    trunk/gcc/ipa-inline.c

Comment 7 Richard Biener 2009-10-22 13:46:05 UTC
Fixed.
Comment 8 Richard Biener 2009-10-23 22:28:10 UTC
*** Bug 41740 has been marked as a duplicate of this bug. ***