This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Merge constructors and destructors
- From: Richard Henderson <rth at redhat dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc-patches at gcc dot gnu dot org, tglek at mozilla dot com
- Date: Mon, 23 Aug 2010 11:16:56 -0700
- Subject: Re: Merge constructors and destructors
- References: <20100821121110.GQ630@kam.mff.cuni.cz>
On 08/21/2010 05:11 AM, Jan Hubicka wrote:
> + while (i < len)
> + {
> + tree body;
> + tree fn;
> + priority_type priority;
> +
> + priority = 0;
> + body = NULL_TREE;
> + j = i;
> + do
> + {
> + priority_type p;
> + fn = cdtors[i];
Surely this should be J. Nothing in this loop looks at J.
> + /* Find the next batch of constructors/destructors with the same
> + initialization priority. */
Probably clearer to write the loop
for (; i < j; ++i)
rather than the do/while with the break in the middle.
> + /* Ensure a stable sort. Constructors are executed in backwarding
> + order to make LTO initialize braries first. */
> + return DECL_UID (f2) - DECL_UID (f1);
I have trouble believing that this is reliable. If you do this,
put a checking assert that the original vector is monotonically
increasing in DECL_UID.
> + build_cdtor (/*ctor_p=*/true,
> + VEC_address (tree, static_ctors),
> + VEC_length (tree, static_ctors));
Surely it would be better to pass in the vector, rather than
decomposing it into address+length.
r~