summaryrefslogtreecommitdiff
path: root/gcc/reg-stack.c
diff options
context:
space:
mode:
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2006-03-14 18:11:11 +0000
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2006-03-14 18:11:11 +0000
commit9500df50b464c25f7a995b7d9ed7282320164728 (patch)
treeba26be5febaa75b9f0f98497149c7028e94907e3 /gcc/reg-stack.c
parentdc5d8324bc60f586a45c4733626004b11670cdb1 (diff)
downloadgcc-9500df50b464c25f7a995b7d9ed7282320164728.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@112060 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/reg-stack.c')
-rw-r--r--gcc/reg-stack.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c
index 73c132fda22..f77b2b3f313 100644
--- a/gcc/reg-stack.c
+++ b/gcc/reg-stack.c
@@ -174,13 +174,16 @@
#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"