public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Type-based alias analysis and alias sets
@ 2009-10-23 13:43 Eric Botcazou
  2009-10-23 14:04 ` Richard Guenther
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Botcazou @ 2009-10-23 13:43 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc

[-- Attachment #1: Type: text/plain, Size: 1359 bytes --]

Hi Richard,

I just (re-)discovered that the new TBAA machinery is quite aggressive and 
breaks cases that used to work in Ada (-O2 testcase for SPARC64 attached).

The problem boils down to this:

  D.1416_1 = (struct p__rec &) &r.F;
  r.F = ...
  ... = D.1416_1->d;

DSE computes that the store to r.F is dead and eliminates it at -O2 because 
ultimately nonaliasing_component_refs_p returns false:

  /* If we have two type access paths B1.path1 and B2.path2 they may
     only alias if either B1 is in B2.path2 or B2 is in B1.path1.  */
  return false;

[Shouldn't nonaliasing_component_refs_p be named aliasing_component_refs_p or 
component_refs_may_alias_p instead]?

Yes, it's a blatant type-punning case but all the structure types are given 
the same alias set (struct p__rec, type of r, type of F) and 'd' is not 
addressable so all the memory accesses are done with the same alias set.

The root of the problem is that same_type_for_tbaa never returns true since 
the types don't have the same TYPE_CANONICAL (rightfully so, they are not 
equivalent) so we fall back to the final return of nonaliasing_c_r_p.

Shouldn't this final return be 'true' instead of 'false', like the final 
return in indirect_ref_may_alias_decl_p, so that the ultimate fallback is the 
comparison of alias sets like it used to be?

Thanks in advance.

-- 
Eric Botcazou

[-- Attachment #2: p.adb --]
[-- Type: text/x-adasrc, Size: 258 bytes --]

procedure P is

  type Rec (D : Natural) is record
    S : String (1..D);
  end record;

  procedure Test (R : Rec) is
  begin
    if R.D /= 9 then
      raise Program_Error;
    end if;
  end;

  R : Rec(9);

begin
  R := (9, "123456789");
  Test (R);
end;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-10-23 21:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-23 13:43 Type-based alias analysis and alias sets Eric Botcazou
2009-10-23 14:04 ` Richard Guenther
2009-10-23 16:20   ` Eric Botcazou
2009-10-23 19:12   ` Eric Botcazou
2009-10-23 23:00     ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).