From: Martin Jambor Date: Wed, 10 Jun 2009 16:43:24 +0000 (+0200) Subject: cgraph.c (cgraph_node_can_be_local_p): New function. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a550d677f52207d3620443399e37fd8caff18b5e;p=platform%2Fupstream%2Fgcc.git cgraph.c (cgraph_node_can_be_local_p): New function. 2009-06-10 Martin Jambor * 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. From-SVN: r148349 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c3fe425..e351c2c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2009-06-10 Martin Jambor + + * 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. + 2009-06-10 Nathan Froyd * tree.h (tree_base): Add packed_flag and user_align fields. diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 53475d1..640d180 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1871,4 +1871,32 @@ cgraph_add_new_function (tree fndecl, bool lowered) } } +/* 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" diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 1f05eed..bf3f320 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -505,6 +505,8 @@ void dump_varpool_node (FILE *, struct varpool_node *); 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);