diff mbox

Fix a bug in merging uninitialized refs into a single web

Message ID 4D4D3D16.5090405@codesourcery.com
State New
Headers show

Commit Message

Jie Zhang Feb. 5, 2011, 12:05 p.m. UTC
Hi Jeff,

On 02/04/2011 12:44 AM, Jeff Law wrote:
> Sorry for the long delay -- I probably should have asked someone else to
> own this since my initial comments were solely on the CLOBBER issue and
> I didn't have any familiarity with the web pass.
>
No problem. Thanks for review! :-)

> On 01/05/11 19:21, Jie Zhang wrote:
>> Thanks for review. Yeah. I thought about ignoring the clobber at first.
>> But later I found there was a bug in the code which merges uninitialized
>> refs into a single web and fixing that bug should also fix the issue I
>> encountered. So I just try to fix that bug which will be safer and
>> easier for me.
> So just so I'm certain I understand the problem.  In the original
> testcase a naked CLOBBER was the "set" that triggered the problem, but
> this problem can occur for assignments to any uninitialized pseudo, such
> as in examples you provided below.
>
> When we see a set to an uninitialized pseudo, we're losing the saved
> DF_REF_UID which allows us to combine all the uninitialized uses into a
> single web.  Right?
>
Yes. My patch just prevents this losing.

> Assuming that those statements are correct, the patch is OK.  I would
> suggest including both the testcase derived from dhrystone as well as
> the one in this message in the testsuite.
>
That test case is already in the testsuite. I just update that test case 
to check the issue I found.

I have committed the attached patch on trunk.


Regards,
diff mbox

Patch


	PR debug/42631
	* web.c (entry_register): Don't clobber the number of the
	first uninitialized reference in used[].

	testsuite/
	PR debug/42631
	* gcc.dg/pr42631.c: Update test.
	* gcc.dg/pr42631-2.c: New test.

Index: testsuite/gcc.dg/pr42631-2.c
===================================================================
--- testsuite/gcc.dg/pr42631-2.c	(revision 0)
+++ testsuite/gcc.dg/pr42631-2.c	(revision 0)
@@ -0,0 +1,9 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -funroll-loops -fdump-rtl-web" } */
+
+foo()
+{
+}
+
+/* { dg-final { scan-rtl-dump-not "Web oldreg" "web" } } */
+/* { dg-final { cleanup-rtl-dump "web" } } */
Index: testsuite/gcc.dg/pr42631.c
===================================================================
--- testsuite/gcc.dg/pr42631.c	(revision 169850)
+++ testsuite/gcc.dg/pr42631.c	(working copy)
@@ -14,10 +14,13 @@ 
    combine uninitialized uses into a single web.  */
 
 /* { dg-do compile } */
-/* { dg-options "-g -O1 -funroll-loops -fcompare-debug" } */
+/* { dg-options "-g -O1 -funroll-loops -fcompare-debug -fdump-rtl-web" } */
 
 void foo()
 {
   unsigned k;
   while (--k > 0);
 }
+
+/* { dg-final { scan-rtl-dump-not "Web oldreg" "web" } } */
+/* { dg-final { cleanup-rtl-dump "web" } } */
Index: web.c
===================================================================
--- web.c	(revision 169850)
+++ web.c	(working copy)
@@ -260,7 +260,11 @@  entry_register (struct web_entry *entry,
      and there won't be any use for the other values when we get to
      this point.  */
   if (used[REGNO (reg)] != 1)
-    newreg = reg, used[REGNO (reg)] = 1;
+    {
+      newreg = reg;
+      if (!used[REGNO (reg)])
+	used[REGNO (reg)] = 1;
+    }
   else
     {
       newreg = gen_reg_rtx (GET_MODE (reg));