OSDN Git Service

* Makefile.in (reg-stack.o): Don't depend on gt-reg-stack.h.
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Mar 2006 18:11:11 +0000 (18:11 +0000)
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Mar 2006 18:11:11 +0000 (18:11 +0000)
* reg-stack.c (stack_regs_mentioned_data): Change the type to
VEC(char,heap) *.
(stack_regs_mentioned): Update the uses of
stack_regs_mentioned_data.  Don't access the array beyond its
end.
(reg_to_stack): Update the uses of stack_regs_mentioned_data.
Don't include gt-reg-stack.h.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@112060 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/Makefile.in
gcc/reg-stack.c

index 21f659e..441819c 100644 (file)
@@ -1,3 +1,14 @@
+2006-03-14  Kazu Hirata  <kazu@codesourcery.com>
+
+       * Makefile.in (reg-stack.o): Don't depend on gt-reg-stack.h.
+       * reg-stack.c (stack_regs_mentioned_data): Change the type to
+       VEC(char,heap) *.
+       (stack_regs_mentioned): Update the uses of
+       stack_regs_mentioned_data.  Don't access the array beyond its
+       end.
+       (reg_to_stack): Update the uses of stack_regs_mentioned_data.
+       Don't include gt-reg-stack.h.
+
 2006-03-14  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * pa/pa32-linux.h (CRT_CALL_STATIC_FUNCTION): Fix typo.
index 934593f..4552eff 100644 (file)
@@ -2544,7 +2544,7 @@ recog.o : recog.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
 reg-stack.o : reg-stack.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    $(RTL_H) $(TREE_H) $(RECOG_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) \
    insn-config.h toplev.h reload.h $(FUNCTION_H) $(TM_P_H) $(GGC_H) \
-   gt-reg-stack.h $(BASIC_BLOCK_H) output.h $(VARRAY_H) timevar.h tree-pass.h \
+   $(BASIC_BLOCK_H) output.h $(VARRAY_H) timevar.h tree-pass.h \
    target.h
 sreal.o: sreal.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) sreal.h
 predict.o: predict.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
@@ -2845,7 +2845,7 @@ gt-function.h gt-integrate.h gt-tree.h gt-varasm.h \
 gt-emit-rtl.h gt-explow.h gt-stor-layout.h gt-regclass.h \
 gt-lists.h gt-alias.h gt-cselib.h gt-gcse.h \
 gt-expr.h gt-sdbout.h gt-optabs.h gt-bitmap.h gt-dojump.h \
-gt-dwarf2out.h gt-reg-stack.h gt-dwarf2asm.h \
+gt-dwarf2out.h gt-dwarf2asm.h \
 gt-dbxout.h \
 gtype-c.h gt-cfglayout.h \
 gt-tree-mudflap.h gt-tree-vect-generic.h \
index 73c132f..f77b2b3 100644 (file)
 #include "tree-pass.h"
 #include "target.h"
 
+DEF_VEC_I(char);
+DEF_VEC_ALLOC_I(char,heap);
+
 /* We use this array to cache info about insns, because otherwise we
    spend too much time in stack_regs_mentioned_p.
 
    Indexed by insn UIDs.  A value of zero is uninitialized, one indicates
    the insn uses stack registers, two indicates the insn does not use
    stack registers.  */
-static GTY(()) varray_type stack_regs_mentioned_data;
+static VEC(char,heap) *stack_regs_mentioned_data;
 
 #ifdef STACK_REGS
 
@@ -309,21 +312,27 @@ stack_regs_mentioned (rtx insn)
     return 0;
 
   uid = INSN_UID (insn);
-  max = VARRAY_SIZE (stack_regs_mentioned_data);
+  max = VEC_length (char, stack_regs_mentioned_data);
   if (uid >= max)
     {
+      char *p;
+      unsigned int old_max = max;
+
       /* Allocate some extra size to avoid too many reallocs, but
         do not grow too quickly.  */
-      max = uid + uid / 20;
-      VARRAY_GROW (stack_regs_mentioned_data, max);
+      max = uid + uid / 20 + 1;
+      VEC_safe_grow (char, heap, stack_regs_mentioned_data, max);
+      p = VEC_address (char, stack_regs_mentioned_data);
+      memset (&p[old_max], 0,
+             sizeof (char) * (max - old_max));
     }
 
-  test = VARRAY_CHAR (stack_regs_mentioned_data, uid);
+  test = VEC_index (char, stack_regs_mentioned_data, uid);
   if (test == 0)
     {
       /* This insn has yet to be examined.  Do so now.  */
       test = stack_regs_mentioned_p (PATTERN (insn)) ? 1 : 2;
-      VARRAY_CHAR (stack_regs_mentioned_data, uid) = test;
+      VEC_replace (char, stack_regs_mentioned_data, uid, test);
     }
 
   return test == 1;
@@ -3031,7 +3040,8 @@ reg_to_stack (void)
   int max_uid;
 
   /* Clean up previous run.  */
-  stack_regs_mentioned_data = 0;
+  if (stack_regs_mentioned_data != NULL)
+    VEC_free (char, heap, stack_regs_mentioned_data);
 
   /* See if there is something to do.  Flow analysis is quite
      expensive so we might save some compilation time.  */
@@ -3114,8 +3124,9 @@ reg_to_stack (void)
 
   /* Allocate a cache for stack_regs_mentioned.  */
   max_uid = get_max_uid ();
-  VARRAY_CHAR_INIT (stack_regs_mentioned_data, max_uid + 1,
-                   "stack_regs_mentioned cache");
+  stack_regs_mentioned_data = VEC_alloc (char, heap, max_uid + 1);
+  memset (VEC_address (char, stack_regs_mentioned_data),
+         0, sizeof (char) * max_uid + 1);
 
   convert_regs ();
 
@@ -3171,5 +3182,3 @@ struct tree_opt_pass pass_stack_regs =
   TODO_ggc_collect,                     /* todo_flags_finish */
   'k'                                   /* letter */
 };
-
-#include "gt-reg-stack.h"