This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix PR ada/43096


This is the failure of a couple of ACATS tests at -O2, visible in the results 
on some platforms (arm-linux, sparc-linux, powerpc-linux) but generic under 
the hood.  The problem comes again from a bad interaction between the new 
alias analysis code, in particular aliasing_component_refs_p, and some Ada 
constructs.  The core code expects a strong relationship between types that 
can alias each other (same TYPE_CANONICAL) whereas the Ada types only have a 
weaker one (same alias set).

The fix is a middle-ground solution that instructs same_type_for_tbaa to 
return -1 (don't know) in this case.  Tested on x86_64-suse-linux, pre- 
approved by Richard in the audit trail, applied on the mainline.


2010-02-26  Eric Botcazou  <ebotcazou@adacore.com>

	PR ada/43096
	* tree-ssa-alias.c (same_type_for_tbaa): Return -1 if the types have
	the same alias set.


-- 
Eric Botcazou
Index: tree-ssa-alias.c
===================================================================
--- tree-ssa-alias.c	(revision 156989)
+++ tree-ssa-alias.c	(working copy)
@@ -544,13 +544,15 @@ same_type_for_tbaa (tree type1, tree typ
       && TREE_CODE (type2) == ARRAY_TYPE)
     return -1;
 
-  /* In Ada, an lvalue of unconstrained type can be used to access an object
-     of one of its constrained subtypes, for example when a function with an
-     unconstrained parameter passed by reference is called on a constrained
-     object and inlined.  In this case, the types have the same alias set.  */
-  if (TYPE_SIZE (type1) && TYPE_SIZE (type2)
-      && TREE_CONSTANT (TYPE_SIZE (type1)) != TREE_CONSTANT (TYPE_SIZE (type2))
-      && get_alias_set (type1) == get_alias_set (type2))
+  /* ??? In Ada, an lvalue of an unconstrained type can be used to access an
+     object of one of its constrained subtypes, e.g. when a function with an
+     unconstrained parameter passed by reference is called on an object and
+     inlined.  But, even in the case of a fixed size, type and subtypes are
+     not equivalent enough as to share the same TYPE_CANONICAL, since this
+     would mean that conversions between them are useless, whereas they are
+     not (e.g. type and subtypes can have different modes).  So, in the end,
+     they are only guaranteed to have the same alias set.  */
+  if (get_alias_set (type1) == get_alias_set (type2))
     return -1;
 
   /* The types are known to be not equal.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]