From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id E239F3857C75; Tue, 14 Sep 2021 12:35:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E239F3857C75 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/casm-state-v3)] Step #2. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/casm-state-v3 X-Git-Oldrev: de2e6a6036388de831a20678f543b5034b7c8e22 X-Git-Newrev: ba2501581e4b557dbcdb88d91984e9350701cabb Message-Id: <20210914123518.E239F3857C75@sourceware.org> Date: Tue, 14 Sep 2021 12:35:18 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Sep 2021 12:35:19 -0000 https://gcc.gnu.org/g:ba2501581e4b557dbcdb88d91984e9350701cabb commit ba2501581e4b557dbcdb88d91984e9350701cabb Author: Martin Liska Date: Tue Sep 7 13:47:44 2021 +0200 Step #2. Diff: --- gcc/dbxout.c | 12 ++++++------ gcc/dwarf2out.c | 26 +++++++++++++------------- gcc/final.c | 14 +++++++------- gcc/langhooks.c | 2 +- gcc/output.h | 30 +++++++++++++++++++++++------- gcc/targhooks.c | 2 +- gcc/varasm.c | 42 +++++++++++++++--------------------------- 7 files changed, 66 insertions(+), 62 deletions(-) diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 6be282714cf..d41ce0a968f 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -934,7 +934,7 @@ dbxout_function_end (tree decl ATTRIBUTE_UNUSED) if (crtl->has_bb_partition) { dbxout_begin_empty_stabs (N_FUN); - if (in_cold_section_p) + if (casm->in_cold_section_p) dbxout_stab_value_label_diff (crtl->subsections.cold_section_end_label, crtl->subsections.cold_section_label); else @@ -1314,12 +1314,12 @@ dbxout_switch_text_section (void) /* The N_FUN tag at the end of the function is a GNU extension, which may be undesirable, and is unnecessary if we do not have named sections. */ - in_cold_section_p = !in_cold_section_p; + casm->in_cold_section_p = !casm->in_cold_section_p; switch_to_section (current_function_section ()); dbxout_block (DECL_INITIAL (current_function_decl), 0, DECL_ARGUMENTS (current_function_decl), -1); dbxout_function_end (current_function_decl); - in_cold_section_p = !in_cold_section_p; + casm->in_cold_section_p = !casm->in_cold_section_p; switch_to_section (current_function_section ()); @@ -3776,7 +3776,7 @@ dbxout_block (tree block, int depth, tree args, int parent_blocknum) /* If called for the second partition, ignore blocks that don't have any children in the second partition. */ - if (crtl->has_bb_partition && in_cold_section_p && depth == 0) + if (crtl->has_bb_partition && casm->in_cold_section_p && depth == 0) dbx_block_with_cold_children (block); for (; block; block = BLOCK_CHAIN (block)) @@ -3801,7 +3801,7 @@ dbxout_block (tree block, int depth, tree args, int parent_blocknum) the assembler symbols LBBn and LBEn that final will define around the code in this block. */ if (did_output - && BLOCK_IN_COLD_SECTION_P (block) == in_cold_section_p) + && BLOCK_IN_COLD_SECTION_P (block) == casm->in_cold_section_p) { char buf[20]; const char *scope_start; @@ -3829,7 +3829,7 @@ dbxout_block (tree block, int depth, tree args, int parent_blocknum) /* Refer to the marker for the end of the block. */ if (did_output - && BLOCK_IN_COLD_SECTION_P (block) == in_cold_section_p) + && BLOCK_IN_COLD_SECTION_P (block) == casm->in_cold_section_p) { char buf[100]; if (depth == 0) diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 9876750e4f9..44d53e11ffd 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -1295,7 +1295,7 @@ dwarf2out_switch_text_section (void) current_function_funcdef_no); fde->dw_fde_second_begin = ggc_strdup (label); - if (!in_cold_section_p) + if (!casm->in_cold_section_p) { fde->dw_fde_end = crtl->subsections.cold_section_end_label; fde->dw_fde_second_end = crtl->subsections.hot_section_end_label; @@ -17268,7 +17268,7 @@ secname_for_decl (const_tree decl) secname = DECL_SECTION_NAME (decl); else if (current_function_decl && DECL_SECTION_NAME (current_function_decl)) { - if (in_cold_section_p) + if (casm->in_cold_section_p) { section *sec = current_function_section (); if (sec->common.flags & SECTION_NAMED) @@ -17276,7 +17276,7 @@ secname_for_decl (const_tree decl) } secname = DECL_SECTION_NAME (current_function_decl); } - else if (cfun && in_cold_section_p) + else if (cfun && casm->in_cold_section_p) secname = crtl->subsections.cold_section_label; else secname = text_section_label; @@ -17597,12 +17597,12 @@ dw_loc_list (var_loc_list *loc_list, tree decl, int want_address) if (cfun && crtl->has_bb_partition) { - bool save_in_cold_section_p = in_cold_section_p; - in_cold_section_p = first_function_block_is_cold; + bool save_in_cold_section_p = casm->in_cold_section_p; + casm->in_cold_section_p = first_function_block_is_cold; if (loc_list->last_before_switch == NULL) - in_cold_section_p = !in_cold_section_p; + casm->in_cold_section_p = !casm->in_cold_section_p; secname = secname_for_decl (decl); - in_cold_section_p = save_in_cold_section_p; + casm->in_cold_section_p = save_in_cold_section_p; } else secname = secname_for_decl (decl); @@ -17680,10 +17680,10 @@ dw_loc_list (var_loc_list *loc_list, tree decl, int want_address) && crtl->has_bb_partition && node == loc_list->last_before_switch) { - bool save_in_cold_section_p = in_cold_section_p; - in_cold_section_p = !first_function_block_is_cold; + bool save_in_cold_section_p = casm->in_cold_section_p; + casm->in_cold_section_p = !first_function_block_is_cold; secname = secname_for_decl (decl); - in_cold_section_p = save_in_cold_section_p; + casm->in_cold_section_p = save_in_cold_section_p; } if (range_across_switch) @@ -27851,7 +27851,7 @@ create_label: last_{,postcall_}label so that they are not reused this time. */ if (last_var_location_insn == NULL_RTX || last_var_location_insn != next_real - || last_in_cold_section_p != in_cold_section_p) + || last_in_cold_section_p != casm->in_cold_section_p) { last_label = NULL; last_postcall_label = NULL; @@ -28022,7 +28022,7 @@ create_label: } last_var_location_insn = next_real; - last_in_cold_section_p = in_cold_section_p; + last_in_cold_section_p = casm->in_cold_section_p; } /* Check whether BLOCK, a lexical block, is nested within OUTER, or is @@ -28207,7 +28207,7 @@ set_cur_line_info_table (section *sec) if (crtl->has_bb_partition) { - if (in_cold_section_p) + if (casm->in_cold_section_p) end_label = crtl->subsections.cold_section_end_label; else end_label = crtl->subsections.hot_section_end_label; diff --git a/gcc/final.c b/gcc/final.c index ac6892d041c..481e1ef6835 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -2189,10 +2189,10 @@ final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, if (targetm.asm_out.unwind_emit) targetm.asm_out.unwind_emit (asm_out_file, insn); - in_cold_section_p = !in_cold_section_p; + casm->in_cold_section_p = !casm->in_cold_section_p; - gcc_checking_assert (in_cold_section_p); - if (in_cold_section_p) + gcc_checking_assert (casm->in_cold_section_p); + if (casm->in_cold_section_p) cold_function_name = clone_function_name (current_function_decl, "cold"); @@ -2213,10 +2213,10 @@ final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, switch_to_section (current_function_section ()); targetm.asm_out.function_switched_text_sections (asm_out_file, current_function_decl, - in_cold_section_p); + casm->in_cold_section_p); /* Emit a label for the split cold section. Form label name by suffixing "cold" to the original function's name. */ - if (in_cold_section_p) + if (casm->in_cold_section_p) { #ifdef ASM_DECLARE_COLD_FUNCTION_NAME ASM_DECLARE_COLD_FUNCTION_NAME (asm_out_file, @@ -2323,7 +2323,7 @@ final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, /* Mark this block as output. */ TREE_ASM_WRITTEN (NOTE_BLOCK (insn)) = 1; - BLOCK_IN_COLD_SECTION_P (NOTE_BLOCK (insn)) = in_cold_section_p; + BLOCK_IN_COLD_SECTION_P (NOTE_BLOCK (insn)) = casm->in_cold_section_p; } if (write_symbols == DBX_DEBUG) { @@ -2358,7 +2358,7 @@ final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, if (!DECL_IGNORED_P (current_function_decl)) debug_hooks->end_block (high_block_linenum, n); gcc_assert (BLOCK_IN_COLD_SECTION_P (NOTE_BLOCK (insn)) - == in_cold_section_p); + == casm->in_cold_section_p); } if (write_symbols == DBX_DEBUG) { diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 48c72377778..9a19652a953 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -803,7 +803,7 @@ lhd_begin_section (const char *name) /* Save the old section so we can restore it in lto_end_asm_section. */ gcc_assert (!saved_section); - saved_section = in_section; + saved_section = casm->in_section; if (!saved_section) saved_section = text_section; diff --git a/gcc/output.h b/gcc/output.h index c7ee25c2bd4..e8e2a823a0d 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -313,25 +313,41 @@ extern rtx_sequence *final_sequence; /* File in which assembler code is being written. */ +struct section_hasher : ggc_ptr_hash
+{ + typedef const char *compare_type; + + static hashval_t hash (section *); + static bool equal (section *, const char *); +}; + struct GTY(()) asm_out_state { - asm_out_state (): out_file (NULL), m_in_section (NULL), - m_in_cold_section_p (false) - {} + asm_out_state (): out_file (NULL), in_section (NULL), + in_cold_section_p (false) + { + section_htab = hash_table::create_ggc (31); + } /* Assembly output stream. */ FILE * GTY((skip)) out_file; - section *m_in_section; - bool m_in_cold_section_p; + /* Hash table of named sections. */ + hash_table *section_htab; + + /* asm_out_file's current section. This is NULL if no section has yet + been selected or if we lose track of what the current section is. */ + section *in_section; + + /* True if code for the current function is currently being directed + at the cold section. */ + bool in_cold_section_p; }; extern GTY(()) asm_out_state *casm; /* Helper macro for commonly used accesses. */ #define asm_out_file casm->out_file -#define in_section casm->m_in_section -#define in_cold_section_p casm->m_in_cold_section_p /* The first global object in the file. */ extern const char *first_global_object_name; diff --git a/gcc/targhooks.c b/gcc/targhooks.c index c9b5208853d..68660186ec5 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1962,7 +1962,7 @@ default_print_patchable_function_entry_1 (FILE *file, { char buf[256]; static int patch_area_number; - section *previous_section = in_section; + section *previous_section = casm->in_section; const char *asm_op = integer_asm_op (POINTER_SIZE_UNITS, false); gcc_assert (asm_op != NULL); diff --git a/gcc/varasm.c b/gcc/varasm.c index b876063f5be..a5e550d81ea 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -173,17 +173,6 @@ static GTY(()) section *unnamed_sections; #define IN_NAMED_SECTION(DECL) \ (VAR_OR_FUNCTION_DECL_P (DECL) && DECL_SECTION_NAME (DECL) != NULL) -struct section_hasher : ggc_ptr_hash
-{ - typedef const char *compare_type; - - static hashval_t hash (section *); - static bool equal (section *, const char *); -}; - -/* Hash table of named sections. */ -static GTY(()) hash_table *section_htab; - struct object_block_hasher : ggc_ptr_hash { typedef const section *compare_type; @@ -286,8 +275,8 @@ get_section (const char *name, unsigned int flags, tree decl, { section *sect, **slot; - slot = section_htab->find_slot_with_hash (name, htab_hash_string (name), - INSERT); + slot = casm->section_htab->find_slot_with_hash (name, htab_hash_string (name), + INSERT); flags |= SECTION_NAMED; if (decl != nullptr && DECL_P (decl) @@ -710,7 +699,7 @@ function_section (tree decl) section * current_function_section (void) { - return function_section_1 (current_function_decl, in_cold_section_p); + return function_section_1 (current_function_decl, casm->in_cold_section_p); } /* Tell assembler to switch to unlikely-to-be-executed text section. */ @@ -738,7 +727,7 @@ unlikely_text_section_p (section *sect) void switch_to_other_text_partition (void) { - in_cold_section_p = !in_cold_section_p; + casm->in_cold_section_p = !casm->in_cold_section_p; switch_to_section (current_function_section ()); } @@ -1816,7 +1805,7 @@ decide_function_section (tree decl) == NODE_FREQUENCY_UNLIKELY_EXECUTED); } - in_cold_section_p = first_function_block_is_cold; + casm->in_cold_section_p = first_function_block_is_cold; } /* Get the function's name, as described by its RTL. This may be @@ -1898,7 +1887,7 @@ assemble_start_function (tree decl, const char *fnname) hot_label_written = true; first_function_block_is_cold = true; } - in_cold_section_p = first_function_block_is_cold; + casm->in_cold_section_p = first_function_block_is_cold; } @@ -2012,7 +2001,7 @@ assemble_end_function (tree decl, const char *fnname ATTRIBUTE_UNUSED) { section *save_text_section; - save_text_section = in_section; + save_text_section = casm->in_section; switch_to_section (unlikely_text_section ()); #ifdef ASM_DECLARE_COLD_FUNCTION_SIZE if (cold_function_name != NULL_TREE) @@ -2042,7 +2031,7 @@ assemble_zeros (unsigned HOST_WIDE_INT size) #ifdef ASM_NO_SKIP_IN_TEXT /* The `space' pseudo in the text section outputs nop insns rather than 0s, so we must output 0s explicitly in the text section. */ - if (ASM_NO_SKIP_IN_TEXT && (in_section->common.flags & SECTION_CODE) != 0) + if (ASM_NO_SKIP_IN_TEXT && (casm->in_section->common.flags & SECTION_CODE) != 0) { unsigned HOST_WIDE_INT i; for (i = 0; i < size; i++) @@ -4184,8 +4173,8 @@ output_constant_pool_1 (class constant_descriptor_rtx *desc, /* Make sure all constants in SECTION_MERGE and not SECTION_STRINGS sections have proper size. */ if (align > GET_MODE_BITSIZE (desc->mode) - && in_section - && (in_section->common.flags & SECTION_MERGE)) + && casm->in_section + && (casm->in_section->common.flags & SECTION_MERGE)) assemble_align (align); #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY @@ -6588,7 +6577,6 @@ make_decl_one_only (tree decl, tree comdat_group) void init_varasm_once (void) { - section_htab = hash_table::create_ggc (31); object_block_htab = hash_table::create_ggc (31); const_desc_htab = hash_table::create_ggc (1009); @@ -7810,13 +7798,13 @@ switch_to_section (section *new_section, tree decl) "%qD was declared here", used_decl); } } - else if (in_section == new_section) + else if (casm->in_section == new_section) return; if (new_section->common.flags & SECTION_FORGET) - in_section = NULL; + casm->in_section = NULL; else - in_section = new_section; + casm->in_section = new_section; switch (SECTION_STYLE (new_section)) { @@ -8461,7 +8449,7 @@ handle_vtv_comdat_section (section *sect, const_tree decl ATTRIBUTE_UNUSED) sect->named.common.flags | SECTION_LINKONCE, DECL_NAME (decl)); - in_section = sect; + casm->in_section = sect; #else /* Neither OBJECT_FORMAT_PE, nor OBJECT_FORMAT_COFF is set here. Therefore the following check is used. @@ -8487,7 +8475,7 @@ handle_vtv_comdat_section (section *sect, const_tree decl ATTRIBUTE_UNUSED) sect->named.common.flags | SECTION_LINKONCE, DECL_NAME (decl)); - in_section = sect; + casm->in_section = sect; } else switch_to_section (sect);