public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: gcc-patches@gcc.gnu.org
Subject: Cgraph alias reorg 12/14 (ipa.c update)
Date: Fri, 10 Jun 2011 18:39:00 -0000	[thread overview]
Message-ID: <20110610183214.GJ28776@kam.mff.cuni.cz> (raw)

Hi,
the usual update to walk alias nodes, this time for cgraph_local_node_p and
logic deicing whether address is taken.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

	* ipa.c (cgraph_non_local_node_p_1): Break out from ...
	(cgraph_local_node_p): ... here.
	(has_addr_references_p): Break out from ...
	(cgraph_remove_unreachable_nodes): ... here;
Index: ipa.c
===================================================================
--- ipa.c	(revision 174913)
+++ ipa.c	(working copy)
@@ -113,17 +113,48 @@ process_references (struct ipa_ref_list 
     }
 }
 
+
+/* Return true when NODE can not be local. Worker for cgraph_local_node_p.  */
+
+static bool
+cgraph_non_local_node_p_1 (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
+{
+   return !(cgraph_only_called_directly_or_aliased_p (node)
+	    && node->analyzed
+	    && !DECL_EXTERNAL (node->decl)
+	    && !node->local.externally_visible
+	    && !node->reachable_from_other_partition
+	    && !node->in_other_partition);
+}
+
 /* Return true when function can be marked local.  */
 
 static bool
 cgraph_local_node_p (struct cgraph_node *node)
 {
-   return (cgraph_only_called_directly_p (node)
-	   && node->analyzed
-	   && !DECL_EXTERNAL (node->decl)
-	   && !node->local.externally_visible
-	   && !node->reachable_from_other_partition
-	   && !node->in_other_partition);
+   return !cgraph_for_node_and_aliases (cgraph_function_or_thunk_node (node, NULL),
+					cgraph_non_local_node_p_1, NULL, true);
+					
+}
+
+/* Return true when NODE has ADDR reference.  */
+
+static bool
+has_addr_references_p (struct cgraph_node *node,
+		       void *data ATTRIBUTE_UNUSED)
+{
+  int i;
+  struct ipa_ref *ref;
+
+  for (i = 0; ipa_ref_list_refering_iterate (&node->ref_list, i, ref); i++)
+    {
+      /* FIXME: handle aliases correctly.  */
+      gcc_assert (ref->use == IPA_REF_ADDR
+		  || ref->use == IPA_REF_ALIAS);
+      if (ref->use == IPA_REF_ADDR)
+        return true;
+    }
+  return false;
 }
 
 /* Perform reachability analysis and reclaim all unreachable nodes.
@@ -417,16 +448,7 @@ cgraph_remove_unreachable_nodes (bool be
     if (node->address_taken
 	&& !node->reachable_from_other_partition)
       {
-	int i;
-        struct ipa_ref *ref;
-	bool found = false;
-        for (i = 0; ipa_ref_list_refering_iterate (&node->ref_list, i, ref)
-		    && !found; i++)
-	  {
-	    gcc_assert (ref->use == IPA_REF_ADDR);
-	    found = true;
-	  }
-	if (!found)
+	if (!cgraph_for_node_and_aliases (node, has_addr_references_p, NULL, true))
 	  {
 	    if (file)
 	      fprintf (file, " %s", cgraph_node_name (node));

                 reply	other threads:[~2011-06-10 18:32 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=20110610183214.GJ28776@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-patches@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: link
Be 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).