public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-8202] cgraph: Fix up semantic_interposition handling [PR105306] Date: Wed, 20 Apr 2022 07:25:11 +0000 (GMT) [thread overview] Message-ID: <20220420072511.894503858D3C@sourceware.org> (raw) https://gcc.gnu.org/g:2a6d372ba96cc0836bfd46579ad78c1ee5a3cf8a commit r12-8202-g2a6d372ba96cc0836bfd46579ad78c1ee5a3cf8a Author: Jakub Jelinek <jakub@redhat.com> Date: Wed Apr 20 09:24:18 2022 +0200 cgraph: Fix up semantic_interposition handling [PR105306] cgraph_node has a semantic_interposition flag which should mirror opt_for_fn (decl, flag_semantic_interposition). But it actually is initialized not from that, but from flag_semantic_interposition in the explicit symtab_node (symtab_type t) : type (t), resolution (LDPR_UNKNOWN), definition (false), alias (false), ... semantic_interposition (flag_semantic_interposition), ... x_comdat_group (NULL_TREE), x_section (NULL) {} ctor. I think that might be fine for varpool nodes, but since flag_semantic_interposition is now implied from -Ofast it isn't correct for cgraph nodes, unless we guarantee that cgraph node for a particular function decl is always created while that function is current_function_decl. That is often the case, but not always as the following function shows. Because symtab_node's ctor doesn't know for which decl the cgraph node is being created, the following patch keeps that as is, but updates it from opt_for_fn (decl, flag_semantic_interposition) when we know that, or for clones copies that flag (often it is then overridden in set_new_clone_decl_and_node_flags, but not always). 2022-04-20 Jakub Jelinek <jakub@redhat.com> PR ipa/105306 * cgraph.cc (cgraph_node::create): Set node->semantic_interposition to opt_for_fn (decl, flag_semantic_interposition). * cgraphclones.cc (cgraph_node::create_clone): Copy over semantic_interposition flag. * g++.dg/opt/pr105306.C: New test. Diff: --- gcc/cgraph.cc | 1 + gcc/cgraphclones.cc | 1 + gcc/testsuite/g++.dg/opt/pr105306.C | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc index b923a59ab0c..d3cc06bbaed 100644 --- a/gcc/cgraph.cc +++ b/gcc/cgraph.cc @@ -507,6 +507,7 @@ cgraph_node::create (tree decl) gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); node->decl = decl; + node->semantic_interposition = opt_for_fn (decl, flag_semantic_interposition); if ((flag_openacc || flag_openmp) && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl))) diff --git a/gcc/cgraphclones.cc b/gcc/cgraphclones.cc index 60da1e867c8..eb0fa87b554 100644 --- a/gcc/cgraphclones.cc +++ b/gcc/cgraphclones.cc @@ -394,6 +394,7 @@ cgraph_node::create_clone (tree new_decl, profile_count prof_count, new_node->versionable = versionable; new_node->can_change_signature = can_change_signature; new_node->redefined_extern_inline = redefined_extern_inline; + new_node->semantic_interposition = semantic_interposition; new_node->tm_may_enter_irr = tm_may_enter_irr; new_node->externally_visible = false; new_node->no_reorder = no_reorder; diff --git a/gcc/testsuite/g++.dg/opt/pr105306.C b/gcc/testsuite/g++.dg/opt/pr105306.C new file mode 100644 index 00000000000..552d37491bc --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr105306.C @@ -0,0 +1,13 @@ +// PR ipa/105306 +// { dg-do compile } +// { dg-options "-Ofast" } + +#pragma GCC optimize 0 +template <typename T> void foo (T); +struct B { ~B () {} }; +struct C { B f; }; +template <typename> struct E { + void bar () { foo (g); } + C g; +}; +template class E<char>;
reply other threads:[~2022-04-20 7:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220420072511.894503858D3C@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).