This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Ada and TBAA and arrays vs. VIEW_CONVERT_EXPRs
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 8 Feb 2009 16:51:54 +0100
- Subject: Re: Ada and TBAA and arrays vs. VIEW_CONVERT_EXPRs
- References: <alpine.LNX.2.00.0902081520140.11836@zhemvz.fhfr.qr>
> I manage to miscompile c354003.a with improved dead store elimination.
> I believe this is a problem with the Ada frontend and type alias sets.
> My improved dead store elimination eliminates all stores to D.2638 in
>
> # .MEM_357 = VDEF <.MEM_356(ab)>
> D.2638[1]{lb: 1 sz: 2} = 32;
> # .MEM_358 = VDEF <.MEM_357>
> D.2638[2]{lb: 1 sz: 2} = 50;
> # .MEM_359 = VDEF <.MEM_358>
> D.2638[3]{lb: 1 sz: 2} = 53;
> # .MEM_360 = VDEF <.MEM_359>
> D.2638[4]{lb: 1 sz: 2} = 53;
> # VUSE <.MEM_360>
> D.2639_41 = VIEW_CONVERT_EXPR<UNSIGNED_64>(D.2638);
Note that the .original dump file contains:
VIEW_CONVERT_EXPR<wide_character[1:4]>(S1b.F[1 ...]{lb: 1 sz: 2}) == {32, 50,
53, 53})
so the above sequence is generated by the gimplifier.
> Because VIEW_CONVERT_EXPR<UNSIGNED_64>(D.2638) does not alias with
> any of the array-reference stores through TBAA rules:
>
> get_alias_set (D.2638[4]{lb: 1 sz: 2}) == 15
> no component_uses_parent_alias_set for the array-ref? So it is
> marked aliased here?
>
> get_alias_set (VIEW_CONVERT_EXPR<UNSIGNED_64>(D.2638)) == 7
> via component_uses_parent_alias_set we get to D.2638. I think that's
> perfectly correct.
>
> 15 and 7 do not conflict. So - that hints back at my patch returning
> the same alias set for an array and its elements - but for Ada, which
> one of you claimed that it does the right thing(TM). Not?
Try the attached, totally untested patch. It looks correct from a language
viewpoint, although it probably papers over a more general problem.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_String_Literal_Subtype>:
Set TYPE_NONALIASED_COMPONENT on the array type.
--
Eric Botcazou
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c (revision 143923)
+++ gcc-interface/decl.c (working copy)
@@ -2615,6 +2615,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
gnu_type
= build_array_type (gnat_to_gnu_type (Component_Type (gnat_entity)),
gnu_index_type);
+ TYPE_NONALIASED_COMPONENT (gnu_type) = 1;
copy_alias_set (gnu_type, gnu_string_type);
}
break;