From d29c259b715bb5873c1b9ecf5af5ce06132a3377 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 19 Jan 2000 01:42:11 -0800 Subject: [PATCH] stupid.c: Die die die. * stupid.c: Die die die. * Makefile.in (OBJS): Remove stupid.o. (stupid.o): Likewise. * except.c (emit_eh_context): Don't emit USEs for stupid. * explow.c (probe_stack_range): Likewise. * flags.h (obey_regdecls): Remove. * flow.c (find_basic_blocks): Don't run try_merge_blocks when not optimizing. (life_analysis): Limit data collection when not optimizing. (mark_regs_live_at_end): Always mark the return value registers. (mark_used_regs): Remove dummy RETURN case. (print_rtl_with_bb): Don't consult obey_regdecls. * function.c (use_variable, use_variable_after): Remove. (assign_parms): Consult optimize not obey_regdecls. (expand_function_start): Don't emit USEs for stupid. (expand_function_end): Likewise. * global.c (build_insn_chain): Export. * integrate.c (expand_inline_function): Kill return-value USE handling code. * jump.c (jump_optimize_1): Do simple jump optimizations and dead code elimination. (calculate_can_reach_end): Remove check_deleted argument. (delete_insn): Patch out insns even when not optimizing. * local-alloc.c (block_alloc): Don't do tying when not optimizing. * rtl.h (use_variable, use_variable_after): Remove declarations. (build_insn_chain): Declare. * stmt.c (expand_value_return): Don't emit USEs for stupid. (expand_end_bindings): Likewise. (expand_decl): Likewise. Consult optimize not obey_regdecls. * toplev.c (obey_regdecls): Remove. (rest_of_compilation): Don't set it. Kill stupid in favour of flow1, local-alloc, and reload. (main): Don't set obey_regdecls. * config/nextstep.c (handle_pragma): Likewise. * alpha/alpha.md (allocate_stack): Don't emit USEs for stupid. * arm/arm.h (CONDITIONAL_REGISTER_USAGE): Don't fix reg 0 for stupid. From-SVN: r31499 --- gcc/ChangeLog | 43 +++ gcc/Makefile.in | 4 +- gcc/config/alpha/alpha.md | 2 - gcc/config/arm/arm.h | 6 - gcc/config/nextstep.c | 12 +- gcc/except.c | 8 - gcc/explow.c | 4 - gcc/flags.h | 5 - gcc/flow.c | 31 +- gcc/function.c | 89 +---- gcc/global.c | 3 +- gcc/integrate.c | 7 - gcc/jump.c | 43 +-- gcc/local-alloc.c | 6 +- gcc/rtl.h | 3 +- gcc/stmt.c | 20 +- gcc/stupid.c | 761 -------------------------------------- gcc/toplev.c | 98 ++--- 18 files changed, 120 insertions(+), 1025 deletions(-) delete mode 100644 gcc/stupid.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0ba4bbc3786..50211e64333 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,46 @@ +2000-01-19 Richard Henderson + + * stupid.c: Die die die. + * Makefile.in (OBJS): Remove stupid.o. + (stupid.o): Likewise. + + * except.c (emit_eh_context): Don't emit USEs for stupid. + * explow.c (probe_stack_range): Likewise. + * flags.h (obey_regdecls): Remove. + * flow.c (find_basic_blocks): Don't run try_merge_blocks + when not optimizing. + (life_analysis): Limit data collection when not optimizing. + (mark_regs_live_at_end): Always mark the return value registers. + (mark_used_regs): Remove dummy RETURN case. + (print_rtl_with_bb): Don't consult obey_regdecls. + * function.c (use_variable, use_variable_after): Remove. + (assign_parms): Consult optimize not obey_regdecls. + (expand_function_start): Don't emit USEs for stupid. + (expand_function_end): Likewise. + * global.c (build_insn_chain): Export. + * integrate.c (expand_inline_function): Kill return-value USE + handling code. + * jump.c (jump_optimize_1): Do simple jump optimizations and + dead code elimination. + (calculate_can_reach_end): Remove check_deleted argument. + (delete_insn): Patch out insns even when not optimizing. + * local-alloc.c (block_alloc): Don't do tying when not optimizing. + * rtl.h (use_variable, use_variable_after): Remove declarations. + (build_insn_chain): Declare. + * stmt.c (expand_value_return): Don't emit USEs for stupid. + (expand_end_bindings): Likewise. + (expand_decl): Likewise. Consult optimize not obey_regdecls. + * toplev.c (obey_regdecls): Remove. + (rest_of_compilation): Don't set it. Kill stupid in favour of + flow1, local-alloc, and reload. + (main): Don't set obey_regdecls. + + * config/nextstep.c (handle_pragma): Likewise. + + * alpha/alpha.md (allocate_stack): Don't emit USEs for stupid. + + * arm/arm.h (CONDITIONAL_REGISTER_USAGE): Don't fix reg 0 for stupid. + 2000-01-18 Kaveh R. Ghazi * alpha-protos.h: PROTO -> PARAMS. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 0ab31152db4..66e06b79e67 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -667,7 +667,7 @@ OBJS = diagnostic.o \ function.o stmt.o except.o expr.o calls.o expmed.o explow.o optabs.o real.o \ builtins.o intl.o varasm.o rtl.o print-rtl.o rtlanal.o emit-rtl.o genrtl.o \ dbxout.o sdbout.o dwarfout.o dwarf2out.o xcoffout.o bitmap.o alias.o gcse.o \ - integrate.o jump.o cse.o loop.o unroll.o flow.o stupid.o combine.o varray.o \ + integrate.o jump.o cse.o loop.o unroll.o flow.o combine.o varray.o \ regclass.o regmove.o local-alloc.o global.o reload.o reload1.o caller-save.o \ insn-peep.o reorg.o haifa-sched.o final.o recog.o reg-stack.o \ insn-opinit.o insn-recog.o insn-extract.o insn-output.o insn-emit.o lcm.o \ @@ -1546,8 +1546,6 @@ integrate.o : integrate.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h \ jump.o : jump.c $(CONFIG_H) system.h $(RTL_H) flags.h hard-reg-set.h $(REGS_H) \ insn-config.h insn-flags.h $(RECOG_H) $(EXPR_H) real.h except.h function.h \ toplev.h insn-attr.h -stupid.o : stupid.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) hard-reg-set.h \ - $(BASIC_BLOCK_H) insn-config.h reload.h flags.h function.h toplev.h simplify-rtx.o : simplify-rtx.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) \ hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) toplev.h \ diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md index 577cbe647e9..7adee1d3133 100644 --- a/gcc/config/alpha/alpha.md +++ b/gcc/config/alpha/alpha.md @@ -5116,8 +5116,6 @@ emit_insn (gen_adddi3 (tmp, tmp, GEN_INT(-8192))); emit_insn (gen_cmpdi (tmp, want)); emit_jump_insn (gen_bgtu (loop_label)); - if (obey_regdecls) - gen_rtx_USE (VOIDmode, tmp); memref = gen_rtx_MEM (DImode, want); MEM_VOLATILE_P (memref) = 1; diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 577cbe88f7d..33f5932a8f4 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -736,14 +736,8 @@ extern const char * structure_size_string; #define SUBTARGET_CONDITIONAL_REGISTER_USAGE #endif -/* If doing stupid life analysis, avoid a bug causing a return value r0 to be - trampled. This effectively reduces the number of available registers by 1. - XXX It is a hack, I know. - XXX Is this still needed? */ #define CONDITIONAL_REGISTER_USAGE \ { \ - if (obey_regdecls) \ - fixed_regs[0] = 1; \ if (TARGET_SOFT_FLOAT) \ { \ int regno; \ diff --git a/gcc/config/nextstep.c b/gcc/config/nextstep.c index 1c658fb1171..f7d85bdad27 100644 --- a/gcc/config/nextstep.c +++ b/gcc/config/nextstep.c @@ -61,13 +61,13 @@ handle_pragma (p_getc, p_ungetc, pname) if (strcmp (pname, "CC_OPT_ON") == 0) { - optimize = 1, obey_regdecls = 0; + optimize = 1; warning ("optimization turned on"); retval = 1; } else if (strcmp (pname, "CC_OPT_OFF") == 0) { - optimize = 0, obey_regdecls = 1; + optimize = 0; warning ("optimization turned off"); retval = 1; } @@ -76,13 +76,7 @@ handle_pragma (p_getc, p_ungetc, pname) extern int initial_optimize_flag; if (optimize != initial_optimize_flag) - { - if (initial_optimize_flag) - obey_regdecls = 0; - else - obey_regdecls = 1; - optimize = initial_optimize_flag; - } + optimize = initial_optimize_flag; warning ("optimization level restored"); retval = 1; } diff --git a/gcc/except.c b/gcc/except.c index 0a09fbdd745..8fdc9c9a764 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -2364,14 +2364,6 @@ emit_eh_context () end_sequence (); emit_insns_before (insns, insn); - - /* At -O0, we must make the context register stay alive so - that the stupid.c register allocator doesn't get confused. */ - if (obey_regdecls != 0) - { - insns = gen_rtx_USE (GET_MODE (XEXP (reg,0)), XEXP (reg,0)); - emit_insn_before (insns, get_last_insn ()); - } } } } diff --git a/gcc/explow.c b/gcc/explow.c index 65e43a71747..1f76dcf081d 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -1556,10 +1556,6 @@ probe_stack_range (first, size) emit_note (NULL_PTR, NOTE_INSN_LOOP_END); emit_label (end_lab); - /* If will be doing stupid optimization, show test_addr is still live. */ - if (obey_regdecls) - emit_insn (gen_rtx_USE (VOIDmode, test_addr)); - emit_stack_probe (last_addr); } } diff --git a/gcc/flags.h b/gcc/flags.h index 92d121cb6ed..8b8e995e5eb 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -57,11 +57,6 @@ extern int optimize; extern int optimize_size; -/* Nonzero means do stupid register allocation. -noreg. - Currently, this is 1 if `optimize' is 0. */ - -extern int obey_regdecls; - /* Don't print functions as they are compiled and don't print times taken by the various passes. -quiet. */ diff --git a/gcc/flow.c b/gcc/flow.c index 0591b007d9d..ac5d204350d 100644 --- a/gcc/flow.c +++ b/gcc/flow.c @@ -436,7 +436,8 @@ find_basic_blocks (f, nregs, file, do_cleanup) delete_unreachable_blocks (); move_stray_eh_region_notes (); record_active_eh_regions (f); - try_merge_blocks (); + if (optimize) + try_merge_blocks (); } /* Mark critical edges. */ @@ -2447,9 +2448,14 @@ life_analysis (f, nregs, file, remove_dead_code) /* We want alias analysis information for local dead store elimination. */ init_alias_analysis (); - flags = PROP_FINAL; - if (! remove_dead_code) - flags &= ~(PROP_SCAN_DEAD_CODE | PROP_KILL_DEAD_CODE); + if (! optimize) + flags = PROP_DEATH_NOTES | PROP_REG_INFO; + else + { + flags = PROP_FINAL; + if (! remove_dead_code) + flags &= ~(PROP_SCAN_DEAD_CODE | PROP_KILL_DEAD_CODE); + } life_analysis_1 (f, nregs, flags); if (! reload_completed) @@ -2835,15 +2841,9 @@ mark_regs_live_at_end (set) } /* Mark function return value. */ - /* ??? Only do this after reload. Consider a non-void function that - omits a return statement. Across that edge we'll have the return - register live, and no set for it. Thus the return register will - be live back through the CFG to the entry, and thus we die. A - possible solution is to emit a clobber at exits without returns. */ type = TREE_TYPE (DECL_RESULT (current_function_decl)); - if (reload_completed - && type != void_type_node) + if (type != void_type_node) { rtx outgoing; @@ -4643,12 +4643,6 @@ mark_used_regs (needed, live, x, flags, insn) } break; - case RETURN: - /* ??? This info should have been gotten from mark_regs_live_at_end, - as applied to the EXIT block, and propagated along the edge that - connects this block to the EXIT. */ - break; - case ASM_OPERANDS: case UNSPEC_VOLATILE: case TRAP_IF: @@ -5112,8 +5106,7 @@ print_rtl_with_bb (outf, rtx_first) if (in_bb_p[INSN_UID(tmp_rtx)] == NOT_IN_BB && GET_CODE (tmp_rtx) != NOTE - && GET_CODE (tmp_rtx) != BARRIER - && ! obey_regdecls) + && GET_CODE (tmp_rtx) != BARRIER) fprintf (outf, ";; Insn is not within a basic block\n"); else if (in_bb_p[INSN_UID(tmp_rtx)] == IN_MULTIPLE_BB) fprintf (outf, ";; Insn is in multiple basic blocks\n"); diff --git a/gcc/function.c b/gcc/function.c index fffeb73e50f..9006d16dd9b 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -3916,45 +3916,6 @@ delete_handlers () } } -/* Output a USE for any register use in RTL. - This is used with -noreg to mark the extent of lifespan - of any registers used in a user-visible variable's DECL_RTL. */ - -void -use_variable (rtl) - rtx rtl; -{ - if (GET_CODE (rtl) == REG) - /* This is a register variable. */ - emit_insn (gen_rtx_USE (VOIDmode, rtl)); - else if (GET_CODE (rtl) == MEM - && GET_CODE (XEXP (rtl, 0)) == REG - && (REGNO (XEXP (rtl, 0)) < FIRST_VIRTUAL_REGISTER - || REGNO (XEXP (rtl, 0)) > LAST_VIRTUAL_REGISTER) - && XEXP (rtl, 0) != current_function_internal_arg_pointer) - /* This is a variable-sized structure. */ - emit_insn (gen_rtx_USE (VOIDmode, XEXP (rtl, 0))); -} - -/* Like use_variable except that it outputs the USEs after INSN - instead of at the end of the insn-chain. */ - -void -use_variable_after (rtl, insn) - rtx rtl, insn; -{ - if (GET_CODE (rtl) == REG) - /* This is a register variable. */ - emit_insn_after (gen_rtx_USE (VOIDmode, rtl), insn); - else if (GET_CODE (rtl) == MEM - && GET_CODE (XEXP (rtl, 0)) == REG - && (REGNO (XEXP (rtl, 0)) < FIRST_VIRTUAL_REGISTER - || REGNO (XEXP (rtl, 0)) > LAST_VIRTUAL_REGISTER) - && XEXP (rtl, 0) != current_function_internal_arg_pointer) - /* This is a variable-sized structure. */ - emit_insn_after (gen_rtx_USE (VOIDmode, XEXP (rtl, 0)), insn); -} - int max_parm_reg_num () { @@ -4495,7 +4456,8 @@ assign_parms (fndecl) } DECL_RTL (parm) = stack_parm; } - else if (! ((obey_regdecls && ! DECL_REGISTER (parm) + else if (! ((! optimize + && ! DECL_REGISTER (parm) && ! DECL_INLINE (fndecl)) /* layout_decl may set this. */ || TREE_ADDRESSABLE (parm) @@ -4579,7 +4541,8 @@ assign_parms (fndecl) /* If we were passed a pointer but the actual value can safely live in a register, put it in one. */ if (passed_pointer && TYPE_MODE (TREE_TYPE (parm)) != BLKmode - && ! ((obey_regdecls && ! DECL_REGISTER (parm) + && ! ((! optimize + && ! DECL_REGISTER (parm) && ! DECL_INLINE (fndecl)) /* layout_decl may set this. */ || TREE_ADDRESSABLE (parm) @@ -6064,32 +6027,19 @@ expand_function_start (subr, parms_have_cleanups) as opposed to parm setup. */ emit_note (NULL_PTR, NOTE_INSN_FUNCTION_BEG); - /* If doing stupid allocation, mark parms as born here. */ - if (GET_CODE (get_last_insn ()) != NOTE) emit_note (NULL_PTR, NOTE_INSN_DELETED); parm_birth_insn = get_last_insn (); - if (obey_regdecls) - { - for (i = LAST_VIRTUAL_REGISTER + 1; i < max_parm_reg; i++) - use_variable (regno_reg_rtx[i]); - - if (current_function_internal_arg_pointer != virtual_incoming_args_rtx) - use_variable (current_function_internal_arg_pointer); - } - context_display = 0; if (current_function_needs_context) { /* Fetch static chain values for containing functions. */ tem = decl_function_context (current_function_decl); - /* If not doing stupid register allocation copy the static chain - pointer into a pseudo. If we have small register classes, copy - the value from memory if static_chain_incoming_rtx is a REG. If - we do stupid register allocation, we use the stack address - generated above. */ - if (tem && ! obey_regdecls) + /* Copy the static chain pointer into a pseudo. If we have + small register classes, copy the value from memory if + static_chain_incoming_rtx is a REG. */ + if (tem) { /* If the static chain originally came in a register, put it back there, then move it out in the next insn. The reason for @@ -6349,27 +6299,6 @@ expand_function_end (filename, line, end_bindings) until next function's body starts. */ immediate_size_expand--; - /* If doing stupid register allocation, - mark register parms as dying here. */ - - if (obey_regdecls) - { - rtx tem; - for (i = LAST_VIRTUAL_REGISTER + 1; i < max_parm_reg; i++) - use_variable (regno_reg_rtx[i]); - - /* Likewise for the regs of all the SAVE_EXPRs in the function. */ - - for (tem = save_expr_regs; tem; tem = XEXP (tem, 1)) - { - use_variable (XEXP (tem, 0)); - use_variable_after (XEXP (tem, 0), parm_birth_insn); - } - - if (current_function_internal_arg_pointer != virtual_incoming_args_rtx) - use_variable (current_function_internal_arg_pointer); - } - clear_pending_stack_adjust (); do_pending_stack_adjust (); @@ -6488,7 +6417,6 @@ expand_function_end (filename, line, end_bindings) GET_MODE (DECL_RTL (DECL_RESULT (current_function_decl)))); emit_move_insn (real_decl_result, DECL_RTL (DECL_RESULT (current_function_decl))); - emit_insn (gen_rtx_USE (VOIDmode, real_decl_result)); /* The delay slot scheduler assumes that current_function_return_rtx holds the hard register containing the return value, not a temporary @@ -6522,7 +6450,6 @@ expand_function_end (filename, line, end_bindings) REG_FUNCTION_VALUE_P (outgoing) = 1; emit_move_insn (outgoing, value_address); - use_variable (outgoing); } /* If this is an implementation of __throw, do what's necessary to diff --git a/gcc/global.c b/gcc/global.c index 949e88d6348..7fdc0bed722 100644 --- a/gcc/global.c +++ b/gcc/global.c @@ -305,7 +305,6 @@ static void dump_conflicts PARAMS ((FILE *)); static void reg_becomes_live PARAMS ((rtx, rtx, void *)); static void reg_dies PARAMS ((int, enum machine_mode, struct insn_chain *)); -static void build_insn_chain PARAMS ((rtx)); /* Perform allocation of pseudo-registers not allocated by local_alloc. FILE is a file to output debugging information on, @@ -1757,7 +1756,7 @@ reg_dies (regno, mode, chain) /* Walk the insns of the current function and build reload_insn_chain, and record register life information. */ -static void +void build_insn_chain (first) rtx first; { diff --git a/gcc/integrate.c b/gcc/integrate.c index 0cbff9d05f3..8b3fff718a5 100644 --- a/gcc/integrate.c +++ b/gcc/integrate.c @@ -1099,13 +1099,6 @@ expand_inline_function (fndecl, parms, target, ignore, type, pattern = PATTERN (insn); set = single_set (insn); copy = 0; - if (GET_CODE (pattern) == USE - && GET_CODE (XEXP (pattern, 0)) == REG - && REG_FUNCTION_VALUE_P (XEXP (pattern, 0))) - /* The (USE (REG n)) at return from the function should - be ignored since we are changing (REG n) into - inline_target. */ - break; /* If the inline fn needs eh context, make sure that the current fn has one. */ diff --git a/gcc/jump.c b/gcc/jump.c index 785aa41faa1..9028be1ae6d 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -112,7 +112,7 @@ static void delete_barrier_successors PARAMS ((rtx)); static void mark_all_labels PARAMS ((rtx, int)); static rtx delete_unreferenced_labels PARAMS ((rtx)); static void delete_noop_moves PARAMS ((rtx)); -static int calculate_can_reach_end PARAMS ((rtx, int, int)); +static int calculate_can_reach_end PARAMS ((rtx, int)); static int duplicate_loop_exit_test PARAMS ((rtx)); static void find_cross_jump PARAMS ((rtx, rtx, int, rtx *, rtx *)); static void do_cross_jump PARAMS ((rtx, rtx, rtx)); @@ -232,24 +232,8 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan, mark_labels_only) last_insn = delete_unreferenced_labels (f); - if (optimize == 0) - { - /* CAN_REACH_END is persistent for each function. Once set it should - not be cleared. This is especially true for the case where we - delete the NOTE_FUNCTION_END note. CAN_REACH_END is cleared by - the front-end before compiling each function. */ - if (calculate_can_reach_end (last_insn, 1, 0)) - can_reach_end = 1; - - /* Zero the "deleted" flag of all the "deleted" insns. */ - for (insn = f; insn; insn = NEXT_INSN (insn)) - INSN_DELETED_P (insn) = 0; - - goto end; - } - #ifdef HAVE_return - if (HAVE_return) + if (optimize && HAVE_return) { /* If we fall through to the epilogue, see if we can insert a RETURN insn in front of it. If the machine allows it at this point (we might be @@ -275,7 +259,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan, mark_labels_only) This helps some of the optimizations below by having less insns being jumped around. */ - if (! reload_completed && after_regscan) + if (optimize && ! reload_completed && after_regscan) for (insn = f; insn; insn = next) { rtx set = single_set (insn); @@ -389,6 +373,9 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan, mark_labels_only) } } + if (! optimize) + continue; + /* If a jump references the end of the function, try to turn it into a RETURN insn, possibly a conditional one. */ if (JUMP_LABEL (insn) != 0 @@ -986,7 +973,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan, mark_labels_only) CALL_INSN, which some machines, such as the ARC, can do, but this is a very minor optimization. */ if (this_is_condjump && ! this_is_simplejump - && cse_not_expected && optimize > 0 && ! reload_completed + && cse_not_expected && ! reload_completed && BRANCH_COST > 2 && can_reverse_comparison_p (XEXP (SET_SRC (PATTERN (insn)), 0), insn)) @@ -2008,8 +1995,6 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan, mark_labels_only) #endif else { - /* Detect a jump to a jump. */ - /* Look for if (foo) bar; else break; */ /* The insns look like this: insn = condjump label1; @@ -2300,7 +2285,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan, mark_labels_only) not be cleared. This is especially true for the case where we delete the NOTE_FUNCTION_END note. CAN_REACH_END is cleared by the front-end before compiling each function. */ - if (calculate_can_reach_end (last_insn, 0, 1)) + if (calculate_can_reach_end (last_insn, optimize != 0)) can_reach_end = 1; end: @@ -2711,9 +2696,8 @@ delete_noop_moves (f) if we find it. */ static int -calculate_can_reach_end (last, check_deleted, delete_final_note) +calculate_can_reach_end (last, delete_final_note) rtx last; - int check_deleted; int delete_final_note; { rtx insn = last; @@ -2751,9 +2735,7 @@ calculate_can_reach_end (last, check_deleted, delete_final_note) /* See if we backed up to the appropriate type of note. */ if (insn != NULL_RTX && GET_CODE (insn) == NOTE - && NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_END - && (check_deleted == 0 - || ! INSN_DELETED_P (insn))) + && NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_END) { if (delete_final_note) delete_insn (insn); @@ -4320,8 +4302,7 @@ delete_insn (insn) /* Don't delete user-declared labels. Convert them to special NOTEs instead. */ - if (was_code_label && LABEL_NAME (insn) != 0 - && optimize && ! dont_really_delete) + if (was_code_label && LABEL_NAME (insn) != 0 && ! dont_really_delete) { PUT_CODE (insn, NOTE); NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED_LABEL; @@ -4347,7 +4328,7 @@ delete_insn (insn) /* Patch out INSN (and the barrier if any) */ - if (optimize && ! dont_really_delete) + if (! dont_really_delete) { if (prev) { diff --git a/gcc/local-alloc.c b/gcc/local-alloc.c index 20857a908ab..a8bb1e11096 100644 --- a/gcc/local-alloc.c +++ b/gcc/local-alloc.c @@ -1110,7 +1110,8 @@ block_alloc (b) If tying is done, WIN is set nonzero. */ - if (recog_data.n_operands > 1 + if (optimize + && recog_data.n_operands > 1 && recog_data.constraints[0][0] == '=' && recog_data.constraints[0][1] != '&') { @@ -1194,7 +1195,8 @@ block_alloc (b) destination register won't have had a quantity number assigned, since that would prevent combining. */ - if (GET_CODE (PATTERN (insn)) == CLOBBER + if (optimize + && GET_CODE (PATTERN (insn)) == CLOBBER && (r0 = XEXP (PATTERN (insn), 0), GET_CODE (r0) == REG) && (link = find_reg_note (insn, REG_LIBCALL, NULL_RTX)) != 0 diff --git a/gcc/rtl.h b/gcc/rtl.h index 362d293eefb..22ad556423c 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1503,12 +1503,10 @@ extern void record_excess_regs PARAMS ((rtx, rtx, rtx *)); extern void reposition_prologue_and_epilogue_notes PARAMS ((rtx)); extern void thread_prologue_and_epilogue_insns PARAMS ((rtx)); extern int prologue_epilogue_contains PARAMS ((rtx)); -extern void use_variable PARAMS ((rtx)); extern HOST_WIDE_INT get_frame_size PARAMS ((void)); extern void preserve_rtl_expr_result PARAMS ((rtx)); extern void mark_temp_addr_taken PARAMS ((rtx)); extern void update_temp_slot_address PARAMS ((rtx, rtx)); -extern void use_variable_after PARAMS ((rtx, rtx)); extern void purge_addressof PARAMS ((rtx)); /* In reload.c */ @@ -1562,6 +1560,7 @@ extern void dump_global_regs PARAMS ((FILE *)); #ifdef HARD_CONST extern void retry_global_alloc PARAMS ((int, HARD_REG_SET)); #endif +extern void build_insn_chain PARAMS ((rtx)); /* In regclass.c */ extern int reg_classes_intersect_p PARAMS ((enum reg_class, enum reg_class)); diff --git a/gcc/stmt.c b/gcc/stmt.c index 3cb79b19cbd..86509536119 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -2722,8 +2722,6 @@ expand_value_return (val) emit_move_insn (return_reg, val); } - diddle_return_value (USE); - /* Does any pending block have cleanups? */ while (block && block->data.block.cleanups == 0) @@ -3689,14 +3687,6 @@ expand_end_bindings (vars, mark_ends, dont_jump_in) /* Get rid of the beginning-mark if we don't make an end-mark. */ NOTE_LINE_NUMBER (thisblock->data.block.first_insn) = NOTE_INSN_DELETED; - /* If doing stupid register allocation, make sure lives of all - register variables declared here extend thru end of scope. */ - - if (obey_regdecls) - for (decl = vars; decl; decl = TREE_CHAIN (decl)) - if (TREE_CODE (decl) == VAR_DECL && DECL_RTL (decl)) - use_variable (DECL_RTL (decl)); - /* Restore the temporary level of TARGET_EXPRs. */ target_temp_slot_level = thisblock->data.block.block_target_temp_slot_level; @@ -3757,7 +3747,7 @@ expand_decl (decl) && TREE_CODE (type) == REAL_TYPE) && ! TREE_THIS_VOLATILE (decl) && ! TREE_ADDRESSABLE (decl) - && (DECL_REGISTER (decl) || ! obey_regdecls) + && (DECL_REGISTER (decl) || optimize) /* if -fcheck-memory-usage, check all variables. */ && ! current_function_check_memory_usage) { @@ -3889,15 +3879,7 @@ expand_decl (decl) if (TREE_READONLY (decl)) RTX_UNCHANGING_P (DECL_RTL (decl)) = 1; #endif - - /* If doing stupid register allocation, make sure life of any - register variable starts here, at the start of its scope. */ - - if (obey_regdecls) - use_variable (DECL_RTL (decl)); } - - /* Emit code to perform the initialization of a declaration DECL. */ diff --git a/gcc/stupid.c b/gcc/stupid.c deleted file mode 100644 index 6e36b49922b..00000000000 --- a/gcc/stupid.c +++ /dev/null @@ -1,761 +0,0 @@ -/* Dummy data flow analysis for GNU compiler in nonoptimizing mode. - Copyright (C) 1987, 91, 94-96, 98, 99, 2000 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -/* This file performs stupid register allocation, which is used - when cc1 gets the -noreg switch (which is when cc does not get -O). - - Stupid register allocation goes in place of the flow_analysis, - local_alloc and global_alloc passes. combine_instructions cannot - be done with stupid allocation because the data flow info that it needs - is not computed here. - - In stupid allocation, the only user-defined variables that can - go in registers are those declared "register". They are assumed - to have a life span equal to their scope. Other user variables - are given stack slots in the rtl-generation pass and are not - represented as pseudo regs. A compiler-generated temporary - is assumed to live from its first mention to its last mention. - - Since each pseudo-reg's life span is just an interval, it can be - represented as a pair of numbers, each of which identifies an insn by - its position in the function (number of insns before it). The first - thing done for stupid allocation is to compute such a number for each - insn. It is called the suid. Then the life-interval of each - pseudo reg is computed. Then the pseudo regs are ordered by priority - and assigned hard regs in priority order. */ - -#include "config.h" -#include "system.h" - -#include "rtl.h" -#include "hard-reg-set.h" -#include "basic-block.h" -#include "regs.h" -#include "function.h" -#include "insn-config.h" -#include "reload.h" -#include "flags.h" -#include "toplev.h" -#include "tm_p.h" - -/* Vector mapping INSN_UIDs to suids. - The suids are like uids but increase monotonically always. - We use them to see whether a subroutine call came - between a variable's birth and its death. */ - -static int *uid_suid; - -/* Get the suid of an insn. */ - -#define INSN_SUID(INSN) (uid_suid[INSN_UID (INSN)]) - -/* Record the suid of the last CALL_INSN - so we can tell whether a pseudo reg crosses any calls. */ - -static int last_call_suid; - -/* Record the suid of the last NOTE_INSN_SETJMP - so we can tell whether a pseudo reg crosses any setjmp. */ - -static int last_setjmp_suid; - -/* Element N is suid of insn where life span of pseudo reg N ends. - Element is 0 if register N has not been seen yet on backward scan. */ - -static int *reg_where_dead; - -/* Likewise, but point to the insn_chain structure of the insn at which - the reg dies. */ -static struct insn_chain **reg_where_dead_chain; - -/* Element N is suid of insn where life span of pseudo reg N begins. */ -static int *reg_where_born_exact; - -/* Element N is 1 if the birth of pseudo reg N is due to a CLOBBER, - 0 otherwise. */ -static int *reg_where_born_clobber; - -/* Return the suid of the insn where the register is born, or the suid - of the insn before if the birth is due to a CLOBBER. */ -#define REG_WHERE_BORN(N) \ - (reg_where_born_exact[(N)] - reg_where_born_clobber[(N)]) - -/* Numbers of pseudo-regs to be allocated, highest priority first. */ - -static int *reg_order; - -/* Indexed by reg number (hard or pseudo), nonzero if register is live - at the current point in the instruction stream. */ - -static char *regs_live; - -/* Indexed by reg number, nonzero if reg was used in a SUBREG that changes - its size. */ - -static char *regs_change_size; - -/* Indexed by reg number, nonzero if reg crosses a setjmp. */ - -static char *regs_crosses_setjmp; - -/* Indexed by insn's suid, the set of hard regs live after that insn. */ - -static HARD_REG_SET *after_insn_hard_regs; - -/* Record that hard reg REGNO is live after insn INSN. */ - -#define MARK_LIVE_AFTER(INSN,REGNO) \ - SET_HARD_REG_BIT (after_insn_hard_regs[INSN_SUID (INSN)], (REGNO)) - -static int stupid_reg_compare PARAMS ((const PTR,const PTR)); -static int stupid_find_reg PARAMS ((int, enum reg_class, enum machine_mode, - int, int, int)); -static void stupid_mark_refs PARAMS ((rtx, struct insn_chain *)); -static void find_clobbered_regs PARAMS ((rtx, rtx, void *)); -static void mark_hard_ref PARAMS ((rtx, int, struct insn_chain *)); - -/* For communication between stupid_life_analysis and find_clobbered_regs. */ -static struct insn_chain *current_chain; - -/* This function, called via note_stores, marks any hard registers that are - clobbered in an insn as being live in the live_throughout field - of the appropriate insn_chain structure. */ - -static void -find_clobbered_regs (reg, setter, data) - rtx reg, setter; - void *data ATTRIBUTE_UNUSED; -{ - int regno, nregs; - if (setter == 0 || GET_CODE (setter) != CLOBBER) - return; - - if (GET_CODE (reg) == SUBREG) - reg = SUBREG_REG (reg); - - if (GET_CODE (reg) != REG) - return; - regno = REGNO (reg); - if (regno >= FIRST_PSEUDO_REGISTER) - return; - - if (GET_MODE (reg) == VOIDmode) - abort (); - else - nregs = HARD_REGNO_NREGS (regno, GET_MODE (reg)); - while (nregs-- > 0) - { - SET_REGNO_REG_SET (¤t_chain->live_throughout, regno++); - } -} - -/* Stupid life analysis is for the case where only variables declared - `register' go in registers. For this case, we mark all - pseudo-registers that belong to register variables as - dying in the last instruction of the function, and all other - pseudo registers as dying in the last place they are referenced. - Hard registers are marked as dying in the last reference before - the end or before each store into them. */ - -void -stupid_life_analysis (f, nregs, file) - rtx f; - int nregs; - FILE *file; -{ - register int i; - register rtx last, insn; - int max_uid, max_suid; - - current_function_has_computed_jump = 0; - - bzero (regs_ever_live, sizeof regs_ever_live); - - regs_live = (char *) xmalloc (nregs); - - /* First find the last real insn, and count the number of insns, - and assign insns their suids. */ - - for (insn = f, i = 0; insn; insn = NEXT_INSN (insn)) - if (INSN_UID (insn) > i) - i = INSN_UID (insn); - - max_uid = i + 1; - uid_suid = (int *) xmalloc ((i + 1) * sizeof (int)); - - /* Compute the mapping from uids to suids. - Suids are numbers assigned to insns, like uids, - except that suids increase monotonically through the code. */ - - last = 0; /* In case of empty function body */ - for (insn = f, i = 0; insn; insn = NEXT_INSN (insn)) - { - if (GET_RTX_CLASS (GET_CODE (insn)) == 'i') - last = insn; - - INSN_SUID (insn) = ++i; - } - - last_call_suid = i + 1; - last_setjmp_suid = i + 1; - max_suid = i + 1; - - max_regno = nregs; - - /* Allocate tables to record info about regs. */ - - reg_where_dead = (int *) xcalloc (nregs, sizeof (int)); - reg_where_born_exact = (int *) xcalloc (nregs, sizeof (int)); - reg_where_born_clobber = (int *) xcalloc (nregs, sizeof (int)); - reg_where_dead_chain = (struct insn_chain **) - xcalloc (nregs, sizeof (struct insn_chain *)); - reg_order = (int *) xcalloc (nregs, sizeof (int)); - regs_change_size = (char *) xcalloc (nregs, sizeof (char)); - regs_crosses_setjmp = (char *) xcalloc (nregs, sizeof (char)); - - /* Allocate the reg_renumber array */ - allocate_reg_info (max_regno, FALSE, TRUE); - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - reg_renumber[i] = i; - - after_insn_hard_regs = - (HARD_REG_SET *) xcalloc (max_suid, sizeof (HARD_REG_SET)); - - /* Allocate and zero out many data structures - that will record the data from lifetime analysis. */ - - allocate_reg_life_data (); - allocate_bb_life_data (); - - for (i = 0; i < max_regno; i++) - REG_N_DEATHS (i) = 1; - - bzero (regs_live, nregs); - - /* Find where each pseudo register is born and dies, - by scanning all insns from the end to the start - and noting all mentions of the registers. - - Also find where each hard register is live - and record that info in after_insn_hard_regs. - regs_live[I] is 1 if hard reg I is live - at the current point in the scan. - - Build reload_insn_chain while we're walking the insns. */ - - reload_insn_chain = 0; - for (insn = last; insn; insn = PREV_INSN (insn)) - { - register HARD_REG_SET *p = after_insn_hard_regs + INSN_SUID (insn); - struct insn_chain *chain = 0; - - /* Copy the info in regs_live into the element of after_insn_hard_regs - for the current position in the rtl code. */ - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (regs_live[i]) - SET_HARD_REG_BIT (*p, i); - - if (GET_CODE (insn) != NOTE && GET_CODE (insn) != BARRIER) - { - chain = new_insn_chain (); - if (reload_insn_chain) - reload_insn_chain->prev = chain; - chain->next = reload_insn_chain; - chain->prev = 0; - reload_insn_chain = chain; - chain->block = 0; - chain->insn = insn; - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (regs_live[i]) - SET_REGNO_REG_SET (&chain->live_throughout, i); - } - - /* Update which hard regs are currently live - and also the birth and death suids of pseudo regs - based on the pattern of this insn. */ - - if (GET_RTX_CLASS (GET_CODE (insn)) == 'i') - stupid_mark_refs (PATTERN (insn), chain); - - if (GET_CODE (insn) == NOTE - && NOTE_LINE_NUMBER (insn) == NOTE_INSN_SETJMP) - last_setjmp_suid = INSN_SUID (insn); - - /* Mark all call-clobbered regs as dead after each call insn so that - a pseudo whose life span includes this insn will not go in one of - them. If the function contains a non-local goto, mark all hard - registers dead (except for stack related bits). - - Then mark those regs as all dead for the continuing scan - of the insns before the call. */ - - if (GET_CODE (insn) == CALL_INSN) - { - last_call_suid = INSN_SUID (insn); - - if (current_function_has_nonlocal_label) - { - IOR_COMPL_HARD_REG_SET (after_insn_hard_regs[last_call_suid], - fixed_reg_set); - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (! fixed_regs[i]) - regs_live[i] = 0; - } - else - { - IOR_HARD_REG_SET (after_insn_hard_regs[last_call_suid], - call_used_reg_set); - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (call_used_regs[i]) - regs_live[i] = 0; - } - - /* It is important that this be done after processing the insn's - pattern because we want the function result register to still - be live if it's also used to pass arguments. */ - stupid_mark_refs (CALL_INSN_FUNCTION_USAGE (insn), chain); - } - - if (GET_CODE (insn) != NOTE && GET_CODE (insn) != BARRIER) - { - /* The regs_live array doesn't say anything about hard registers - clobbered by this insn. So we need an extra pass over the - pattern. */ - current_chain = chain; - if (GET_RTX_CLASS (GET_CODE (insn)) == 'i') - note_stores (PATTERN (insn), find_clobbered_regs, NULL); - } - - if (GET_CODE (insn) == JUMP_INSN && computed_jump_p (insn)) - current_function_has_computed_jump = 1; - } - - /* Now decide the order in which to allocate the pseudo registers. */ - - for (i = LAST_VIRTUAL_REGISTER + 1; i < max_regno; i++) - reg_order[i] = i; - - qsort (®_order[LAST_VIRTUAL_REGISTER + 1], - max_regno - LAST_VIRTUAL_REGISTER - 1, sizeof (int), - stupid_reg_compare); - - /* Now, in that order, try to find hard registers for those pseudo regs. */ - - for (i = LAST_VIRTUAL_REGISTER + 1; i < max_regno; i++) - { - register int r = reg_order[i]; - - /* Some regnos disappear from the rtl. Ignore them to avoid crash. - Also don't allocate registers that cross a setjmp, or live across - a call if this function receives a nonlocal goto. - Also ignore registers we didn't see during the scan. */ - if (regno_reg_rtx[r] == 0 || regs_crosses_setjmp[r] - || (reg_where_born_exact[r] == 0 && reg_where_dead[r] == 0) - || (REG_N_CALLS_CROSSED (r) > 0 - && current_function_has_nonlocal_label)) - continue; - - /* Now find the best hard-register class for this pseudo register */ - if (N_REG_CLASSES > 1) - reg_renumber[r] = stupid_find_reg (REG_N_CALLS_CROSSED (r), - reg_preferred_class (r), - PSEUDO_REGNO_MODE (r), - REG_WHERE_BORN (r), - reg_where_dead[r], - regs_change_size[r]); - - /* If no reg available in that class, try alternate class. */ - if (reg_renumber[r] == -1 && reg_alternate_class (r) != NO_REGS) - reg_renumber[r] = stupid_find_reg (REG_N_CALLS_CROSSED (r), - reg_alternate_class (r), - PSEUDO_REGNO_MODE (r), - REG_WHERE_BORN (r), - reg_where_dead[r], - regs_change_size[r]); - } - - /* Fill in the pseudo reg life information into the insn chain. */ - for (i = LAST_VIRTUAL_REGISTER + 1; i < max_regno; i++) - { - struct insn_chain *chain; - int regno; - - regno = reg_renumber[i]; - if (regno < 0) - continue; - - chain = reg_where_dead_chain[i]; - SET_REGNO_REG_SET (&chain->dead_or_set, i); - - while ((chain = chain->prev) - && INSN_SUID (chain->insn) > reg_where_born_exact[i]) - SET_REGNO_REG_SET (&chain->live_throughout, i); - - if (chain) - SET_REGNO_REG_SET (&chain->dead_or_set, i); - } - - if (file) - dump_flow_info (file); - - free (regs_live); - free (uid_suid); - free (reg_where_dead); - free (reg_where_born_exact); - free (reg_where_born_clobber); - free (reg_where_dead_chain); - free (reg_order); - free (regs_change_size); - free (regs_crosses_setjmp); - free (after_insn_hard_regs); -} - -/* Comparison function for qsort. - Returns -1 (1) if register *R1P is higher priority than *R2P. */ - -static int -stupid_reg_compare (r1p, r2p) - const PTR r1p; - const PTR r2p; -{ - register int r1 = *(const int *)r1p, r2 = *(const int *)r2p; - register int len1 = reg_where_dead[r1] - REG_WHERE_BORN (r1); - register int len2 = reg_where_dead[r2] - REG_WHERE_BORN (r2); - int tem; - - tem = len2 - len1; - if (tem != 0) - return tem; - - tem = REG_N_REFS (r1) - REG_N_REFS (r2); - if (tem != 0) - return tem; - - /* If regs are equally good, sort by regno, - so that the results of qsort leave nothing to chance. */ - return r1 - r2; -} - -/* Find a block of SIZE words of hard registers in reg_class CLASS - that can hold a value of machine-mode MODE - (but actually we test only the first of the block for holding MODE) - currently free from after insn whose suid is BORN_INSN - through the insn whose suid is DEAD_INSN, - and return the number of the first of them. - Return -1 if such a block cannot be found. - - If CALL_PRESERVED is nonzero, insist on registers preserved - over subroutine calls, and return -1 if cannot find such. - - If CHANGES_SIZE is nonzero, it means this register was used as the - operand of a SUBREG that changes its size. */ - -static int -stupid_find_reg (call_preserved, class, mode, - born_insn, dead_insn, changes_size) - int call_preserved; - enum reg_class class; - enum machine_mode mode; - int born_insn, dead_insn; - int changes_size ATTRIBUTE_UNUSED; -{ - register int i, ins; -#ifdef HARD_REG_SET - register /* Declare them register if they are scalars. */ -#endif - HARD_REG_SET used, this_reg; -#ifdef ELIMINABLE_REGS - static struct {int from, to; } eliminables[] = ELIMINABLE_REGS; -#endif - - /* If this register's life is more than 5,000 insns, we probably - can't allocate it, so don't waste the time trying. This avoids - quadratic behavior on programs that have regularly-occurring - SAVE_EXPRs. */ - if (dead_insn > born_insn + 5000) - return -1; - - COPY_HARD_REG_SET (used, - call_preserved ? call_used_reg_set : fixed_reg_set); - -#ifdef ELIMINABLE_REGS - for (i = 0; i < (int)(sizeof eliminables / sizeof eliminables[0]); i++) - SET_HARD_REG_BIT (used, eliminables[i].from); -#if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM - SET_HARD_REG_BIT (used, HARD_FRAME_POINTER_REGNUM); -#endif -#else - SET_HARD_REG_BIT (used, FRAME_POINTER_REGNUM); -#endif - - for (ins = born_insn; ins < dead_insn; ins++) - IOR_HARD_REG_SET (used, after_insn_hard_regs[ins]); - -#ifdef STACK_REGS - if (current_function_has_computed_jump) - for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++) - SET_HARD_REG_BIT (used, i); -#endif - - IOR_COMPL_HARD_REG_SET (used, reg_class_contents[(int) class]); - -#ifdef CLASS_CANNOT_CHANGE_SIZE - if (changes_size) - IOR_HARD_REG_SET (used, - reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE]); -#endif - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - { -#ifdef REG_ALLOC_ORDER - int regno = reg_alloc_order[i]; -#else - int regno = i; -#endif - - if (! TEST_HARD_REG_BIT (used, regno) - && HARD_REGNO_MODE_OK (regno, mode)) - { - register int j; - register int size1 = HARD_REGNO_NREGS (regno, mode); - for (j = 1; j < size1 && ! TEST_HARD_REG_BIT (used, regno + j); j++); - if (j == size1) - { - CLEAR_HARD_REG_SET (this_reg); - while (--j >= 0) - SET_HARD_REG_BIT (this_reg, regno + j); - for (ins = born_insn; ins < dead_insn; ins++) - { - IOR_HARD_REG_SET (after_insn_hard_regs[ins], this_reg); - } - return regno; - } -#ifndef REG_ALLOC_ORDER - i += j; /* Skip starting points we know will lose */ -#endif - } - } - - return -1; -} - -/* Note that REG is being set or referenced, and add the appropriate - REG_DEAD / REG_UNUSED note(s). For sets, LIVE_BEFORE_P will be 0, - while for references, LIVE_BEFORE_P will be 1. - INSN is the instruction that the reg notes have to be added to. */ -static void -mark_hard_ref (reg, live_before_p, chain) - rtx reg; - int live_before_p; - struct insn_chain *chain; -{ - /* Hard reg: mark it live for continuing scan of previous insns. */ - int regno = REGNO (reg); - char *live = regs_live; - register int j; - int nregs = HARD_REGNO_NREGS (regno, GET_MODE (reg)); - - for (j = nregs - 1; j >= 0; j--) - { - if (! fixed_regs[regno+j] - && (! live_before_p || ! live[regno+j])) - SET_REGNO_REG_SET (&chain->dead_or_set, regno+j); - regs_ever_live[regno+j] = 1; - live[regno+j] = live_before_p; - } -} - -/* Walk X, noting all assignments and references to registers - and recording what they imply about life spans. - INSN is the current insn, supplied so we can find its suid. */ - -static void -stupid_mark_refs (x, chain) - rtx x; - struct insn_chain *chain; -{ - register RTX_CODE code; - register const char *fmt; - register int regno, i; - rtx insn = chain->insn; - - if (x == 0) - return; - - code = GET_CODE (x); - - if (code == SET || code == CLOBBER) - { - if (SET_DEST (x) != 0 - && (GET_CODE (SET_DEST (x)) == REG - || (GET_CODE (SET_DEST (x)) == SUBREG - && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG - && (REGNO (SUBREG_REG (SET_DEST (x))) - >= FIRST_PSEUDO_REGISTER)))) - { - /* Register is being assigned. */ - rtx reg = SET_DEST (x); - - /* If setting a SUBREG, we treat the entire reg as being set. */ - if (GET_CODE (SET_DEST (x)) == SUBREG) - reg = SUBREG_REG (reg); - - regno = REGNO (reg); - - /* For hard regs, update the where-live info. */ - if (regno < FIRST_PSEUDO_REGISTER) - { - register int j - = HARD_REGNO_NREGS (regno, GET_MODE (SET_DEST (x))); - - mark_hard_ref (reg, 0, chain); - - while (--j >= 0) - { - /* The following line is for unused outputs; - they do get stored even though never used again. */ - MARK_LIVE_AFTER (insn, regno+j); - - CLEAR_REGNO_REG_SET (&chain->live_throughout, regno + j); - - /* When a hard reg is clobbered, mark it in use - just before this insn, so it is live all through. */ - if (code == CLOBBER && INSN_SUID (insn) > 0) - SET_HARD_REG_BIT (after_insn_hard_regs[INSN_SUID (insn) - 1], - regno+j); - } - } - /* For pseudo regs, record where born, where dead, number of - times used, and whether live across a call. */ - else - { - /* Update the life-interval bounds of this pseudo reg. */ - - /* When a pseudo-reg is CLOBBERed, it is born just before - the clobbering insn. When setting, just after. */ - int where_born = INSN_SUID (insn) - (code == CLOBBER); - - reg_where_born_exact[regno] = INSN_SUID (insn); - reg_where_born_clobber[regno] = (code == CLOBBER); - - if (reg_where_dead_chain[regno] == 0) - reg_where_dead_chain[regno] = chain; - - /* The reg must live at least one insn even - in it is never again used--because it has to go - in SOME hard reg. Mark it as dying after the current - insn so that it will conflict with any other outputs of - this insn. */ - if (reg_where_dead[regno] < where_born + 2) - { - reg_where_dead[regno] = where_born + 2; - regs_live[regno] = 1; - } - - /* Count the refs of this reg. */ - REG_N_REFS (regno)++; - - if (last_call_suid < reg_where_dead[regno]) - REG_N_CALLS_CROSSED (regno) += 1; - - if (last_setjmp_suid < reg_where_dead[regno]) - regs_crosses_setjmp[regno] = 1; - - /* If this register is clobbered or it is only used in - this insn and is only set, mark it unused. We have - to do this even when not optimizing so that MD patterns - which count on this behavior (e.g., it not causing an - output reload on an insn setting CC) will operate - correctly. */ - if (GET_CODE (SET_DEST (x)) == REG - && (code == CLOBBER - || (REGNO_FIRST_UID (regno) == INSN_UID (insn) - && REGNO_LAST_UID (regno) == INSN_UID (insn) - && ! reg_mentioned_p (SET_DEST (x), - SET_SRC (x))))) - REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_UNUSED, - SET_DEST (x), - REG_NOTES (insn)); - } - } - - /* Record references from the value being set, - or from addresses in the place being set if that's not a reg. - If setting a SUBREG, we treat the entire reg as *used*. */ - if (code == SET) - { - stupid_mark_refs (SET_SRC (x), chain); - if (GET_CODE (SET_DEST (x)) != REG) - stupid_mark_refs (SET_DEST (x), chain); - } - return; - } - - else if (code == SUBREG - && GET_CODE (SUBREG_REG (x)) == REG - && REGNO (SUBREG_REG (x)) >= FIRST_PSEUDO_REGISTER - && (GET_MODE_SIZE (GET_MODE (x)) - != GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) - && (INTEGRAL_MODE_P (GET_MODE (x)) - || INTEGRAL_MODE_P (GET_MODE (SUBREG_REG (x))))) - regs_change_size[REGNO (SUBREG_REG (x))] = 1; - - /* Register value being used, not set. */ - - else if (code == REG) - { - regno = REGNO (x); - if (regno < FIRST_PSEUDO_REGISTER) - /* Hard reg: mark it live for continuing scan of previous insns. */ - mark_hard_ref (x, 1, chain); - else - { - /* Pseudo reg: record first use, last use and number of uses. */ - - reg_where_born_exact[regno] = INSN_SUID (insn); - reg_where_born_clobber[regno] = 0; - REG_N_REFS (regno)++; - if (regs_live[regno] == 0) - { - regs_live[regno] = 1; - reg_where_dead[regno] = INSN_SUID (insn); - reg_where_dead_chain[regno] = chain; - } - } - return; - } - - /* Recursive scan of all other rtx's. */ - - fmt = GET_RTX_FORMAT (code); - for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) - { - if (fmt[i] == 'e') - stupid_mark_refs (XEXP (x, i), chain); - else if (fmt[i] == 'E') - { - register int j; - for (j = XVECLEN (x, i) - 1; j >= 0; j--) - stupid_mark_refs (XVECEXP (x, i, j), chain); - } - } -} diff --git a/gcc/toplev.c b/gcc/toplev.c index 7fac2af3601..c77ea7a5313 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -362,11 +362,6 @@ int pedantic = 0; int in_system_header = 0; -/* Nonzero means do stupid register allocation. - Currently, this is 1 if `optimize' is 0. */ - -int obey_regdecls = 0; - /* Don't print functions as they are compiled and don't print times taken by the various passes. -quiet. */ @@ -3207,13 +3202,6 @@ rest_of_compilation (decl) ggc_collect (); } - /* Now we choose between stupid (pcc-like) register allocation - (if we got the -noreg switch and not -opt) - and smart register allocation. */ - - if (optimize > 0) /* Stupid allocation probably won't work */ - obey_regdecls = 0; /* if optimizations being done. */ - regclass_init (); /* Print function header into flow dump now @@ -3222,34 +3210,23 @@ rest_of_compilation (decl) if (flow_dump) open_dump_file (".08.flow", decl_printable_name (decl, 2)); - if (obey_regdecls) - { - TIMEVAR (flow_time, - { - regclass (insns, max_reg_num (), NULL); - stupid_life_analysis (insns, max_reg_num (), - rtl_dump_file); - }); - } - else - { - /* Do control and data flow analysis, - and write some of the results to dump file. */ + /* Do control and data flow analysis; wrote some of the results to + the dump file. */ - TIMEVAR - (flow_time, - { - find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1); - calculate_loop_depth (rtl_dump_file); - life_analysis (insns, max_reg_num (), rtl_dump_file, 1); - }); + TIMEVAR + (flow_time, + { + find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1); + if (optimize) + calculate_loop_depth (rtl_dump_file); + life_analysis (insns, max_reg_num (), rtl_dump_file, 1); + }); - if (warn_uninitialized || extra_warnings) - { - uninitialized_vars_warning (DECL_INITIAL (decl)); - if (extra_warnings) - setjmp_args_warning (); - } + if (warn_uninitialized || extra_warnings) + { + uninitialized_vars_warning (DECL_INITIAL (decl)); + if (extra_warnings) + setjmp_args_warning (); } /* Dump rtl after flow analysis. */ @@ -3344,24 +3321,20 @@ rest_of_compilation (decl) if (local_reg_dump) open_dump_file (".12.lreg", decl_printable_name (decl, 2)); - /* Unless we did stupid register allocation, - allocate pseudo-regs that are used only within 1 basic block. + /* Allocate pseudo-regs that are used only within 1 basic block. RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the jump optimizer after register allocation and reloading are finished. */ - if (!obey_regdecls) - TIMEVAR (local_alloc_time, - { - /* We recomputed reg usage as part of updating the rest - of life info during sched. */ - if (! flag_schedule_insns) - recompute_reg_usage (insns, ! optimize_size); - regclass (insns, max_reg_num (), rtl_dump_file); - rebuild_label_notes_after_reload = local_alloc (); - }); - else - rebuild_label_notes_after_reload = 0; + TIMEVAR (local_alloc_time, + { + /* We recomputed reg usage as part of updating the rest + of life info during sched. */ + if (! flag_schedule_insns) + recompute_reg_usage (insns, ! optimize_size); + regclass (insns, max_reg_num (), rtl_dump_file); + rebuild_label_notes_after_reload = local_alloc (); + }); /* Dump rtl code after allocating regs within basic blocks. */ @@ -3381,19 +3354,20 @@ rest_of_compilation (decl) if (global_reg_dump) open_dump_file (".13.greg", decl_printable_name (decl, 2)); - /* Unless we did stupid register allocation, - allocate remaining pseudo-regs, then do the reload pass - fixing up any insns that are invalid. */ + /* If optimizing, allocate remaining pseudo-regs. Do the reload + pass fixing up any insns that are invalid. */ TIMEVAR (global_alloc_time, { - if (!obey_regdecls) + if (optimize) failure = global_alloc (rtl_dump_file); else - failure = reload (insns, 0, rtl_dump_file); + { + build_insn_chain (insns); + failure = reload (insns, 0, rtl_dump_file); + } }); - if (failure) goto exit_rest_of_compilation; @@ -3507,10 +3481,8 @@ rest_of_compilation (decl) = optimize > 0 && only_leaf_regs_used () && leaf_function_p (); #endif - /* One more attempt to remove jumps to .+1 - left by dead-store-elimination. - Also do cross-jumping this time - and delete no-op move insns. */ + /* One more attempt to remove jumps to .+1 left by dead-store elimination. + Also do cross-jumping this time and delete no-op move insns. */ if (optimize > 0) { @@ -4573,8 +4545,6 @@ main (argc, argv) } } - obey_regdecls = (optimize == 0); - if (optimize >= 1) { flag_defer_pop = 1; -- 2.30.2