OSDN Git Service

PR debug/42278
[pf3gnuchains/gcc-fork.git] / gcc / tree-nested.c
index 706571c..cd1d770 100644 (file)
@@ -1,5 +1,5 @@
 /* Nested function decomposition for GIMPLE.
-   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of GCC.
@@ -23,7 +23,6 @@
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
-#include "rtl.h"
 #include "tm_p.h"
 #include "function.h"
 #include "tree-dump.h"
@@ -35,7 +34,6 @@
 #include "expr.h"
 #include "langhooks.h"
 #include "pointer-set.h"
-#include "ggc.h"
 
 
 /* The object of this pass is to lower the representation of a set of nested
    nonlocal references.  We want to do this sooner rather than later, in
    order to give us more freedom in emitting all of the functions in question.
 
-   Back in olden times, when gcc was young, we developed an insanely 
+   Back in olden times, when gcc was young, we developed an insanely
    complicated scheme whereby variables which were referenced nonlocally
    were forced to live in the stack of the declaring function, and then
    the nested functions magically discovered where these variables were
    placed.  In order for this scheme to function properly, it required
-   that the outer function be partially expanded, then we switch to 
+   that the outer function be partially expanded, then we switch to
    compiling the inner function, and once done with those we switch back
    to compiling the outer function.  Such delicate ordering requirements
-   makes it difficult to do whole translation unit optimizations 
+   makes it difficult to do whole translation unit optimizations
    involving such functions.
 
    The implementation here is much more direct.  Everything that can be
    referenced by an inner function is a member of an explicitly created
    structure herein called the "nonlocal frame struct".  The incoming
-   static chain for a nested function is a pointer to this struct in 
+   static chain for a nested function is a pointer to this struct in
    the parent.  In this way, we settle on known offsets from a known
    base, and so are decoupled from the logic that places objects in the
    function's stack frame.  More importantly, we don't have to wait for
@@ -66,8 +64,8 @@
    allocated anywhere.  Which means that the outer function is now
    inlinable.
 
-   Theory of operation here is very simple.  Iterate over all the 
-   statements in all the functions (depth first) several times, 
+   Theory of operation here is very simple.  Iterate over all the
+   statements in all the functions (depth first) several times,
    allocating structures and fields on demand.  In general we want to
    examine inner functions first, so that we can avoid making changes
    to outer functions which are unnecessary.
@@ -83,7 +81,7 @@ struct nesting_info
   struct nesting_info *outer;
   struct nesting_info *inner;
   struct nesting_info *next;
-  
+
   struct pointer_map_t *field_map;
   struct pointer_map_t *var_map;
   bitmap suppress_expansion;
@@ -335,7 +333,7 @@ get_chain_decl (struct nesting_info *info)
         the construction of this variable is handled specially in
         expand_function_start and initialize_inlined_parameters.
         Note also that it's represented as a parameter.  This is more
-        close to the truth, since the initial value does come from 
+        close to the truth, since the initial value does come from
         the caller.  */
       decl = build_decl (DECL_SOURCE_LOCATION (info->context),
                         PARM_DECL, create_tmp_var_name ("CHAIN"), type);
@@ -413,7 +411,7 @@ init_tmp_var_with_call (struct nesting_info *info, gimple_stmt_iterator *gsi,
   return t;
 }
 
-  
+
 /* Copy EXP into a temporary.  Allocate the temporary in the context of
    INFO and insert the initialization statement before GSI.  */
 
@@ -533,7 +531,7 @@ lookup_tramp_for_decl (struct nesting_info *info, tree decl,
     }
 
   return (tree) *slot;
-} 
+}
 
 /* Build or return the field within the non-local frame state that holds
    the non-local goto "jmp_buf".  The buffer itself is maintained by the
@@ -657,7 +655,7 @@ walk_gimple_omp_for (gimple for_stmt,
 }
 
 /* Similarly for ROOT and all functions nested underneath, depth first.  */
-    
+
 static void
 walk_all_functions (walk_stmt_fn callback_stmt, walk_tree_fn callback_op,
                    struct nesting_info *root)
@@ -811,7 +809,7 @@ static void note_nonlocal_vla_type (struct nesting_info *info, tree type);
 
 /* A subroutine of convert_nonlocal_reference_op.  Create a local variable
    in the nested function with DECL_VALUE_EXPR set to reference the true
-   variable in the parent function.  This is used both for debug info 
+   variable in the parent function.  This is used both for debug info
    and in OpenMP lowering.  */
 
 static tree
@@ -1088,7 +1086,8 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
            {
              bitmap_set_bit (new_suppress, DECL_UID (decl));
              OMP_CLAUSE_DECL (clause) = get_nonlocal_debug_decl (info, decl);
-             need_chain = true;
+             if (OMP_CLAUSE_CODE (clause) != OMP_CLAUSE_PRIVATE)
+               need_chain = true;
            }
          break;
 
@@ -1307,6 +1306,12 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       *handled_ops_p = false;
       return NULL_TREE;
 
+    case GIMPLE_COND:
+      wi->val_only = true;
+      wi->is_lhs = false;
+      *handled_ops_p = false;
+      return NULL_TREE;
+
     default:
       /* For every other statement that we are not interested in
         handling here, let the walker traverse the operands.  */
@@ -1439,7 +1444,7 @@ convert_local_reference_op (tree *tp, int *walk_subtrees, void *data)
 
          /* Then the frame decl is now addressable.  */
          TREE_ADDRESSABLE (info->frame_decl) = 1;
-           
+
          save_context = current_function_decl;
          current_function_decl = info->context;
          recompute_tree_invariant_for_addr_expr (t);
@@ -1707,6 +1712,12 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
                 info, gimple_omp_body (stmt));
       break;
 
+    case GIMPLE_COND:
+      wi->val_only = true;
+      wi->is_lhs = false;
+      *handled_ops_p = false;
+      return NULL_TREE;
+
     default:
       /* For every other statement that we are not interested in
         handling here, let the walker traverse the operands.  */
@@ -1773,7 +1784,7 @@ convert_nl_goto_reference (gimple_stmt_iterator *gsi, bool *handled_ops_p,
     }
   else
     new_label = (tree) *slot;
-  
+
   /* Build: __builtin_nl_goto(new_label, &chain->nl_goto_field).  */
   field = get_nl_goto_field (i);
   x = get_frame_field (info, target_context, field, &wi->gsi);
@@ -2066,7 +2077,7 @@ convert_all_function_calls (struct nesting_info *root)
      transformations can induce new uses of the static chain, which in turn
      require re-examining all users of the decl.  */
   /* ??? It would make sense to try to use the call graph to speed this up,
-     but the call graph hasn't really been built yet.  Even if it did, we 
+     but the call graph hasn't really been built yet.  Even if it did, we
      would still need to iterate in this loop since address-of references
      wouldn't show up in the callgraph anyway.  */
   iter_count = 0;
@@ -2280,7 +2291,7 @@ finalize_nesting_tree_1 (struct nesting_info *root)
                    gimple_seq_first_stmt (gimple_body (context)), true);
     }
 
-  /* If any parameters were referenced non-locally, then we need to 
+  /* If any parameters were referenced non-locally, then we need to
      insert a copy.  Likewise, if any variables were referenced by
      pointer, we need to initialize the address.  */
   if (root->any_parm_remapped)