i386.c (legitimize_tls_address): Generate tls_initial_exec_64_sun only when !TARGET_X32.
[gcc.git] / gcc / tree-ssa.c
index 258a7444b08f3ad45b6c5ba55de06666c1ab238c..2655d26e5e232862f26229976d595405986895a9 100644 (file)
@@ -264,7 +264,12 @@ target_for_debug_bind (tree var)
     return NULL_TREE;
 
   if (!is_gimple_reg (var))
-    return NULL_TREE;
+    {
+      if (is_gimple_reg_type (TREE_TYPE (var))
+         && referenced_var_lookup (cfun, DECL_UID (var)) == NULL_TREE)
+       return var;
+      return NULL_TREE;
+    }
 
   return var;
 }
@@ -920,8 +925,6 @@ verify_ssa (bool check_modified_stmt)
 
   gcc_assert (!need_ssa_update_p (cfun));
 
-  verify_gimple_in_cfg (cfun);
-
   timevar_push (TV_TREE_SSA_VERIFY);
 
   /* Keep track of SSA names present in the IL.  */
@@ -933,6 +936,8 @@ verify_ssa (bool check_modified_stmt)
          gimple stmt;
          TREE_VISITED (name) = 0;
 
+         verify_ssa_name (name, !is_gimple_reg (name));
+
          stmt = SSA_NAME_DEF_STMT (name);
          if (!gimple_nop_p (stmt))
            {
@@ -982,9 +987,6 @@ verify_ssa (bool check_modified_stmt)
        {
          gimple stmt = gsi_stmt (gsi);
          use_operand_p use_p;
-         bool has_err;
-         int count;
-         unsigned i;
 
          if (check_modified_stmt && gimple_modified_p (stmt))
            {
@@ -994,89 +996,15 @@ verify_ssa (bool check_modified_stmt)
              goto err;
            }
 
-         if (is_gimple_assign (stmt)
-             && TREE_CODE (gimple_assign_lhs (stmt)) != SSA_NAME)
-           {
-             tree lhs, base_address;
-
-             lhs = gimple_assign_lhs (stmt);
-             base_address = get_base_address (lhs);
-
-             if (base_address
-                 && SSA_VAR_P (base_address)
-                 && !gimple_vdef (stmt)
-                 && optimize > 0)
-               {
-                 error ("statement makes a memory store, but has no VDEFS");
-                 print_gimple_stmt (stderr, stmt, 0, TDF_VOPS);
-                 goto err;
-               }
-           }
-         else if (gimple_debug_bind_p (stmt)
-                  && !gimple_debug_bind_has_value_p (stmt))
-           continue;
-
-         /* Verify the single virtual operand and its constraints.  */
-         has_err = false;
-         if (gimple_vdef (stmt))
-           {
-             if (gimple_vdef_op (stmt) == NULL_DEF_OPERAND_P)
-               {
-                 error ("statement has VDEF operand not in defs list");
-                 has_err = true;
-               }
-             if (!gimple_vuse (stmt))
-               {
-                 error ("statement has VDEF but no VUSE operand");
-                 has_err = true;
-               }
-             else if (SSA_NAME_VAR (gimple_vdef (stmt))
-                      != SSA_NAME_VAR (gimple_vuse (stmt)))
-               {
-                 error ("VDEF and VUSE do not use the same symbol");
-                 has_err = true;
-               }
-             has_err |= verify_ssa_name (gimple_vdef (stmt), true);
-           }
-         if (gimple_vuse (stmt))
-           {
-             if  (gimple_vuse_op (stmt) == NULL_USE_OPERAND_P)
-               {
-                 error ("statement has VUSE operand not in uses list");
-                 has_err = true;
-               }
-             has_err |= verify_ssa_name (gimple_vuse (stmt), true);
-           }
-         if (has_err)
+         if (verify_ssa_operands (stmt))
            {
-             error ("in statement");
-             print_gimple_stmt (stderr, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
+             print_gimple_stmt (stderr, stmt, 0, TDF_VOPS);
              goto err;
            }
 
-         count = 0;
-         FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE|SSA_OP_DEF)
-           {
-             if (verify_ssa_name (op, false))
-               {
-                 error ("in statement");
-                 print_gimple_stmt (stderr, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
-                 goto err;
-               }
-             count++;
-           }
-
-         for (i = 0; i < gimple_num_ops (stmt); i++)
-           {
-             op = gimple_op (stmt, i);
-             if (op && TREE_CODE (op) == SSA_NAME && --count < 0)
-               {
-                 error ("number of operands and imm-links don%'t agree"
-                        " in statement");
-                 print_gimple_stmt (stderr, stmt, 0, TDF_VOPS|TDF_MEMSYMS);
-                 goto err;
-               }
-           }
+         if (gimple_debug_bind_p (stmt)
+             && !gimple_debug_bind_has_value_p (stmt))
+           continue;
 
          FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE|SSA_OP_VUSE)
            {
@@ -1189,9 +1117,37 @@ init_tree_ssa (struct function *fn)
                                                 uid_ssaname_map_eq, NULL);
   pt_solution_reset (&fn->gimple_df->escaped);
   init_ssanames (fn, 0);
-  init_phinodes ();
 }
 
+/* Do the actions required to initialize internal data structures used
+   in tree-ssa optimization passes.  */
+
+static unsigned int
+execute_init_datastructures (void)
+{
+  /* Allocate hash tables, arrays and other structures.  */
+  init_tree_ssa (cfun);
+  return 0;
+}
+
+struct gimple_opt_pass pass_init_datastructures =
+{
+ {
+  GIMPLE_PASS,
+  "*init_datastructures",              /* name */
+  NULL,                                        /* gate */
+  execute_init_datastructures,         /* execute */
+  NULL,                                        /* sub */
+  NULL,                                        /* next */
+  0,                                   /* static_pass_number */
+  TV_NONE,                             /* tv_id */
+  PROP_cfg,                            /* properties_required */
+  0,                                   /* properties_provided */
+  0,                                   /* properties_destroyed */
+  0,                                   /* todo_flags_start */
+  0                                    /* todo_flags_finish */
+ }
+};
 
 /* Deallocate memory associated with SSA data structures for FNDECL.  */
 
@@ -1216,7 +1172,6 @@ delete_tree_ssa (void)
   cfun->gimple_df->referenced_vars = NULL;
 
   fini_ssanames ();
-  fini_phinodes ();
 
   /* We no longer maintain the SSA operand cache at this point.  */
   if (ssa_operands_active ())
@@ -1269,10 +1224,6 @@ useless_type_conversion_p (tree outer_type, tree inner_type)
       if (TYPE_ADDR_SPACE (TREE_TYPE (outer_type))
          != TYPE_ADDR_SPACE (TREE_TYPE (inner_type)))
        return false;
-
-      /* If the outer type is (void *), the conversion is not necessary.  */
-      if (VOID_TYPE_P (TREE_TYPE (outer_type)))
-       return true;
     }
 
   /* From now on qualifiers on value types do not matter.  */
