This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] p-ipa merge: Cgraph function locality functions


Hi,

these two tiny functions are used by IPA-SRA (call regularization).
Honza already approved this merge in person so I will commit this
to trunk after bootstrap and testsuite finish running.

Thanks,

Martin


2009-06-09  Martin Jambor  <mjambor@suse.cz>

	* cgraph.c (cgraph_node_can_be_local_p): New function.
	(cgraph_make_node_local): New function.
	* cgraph.h (cgraph_node_can_be_local_p): Declare.
	(cgraph_make_node_local): Declare.

Index: mine/gcc/cgraph.c
===================================================================
--- mine.orig/gcc/cgraph.c	2009-06-09 17:38:07.000000000 +0200
+++ mine/gcc/cgraph.c	2009-06-09 17:44:21.000000000 +0200
@@ -1871,4 +1871,32 @@ cgraph_add_new_function (tree fndecl, bo
     }
 }
 
+/* Return true if NODE can be made local for API change.
+   Extern inline functions and C++ COMDAT functions can be made local
+   at the expense of possible code size growth if function is used in multiple
+   compilation units.  */
+bool
+cgraph_node_can_be_local_p (struct cgraph_node *node)
+{
+  return !node->needed;
+}
+
+/* Bring NODE local.  */
+void
+cgraph_make_node_local (struct cgraph_node *node)
+{
+  gcc_assert (cgraph_node_can_be_local_p (node));
+  if (DECL_COMDAT (node->decl) || DECL_EXTERNAL (node->decl))
+    {
+      DECL_COMDAT (node->decl) = 0;
+      DECL_ONE_ONLY (node->decl) = 0;
+      TREE_PUBLIC (node->decl) = 0;
+      DECL_WEAK (node->decl) = 0;
+      DECL_EXTERNAL (node->decl) = 0;
+      node->local.externally_visible = false;
+      node->local.local = true;
+      gcc_assert (cgraph_function_body_availability (node) == AVAIL_LOCAL);
+    }
+}
+
 #include "gt-cgraph.h"
Index: mine/gcc/cgraph.h
===================================================================
--- mine.orig/gcc/cgraph.h	2009-05-31 23:06:13.000000000 +0200
+++ mine/gcc/cgraph.h	2009-06-09 17:44:21.000000000 +0200
@@ -505,6 +505,8 @@ void dump_varpool_node (FILE *, struct v
 void varpool_finalize_decl (tree);
 bool decide_is_variable_needed (struct varpool_node *, tree);
 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
+void cgraph_make_node_local (struct cgraph_node *);
+bool cgraph_node_can_be_local_p (struct cgraph_node *);
 
 bool varpool_assemble_pending_decls (void);
 bool varpool_assemble_decl (struct varpool_node *node);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]