From: Trevor Saunders Date: Wed, 13 Jul 2016 02:43:43 +0000 (+0000) Subject: ipa.c: remove static_{ctors,dtors} globals X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=37a5199721af7f322f681cd17efb673d70209d52;p=gcc.git ipa.c: remove static_{ctors,dtors} globals gcc/ChangeLog: 2016-07-12 Trevor Saunders * ipa.c (record_cdtor_fn): Adjust. (build_cdtor_fns): Likewise. (ipa_cdtor_merge): Make static_ctors and static_dtors local variables. From-SVN: r238281 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 16198c1bca3..1e15b9612d5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-07-12 Trevor Saunders + + * ipa.c (record_cdtor_fn): Adjust. + (build_cdtor_fns): Likewise. + (ipa_cdtor_merge): Make static_ctors and static_dtors local + variables. + 2016-07-12 Trevor Saunders * genextract.c (struct accum_extract): Add constructor and make diff --git a/gcc/ipa.c b/gcc/ipa.c index 6722d3b806e..2609e327fd2 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -989,11 +989,6 @@ cgraph_build_static_cdtor (char which, tree body, int priority) cgraph_build_static_cdtor_1 (which, body, priority, false); } -/* A vector of FUNCTION_DECLs declared as static constructors. */ -static vec static_ctors; -/* A vector of FUNCTION_DECLs declared as static destructors. */ -static vec static_dtors; - /* When target does not have ctors and dtors, we call all constructor and destructor by special initialization/destruction function recognized by collect2. @@ -1002,12 +997,12 @@ static vec static_dtors; destructors and turn them into normal functions. */ static void -record_cdtor_fn (struct cgraph_node *node) +record_cdtor_fn (struct cgraph_node *node, vec *ctors, vec *dtors) { if (DECL_STATIC_CONSTRUCTOR (node->decl)) - static_ctors.safe_push (node->decl); + ctors->safe_push (node->decl); if (DECL_STATIC_DESTRUCTOR (node->decl)) - static_dtors.safe_push (node->decl); + dtors->safe_push (node->decl); node = cgraph_node::get (node->decl); DECL_DISREGARD_INLINE_LIMITS (node->decl) = 1; } @@ -1018,7 +1013,7 @@ record_cdtor_fn (struct cgraph_node *node) they are destructors. */ static void -build_cdtor (bool ctor_p, vec cdtors) +build_cdtor (bool ctor_p, const vec &cdtors) { size_t i,j; size_t len = cdtors.length (); @@ -1135,20 +1130,20 @@ compare_dtor (const void *p1, const void *p2) functions have magic names which are detected by collect2. */ static void -build_cdtor_fns (void) +build_cdtor_fns (vec *ctors, vec *dtors) { - if (!static_ctors.is_empty ()) + if (!ctors->is_empty ()) { gcc_assert (!targetm.have_ctors_dtors || in_lto_p); - static_ctors.qsort (compare_ctor); - build_cdtor (/*ctor_p=*/true, static_ctors); + ctors->qsort (compare_ctor); + build_cdtor (/*ctor_p=*/true, *ctors); } - if (!static_dtors.is_empty ()) + if (!dtors->is_empty ()) { gcc_assert (!targetm.have_ctors_dtors || in_lto_p); - static_dtors.qsort (compare_dtor); - build_cdtor (/*ctor_p=*/false, static_dtors); + dtors->qsort (compare_dtor); + build_cdtor (/*ctor_p=*/false, *dtors); } } @@ -1161,14 +1156,16 @@ build_cdtor_fns (void) static unsigned int ipa_cdtor_merge (void) { + /* A vector of FUNCTION_DECLs declared as static constructors. */ + auto_vec ctors; + /* A vector of FUNCTION_DECLs declared as static destructors. */ + auto_vec dtors; struct cgraph_node *node; FOR_EACH_DEFINED_FUNCTION (node) if (DECL_STATIC_CONSTRUCTOR (node->decl) || DECL_STATIC_DESTRUCTOR (node->decl)) - record_cdtor_fn (node); - build_cdtor_fns (); - static_ctors.release (); - static_dtors.release (); + record_cdtor_fn (node, &ctors, &dtors); + build_cdtor_fns (&ctors, &dtors); return 0; }