OSDN Git Service

* ira-costs.c (record_reg_classes): Ignore alternatives that are
[pf3gnuchains/gcc-fork.git] / gcc / tree-inline.c
index 3c90941..e0928b9 100644 (file)
@@ -1,5 +1,5 @@
 /* Tree inlining.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Alexandre Oliva <aoliva@redhat.com>
 
@@ -171,6 +171,12 @@ insert_debug_decl_map (copy_body_data *id, tree key, tree value)
   *pointer_map_insert (id->debug_map, key) = value;
 }
 
+/* If nonzero, we're remapping the contents of inlined debug
+   statements.  If negative, an error has occurred, such as a
+   reference to a variable that isn't available in the inlined
+   context.  */
+static int processing_debug_stmt = 0;
+
 /* Construct new SSA name for old NAME. ID is the inline context.  */
 
 static tree
@@ -185,6 +191,12 @@ remap_ssa_name (tree name, copy_body_data *id)
   if (n)
     return unshare_expr (*n);
 
+  if (processing_debug_stmt)
+    {
+      processing_debug_stmt = -1;
+      return name;
+    }
+
   /* Do not set DEF_STMT yet as statement is not copied yet. We do that
      in copy_bb.  */
   new_tree = remap_decl (SSA_NAME_VAR (name), id);
@@ -244,12 +256,6 @@ remap_ssa_name (tree name, copy_body_data *id)
   return new_tree;
 }
 
-/* If nonzero, we're remapping the contents of inlined debug
-   statements.  If negative, an error has occurred, such as a
-   reference to a variable that isn't available in the inlined
-   context.  */
-int processing_debug_stmt = 0;
-
 /* Remap DECL during the copying of the BLOCK tree for the function.  */
 
 tree
@@ -305,17 +311,7 @@ remap_decl (tree decl, copy_body_data *id)
          && (TREE_CODE (t) == VAR_DECL
              || TREE_CODE (t) == RESULT_DECL || TREE_CODE (t) == PARM_DECL))
        {
-          tree def = gimple_default_def (id->src_cfun, decl);
          get_var_ann (t);
-         if (TREE_CODE (decl) != PARM_DECL && def)
-           {
-             tree map = remap_ssa_name (def, id);
-             /* Watch out RESULT_DECLs whose SSA names map directly
-                to them.  */
-             if (TREE_CODE (map) == SSA_NAME
-                 && gimple_nop_p (SSA_NAME_DEF_STMT (map)))
-               set_default_def (t, map);
-           }
          add_referenced_var (t);
        }
       return t;
@@ -537,7 +533,6 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id)
   for (old_var = decls; old_var; old_var = TREE_CHAIN (old_var))
     {
       tree new_var;
-      tree origin_var = DECL_ORIGIN (old_var);
 
       if (can_be_nonlocal (old_var, id))
        {
@@ -549,7 +544,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id)
          if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE)
              && !DECL_IGNORED_P (old_var)
              && nonlocalized_list)
-           VEC_safe_push (tree, gc, *nonlocalized_list, origin_var);
+           VEC_safe_push (tree, gc, *nonlocalized_list, old_var);
          continue;
        }
 
@@ -567,7 +562,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id)
          if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE)
              && !DECL_IGNORED_P (old_var)
              && nonlocalized_list)
-           VEC_safe_push (tree, gc, *nonlocalized_list, origin_var);
+           VEC_safe_push (tree, gc, *nonlocalized_list, old_var);
        }
       else
        {
@@ -1655,6 +1650,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
                                   bb->frequency,
                                   copy_basic_block->frequency);
                        }
+                     stmt = cgraph_redirect_edge_call_stmt_to_callee (edge);
                    }
                  break;
 
@@ -1694,13 +1690,15 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
                              || !id->src_node->analyzed);
                  if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES)
                    cgraph_create_edge_including_clones
