Bug 38236 - [4.4 Regression] SMT aliases incomplete
Summary: [4.4 Regression] SMT aliases incomplete
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Richard Biener
URL:
Keywords: alias, wrong-code
Depends on:
Blocks: 38151
  Show dependency treegraph
 
Reported: 2008-11-23 12:10 UTC by Richard Biener
Modified: 2008-11-25 10:34 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.2
Known to fail:
Last reconfirmed: 2008-11-23 12:11:01


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2008-11-23 12:10:37 UTC
struct X { int i; };

int __attribute__((noinline))
foo (struct X *p, int *q, int a, int b)
{
  struct X x, y;
  if (a)
    p = &x;
  if (b)
    q = &x.i;
  else
    q = &y.i;
  *q = 1;
  return p->i;
}
extern void abort (void);
int main()
{
  if (foo((void *)0, (void *)0, 1, 1) != 1)
    abort ();
  return 0;
}

is miscompiled (the store to *q is deleted as unused) because the SMT used
for *p misses the x and y aliases as x and y are neither directly stored
nor is their SMT (but only the aliasing SMT for int).
Comment 1 Richard Biener 2008-11-23 12:11:01 UTC
Mine.  Patch posted.
Comment 2 Richard Biener 2008-11-23 12:17:35 UTC
GCC 4.3 is "safe" because it doesn't fall back to anything for p, but uses
{ x, y, ANYTHING } instead.  In turn it heavily relies on correct call clobbers
if you obfuscate the pointers.  Which makes me not entirely convinced that
I cannot make this latent problem trigger on the 4.3 branch ...
Comment 3 Richard Biener 2008-11-25 10:34:22 UTC
Fixed.
Comment 4 Richard Biener 2008-11-25 10:35:39 UTC
Subject: Bug 38236

Author: rguenth
Date: Tue Nov 25 10:34:11 2008
New Revision: 142189

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142189
Log:
2008-11-25  Richard Guenther  <rguenther@suse.de>

	PR middle-end/38151
	PR middle-end/38236
	* tree-ssa-alias.c (struct alias_info): Remove written_vars.
	Remove dereferenced_ptrs_store and dereferenced_ptrs_load
	in favor of dereferenced_ptrs.
	(init_alias_info): Adjust.
	(delete_alias_info): Likewise.
	(compute_flow_insensitive_aliasing): Properly
	include all aliased variables.
	(update_alias_info_1): Use dereferenced_ptrs.
	(setup_pointers_and_addressables): Likewise.
	(get_smt_for): Honor ref-all pointers and pointers with known alias
	set properly.
	* config/i386/i386.c (ix86_gimplify_va_arg): Use ref-all pointers.

	* gcc.c-torture/execute/pr38151.c: New testcase.
	* gcc.c-torture/execute/pr38236.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr38151.c
    trunk/gcc/testsuite/gcc.c-torture/execute/pr38236.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-alias.c