diff options
Diffstat (limited to 'gcc/passes.c')
-rw-r--r-- | gcc/passes.c | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/gcc/passes.c b/gcc/passes.c index d4115b3..7e224fb 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -633,9 +633,7 @@ register_pass_name (struct opt_pass *pass, const char *name) /* Map from pass id to canonicalized pass name. */ typedef const char *char_ptr; -DEF_VEC_P(char_ptr); -DEF_VEC_ALLOC_P(char_ptr, heap); -static VEC(char_ptr, heap) *pass_tab = NULL; +static vec<char_ptr> pass_tab = vec<char_ptr>(); /* Callback function for traversing NAME_TO_PASS_MAP. */ @@ -646,10 +644,9 @@ pass_traverse (void **slot, void *data ATTRIBUTE_UNUSED) struct opt_pass *pass = (*p)->pass; gcc_assert (pass->static_pass_number > 0); - gcc_assert (pass_tab); + gcc_assert (pass_tab.exists ()); - VEC_replace (char_ptr, pass_tab, pass->static_pass_number, - (*p)->unique_name); + pass_tab[pass->static_pass_number] = (*p)->unique_name; return 1; } @@ -663,8 +660,7 @@ create_pass_tab (void) if (!flag_dump_passes) return; - VEC_safe_grow_cleared (char_ptr, heap, - pass_tab, passes_by_id_size + 1); + pass_tab.safe_grow_cleared (passes_by_id_size + 1); htab_traverse (name_to_pass_map, pass_traverse, NULL); } @@ -686,7 +682,7 @@ dump_one_pass (struct opt_pass *pass, int pass_indent) if (pass->static_pass_number <= 0) pn = pass->name; else - pn = VEC_index (char_ptr, pass_tab, pass->static_pass_number); + pn = pass_tab[pass->static_pass_number]; fprintf (stderr, "%*s%-40s%*s:%s%s\n", indent, " ", pn, (15 - indent < 0 ? 0 : 15 - indent), " ", @@ -772,11 +768,11 @@ struct uid_range typedef struct uid_range *uid_range_p; -DEF_VEC_P(uid_range_p); -DEF_VEC_ALLOC_P(uid_range_p, heap); -static VEC(uid_range_p, heap) *enabled_pass_uid_range_tab = NULL; -static VEC(uid_range_p, heap) *disabled_pass_uid_range_tab = NULL; +static vec<uid_range_p> + enabled_pass_uid_range_tab = vec<uid_range_p>(); +static vec<uid_range_p> + disabled_pass_uid_range_tab = vec<uid_range_p>(); /* Parse option string for -fdisable- and -fenable- @@ -795,7 +791,7 @@ enable_disable_pass (const char *arg, bool is_enable) struct opt_pass *pass; char *range_str, *phase_name; char *argstr = xstrdup (arg); - VEC(uid_range_p, heap) **tab = 0; + vec<uid_range_p> *tab = 0; range_str = strchr (argstr,'='); if (range_str) @@ -830,9 +826,8 @@ enable_disable_pass (const char *arg, bool is_enable) else tab = &disabled_pass_uid_range_tab; - if ((unsigned) pass->static_pass_number >= VEC_length (uid_range_p, *tab)) - VEC_safe_grow_cleared (uid_range_p, heap, - *tab, pass->static_pass_number + 1); + if ((unsigned) pass->static_pass_number >= tab->length ()) + tab->safe_grow_cleared (pass->static_pass_number + 1); if (!range_str) { @@ -842,10 +837,9 @@ enable_disable_pass (const char *arg, bool is_enable) new_range->start = 0; new_range->last = (unsigned)-1; - slot = VEC_index (uid_range_p, *tab, pass->static_pass_number); + slot = (*tab)[pass->static_pass_number]; new_range->next = slot; - VEC_replace (uid_range_p, *tab, pass->static_pass_number, - new_range); + (*tab)[pass->static_pass_number] = new_range; if (is_enable) inform (UNKNOWN_LOCATION, "enable pass %s for functions in the range " "of [%u, %u]", phase_name, new_range->start, new_range->last); @@ -925,10 +919,9 @@ enable_disable_pass (const char *arg, bool is_enable) new_range->last = (unsigned) last; } - slot = VEC_index (uid_range_p, *tab, pass->static_pass_number); + slot = (*tab)[pass->static_pass_number]; new_range->next = slot; - VEC_replace (uid_range_p, *tab, pass->static_pass_number, - new_range); + (*tab)[pass->static_pass_number] = new_range; if (is_enable) { if (new_range->assem_name) @@ -980,18 +973,18 @@ disable_pass (const char *arg) static bool is_pass_explicitly_enabled_or_disabled (struct opt_pass *pass, tree func, - VEC(uid_range_p, heap) *tab) + vec<uid_range_p> tab) { uid_range_p slot, range; int cgraph_uid; const char *aname = NULL; - if (!tab - || (unsigned) pass->static_pass_number >= VEC_length (uid_range_p, tab) + if (!tab.exists () + || (unsigned) pass->static_pass_number >= tab.length () || pass->static_pass_number == -1) return false; - slot = VEC_index (uid_range_p, tab, pass->static_pass_number); + slot = tab[pass->static_pass_number]; if (!slot) return false; @@ -2203,18 +2196,13 @@ execute_all_ipa_transforms (void) return; node = cgraph_get_node (current_function_decl); - if (node->ipa_transforms_to_apply) + if (node->ipa_transforms_to_apply.exists ()) { unsigned int i; - for (i = 0; i < VEC_length (ipa_opt_pass, node->ipa_transforms_to_apply); - i++) - execute_one_ipa_transform_pass (node, - VEC_index (ipa_opt_pass, - node->ipa_transforms_to_apply, - i)); - VEC_free (ipa_opt_pass, heap, node->ipa_transforms_to_apply); - node->ipa_transforms_to_apply = NULL; + for (i = 0; i < node->ipa_transforms_to_apply.length (); i++) + execute_one_ipa_transform_pass (node, node->ipa_transforms_to_apply[i]); + node->ipa_transforms_to_apply.release (); } } @@ -2224,7 +2212,7 @@ static void apply_ipa_transforms (void *data) { struct cgraph_node *node = cgraph_get_node (current_function_decl); - if (!node->global.inlined_to && node->ipa_transforms_to_apply) + if (!node->global.inlined_to && node->ipa_transforms_to_apply.exists ()) { *(bool *)data = true; execute_all_ipa_transforms(); @@ -2372,8 +2360,7 @@ execute_one_pass (struct opt_pass *pass) { struct cgraph_node *node; FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node) - VEC_safe_push (ipa_opt_pass, heap, node->ipa_transforms_to_apply, - (struct ipa_opt_pass_d *)pass); + node->ipa_transforms_to_apply.safe_push ((struct ipa_opt_pass_d *)pass); } if (!current_function_decl) |