示例#1
0
static void
cgraph_build_cdtor_fns (void)
{
  if (!VEC_empty (tree, static_ctors))
    {
      gcc_assert (!targetm.have_ctors_dtors);
      qsort (VEC_address (tree, static_ctors),
	     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);
    }

  if (!VEC_empty (tree, static_dtors))
    {
      gcc_assert (!targetm.have_ctors_dtors);
      qsort (VEC_address (tree, static_dtors),
	     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);
    }
}
        return 0;
}

void
normalize_mem_ranges (VEC(mem_range_s) *ranges)
{
    /* This function must not use any VEC operation on RANGES that
       reallocates the memory block as that invalidates the RANGES
       pointer, which callers expect to remain valid.  */

    if (!VEC_empty (mem_range_s, ranges))
    {
        struct mem_range *ra, *rb;
        int a, b;

        qsort (VEC_address (mem_range_s, ranges),
               VEC_length (mem_range_s, ranges),
               sizeof (mem_range_s),
               compare_mem_ranges);

        a = 0;
        ra = VEC_index (mem_range_s, ranges, a);
        for (b = 1; VEC_iterate (mem_range_s, ranges, b, rb); b++)
        {
            /* If mem_range B overlaps or is adjacent to mem_range A,
               merge them.  */
            if (rb->start <= ra->start + ra->length)
            {
                ra->length = max (ra->length,
                                  (rb->start - ra->start) + rb->length);
                continue;		/* next b, same a */