This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: fix incorrect debug temp added by df-problems
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 09 Apr 2012 03:44:47 -0300
- Subject: Re: fix incorrect debug temp added by df-problems
- References: <ormxcm361t.fsf@livre.localdomain>
On Oct 27, 2011, Alexandre Oliva <aoliva@redhat.com> wrote:
> pr43165.c -Os -g exercises a bug in df-problems WRT the introduction of
> debug temps. After pro_and_epilogue, the function was optimized to this:
> push bp
> mov bp,sp
> # debug insn referencing bp
> pop bp
> I don't know why we bother to preserve and set up bp, it's not used in
> nondebug insns (and even with -g0 we still emit it). GCC 4.5 did
> better, but that's a different issue I haven't addressed.
> The problem I address here is that the debug insn references bp, but
> df-problems sees bp is dead at the debug insn during backward scanning,
> and decides we have to emit a debug temp before its last use.
> However, there isn't a last use: the set is dead, but it isn't regarded
> as such because bp is in artificial_uses at the end of the block. For
> this reason, df_create_unused_note refrains from emitting the note and
> resetting the debug uses.
> However, the decision to emit a debug temp before the last bp use
> remains in effect, so when the backward scanning reaches the push bp, it
> emits a debug temp bound to the *previous* value of bp, and replaces
> the debug use of bp with that. Oops.
> This patch arranges for us to not decide a debug use is dead if we won't
> emit a REG_DEAD or REG_UNUSED note for it, because it is
> artificially-used or an ignored stack reg. An alternative would be to
> remove any pending dead_debug entry from the list when we encounter a
> set, but this is cheaper and it *should* be equivalent.
> With this patch, the debug insn remains using bp, and no debug temp is
> introduced.
> Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install?
Apologies, I've just re-posted this patch claiming it had to do with
pr50826. Maybe it does (I'm no longer sure I actually ran into the same
problem there), but this was the thread in which I first posted it, so
I'll follow up here.
Regstrapped and retested. Ok?
This fixes a bug in pr43165.c with -Os -g.
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* df-problems.c (df_note_bb_compute): Do not take note of
debug uses for whose REGs we won't emit DEAD or UNUSED notes.
Index: gcc/df-problems.c
===================================================================
--- gcc/df-problems.c.orig 2012-04-08 01:50:45.379141149 -0300
+++ gcc/df-problems.c 2012-04-08 02:05:13.406574358 -0300
@@ -3528,7 +3528,12 @@ df_note_bb_compute (unsigned int bb_inde
{
if (debug_insn > 0)
{
- dead_debug_add (&debug, use, uregno);
+ /* We won't add REG_UNUSED or REG_DEAD notes for
+ these, so we don't have to mess with them in
+ debug insns either. */
+ if (!bitmap_bit_p (artificial_uses, uregno)
+ && (!df_ignore_stack_reg (uregno)))
+ dead_debug_add (&debug, use, uregno);
continue;
}
break;
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist Red Hat Brazil Compiler Engineer