public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* fix incorrect debug temp added by df-problems
@ 2011-10-27 15:09 Alexandre Oliva
  2012-04-09  6:45 ` Alexandre Oliva
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Oliva @ 2011-10-27 15:09 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1570 bytes --]

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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: df-probs-no-death-of-artif-uses-pr50826.patch --]
[-- Type: text/x-diff, Size: 869 bytes --]

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* df-problems.c (df_note_bb_compute): Do not add 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	2011-10-26 11:02:16.709112252 -0200
+++ gcc/df-problems.c	2011-10-26 11:22:46.130851000 -0200
@@ -3410,7 +3410,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;

[-- Attachment #3: Type: text/plain, Size: 258 bytes --]



-- 
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fix incorrect debug temp added by df-problems
  2011-10-27 15:09 fix incorrect debug temp added by df-problems Alexandre Oliva
@ 2012-04-09  6:45 ` Alexandre Oliva
  2012-04-13 16:01   ` Alexandre Oliva
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Oliva @ 2012-04-09  6:45 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1954 bytes --]

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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: df-probs-no-death-of-artif-uses.patch --]
[-- Type: text/x-diff, Size: 909 bytes --]

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;

[-- Attachment #3: Type: text/plain, Size: 258 bytes --]



-- 
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fix incorrect debug temp added by df-problems
  2012-04-09  6:45 ` Alexandre Oliva
@ 2012-04-13 16:01   ` Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2012-04-13 16:01 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 403 bytes --]

On Apr  9, 2012, Jakub Jelinek <jakub@redhat.com> wrote, in response to
my posting to the wrong thread (now fixed):

> On Mon, Apr 09, 2012 at 03:29:05AM -0300, Alexandre Oliva wrote:
>> +			  && (!df_ignore_stack_reg (uregno)))

> Please remove the extra () around this line,
> 			  && !df_ignore_stack_reg (uregno))

> Ok for trunk with that change, thanks.

Thanks, here's what I've just installed.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: df-probs-no-death-of-artif-uses.patch --]
[-- Type: text/x-diff, Size: 907 bytes --]

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-13 05:18:28.604788011 -0300
+++ gcc/df-problems.c	2012-04-13 06:58:42.053258184 -0300
@@ -3453,7 +3453,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;

[-- Attachment #3: Type: text/plain, Size: 257 bytes --]


-- 
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-13 16:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-27 15:09 fix incorrect debug temp added by df-problems Alexandre Oliva
2012-04-09  6:45 ` Alexandre Oliva
2012-04-13 16:01   ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).