/* Callgraph handling code.
- Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Contributed by Jan Hubicka
#include "value-prof.h"
#include "except.h"
#include "diagnostic.h"
+#include "rtl.h"
static void cgraph_node_remove_callers (struct cgraph_node *node);
static inline void cgraph_edge_remove_caller (struct cgraph_edge *e);
|| !node->local.externally_visible));
}
+/* Make DECL local. FIXME: We shouldn't need to mess with rtl this early,
+ but other code such as notice_global_symbol generates rtl. */
+void
+cgraph_make_decl_local (tree decl)
+{
+ rtx rtl, symbol;
+
+ if (TREE_CODE (decl) == VAR_DECL)
+ DECL_COMMON (decl) = 0;
+ else if (TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ DECL_COMDAT (decl) = 0;
+ DECL_COMDAT_GROUP (decl) = 0;
+ DECL_WEAK (decl) = 0;
+ DECL_EXTERNAL (decl) = 0;
+ }
+ else
+ gcc_unreachable ();
+ TREE_PUBLIC (decl) = 0;
+ if (!DECL_RTL_SET_P (decl))
+ return;
+
+ /* Update rtl flags. */
+ make_decl_rtl (decl);
+
+ rtl = DECL_RTL (decl);
+ if (!MEM_P (rtl))
+ return;
+
+ symbol = XEXP (rtl, 0);
+ if (GET_CODE (symbol) != SYMBOL_REF)
+ return;
+
+ SYMBOL_REF_WEAK (symbol) = DECL_WEAK (decl);
+}
+
/* 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_COMDAT_GROUP (node->decl) = 0;
- TREE_PUBLIC (node->decl) = 0;
- DECL_WEAK (node->decl) = 0;
- DECL_EXTERNAL (node->decl) = 0;
+ struct cgraph_node *alias;
+ cgraph_make_decl_local (node->decl);
+
+ for (alias = node->same_body; alias; alias = alias->next)
+ cgraph_make_decl_local (alias->decl);
+
node->local.externally_visible = false;
node->local.local = true;
gcc_assert (cgraph_function_body_availability (node) == AVAIL_LOCAL);