Commit 48c24aca by Jan Hubicka Committed by Jan Hubicka

ipa.c (build_cdtor): Take VECtor as argument; fix array walk.


	* ipa.c (build_cdtor): Take VECtor as argument; fix array walk.
	(build_cdtor_fns): Update use of build_cdtor.

From-SVN: r163849
parent 9c7f808d
2010-09-03 Jan Hubicka <jh@suse.cz>
* ipa.c (build_cdtor): Take VECtor as argument; fix array walk.
(build_cdtor_fns): Update use of build_cdtor.
2010-09-03 Joseph Myers <joseph@codesourcery.com> 2010-09-03 Joseph Myers <joseph@codesourcery.com>
* doc/options.texi (SeparateAlias): Document. * doc/options.texi (SeparateAlias): Document.
......
...@@ -1425,9 +1425,10 @@ record_cdtor_fn (struct cgraph_node *node) ...@@ -1425,9 +1425,10 @@ record_cdtor_fn (struct cgraph_node *node)
they are destructors. */ they are destructors. */
static void static void
build_cdtor (bool ctor_p, tree *cdtors, size_t len) build_cdtor (bool ctor_p, VEC (tree, heap) *cdtors)
{ {
size_t i,j; size_t i,j;
size_t len = VEC_length (tree, cdtors);
i = 0; i = 0;
while (i < len) while (i < len)
...@@ -1442,7 +1443,7 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t len) ...@@ -1442,7 +1443,7 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t len)
do do
{ {
priority_type p; priority_type p;
fn = cdtors[i]; fn = VEC_index (tree, cdtors, j);
p = ctor_p ? DECL_INIT_PRIORITY (fn) : DECL_FINI_PRIORITY (fn); p = ctor_p ? DECL_INIT_PRIORITY (fn) : DECL_FINI_PRIORITY (fn);
if (j == i) if (j == i)
priority = p; priority = p;
...@@ -1452,7 +1453,7 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t len) ...@@ -1452,7 +1453,7 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t len)
} }
while (j < len); while (j < len);
/* When there is only once constructor and target supports them, do nothing. */ /* When there is only one cdtor and target supports them, do nothing. */
if (j == i + 1 if (j == i + 1
&& targetm.have_ctors_dtors) && targetm.have_ctors_dtors)
{ {
...@@ -1461,14 +1462,10 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t len) ...@@ -1461,14 +1462,10 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t len)
} }
/* Find the next batch of constructors/destructors with the same /* Find the next batch of constructors/destructors with the same
initialization priority. */ initialization priority. */
do for (;i < j; i++)
{ {
priority_type p;
tree call; tree call;
fn = cdtors[i]; fn = VEC_index (tree, cdtors, i);
p = ctor_p ? DECL_INIT_PRIORITY (fn) : DECL_FINI_PRIORITY (fn);
if (p != priority)
break;
call = build_call_expr (fn, 0); call = build_call_expr (fn, 0);
if (ctor_p) if (ctor_p)
DECL_STATIC_CONSTRUCTOR (fn) = 0; DECL_STATIC_CONSTRUCTOR (fn) = 0;
...@@ -1479,7 +1476,6 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t len) ...@@ -1479,7 +1476,6 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t len)
optimizing, we want user to be able to breakpoint in them. */ optimizing, we want user to be able to breakpoint in them. */
TREE_SIDE_EFFECTS (call) = 1; TREE_SIDE_EFFECTS (call) = 1;
append_to_statement_list (call, &body); append_to_statement_list (call, &body);
++i;
} }
while (i < len); while (i < len);
gcc_assert (body != NULL_TREE); gcc_assert (body != NULL_TREE);
...@@ -1556,10 +1552,7 @@ build_cdtor_fns (void) ...@@ -1556,10 +1552,7 @@ build_cdtor_fns (void)
VEC_length (tree, static_ctors), VEC_length (tree, static_ctors),
sizeof (tree), sizeof (tree),
compare_ctor); compare_ctor);
build_cdtor (/*ctor_p=*/true, build_cdtor (/*ctor_p=*/true, static_ctors);
VEC_address (tree, static_ctors),
VEC_length (tree, static_ctors));
VEC_truncate (tree, static_ctors, 0);
} }
if (!VEC_empty (tree, static_dtors)) if (!VEC_empty (tree, static_dtors))
...@@ -1569,10 +1562,7 @@ build_cdtor_fns (void) ...@@ -1569,10 +1562,7 @@ build_cdtor_fns (void)
VEC_length (tree, static_dtors), VEC_length (tree, static_dtors),
sizeof (tree), sizeof (tree),
compare_dtor); compare_dtor);
build_cdtor (/*ctor_p=*/false, build_cdtor (/*ctor_p=*/false, static_dtors);
VEC_address (tree, static_dtors),
VEC_length (tree, static_dtors));
VEC_truncate (tree, static_dtors, 0);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment