Ejemplo n.º 1
0
/* Return SSA names that are unused to GGC memory.  This is used to keep
   footprint of compiler during interprocedural optimization.
   As a side effect the SSA_NAME_VERSION number reuse is reduced
   so this function should not be used too often.  */
static unsigned int
release_dead_ssa_names (void)
{
    tree t, next;
    int n = 0;
    referenced_var_iterator rvi;

    /* Current defs point to various dead SSA names that in turn points to dead
       statements so bunch of dead memory is held from releasing.  */
    FOR_EACH_REFERENCED_VAR (t, rvi)
    set_current_def (t, NULL);
    /* Now release the freelist.  */
    for (t = FREE_SSANAMES (cfun); t; t = next)
    {
        next = TREE_CHAIN (t);
        /* Dangling pointers might make GGC to still see dead SSA names, so it is
        important to unlink the list and avoid GGC from seeing all subsequent
        SSA names.  In longer run we want to have all dangling pointers here
         removed (since they usually go through dead statements that consume
         considerable amounts of memory).  */
        TREE_CHAIN (t) = NULL_TREE;
        n++;
    }
    FREE_SSANAMES (cfun) = NULL;

    /* Cgraph edges has been invalidated and point to dead statement.  We need to
       remove them now and will rebuild it before next IPA pass.  */
    cgraph_node_remove_callees (cgraph_node (current_function_decl));

    if (dump_file)
        fprintf (dump_file, "Released %i names, %.2f%%\n", n, n * 100.0 / num_ssa_names);
    return 0;
}
Ejemplo n.º 2
0
/* Return SSA names that are unused to GGC memory.  This is used to keep
   footprint of compiler during interprocedural optimization.
   As a side effect the SSA_NAME_VERSION number reuse is reduced
   so this function should not be used too often.  */
static unsigned int
release_dead_ssa_names (void)
{
  tree t, next;
  int n = 0;
  referenced_var_iterator rvi;

  /* Current defs point to various dead SSA names that in turn point to
     eventually dead variables so a bunch of memory is held live.  */
  FOR_EACH_REFERENCED_VAR (t, rvi)
    set_current_def (t, NULL);
  /* Now release the freelist.  */
  for (t = FREE_SSANAMES (cfun); t; t = next)
    {
      next = TREE_CHAIN (t);
      /* Dangling pointers might make GGC to still see dead SSA names, so it is
 	 important to unlink the list and avoid GGC from seeing all subsequent
	 SSA names.  In longer run we want to have all dangling pointers here
	 removed (since they usually go through dead statements that consume
	 considerable amounts of memory).  */
      TREE_CHAIN (t) = NULL_TREE;
      n++;
    }
  FREE_SSANAMES (cfun) = NULL;

  statistics_counter_event (cfun, "SSA names released", n);
  if (dump_file)
    fprintf (dump_file, "Released %i names, %.2f%%\n",
	     n, n * 100.0 / num_ssa_names);
  return 0;
}
Ejemplo n.º 3
0
/* Return SSA names that are unused to GGC memory and compact the SSA
   version namespace.  This is used to keep footprint of compiler during
   interprocedural optimization.  */
static unsigned int
release_dead_ssa_names (void)
{
  tree t;
  unsigned i, j;
  int n = VEC_length (tree, FREE_SSANAMES (cfun));
  referenced_var_iterator rvi;

  /* Current defs point to various dead SSA names that in turn point to
     eventually dead variables so a bunch of memory is held live.  */
  FOR_EACH_REFERENCED_VAR (cfun, t, rvi)
    set_current_def (t, NULL);

  /* Now release the freelist.  */
  VEC_free (tree, gc, FREE_SSANAMES (cfun));
  FREE_SSANAMES (cfun) = NULL;

  /* And compact the SSA number space.  We make sure to not change the
     relative order of SSA versions.  */
  for (i = 1, j = 1; i < VEC_length (tree, cfun->gimple_df->ssa_names); ++i)
    {
      tree name = ssa_name (i);
      if (name)
	{
	  if (i != j)
	    {
	      SSA_NAME_VERSION (name) = j;
	      VEC_replace (tree, cfun->gimple_df->ssa_names, j, name);
	    }
	  j++;
	}
    }
  VEC_truncate (tree, cfun->gimple_df->ssa_names, j);

  statistics_counter_event (cfun, "SSA names released", n);
  statistics_counter_event (cfun, "SSA name holes removed", i - j);
  if (dump_file)
    fprintf (dump_file, "Released %i names, %.2f%%, removed %i holes\n",
	     n, n * 100.0 / num_ssa_names, i - j);
  return 0;
}