This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [dataflow]: PATCH COMMITTED to fix frame pointer use in dce.
- From: Kenneth Zadeck <zadeck at naturalbridge dot com>
- To: Kenneth Zadeck <zadeck at naturalbridge dot com>, "Park, Seongbae" <seongbae dot park at gmail dot com>, Ian Lance Taylor <iant at google dot com>, "Berlin, Daniel" <dberlin at dberlin dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>, richard at codesourcery dot com
- Date: Mon, 21 May 2007 09:49:21 -0400
- Subject: Re: [dataflow]: PATCH COMMITTED to fix frame pointer use in dce.
- References: <465198E2.8090804@naturalbridge.com> <87hcq69tkl.fsf@firetop.home>
Richard Sandiford wrote:
> Kenneth Zadeck <zadeck@naturalbridge.com> writes:
>
>> This patch fixes the frame pointer handling in dce according to the
>> discussion on irc between ian taylor, richard sandiford, seongae park,
>> danny berlin and myself.
>>
>
> ENOPATCH btw. But I can guess what it did from the changelog.
>
>
sorry
Index: dbgcnt.def
===================================================================
--- dbgcnt.def (revision 124893)
+++ dbgcnt.def (working copy)
@@ -50,7 +50,7 @@ Software Foundation, 51 Franklin Street,
or constant-propagation for each insn,
or a block straightening, etc.
See dce.c for an example. With the dbg_cnt () call in dce.c,
- now a developer can use -fdbg-cnt=new_dce:N
+ now a developer can use -fdbg-cnt=dce:N
to stop doing the dead code elimination after N times.
How to use it ?
Index: df-scan.c
===================================================================
--- df-scan.c (revision 124893)
+++ df-scan.c (working copy)
@@ -3392,10 +3392,15 @@ df_get_regular_block_artificial_uses (bi
{
bitmap_clear (regular_block_artificial_uses);
- /* Before reload, there are a few registers that must be forced
- live everywhere -- which might not already be the case for
- blocks within infinite loops. */
- if (!reload_completed)
+ if (reload_completed)
+ {
+ if (frame_pointer_needed)
+ bitmap_set_bit (regular_block_artificial_uses, FRAME_POINTER_REGNUM);
+ }
+ else
+ /* Before reload, there are a few registers that must be forced
+ live everywhere -- which might not already be the case for
+ blocks within infinite loops. */
{
/* Any reference to any pseudo before reload is a potential
reference of the frame pointer. */
Index: df.h
===================================================================
--- df.h (revision 124893)
+++ df.h (working copy)
@@ -887,6 +887,8 @@ extern void df_urec_add_problem (void);
extern void df_chain_add_problem (enum df_chain_flags);
extern void df_note_add_problem (void);
extern void df_simulate_find_defs (rtx, bitmap);
+extern void df_simulate_defs (rtx, bitmap);
+extern void df_simulate_uses (rtx, bitmap);
extern void df_simulate_artificial_refs_at_top (basic_block, bitmap);
extern void df_simulate_one_insn_forwards (basic_block, rtx, bitmap);
extern void df_simulate_artificial_refs_at_end (basic_block, bitmap);
Index: df-problems.c
===================================================================
--- df-problems.c (revision 124893)
+++ df-problems.c (working copy)
@@ -4188,7 +4188,7 @@ df_simulate_find_defs (rtx insn, bitmap
/* Simulate the effects of the defs of INSN on LIVE. */
-static inline void
+void
df_simulate_defs (rtx insn, bitmap live)
{
struct df_ref **def_rec;
@@ -4240,7 +4240,7 @@ df_simulate_defs (rtx insn, bitmap live)
/* Simulate the effects of the uses of INSN on LIVE. */
-static inline void
+void
df_simulate_uses (rtx insn, bitmap live)
{
struct df_ref **use_rec;
Index: dce.c
===================================================================
--- dce.c (revision 124893)
+++ dce.c (working copy)
@@ -68,7 +68,8 @@ deletable_insn_p (rtx insn, bool fast)
/* These insns may not have real uses but are there because the
dwarf unwinder may need to see the values they compute. */
- if (RTX_FRAME_RELATED_P (insn))
+ if (RTX_FRAME_RELATED_P (insn)
+ && find_reg_note (insn, REG_MAYBE_DEAD, NULL_RTX) == 0)
return false;
switch (GET_CODE (PATTERN (insn)))
@@ -591,57 +592,13 @@ dce_process_block (basic_block bb, bool
}
/* No matter if the instruction is needed or not, we remove
- any regno in the defs from the live set. This code is a
- hacked up version of the regular scanning code in
- df-problems.c:df_lr_bb_local_compute. It must stay in sync.
- */
- if (CALL_P (insn))
- {
- for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++)
- {
- struct df_ref *def = *def_rec;
- unsigned int dregno = DF_REF_REGNO (def);
-
- if (DF_REF_FLAGS (def) & DF_REF_MUST_CLOBBER)
- {
- if (dregno >= FIRST_PSEUDO_REGISTER
- || !(SIBLING_CALL_P (insn)
- && bitmap_bit_p (df->exit_block_uses, dregno)
- && !refers_to_regno_p (dregno, dregno+1,
- current_function_return_rtx,
- (rtx *)0)))
- {
- /* If the def is to only part of the reg, it does
- not kill the other defs that reach here. */
- if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
- bitmap_clear_bit (local_live, dregno);
- }
- }
- else
- /* This is the return value. */
- if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
- bitmap_clear_bit (local_live, dregno);
- }
- }
- else
- {
- for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++)
- {
- struct df_ref *def = *def_rec;
- unsigned int dregno = DF_REF_REGNO (def);
- /* If the def is to only part of the reg, it does
- not kill the other defs that reach here. */
- if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
- bitmap_clear_bit (local_live, dregno);
- }
- }
+ any regno in the defs from the live set. */
+ df_simulate_defs (insn, local_live);
+ /* On the other hand, we do not allow the dead uses to set
+ anything in local_live. */
if (marked_insn_p (insn))
- for (use_rec = DF_INSN_USES (insn); *use_rec; use_rec++)
- {
- unsigned int regno = DF_REF_REGNO (*use_rec);
- bitmap_set_bit (local_live, regno);
- }
+ df_simulate_uses (insn, local_live);
}
for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)