OSDN Git Service

Fix PR debug/49047
[pf3gnuchains/gcc-fork.git] / gcc / tree-emutls.c
index ec4e0ad..1124047 100644 (file)
@@ -257,7 +257,12 @@ get_emutls_init_templ_addr (tree decl)
                        targetm.emutls.tmpl_section);
     }
 
-  varpool_finalize_decl (to);
+  /* Create varpool node for the new variable and finalize it if it is
+     not external one.  */
+  if (DECL_EXTERNAL (to))
+    varpool_node (to);
+  else
+    varpool_finalize_decl (to);
   return build_fold_addr_expr (to);
 }
 
@@ -324,7 +329,12 @@ new_emutls_decl (tree decl)
       record_references_in_initializer (to, false);
     }
 
-  varpool_finalize_decl (to);
+  /* Create varpool node for the new variable and finalize it if it is
+     not external one.  */
+  if (DECL_EXTERNAL (to))
+    varpool_node (to);
+  else
+    varpool_finalize_decl (to);
   return to;
 }
 
@@ -427,7 +437,7 @@ gen_emutls_addr (tree decl, struct lower_emutls_data *d)
       gimple_seq_add_stmt (&d->seq, x);
 
       cgraph_create_edge (d->cfun_node, d->builtin_node, x,
-                          d->bb->count, d->bb_freq, d->bb->loop_depth);
+                          d->bb->count, d->bb_freq);
 
       /* 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.  */
@@ -609,7 +619,9 @@ lower_emutls_function_body (struct cgraph_node *node)
 
   d.cfun_node = node;
   d.builtin_decl = built_in_decls[BUILT_IN_EMUTLS_GET_ADDRESS];
-  d.builtin_node = cgraph_node (d.builtin_decl);
+  /* This is where we introduce the declaration to the IL and so we have to
+     create a node for it.  */
+  d.builtin_node = cgraph_get_create_node (d.builtin_decl);
 
   FOR_EACH_BB (d.bb)
     {
@@ -769,7 +781,7 @@ ipa_lower_emutls (void)
 
   VEC_free (varpool_node_ptr, heap, control_vars);
   VEC_free (tree, heap, access_vars);
-  tls_vars = NULL;
+  free_varpool_node_set (tls_vars);
 
   return TODO_dump_func | TODO_ggc_collect | TODO_verify_all;
 }
@@ -792,7 +804,7 @@ struct simple_ipa_opt_pass pass_ipa_lower_emutls =
   NULL,                                 /* sub */
   NULL,                                 /* next */
   0,                                    /* static_pass_number */
-  TV_NONE,                             /* tv_id */
+  TV_IPA_OPT,                          /* tv_id */
   PROP_cfg | PROP_ssa,                 /* properties_required */
   0,                                    /* properties_provided */
   0,                                    /* properties_destroyed */