aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-04-20 09:24:18 +0200
committerJakub Jelinek <jakub@redhat.com>2022-04-20 09:24:18 +0200
commit2a6d372ba96cc0836bfd46579ad78c1ee5a3cf8a (patch)
tree1e69e3b4252acdcecae1cf4fae510edf86027fff /gcc/cgraph.cc
parentd1d571873c83ed49a98f84c98f78349e7ad1df14 (diff)
downloadgcc-2a6d372ba96cc0836bfd46579ad78c1ee5a3cf8a.zip
gcc-2a6d372ba96cc0836bfd46579ad78c1ee5a3cf8a.tar.gz
gcc-2a6d372ba96cc0836bfd46579ad78c1ee5a3cf8a.tar.bz2
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.
Diffstat (limited to 'gcc/cgraph.cc')
-rw-r--r--gcc/cgraph.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index b923a59..d3cc06b 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)))