public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] ifunc alias: follow alias links testing for ifunc_resolver
@ 2022-08-04 14:16 Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2022-08-04 14:16 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:893ce0c3c7005715157dd9e8ebb4fe5633d94d90

commit 893ce0c3c7005715157dd9e8ebb4fe5633d94d90
Author: Alexandre Oliva <oliva@gnu.org>
Date:   Thu Aug 4 09:21:15 2022 -0300

    ifunc alias: follow alias links testing for ifunc_resolver

Diff:
---
 gcc/cgraph.cc               |  4 ++--
 gcc/cgraph.h                | 12 +++++++++++-
 gcc/config/i386/i386.cc     |  4 ++--
 gcc/symtab.cc               |  2 +-
 gcc/tree-ssa-structalias.cc |  4 ++--
 gcc/varasm.cc               |  2 +-
 6 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 8d6ed38efa2..29f60d8a227 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -2369,7 +2369,7 @@ cgraph_node::get_availability (symtab_node *ref)
     avail = AVAIL_AVAILABLE;
   else if (transparent_alias)
     ultimate_alias_target (&avail, ref);
-  else if (ifunc_resolver
+  else if (ifunc_resolver_p ()
 	   || lookup_attribute ("noipa", DECL_ATTRIBUTES (decl)))
     avail = AVAIL_INTERPOSABLE;
   else if (!externally_visible)
@@ -2408,7 +2408,7 @@ static bool
 cgraph_node_cannot_be_local_p_1 (cgraph_node *node, void *)
 {
   return !(!node->force_output
-	   && !node->ifunc_resolver
+	   && !node->ifunc_resolver_p ()
 	   /* Limitation of gas requires us to output targets of symver aliases
 	      as global symbols.  This is binutils PR 25295.  */
 	   && !node->symver
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 4be67e3cea9..2b81c06b047 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -1283,6 +1283,16 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node
      calls_comdat_local flag after function transformations.  */
   bool check_calls_comdat_local_p ();
 
+  /* Check if function is an [alias to] ifunc resolver.  */
+  bool ifunc_resolver_p () {
+    if (ifunc_resolver)
+      return true;
+    if (!alias)
+      return false;
+    cgraph_node *node = get_alias_target ();
+    return node && node->ifunc_resolver_p ();
+  }
+
   /* Return true if function should be optimized for size.  */
   enum optimize_size_level optimize_for_size_p (void);
 
@@ -3127,7 +3137,7 @@ cgraph_node::can_remove_if_no_direct_calls_and_refs_p (void)
     return false;
   /* Only COMDAT functions can be removed if externally visible.  */
   if (externally_visible
-      && ((!DECL_COMDAT (decl) || ifunc_resolver)
+      && ((!DECL_COMDAT (decl) || ifunc_resolver_p ())
 	  || forced_by_abi
 	  || used_from_object_file_p ()))
     return false;
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 5e30dc884bf..e88621611c3 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -1020,7 +1020,7 @@ ix86_function_ok_for_sibcall (tree decl, tree exp)
       /* When PIC register is used, it must be restored after ifunc
 	 function returns.  */
        cgraph_node *node = cgraph_node::get (decl);
-       if (node && node->ifunc_resolver)
+       if (node && node->ifunc_resolver_p ())
 	 return false;
     }
 
@@ -16062,7 +16062,7 @@ ix86_call_use_plt_p (rtx call_op)
 	  /* NB: All ifunc functions must be called via PLT.  */
 	  cgraph_node *node
 	    = cgraph_node::get (SYMBOL_REF_DECL (call_op));
-	  if (node && node->ifunc_resolver)
+	  if (node && node->ifunc_resolver_p ())
 	    return true;
 	}
       return false;
diff --git a/gcc/symtab.cc b/gcc/symtab.cc
index f2d96c0268b..b3176f729ab 100644
--- a/gcc/symtab.cc
+++ b/gcc/symtab.cc
@@ -2480,7 +2480,7 @@ symtab_node::binds_to_current_def_p (symtab_node *ref)
     return definition
 	   && get_alias_target()->binds_to_current_def_p (ref);
   cgraph_node *cnode = dyn_cast <cgraph_node *> (this);
-  if (cnode && cnode->ifunc_resolver)
+  if (cnode && cnode->ifunc_resolver_p ())
     return false;
   if (decl_binds_to_current_def_p (decl))
     return true;
diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index dcf13d939bd..6612ac917d4 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -6381,7 +6381,7 @@ create_variable_info_for (tree decl, const char *name, bool add_id)
   if (in_ipa_mode
       && TREE_CODE (decl) == FUNCTION_DECL
       && (node = cgraph_node::get (decl))
-      && node->ifunc_resolver)
+      && node->ifunc_resolver_p ())
     {
       varinfo_t fi = get_vi_for_tree (node->get_alias_target ()->decl);
       constraint_expr rhs
@@ -8150,7 +8150,7 @@ associate_varinfo_to_alias (struct cgraph_node *node, void *data)
        || (node->thunk
 	   && ! node->inlined_to))
       && node->analyzed
-      && !node->ifunc_resolver)
+      && !node->ifunc_resolver_p ())
     insert_vi_for_tree (node->decl, (varinfo_t)data);
   return false;
 }
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index 4db8506b106..f5cbe67f3f1 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -7486,7 +7486,7 @@ default_binds_local_p_3 (const_tree exp, bool shlib, bool weak_dominate,
       || (!targetm.ifunc_ref_local_ok ()
 	  && TREE_CODE (exp) == FUNCTION_DECL
 	  && cgraph_node::get (exp)
-	  && cgraph_node::get (exp)->ifunc_resolver))
+	  && cgraph_node::get (exp)->ifunc_resolver_p ()))
     return false;
 
   /* Static variables are always local.  */


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] ifunc alias: follow alias links testing for ifunc_resolver
@ 2022-08-04 14:24 Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2022-08-04 14:24 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f4b1a9fc2a729c93263f4fb19fb1614a8df21d32

