remove unused files
[platform/upstream/gcc48.git] / gcc / tree-emutls.c
index abf5657..d7d7360 100644 (file)
@@ -1,6 +1,5 @@
 /* Lower TLS operations to emulation functions.
-   Copyright (C) 2006, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   Copyright (C) 2006-2013 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -59,11 +58,11 @@ along with GCC; see the file COPYING3.  If not see
    the index of a TLS variable equals the index of its control variable in
    the other vector.  */
 static varpool_node_set tls_vars;
-static VEC(varpool_node_ptr, heap) *control_vars;
+static vec<varpool_node_ptr> control_vars;
 
 /* For the current basic block, an SSA_NAME that has computed the address 
    of the TLS variable at the corresponding index.  */
-static VEC(tree, heap) *access_vars;
+static vec<tree> access_vars;
 
 /* The type of the control structure, shared with the emutls.c runtime.  */
 static tree emutls_object_type;
@@ -148,30 +147,31 @@ default_emutls_var_fields (tree type, tree *name ATTRIBUTE_UNUSED)
 tree
 default_emutls_var_init (tree to, tree decl, tree proxy)
 {
-  VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 4);
-  constructor_elt *elt;
+  vec<constructor_elt, va_gc> *v;
+  vec_alloc (v, 4);
+  constructor_elt elt;
   tree type = TREE_TYPE (to);
   tree field = TYPE_FIELDS (type);
 
-  elt = VEC_quick_push (constructor_elt, v, NULL);
-  elt->index = field;
-  elt->value = fold_convert (TREE_TYPE (field), DECL_SIZE_UNIT (decl));
+  elt.index = field;
+  elt.value = fold_convert (TREE_TYPE (field), DECL_SIZE_UNIT (decl));
+  v->quick_push (elt);
 
-  elt = VEC_quick_push (constructor_elt, v, NULL);
   field = DECL_CHAIN (field);
-  elt->index = field;
-  elt->value = build_int_cst (TREE_TYPE (field),
-                             DECL_ALIGN_UNIT (decl));
+  elt.index = field;
+  elt.value = build_int_cst (TREE_TYPE (field),
+                            DECL_ALIGN_UNIT (decl));
+  v->quick_push (elt);
 
-  elt = VEC_quick_push (constructor_elt, v, NULL);
   field = DECL_CHAIN (field);
-  elt->index = field;
-  elt->value = null_pointer_node;
+  elt.index = field;
+  elt.value = null_pointer_node;
+  v->quick_push (elt);
 
-  elt = VEC_quick_push (constructor_elt, v, NULL);
   field = DECL_CHAIN (field);
-  elt->index = field;
-  elt->value = proxy;
+  elt.index = field;
+  elt.value = proxy;
+  v->quick_push (elt);
 
   return build_constructor (type, v);
 }
@@ -260,7 +260,7 @@ get_emutls_init_templ_addr (tree decl)
   /* Create varpool node for the new variable and finalize it if it is
      not external one.  */
   if (DECL_EXTERNAL (to))
-    varpool_node (to);
+    varpool_node_for_decl (to);
   else
     varpool_add_new_variable (to);
   return build_fold_addr_expr (to);
@@ -295,7 +295,6 @@ new_emutls_decl (tree decl, tree alias_of)
   DECL_WEAK (to) = DECL_WEAK (decl);
   DECL_VISIBILITY (to) = DECL_VISIBILITY (decl);
   DECL_VISIBILITY_SPECIFIED (to) = DECL_VISIBILITY_SPECIFIED (decl);
-  DECL_RESTRICTED_P (to) = DECL_RESTRICTED_P (decl);
   DECL_DLLIMPORT_P (to) = DECL_DLLIMPORT_P (decl);
 
   DECL_ATTRIBUTES (to) = targetm.merge_decl_attributes (decl, to);
@@ -312,8 +311,8 @@ new_emutls_decl (tree decl, tree alias_of)
   if (!DECL_COMMON (to) && targetm.emutls.var_section)
     {
       DECL_SECTION_NAME (to)
-        = build_string (strlen (targetm.emutls.tmpl_section),
-                       targetm.emutls.tmpl_section);
+        = build_string (strlen (targetm.emutls.var_section),
+                       targetm.emutls.var_section);
     }
 
   /* If this variable is defined locally, then we need to initialize the
@@ -332,13 +331,13 @@ new_emutls_decl (tree decl, tree alias_of)
   /* Create varpool node for the new variable and finalize it if it is
      not external one.  */
   if (DECL_EXTERNAL (to))
