This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Merge constructors and destructors


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]