commit f4b1a9fc2a729c93263f4fb19fb1614a8df21d32
Author: Alexandre Oliva <oliva@gnu.org>
Date:   Thu Aug 4 09:21:15 2022 -0300

    ifunc alias: follow alias links testing for ifunc_resolver

Diff:
---
 gcc/cgraph.cc               |  2 +-
 gcc/cgraph.h                | 10 ++++++++++
 gcc/config/i386/i386.cc     |  4 ++--
 gcc/symtab.cc               |  2 +-
 gcc/tree-ssa-structalias.cc |  4 ++--
 gcc/varasm.cc               |  2 +-
 6 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 8d6ed38efa2..69988c6854a 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -2408,7 +2408,7 @@ static bool
 cgraph_node_cannot_be_local_p_1 (cgraph_node *node, void *)
 {
   return !(!node->force_output
-	   && !node->ifunc_resolver
+	   && !node->ifunc_resolver_p ()
 	   /* Limitation of gas requires us to output targets of symver aliases
 	      as global symbols.  This is binutils PR 25295.  */
 	   && !node->symver
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 4be67e3cea9..649f14b9cb4 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -1283,6 +1283,16 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node
      calls_comdat_local flag after function transformations.  */
   bool check_calls_comdat_local_p ();
 
+  /* Check if function is an [alias to] ifunc resolver.  */
+  bool ifunc_resolver_p () {
+    if (ifunc_resolver)
+      return true;
+    if (!alias)
+      return false;
+    cgraph_node *node = get_alias_target ();
+    return node && node->ifunc_resolver_p ();
+  }
+
   /* Return true if function should be optimized for size.  */
   enum optimize_size_level optimize_for_size_p (void);
 
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 5e30dc884bf..e88621611c3 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -1020,7 +1020,7 @@ ix86_function_ok_for_sibcall (tree decl, tree exp)
       /* When PIC register is used, it must be restored after ifunc
 	 function returns.  */
        cgraph_node *node = cgraph_node::get (decl);
-       if (node && node->ifunc_resolver)
+       if (node && node->ifunc_resolver_p ())
 	 return false;
     }
 
@@ -16062,7 +16062,7 @@ ix86_call_use_plt_p (rtx call_op)
 	  /* NB: All ifunc functions must be called via PLT.  */
 	  cgraph_node *node
 	    = cgraph_node::get (SYMBOL_REF_DECL (call_op));
-	  if (node && node->ifunc_resolver)
+	  if (node && node->ifunc_resolver_p ())
 	    return true;
 	}
       return false;
diff --git a/gcc/symtab.cc b/gcc/symtab.cc
index f2d96c0268b..b3176f729ab 100644
--- a/gcc/symtab.cc
+++ b/gcc/symtab.cc
@@ -2480,7 +2480,7 @@ symtab_node::binds_to_current_def_p (symtab_node *ref)
     return definition
 	   && get_alias_target()->binds_to_current_def_p (ref);
   cgraph_node *cnode = dyn_cast <cgraph_node *> (this);
-  if (cnode && cnode->ifunc_resolver)
+  if (cnode && cnode->ifunc_resolver_p ())
     return false;
   if (decl_binds_to_current_def_p (decl))
     return true;
diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index dcf13d939bd..6612ac917d4 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -6381,7 +6381,7 @@ create_variable_info_for (tree decl, const char *name, bool add_id)
   if (in_ipa_mode
       && TREE_CODE (decl) == FUNCTION_DECL
       && (node = cgraph_node::get (decl))
-      && node->ifunc_resolver)
+      && node->ifunc_resolver_p ())
     {
       varinfo_t fi = get_vi_for_tree (node->get_alias_target ()->decl);
       constraint_expr rhs
@@ -8150,7 +8150,7 @@ associate_varinfo_to_alias (struct cgraph_node *node, void *data)
        || (node->thunk
 	   && ! node->inlined_to))
       && node->analyzed
-      && !node->ifunc_resolver)
+      && !node->ifunc_resolver_p ())
     insert_vi_for_tree (node->decl, (varinfo_t)data);
   return false;
 }
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index 4db8506b106..f5cbe67f3f1 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -7486,7 +7486,7 @@ default_binds_local_p_3 (const_tree exp, bool shlib, bool weak_dominate,
       || (!targetm.ifunc_ref_local_ok ()
 	  && TREE_CODE (exp) == FUNCTION_DECL
 	  && cgraph_node::get (exp)
-	  && cgraph_node::get (exp)->ifunc_resolver))
+	  && cgraph_node::get (exp)->ifunc_resolver_p ()))
     return false;
 
   /* Static variables are always local.  */


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-04 14:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04 14:16 [gcc(refs/users/aoliva/heads/testme)] ifunc alias: follow alias links testing for ifunc_resolver Alexandre Oliva
2022-08-04 14:24 Alexandre Oliva

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).