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]

Re: Loop clean up fixes


On Jan 21, 2000, Michael Hayes <m.hayes@elec.canterbury.ac.nz> wrote:

> 2000-01-21  Michael Hayes  <m.hayes@elec.canterbury.ac.nz>

> 	* loop.c (loop_optimize): Replace alloca with xcalloc/free.

How about this, then?

BTW, I can't see where loops->array is freed; does it remain allocated
forever?  In this case, you might prefer to allocate the loop_info
array as I do, but within loop_optimize.

Index: gcc/ChangeLog
from  Alexandre Oliva  <oliva@lsd.ic.unicamp.br>
	
	* loop.c (find_and_verify_loops): Allocate loop_info array.
	
Index: gcc/loop.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/loop.c,v
retrieving revision 1.221
diff -u -r1.221 loop.c
--- gcc/loop.c	2000/01/19 20:10:00	1.221
+++ gcc/loop.c	2000/01/21 11:14:51
@@ -2597,8 +2597,13 @@
   uid_loop[0] = NULL;
 
   loops->array = (struct loop *)
-    xmalloc (num_loops * sizeof (struct loop));
-  bzero ((char *)loops->array, num_loops * sizeof (struct loop));
+    xcalloc (num_loops, sizeof (struct loop));
+
+  loops->array[0].info = (struct loop_info *)
+    xcalloc (num_loops, sizeof (struct loop_info));
+
+  while (--num_loops > 0)
+    loops->array[num_loops].info = &loops->array[0].info[num_loops];
       
   /* Find boundaries of loops, mark which loops are contained within
      loops, and invalidate loops that have setjmp.  */

-- 
Alexandre Oliva http://www.ic.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{lsd.ic.unicamp.br,guarana.{org,com}} aoliva@{acm,computer}.org
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them

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