]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/120156 - ICE in ptr_derefs_may_alias_p
authorRichard Biener <rguenther@suse.de>
Tue, 14 May 2024 09:13:51 +0000 (11:13 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 14 Oct 2025 11:15:25 +0000 (13:15 +0200)
This picks the ptr_derefs_may_alias_p fix from the PR99954 fix
which said:  This makes us run into a latent issue in
ptr_deref_may_alias_decl_p when the pointer is something like &MEM[0].a
in which case we fail to handle non-SSA name pointers.  Add code
similar to what we have in ptr_derefs_may_alias_p.

PR tree-optimization/120156
* tree-ssa-alias.cc (ptr_deref_may_alias_decl_p): Verify
the pointer is an SSA name.

(cherry picked from commit 50d3f67c71cf77a4ec95152079d37adf9d0b0a35)

gcc/tree-ssa-alias.cc

index 6a626c9e1ca7840641c3a9bd5e5155fee203acef..58a20f0d3352e20bb9a5e6c7eda2129939d4cf75 100644 (file)
@@ -295,6 +295,11 @@ ptr_deref_may_alias_decl_p (tree ptr, tree decl)
   if (!may_be_aliased (decl))
     return false;
 
+  /* From here we require a SSA name pointer.  Anything else aliases.  */
+  if (TREE_CODE (ptr) != SSA_NAME
+      || !POINTER_TYPE_P (TREE_TYPE (ptr)))
+    return true;
+
   /* If we do not have useful points-to information for this pointer
      we cannot disambiguate anything else.  */
   pi = SSA_NAME_PTR_INFO (ptr);