-    varpool_node (to);
+    varpool_node_for_decl (to);
   else if (!alias_of)
     varpool_add_new_variable (to);
   else 
     varpool_create_variable_alias (to,
                                   varpool_node_for_asm
-                                   (DECL_ASSEMBLER_NAME (alias_of))->decl);
+                                   (DECL_ASSEMBLER_NAME (DECL_VALUE_EXPR (alias_of)))->symbol.decl);
   return to;
 }
 
@@ -365,8 +364,8 @@ emutls_decl (tree decl)
   unsigned int i;
 
   i = emutls_index (decl);
-  var = VEC_index (varpool_node_ptr, control_vars, i);
-  return var->decl;
+  var = control_vars[i];
+  return var->symbol.decl;
 }
 
 /* Generate a call statement to initialize CONTROL_DECL for TLS_DECL.
@@ -420,21 +419,20 @@ gen_emutls_addr (tree decl, struct lower_emutls_data *d)
 
   /* Compute the address of the TLS variable with help from runtime.  */
   index = emutls_index (decl);
-  addr = VEC_index (tree, access_vars, index);
+  addr = access_vars[index];
   if (addr == NULL)
     {
       struct varpool_node *cvar;
       tree cdecl;
       gimple x;
 
-      cvar = VEC_index (varpool_node_ptr, control_vars, index);
-      cdecl = cvar->decl;
+      cvar = control_vars[index];
+      cdecl = cvar->symbol.decl;
       TREE_ADDRESSABLE (cdecl) = 1;
 
       addr = create_tmp_var (build_pointer_type (TREE_TYPE (decl)), NULL);
       x = gimple_build_call (d->builtin_decl, 1, build_fold_addr_expr (cdecl));
       gimple_set_location (x, d->loc);
-      add_referenced_var (cdecl);
 
       addr = make_ssa_name (addr, x);
       gimple_call_set_lhs (x, addr);
@@ -446,10 +444,10 @@ gen_emutls_addr (tree decl, struct lower_emutls_data *d)
 
       /* We may be adding a new reference to a new variable to the function.
          This means we have to play with the ipa-reference web.  */
-      ipa_record_reference (d->cfun_node, NULL, NULL, cvar, IPA_REF_ADDR, x);
+      ipa_record_reference ((symtab_node)d->cfun_node, (symtab_node)cvar, IPA_REF_ADDR, x);
 
       /* Record this ssa_name for possible use later in the basic block.  */
-      VEC_replace (tree, access_vars, index, addr);
+      access_vars[index] = addr;
     }
 
   return addr;
@@ -607,8 +605,8 @@ lower_emutls_phi_arg (gimple phi, unsigned int i, struct lower_emutls_data *d)
 static inline void
 clear_access_vars (void)
 {
-  memset (VEC_address (tree, access_vars), 0,
-          VEC_length (tree, access_vars) * sizeof(tree));
+  memset (access_vars.address (), 0,
+          access_vars.length () * sizeof(tree));
 }
 
 /* Lower the entire function NODE.  */
@@ -619,8 +617,7 @@ lower_emutls_function_body (struct cgraph_node *node)
   struct lower_emutls_data d;
   bool any_edge_inserts = false;
 
-  current_function_decl = node->decl;
-  push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+  push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
 
   d.cfun_node = node;
   d.builtin_decl = builtin_decl_explicit (BUILT_IN_EMUTLS_GET_ADDRESS);
@@ -690,7 +687,6 @@ lower_emutls_function_body (struct cgraph_node *node)
     gsi_commit_edge_inserts ();
 
   pop_cfun ();
-  current_function_decl = NULL;
 }
 
 /* Create emutls variable for VAR, DATA is pointer to static
@@ -703,17 +699,17 @@ create_emultls_var (struct varpool_node *var, void *data)
   tree cdecl;
   struct varpool_node *cvar;
 
-  cdecl = new_emutls_decl (var->decl, var->alias_of);
+  cdecl = new_emutls_decl (var->symbol.decl, var->alias_of);
 
   cvar = varpool_get_node (cdecl);
-  VEC_quick_push (varpool_node_ptr, control_vars, cvar);
+  control_vars.quick_push (cvar);
 
   if (!var->alias)
     {
       /* Make sure the COMMON block control variable gets initialized.
         Note that there's no point in doing this for aliases; we only
         need to do this once for the main variable.  */
-      emutls_common_1 (var->decl, cdecl, (tree *)data);
+      emutls_common_1 (var->symbol.decl, cdecl, (tree *)data);
     }
   if (var->alias && !var->alias_of)
     cvar->alias = true;
