This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix var-tracking WRT location list for DW_AT_frame_base
- From: Josef Zlomek <zlomekj at suse dot cz>
- To: Roger Sayle <roger at eyesopen dot com>, gcc-patches at gcc dot gnu dot org
- Cc: Richard Sandiford <rsandifo at redhat dot com>
- Date: Mon, 5 Jul 2004 06:48:28 +0200
- Subject: Re: Fix var-tracking WRT location list for DW_AT_frame_base
- References: <878ydzzv0l.fsf@redhat.com> <Pine.LNX.4.44.0407040853210.657-100000@www.eyesopen.com>
> Josef, could you go with the variant using plus_constant?
Yes. The patch is attached.
Bootstrapped/regtested ia64; clean mainline does not build on ppc and ppc64.
I'm commiting it as pre-approved.
Josef
2004-07-05 Josef Zlomek <zlomekj@suse.cz>
* var-tracking.c: Fix some comments.
(frame_stack_adjust): New.
(vt_stack_adjustments): Init stack_adjust of entry block to
minus stack adjustment of function prologue.
(adjust_stack_reference): Do not adjust if adjustment == 0.
(compute_bb_dataflow): Use plus_constant instead of gen_rtx_PLUS.
(emit_notes_in_bb): Likewise.
(vt_add_function_parameters): Do not adjust locations of
function arguments.
(vt_initialize): Compute the stack adjustment of function
prologue and offset the initial "location" of frame_base_decl
from the stack pointer after prologue.
Index: var-tracking.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/var-tracking.c,v
retrieving revision 2.18
diff -c -p -r2.18 var-tracking.c
*** var-tracking.c 1 Jul 2004 12:52:53 -0000 2.18
--- var-tracking.c 5 Jul 2004 04:34:56 -0000
*************** static bool emit_notes;
*** 267,272 ****
--- 267,275 ----
/* 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 *);
*************** bb_stack_adjust_offset (basic_block bb)
*** 484,490 ****
VTI (bb)->out.stack_adjust = offset;
}
! /* Compute stack adjustment caused by function prolog. */
static HOST_WIDE_INT
prologue_stack_adjust (void)
--- 487,493 ----
VTI (bb)->out.stack_adjust = offset;
}
! /* Compute stack adjustment caused by function prologue. */
static HOST_WIDE_INT
prologue_stack_adjust (void)
*************** vt_stack_adjustments (void)
*** 528,534 ****
/* Initialize entry block. */
VTI (ENTRY_BLOCK_PTR)->visited = true;
! VTI (ENTRY_BLOCK_PTR)->out.stack_adjust = 0;
/* Allocate stack for back-tracking up CFG. */
stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge));
--- 531,537 ----
/* Initialize entry block. */
VTI (ENTRY_BLOCK_PTR)->visited = true;
! VTI (ENTRY_BLOCK_PTR)->out.stack_adjust = frame_stack_adjust;
/* Allocate stack for back-tracking up CFG. */
stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge));
*************** adjust_stack_reference (rtx mem, HOST_WI
*** 590,595 ****
--- 593,601 ----
rtx adjusted_mem;
rtx tmp;
+ if (adjustment == 0)
+ return mem;
+
adjusted_mem = copy_rtx (mem);
XEXP (adjusted_mem, 0) = replace_rtx (XEXP (adjusted_mem, 0),
stack_pointer_rtx,
*************** compute_bb_dataflow (basic_block bb)
*** 1653,1661 ****
rtx base;
out->stack_adjust += VTI (bb)->mos[i].u.adjust;
! base = gen_rtx_MEM (Pmode,
! gen_rtx_PLUS (Pmode, stack_pointer_rtx,
! GEN_INT (out->stack_adjust)));
set_frame_base_location (out, base);
}
break;
--- 1659,1666 ----
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);
}
break;
*************** variable_was_changed (variable var, htab
*** 1918,1926 ****
}
/* 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)
--- 1923,1930 ----
}
/* 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)
*************** emit_notes_in_bb (basic_block bb)
*** 2409,2417 ****
rtx base;
set.stack_adjust += VTI (bb)->mos[i].u.adjust;
! base = gen_rtx_MEM (Pmode,
! gen_rtx_PLUS (Pmode, stack_pointer_rtx,
! GEN_INT (set.stack_adjust)));
set_frame_base_location (&set, base);
emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN);
}
--- 2413,2420 ----
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);
}
*************** static void
*** 2490,2500 ****
vt_add_function_parameters (void)
{
tree parm;
- HOST_WIDE_INT stack_adjust = 0;
- if (!frame_pointer_needed)
- stack_adjust = prologue_stack_adjust ();
-
for (parm = DECL_ARGUMENTS (current_function_decl);
parm; parm = TREE_CHAIN (parm))
{
--- 2493,2499 ----
*************** vt_add_function_parameters (void)
*** 2529,2536 ****
#endif
incoming = eliminate_regs (incoming, 0, NULL_RTX);
- if (!frame_pointer_needed && MEM_P (incoming))
- incoming = adjust_stack_reference (incoming, -stack_adjust);
out = &VTI (ENTRY_BLOCK_PTR)->out;
if (REG_P (incoming))
--- 2528,2533 ----
*************** vt_initialize (void)
*** 2703,2709 ****
DECL_ARTIFICIAL (frame_base_decl) = 1;
/* Set its initial "location". */
! base = gen_rtx_MEM (Pmode, stack_pointer_rtx);
set_variable_part (&VTI (ENTRY_BLOCK_PTR)->out, base, frame_base_decl, 0);
}
else
--- 2700,2708 ----
DECL_ARTIFICIAL (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