summaryrefslogtreecommitdiff
path: root/gcc/var-tracking.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-07 07:47:15 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-07 07:47:15 +0000
commit12d886b8ae0a0970287c7ad9ff8193f2abb1db37 (patch)
tree8185487e9f35c89d163198116ad501cfa5dad143 /gcc/var-tracking.c
parent2f77cce8ec0cc9af8d39c6280dd77a814018600a (diff)
downloadgcc-12d886b8ae0a0970287c7ad9ff8193f2abb1db37.tar.gz
* function.c (ARG_POINTER_CFA_OFFSET): Move ...
* defaults.h (ARG_POINTER_CFA_OFFSET): ... here. (INCOMING_FRAME_SP_OFFSET): Move from dwarf2out.c. * dwarf2out.c (struct cfa_loc): Change reg to unsigned int, rearrange for better packing. (INCOMING_FRAME_SP_OFFSET): Move to defaults.h. (lookup_cfa_1): Remove inline marker. (cfa_equal_p): Split out of ... (def_cfa_1): ... here. Use INVALID_REGNUM. (build_cfa_loc): Handle !cfa->indirect. (frame_pointer_cfa_offset): New. (dbx_reg_number): Assert register elimination performed; do leaf register remapping. (reg_loc_descriptor): Avoid calling dbx_reg_number when unused. (eliminate_reg_to_offset): New. (based_loc_descr): Remove can_use_fbreg argument. Use fbreg only for verifiably local stack frame addresses; re-base to CFA. (mem_loc_descriptor): Remove can_use_fbreg argument. (concat_loc_descriptor, loc_descriptor): Likewise. (containing_function_has_frame_base): Remove. (rtl_for_decl_location): Don't do register elimination or leaf register remapping here. (secname_for_decl): Split out from .. (add_location_or_const_value_attribute): ... here. (convert_cfa_to_loc_list): New. (compute_frame_pointer_to_cfa_displacement): New. (gen_subprogram_die): Use them. * tree.h (frame_base_decl): Remove. * var-tracking.c (frame_base_decl, frame_stack_adjust): Remove. (prologue_stack_adjust): Remove. (vt_stack_adjustments): Use INCOMING_FRAME_SP_OFFSET. (adjust_stack_reference): Re-base memories to arg_pointer_rtx. (set_frame_base_location): Remove. (compute_bb_dataflow, emit_notes_in_bb): Don't call it. (dump_attrs_list, dump_dataflow_set): Use string concatenation. (vt_add_function_parameters): Don't eliminate_regs. (vt_initialize): Don't create frame_base_decl. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@103983 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/var-tracking.c')
-rw-r--r--gcc/var-tracking.c143
1 files changed, 16 insertions, 127 deletions
diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 92976dc3a81..ba034f34b47 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -268,19 +268,12 @@ static htab_t changed_variables;
/* Shall notes be emitted? */
static bool emit_notes;
-/* Fake variable for stack pointer. */
-tree frame_base_decl;
-
-/* Stack adjust caused by function prologue. */
-static HOST_WIDE_INT frame_stack_adjust;
-
/* Local function prototypes. */
static void stack_adjust_offset_pre_post (rtx, HOST_WIDE_INT *,
HOST_WIDE_INT *);
static void insn_stack_adjust_offset_pre_post (rtx, HOST_WIDE_INT *,
HOST_WIDE_INT *);
static void bb_stack_adjust_offset (basic_block);
-static HOST_WIDE_INT prologue_stack_adjust (void);
static bool vt_stack_adjustments (void);
static rtx adjust_stack_reference (rtx, HOST_WIDE_INT);
static hashval_t variable_htab_hash (const void *);
@@ -335,7 +328,6 @@ static void dump_dataflow_set (dataflow_set *);
static void dump_dataflow_sets (void);
static void variable_was_changed (variable, htab_t);
-static void set_frame_base_location (dataflow_set *, rtx);
static void set_variable_part (dataflow_set *, rtx, tree, HOST_WIDE_INT);
static void delete_variable_part (dataflow_set *, rtx, tree, HOST_WIDE_INT);
static int emit_note_insn_var_location (void **, void *);
@@ -491,38 +483,6 @@ bb_stack_adjust_offset (basic_block bb)
VTI (bb)->out.stack_adjust = offset;
}
-/* Compute stack adjustment caused by function prologue. */
-
-static HOST_WIDE_INT
-prologue_stack_adjust (void)
-{
- HOST_WIDE_INT offset = 0;
- basic_block bb = ENTRY_BLOCK_PTR->next_bb;
- rtx insn;
- rtx end;
-
- if (!BB_END (bb))
- return 0;
-
- end = NEXT_INSN (BB_END (bb));
- for (insn = BB_HEAD (bb); insn != end; insn = NEXT_INSN (insn))
- {
- if (NOTE_P (insn)
- && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PROLOGUE_END)
- break;
-
- if (INSN_P (insn))
- {
- HOST_WIDE_INT tmp;
-
- insn_stack_adjust_offset_pre_post (insn, &tmp, &tmp);
- offset += tmp;
- }
- }
-
- return offset;
-}
-
/* Compute stack adjustments for all blocks by traversing DFS tree.
Return true when the adjustments on all incoming edges are consistent.
Heavily borrowed from flow_depth_first_order_compute. */
@@ -535,7 +495,7 @@ vt_stack_adjustments (void)
/* Initialize entry block. */
VTI (ENTRY_BLOCK_PTR)->visited = true;
- VTI (ENTRY_BLOCK_PTR)->out.stack_adjust = frame_stack_adjust;
+ VTI (ENTRY_BLOCK_PTR)->out.stack_adjust = INCOMING_FRAME_SP_OFFSET;
/* Allocate stack for back-tracking up CFG. */
stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge_iterator));
@@ -589,27 +549,23 @@ vt_stack_adjustments (void)
return true;
}
-/* Adjust stack reference MEM by ADJUSTMENT bytes and return the new rtx. */
+/* Adjust stack reference MEM by ADJUSTMENT bytes and make it relative
+ to the argument pointer. Return the new rtx. */
static rtx
adjust_stack_reference (rtx mem, HOST_WIDE_INT adjustment)
{
- rtx adjusted_mem;
- rtx tmp;
+ rtx addr, cfa, tmp;
- if (adjustment == 0)
- return mem;
+ adjustment -= ARG_POINTER_CFA_OFFSET (current_function_decl);
+ cfa = plus_constant (arg_pointer_rtx, adjustment);
- adjusted_mem = copy_rtx (mem);
- XEXP (adjusted_mem, 0) = replace_rtx (XEXP (adjusted_mem, 0),
- stack_pointer_rtx,
- gen_rtx_PLUS (Pmode, stack_pointer_rtx,
- GEN_INT (adjustment)));
- tmp = simplify_rtx (XEXP (adjusted_mem, 0));
+ addr = replace_rtx (copy_rtx (XEXP (mem, 0)), stack_pointer_rtx, cfa);
+ tmp = simplify_rtx (addr);
if (tmp)
- XEXP (adjusted_mem, 0) = tmp;
+ addr = tmp;
- return adjusted_mem;
+ return replace_equiv_address_nv (mem, addr);
}
/* The hash function for variable_htab, computes the hash value
@@ -1652,14 +1608,7 @@ compute_bb_dataflow (basic_block bb)
break;
case MO_ADJUST:
- {
- rtx base;
-
- out->stack_adjust += VTI (bb)->mos[i].u.adjust;
- base = gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx,
- out->stack_adjust));
- set_frame_base_location (out, base);
- }
+ out->stack_adjust += VTI (bb)->mos[i].u.adjust;
break;
}
}
@@ -1782,8 +1731,7 @@ dump_attrs_list (attrs list)
for (; list; list = list->next)
{
print_mem_expr (dump_file, list->decl);
- fprintf (dump_file, "+");
- fprintf (dump_file, HOST_WIDE_INT_PRINT_DEC, list->offset);
+ fprintf (dump_file, "+" HOST_WIDE_INT_PRINT_DEC, list->offset);
}
fprintf (dump_file, "\n");
}
@@ -1833,9 +1781,8 @@ dump_dataflow_set (dataflow_set *set)
{
int i;
- fprintf (dump_file, "Stack adjustment: ");
- fprintf (dump_file, HOST_WIDE_INT_PRINT_DEC, set->stack_adjust);
- fprintf (dump_file, "\n");
+ fprintf (dump_file, "Stack adjustment: " HOST_WIDE_INT_PRINT_DEC "\n",
+ set->stack_adjust);
for (i = 1; i < FIRST_PSEUDO_REGISTER; i++)
{
if (set->regs[i])
@@ -1914,31 +1861,6 @@ variable_was_changed (variable var, htab_t htab)
}
}
-/* Set the location of frame_base_decl to LOC in dataflow set SET. This
- function expects that frame_base_decl has already one location for offset 0
- in the variable table. */
-
-static void
-set_frame_base_location (dataflow_set *set, rtx loc)
-{
- variable var;
-
- var = htab_find_with_hash (set->vars, frame_base_decl,
- VARIABLE_HASH_VAL (frame_base_decl));
- gcc_assert (var);
- gcc_assert (var->n_var_parts == 1);
- gcc_assert (!var->var_part[0].offset);
- gcc_assert (var->var_part[0].loc_chain);
-
- /* If frame_base_decl is shared unshare it first. */
- if (var->refcount > 1)
- var = unshare_variable (set, var);
-
- var->var_part[0].loc_chain->loc = loc;
- var->var_part[0].cur_loc = loc;
- variable_was_changed (var, set->vars);
-}
-
/* Set the part of variable's location in the dataflow set SET. The variable
part is specified by variable's declaration DECL and offset OFFSET and the
part's location by LOC. */
@@ -2463,15 +2385,7 @@ emit_notes_in_bb (basic_block bb)
break;
case MO_ADJUST:
- {
- rtx base;
-
- set.stack_adjust += VTI (bb)->mos[i].u.adjust;
- base = gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx,
- set.stack_adjust));
- set_frame_base_location (&set, base);
- emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN);
- }
+ set.stack_adjust += VTI (bb)->mos[i].u.adjust;
break;
}
}
@@ -2575,7 +2489,6 @@ vt_add_function_parameters (void)
gcc_assert (parm == decl);
- incoming = eliminate_regs (incoming, 0, NULL_RTX);
out = &VTI (ENTRY_BLOCK_PTR)->out;
if (REG_P (incoming))
@@ -2586,9 +2499,7 @@ vt_add_function_parameters (void)
set_variable_part (out, incoming, parm, offset);
}
else if (MEM_P (incoming))
- {
- set_variable_part (out, incoming, parm, offset);
- }
+ set_variable_part (out, incoming, parm, offset);
}
}
@@ -2733,28 +2644,6 @@ vt_initialize (void)
changed_variables = htab_create (10, variable_htab_hash, variable_htab_eq,
NULL);
vt_add_function_parameters ();
-
- if (!frame_pointer_needed)
- {
- rtx base;
-
- /* Create fake variable for tracking stack pointer changes. */
- frame_base_decl = make_node (VAR_DECL);
- DECL_NAME (frame_base_decl) = get_identifier ("___frame_base_decl");
- TREE_TYPE (frame_base_decl) = char_type_node;
- DECL_ARTIFICIAL (frame_base_decl) = 1;
- DECL_IGNORED_P (frame_base_decl) = 1;
-
- /* Set its initial "location". */
- frame_stack_adjust = -prologue_stack_adjust ();
- base = gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx,
- frame_stack_adjust));
- set_variable_part (&VTI (ENTRY_BLOCK_PTR)->out, base, frame_base_decl, 0);
- }
- else
- {
- frame_base_decl = NULL;
- }
}
/* Free the data structures needed for variable tracking. */