@@ -1660,7 +1611,7 @@ warn_uninit (enum opt_code wc, tree t,
             tree expr, tree var, const char *gmsgid, void *data)
 {
   gimple context = (gimple) data;
-  location_t location;
+  location_t location, cfun_loc;
   expanded_location xloc, floc;
 
   if (!ssa_undefined_value_p (t))
@@ -1678,8 +1629,12 @@ warn_uninit (enum opt_code wc, tree t,
   location = (context != NULL && gimple_has_location (context))
             ? gimple_location (context)
             : DECL_SOURCE_LOCATION (var);
+  location = linemap_resolve_location (line_table, location,
+                                      LRK_SPELLING_LOCATION,
+                                      NULL);
+  cfun_loc = DECL_SOURCE_LOCATION (cfun->decl);
   xloc = expand_location (location);
-  floc = expand_location (DECL_SOURCE_LOCATION (cfun->decl));
+  floc = expand_location (cfun_loc);
   if (warning_at (location, wc, gmsgid, expr))
     {
       TREE_NO_WARNING (expr) = 1;
@@ -1687,8 +1642,11 @@ warn_uninit (enum opt_code wc, tree t,
       if (location == DECL_SOURCE_LOCATION (var))
        return;
       if (xloc.file != floc.file
-         || xloc.line < floc.line
-         || xloc.line > LOCATION_LINE (cfun->function_end_locus))
+         || linemap_location_before_p (line_table,
+                                       location, cfun_loc)
+         || linemap_location_before_p (line_table,
+                                       cfun->function_end_locus,
+                                       location))
        inform (DECL_SOURCE_LOCATION (var), "%qD was declared here", var);
     }
 }
@@ -1963,6 +1921,8 @@ maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs)
         a non-register.  Otherwise we are confused and forget to
         add virtual operands for it.  */
       && (!is_gimple_reg_type (TREE_TYPE (var))
+         || TREE_CODE (TREE_TYPE (var)) == VECTOR_TYPE
+         || TREE_CODE (TREE_TYPE (var)) == COMPLEX_TYPE
          || !bitmap_bit_p (not_reg_needs, DECL_UID (var))))
     {
       TREE_ADDRESSABLE (var) = 0;
@@ -2116,7 +2076,7 @@ execute_update_addresses_taken (void)
   if (update_vops)
     {
       FOR_EACH_BB (bb)
-       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
          {
            gimple stmt = gsi_stmt (gsi);
 
@@ -2157,6 +2117,18 @@ execute_update_addresses_taken (void)
                if (gimple_assign_lhs (stmt) != lhs)
                  gimple_assign_set_lhs (stmt, lhs);
 
+               /* For var ={v} {CLOBBER}; where var lost
+                  TREE_ADDRESSABLE just remove the stmt.  */
+               if (DECL_P (lhs)
+                   && TREE_CLOBBER_P (rhs)
+                   && symbol_marked_for_renaming (lhs))
+                 {
+                   unlink_stmt_vdef (stmt);
+                   gsi_remove (&gsi, true);
+                   release_defs (stmt);
+                   continue;
+                 }
+
                if (gimple_assign_rhs1 (stmt) != rhs)
                  {
                    gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
@@ -2203,6 +2175,8 @@ execute_update_addresses_taken (void)
            if (gimple_references_memory_p (stmt)
                || is_gimple_debug (stmt))
              update_stmt (stmt);
+
+           gsi_next (&gsi);
          }
 
       /* Update SSA form here, we are called as non-pass as well.  */