Patchwork [PR,rtl-optimization/55604] : fix ICE in remove_some_program_points_and_update_live_ranges

login
register
mail settings
Submitter Aldy Hernandez
Date Dec. 5, 2012, 6:13 p.m.
Message ID <50BF8ECF.4010804@redhat.com>
Download mbox | patch
Permalink /patch/203917/
State New
Headers show

Comments

Aldy Hernandez - Dec. 5, 2012, 6:13 p.m.
This is a division by zero ICE.

In the testcase in the PR, both `n' and `lra_live_max_point' are zero. 
I have opted to inhibit the dump when lra_live_max_point is zero, but I 
can just as easily avoiding printing the percentage in this case.

Let me know what you prefer.

OK for trunk?
commit 6b366d44e7d30d3a24eda07fcb43fc20e2aa7102
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Wed Dec 5 12:06:01 2012 -0600

    	PR rtl-optimization/55604
    	* lra-lives.c
    	* (remove_some_program_points_and_update_live_ranges):
    	Avoiding division by zero when dumping live range compression.
Steven Bosscher - Dec. 5, 2012, 6:26 p.m.
On Wed, Dec 5, 2012 at 7:13 PM, Aldy Hernandez wrote:
> This is a division by zero ICE.
>
> In the testcase in the PR, both `n' and `lra_live_max_point' are zero. I
> have opted to inhibit the dump when lra_live_max_point is zero, but I can
> just as easily avoiding printing the percentage in this case.

Test case?

Also, it'd be preferable if you can also update
remove_some_program_points_and_update_live_ranges in ira-lives.c -- it
seems to me that at some point we're going to want to merge the almost
identical functions from LRA and IRA but that gets harder if they
start diverging.

> Let me know what you prefer.

How can you end up with lra_live_max_point==0? AFAIU that can only
happen if you have no live ranges at all (no program points) or if
somehow the curr_point counter got messed up. The former case would
mean you shouldn't end up calling
remove_some_program_points_and_update_live_ranges to begin with (no
program points being there to remove), the latter case would be a bug.

I don't think this is the correct fix.

Ciao!
Steven
Vladimir Makarov - Dec. 5, 2012, 6:47 p.m.
On 12-12-05 1:13 PM, Aldy Hernandez wrote:
> This is a division by zero ICE.
>
> In the testcase in the PR, both `n' and `lra_live_max_point' are zero. 
> I have opted to inhibit the dump when lra_live_max_point is zero, but 
> I can just as easily avoiding printing the percentage in this case.
>
Interesting.  I never thought that is possible.
> Let me know what you prefer.
>
> OK for trunk?
Yes, it is ok if you add the testcase for GCC testsuite.  It would be 
nice if you add analogous code for 
ira-lives.c::remove_some_program_points_and_update_live_ranges too.

Patch

diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c
index c79b95b..46146ca 100644
--- a/gcc/lra-lives.c
+++ b/gcc/lra-lives.c
@@ -811,7 +811,7 @@  remove_some_program_points_and_update_live_ranges (void)
   sbitmap_free (born);
   sbitmap_free (dead);
   n++;
-  if (lra_dump_file != NULL)
+  if (lra_dump_file != NULL && lra_live_max_point)
     fprintf (lra_dump_file, "Compressing live ranges: from %d to %d - %d%%\n",
 	     lra_live_max_point, n, 100 * n / lra_live_max_point);
   if (n < lra_live_max_point)