[patch] c-pragma.c: Stop using TREE_LIST for pending_weaks.
Kazu Hirata
kazu@codesourcery.com
Fri Jun 2 19:53:00 GMT 2006
Hi,
Attached is a patch to stop using TREE_LIST for pending_weaks and use
the VEC API instead.
The patch may change the order of elements. AFAICT, I don't think the
order of elements matters, but if it does, please let me know.
Tested on x86_64-pc-linux-gnu. OK to apply to the LTO branch (and 4.3
once in Stage 1)?
Kazu Hirata
2006-06-02 Kazu Hirata <kazu@codesourcery.com>
* c-pragma.c (pending_weak_d, pending_weak): New.
(pending_weaks): Change the type to VEC((pending_weak,gc) *.
(maybe_apply_pragma_weak, maybe_apply_pending_pragma_weaks,
handle_pragma_weak): Update the uses of pending_weaks.
Index: c-pragma.c
===================================================================
--- c-pragma.c (revision 114242)
+++ c-pragma.c (working copy)
@@ -241,7 +241,16 @@ handle_pragma_pack (cpp_reader * ARG_UNU
}
#endif /* HANDLE_PRAGMA_PACK */
-static GTY(()) tree pending_weaks;
+typedef struct pending_weak_d GTY(())
+{
+ tree name;
+ tree value;
+} pending_weak;
+
+DEF_VEC_O(pending_weak);
+DEF_VEC_ALLOC_O(pending_weak,gc);
+
+static GTY(()) VEC(pending_weak,gc) *pending_weaks;
#ifdef HANDLE_PRAGMA_WEAK
static void apply_pragma_weak (tree, tree);
@@ -271,7 +280,9 @@ apply_pragma_weak (tree decl, tree value
void
maybe_apply_pragma_weak (tree decl)
{
- tree *p, t, id;
+ tree id;
+ int i;
+ pending_weak *pe;
/* Avoid asking for DECL_ASSEMBLER_NAME when it's not needed. */
@@ -290,11 +301,11 @@ maybe_apply_pragma_weak (tree decl)
id = DECL_ASSEMBLER_NAME (decl);
- for (p = &pending_weaks; (t = *p) ; p = &TREE_CHAIN (t))
- if (id == TREE_PURPOSE (t))
+ for (i = 0; VEC_iterate (pending_weak, pending_weaks, i, pe); i++)
+ if (id == pe->name)
{
- apply_pragma_weak (decl, TREE_VALUE (t));
- *p = TREE_CHAIN (t);
+ apply_pragma_weak (decl, pe->value);
+ VEC_unordered_remove (pending_weak, pending_weaks, i);
break;
}
}
@@ -304,15 +315,16 @@ maybe_apply_pragma_weak (tree decl)
void
maybe_apply_pending_pragma_weaks (void)
{
- tree *p, t, alias_id, id, decl, *next;
+ tree alias_id, id, decl;
+ int i;
+ pending_weak *pe;
- for (p = &pending_weaks; (t = *p) ; p = next)
+ for (i = 0; VEC_iterate (pending_weak, pending_weaks, i, pe); i++)
{
- next = &TREE_CHAIN (t);
- alias_id = TREE_PURPOSE (t);
- id = TREE_VALUE (t);
+ alias_id = pe->name;
+ id = pe->value;
- if (TREE_VALUE (t) == NULL)
+ if (id == NULL)
continue;
decl = build_decl (FUNCTION_DECL, alias_id, default_function_type);
@@ -355,7 +367,12 @@ handle_pragma_weak (cpp_reader * ARG_UNU
assemble_alias (decl, value);
}
else
- pending_weaks = tree_cons (name, value, pending_weaks);
+ {
+ pending_weak *pe;
+ pe = VEC_safe_push (pending_weak, gc, pending_weaks, NULL);
+ pe->name = name;
+ pe->value = value;
+ }
}
#else
void
More information about the Gcc-patches
mailing list