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: [PATCH] Use refcounted shared hash tables to decrease var-tracking memory usage and speed it up


Jakub Jelinek wrote:
@@ -801,7 +856,9 @@ unshare_variable (dataflow_set *set, var
new_var->var_part[i].cur_loc = NULL;
}
- slot = htab_find_slot_with_hash (set->vars, new_var->decl,
+ if (shared_hash_shared (set->vars))
+ set->vars = shared_hash_unshare (set->vars);
+ slot = htab_find_slot_with_hash (shared_hash_htab (set->vars), new_var->decl,
VARIABLE_HASH_VAL (new_var->decl),
INSERT);

Seems like this sequence ought to be split out to a function. Indeed, it wouldn't bother me at all if the NO_INSERT case were split out as well -- the repetition of shared_hash_htab and VARIABLE_HASH_VAL are moderately bulky.

E.g.

static inline variable *
shared_hash_find_slot (shared_hash vars, tree decl)
{
  return (variable *)
    htab_find_slot_with_hash (shared_hash_htab (vars),
                              decl, VARIABLE_HASH_VAL (decl),
                              NO_INSERT);
}

static variable *
shared_hash_find_slot_unshare (shared_hash *pvars, tree decl,
                               enum insert_option ins)
{
  shared_hash vars = *pvars;
  if (shared_hash_shared (vars))
    *pvars = vars = shared_hash_unshare (vars);
  return (variable *)
    htab_find_slot_with_hash (shared_hash_htab (vars),
                              decl, VARIABLE_HASH_VAL (decl), ins);
}

Otherwise the patch looks ok.


r~



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