diff options
author | Richard Biener <rguenther@suse.de> | 2025-05-07 10:20:55 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2025-05-11 10:54:41 +0200 |
commit | 47e830211d39b5efb14144bbdaf8f2d83ba8375e (patch) | |
tree | 44556982b197f5bf1c78f1fc32d9bc5ef2b1f773 | |
parent | 94d10c0ef2dca46f1c043c81bcda67ee7e2efc67 (diff) | |
download | gcc-47e830211d39b5efb14144bbdaf8f2d83ba8375e.zip gcc-47e830211d39b5efb14144bbdaf8f2d83ba8375e.tar.gz gcc-47e830211d39b5efb14144bbdaf8f2d83ba8375e.tar.bz2 |
ipa/120146 - deal with vanished varpool nodes in IPA PTA
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.
(cherry picked from commit b38e3a7196d25bc8bcb1fe55da7663745cea9470)
-rw-r--r-- | gcc/testsuite/g++.dg/ipa/pr120146.C | 12 | ||||
-rw-r--r-- | gcc/tree-ssa-structalias.cc | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/gcc/testsuite/g++.dg/ipa/pr120146.C b/gcc/testsuite/g++.dg/ipa/pr120146.C new file mode 100644 index 0000000..33644b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr120146.C @@ -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); } diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc index 3ad0c69..deca44a 100644 --- a/gcc/tree-ssa-structalias.cc +++ b/gcc/tree-ssa-structalias.cc @@ -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; |