mirror of
https://github.com/pret/agbcc.git
synced 2026-09-30 05:06:27 -05:00
remove unused simple return code
This commit is contained in:
27
gcc/calls.c
27
gcc/calls.c
@@ -1025,21 +1025,6 @@ expand_call (exp, target, ignore)
|
||||
/* This call returns a big structure. */
|
||||
is_const = 0;
|
||||
|
||||
#ifdef PCC_STATIC_STRUCT_RETURN
|
||||
{
|
||||
pcc_struct_value = 1;
|
||||
/* Easier than making that case work right. */
|
||||
if (is_integrable)
|
||||
{
|
||||
/* In case this is a static function, note that it has been
|
||||
used. */
|
||||
if (! TREE_ADDRESSABLE (fndecl))
|
||||
mark_addressable (fndecl);
|
||||
is_integrable = 0;
|
||||
}
|
||||
}
|
||||
#else /* not PCC_STATIC_STRUCT_RETURN */
|
||||
{
|
||||
struct_value_size = int_size_in_bytes (TREE_TYPE (exp));
|
||||
|
||||
if (target && GET_CODE (target) == MEM)
|
||||
@@ -1065,8 +1050,6 @@ expand_call (exp, target, ignore)
|
||||
TREE_USED (d) = 1;
|
||||
target = 0;
|
||||
}
|
||||
}
|
||||
#endif /* not PCC_STATIC_STRUCT_RETURN */
|
||||
}
|
||||
|
||||
/* If called function is inline, try to integrate it. */
|
||||
@@ -2912,21 +2895,11 @@ emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
|
||||
decide where in memory it should come back. */
|
||||
if (aggregate_value_p (type_for_mode (outmode, 0)))
|
||||
{
|
||||
#ifdef PCC_STATIC_STRUCT_RETURN
|
||||
rtx pointer_reg
|
||||
= hard_function_value (build_pointer_type (type_for_mode (outmode, 0)),
|
||||
0);
|
||||
mem_value = gen_rtx_MEM (outmode, pointer_reg);
|
||||
pcc_struct_value = 1;
|
||||
if (value == 0)
|
||||
value = gen_reg_rtx (outmode);
|
||||
#else /* not PCC_STATIC_STRUCT_RETURN */
|
||||
struct_value_size = GET_MODE_SIZE (outmode);
|
||||
if (value != 0 && GET_CODE (value) == MEM)
|
||||
mem_value = value;
|
||||
else
|
||||
mem_value = assign_stack_temp (outmode, GET_MODE_SIZE (outmode), 0);
|
||||
#endif
|
||||
|
||||
/* This call returns a big structure. */
|
||||
is_const = 0;
|
||||
|
||||
@@ -741,65 +741,6 @@ far_jump_used_p()
|
||||
|
||||
static int return_used_this_function = 0;
|
||||
|
||||
char *
|
||||
output_return()
|
||||
{
|
||||
int regno;
|
||||
int live_regs_mask = 0;
|
||||
|
||||
/* If a function is naked, don't use the "return" insn. */
|
||||
if (arm_naked_function_p(current_function_decl))
|
||||
return "";
|
||||
|
||||
return_used_this_function = 1;
|
||||
|
||||
for (regno = 0; regno < 8; regno++)
|
||||
if (regs_ever_live[regno] && !call_used_regs[regno])
|
||||
live_regs_mask |= 1 << regno;
|
||||
|
||||
if (live_regs_mask == 0)
|
||||
{
|
||||
if (leaf_function_p() && !far_jump_used_p())
|
||||
{
|
||||
thumb_exit(asm_out_file, 14);
|
||||
}
|
||||
else if (TARGET_THUMB_INTERWORK)
|
||||
{
|
||||
thumb_exit(asm_out_file, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
asm_fprintf(asm_out_file, "\tpop\t{pc}\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
asm_fprintf(asm_out_file, "\tpop\t{");
|
||||
|
||||
for (regno = 0; live_regs_mask; regno++, live_regs_mask >>= 1)
|
||||
{
|
||||
if (live_regs_mask & 1)
|
||||
{
|
||||
asm_fprintf(asm_out_file, reg_names[regno]);
|
||||
if (live_regs_mask & ~1)
|
||||
asm_fprintf(asm_out_file, ", ");
|
||||
}
|
||||
}
|
||||
|
||||
if (TARGET_THUMB_INTERWORK)
|
||||
{
|
||||
asm_fprintf(asm_out_file, "}\n");
|
||||
thumb_exit(asm_out_file, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
asm_fprintf(asm_out_file, ", pc}\n");
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void
|
||||
thumb_function_prologue(FILE *f, int frame_size)
|
||||
{
|
||||
|
||||
@@ -1148,12 +1148,8 @@ int thumb_shiftable_const ();
|
||||
limited PC addressing range: */
|
||||
#define MACHINE_DEPENDENT_REORG(INSN) thumb_reorg ((INSN))
|
||||
|
||||
/* True if a return instruction can be used in this function. */
|
||||
#define USE_RETURN reload_completed
|
||||
|
||||
extern char * thumb_unexpanded_epilogue ();
|
||||
extern char * output_move_mem_multiple ();
|
||||
extern char * thumb_load_double_from_address ();
|
||||
extern char * output_return ();
|
||||
extern int far_jump_used_p();
|
||||
|
||||
|
||||
@@ -993,12 +993,6 @@
|
||||
""
|
||||
"mov\\tpc, %0")
|
||||
|
||||
(define_insn "return"
|
||||
[(return)]
|
||||
"USE_RETURN"
|
||||
"* return output_return ();"
|
||||
[(set_attr "length" "18")])
|
||||
|
||||
;; Call insns
|
||||
|
||||
(define_expand "call"
|
||||
|
||||
@@ -5690,9 +5690,6 @@ init_function_start (subr, filename, line)
|
||||
/* Set flags used by final.c. */
|
||||
if (aggregate_value_p (DECL_RESULT (subr)))
|
||||
{
|
||||
#ifdef PCC_STATIC_STRUCT_RETURN
|
||||
current_function_returns_pcc_struct = 1;
|
||||
#endif
|
||||
current_function_returns_struct = 1;
|
||||
}
|
||||
|
||||
@@ -5799,17 +5796,7 @@ expand_function_start (subr, parms_have_cleanups)
|
||||
/* Make the label for return statements to jump to, if this machine
|
||||
does not have a one-instruction return and uses an epilogue,
|
||||
or if it returns a structure, or if it has parm cleanups. */
|
||||
#ifdef HAVE_return
|
||||
if (cleanup_label == 0 && HAVE_return
|
||||
&& ! current_function_instrument_entry_exit
|
||||
&& ! current_function_returns_pcc_struct
|
||||
&& ! (current_function_returns_struct && ! optimize))
|
||||
return_label = 0;
|
||||
else
|
||||
return_label = gen_label_rtx ();
|
||||
#else
|
||||
return_label = gen_label_rtx ();
|
||||
#endif
|
||||
|
||||
/* Initialize rtx used to return the value. */
|
||||
/* Do this before assign_parms so that we copy the struct value address
|
||||
@@ -5821,15 +5808,7 @@ expand_function_start (subr, parms_have_cleanups)
|
||||
/* Returning something that won't go in a register. */
|
||||
register rtx value_address = 0;
|
||||
|
||||
#ifdef PCC_STATIC_STRUCT_RETURN
|
||||
if (current_function_returns_pcc_struct)
|
||||
{
|
||||
int size = int_size_in_bytes (TREE_TYPE (DECL_RESULT (subr)));
|
||||
value_address = assemble_static_space (size);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
||||
/* Expect to be passed the address of a place to store the value.
|
||||
If it is passed as an argument, assign_parms will take care of
|
||||
it. */
|
||||
@@ -5838,7 +5817,6 @@ expand_function_start (subr, parms_have_cleanups)
|
||||
value_address = gen_reg_rtx (Pmode);
|
||||
emit_move_insn (value_address, struct_value_incoming_rtx);
|
||||
}
|
||||
}
|
||||
if (value_address)
|
||||
{
|
||||
DECL_RTL (DECL_RESULT (subr))
|
||||
@@ -6370,13 +6348,6 @@ expand_function_end (filename, line, end_bindings)
|
||||
Otherwise, let the rtl chain end here, to drop through
|
||||
into the epilogue. */
|
||||
|
||||
#ifdef HAVE_return
|
||||
if (HAVE_return)
|
||||
{
|
||||
emit_jump_insn (gen_return ());
|
||||
emit_barrier ();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Fix up any gotos that jumped out to the outermost
|
||||
binding level of the function.
|
||||
|
||||
37
gcc/jump.c
37
gcc/jump.c
@@ -243,24 +243,6 @@ jump_optimize (f, cross_jump, noop_moves, after_regscan)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_return
|
||||
if (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
|
||||
after reload for a leaf routine), it will improve optimization for it
|
||||
to be there. */
|
||||
insn = get_last_insn ();
|
||||
while (insn && GET_CODE (insn) == NOTE)
|
||||
insn = PREV_INSN (insn);
|
||||
|
||||
if (insn && GET_CODE (insn) != BARRIER)
|
||||
{
|
||||
emit_jump_insn (gen_return ());
|
||||
emit_barrier ();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (noop_moves)
|
||||
delete_noop_moves (f);
|
||||
@@ -2072,25 +2054,6 @@ jump_optimize (f, cross_jump, noop_moves, after_regscan)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_return
|
||||
if (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
|
||||
after reload for a leaf routine), it will improve optimization for it
|
||||
to be there. We do this both here and at the start of this pass since
|
||||
the RETURN might have been deleted by some of our optimizations. */
|
||||
insn = get_last_insn ();
|
||||
while (insn && GET_CODE (insn) == NOTE)
|
||||
insn = PREV_INSN (insn);
|
||||
|
||||
if (insn && GET_CODE (insn) != BARRIER)
|
||||
{
|
||||
emit_jump_insn (gen_return ());
|
||||
emit_barrier ();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
can_reach_end = calculate_can_reach_end (last_insn, 0, 1);
|
||||
|
||||
|
||||
138
gcc/reorg.c
138
gcc/reorg.c
@@ -374,17 +374,6 @@ find_end_label ()
|
||||
end_of_function_label = gen_label_rtx ();
|
||||
LABEL_NUSES (end_of_function_label) = 0;
|
||||
emit_label (end_of_function_label);
|
||||
#ifdef HAVE_return
|
||||
if (HAVE_return)
|
||||
{
|
||||
/* The return we make may have delay slots too. */
|
||||
rtx insn = gen_return ();
|
||||
insn = emit_jump_insn (insn);
|
||||
emit_barrier ();
|
||||
if (num_delay_slots (insn) > 0)
|
||||
obstack_ptr_grow (&unfilled_slots_obstack, insn);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Show one additional use for this label so it won't go away until
|
||||
@@ -3353,129 +3342,6 @@ relax_delay_slots (first)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_return
|
||||
|
||||
/* Look for filled jumps to the end of function label. We can try to convert
|
||||
them into RETURN insns if the insns in the delay slot are valid for the
|
||||
RETURN as well. */
|
||||
|
||||
static void
|
||||
make_return_insns (first)
|
||||
rtx first;
|
||||
{
|
||||
rtx insn, jump_insn, pat;
|
||||
rtx real_return_label = end_of_function_label;
|
||||
int slots, i;
|
||||
|
||||
/* See if there is a RETURN insn in the function other than the one we
|
||||
made for END_OF_FUNCTION_LABEL. If so, set up anything we can't change
|
||||
into a RETURN to jump to it. */
|
||||
for (insn = first; insn; insn = NEXT_INSN (insn))
|
||||
if (GET_CODE (insn) == JUMP_INSN && GET_CODE (PATTERN (insn)) == RETURN)
|
||||
{
|
||||
real_return_label = get_label_before (insn);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Show an extra usage of REAL_RETURN_LABEL so it won't go away if it
|
||||
was equal to END_OF_FUNCTION_LABEL. */
|
||||
LABEL_NUSES (real_return_label)++;
|
||||
|
||||
/* Clear the list of insns to fill so we can use it. */
|
||||
obstack_free (&unfilled_slots_obstack, unfilled_firstobj);
|
||||
|
||||
for (insn = first; insn; insn = NEXT_INSN (insn))
|
||||
{
|
||||
int flags;
|
||||
|
||||
/* Only look at filled JUMP_INSNs that go to the end of function
|
||||
label. */
|
||||
if (GET_CODE (insn) != INSN
|
||||
|| GET_CODE (PATTERN (insn)) != SEQUENCE
|
||||
|| GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) != JUMP_INSN
|
||||
|| JUMP_LABEL (XVECEXP (PATTERN (insn), 0, 0)) != end_of_function_label)
|
||||
continue;
|
||||
|
||||
pat = PATTERN (insn);
|
||||
jump_insn = XVECEXP (pat, 0, 0);
|
||||
|
||||
/* If we can't make the jump into a RETURN, try to redirect it to the best
|
||||
RETURN and go on to the next insn. */
|
||||
if (! reorg_redirect_jump (jump_insn, NULL_RTX))
|
||||
{
|
||||
/* Make sure redirecting the jump will not invalidate the delay
|
||||
slot insns. */
|
||||
if (redirect_with_delay_slots_safe_p (jump_insn,
|
||||
real_return_label,
|
||||
insn))
|
||||
reorg_redirect_jump (jump_insn, real_return_label);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* See if this RETURN can accept the insns current in its delay slot.
|
||||
It can if it has more or an equal number of slots and the contents
|
||||
of each is valid. */
|
||||
|
||||
flags = get_jump_flags (jump_insn, JUMP_LABEL (jump_insn));
|
||||
slots = num_delay_slots (jump_insn);
|
||||
if (slots >= XVECLEN (pat, 0) - 1)
|
||||
{
|
||||
for (i = 1; i < XVECLEN (pat, 0); i++)
|
||||
if (! (
|
||||
#ifdef ANNUL_IFFALSE_SLOTS
|
||||
(INSN_ANNULLED_BRANCH_P (jump_insn)
|
||||
&& INSN_FROM_TARGET_P (XVECEXP (pat, 0, i)))
|
||||
? eligible_for_annul_false (jump_insn, i - 1,
|
||||
XVECEXP (pat, 0, i), flags) :
|
||||
#endif
|
||||
#ifdef ANNUL_IFTRUE_SLOTS
|
||||
(INSN_ANNULLED_BRANCH_P (jump_insn)
|
||||
&& ! INSN_FROM_TARGET_P (XVECEXP (pat, 0, i)))
|
||||
? eligible_for_annul_true (jump_insn, i - 1,
|
||||
XVECEXP (pat, 0, i), flags) :
|
||||
#endif
|
||||
eligible_for_delay (jump_insn, i -1, XVECEXP (pat, 0, i), flags)))
|
||||
break;
|
||||
}
|
||||
else
|
||||
i = 0;
|
||||
|
||||
if (i == XVECLEN (pat, 0))
|
||||
continue;
|
||||
|
||||
/* We have to do something with this insn. If it is an unconditional
|
||||
RETURN, delete the SEQUENCE and output the individual insns,
|
||||
followed by the RETURN. Then set things up so we try to find
|
||||
insns for its delay slots, if it needs some. */
|
||||
if (GET_CODE (PATTERN (jump_insn)) == RETURN)
|
||||
{
|
||||
rtx prev = PREV_INSN (insn);
|
||||
|
||||
delete_insn (insn);
|
||||
for (i = 1; i < XVECLEN (pat, 0); i++)
|
||||
prev = emit_insn_after (PATTERN (XVECEXP (pat, 0, i)), prev);
|
||||
|
||||
insn = emit_jump_insn_after (PATTERN (jump_insn), prev);
|
||||
emit_barrier_after (insn);
|
||||
|
||||
if (slots)
|
||||
obstack_ptr_grow (&unfilled_slots_obstack, insn);
|
||||
}
|
||||
else
|
||||
/* It is probably more efficient to keep this with its current
|
||||
delay slot as a branch to a RETURN. */
|
||||
reorg_redirect_jump (jump_insn, real_return_label);
|
||||
}
|
||||
|
||||
/* Now delete REAL_RETURN_LABEL if we never used it. Then try to fill any
|
||||
new delay slots we have created. */
|
||||
if (--LABEL_NUSES (real_return_label) == 0)
|
||||
delete_insn (real_return_label);
|
||||
|
||||
fill_simple_delay_slots (1);
|
||||
fill_simple_delay_slots (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Try to find insns to place in delay slots. */
|
||||
|
||||
@@ -3589,10 +3455,6 @@ dbr_schedule (first, file)
|
||||
if (end_of_function_label && --LABEL_NUSES (end_of_function_label) == 0)
|
||||
delete_insn (end_of_function_label);
|
||||
|
||||
#ifdef HAVE_return
|
||||
if (HAVE_return && end_of_function_label != 0)
|
||||
make_return_insns (first);
|
||||
#endif
|
||||
|
||||
obstack_free (&unfilled_slots_obstack, unfilled_firstobj);
|
||||
|
||||
|
||||
75
gcc/stmt.c
75
gcc/stmt.c
@@ -2472,17 +2472,6 @@ expand_null_return_1 (last_insn, use_goto)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Otherwise output a simple return-insn if one is available,
|
||||
unless it won't do the job. */
|
||||
#ifdef HAVE_return
|
||||
if (HAVE_return && use_goto == 0 && cleanup_label == 0)
|
||||
{
|
||||
emit_jump_insn (gen_return ());
|
||||
emit_barrier ();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Otherwise jump to the epilogue. */
|
||||
expand_goto_internal (NULL_TREE, end_label, last_insn);
|
||||
}
|
||||
@@ -2578,70 +2567,6 @@ expand_return (retval)
|
||||
if (optimize_tail_recursion (retval_rhs, last_insn))
|
||||
return;
|
||||
|
||||
#ifdef HAVE_return
|
||||
/* This optimization is safe if there are local cleanups
|
||||
because expand_null_return takes care of them.
|
||||
??? I think it should also be safe when there is a cleanup label,
|
||||
because expand_null_return takes care of them, too.
|
||||
Any reason why not? */
|
||||
if (HAVE_return && cleanup_label == 0
|
||||
&& ! current_function_returns_pcc_struct
|
||||
&& BRANCH_COST <= 1)
|
||||
{
|
||||
/* If this is return x == y; then generate
|
||||
if (x == y) return 1; else return 0;
|
||||
if we can do it with explicit return insns and branches are cheap,
|
||||
but not if we have the corresponding scc insn. */
|
||||
int has_scc = 0;
|
||||
if (retval_rhs)
|
||||
switch (TREE_CODE (retval_rhs))
|
||||
{
|
||||
case EQ_EXPR:
|
||||
#ifdef HAVE_seq
|
||||
has_scc = HAVE_seq;
|
||||
#endif
|
||||
case NE_EXPR:
|
||||
#ifdef HAVE_sne
|
||||
has_scc = HAVE_sne;
|
||||
#endif
|
||||
case GT_EXPR:
|
||||
#ifdef HAVE_sgt
|
||||
has_scc = HAVE_sgt;
|
||||
#endif
|
||||
case GE_EXPR:
|
||||
#ifdef HAVE_sge
|
||||
has_scc = HAVE_sge;
|
||||
#endif
|
||||
case LT_EXPR:
|
||||
#ifdef HAVE_slt
|
||||
has_scc = HAVE_slt;
|
||||
#endif
|
||||
case LE_EXPR:
|
||||
#ifdef HAVE_sle
|
||||
has_scc = HAVE_sle;
|
||||
#endif
|
||||
case TRUTH_ANDIF_EXPR:
|
||||
case TRUTH_ORIF_EXPR:
|
||||
case TRUTH_AND_EXPR:
|
||||
case TRUTH_OR_EXPR:
|
||||
case TRUTH_NOT_EXPR:
|
||||
case TRUTH_XOR_EXPR:
|
||||
if (! has_scc)
|
||||
{
|
||||
op0 = gen_label_rtx ();
|
||||
jumpifnot (retval_rhs, op0);
|
||||
expand_value_return (const1_rtx);
|
||||
emit_label (op0);
|
||||
expand_value_return (const0_rtx);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_return */
|
||||
|
||||
/* If the result is an aggregate that is being returned in one (or more)
|
||||
registers, load the registers here. The compiler currently can't handle
|
||||
|
||||
Reference in New Issue
Block a user