tree-nested.c (build_addr): New "context" argument.
authorJeff Law <law@redhat.com>
Tue, 24 May 2005 20:19:13 +0000 (14:19 -0600)
committerJeff Law <law@gcc.gnu.org>
Tue, 24 May 2005 20:19:13 +0000 (14:19 -0600)
        * tree-nested.c (build_addr): New "context" argument.  Temporarily
        set current_function_decl around the call to build the ADDR_EXPR.
        (get_static_chain): Pass proper context to build_addr.
        (convert_nl_goto_reference): Likewise.
        (convert_tramp_reference): Likewise.
        (final_nesting_tree_1): Likewise.
        * tree-profile.c (tree_gen_interval_profiler): Likewise.
        (tree_gen_pow2_profiler): Likewise.
        (tree_gen_one_value_profiler): Likewise.
        * tree-ssa-loop-ivopts.c (build_addr_strip_iref): Likewise.
        * tree.h (build_addr): Update prototype.

From-SVN: r100110

gcc/ChangeLog
gcc/tree-nested.c
gcc/tree-profile.c
gcc/tree-ssa-loop-ivopts.c
gcc/tree.h

index 71ae0c62c6757bdf8942855aace1d566f6dcf30d..665911fc92527aa1bb7865505c1deccdb5a6ac6b 100644 (file)
@@ -1,3 +1,17 @@
+2005-05-24  Jeff Law  <law@redhat.com>
+
+       * tree-nested.c (build_addr): New "context" argument.  Temporarily
+       set current_function_decl around the call to build the ADDR_EXPR.
+       (get_static_chain): Pass proper context to build_addr.
+       (convert_nl_goto_reference): Likewise.
+       (convert_tramp_reference): Likewise.
+       (final_nesting_tree_1): Likewise.
+       * tree-profile.c (tree_gen_interval_profiler): Likewise.
+       (tree_gen_pow2_profiler): Likewise.
+       (tree_gen_one_value_profiler): Likewise.
+       * tree-ssa-loop-ivopts.c (build_addr_strip_iref): Likewise.
+       * tree.h (build_addr): Update prototype.
+
 2005-05-24  Kazu Hirata  <kazu@cs.umass.edu>
 
        * tree-flow.h (bb_ann_d): Remove has_escape_site.
index b1ab217340b24b3507fa5113a91f8ee8c1aa9556..124bbf98cfb2ce78e446e5fc2b1596f31f050680 100644 (file)
@@ -148,12 +148,15 @@ create_tmp_var_for (struct nesting_info *info, tree type, const char *prefix)
   return tmp_var;
 }
 
-/* Take the address of EXP.  Mark it for addressability as necessary.  */
+/* Take the address of EXP to be used within function CONTEXT.
+   Mark it for addressability as necessary.  */
 
 tree
-build_addr (tree exp)
+build_addr (tree exp, tree context)
 {
   tree base = exp;
+  tree save_context;
+  tree retval;
 
   while (handled_component_p (base))
     base = TREE_OPERAND (base, 0);
@@ -161,7 +164,18 @@ build_addr (tree exp)
   if (DECL_P (base))
     TREE_ADDRESSABLE (base) = 1;
 
-  return build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (exp)), exp);
+  /* Building the ADDR_EXPR will compute a set of properties for
+     that ADDR_EXPR.  Those properties are unfortunately context
+     specific.  ie, they are dependent on CURRENT_FUNCTION_DECL.
+
+     Temporarily set CURRENT_FUNCTION_DECL to the desired context,
+     build the ADDR_EXPR, then restore CURRENT_FUNCTION_DECL.  That
+     way the properties are for the ADDR_EXPR are computed properly.  */
+  save_context = current_function_decl;
+  current_function_decl = context;
+  retval = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (exp)), exp);
+  current_function_decl = save_context;;
+  return retval;
 }
 
 /* Insert FIELD into TYPE, sorted by alignment requirements.  */
