diff mbox

[PR,debug/46782] Skip debug insns in try_forward_edges

Message ID or62uxhtrp.fsf@livre.localdomain
State New
Headers show

Commit Message

Alexandre Oliva Dec. 14, 2010, 4:18 a.m. UTC
On Dec  8, 2010, Richard Guenther <richard.guenther@gmail.com> wrote:

> On Wed, Dec 8, 2010 at 5:06 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
>> At -O0, we merge blocks or not depending on locus information present at
>> the last insn in a block and the entry locus of the subsequent block.
>> We shouldn't use the locus of a debug insn for this compare, lest we may
>> end up not merging blocks that, with -g0, we would.
>> 
>> This seldom occurs in practice, since this patch is only active at -O0,
>> and -fvar-tracking is disabled by default at -O0, even if -g is enabled.
>> However, since it's possible to explicitly activate -fvar-tracking (and
>> -fvar-tracking-assignments), even at -O0, we shouldn't generate
>> different executable code if the user does this.
>> 
>> The patch below was regstrapped on x86_64-linux-gnu.  Ok to install?

> Ok.

A few tweaks were needed for 4.5.  Regstrapped on x86_64-linux-gnu,
along with the patch for PR 46576 (unchanged).  I'll apply both in the
4.5 branch if there aren't objections within 20 hours or so, so that the
bug reports can be closed.

Comments

Richard Biener Dec. 15, 2010, 2:18 a.m. UTC | #1
On Tue, Dec 14, 2010 at 5:18 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
> On Dec  8, 2010, Richard Guenther <richard.guenther@gmail.com> wrote:
>
>> On Wed, Dec 8, 2010 at 5:06 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
>>> At -O0, we merge blocks or not depending on locus information present at
>>> the last insn in a block and the entry locus of the subsequent block.
>>> We shouldn't use the locus of a debug insn for this compare, lest we may
>>> end up not merging blocks that, with -g0, we would.
>>>
>>> This seldom occurs in practice, since this patch is only active at -O0,
>>> and -fvar-tracking is disabled by default at -O0, even if -g is enabled.
>>> However, since it's possible to explicitly activate -fvar-tracking (and
>>> -fvar-tracking-assignments), even at -O0, we shouldn't generate
>>> different executable code if the user does this.
>>>
>>> The patch below was regstrapped on x86_64-linux-gnu.  Ok to install?
>
>> Ok.
>
> A few tweaks were needed for 4.5.  Regstrapped on x86_64-linux-gnu,
> along with the patch for PR 46576 (unchanged).  I'll apply both in the
> 4.5 branch if there aren't objections within 20 hours or so, so that the
> bug reports can be closed.

Please wait until after 4.5.2 is released, the branch is currently frozen.

Thanks,
Richard.

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

Patch

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

	PR debug/46782
	* cfgcleanup.c (try_forward_edges): Skip debug insns.
	
for  gcc/testsuite/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR debug/46782
	* gcc.dg/debug/pr46782.c: New.

Index: gcc/cfgcleanup.c
===================================================================
--- gcc/cfgcleanup.c.orig	2010-06-10 13:56:42.000000000 -0300
+++ gcc/cfgcleanup.c	2010-12-13 01:24:08.015744331 -0200
@@ -482,15 +482,20 @@  try_forward_edges (int mode, basic_block
 		  /* When not optimizing, ensure that edges or forwarder
 		     blocks with different locus are not optimized out.  */
 		  int locus = single_succ_edge (target)->goto_locus;
+		  rtx last ;
 
 		  if (locus && goto_locus && !locator_eq (locus, goto_locus))
 		    counter = n_basic_blocks;
 		  else if (locus)
 		    goto_locus = locus;
 
-		  if (INSN_P (BB_END (target)))
+		  last = BB_END (target);
+		  if (DEBUG_INSN_P (last))
+		    last = prev_nondebug_insn (last);
+
+		  if (last && INSN_P (last))
 		    {
-		      locus = INSN_LOCATOR (BB_END (target));
+		      locus = INSN_LOCATOR (last);
 
 		      if (locus && goto_locus
 			  && !locator_eq (locus, goto_locus))
Index: gcc/testsuite/gcc.dg/debug/pr46782.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/gcc.dg/debug/pr46782.c	2010-12-13 01:21:44.334901591 -0200
@@ -0,0 +1,11 @@ 
+/* PR debug/46782 */
+/* { dg-do compile } */
+/* { dg-options "-w -O0 -fvar-tracking -fcompare-debug" } */
+
+void foo (int i)
+{
+  if (i)
+    i++;
+  while (i)
+    ;
+}