@@ -722,8 +718,8 @@ create_emultls_var (struct varpool_node *var, void *data)
      preventing the variable from re-appearing in the GIMPLE.  We cheat
      and use the control variable here (rather than a full call_expr),
      which is special-cased inside the DWARF2 output routines.  */
-  SET_DECL_VALUE_EXPR (var->decl, cdecl);
-  DECL_HAS_VALUE_EXPR_P (var->decl) = 1;
+  SET_DECL_VALUE_EXPR (var->symbol.decl, cdecl);
+  DECL_HAS_VALUE_EXPR_P (var->symbol.decl) = 1;
   return false;
 }
 
@@ -741,18 +737,18 @@ ipa_lower_emutls (void)
   tls_vars = varpool_node_set_new ();
 
   /* Examine all global variables for TLS variables.  */
-  for (var = varpool_nodes; var ; var = var->next)
-    if (DECL_THREAD_LOCAL_P (var->decl))
+  FOR_EACH_VARIABLE (var)
+    if (DECL_THREAD_LOCAL_P (var->symbol.decl))
       {
-       gcc_checking_assert (TREE_STATIC (var->decl)
-                            || DECL_EXTERNAL (var->decl));
+       gcc_checking_assert (TREE_STATIC (var->symbol.decl)
+                            || DECL_EXTERNAL (var->symbol.decl));
        varpool_node_set_add (tls_vars, var);
        if (var->alias && var->analyzed)
          varpool_node_set_add (tls_vars, varpool_variable_node (var, NULL));
       }
 
   /* If we found no TLS variables, then there is no further work to do.  */
-  if (tls_vars->nodes == NULL)
+  if (!tls_vars->nodes.exists ())
     {
       tls_vars = NULL;
       if (dump_file)
@@ -761,15 +757,15 @@ ipa_lower_emutls (void)
     }
 
   /* Allocate the on-the-side arrays that share indicies with the TLS vars.  */
-  n_tls = VEC_length (varpool_node_ptr, tls_vars->nodes);
-  control_vars = VEC_alloc (varpool_node_ptr, heap, n_tls);
-  access_vars = VEC_alloc (tree, heap, n_tls);
-  VEC_safe_grow (tree, heap, access_vars, n_tls);
+  n_tls = tls_vars->nodes.length ();
+  control_vars.create (n_tls);
+  access_vars.create (n_tls);
+  access_vars.safe_grow_cleared (n_tls);
 
   /* Create the control variables for each TLS variable.  */
-  FOR_EACH_VEC_ELT (varpool_node_ptr, tls_vars->nodes, i, var)
+  FOR_EACH_VEC_ELT (tls_vars->nodes, i, var)
     {
-      var = VEC_index (varpool_node_ptr, tls_vars->nodes, i);
+      var = tls_vars->nodes[i];
 
       if (var->alias && !var->alias_of)
        any_aliases = true;
@@ -781,7 +777,7 @@ ipa_lower_emutls (void)
   if (any_aliases)
     {
       alias_pair *p;
-      FOR_EACH_VEC_ELT (alias_pair, alias_pairs, i, p)
+      FOR_EACH_VEC_SAFE_ELT (alias_pairs, i, p)
        if (DECL_THREAD_LOCAL_P (p->decl))
          {
            p->decl = emutls_decl (p->decl);
@@ -790,16 +786,16 @@ ipa_lower_emutls (void)
     }
 
   /* Adjust all uses of TLS variables within the function bodies.  */
-  for (func = cgraph_nodes; func; func = func->next)
-    if (func->reachable && func->lowered)
+  FOR_EACH_DEFINED_FUNCTION (func)
+    if (func->lowered)
       lower_emutls_function_body (func);
 
   /* Generate the constructor for any COMMON control variables created.  */
   if (ctor_body)
     cgraph_build_static_cdtor ('I', ctor_body, DEFAULT_INIT_PRIORITY);
 
-  VEC_free (varpool_node_ptr, heap, control_vars);
-  VEC_free (tree, heap, access_vars);
+  control_vars.release ();
+  access_vars.release ();
   free_varpool_node_set (tls_vars);
 
   return TODO_ggc_collect | TODO_verify_all;
@@ -818,6 +814,7 @@ struct simple_ipa_opt_pass pass_ipa_lower_emutls =
  {
   SIMPLE_IPA_PASS,
   "emutls",                            /* name */
+  OPTGROUP_NONE,                        /* optinfo_flags */
   gate_emutls,                         /* gate */
   ipa_lower_emutls,                    /* execute */
   NULL,                                 /* sub */