* alias.c (record_set, memory_modified_1): Constify. * bt-load.c (note_btr_set): Likewise. * caller-save.c (mark_set_regs, add_stored_regs): Likewise. * combine.c (set_nonzero_bits_and_sign_copies, expand_field_assignment, record_dead_and_set_regs_1, use_crosses_set_p, reg_dead_at_p_1, can_combine_p, likely_spilled_retval_1): Likewise. * config/frv/frv.c (frv_registers_update_1, frv_io_check_address, frv_io_handle_set): Likewise. * config/mips/mips.c (mips_sim_record_set, vr4130_true_reg_dependence_p_1): Likewise. * config/mt/mt.c (insn_dependent_p_1): Likewise. * config/s390/s390.c (s390_reg_clobbered_rtx): Likewise. * config/sh/sh.c (flow_dependent_p_1): Likewise. * cselib.c (cselib_invalidate_rtx_note_stores): Likewise. * dce.c (mark_nonreg_stores_1, mark_nonreg_stores_2): Likewise. * ddg.c (mark_mem_store): Likewise. * df-problems.c (df_urec_mark_reg_change): Likewise. * function.c (update_epilogue_consts): Likewise. * gcse.c (record_set_info, record_last_set_info, mems_conflict_for_gcse_p, canon_list_insert, reg_set_info, reg_clear_last_set): Likewise. * global.c (mark_reg_store, mark_reg_clobber, reg_becomes_live): Likewise. * jump.c (reversed_comparison_code_parts): Likewise. * local-alloc.c (validate_equiv_mem_from_store, no_equiv, reg_is_set): Likewise. * loop-iv.c (mark_altered): Likewise. * mode-switching.c (reg_becomes_live): Likewise. * optabs.c (no_conflict_move_test): Likewise. * postreload-gcse.c (record_last_set_info, find_mem_conflicts): Likewise. * postreload.c (reload_combine_note_store, move2add_note_store): Likewise. * regmove.c (flags_set_1): Likewise. * regrename.c (note_sets, kill_clobbered_value, kill_set_value): Likewise. * reload1.c (mark_not_eliminable, forget_old_reloads_1): Likewise. * resource.c (update_live_status): Likewise. * rtl.h (set_of, note_stores): Likewise. * rtlanal.c (set_of_1, parms_set, struct set_of_data, set_of, note_stores, parms_set): Likewise. * sched-rgn.c (sets_likely_spilled_1): Likewise. * stack-ptr-mod.c (notice_stack_pointer_modification_1): Likewise. * var-tracking.c (count_stores, add_stores): Likewise. From-SVN: r127065
110 lines
3.5 KiB
C
110 lines
3.5 KiB
C
/* Discover if the stack pointer is modified in a function.
|
|
Copyright (C) 2007
|
|
Free Software Foundation, Inc.
|
|
|
|
This file is part of GCC.
|
|
|
|
GCC 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 3, or (at your option) any later
|
|
version.
|
|
|
|
GCC 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 GCC; see the file COPYING3. If not see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#include "config.h"
|
|
#include "system.h"
|
|
#include "coretypes.h"
|
|
#include "tm.h"
|
|
#include "tree.h"
|
|
#include "rtl.h"
|
|
#include "regs.h"
|
|
#include "expr.h"
|
|
#include "tree-pass.h"
|
|
#include "basic-block.h"
|
|
#include "flags.h"
|
|
#include "output.h"
|
|
#include "df.h"
|
|
|
|
/* Determine if the stack pointer is constant over the life of the function.
|
|
Only useful before prologues have been emitted. */
|
|
|
|
static void
|
|
notice_stack_pointer_modification_1 (rtx x, const_rtx pat ATTRIBUTE_UNUSED,
|
|
void *data ATTRIBUTE_UNUSED)
|
|
{
|
|
if (x == stack_pointer_rtx
|
|
/* The stack pointer is only modified indirectly as the result
|
|
of a push until later. See the comments in rtl.texi
|
|
regarding Embedded Side-Effects on Addresses. */
|
|
|| (MEM_P (x)
|
|
&& GET_RTX_CLASS (GET_CODE (XEXP (x, 0))) == RTX_AUTOINC
|
|
&& XEXP (XEXP (x, 0), 0) == stack_pointer_rtx))
|
|
current_function_sp_is_unchanging = 0;
|
|
}
|
|
|
|
static void
|
|
notice_stack_pointer_modification (void)
|
|
{
|
|
basic_block bb;
|
|
rtx insn;
|
|
|
|
/* Assume that the stack pointer is unchanging if alloca hasn't
|
|
been used. */
|
|
current_function_sp_is_unchanging = !current_function_calls_alloca;
|
|
if (current_function_sp_is_unchanging)
|
|
FOR_EACH_BB (bb)
|
|
FOR_BB_INSNS (bb, insn)
|
|
{
|
|
if (INSN_P (insn))
|
|
{
|
|
/* Check if insn modifies the stack pointer. */
|
|
note_stores (PATTERN (insn),
|
|
notice_stack_pointer_modification_1,
|
|
NULL);
|
|
if (! current_function_sp_is_unchanging)
|
|
return;
|
|
}
|
|
}
|
|
|
|
/* The value coming into this pass was 0, and the exit block uses
|
|
are based on this. If the value is now 1, we need to redo the
|
|
exit block uses. */
|
|
if (df && current_function_sp_is_unchanging)
|
|
df_update_exit_block_uses ();
|
|
}
|
|
|
|
/* Some targets can emit simpler epilogues if they know that sp was
|
|
not ever modified during the function. After reload, of course,
|
|
we've already emitted the epilogue so there's no sense searching. */
|
|
|
|
static unsigned int
|
|
rest_of_handle_stack_ptr_mod (void)
|
|
{
|
|
notice_stack_pointer_modification ();
|
|
return 0;
|
|
}
|
|
|
|
struct tree_opt_pass pass_stack_ptr_mod =
|
|
{
|
|
NULL, /* name */
|
|
NULL, /* gate */
|
|
rest_of_handle_stack_ptr_mod, /* execute */
|
|
NULL, /* sub */
|
|
NULL, /* next */
|
|
0, /* static_pass_number */
|
|
0, /* tv_id */
|
|
0, /* properties_required */
|
|
0, /* properties_provided */
|
|
0, /* properties_destroyed */
|
|
0, /* todo_flags_start */
|
|
0, /* todo_flags_finish */
|
|
0 /* letter */
|
|
};
|