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 ao initialization in ipa-polymorphic-call


Hi,
this patch fixes thinko when initializing ao oracle in
ipa_polymorphic_call_context::get_dynamic_type.  It took get_deref_alias_set of vptr type
instead of get_alias_set that now makes difference because pointer types are different.

Bootstrapped/regtested x86_64-linux, comitted.

Honza
	PR ipa/66351
	* ipa-polymorphic-call.c
	(ipa_polymorphic_call_context::get_dynamic_type): Fix thinko when
	initializing alias oracle; fix formating; set base_alias_set if it
	is known.
Index: ipa-polymorphic-call.c
===================================================================
--- ipa-polymorphic-call.c	(revision 224713)
+++ ipa-polymorphic-call.c	(working copy)
@@ -1574,13 +1574,15 @@ ipa_polymorphic_call_context::get_dynami
 		  tree base_ref = get_ref_base_and_extent
 				   (ref_exp, &offset2, &size, &max_size);
 
-		  /* Finally verify that what we found looks like read from OTR_OBJECT
-		     or from INSTANCE with offset OFFSET.  */
+		  /* Finally verify that what we found looks like read from
+		     OTR_OBJECT or from INSTANCE with offset OFFSET.  */
 		  if (base_ref
 		      && ((TREE_CODE (base_ref) == MEM_REF
 		           && ((offset2 == instance_offset
 		                && TREE_OPERAND (base_ref, 0) == instance)
-			       || (!offset2 && TREE_OPERAND (base_ref, 0) == otr_object)))
+			       || (!offset2
+				   && TREE_OPERAND (base_ref, 0)
+				      == otr_object)))
 			  || (DECL_P (instance) && base_ref == instance
 			      && offset2 == instance_offset)))
 		    {
@@ -1608,9 +1610,17 @@ ipa_polymorphic_call_context::get_dynami
   /* We look for vtbl pointer read.  */
   ao.size = POINTER_SIZE;
   ao.max_size = ao.size;
+  /* We are looking for stores to vptr pointer within the instance of
+     outer type.
+     TODO: The vptr pointer type is globally known, we probably should
+     keep it and do that even when otr_type is unknown.  */
   if (otr_type)
-    ao.ref_alias_set
-      = get_deref_alias_set (TREE_TYPE (BINFO_VTABLE (TYPE_BINFO (otr_type))));
+    {
+      ao.base_alias_set
+	= get_alias_set (outer_type ? outer_type : otr_type);
+      ao.ref_alias_set
+        = get_alias_set (TREE_TYPE (BINFO_VTABLE (TYPE_BINFO (otr_type))));
+    }
 
   if (dump_file)
     {


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