public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-4937] More '#ifdef ASM_OUTPUT_DEF' -> 'if (TARGET_SUPPORTS_ALIASES)' etc.
@ 2023-10-26  6:38 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-10-26  6:38 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3dfe7e2d556580300b739f545c9d13213264e282

commit r14-4937-g3dfe7e2d556580300b739f545c9d13213264e282
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Thu Sep 7 22:15:08 2023 +0200

    More '#ifdef ASM_OUTPUT_DEF' -> 'if (TARGET_SUPPORTS_ALIASES)' etc.
    
    Per commit a8b522b483ebb8c972ecfde8779a7a6ec16aecd6 (Subversion r251048)
    "Introduce TARGET_SUPPORTS_ALIASES", there is the idea that a back end may or
    may not provide symbol aliasing support ('TARGET_SUPPORTS_ALIASES') independent
    of '#ifdef ASM_OUTPUT_DEF', and in particular, depending not just on static but
    instead on dynamic (run-time) configuration.  There did remain a few instances
    where we currently still assume that from '#ifdef ASM_OUTPUT_DEF' follows
    'TARGET_SUPPORTS_ALIASES'.  Change these to 'if (TARGET_SUPPORTS_ALIASES)',
    similarly, or 'gcc_checking_assert (TARGET_SUPPORTS_ALIASES);'.
    
            gcc/
            * ipa-icf.cc (sem_item::target_supports_symbol_aliases_p):
            'gcc_checking_assert (TARGET_SUPPORTS_ALIASES);' before
            'return true;'.
            * ipa-visibility.cc (function_and_variable_visibility): Change
            '#ifdef ASM_OUTPUT_DEF' to 'if (TARGET_SUPPORTS_ALIASES)'.
            * varasm.cc (output_constant_pool_contents)
            [#ifdef ASM_OUTPUT_DEF]:
            'gcc_checking_assert (TARGET_SUPPORTS_ALIASES);'.
            (do_assemble_alias) [#ifdef ASM_OUTPUT_DEF]:
            'if (!TARGET_SUPPORTS_ALIASES)',
            'gcc_checking_assert (seen_error ());'.
            (assemble_alias): Change '#if !defined (ASM_OUTPUT_DEF)' to
            'if (!TARGET_SUPPORTS_ALIASES)'.
            (default_asm_output_anchor):
            'gcc_checking_assert (TARGET_SUPPORTS_ALIASES);'.

Diff:
---
 gcc/ipa-icf.cc        |  1 +
 gcc/ipa-visibility.cc | 54 ++++++++++++++++++++++++++-------------------------
 gcc/varasm.cc         | 13 ++++++++++---
 3 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/gcc/ipa-icf.cc b/gcc/ipa-icf.cc
index 836d0914ded2..bbdfd445397d 100644
--- a/gcc/ipa-icf.cc
+++ b/gcc/ipa-icf.cc
@@ -218,6 +218,7 @@ sem_item::target_supports_symbol_aliases_p (void)
 #if !defined (ASM_OUTPUT_DEF) || (!defined(ASM_OUTPUT_WEAK_ALIAS) && !defined (ASM_WEAKEN_DECL))
   return false;
 #else
+  gcc_checking_assert (TARGET_SUPPORTS_ALIASES);
   return true;
 #endif
 }
diff --git a/gcc/ipa-visibility.cc b/gcc/ipa-visibility.cc
index 8ec82bb333e2..8ce56114ee3d 100644
--- a/gcc/ipa-visibility.cc
+++ b/gcc/ipa-visibility.cc
@@ -622,41 +622,43 @@ function_and_variable_visibility (bool whole_program)
   /* All aliases should be processed at this point.  */
   gcc_checking_assert (!alias_pairs || !alias_pairs->length ());
 
-#ifdef ASM_OUTPUT_DEF
-  FOR_EACH_DEFINED_FUNCTION (node)
+  if (TARGET_SUPPORTS_ALIASES)
     {
-      if (node->get_availability () != AVAIL_INTERPOSABLE
-	  || DECL_EXTERNAL (node->decl)
-	  || node->has_aliases_p ()
-	  || lookup_attribute ("noipa", DECL_ATTRIBUTES (node->decl)))
-	continue;
-
-      cgraph_node *alias = 0;
-      cgraph_edge *next_edge;
-      for (cgraph_edge *e = node->callees; e; e = next_edge)
+      FOR_EACH_DEFINED_FUNCTION (node)
 	{
-	  next_edge = e->next_callee;
-	  /* Recursive function calls usually can't be interposed.  */
-
-	  if (!e->recursive_p ())
+	  if (node->get_availability () != AVAIL_INTERPOSABLE
+	      || DECL_EXTERNAL (node->decl)
+	      || node->has_aliases_p ()
+	      || lookup_attribute ("noipa", DECL_ATTRIBUTES (node->decl)))
 	    continue;
 
-	  if (!alias)
+	  cgraph_node *alias = 0;
+	  cgraph_edge *next_edge;
+	  for (cgraph_edge *e = node->callees; e; e = next_edge)
 	    {
-	      alias = dyn_cast<cgraph_node *> (node->noninterposable_alias ());
-	      gcc_assert (alias && alias != node);
-	    }
+	      next_edge = e->next_callee;
+	      /* Recursive function calls usually can't be interposed.  */
 
-	  e->redirect_callee (alias);
-	  if (gimple_has_body_p (e->caller->decl))
-	    {
-	      push_cfun (DECL_STRUCT_FUNCTION (e->caller->decl));
-	      cgraph_edge::redirect_call_stmt_to_callee (e);
-	      pop_cfun ();
+	      if (!e->recursive_p ())
+		continue;
+
+	      if (!alias)
+		{
+		  alias
+		    = dyn_cast<cgraph_node *> (node->noninterposable_alias ());
+		  gcc_assert (alias && alias != node);
+		}
+
+	      e->redirect_callee (alias);
+	      if (gimple_has_body_p (e->caller->decl))
+		{
+		  push_cfun (DECL_STRUCT_FUNCTION (e->caller->decl));
+		  cgraph_edge::redirect_call_stmt_to_callee (e);
+		  pop_cfun ();
+		}
 	    }
 	}
     }
-#endif
 
   FOR_EACH_FUNCTION (node)
     {
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index b0eff17b8b5c..6ae35edc5aed 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -4300,6 +4300,8 @@ output_constant_pool_contents (struct rtx_constant_pool *pool)
     if (desc->mark < 0)
       {
 #ifdef ASM_OUTPUT_DEF
+	gcc_checking_assert (TARGET_SUPPORTS_ALIASES);
+
 	const char *name = XSTR (desc->sym, 0);
 	char label[256];
 	char buffer[256 + 32];
@@ -6280,6 +6282,10 @@ do_assemble_alias (tree decl, tree target)
 		  IDENTIFIER_POINTER (id),
 		  IDENTIFIER_POINTER (target));
 # endif
+  /* If symbol aliases aren't actually supported...  */
+  if (!TARGET_SUPPORTS_ALIASES)
+    /* ..., 'ASM_OUTPUT_DEF{,_FROM_DECLS}' better have raised an error.  */
+    gcc_checking_assert (seen_error ());
 #elif defined (ASM_OUTPUT_WEAK_ALIAS) || defined (ASM_WEAKEN_DECL)
   {
     const char *name;
@@ -6349,9 +6355,8 @@ assemble_alias (tree decl, tree target)
       if (TREE_PUBLIC (decl))
 	error ("%qs symbol %q+D must have static linkage", "weakref", decl);
     }
-  else
+  else if (!TARGET_SUPPORTS_ALIASES)
     {
-#if !defined (ASM_OUTPUT_DEF)
 # if !defined(ASM_OUTPUT_WEAK_ALIAS) && !defined (ASM_WEAKEN_DECL)
       error_at (DECL_SOURCE_LOCATION (decl),
 		"alias definitions not supported in this configuration");
@@ -6372,7 +6377,7 @@ assemble_alias (tree decl, tree target)
 	  return;
 	}
 # endif
-#endif
+      gcc_unreachable ();
     }
   TREE_USED (decl) = 1;
 
@@ -7461,6 +7466,8 @@ default_strip_name_encoding (const char *str)
 void
 default_asm_output_anchor (rtx symbol)
 {
+  gcc_checking_assert (TARGET_SUPPORTS_ALIASES);
+
   char buffer[100];
 
   sprintf (buffer, "*. + " HOST_WIDE_INT_PRINT_DEC,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-26  6:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-26  6:38 [gcc r14-4937] More '#ifdef ASM_OUTPUT_DEF' -> 'if (TARGET_SUPPORTS_ALIASES)' etc Thomas Schwinge

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