Bug 28410 - [4.2 Regression] Wrong aliasing with global var grouping during call clobbering
Summary: [4.2 Regression] Wrong aliasing with global var grouping during call clobbering
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P3 blocker
Target Milestone: 4.2.0
Assignee: Diego Novillo
URL:
Keywords: alias, wrong-code
Depends on:
Blocks:
 
Reported: 2006-07-17 12:51 UTC by Richard Biener
Modified: 2006-07-18 17:29 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-07-17 13:30:56


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2006-07-17 12:51:12 UTC
struct Bar { int p; };
struct Foo { struct Bar *p; };
int foo(struct Foo *f)
{
  f->p->p = 1;
  bar(f);
  return f->p->p;
}

.alias1:

  #   VUSE <SMT.4_6>;
  D.1528_2 = f_1->p; 
  #   SMT.5_8 = V_MAY_DEF <SMT.5_7>;
  D.1528_2->p = 1;
  #   .GLOBAL_VAR_10 = V_MAY_DEF <.GLOBAL_VAR_9>;
  bar (f_1);
  #   VUSE <SMT.4_6>;
  D.1528_3 = f_1->p;
  #   VUSE <SMT.5_8>;
  D.1529_4 = D.1528_3->p;
  return D.1529_4;

and fre then does:

  #   VUSE <SMT.4_6>;
  D.1528_2 = f_1->p;
  #   SMT.5_8 = V_MAY_DEF <SMT.5_7>;
  D.1528_2->p = 1;
  #   .GLOBAL_VAR_10 = V_MAY_DEF <.GLOBAL_VAR_9>;
  bar (f_1);
  D.1528_3 = D.1528_2;
  #   VUSE <SMT.5_8>;
  D.1529_4 = D.1528_3->p;
  return D.1529_4;


miscompiles kde4.
Comment 1 Richard Biener 2006-07-17 12:51:43 UTC
Oh - build with -O2 --param global-var-threshold=1
Comment 2 Richard Biener 2006-07-17 13:29:11 UTC
Runnable testcase:

extern void abort(void);
struct Bar { int p; };
struct Foo { struct Bar *p; };
struct Bar p0 = { 0 };
struct Bar p1 = { 1 };
void bar(struct Foo *f)
{
  f->p = &p0;
}
int foo(struct Foo *f)
{
  f->p->p = 1;
  bar(f);
  return f->p->p;
}
int main()
{
  struct Foo f;
  f.p = &p1;
  if (foo(&f) != 0)
    abort ();
  return 0;
}
Comment 3 Diego Novillo 2006-07-18 13:25:13 UTC
Testing patch.  The bug was in the alias pruning code.  We need to handle .GLOBAL_VAR in access_can_touch_variable.  A memory reference that uses a call-clobbered memory tag should always be considered to touch .GLOBAL_VAR.
Comment 4 Daniel Berlin 2006-07-18 14:06:19 UTC
Subject: Re:  [4.2 Regression] Wrong aliasing
 with global var grouping during call clobbering

dnovillo at gcc dot gnu dot org wrote:
> ------- Comment #3 from dnovillo at gcc dot gnu dot org  2006-07-18 13:25 -------
> 
> Testing patch.  The bug was in the alias pruning code.  We need to handle
> .GLOBAL_VAR in access_can_touch_variable.  A memory reference that uses a
> call-clobbered memory tag should always be considered to touch .GLOBAL_VAR.

Yay for random invariants!
Comment 5 Diego Novillo 2006-07-18 17:28:14 UTC
Subject: Bug 28410

Author: dnovillo
Date: Tue Jul 18 17:27:57 2006
New Revision: 115564

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

	PR 28410
	* tree-ssa-operands.c (access_can_touch_variable): Update
	comment.
	Return true if ALIAS is .GLOBAL_VAR.

testsuite/ChangeLog

	PR 28410
	* gcc.dg/tree-ssa/pr28410.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr28410.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-operands.c

Comment 6 Diego Novillo 2006-07-18 17:29:02 UTC
Fixed.  http://gcc.gnu.org/ml/gcc-patches/2006-07/msg00786.html