diff options
Diffstat (limited to 'gcc/ada/gcc-interface')
-rw-r--r-- | gcc/ada/gcc-interface/gigi.h | 5 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/misc.c | 3 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 27 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 43 |
4 files changed, 29 insertions, 49 deletions
diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index de253b8..05a4686 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -678,9 +678,8 @@ extern tree create_label_decl (tree label_name); extern void begin_subprog_body (tree subprog_decl); /* Finish the definition of the current subprogram BODY and compile it all the - way to assembler language output. ELAB_P tells if this is called for an - elaboration routine, to be entirely discarded if empty. */ -extern void end_subprog_body (tree body, bool elab_p); + way to assembler language output. */ +extern void end_subprog_body (tree body); /* Build a template of type TEMPLATE_TYPE from the array bounds of ARRAY_TYPE. EXPR is an expression that we can use to locate any PLACEHOLDER_EXPRs. diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 587eab3..4b68227 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -176,9 +176,6 @@ gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED) /* Call the front end. */ _ada_gnat1drv (); - - /* We always have a single compilation unit in Ada. */ - cgraph_finalize_compilation_unit (); } /* Decode all the language specific options that cannot be decoded by GCC. diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 5b4e5e8..1259967 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -627,6 +627,7 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name, for (info = elab_info_list; info; info = info->next) { tree gnu_body = DECL_SAVED_TREE (info->elab_proc); + tree gnu_stmts; /* Unshare SAVE_EXPRs between subprograms. These are not unshared by the gimplifier for obvious reasons, but it turns out that we need to @@ -638,14 +639,24 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name, an upstream bug for which we would not change the outcome. */ walk_tree_without_duplicates (&gnu_body, unshare_save_expr, NULL); - /* Process the function as others, but for indicating this is an - elab proc, to be discarded if empty, then propagate the status - up to the GNAT tree node. */ - begin_subprog_body (info->elab_proc); - end_subprog_body (gnu_body, true); - if (empty_body_p (gimple_body (info->elab_proc))) - Set_Has_No_Elaboration_Code (info->gnat_node, 1); + /* We should have a BIND_EXPR, but it may or may not have any statements + in it. If it doesn't have any, we have nothing to do. */ + gnu_stmts = gnu_body; + if (TREE_CODE (gnu_stmts) == BIND_EXPR) + gnu_stmts = BIND_EXPR_BODY (gnu_stmts); + + /* If there are no statements, there is no elaboration code. */ + if (!gnu_stmts || !STATEMENT_LIST_HEAD (gnu_stmts)) + { + Set_Has_No_Elaboration_Code (info->gnat_node, 1); + } + else + { + /* Process the function as others. */ + begin_subprog_body (info->elab_proc); + end_subprog_body (gnu_body); + } } /* We cannot track the location of errors past this point. */ @@ -2326,7 +2337,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) : Sloc (gnat_node)), &DECL_STRUCT_FUNCTION (gnu_subprog_decl)->function_end_locus); - end_subprog_body (gnu_result, false); + end_subprog_body (gnu_result); /* Finally annotate the parameters and disconnect the trees for parameters that we have turned into variables since they are now unusable. */ diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index aa12eb7..59d9477 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -203,7 +203,6 @@ static GTY((deletable)) tree free_block_chain; static tree merge_sizes (tree, tree, tree, bool, bool); static tree compute_related_constant (tree, tree); static tree split_plus (tree, tree *); -static void gnat_gimplify_function (tree); static tree float_type_for_precision (int, enum machine_mode); static tree convert_to_fat_pointer (tree, tree); static tree convert_to_thin_pointer (tree, tree); @@ -2070,11 +2069,10 @@ gnat_genericize (tree fndecl) } /* Finish the definition of the current subprogram BODY and compile it all the - way to assembler language output. ELAB_P tells if this is called for an - elaboration routine, to be entirely discarded if empty. */ + way to assembler language output. */ void -end_subprog_body (tree body, bool elab_p) +end_subprog_body (tree body) { tree fndecl = current_function_decl; @@ -2107,44 +2105,19 @@ end_subprog_body (tree body, bool elab_p) /* Perform the required pre-gimplification transformations on the tree. */ gnat_genericize (fndecl); + /* Dump functions before gimplification. */ + dump_function (TDI_original, fndecl); + /* We do different things for nested and non-nested functions. ??? This should be in cgraph. */ if (!DECL_CONTEXT (fndecl)) - { - gnat_gimplify_function (fndecl); - - /* If this is an empty elaboration proc, just discard the node. - Otherwise, compile further. */ - if (elab_p && empty_body_p (gimple_body (fndecl))) - cgraph_remove_node (cgraph_node (fndecl)); - else - cgraph_finalize_function (fndecl, false); - } + cgraph_finalize_function (fndecl, false); else /* Register this function with cgraph just far enough to get it added to our parent's nested function list. */ (void) cgraph_node (fndecl); } -/* Convert FNDECL's code to GIMPLE and handle any nested functions. */ - -static void -gnat_gimplify_function (tree fndecl) -{ - struct cgraph_node *cgn; - - dump_function (TDI_original, fndecl); - gimplify_function_tree (fndecl); - dump_function (TDI_generic, fndecl); - - /* Convert all nested functions to GIMPLE now. We do things in this order - so that items like VLA sizes are expanded properly in the context of the - correct function. */ - cgn = cgraph_node (fndecl); - for (cgn = cgn->nested; cgn; cgn = cgn->next_nested) - gnat_gimplify_function (cgn->decl); -} - tree gnat_builtin_function (tree decl) { @@ -3520,7 +3493,7 @@ build_function_stub (tree gnu_subprog, Entity_Id gnat_subprog) gnat_poplevel (); allocate_struct_function (gnu_stub_decl, false); - end_subprog_body (gnu_body, false); + end_subprog_body (gnu_body); } /* Build a type to be used to represent an aliased object whose nominal @@ -4693,7 +4666,7 @@ gnat_write_global_declarations (void) { /* Proceed to optimize and emit assembly. FIXME: shouldn't be the front end's responsibility to call this. */ - cgraph_optimize (); + cgraph_finalize_compilation_unit (); /* Emit debug info for all global declarations. */ emit_debug_global_declarations (VEC_address (tree, global_decls), |