This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix another LRA memory leak (PR middle-end/56461)


Hi!

As discussed in the PR, sometimes we call lra_create_live_ranges multiple
times without intervening lra_clear_live_ranges, which results in memory
leaks.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2013-02-27  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/56461
	* lra.c (lra): Call lra_clear_live_ranges if live_p,
	right before calling lra_create_live_ranges, also call it
	when clearing live_p.  Only call lra_clear_live_ranges
	at the end if live_p.

--- gcc/lra.c.jj	2013-02-09 10:29:36.000000000 +0100
+++ gcc/lra.c	2013-02-27 08:51:34.971860214 +0100
@@ -2291,6 +2291,8 @@ lra (FILE *f)
 	  /* Do inheritance only for regular algorithms.  */
 	  if (! lra_simple_p)
 	    lra_inheritance ();
+	  if (live_p)
+	    lra_clear_live_ranges ();
 	  /* We need live ranges for lra_assign -- so build them.  */
 	  lra_create_live_ranges (true);
 	  live_p = true;
@@ -2308,6 +2310,8 @@ lra (FILE *f)
 		live_p = false;
 	      if (lra_undo_inheritance ())
 		live_p = false;
+	      if (! live_p)
+		lra_clear_live_ranges ();
 	    }
 	}
       bitmap_clear (&lra_optional_reload_pseudos);
@@ -2334,7 +2338,8 @@ lra (FILE *f)
   lra_eliminate (true);
   lra_final_code_change ();
   lra_in_progress = 0;
-  lra_clear_live_ranges ();
+  if (live_p)
+    lra_clear_live_ranges ();
   lra_live_ranges_finish ();
   lra_constraints_finish ();
   finish_reg_info ();

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]