]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa/120146 - deal with vanished varpool nodes in IPA PTA
authorRichard Biener <rguenther@suse.de>
Wed, 7 May 2025 08:20:55 +0000 (10:20 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 8 May 2025 07:26:24 +0000 (09:26 +0200)
I don't understand why they vanish when still refered to, but
lets deal with that in a conservative way.

PR ipa/120146
* tree-ssa-structalias.cc (create_variable_info_for): If
the symtab cannot tell us whether all refs to a variable
are explicit assume they are not.

* g++.dg/ipa/pr120146.C: New testcase.

gcc/testsuite/g++.dg/ipa/pr120146.C [new file with mode: 0644]
gcc/tree-ssa-structalias.cc

diff --git a/gcc/testsuite/g++.dg/ipa/pr120146.C b/gcc/testsuite/g++.dg/ipa/pr120146.C
new file mode 100644 (file)
index 0000000..33644b4
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile }
+// { dg-options "-O -fipa-pta" }
+
+struct basic_ios {
+  ~basic_ios();
+};
+struct basic_istream : virtual basic_ios {};
+template <typename> struct basic_ifstream : basic_istream {
+  template <typename _Path> basic_ifstream(_Path, int);
+};
+extern template class basic_ifstream<char>;
+void CompareFiles_path2() { basic_ifstream<char>(CompareFiles_path2, 0); }
index 3ad0c69930c72c0dbd6070adefc90058e435afbc..deca44ae0bf35a74e210018c387a9c71934166f0 100644 (file)
@@ -6562,7 +6562,7 @@ create_variable_info_for (tree decl, const char *name, bool add_id)
          varpool_node *vnode = varpool_node::get (decl);
 
          /* For escaped variables initialize them from nonlocal.  */
-         if (!vnode->all_refs_explicit_p ())
+         if (!vnode || !vnode->all_refs_explicit_p ())
            make_copy_constraint (vi, nonlocal_id);
 
          /* While we can in theory walk references for the varpool
@@ -6581,7 +6581,7 @@ create_variable_info_for (tree decl, const char *name, bool add_id)
                process_constraint (new_constraint (lhs, *rhsp));
              /* If this is a variable that escapes from the unit
                 the initializer escapes as well.  */
-             if (!vnode->all_refs_explicit_p ())
+             if (!vnode || !vnode->all_refs_explicit_p ())
                {
                  lhs.var = escaped_id;
                  lhs.offset = 0;