diff options
author | Kazu Hirata <kazu@codesourcery.com> | 2006-03-14 18:11:11 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2006-03-14 18:11:11 +0000 |
commit | e4881f234282275033295e6ed76be02c5f42bbc3 (patch) | |
tree | ba26be5febaa75b9f0f98497149c7028e94907e3 /gcc/reg-stack.c | |
parent | 69d1a403420aea41cd6ce81087e1e388c571118e (diff) | |
download | gcc-e4881f234282275033295e6ed76be02c5f42bbc3.zip gcc-e4881f234282275033295e6ed76be02c5f42bbc3.tar.gz gcc-e4881f234282275033295e6ed76be02c5f42bbc3.tar.bz2 |
Makefile.in (reg-stack.o): Don't depend on gt-reg-stack.h.
* 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.
From-SVN: r112060
Diffstat (limited to 'gcc/reg-stack.c')
-rw-r--r-- | gcc/reg-stack.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c index 73c132f..f77b2b3 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" |