-                     (id->dst_node, dest, stmt, bb->count,
+                     (id->dst_node, dest, orig_stmt, stmt, bb->count,
                       compute_call_stmt_bb_frequency (id->dst_node->decl,
                                                       copy_basic_block),
                       bb->loop_depth, CIF_ORIGINALLY_INDIRECT_CALL);
                  else
                    cgraph_create_edge (id->dst_node, dest, stmt,
-                                       bb->count, CGRAPH_FREQ_BASE,
+                                       bb->count,
+                                       compute_call_stmt_bb_frequency
+                                         (id->dst_node->decl, copy_basic_block),
                                        bb->loop_depth)->inline_failed
                      = CIF_ORIGINALLY_INDIRECT_CALL;
                  if (dump_file)
@@ -2152,6 +2150,12 @@ copy_debug_stmt (gimple stmt, copy_body_data *id)
       gcc_assert (TREE_CODE (*n) == VAR_DECL);
       t = *n;
     }
+  else if (TREE_CODE (t) == VAR_DECL
+          && !TREE_STATIC (t)
+          && gimple_in_ssa_p (cfun)
+          && !pointer_map_contains (id->decl_map, t)
+          && !var_ann (t))
+    /* T is a non-localized variable.  */;
   else
     walk_tree (&t, remap_gimple_op_r, &wi, NULL);
 
@@ -2538,9 +2542,16 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest)
   tree caller = id->dst_fn;
   tree result = DECL_RESULT (callee);
   tree callee_type = TREE_TYPE (result);
-  tree caller_type = TREE_TYPE (TREE_TYPE (callee));
+  tree caller_type;
   tree var, use;
 
+  /* Handle type-mismatches in the function declaration return type
+     vs. the call expression.  */
+  if (modify_dest)
+    caller_type = TREE_TYPE (modify_dest);
+  else
+    caller_type = TREE_TYPE (TREE_TYPE (callee));
+
   /* We don't need to do anything for functions that don't return
      anything.  */
   if (!result || VOID_TYPE_P (callee_type))
@@ -2716,39 +2727,6 @@ has_label_address_in_static_1 (tree *nodep, int *walk_subtrees, void *fnp)
   return NULL_TREE;
 }
 
-/* Callback through walk_tree.  Determine if we've got an aggregate
-   type that we can't support; return non-null if so.  */
-
-static tree
-cannot_copy_type_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED,
-                    void *data ATTRIBUTE_UNUSED)
-{
-  tree t, node = *nodep;
-
-  if (TREE_CODE (node) == RECORD_TYPE || TREE_CODE (node) == UNION_TYPE)
-    {
-      /* We cannot inline a function of the form
-
-          void F (int i) { struct S { int ar[i]; } s; }
-
-        Attempting to do so produces a catch-22.
-        If walk_tree examines the TYPE_FIELDS chain of RECORD_TYPE/
-        UNION_TYPE nodes, then it goes into infinite recursion on a
-        structure containing a pointer to its own type.  If it doesn't,
-        then the type node for S doesn't get adjusted properly when
-        F is inlined.
-
-        ??? This is likely no longer true, but it's too late in the 4.0
-        cycle to try to find out.  This should be checked for 4.1.  */
-      for (t = TYPE_FIELDS (node); t; t = TREE_CHAIN (t))
-       if (variably_modified_type_p (TREE_TYPE (t), NULL))
-         return node;
-    }
-
-  return NULL_TREE;
-}
-
-
 /* Determine if the function can be copied.  If so return NULL.  If
    not return a string describng the reason for failure.  */
 
@@ -2791,16 +2769,6 @@ copy_forbidden (struct function *fun, tree fndecl)
                      "address of local label in a static variable");
          goto fail;
        }
-
-      if (!TREE_STATIC (decl) && !DECL_EXTERNAL (decl)
-         && variably_modified_type_p (TREE_TYPE (decl), NULL)
-         && walk_tree_without_duplicates (&TREE_TYPE (decl),
-                                          cannot_copy_type_1, NULL))
-       {
-         reason = G_("function %q+F can never be copied "
-                     "because it uses variable sized variables");
-         goto fail;
-       }
     }
 
  fail:
@@ -3296,6 +3264,12 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
              cost = weights->target_builtin_call_cost;
              break;
 
+           /* Exception state returns or moves registers around.  */
+           case BUILT_IN_EH_FILTER:
+           case BUILT_IN_EH_POINTER:
+           case BUILT_IN_EH_COPY_VALUES:
+             return 0;
+
            default:
              break;
            }