[Bug tree-optimization/103175] [12 Regression] internal compiler error: in handle_call_arg, at tree-ssa-structalias.c:4139

Jan Hubicka hubicka@kam.mff.cuni.cz
Thu Nov 11 17:47:33 GMT 2021


The sanity check verifies that functions acessing parameter indirectly
also reads the parameter (otherwise the indirect reference can not
happen).  This patch moves the check earlier and removes some overactive
flag cleaning on function call boundary which introduces the non-sential
situation.  I got bit paranoid here on how return value relates to
escaping solution.

as discussed on ML, matmul failure is simply the fact that the testcase
verified missed optimization is still misssed.

diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index 72006251f29..a97021c6c60 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -1681,6 +1681,13 @@ modref_lattice::merge (int f)
 {
   if (f & EAF_UNUSED)
     return false;
+  /* Check that flags seems sane: if function does not read the parameter
+     it can not access it indirectly.  */
+  gcc_checking_assert (!(f & EAF_NO_DIRECT_READ)
+		       || ((f & EAF_NO_INDIRECT_READ)
+			   && (f & EAF_NO_INDIRECT_CLOBBER)
+			   && (f & EAF_NO_INDIRECT_ESCAPE)
+			   && (f & EAF_NOT_RETURNED_INDIRECTLY)));
   if ((flags & f) != flags)
     {
       flags &= f;
@@ -1874,27 +1881,13 @@ modref_eaf_analysis::merge_call_lhs_flags (gcall *call, int arg,
    argument if needed.  */
 
 static int
-callee_to_caller_flags (int call_flags, bool ignore_stores,
-			modref_lattice &lattice)
+callee_to_caller_flags (int call_flags, bool ignore_stores)
 {
   /* call_flags is about callee returning a value
      that is not the same as caller returning it.  */
   call_flags |= EAF_NOT_RETURNED_DIRECTLY
 		| EAF_NOT_RETURNED_INDIRECTLY;
-  /* TODO: We miss return value propagation.
-     Be conservative and if value escapes to memory
-     also mark it as escaping.  */
-  if (!ignore_stores && !(call_flags & EAF_UNUSED))
-    {
-      if (!(call_flags & EAF_NO_DIRECT_ESCAPE))
-	lattice.merge (~(EAF_NOT_RETURNED_DIRECTLY
-			 | EAF_NOT_RETURNED_INDIRECTLY
-			 | EAF_UNUSED));
-      if (!(call_flags & EAF_NO_INDIRECT_ESCAPE))
-	lattice.merge (~(EAF_NOT_RETURNED_INDIRECTLY
-			 | EAF_UNUSED));
-    }
-  else
+  if (ignore_stores)
     call_flags |= ignore_stores_eaf_flags;
   return call_flags;
 }
@@ -2033,15 +2026,9 @@ modref_eaf_analysis::analyze_ssa_name (tree name)
 			  if (!(call_flags & (EAF_NOT_RETURNED_DIRECTLY
 					      | EAF_UNUSED)))
 			    m_lattice[index].merge (~(EAF_NO_DIRECT_ESCAPE
-						      | EAF_NO_INDIRECT_ESCAPE
-						      | EAF_UNUSED));
-			  if (!(call_flags & (EAF_NOT_RETURNED_INDIRECTLY
-					      | EAF_UNUSED)))
-			    m_lattice[index].merge (~(EAF_NO_INDIRECT_ESCAPE
 						      | EAF_UNUSED));
 			  call_flags = callee_to_caller_flags
-					   (call_flags, false,
-					    m_lattice[index]);
+					   (call_flags, false);
 			}
 		      m_lattice[index].merge (call_flags);
 		    }
@@ -2057,8 +2044,7 @@ modref_eaf_analysis::analyze_ssa_name (tree name)
 			  !(call_flags & EAF_NOT_RETURNED_DIRECTLY),
 			  !(call_flags & EAF_NOT_RETURNED_INDIRECTLY));
 		  call_flags = callee_to_caller_flags
-				   (call_flags, ignore_stores,
-				    m_lattice[index]);
+				   (call_flags, ignore_stores);
 		  if (!(ecf_flags & (ECF_CONST | ECF_NOVOPS)))
 		    m_lattice[index].merge (call_flags);
 		}
@@ -2082,8 +2068,7 @@ modref_eaf_analysis::analyze_ssa_name (tree name)
 		    if (!(ecf_flags & (ECF_CONST | ECF_NOVOPS)))
 		      {
 			call_flags = callee_to_caller_flags
-					 (call_flags, ignore_stores,
-					  m_lattice[index]);
+					 (call_flags, ignore_stores);
 			if (!record_ipa)
 			  m_lattice[index].merge (call_flags);
 			else
@@ -2105,8 +2090,7 @@ modref_eaf_analysis::analyze_ssa_name (tree name)
 		    else
 		      {
 			call_flags = callee_to_caller_flags
-					 (call_flags, ignore_stores,
-					  m_lattice[index]);
+					 (call_flags, ignore_stores);
 			if (!record_ipa)
 			  m_lattice[index].merge (call_flags);
 			else


More information about the Gcc-bugs mailing list