summaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2013-08-06 18:59:49 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2013-08-06 16:59:49 +0000
commita2e2a66815796bd961250264ff32809bae478a31 (patch)
treee06c2e69d4ad72b54dff08acfb5ac74d389b8f74 /gcc/cgraph.c
parente086adbdb433ea655c8bf0bdcd210baa5a0a63f6 (diff)
downloadgcc-a2e2a66815796bd961250264ff32809bae478a31.tar.gz
cgraph.c (cgraph_get_body): New function based on lto.c implementation.
* cgraph.c (cgraph_get_body): New function based on lto.c implementation. * cgraph.h (cgraph_get_body): Declare. * cgraphclones.c (cgraph_create_virtual_clone): Commonize WPA and LTO paths. * cgraphunit.c (expand_function): Get body prior expanding. * ipa.c (function_and_variable_visibility): Use gimple_has_body_p test. * lto-cgraph.c (lto_output_node): Do not stream bodies we don't really need. * passes.c (do_per_function_toporder): Get body. * tree-inline.c (expand_call_inline): Get body prior inlining it. * tree-ssa-structalias.c (ipa_pta_execute): Get body; skip clones. * lto.c (lto_materialize_function): Do not read body anymore. From-SVN: r201537
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index a90e1a73ff1..bb7016f441d 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -2707,4 +2707,44 @@ cgraph_function_node (struct cgraph_node *node, enum availability *availability)
return node;
}
+/* When doing LTO, read NODE's body from disk if it is not already present. */
+
+bool
+cgraph_get_body (struct cgraph_node *node)
+{
+ struct lto_file_decl_data *file_data;
+ const char *data, *name;
+ size_t len;
+ tree decl = node->symbol.decl;
+
+ if (DECL_RESULT (decl))
+ return false;
+
+ gcc_assert (in_lto_p);
+
+ file_data = node->symbol.lto_file_data;
+ name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+
+ /* We may have renamed the declaration, e.g., a static function. */
+ name = lto_get_decl_name_mapping (file_data, name);
+
+ data = lto_get_section_data (file_data, LTO_section_function_body,
+ name, &len);
+ if (!data)
+ {
+ dump_cgraph_node (stderr, node);
+ fatal_error ("%s: section %s is missing",
+ file_data->file_name,
+ name);
+ }
+
+ gcc_assert (DECL_STRUCT_FUNCTION (decl) == NULL);
+
+ lto_input_function_body (file_data, decl, data);
+ lto_stats.num_function_bodies++;
+ lto_free_section_data (file_data, LTO_section_function_body, name,
+ data, len);
+ return true;
+}
+
#include "gt-cgraph.h"