@@ -716,7 +730,7 @@ get_static_chain (struct nesting_info *info, tree target_context,
 
   if (info->context == target_context)
     {
-      x = build_addr (info->frame_decl);
+      x = build_addr (info->frame_decl, target_context);
     }
   else
     {
@@ -1092,10 +1106,10 @@ convert_nl_goto_reference (tree *tp, int *walk_subtrees, void *data)
   /* 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->tsi);
-  x = build_addr (x);
+  x = build_addr (x, target_context);
   x = tsi_gimplify_val (info, x, &wi->tsi);
   arg = tree_cons (NULL, x, NULL);
-  x = build_addr (new_label);
+  x = build_addr (new_label, target_context);
   arg = tree_cons (NULL, x, arg);
   x = implicit_built_in_decls[BUILT_IN_NONLOCAL_GOTO];
   x = build_function_call_expr (x, arg);
@@ -1190,7 +1204,7 @@ convert_tramp_reference (tree *tp, int *walk_subtrees, void *data)
 
       /* Compute the address of the field holding the trampoline.  */
       x = get_frame_field (info, target_context, x, &wi->tsi);
-      x = build_addr (x);
+      x = build_addr (x, target_context);
       x = tsi_gimplify_val (info, x, &wi->tsi);
       arg = tree_cons (NULL, x, NULL);
 
@@ -1322,7 +1336,7 @@ finalize_nesting_tree_1 (struct nesting_info *root)
            continue;
 
          if (use_pointer_in_frame (p))
-           x = build_addr (p);
+           x = build_addr (p, context);
          else
            x = p;
 
@@ -1358,15 +1372,15 @@ finalize_nesting_tree_1 (struct nesting_info *root)
          if (DECL_NO_STATIC_CHAIN (i->context))
            x = null_pointer_node;
          else
-           x = build_addr (root->frame_decl);
+           x = build_addr (root->frame_decl, context);
          arg = tree_cons (NULL, x, NULL);
 
-         x = build_addr (i->context);
+         x = build_addr (i->context, context);
          arg = tree_cons (NULL, x, arg);
 
          x = build (COMPONENT_REF, TREE_TYPE (field),
                     root->frame_decl, field, NULL_TREE);
-         x = build_addr (x);
+         x = build_addr (x, context);
          arg = tree_cons (NULL, x, arg);
 
          x = implicit_built_in_decls[BUILT_IN_INIT_TRAMPOLINE];
index 2c91fc3859fa20d5d1c8e829a60f7b7e867cc80e..d611168635e7d690e74ef5d85ce625d73e1d09f5 100644 (file)
@@ -143,7 +143,7 @@ tree_gen_interval_profiler (histogram_value value, unsigned tag, unsigned base)
   tree steps = build_int_cst_type (unsigned_type_node, value->hdata.intvl.steps);
   
   ref_ptr = force_gimple_operand_bsi (&bsi,
-                                     build_addr (ref),
+                                     build_addr (ref, current_function_decl),
                                      true, NULL_TREE);
   val = prepare_instrumented_value (&bsi, value);
   args = tree_cons (NULL_TREE, ref_ptr,
@@ -168,7 +168,7 @@ tree_gen_pow2_profiler (histogram_value value, unsigned tag, unsigned base)
   tree args, call, val;
   
   ref_ptr = force_gimple_operand_bsi (&bsi,
-                                     build_addr (ref),
+                                     build_addr (ref, current_function_decl),
                                      true, NULL_TREE);
   val = prepare_instrumented_value (&bsi, value);
   args = tree_cons (NULL_TREE, ref_ptr,
@@ -191,7 +191,7 @@ tree_gen_one_value_profiler (histogram_value value, unsigned tag, unsigned base)
   tree args, call, val;
   
   ref_ptr = force_gimple_operand_bsi (&bsi,
-                                     build_addr (ref),
+                                     build_addr (ref, current_function_decl),
                                      true, NULL_TREE);
   val = prepare_instrumented_value (&bsi, value);
   args = tree_cons (NULL_TREE, ref_ptr,
index f60082ab31a3f5cf4136e3fe2febcd9a517a8331..5cb623b871e2186eac6faf874b0b401f989b1dff 100644 (file)
@@ -1527,7 +1527,7 @@ build_addr_strip_iref (tree obj)
       obj = fold_convert (type, TREE_OPERAND (obj, 0));
     }
   else
-    obj = build_addr (obj);
+    obj = build_addr (obj, current_function_decl);
 
   return obj;
 }
index 8dc989435bb2412d1c8b053fd848768d7170d0a4..b7764d81882641a0c9a97ac3fe35cb1356526fa0 100644 (file)
@@ -3651,7 +3651,7 @@ extern tree build_nonstandard_integer_type (unsigned HOST_WIDE_INT, int);
 extern tree build_range_type (tree, tree, tree);
 extern HOST_WIDE_INT int_cst_value (tree);
 extern tree tree_fold_gcd (tree, tree);
-extern tree build_addr (tree);
+extern tree build_addr (tree, tree);
 
 extern bool fields_compatible_p (tree, tree);
 extern tree find_compatible_field (tree, tree);