* df.h: Include "timevar.h". (struct df_problem): Change tv_id field to timevar_id_t. * tree-pass.h: Include "timevar.h". (struct opt_pass): Change tv_id field to timevar_id_t. * timevar.h (timevar_id_t): Define TV_NONE. * passes.c (execute_one_ipa_transform_pass): Check for tv_id != TV_NONE rather than tv_id != 0. (execute_one_pass): Likewise. * Makefile.in (DF_H): Add $(TIMEVAR_H). (TREE_PASS_H): Define. Change all instances of tree-pass.h in dependencies to $(TREE_PASS_H). * bt-load.c (pass_branch_target_load_optimize1): Set tv_id field to TV_NONE. (pass_branch_target_load_optimize2): Likewise. * cfglayout.c (pass_into_cfg_layout_mode): Likewise. (pass_outof_cfg_layout_mode): Likewise. * cgraphbuild.c (pass_remove_cgraph_callee_edges): Likewise. (pass_rebuild_cgraph_edges): Likewise. (pass_remove_cgraph_callee_edges): Likewise. * df-core.c (pass_df_initialize_opt): Likewise. (pass_df_initialize_no_opt): Likewise. (pass_df_finish): Likewise. * emit-rtl.c (pass_unshare_all_rtl): Likewise. * except.c (pass_set_nothrow_function_flags): Likewise. (pass_convert_to_eh_region_ranges): Likewise. * final.c (pass_compute_alignments): Likewise. * function.c (pass_instantiate_virtual_regs): Likewise. (pass_init_function): Likewise. (pass_leaf_regs): Likewise. (pass_match_asm_constraints): Likewise. * gimple-low.c (pass_lower_cf): Likewise. (pass_mark_used_blocks): Likewise. * init-regs.c (pass_initialize_regs): Likewise. * integrate.c (pass_initial_value_sets): Likewise. * ira.c (pass_ira): Likewise. * jump.c (pass_cleanup_barriers): Likewise. * omp-low.c (pass_expand_omp): Likewise. (pass_lower_omp): Likewise. * matrix-reorg.c (pass_ipa_matrix_reorg): Likewise. * recog.c (pass_split_all_insns): Likewise. (pass_split_after_reload): Likewise. (pass_split_before_regstack): Likewise. (pass_split_before_sched2): Likewise. (pass_split_for_shorten_branches): Likewise. * reginfo.c (pass_reginfo_init): Likewise. (pass_subregs_of_mode_init): Likewise. (pass_subregs_of_mode_finish): Likewise. * passes.c (pass_postreload): Likewise. * stack-ptr-mod.c (pass_stack_ptr_mod): Likewise. * tree-cfg.c (pass_remove_useless_stmts): Likewise. (pass_warn_function_return): Likewise. (pass_warn_function_noreturn): Likewise. * tree-complex.c (pass_lower_complex): Likewise. (pass_lower_complex_O0): Likewise. * tree-if-conv.c (pass_if_conversion): Likewise. * tree-into-ssa.c (pass_build_ssa): Likewise. * tree-mudflap.c (pass_mudflap_1): Likewise. (pass_mudflap_2): Likewise. * tree-nomudflap.c (pass_mudflap_1): Likewise. (pass_mudflap_2): Likewise. * tree-nrv.c (pass_return_slot): Likewise. * tree-object-size.c (pass_object_sizes): Likewise. * tree-optimize.c (pass_all_optimizations): Likewise. (pass_early_local_passes): Likewise. (pass_all_early_optimizations): Likewise. (pass_cleanup_cfg): Likewise. (pass_cleanup_cfg_post_optimizing): Likewise. (pass_free_datastructures): Likewise. (pass_free_cfg_annotations): Likewise. (pass_fixup_cfg): Likewise. (pass_init_datastructures): Likewise. * tree-ssa.c (pass_early_warn_uninitialized): Likewise. (pass_late_warn_uninitialized): Likewise. (pass_update_address_taken): Likewise. * tree-ssa-ccp.c (pass_fold_builtins): Likewise. * tree-ssa-math-opts.c (pass_cse_reciprocals): Likewise. (pass_cse_sincos): Likewise. (pass_convert_to_rsqrt): Likewise. * tree-ssa-structalias.c (pass_build_alias): Likewise. * tree-stdarg.c (pass_stdarg): Likewise. * tree-tailcall.c (pass_tail_recursion): Likewise. (pass_tail_calls): Likewise. * tree-vect-generic.c (pass_lower_vector): Likewise. (pass_lower_vector_ssa): Likewise. * tree-vectorizer.c (pass_ipa_increase_alignment): Likewise. From-SVN: r146222
112 lines
3.5 KiB
C
112 lines
3.5 KiB
C
/* Discover if the stack pointer is modified in a function.
|
|
Copyright (C) 2007, 2008, 2009
|
|
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 = !cfun->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 rtl_opt_pass pass_stack_ptr_mod =
|
|
{
|
|
{
|
|
RTL_PASS,
|
|
NULL, /* name */
|
|
NULL, /* gate */
|
|
rest_of_handle_stack_ptr_mod, /* execute */
|
|
NULL, /* sub */
|
|
NULL, /* next */
|
|
0, /* static_pass_number */
|
|
TV_NONE, /* tv_id */
|
|
0, /* properties_required */
|
|
0, /* properties_provided */
|
|
0, /* properties_destroyed */
|
|
0, /* todo_flags_start */
|
|
0 /* todo_flags_finish */
|
|
}
|
|
};
|