]> gcc.gnu.org Git - gcc.git/commitdiff
ipa.c (build_cdtor): Take VECtor as argument; fix array walk.
authorJan Hubicka <jh@suse.cz>
Fri, 3 Sep 2010 23:47:11 +0000 (01:47 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 3 Sep 2010 23:47:11 +0000 (23:47 +0000)
* ipa.c (build_cdtor): Take VECtor as argument; fix array walk.
(build_cdtor_fns): Update use of build_cdtor.

From-SVN: r163849

gcc/ChangeLog
gcc/ipa.c

index 6e30c005c6d9632e230a620ff5a0065b0b92a128..f7fe198180d7c4b764323ac407eac1da3ea73c80 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * doc/options.texi (SeparateAlias): Document.
index b199796fcdb2f1f320a4266af0119a0e66b1551f..48e331e9b77f271fc7665a4dbb563871a5fd25d5 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -1425,9 +1425,10 @@ record_cdtor_fn (struct cgraph_node *node)
    they are destructors.  */
 
 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 len = VEC_length (tree, cdtors);
 
   i = 0;
   while (i < len)
@@ -1442,7 +1443,7 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t len)
       do
        {
          priority_type p;
-         fn = cdtors[i];
+         fn = VEC_index (tree, cdtors, j);
          p = ctor_p ? DECL_INIT_PRIORITY (fn) : DECL_FINI_PRIORITY (fn);
          if (j == i)
            priority = p;
@@ -1452,7 +1453,7 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t 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
          && targetm.have_ctors_dtors)
        {
@@ -1461,14 +1462,10 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t len)
        }
       /* Find the next batch of constructors/destructors with the same
         initialization priority.  */
-      do
+      for (;i < j; i++)
        {
-         priority_type p;
          tree call;
-         fn = cdtors[i];
-         p = ctor_p ? DECL_INIT_PRIORITY (fn) : DECL_FINI_PRIORITY (fn);
-         if (p != priority)
-           break;
+         fn = VEC_index (tree, cdtors, i);
          call = build_call_expr (fn, 0);
          if (ctor_p)
            DECL_STATIC_CONSTRUCTOR (fn) = 0;
@@ -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.  */
          TREE_SIDE_EFFECTS (call) = 1;
          append_to_statement_list (call, &body);
-         ++i;
        }
       while (i < len);
       gcc_assert (body != NULL_TREE);
@@ -1556,10 +1552,7 @@ build_cdtor_fns (void)
             VEC_length (tree, static_ctors),
             sizeof (tree),
             compare_ctor);
-      build_cdtor (/*ctor_p=*/true,
-                  VEC_address (tree, static_ctors),
-                  VEC_length (tree, static_ctors));
-      VEC_truncate (tree, static_ctors, 0);
+      build_cdtor (/*ctor_p=*/true, static_ctors);
     }
 
   if (!VEC_empty (tree, static_dtors))
@@ -1569,10 +1562,7 @@ build_cdtor_fns (void)
             VEC_length (tree, static_dtors),
             sizeof (tree),
             compare_dtor);
-      build_cdtor (/*ctor_p=*/false,
-                  VEC_address (tree, static_dtors),
-                  VEC_length (tree, static_dtors));
-      VEC_truncate (tree, static_dtors, 0);
+      build_cdtor (/*ctor_p=*/false, static_dtors);
     }
 }
 
This page took 0.117851 seconds and 5 git commands to generate.