*参照元 [#m85f98c1] #backlinks *説明 [#z9fe61e6] -パス: [[gcc-8.3/gcc/cfgexpand.c]] -FIXME: これは何? --説明 **引数 [#t8f1ab3e] -function *fun -- --[[gcc-8.3/gcc/function]] **返り値 [#i5f20c02] -unsigned int -- **参考 [#oac2a942] *実装 [#o8b32ca0] unsigned int pass_expand::execute (function *fun) { basic_block bb, init_block; edge_iterator ei; edge e; rtx_insn *var_seq, *var_ret_seq; unsigned i; - --[[gcc-8.3/gcc/basic_block]] --[[gcc-8.3/gcc/edge_interator]] --[[gcc-8.3/gcc/edge]] --[[gcc-8.3/gcc/rtx_insn]] timevar_push (TV_OUT_OF_SSA); rewrite_out_of_ssa (&SA); timevar_pop (TV_OUT_OF_SSA); SA.partition_to_pseudo = XCNEWVEC (rtx, SA.map->num_partitions); - --[[gcc-8.3/gcc/timevar_push()]] --[[gcc-8.3/gcc/rewrite_out_of_ssa()]] --[[gcc-8.3/gcc/timevar_pop()]] --[[gcc-8.3/gcc/XCNEWVEC()]] --[[gcc-8.3/gcc/SA(global)]] if (MAY_HAVE_DEBUG_BIND_STMTS && flag_tree_ter) { gimple_stmt_iterator gsi; FOR_EACH_BB_FN (bb, cfun) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) if (gimple_debug_bind_p (gsi_stmt (gsi))) avoid_deep_ter_for_debug (gsi_stmt (gsi), 0); } - --[[gcc-8.3/gcc/gimple_stmt_iterator]] --[[gcc-8.3/gcc/FOR_EACH_BB_FN()]] --[[gcc-8.3/gcc/gsi_start_bb()]] --[[gcc-8.3/gcc/gsi_end_p()]] --[[gcc-8.3/gcc/gsi_next()]] --[[gcc-8.3/gcc/gimple_debug_bind_p()]] --[[gcc-8.3/gcc/gsi_stmt()]] --[[gcc-8.3/gcc/avoid_deep_ter_for_debug()]] /* Make sure all values used by the optimization passes have sane defaults. */ reg_renumber = 0; /* Some backends want to know that we are expanding to RTL. */ currently_expanding_to_rtl = 1; /* Dominators are not kept up-to-date as we may create new basic-blocks. */ free_dominance_info (CDI_DOMINATORS); rtl_profile_for_bb (ENTRY_BLOCK_PTR_FOR_FN (fun)); - --[[gcc-8.3/gcc/free_dominance_info()]] --[[gcc-8.3/gcc/rtl_profile_for_bb()]] --[[gcc-8.3/gcc/ENTRY_BLOCK_PTR_FOR_FN()]] if (chkp_function_instrumented_p (current_function_decl)) chkp_reset_rtl_bounds (); - --[[gcc-8.3/gcc/chkp_function_instrumented_p()]] --[[gcc-8.3/gcc/chkp_reset_rtl_bounds()]] insn_locations_init (); if (!DECL_IS_BUILTIN (current_function_decl)) { /* Eventually, all FEs should explicitly set function_start_locus. */ if (LOCATION_LOCUS (fun->function_start_locus) == UNKNOWN_LOCATION) set_curr_insn_location (DECL_SOURCE_LOCATION (current_function_decl)); else set_curr_insn_location (fun->function_start_locus); } else set_curr_insn_location (UNKNOWN_LOCATION); prologue_location = curr_insn_location (); - --[[gcc-8.3/gcc/insn_locations_init()]] --[[gcc-8.3/gcc/DECL_IS_BUILTIN()]] --[[gcc-8.3/gcc/LOCATION_LOCUS()]] --[[gcc-8.3/gcc/set_curr_insn_location()]] --[[gcc-8.3/gcc/DECL_SOURCE_LOCATION()]] --[[gcc-8.3/gcc/curr_insn_location()]] #ifdef INSN_SCHEDULING init_sched_attrs (); #endif - --[[gcc-8.3/gcc/init_sched_attrs()]] /* Make sure first insn is a note even if we don't want linenums. This makes sure the first insn will never be deleted. Also, final expects a note to appear there. */ emit_note (NOTE_INSN_DELETED); - --[[gcc-8.3/gcc/emit_note()]] /* Mark arrays indexed with non-constant indices with TREE_ADDRESSABLE. */ discover_nonconstant_array_refs (); targetm.expand_to_rtl_hook (); crtl->init_stack_alignment (); fun->cfg->max_jumptable_ents = 0; - --[[gcc-8.3/gcc/discover_nonconstant_array_refs()]] /* Resovle the function section. Some targets, like ARM EABI rely on knowledge of the function section at exapnsion time to predict distance of calls. */ resolve_unique_section (current_function_decl, 0, flag_function_sections); - --[[gcc-8.3/gcc/resolve_unique_section()]] /* Expand the variables recorded during gimple lowering. */ timevar_push (TV_VAR_EXPAND); start_sequence (); var_ret_seq = expand_used_vars (); var_seq = get_insns (); end_sequence (); timevar_pop (TV_VAR_EXPAND); - --[[gcc-8.3/gcc/start_sequence()]] --[[gcc-8.3/gcc/expand_used_vars()]] --[[gcc-8.3/gcc/get_insns()]] --[[gcc-8.3/gcc/end_sequence()]] /* Honor stack protection warnings. */ if (warn_stack_protect) { if (fun->calls_alloca) warning (OPT_Wstack_protector, "stack protector not protecting local variables: " "variable length buffer"); if (has_short_buffer && !crtl->stack_protect_guard) warning (OPT_Wstack_protector, "stack protector not protecting function: " "all local arrays are less than %d bytes long", (int) PARAM_VALUE (PARAM_SSP_BUFFER_SIZE)); } - --[[gcc-8.3/gcc/warning()]] /* Set up parameters and prepare for return, for the function. */ expand_function_start (current_function_decl); - --[[gcc-8.3/gcc/expand_function_start()]] /* If we emitted any instructions for setting up the variables, emit them before the FUNCTION_START note. */ if (var_seq) { emit_insn_before (var_seq, parm_birth_insn); /* In expand_function_end we'll insert the alloca save/restore before parm_birth_insn. We've just insertted an alloca call. Adjust the pointer to match. */ parm_birth_insn = var_seq; } - --[[gcc-8.3/gcc/emit_insn_before()]] /* Now propagate the RTL assignment of each partition to the underlying var of each SSA_NAME. */ tree name; FOR_EACH_SSA_NAME (i, name, cfun) { /* We might have generated new SSA names in update_alias_info_with_stack_vars. They will have a NULL defining statements, and won't be part of the partitioning, so ignore those. */ if (!SSA_NAME_DEF_STMT (name)) continue; adjust_one_expanded_partition_var (name); } - --[[gcc-8.3/gcc/tree]] --[[gcc-8.3/gcc/FOR_EACH_SSA_NAME()]] --[[gcc-8.3/gcc/SSA_NAME_DEF_STMT()]] --[[gcc-8.3/gcc/adjust_one_expanded_partition_var()]] /* Clean up RTL of variables that straddle across multiple partitions, and check that the rtl of any PARM_DECLs that are not cleaned up is that of their default defs. */ FOR_EACH_SSA_NAME (i, name, cfun) { int part; /* We might have generated new SSA names in update_alias_info_with_stack_vars. They will have a NULL defining statements, and won't be part of the partitioning, so ignore those. */ if (!SSA_NAME_DEF_STMT (name)) continue; part = var_to_partition (SA.map, name); if (part == NO_PARTITION) continue; - --[[gcc-8.3/gcc/SSA_NAME_DEF_STMT()]] --[[gcc-8.3/gcc/var_to_partition()]] /* If this decl was marked as living in multiple places, reset this now to NULL. */ tree var = SSA_NAME_VAR (name); if (var && DECL_RTL_IF_SET (var) == pc_rtx) SET_DECL_RTL (var, NULL); /* Check that the pseudos chosen by assign_parms are those of the corresponding default defs. */ else if (SSA_NAME_IS_DEFAULT_DEF (name) && (TREE_CODE (var) == PARM_DECL || TREE_CODE (var) == RESULT_DECL)) { rtx in = DECL_RTL_IF_SET (var); gcc_assert (in); rtx out = SA.partition_to_pseudo[part]; gcc_assert (in == out); /* Now reset VAR's RTL to IN, so that the _EXPR attrs match those expected by debug backends for each parm and for the result. This is particularly important for stabs, whose register elimination from parm's DECL_RTL may cause -fcompare-debug differences as SET_DECL_RTL changes reg's attrs. So, make sure the RTL already has the parm as the EXPR, so that it won't change. */ SET_DECL_RTL (var, NULL_RTX); if (MEM_P (in)) set_mem_attributes (in, var, true); SET_DECL_RTL (var, in); } } - --[[gcc-8.3/gcc/tree]] --[[gcc-8.3/gcc/SSA_NAME_VAR()]] --[[gcc-8.3/gcc/DECL_RTL_IF_SET()]] --[[gcc-8.3/gcc/SET_DECL_RTL()]] --[[gcc-8.3/gcc/SSA_NAME_IS_DEFAULT_DEF()]] --[[gcc-8.3/gcc/TREE_CODE()]] --[[gcc-8.3/gcc/rtx]] --[[gcc-8.3/gcc/DECL_RTL_IF_SET()]] --[[gcc-8.3/gcc/gcc_assert()]] --[[gcc-8.3/gcc/SET_DECL_RTL()]] --[[gcc-8.3/gcc/MEM_P()]] --[[gcc-8.3/gcc/set_mem_attributes()]] /* If this function is `main', emit a call to `__main' to run global initializers, etc. */ if (DECL_NAME (current_function_decl) && MAIN_NAME_P (DECL_NAME (current_function_decl)) && DECL_FILE_SCOPE_P (current_function_decl)) expand_main_function (); - --[[gcc-8.3/gcc/DECL_NAME()]] --[[gcc-8.3/gcc/MAIN_NAME_P()]] --[[gcc-8.3/gcc/DECL_FILE_SCOPE_P()]] --[[gcc-8.3/gcc/expand_main_function()]] /* Initialize the stack_protect_guard field. This must happen after the call to __main (if any) so that the external decl is initialized. */ if (crtl->stack_protect_guard && targetm.stack_protect_runtime_enabled_p ()) stack_protect_prologue (); expand_phi_nodes (&SA); - --[[gcc-8.3/gcc/stack_protect_prologue()]] --[[gcc-8.3/gcc/expand_phi_nodes()]] /* Release any stale SSA redirection data. */ redirect_edge_var_map_empty (); /* Register rtl specific functions for cfg. */ rtl_register_cfg_hooks (); init_block = construct_init_block (); - --[[gcc-8.3/gcc/redirect_edge_var_map_empty()]] --[[gcc-8.3/gcc/rtl_register_cfg_hooks()]] --[[gcc-8.3/gcc/construct_init_block()]] /* Clear EDGE_EXECUTABLE on the entry edge(s). It is cleaned from the remaining edges later. */ FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR_FOR_FN (fun)->succs) e->flags &= ~EDGE_EXECUTABLE; - --[[gcc-8.3/gcc/FOR_EACH_EDGE()]] --[[gcc-8.3/gcc/ENTRY_BLOCK_PTR_FOR_FN()]] /* If the function has too many markers, drop them while expanding. */ if (cfun->debug_marker_count >= PARAM_VALUE (PARAM_MAX_DEBUG_MARKER_COUNT)) cfun->debug_nonbind_markers = false; lab_rtx_for_bb = new hash_map<basic_block, rtx_code_label *>; FOR_BB_BETWEEN (bb, init_block->next_bb, EXIT_BLOCK_PTR_FOR_FN (fun), next_bb) bb = expand_gimple_basic_block (bb, var_ret_seq != NULL_RTX); if (MAY_HAVE_DEBUG_BIND_INSNS) expand_debug_locations (); if (deep_ter_debug_map) { delete deep_ter_debug_map; deep_ter_debug_map = NULL; } - --[[gcc-8.3/gcc/PARAM_VALUE()]] --[[gcc-8.3/gcc/lab_rtx_for_bb]] --[[gcc-8.3/gcc/hashmap]] --[[gcc-8.3/gcc/basic_block]] --[[gcc-8.3/gcc/rtx_code_label]] --[[gcc-8.3/gcc/FOR_BB_BETWEEN()]] --[[gcc-8.3/gcc/EXIT_BLOCK_PTR_FOR_FN()]] --[[gcc-8.3/gcc/expand_gimple_basic_block()]] --[[gcc-8.3/gcc/expand_debug_locations()]] /* Free stuff we no longer need after GIMPLE optimizations. */ free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); delete_tree_cfg_annotations (fun); timevar_push (TV_OUT_OF_SSA); finish_out_of_ssa (&SA); timevar_pop (TV_OUT_OF_SSA); timevar_push (TV_POST_EXPAND); /* We are no longer in SSA form. */ fun->gimple_df->in_ssa_p = false; loops_state_clear (LOOP_CLOSED_SSA); - --[[gcc-8.3/gcc/free_dominance_info()]] --[[gcc-8.3/gcc/delete_tree_cfg_annotations()]] --[[gcc-8.3/gcc/finish_out_of_ssa()]] --[[gcc-8.3/gcc/loops_state_clear()]] /* Expansion is used by optimization passes too, set maybe_hot_insn_p conservatively to true until they are all profile aware. */ delete lab_rtx_for_bb; free_histograms (fun); construct_exit_block (); insn_locations_finalize (); if (var_ret_seq) { rtx_insn *after = return_label; rtx_insn *next = NEXT_INSN (after); if (next && NOTE_INSN_BASIC_BLOCK_P (next)) after = next; emit_insn_after (var_ret_seq, after); } - --[[gcc-8.3/gcc/free_histograms()]] --[[gcc-8.3/gcc/construct_exit_block()]] --[[gcc-8.3/gcc/insn_locations_finalize()]] --[[gcc-8.3/gcc/rtx_insn]] --[[gcc-8.3/gcc/NEXT_INSN()]] --[[gcc-8.3/gcc/NOTE_INSN_BASIC_BLOCK_P()]] --[[gcc-8.3/gcc/emit_insn_after()]] /* Zap the tree EH table. */ set_eh_throw_stmt_table (fun, NULL); - --[[gcc-8.3/gcc/set_eh_throw_stmt_table()]] /* We need JUMP_LABEL be set in order to redirect jumps, and hence split edges which edge insertions might do. */ rebuild_jump_labels (get_insns ()); - --[[gcc-8.3/gcc/rebuild_jump_labels()]] --[[gcc-8.3/gcc/get_insns()]] FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (fun), EXIT_BLOCK_PTR_FOR_FN (fun), next_bb) { edge e; edge_iterator ei; for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); ) { if (e->insns.r) { rebuild_jump_labels_chain (e->insns.r); /* Put insns after parm birth, but before NOTE_INSNS_FUNCTION_BEG. */ if (e->src == ENTRY_BLOCK_PTR_FOR_FN (fun) && single_succ_p (ENTRY_BLOCK_PTR_FOR_FN (fun))) { rtx_insn *insns = e->insns.r; e->insns.r = NULL; if (NOTE_P (parm_birth_insn) && NOTE_KIND (parm_birth_insn) == NOTE_INSN_FUNCTION_BEG) emit_insn_before_noloc (insns, parm_birth_insn, e->dest); else emit_insn_after_noloc (insns, parm_birth_insn, e->dest); } else commit_one_edge_insertion (e); } else ei_next (&ei); } } - --[[gcc-8.3/gcc/FOR_BB_BETWEEN()]] --[[gcc-8.3/gcc/ENTRY_BLOCK_PTR_FOR_FN()]] --[[gcc-8.3/gcc/edge]] --[[gcc-8.3/gcc/edge_iterator]] --[[gcc-8.3/gcc/ei_start()]] --[[gcc-8.3/gcc/ei_safe_edge()]] --[[gcc-8.3/gcc/rebuild_jump_labels_chain()]] --[[gcc-8.3/gcc/single_succ_p()]] --[[gcc-8.3/gcc/rtx_insn]] --[[gcc-8.3/gcc/NOTE_P()]] --[[gcc-8.3/gcc/NOTE_KIND()]] --[[gcc-8.3/gcc/emit_insn_before_noloc()]] --[[gcc-8.3/gcc/emit_insn_after_noloc()]] --[[gcc-8.3/gcc/commit_one_edge_insertion()]] --[[gcc-8.3/gcc/ei_next()]] /* We're done expanding trees to RTL. */ currently_expanding_to_rtl = 0; flush_mark_addressable_queue (); FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (fun)->next_bb, EXIT_BLOCK_PTR_FOR_FN (fun), next_bb) { edge e; edge_iterator ei; for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); ) { /* Clear EDGE_EXECUTABLE. This flag is never used in the backend. */ e->flags &= ~EDGE_EXECUTABLE; /* At the moment not all abnormal edges match the RTL representation. It is safe to remove them here as find_many_sub_basic_blocks will rediscover them. In the future we should get this fixed properly. */ if ((e->flags & EDGE_ABNORMAL) && !(e->flags & EDGE_SIBCALL)) remove_edge (e); else ei_next (&ei); } } auto_sbitmap blocks (last_basic_block_for_fn (fun)); bitmap_ones (blocks); find_many_sub_basic_blocks (blocks); purge_all_dead_edges (); - --[[gcc-8.3/gcc/flush_mark_addressable_queue()]] --[[gcc-8.3/gcc/FOR_BB_BETWEEN()]] --[[gcc-8.3/gcc/ENTRY_BLOCK_PTR_FOR_FN()]] --[[gcc-8.3/gcc/edge]] --[[gcc-8.3/gcc/edge_iterator]] --[[gcc-8.3/gcc/ei_start()]] --[[gcc-8.3/gcc/ei_safe_edge()]] --[[gcc-8.3/gcc/remove_edge()]] --[[gcc-8.3/gcc/ei_next()]] --[[gcc-8.3/gcc/auto_sbitmap]] --[[gcc-8.3/gcc/last_basic_block_for_fn()]] --[[gcc-8.3/gcc/bitmap_ones()]] --[[gcc-8.3/gcc/find_many_sub_basic_blocks()]] --[[gcc-8.3/gcc/purge_all_dead_edges()]] /* After initial rtl generation, call back to finish generating exception support code. We need to do this before cleaning up the CFG as the code does not expect dead landing pads. */ if (fun->eh->region_tree != NULL) finish_eh_generation (); - --[[gcc-8.3/gcc/finish_eh_generation()]] /* Call expand_stack_alignment after finishing all updates to crtl->preferred_stack_boundary. */ expand_stack_alignment (); - --[[gcc-8.3/gcc/expand_stack_alignment()]] /* Fixup REG_EQUIV notes in the prologue if there are tailcalls in this function. */ if (crtl->tail_call_emit) fixup_tail_calls (); - --[[gcc-8.3/gcc/fixup_tail_calls()]] /* BB subdivision may have created basic blocks that are are only reachable from unlikely bbs but not marked as such in the profile. */ if (optimize) propagate_unlikely_bbs_forward (); - --[[gcc-8.3/gcc/propagate_unlikely_bbs_forward()]] /* Remove unreachable blocks, otherwise we cannot compute dominators which are needed for loop state verification. As a side-effect this also compacts blocks. ??? We cannot remove trivially dead insns here as for example the DRAP reg on i?86 is not magically live at this point. gcc.c-torture/execute/ipa-sra-2.c execution, -Os -m32 fails otherwise. */ cleanup_cfg (CLEANUP_NO_INSN_DEL); checking_verify_flow_info (); - --[[gcc-8.3/gcc/cleanup_cfg()]] --[[gcc-8.3/gcc/checking_verify_flow_info()]] /* Initialize pseudos allocated for hard registers. */ emit_initial_value_sets (); /* And finally unshare all RTL. */ unshare_all_rtl (); - --[[gcc-8.3/gcc/emit_initial_value_sets()]] --[[gcc-8.3/gcc/unshare_all_rtl()]] /* There's no need to defer outputting this function any more; we know we want to output it. */ DECL_DEFER_OUTPUT (current_function_decl) = 0; - --[[gcc-8.3/gcc/DECL_DEFER_OUTPUT()]] /* Now that we're done expanding trees to RTL, we shouldn't have any more CONCATs anywhere. */ generating_concat_p = 0; if (dump_file) { fprintf (dump_file, "\n\n;;\n;; Full RTL generated for this function:\n;;\n"); /* And the pass manager will dump RTL for us. */ } /* If we're emitting a nested function, make sure its parent gets emitted as well. Doing otherwise confuses debug info. */ { tree parent; for (parent = DECL_CONTEXT (current_function_decl); parent != NULL_TREE; parent = get_containing_scope (parent)) if (TREE_CODE (parent) == FUNCTION_DECL) TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1; } TREE_ASM_WRITTEN (current_function_decl) = 1; - --[[gcc-8.3/gcc/tree]] --[[gcc-8.3/gcc/DECL_CONTEXT()]] --[[gcc-8.3/gcc/get_containing_scope()]] --[[gcc-8.3/gcc/TREE_CODE()]] --[[gcc-8.3/gcc/TREE_SYMBOL_REFERENCED()]] --[[gcc-8.3/gcc/DECL_ASSEMBLER_NAME()]] /* After expanding, the return labels are no longer needed. */ return_label = NULL; naked_return_label = NULL; /* After expanding, the tm_restart map is no longer needed. */ if (fun->gimple_df->tm_restart) fun->gimple_df->tm_restart = NULL; /* Tag the blocks with a depth number so that change_scope can find the common parent easily. */ set_block_levels (DECL_INITIAL (fun->decl), 0); default_rtl_profile (); - --[[gcc-8.3/gcc/set_block_levels()]] --[[gcc-8.3/gcc/DECL_INITIAL()]] --[[gcc-8.3/gcc/default_rtl_profile()]] /* For -dx discard loops now, otherwise IL verify in clean_state will ICE. */ if (rtl_dump_and_exit) { cfun->curr_properties &= ~PROP_loops; loop_optimizer_finalize (); } timevar_pop (TV_POST_EXPAND); return 0; } - --[[gcc-8.3/gcc/loop_optimizer_finalize()]] *コメント [#g3ab2476]