Bug 39120 - [4.4 Regression] Missed escape constraints for call results
[4.4 Regression] Missed escape constraints for call results
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: tree-optimization
4.4.0
: P2 normal
: 4.5.0
Assigned To: Not yet assigned to anyone
: alias, wrong-code
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-02-06 17:58 UTC by Richard Biener
Modified: 2012-03-13 13:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.2 4.5.0
Known to fail: 4.2.4 4.3.3 4.4.0
Last reconfirmed: 2009-02-06 17:59:36


Attachments
part #1 (4.53 KB, patch)
2009-03-24 14:39 UTC, Richard Biener
Details | Diff
part #2 (12.90 KB, patch)
2009-03-24 14:40 UTC, Richard Biener
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2009-02-06 17:58:55 UTC
struct X { int *p; } x;

struct X __attribute__((noinline))
foo(int *p) { struct X x; x.p = p; return x; }

void __attribute((noinline))
bar() { *x.p = 1; }

extern void abort (void);
int main()
{
  int i = 0;
  x = foo(&i);
  bar();
  if (i != 1)
    abort ();
  return 0;
}
Comment 1 Richard Biener 2009-02-06 17:59:36 UTC
I have a patch.
Comment 2 Richard Biener 2009-02-07 12:31:46 UTC
Subject: Bug 39120

Author: rguenth
Date: Sat Feb  7 12:31:34 2009
New Revision: 144003

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144003
Log:
2009-02-07  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/39120
	* tree-ssa-structalias.c (handle_rhs_call): Fill out return
	constraints.
	(handle_lhs_call): Process return constraints.  Add escape
	constraints if necessary.
	(handle_const_call): Fill out return constraints.  Make nested
	case more precise.  Avoid consttmp if possible.
	(handle_pure_call): Fill out return constraints.  Avoid
	callused if possible.
	(find_func_aliases): Simplify call handling.  Manually build
	nonlocal constraints for asm outputs.
	* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Add
	shortcut for const calls.  Properly use is_call_clobbered for
	non-const, non-pure calls.

	* gcc.c-torture/execute/pr39120.c: New testcase.

Added:
    branches/alias-improvements/gcc/testsuite/gcc.c-torture/execute/pr39120.c
Modified:
    branches/alias-improvements/gcc/ChangeLog.alias
    branches/alias-improvements/gcc/tree-ssa-alias.c
    branches/alias-improvements/gcc/tree-ssa-structalias.c

Comment 3 Jack Howarth 2009-03-24 14:02:48 UTC
Can this be back ported to gcc trunk?
Comment 4 rguenther@suse.de 2009-03-24 14:20:36 UTC
Subject: Re:  [4.2/4.3/4.4 Regression] Missed
 escape constraints for call results

On Tue, 24 Mar 2009, howarth at nitro dot med dot uc dot edu wrote:

> ------- Comment #3 from howarth at nitro dot med dot uc dot edu  2009-03-24 14:02 -------
> Can this be back ported to gcc trunk?

It can, but it would drag in some dependencies, in particular the CALLUSED
handling rewrite and eventually the changes related to handling NONLOCAL
vs. ESCAPED.  I will try to cook up sth but planned to merge these changes
early in stage1 to backport them for 4.4.1 eventually.

Richard.
Comment 5 Richard Biener 2009-03-24 14:39:56 UTC
Created attachment 17531 [details]
part #1
Comment 6 Richard Biener 2009-03-24 14:40:25 UTC
Created attachment 17532 [details]
part #2

Untested patches for the backport.
Comment 7 Richard Biener 2009-03-27 22:36:48 UTC
Subject: Bug 39120

Author: rguenth
Date: Fri Mar 27 22:36:33 2009
New Revision: 145137

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145137
Log:
2009-03-27  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/39120
	* tree-ssa-structalias.c (handle_rhs_call): Fill out return
	constraints.
	(handle_lhs_call): Process return constraints.  Add escape
	constraints if necessary.
	(handle_const_call): Fill out return constraints.  Make nested
	case more precise.  Avoid consttmp if possible.
	(handle_pure_call): Fill out return constraints.  Avoid
	callused if possible.
	(find_func_aliases): Simplify call handling.

	* gcc.c-torture/execute/pr39120.c: New testcase.

2009-03-27  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/39120
	* tree-ssa-structalias.c (do_sd_constraint): Do not use CALLUSED
	as a representative.
	(solve_graph): Do propagate CALLUSED.
	(handle_pure_call): Use a scalar constraint from CALLUSED for
	the return value.
	(find_what_p_points_to): CALLUSED shall not appear in poins-to
	solutions.

	* gcc.dg/torture/pta-callused-1.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr39120.c
    trunk/gcc/testsuite/gcc.dg/torture/pta-callused-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-structalias.c

Comment 8 Richard Biener 2009-03-27 22:41:06 UTC
Fixed for 4.5.
Comment 9 Joseph S. Myers 2009-03-31 21:09:35 UTC
Closing 4.2 branch.
Comment 10 Richard Biener 2009-06-17 12:40:22 UTC
I have no plans for fixing the branches.
Comment 11 Richard Biener 2009-08-04 12:29:57 UTC
GCC 4.3.4 is being released, adjusting target milestone.
Comment 12 Richard Biener 2010-05-22 18:13:23 UTC
GCC 4.3.5 is being released, adjusting target milestone.
Comment 13 Richard Biener 2011-06-27 12:14:02 UTC
4.3 branch is being closed, moving to 4.4.7 target.
Comment 14 Jakub Jelinek 2012-03-13 13:04:32 UTC
Fixed in 4.5+, 4.4 is no longer supported.