https://gcc.gnu.org/g:8c43a22e05a93b9c131632f8f9b7199cfa4c8f87
commit r17-6192-g8c43a22e05a93b9c131632f8f9b7199cfa4c8f87 Author: Trevor Saunders <[email protected]> Date: Sun Nov 8 21:59:33 2026 +0000 Use tighter insn types for variables that already hold insns gcc/ChangeLog: * cfgexpand.cc (expand_gimple_tailcall): Use rtx_code_label * for copied labels. * config/arm/arm.cc (arm_output_function_epilogue, thumb1_final_prescan_insn, thumb_call_via_reg, arm_file_end): Use rtx_insn * or rtx_code_label * for call-via labels. * config/arm/arm.h (machine_function, CC_STATUS_INIT): Use rtx_code_label * for call_via, rtx_insn * for thumb1_cc_insn, and nullptr to clear it. * config/arm/thumb2.md (doloop_end): Use rtx_insn * for the decrement. * config/bfin/bfin.cc (hwloop_optimize, hwloop_fail): Use rtx_code_label * for end_label and rtx_jump_insn * for the failure jump. * config/c6x/c6x.cc (hwloop_fail): Use rtx_jump_insn * for the failure jump. * config/i386/x86-tune-sched-bd.cc (sched_insn_info_s): Use rtx_insn * for the window insn. * config/m68k/m68k.cc (_sched_ib): Use rtx_insn * for the reservation insn. * config/mcore/mcore.cc (pool_node): Use rtx_insn * for the pool label. * config/pa/pa.cc (deferred_plabel): Use rtx_code_label * for the internal label. * config/riscv/riscv.cc (riscv_expand_prologue): Use rtx_insn * for the prologue insn. * config/rs6000/rs6000-logue.cc (rs6000_emit_load_toc_table): Use rtx_code_label * for the local label. * hw-doloop.h (hwloop_info_d): Use rtx_code_label * for end_label. * reorg.cc (redundant_insn): Use rtx_insn * for target_main. * stmt.cc (emit_case_dispatch_table): Use rtx_code_label * for default_label. Signed-off-by: Trevor Saunders <[email protected]> Diff: --- gcc/cfgexpand.cc | 11 ++++++----- gcc/config/arm/arm.cc | 13 +++++++------ gcc/config/arm/arm.h | 8 ++++---- gcc/config/arm/thumb2.md | 7 ++++--- gcc/config/bfin/bfin.cc | 5 ++--- gcc/config/c6x/c6x.cc | 5 +++-- gcc/config/i386/x86-tune-sched-bd.cc | 2 +- gcc/config/m68k/m68k.cc | 2 +- gcc/config/mcore/mcore.cc | 2 +- gcc/config/pa/pa.cc | 2 +- gcc/config/riscv/riscv.cc | 3 ++- gcc/config/rs6000/rs6000-logue.cc | 12 ++++++------ gcc/hw-doloop.h | 2 +- gcc/reorg.cc | 2 +- gcc/stmt.cc | 4 ++-- 15 files changed, 42 insertions(+), 38 deletions(-) diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc index dad4393b3e5b..c9db3e1bc7cc 100644 --- a/gcc/cfgexpand.cc +++ b/gcc/cfgexpand.cc @@ -4491,7 +4491,7 @@ expand_gimple_tailcall (basic_block bb, gcall *stmt, bool *can_fallthru, /* We need to emit a copy of the asan_epilog_seq before the insns emitted by expand_gimple_stmt above. The sequence can contain labels, which need to be remapped. */ - hash_map<rtx, rtx> label_map; + hash_map<rtx, rtx_code_label *> label_map; start_sequence (); emit_note (NOTE_INSN_DELETED); for (rtx_insn *insn = asan_epilog_seq; insn; insn = NEXT_INSN (insn)) @@ -4503,7 +4503,7 @@ expand_gimple_tailcall (basic_block bb, gcall *stmt, bool *can_fallthru, emit_copy_of_insn_after (insn, get_last_insn ()); break; case CODE_LABEL: - label_map.put ((rtx) insn, (rtx) emit_label (gen_label_rtx ())); + label_map.put ((rtx) insn, emit_label (gen_label_rtx ())); break; case BARRIER: emit_barrier (); @@ -4520,14 +4520,15 @@ expand_gimple_tailcall (basic_block bb, gcall *stmt, bool *can_fallthru, rtx *loc = *iter; if (LABEL_REF_P (*loc)) { - rtx *lab = label_map.get ((rtx) label_ref_label (*loc)); + rtx_code_label **lab + = label_map.get ((rtx) label_ref_label (*loc)); gcc_assert (lab); - set_label_ref_label (*loc, as_a <rtx_insn *> (*lab)); + set_label_ref_label (*loc, *lab); } } if (JUMP_LABEL (insn)) { - rtx *lab = label_map.get (JUMP_LABEL (insn)); + rtx_code_label **lab = label_map.get (JUMP_LABEL (insn)); gcc_assert (lab); JUMP_LABEL (insn) = *lab; } diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index c96eef96deaf..1b4f56ce4ee9 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -853,7 +853,7 @@ const struct tune_params *current_tune; int arm_fpu_attr; /* Used for Thumb call_via trampolines. */ -rtx thumb_call_via_label[14]; +rtx_code_label *thumb_call_via_label[14]; static int thumb_call_reg_needed; /* The bits in this mask specify which instruction scheduling options should @@ -21008,7 +21008,7 @@ arm_output_function_epilogue (FILE *) of call_reg and call_value_reg type insns. */ for (regno = 0; regno < LR_REGNUM; regno++) { - rtx label = cfun->machine->call_via[regno]; + rtx_insn *label = cfun->machine->call_via[regno]; if (label != NULL) { @@ -25685,7 +25685,7 @@ thumb1_final_prescan_insn (rtx_insn *insn) } } else if (conds != CONDS_NOCOND) - cfun->machine->thumb1_cc_insn = NULL_RTX; + cfun->machine->thumb1_cc_insn = nullptr; } /* Check if unexpected far jump is used. */ @@ -27411,7 +27411,7 @@ const char * thumb_call_via_reg (rtx reg) { int regno = REGNO (reg); - rtx *labelp; + rtx_code_label **labelp; gcc_assert (regno < LR_REGNUM); @@ -27433,7 +27433,8 @@ thumb_call_via_reg (rtx reg) labelp = cfun->machine->call_via + regno; } - output_asm_insn ("bl\t%a0", labelp); + rtx temp = *labelp; + output_asm_insn ("bl\t%a0", &temp); return ""; } @@ -27834,7 +27835,7 @@ arm_file_end (void) for (regno = 0; regno < LR_REGNUM; regno++) { - rtx label = thumb_call_via_label[regno]; + rtx_code_label *label = thumb_call_via_label[regno]; if (label != 0) { diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 10786ec914d3..0cb394e810dc 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -1577,13 +1577,13 @@ typedef struct GTY(()) machine_function /* Labels for per-function Thumb call-via stubs. One per potential calling register. We can never call via LR or PC. We can call via SP if a trampoline happens to be on the top of the stack. */ - rtx call_via[14]; + rtx_code_label *call_via[14]; /* Set to 1 when a return insn is output, this means that the epilogue is not needed. */ int return_used_this_function; /* When outputting Thumb-1 code, record the last insn that provides information about condition codes, and the comparison operands. */ - rtx thumb1_cc_insn; + rtx_insn *thumb1_cc_insn; rtx thumb1_cc_op0; rtx thumb1_cc_op1; /* Also record the CC mode that is supported. */ @@ -1605,7 +1605,7 @@ machine_function; /* As in the machine_function, a global set of call-via labels, for code that is in text_section. */ -extern GTY(()) rtx thumb_call_via_label[14]; +extern GTY(()) rtx_code_label *thumb_call_via_label[14]; /* The number of potential ways of assigning to a co-processor. */ #define ARM_NUM_COPROC_SLOTS 1 @@ -2213,7 +2213,7 @@ extern int making_const_table; ((VALUE) = GET_MODE_UNIT_BITSIZE (MODE), 2) #define CC_STATUS_INIT \ - do { cfun->machine->thumb1_cc_insn = NULL_RTX; } while (0) + do { cfun->machine->thumb1_cc_insn = nullptr; } while (0) #undef ASM_APP_ON #define ASM_APP_ON (inline_asm_unified ? "\t.syntax unified\n" : \ diff --git a/gcc/config/arm/thumb2.md b/gcc/config/arm/thumb2.md index 5d352425a19b..b0efc4b91245 100644 --- a/gcc/config/arm/thumb2.md +++ b/gcc/config/arm/thumb2.md @@ -1683,13 +1683,14 @@ } /* Otherwise, try standard decrement-by-one dls/le looping. */ + rtx_insn *add; if (TARGET_THUMB2) - insn = emit_insn (gen_thumb2_addsi3_compare0 (s0, s0, + add = emit_insn (gen_thumb2_addsi3_compare0 (s0, s0, GEN_INT (-1))); else - insn = emit_insn (gen_addsi3_compare0 (s0, s0, GEN_INT (-1))); + add = emit_insn (gen_addsi3_compare0 (s0, s0, GEN_INT (-1))); - cmp = XVECEXP (PATTERN (insn), 0, 0); + cmp = XVECEXP (PATTERN (add), 0, 0); cc_reg = SET_DEST (cmp); bcomp = gen_rtx_NE (VOIDmode, cc_reg, const0_rtx); loc_ref = gen_rtx_LABEL_REF (VOIDmode, operands[1]); diff --git a/gcc/config/bfin/bfin.cc b/gcc/config/bfin/bfin.cc index 015ba054029f..300034e2e37a 100644 --- a/gcc/config/bfin/bfin.cc +++ b/gcc/config/bfin/bfin.cc @@ -3842,8 +3842,7 @@ hwloop_optimize (hwloop_info loop) delete_insn (loop->loop_end); /* Insert the loop end label before the last instruction of the loop. */ - emit_label_before (as_a <rtx_code_label *> (loop->end_label), - loop->last_insn); + emit_label_before (loop->end_label, loop->last_insn); return true; } @@ -3860,8 +3859,8 @@ hwloop_fail (hwloop_info loop) { /* If loop->iter_reg is a DREG or PREG, we can split it here without scratch register. */ - rtx_insn *insn; rtx test; + rtx_jump_insn *insn; emit_insn_before (gen_addsi3 (loop->iter_reg, loop->iter_reg, diff --git a/gcc/config/c6x/c6x.cc b/gcc/config/c6x/c6x.cc index febee9f429d9..e11bf5b1dbaf 100644 --- a/gcc/config/c6x/c6x.cc +++ b/gcc/config/c6x/c6x.cc @@ -5848,11 +5848,12 @@ hwloop_fail (hwloop_info loop) emit_insn_before (gen_movsi (testreg, loop->iter_reg), loop->loop_end); test = gen_rtx_NE (VOIDmode, testreg, const0_rtx); - insn = emit_jump_insn_before (gen_cbranchsi4 (test, testreg, const0_rtx, + rtx_jump_insn *jump; + jump = emit_jump_insn_before (gen_cbranchsi4 (test, testreg, const0_rtx, loop->start_label), loop->loop_end); - JUMP_LABEL (insn) = loop->start_label; + JUMP_LABEL (jump) = loop->start_label; LABEL_NUSES (loop->start_label)++; delete_insn (loop->loop_end); } diff --git a/gcc/config/i386/x86-tune-sched-bd.cc b/gcc/config/i386/x86-tune-sched-bd.cc index 5056fc676e08..a56f10830ced 100644 --- a/gcc/config/i386/x86-tune-sched-bd.cc +++ b/gcc/config/i386/x86-tune-sched-bd.cc @@ -114,7 +114,7 @@ enum insn_path { Windows are allocated for each basic block and are linked together. */ typedef struct sched_insn_info_s { - rtx insn; + rtx_insn *insn; enum dispatch_group group; enum insn_path path; int byte_len; diff --git a/gcc/config/m68k/m68k.cc b/gcc/config/m68k/m68k.cc index 135da62395df..5c91bf9e5a1a 100644 --- a/gcc/config/m68k/m68k.cc +++ b/gcc/config/m68k/m68k.cc @@ -6635,7 +6635,7 @@ struct _sched_ib } records; /* An insn that reserves (marks empty) one word in the instruction buffer. */ - rtx insn; + rtx_insn *insn; }; static struct _sched_ib sched_ib; diff --git a/gcc/config/mcore/mcore.cc b/gcc/config/mcore/mcore.cc index d9e18974168c..f9d13a3381bb 100644 --- a/gcc/config/mcore/mcore.cc +++ b/gcc/config/mcore/mcore.cc @@ -2234,7 +2234,7 @@ mcore_expand_epilog (void) typedef struct { rtx value; /* Value in table. */ - rtx label; /* Label of value. */ + rtx_insn *label; /* Label of value. */ } pool_node; /* The maximum number of constants that can fit into one pool, since diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc index 18f5099a1489..8f0248252bc6 100644 --- a/gcc/config/pa/pa.cc +++ b/gcc/config/pa/pa.cc @@ -244,7 +244,7 @@ static unsigned int last_address; output time. They are output after the current function. */ struct GTY(()) deferred_plabel { - rtx internal_label; + rtx_code_label *internal_label; rtx symbol; }; static GTY((length ("n_deferred_plabels"))) struct deferred_plabel * diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index df81393094bd..d53f72ff9fbe 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -10687,7 +10687,8 @@ riscv_expand_prologue (void) unsigned mask = frame->mask; unsigned fmask = frame->fmask; int spimm, multi_push_additional, stack_adj; - rtx insn, dwarf = NULL_RTX; + rtx dwarf = NULL_RTX; + rtx_insn *insn; unsigned th_int_mask = 0; if (flag_stack_usage_info) diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000-logue.cc index 100c462a40b4..316a5ffc4ee9 100644 --- a/gcc/config/rs6000/rs6000-logue.cc +++ b/gcc/config/rs6000/rs6000-logue.cc @@ -1252,11 +1252,11 @@ rs6000_emit_load_toc_table (int fromprolog) if (TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI == ABI_V4 && flag_pic) { char buf[30]; - rtx lab, tmp1, tmp2, got; + rtx tmp1, tmp2, got; - lab = gen_label_rtx (); + rtx_code_label *lab = gen_label_rtx (); ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (lab)); - lab = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf)); + rtx sym = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf)); if (flag_pic == 2) { got = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (toc_label_name)); @@ -1270,10 +1270,10 @@ rs6000_emit_load_toc_table (int fromprolog) tmp1 = gen_reg_rtx (Pmode); tmp2 = gen_reg_rtx (Pmode); } - emit_insn (gen_load_toc_v4_PIC_1 (lab)); + emit_insn (gen_load_toc_v4_PIC_1 (sym)); emit_move_insn (tmp1, gen_rtx_REG (Pmode, LR_REGNO)); - emit_insn (gen_load_toc_v4_PIC_3b (tmp2, tmp1, got, lab)); - emit_insn (gen_load_toc_v4_PIC_3c (dest, tmp2, got, lab)); + emit_insn (gen_load_toc_v4_PIC_3b (tmp2, tmp1, got, sym)); + emit_insn (gen_load_toc_v4_PIC_3c (dest, tmp2, got, sym)); } else if (TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 1) { diff --git a/gcc/hw-doloop.h b/gcc/hw-doloop.h index 22e05389eb05..26f7486cfb82 100644 --- a/gcc/hw-doloop.h +++ b/gcc/hw-doloop.h @@ -81,7 +81,7 @@ struct GTY (()) hwloop_info_d rtx_insn *start_label; /* The new label placed at the end of the loop. */ - rtx end_label; + rtx_code_label *end_label; /* The length of the loop. */ int length; diff --git a/gcc/reorg.cc b/gcc/reorg.cc index 5e7a4d610b86..d835e033854b 100644 --- a/gcc/reorg.cc +++ b/gcc/reorg.cc @@ -1397,7 +1397,7 @@ static rtx_insn * redundant_insn (rtx_insn *insn, rtx_insn *target, const vec<rtx_insn *> &delay_list) { - rtx target_main = target; + rtx_insn *target_main = target; rtx ipat = PATTERN (insn); rtx_insn *trial; rtx pat; diff --git a/gcc/stmt.cc b/gcc/stmt.cc index b46c6802cdc8..784d7dc07a32 100644 --- a/gcc/stmt.cc +++ b/gcc/stmt.cc @@ -1196,7 +1196,7 @@ conditional_probability (profile_probability target_prob, static void emit_case_dispatch_table (tree index_expr, tree index_type, auto_vec<simple_case_node> &case_list, - rtx default_label, + rtx_code_label *default_label, edge default_edge, tree minval, tree maxval, tree range, basic_block stmt_bb) { @@ -1260,7 +1260,7 @@ emit_case_dispatch_table (tree index_expr, tree index_type, dispatch table slots associated with the gaps with the default case label. However, in the event the default case is unreachable, we then use any label from one of the case statements. */ - rtx gap_label = (default_label) ? default_label : fallback_label; + rtx_insn *gap_label = (default_label) ? default_label : fallback_label; for (i = 0; i < ncases; i++) if (labelvec[i] == 0)
