This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/11403] [3.4 regression] ICE in cgraph_remove_edge with -O3 (unit-at-a-time problem)


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11403



------- Additional Comments From jh at suse dot cz  2003-07-02 22:27 -------
Subject: Re:  [3.4 regression] ICE in cgraph_remove_edge with -O3 (unit-at-a-time problem)

> Indeed. Using -O3 -fno-unit-at-a-time makes the ICE go away.
> 
> Surprisingly, I don't need the include. Here's my minimal testcase:
> ----------------------------------
> struct S {
>     double *d;
>     double &operator[] (int n) {return d[n];}
> };
> 
> void foo (bool b) {
>   S s;
>   s[3] = b ? 1. : 2.;
> }
> -----------------------------------

Hi,
Interesting :).  
The problem is that the function body does contain 3 call_exprs, while
first two are shared.  We create callgraph edges by
walk_tree_without_duplicates so we get only two edges instead of three.
Tree inliner inline first two calls, but also forgets about the third
and we get linker failure.

I assume that the rationale why walk_tree was originally replaced by
walk_tree_without_duplicates is right and thus this is latent bug in C++
frontend.  It is fixed by the attached patch (the lhs is used again
immediately afterwards to build the COND_EXPR)  For the arms of
COND_EXPRs the sharing is already cared for, but it may happen in
between the conditional and first operand.

Regtested, bootstrapped.  OK, together with the testcase?
Where noncompilation testcases should be put in G++ testsuite?

Thu Jul  3 00:24:38 CEST 2003  Jan Hubicka  <jh@suse.cz>
	* typeck.c (build_modify_expr): Avoid invalid sharing of CALL_EXPRS.
Index: typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.470
diff -c -3 -p -r1.470 typeck.c
*** typeck.c	2 Jul 2003 09:36:17 -0000	1.470
--- typeck.c	2 Jul 2003 22:23:24 -0000
*************** build_modify_expr (tree lhs, enum tree_c
*** 5591,5597 ****
  
        if (TREE_SIDE_EFFECTS (lhs))
  	cond = build_compound_expr (tree_cons
! 				    (NULL_TREE, lhs,
  				     build_tree_list (NULL_TREE, cond)));
  
        /* Cannot have two identical lhs on this one tree (result) as preexpand
--- 5591,5597 ----
  
        if (TREE_SIDE_EFFECTS (lhs))
  	cond = build_compound_expr (tree_cons
! 				    (NULL_TREE, break_out_calls (lhs),
  				     build_tree_list (NULL_TREE, cond)));
  
        /* Cannot have two identical lhs on this one tree (result) as preexpand


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]