This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][4.5] Do not set TREE_ADDRESSABLE from build_fold_addr_expr


This removes setting TREE_ADDRESSABLE from build_fold_addr_expr and variants.
Apart from being the right thing to do you may wonder for the reason.  On
the alias-improvements branch we use TREE_ADDRESSABLE to tell if a decl
had its address taken and thus may be aliased by a pointer.  We do the same
on trunk, but the difference is that on the branch we do it from anywhere
(through the oracle) but on trunk we do it during alias computation
(which re-computes TREE_ADDRESSABLE before).  On the branch we lose a lot
of precision because things like data-ref and SCEV end up marking random
decls TREE_ADDRESSABLE because they internally store pointers to them ...

Now the good thing is that we adjust TREE_ADDRESSABLE from within the
operand scanner, so whenever an address from data-ref or SCEV leaks into
the IL we adjust the TREE_ADDRESSABLE flag accordingly.  At least once
we use the operand scanner - thus the few fixes elsewhere.  Using
TREE_ADDRESSABLE this way is much easier and less error-prone than trying
to keep the addressable-vars bitmap up-to-date.

The large Fortran frontend parts replace all build_fold_addr_expr calls
with the internal gfc_build_addr_expr routine which properly marks decls
TREE_ADDRESSABLE.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for stage1?
(I need approval for the Fortran FE parts).  I will install this on the
alias-improvements branch later.

Thanks,
Richard.


2009-01-09  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (build_fold_addr_expr_with_type_1): Rename back to ...
	(build_fold_addr_expr_with_type): ... this.  Remove in_fold handling.
	Do not mark decls TREE_ADDRESSABLE.
	(build_fold_addr_expr): Adjust.
	(fold_addr_expr): Remove.
	(fold_unary): Use build_fold_addr_expr.
	(fold_comparison): Likewise.
	(split_address_to_core_and_offset): Likewise.
	* coverage.c (tree_coverage_counter_addr): Mark the array decl
	TREE_ADDRESSABLE.
	* gimplify.c (mark_addressable): Do not exclude RESULT_DECLs.
	(gimplify_modify_expr_to_memcpy): Mark source and destination
	addressable.
	* omp-low.c (create_omp_child_function): Mark the object decl
	TREE_ADDRESSABLE.
	(lower_rec_input_clauses): Mark the var we take the address of
	TREE_ADDRESSABLE.
	(lower_omp_taskreg): Mark the sender decl TREE_ADDRESSABLE.

	fortran/
	* trans-array.c (gfc_conv_descriptor_data_addr): Use
	gfc_build_addr_expr instead of build_fold_addr_expr.
	(gfc_trans_allocate_array_storage, gfc_trans_array_constructor_value,
	gfc_trans_constant_array_constructor, gfc_conv_array_data,
	gfc_conv_expr_descriptor, gfc_conv_array_parameter): Likewise.
	* trans-expr.c (gfc_conv_missing_dummy, gfc_conv_variable,
	gfc_conv_function_val, gfc_conv_operator_assign,
	gfc_conv_subref_array_arg, gfc_conv_function_call,
	gfc_conv_expr_reference, gfc_trans_scalar_assign): Likewise.
	* trans-intrinsic.c (gfc_conv_intrinsic_exponent,
	gfc_conv_intrinsic_ctime, gfc_conv_intrinsic_fdate,
	gfc_conv_intrinsic_ttynam, gfc_conv_intrinsic_minmax_char,
	gfc_conv_intrinsic_fraction, gfc_conv_intrinsic_spacing,
	gfc_conv_intrinsic_rrspacing, gfc_conv_intrinsic_set_exponent,
	gfc_conv_intrinsic_array_transfer, gfc_conv_intrinsic_transfer,
	gfc_conv_intrinsic_si_kind, gfc_conv_intrinsic_trim): Likewise.
	* trans-io.c (gfc_trans_io_runtime_check, set_parameter_ref,
	gfc_convert_array_to_string, gfc_trans_open, gfc_trans_close,
	build_filepos, gfc_trans_inquire, gfc_trans_wait,
	nml_get_addr_expr, transfer_namelist_element, build_dt,
	gfc_trans_dt_end, transfer_array_component, transfer_expr,
	transfer_array_desc, gfc_trans_transfer): Likewise.
	* trans-stmt.c (gfc_trans_allocate, gfc_trans_deallocate): Likewise.
	* trans.c (gfc_build_addr_expr): Mark the base of the address
	TREE_ADDRESSABLE.

Index: alias-improvements/gcc/fold-const.c
===================================================================
*** alias-improvements.orig/gcc/fold-const.c	2009-01-09 10:39:57.000000000 +0100
--- alias-improvements/gcc/fold-const.c	2009-01-09 10:43:17.000000000 +0100
*************** fold_view_convert_expr (tree type, tree
*** 7931,7941 ****
  }
  
  /* Build an expression for the address of T.  Folds away INDIRECT_REF
!    to avoid confusing the gimplify process.  When IN_FOLD is true
!    avoid modifications of T.  */
  
! static tree
! build_fold_addr_expr_with_type_1 (tree t, tree ptrtype, bool in_fold)
  {
    /* The size of the object is not relevant when talking about its address.  */
    if (TREE_CODE (t) == WITH_SIZE_EXPR)
--- 7931,7940 ----
  }
  
  /* Build an expression for the address of T.  Folds away INDIRECT_REF
!    to avoid confusing the gimplify process.  */
  
! tree
! build_fold_addr_expr_with_type (tree t, tree ptrtype)
  {
    /* The size of the object is not relevant when talking about its address.  */
    if (TREE_CODE (t) == WITH_SIZE_EXPR)
*************** build_fold_addr_expr_with_type_1 (tree t
*** 7950,8005 ****
        if (TREE_TYPE (t) != ptrtype)
  	t = build1 (NOP_EXPR, ptrtype, t);
      }
-   else if (!in_fold)
-     {
-       tree base = t;
- 
-       while (handled_component_p (base))
- 	base = TREE_OPERAND (base, 0);
- 
-       if (DECL_P (base))
- 	TREE_ADDRESSABLE (base) = 1;
- 
-       t = build1 (ADDR_EXPR, ptrtype, t);
-     }
    else
      t = build1 (ADDR_EXPR, ptrtype, t);
  
    return t;
  }
  
! /* Build an expression for the address of T with type PTRTYPE.  This
!    function modifies the input parameter 'T' by sometimes setting the
!    TREE_ADDRESSABLE flag.  */
! 
! tree
! build_fold_addr_expr_with_type (tree t, tree ptrtype)
! {
!   return build_fold_addr_expr_with_type_1 (t, ptrtype, false);
! }
! 
! /* Build an expression for the address of T.  This function modifies
!    the input parameter 'T' by sometimes setting the TREE_ADDRESSABLE
!    flag.  When called from fold functions, use fold_addr_expr instead.  */
  
  tree
  build_fold_addr_expr (tree t)
  {
-   return build_fold_addr_expr_with_type_1 (t, 
- 					   build_pointer_type (TREE_TYPE (t)),
- 					   false);
- }
- 
- /* Same as build_fold_addr_expr, builds an expression for the address
-    of T, but avoids touching the input node 't'.  Fold functions
-    should use this version.  */
- 
- static tree
- fold_addr_expr (tree t)
- {
    tree ptrtype = build_pointer_type (TREE_TYPE (t));
  
!   return build_fold_addr_expr_with_type_1 (t, ptrtype, true);
  }
  
  /* Fold a unary expression of code CODE and type TYPE with operand
--- 7949,7968 ----
        if (TREE_TYPE (t) != ptrtype)
  	t = build1 (NOP_EXPR, ptrtype, t);
      }
    else
      t = build1 (ADDR_EXPR, ptrtype, t);
  
    return t;
  }
  
! /* Build an expression for the address of T.  */
  
  tree
  build_fold_addr_expr (tree t)
  {
    tree ptrtype = build_pointer_type (TREE_TYPE (t));
  
!   return build_fold_addr_expr_with_type (t, ptrtype);
  }
  
  /* Fold a unary expression of code CODE and type TYPE with operand
*************** fold_unary (enum tree_code code, tree ty
*** 8235,8241 ****
  	  if (! offset && bitpos == 0
  	      && TYPE_MAIN_VARIANT (TREE_TYPE (type))
  		  == TYPE_MAIN_VARIANT (TREE_TYPE (base)))
! 	    return fold_convert (type, fold_addr_expr (base));
          }
  
        if (TREE_CODE (op0) == MODIFY_EXPR
--- 8198,8204 ----
  	  if (! offset && bitpos == 0
  	      && TYPE_MAIN_VARIANT (TREE_TYPE (type))
  		  == TYPE_MAIN_VARIANT (TREE_TYPE (base)))
! 	    return fold_convert (type, build_fold_addr_expr (base));
          }
  
        if (TREE_CODE (op0) == MODIFY_EXPR
*************** fold_comparison (enum tree_code code, tr
*** 9127,9135 ****
  		       && operand_equal_p (offset0, offset1, 0))))
  	{
  	  if (indirect_base0)
! 	    base0 = fold_addr_expr (base0);
  	  if (indirect_base1)
! 	    base1 = fold_addr_expr (base1);
  	  return fold_build2 (code, type, base0, base1);
  	}
      }
--- 9090,9098 ----
  		       && operand_equal_p (offset0, offset1, 0))))
  	{
  	  if (indirect_base0)
! 	    base0 = build_fold_addr_expr (base0);
  	  if (indirect_base1)
! 	    base1 = build_fold_addr_expr (base1);
  	  return fold_build2 (code, type, base0, base1);
  	}
      }
*************** split_address_to_core_and_offset (tree e
*** 15814,15820 ****
        core = get_inner_reference (TREE_OPERAND (exp, 0), &bitsize, pbitpos,
  				  poffset, &mode, &unsignedp, &volatilep,
  				  false);
!       core = fold_addr_expr (core);
      }
    else
      {
--- 15777,15783 ----
        core = get_inner_reference (TREE_OPERAND (exp, 0), &bitsize, pbitpos,
  				  poffset, &mode, &unsignedp, &volatilep,
  				  false);
!       core = build_fold_addr_expr (core);
      }
    else
      {
Index: alias-improvements/gcc/coverage.c
===================================================================
*** alias-improvements.orig/gcc/coverage.c	2009-01-09 10:39:57.000000000 +0100
--- alias-improvements/gcc/coverage.c	2009-01-09 10:40:33.000000000 +0100
*************** tree_coverage_counter_addr (unsigned cou
*** 459,464 ****
--- 459,466 ----
    gcc_assert (no < fn_n_ctrs[counter] - fn_b_ctrs[counter]);
    no += prg_n_ctrs[counter] + fn_b_ctrs[counter];
  
+   TREE_ADDRESSABLE (tree_ctr_tables[counter]) = 1;
+ 
    /* "no" here is an array index, scaled to bytes later.  */
    return build_fold_addr_expr (build4 (ARRAY_REF, gcov_type_node,
  				       tree_ctr_tables[counter],
Index: alias-improvements/gcc/fortran/trans-array.c
===================================================================
*** alias-improvements.orig/gcc/fortran/trans-array.c	2009-01-09 10:39:57.000000000 +0100
--- alias-improvements/gcc/fortran/trans-array.c	2009-01-09 10:40:33.000000000 +0100
*************** gfc_conv_descriptor_data_addr (tree desc
*** 194,200 ****
    gcc_assert (DATA_FIELD == 0);
  
    t = fold_build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
!   return build_fold_addr_expr (t);
  }
  
  tree
--- 194,200 ----
    gcc_assert (DATA_FIELD == 0);
  
    t = fold_build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
!   return gfc_build_addr_expr (NULL_TREE, t);
  }
  
  tree
*************** gfc_trans_allocate_array_storage (stmtbl
*** 533,539 ****
  	  tmp = build_array_type (gfc_get_element_type (TREE_TYPE (desc)),
  				  tmp);
  	  tmp = gfc_create_var (tmp, "A");
! 	  tmp = build_fold_addr_expr (tmp);
  	  gfc_conv_descriptor_data_set (pre, desc, tmp);
  	}
        else
--- 533,539 ----
  	  tmp = build_array_type (gfc_get_element_type (TREE_TYPE (desc)),
  				  tmp);
  	  tmp = gfc_create_var (tmp, "A");
! 	  tmp = gfc_build_addr_expr (NULL_TREE, tmp);
  	  gfc_conv_descriptor_data_set (pre, desc, tmp);
  	}
        else
*************** gfc_trans_array_constructor_value (stmtb
*** 1281,1288 ****
  	      tmp = gfc_conv_descriptor_data_get (desc);
  	      tmp = build_fold_indirect_ref (tmp);
  	      tmp = gfc_build_array_ref (tmp, *poffset, NULL);
! 	      tmp = build_fold_addr_expr (tmp);
! 	      init = build_fold_addr_expr (init);
  
  	      size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type));
  	      bound = build_int_cst (NULL_TREE, n * size);
--- 1281,1288 ----
  	      tmp = gfc_conv_descriptor_data_get (desc);
  	      tmp = build_fold_indirect_ref (tmp);
  	      tmp = gfc_build_array_ref (tmp, *poffset, NULL);
! 	      tmp = gfc_build_addr_expr (NULL_TREE, tmp);
! 	      init = gfc_build_addr_expr (NULL_TREE, init);
  
  	      size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type));
  	      bound = build_int_cst (NULL_TREE, n * size);
*************** gfc_trans_constant_array_constructor (gf
*** 1683,1689 ****
    info = &ss->data.info;
  
    info->descriptor = tmp;
!   info->data = build_fold_addr_expr (tmp);
    info->offset = gfc_index_zero_node;
  
    for (i = 0; i < info->dimen; i++)
--- 1683,1689 ----
    info = &ss->data.info;
  
    info->descriptor = tmp;
!   info->data = gfc_build_addr_expr (NULL_TREE, tmp);
    info->offset = gfc_index_zero_node;
  
    for (i = 0; i < info->dimen; i++)
*************** gfc_conv_array_data (tree descriptor)
*** 2136,2142 ****
        else
          {
            /* Descriptorless arrays.  */
! 	  return build_fold_addr_expr (descriptor);
          }
      }
    else
--- 2136,2142 ----
        else
          {
            /* Descriptorless arrays.  */
! 	  return gfc_build_addr_expr (NULL_TREE, descriptor);
          }
      }
    else
*************** gfc_conv_expr_descriptor (gfc_se * se, g
*** 4823,4829 ****
  	    {
  	      /* We pass full arrays directly.  This means that pointers and
  		 allocatable arrays should also work.  */
! 	      se->expr = build_fold_addr_expr (desc);
  	    }
  	  else
  	    {
--- 4823,4829 ----
  	    {
  	      /* We pass full arrays directly.  This means that pointers and
  		 allocatable arrays should also work.  */
! 	      se->expr = gfc_build_addr_expr (NULL_TREE, desc);
  	    }
  	  else
  	    {
*************** gfc_conv_expr_descriptor (gfc_se * se, g
*** 4854,4860 ****
  
  	  /* For pointer assignments pass the descriptor directly.  */
  	  se->ss = secss;
! 	  se->expr = build_fold_addr_expr (se->expr);
  	  gfc_conv_expr (se, expr);
  	  return;
  	}
--- 4854,4860 ----
  
  	  /* For pointer assignments pass the descriptor directly.  */
  	  se->ss = secss;
! 	  se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
  	  gfc_conv_expr (se, expr);
  	  return;
  	}
*************** gfc_conv_expr_descriptor (gfc_se * se, g
*** 5176,5182 ****
      {
        /* Get a pointer to the new descriptor.  */
        if (se->want_pointer)
! 	se->expr = build_fold_addr_expr (desc);
        else
  	se->expr = desc;
      }
--- 5176,5182 ----
      {
        /* Get a pointer to the new descriptor.  */
        if (se->want_pointer)
! 	se->expr = gfc_build_addr_expr (NULL_TREE, desc);
        else
  	se->expr = desc;
      }
*************** gfc_conv_array_parameter (gfc_se * se, g
*** 5242,5248 ****
            if (sym->attr.dummy || POINTER_TYPE_P (TREE_TYPE (tmp)))
              se->expr = tmp;
            else
! 	    se->expr = build_fold_addr_expr (tmp);
  	  return;
          }
        if (sym->attr.allocatable)
--- 5242,5248 ----
            if (sym->attr.dummy || POINTER_TYPE_P (TREE_TYPE (tmp)))
              se->expr = tmp;
            else
! 	    se->expr = gfc_build_addr_expr (NULL_TREE, tmp);
  	  return;
          }
        if (sym->attr.allocatable)
*************** gfc_conv_array_parameter (gfc_se * se, g
*** 5262,5268 ****
      {
        /* Result of the enclosing function.  */
        gfc_conv_expr_descriptor (se, expr, ss);
!       se->expr = build_fold_addr_expr (se->expr);
  
        if (g77 && TREE_TYPE (TREE_TYPE (se->expr)) != NULL_TREE
  	      && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (TREE_TYPE (se->expr))))
--- 5262,5268 ----
      {
        /* Result of the enclosing function.  */
        gfc_conv_expr_descriptor (se, expr, ss);
!       se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
  
        if (g77 && TREE_TYPE (TREE_TYPE (se->expr)) != NULL_TREE
  	      && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (TREE_TYPE (se->expr))))
Index: alias-improvements/gcc/fortran/trans-expr.c
===================================================================
*** alias-improvements.orig/gcc/fortran/trans-expr.c	2009-01-09 10:39:57.000000000 +0100
--- alias-improvements/gcc/fortran/trans-expr.c	2009-01-09 10:40:33.000000000 +0100
*************** gfc_conv_missing_dummy (gfc_se * se, gfc
*** 164,170 ****
        tmp = build3 (COND_EXPR, TREE_TYPE (tmp), present, tmp,
  		    fold_convert (TREE_TYPE (tmp), integer_one_node));
        tmp = gfc_evaluate_now (tmp, &se->pre);
!       se->expr = build_fold_addr_expr (tmp);
      }
    else
      {
--- 164,170 ----
        tmp = build3 (COND_EXPR, TREE_TYPE (tmp), present, tmp,
  		    fold_convert (TREE_TYPE (tmp), integer_one_node));
        tmp = gfc_evaluate_now (tmp, &se->pre);
!       se->expr = gfc_build_addr_expr (NULL_TREE, tmp);
      }
    else
      {
*************** gfc_conv_variable (gfc_se * se, gfc_expr
*** 603,609 ****
  	  if (!sym->attr.dummy && !sym->attr.proc_pointer)
  	    {
  	      gcc_assert (TREE_CODE (se->expr) == FUNCTION_DECL);
! 	      se->expr = build_fold_addr_expr (se->expr);
  	    }
  	  return;
  	}
--- 603,609 ----
  	  if (!sym->attr.dummy && !sym->attr.proc_pointer)
  	    {
  	      gcc_assert (TREE_CODE (se->expr) == FUNCTION_DECL);
! 	      se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
  	    }
  	  return;
  	}
*************** gfc_conv_variable (gfc_se * se, gfc_expr
*** 705,711 ****
        if (expr->ts.type == BT_CHARACTER)
  	gfc_conv_string_parameter (se);
        else 
! 	se->expr = build_fold_addr_expr (se->expr);
      }
  }
  
--- 705,711 ----
        if (expr->ts.type == BT_CHARACTER)
  	gfc_conv_string_parameter (se);
        else 
! 	se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
      }
  }
  
*************** gfc_conv_function_val (gfc_se * se, gfc_
*** 1511,1517 ****
        if (!POINTER_TYPE_P (TREE_TYPE (tmp)))
  	{
  	  gcc_assert (TREE_CODE (tmp) == FUNCTION_DECL);
! 	  tmp = build_fold_addr_expr (tmp);
  	}
      }
    se->expr = tmp;
--- 1511,1517 ----
        if (!POINTER_TYPE_P (TREE_TYPE (tmp)))
  	{
  	  gcc_assert (TREE_CODE (tmp) == FUNCTION_DECL);
! 	  tmp = gfc_build_addr_expr (NULL_TREE, tmp);
  	}
      }
    se->expr = tmp;
*************** gfc_conv_operator_assign (gfc_se *lse, g
*** 1539,1546 ****
    gfc_add_block_to_block (&block, &rse->pre);
  
    /* Build the argument list for the call, including hidden string lengths.  */
!   args = gfc_chainon_list (NULL_TREE, build_fold_addr_expr (lse->expr));
!   args = gfc_chainon_list (args, build_fold_addr_expr (rse->expr));
    if (lse->string_length != NULL_TREE)
      args = gfc_chainon_list (args, lse->string_length);
    if (rse->string_length != NULL_TREE)
--- 1539,1546 ----
    gfc_add_block_to_block (&block, &rse->pre);
  
    /* Build the argument list for the call, including hidden string lengths.  */
!   args = gfc_chainon_list (NULL_TREE, gfc_build_addr_expr (NULL_TREE, lse->expr));
!   args = gfc_chainon_list (args, gfc_build_addr_expr (NULL_TREE, rse->expr));
    if (lse->string_length != NULL_TREE)
      args = gfc_chainon_list (args, lse->string_length);
    if (rse->string_length != NULL_TREE)
*************** gfc_conv_subref_array_arg (gfc_se * parm
*** 2363,2369 ****
    if (g77)
      parmse->expr = gfc_conv_descriptor_data_get (parmse->expr);
    else
!     parmse->expr = build_fold_addr_expr (parmse->expr);
  
    return;
  }
--- 2363,2369 ----
    if (g77)
      parmse->expr = gfc_conv_descriptor_data_get (parmse->expr);
    else
!     parmse->expr = gfc_build_addr_expr (NULL_TREE, parmse->expr);
  
    return;
  }
*************** gfc_conv_function_call (gfc_se * se, gfc
*** 2647,2653 ****
  			  && fsym && fsym->attr.target)
  		{
  		  gfc_conv_expr (&parmse, e);
! 		  parmse.expr = build_fold_addr_expr (parmse.expr);
  		}
  	      else
  		{
--- 2647,2653 ----
  			  && fsym && fsym->attr.target)
  		{
  		  gfc_conv_expr (&parmse, e);
! 		  parmse.expr = gfc_build_addr_expr (NULL_TREE, parmse.expr);
  		}
  	      else
  		{
*************** gfc_conv_function_call (gfc_se * se, gfc
*** 2661,2667 ****
  			 indirection. The null pointer already contains
  			 this level of indirection.  */
  		      parm_kind = SCALAR_POINTER;
! 		      parmse.expr = build_fold_addr_expr (parmse.expr);
  		    }
  		}
  	    }
--- 2661,2667 ----
  			 indirection. The null pointer already contains
  			 this level of indirection.  */
  		      parm_kind = SCALAR_POINTER;
! 		      parmse.expr = gfc_build_addr_expr (NULL_TREE, parmse.expr);
  		    }
  		}
  	    }
*************** gfc_conv_function_call (gfc_se * se, gfc
*** 2862,2868 ****
  
  	  /* Pass the temporary as the first argument.  */
  	  tmp = info->descriptor;
! 	  tmp = build_fold_addr_expr (tmp);
  	  retargs = gfc_chainon_list (retargs, tmp);
  	}
        else if (ts.type == BT_CHARACTER)
--- 2862,2868 ----
  
  	  /* Pass the temporary as the first argument.  */
  	  tmp = info->descriptor;
! 	  tmp = gfc_build_addr_expr (NULL_TREE, tmp);
  	  retargs = gfc_chainon_list (retargs, tmp);
  	}
        else if (ts.type == BT_CHARACTER)
*************** gfc_conv_function_call (gfc_se * se, gfc
*** 2878,2884 ****
  	      var = gfc_create_var (type, "pstr");
  
  	      /* Provide an address expression for the function arguments.  */
! 	      var = build_fold_addr_expr (var);
  	    }
  	  else
  	    var = gfc_conv_string_tmp (se, type, len);
--- 2878,2884 ----
  	      var = gfc_create_var (type, "pstr");
  
  	      /* Provide an address expression for the function arguments.  */
! 	      var = gfc_build_addr_expr (NULL_TREE, var);
  	    }
  	  else
  	    var = gfc_conv_string_tmp (se, type, len);
*************** gfc_conv_function_call (gfc_se * se, gfc
*** 2890,2896 ****
  	  gcc_assert (gfc_option.flag_f2c && ts.type == BT_COMPLEX);
  
  	  type = gfc_get_complex_type (ts.kind);
! 	  var = build_fold_addr_expr (gfc_create_var (type, "cmplx"));
  	  retargs = gfc_chainon_list (retargs, var);
  	}
  
--- 2890,2896 ----
  	  gcc_assert (gfc_option.flag_f2c && ts.type == BT_COMPLEX);
  
  	  type = gfc_get_complex_type (ts.kind);
! 	  var = gfc_build_addr_expr (NULL_TREE, gfc_create_var (type, "cmplx"));
  	  retargs = gfc_chainon_list (retargs, var);
  	}
  
*************** gfc_conv_function_call (gfc_se * se, gfc
*** 2926,2932 ****
  	  TREE_TYPE (sym->backend_decl)
  		= build_function_type (integer_type_node,
  		      TYPE_ARG_TYPES (TREE_TYPE (sym->backend_decl)));
! 	  se->expr = build_fold_addr_expr (sym->backend_decl);
  	}
        else
  	TREE_TYPE (TREE_TYPE (TREE_TYPE (se->expr))) = integer_type_node;
--- 2926,2932 ----
  	  TREE_TYPE (sym->backend_decl)
  		= build_function_type (integer_type_node,
  		      TYPE_ARG_TYPES (TREE_TYPE (sym->backend_decl)));
! 	  se->expr = gfc_build_addr_expr (NULL_TREE, sym->backend_decl);
  	}
        else
  	TREE_TYPE (TREE_TYPE (TREE_TYPE (se->expr))) = integer_type_node;
*************** gfc_conv_expr_reference (gfc_se * se, gf
*** 3991,3997 ****
    gfc_add_block_to_block (&se->pre, &se->post);
  
    /* Take the address of that value.  */
!   se->expr = build_fold_addr_expr (var);
  }
  
  
--- 3991,3997 ----
    gfc_add_block_to_block (&se->pre, &se->post);
  
    /* Take the address of that value.  */
!   se->expr = gfc_build_addr_expr (NULL_TREE, var);
  }
  
  
*************** gfc_trans_scalar_assign (gfc_se * lse, g
*** 4207,4214 ****
        if (r_is_var)
  	{
  	  cond = fold_build2 (EQ_EXPR, boolean_type_node,
! 			      build_fold_addr_expr (lse->expr),
! 			      build_fold_addr_expr (rse->expr));
  	  cond = gfc_evaluate_now (cond, &lse->pre);
  	}
  
--- 4207,4214 ----
        if (r_is_var)
  	{
  	  cond = fold_build2 (EQ_EXPR, boolean_type_node,
! 			      gfc_build_addr_expr (NULL_TREE, lse->expr),
! 			      gfc_build_addr_expr (NULL_TREE, rse->expr));
  	  cond = gfc_evaluate_now (cond, &lse->pre);
  	}
  
Index: alias-improvements/gcc/fortran/trans-intrinsic.c
===================================================================
*** alias-improvements.orig/gcc/fortran/trans-intrinsic.c	2009-01-09 10:39:57.000000000 +0100
--- alias-improvements/gcc/fortran/trans-intrinsic.c	2009-01-09 10:40:33.000000000 +0100
*************** gfc_conv_intrinsic_exponent (gfc_se *se,
*** 807,813 ****
  
    res = gfc_create_var (integer_type_node, NULL);
    tmp = build_call_expr (built_in_decls[frexp], 2, arg,
! 			 build_fold_addr_expr (res));
    gfc_add_expr_to_block (&se->pre, tmp);
  
    type = gfc_typenode_for_spec (&expr->ts);
--- 807,813 ----
  
    res = gfc_create_var (integer_type_node, NULL);
    tmp = build_call_expr (built_in_decls[frexp], 2, arg,
! 			 gfc_build_addr_expr (NULL_TREE, res));
    gfc_add_expr_to_block (&se->pre, tmp);
  
    type = gfc_typenode_for_spec (&expr->ts);
*************** gfc_conv_intrinsic_ctime (gfc_se * se, g
*** 1370,1377 ****
    len = gfc_create_var (gfc_get_int_type (8), "len");
  
    gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
!   args[0] = build_fold_addr_expr (var);
!   args[1] = build_fold_addr_expr (len);
  
    fndecl = build_addr (gfor_fndecl_ctime, current_function_decl);
    tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_ctime)),
--- 1370,1377 ----
    len = gfc_create_var (gfc_get_int_type (8), "len");
  
    gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
!   args[0] = gfc_build_addr_expr (NULL_TREE, var);
!   args[1] = gfc_build_addr_expr (NULL_TREE, len);
  
    fndecl = build_addr (gfor_fndecl_ctime, current_function_decl);
    tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_ctime)),
*************** gfc_conv_intrinsic_fdate (gfc_se * se, g
*** 1408,1415 ****
    len = gfc_create_var (gfc_get_int_type (4), "len");
  
    gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
!   args[0] = build_fold_addr_expr (var);
!   args[1] = build_fold_addr_expr (len);
  
    fndecl = build_addr (gfor_fndecl_fdate, current_function_decl);
    tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_fdate)),
--- 1408,1415 ----
    len = gfc_create_var (gfc_get_int_type (4), "len");
  
    gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
!   args[0] = gfc_build_addr_expr (NULL_TREE, var);
!   args[1] = gfc_build_addr_expr (NULL_TREE, len);
  
    fndecl = build_addr (gfor_fndecl_fdate, current_function_decl);
    tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_fdate)),
*************** gfc_conv_intrinsic_ttynam (gfc_se * se,
*** 1448,1455 ****
    len = gfc_create_var (gfc_get_int_type (4), "len");
  
    gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
!   args[0] = build_fold_addr_expr (var);
!   args[1] = build_fold_addr_expr (len);
  
    fndecl = build_addr (gfor_fndecl_ttynam, current_function_decl);
    tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_ttynam)),
--- 1448,1455 ----
    len = gfc_create_var (gfc_get_int_type (4), "len");
  
    gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
!   args[0] = gfc_build_addr_expr (NULL_TREE, var);
!   args[1] = gfc_build_addr_expr (NULL_TREE, len);
  
    fndecl = build_addr (gfor_fndecl_ttynam, current_function_decl);
    tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_ttynam)),
*************** gfc_conv_intrinsic_minmax_char (gfc_se *
*** 1572,1578 ****
  
    /* Create the result variables.  */
    len = gfc_create_var (gfc_charlen_type_node, "len");
!   args[0] = build_fold_addr_expr (len);
    var = gfc_create_var (gfc_get_pchar_type (expr->ts.kind), "pstr");
    args[1] = gfc_build_addr_expr (ppvoid_type_node, var);
    args[2] = build_int_cst (NULL_TREE, op);
--- 1572,1578 ----
  
    /* Create the result variables.  */
    len = gfc_create_var (gfc_charlen_type_node, "len");
!   args[0] = gfc_build_addr_expr (NULL_TREE, len);
    var = gfc_create_var (gfc_get_pchar_type (expr->ts.kind), "pstr");
    args[1] = gfc_build_addr_expr (ppvoid_type_node, var);
    args[2] = build_int_cst (NULL_TREE, op);
*************** gfc_conv_intrinsic_fraction (gfc_se * se
*** 3118,3124 ****
    tmp = gfc_create_var (integer_type_node, NULL);
    se->expr = build_call_expr (built_in_decls[frexp], 2,
  			      fold_convert (type, arg),
! 			      build_fold_addr_expr (tmp));
    se->expr = fold_convert (type, se->expr);
  }
  
--- 3118,3124 ----
    tmp = gfc_create_var (integer_type_node, NULL);
    se->expr = build_call_expr (built_in_decls[frexp], 2,
  			      fold_convert (type, arg),
! 			      gfc_build_addr_expr (NULL_TREE, tmp));
    se->expr = fold_convert (type, se->expr);
  }
  
*************** gfc_conv_intrinsic_spacing (gfc_se * se,
*** 3226,3232 ****
    /* Build the block for s /= 0.  */
    gfc_start_block (&block);
    tmp = build_call_expr (built_in_decls[frexp], 2, arg,
! 			 build_fold_addr_expr (e));
    gfc_add_expr_to_block (&block, tmp);
  
    tmp = fold_build2 (MINUS_EXPR, integer_type_node, e, prec);
--- 3226,3232 ----
    /* Build the block for s /= 0.  */
    gfc_start_block (&block);
    tmp = build_call_expr (built_in_decls[frexp], 2, arg,
! 			 gfc_build_addr_expr (NULL_TREE, e));
    gfc_add_expr_to_block (&block, tmp);
  
    tmp = fold_build2 (MINUS_EXPR, integer_type_node, e, prec);
*************** gfc_conv_intrinsic_rrspacing (gfc_se * s
*** 3304,3310 ****
  
    gfc_start_block (&block);
    tmp = build_call_expr (built_in_decls[frexp], 2, arg,
! 			 build_fold_addr_expr (e));
    gfc_add_expr_to_block (&block, tmp);
  
    tmp = fold_build2 (MINUS_EXPR, integer_type_node,
--- 3304,3310 ----
  
    gfc_start_block (&block);
    tmp = build_call_expr (built_in_decls[frexp], 2, arg,
! 			 gfc_build_addr_expr (NULL_TREE, e));
    gfc_add_expr_to_block (&block, tmp);
  
    tmp = fold_build2 (MINUS_EXPR, integer_type_node,
*************** gfc_conv_intrinsic_set_exponent (gfc_se
*** 3387,3393 ****
    tmp = gfc_create_var (integer_type_node, NULL);
    tmp = build_call_expr (built_in_decls[frexp], 2,
  			 fold_convert (type, args[0]),
! 			 build_fold_addr_expr (tmp));
    se->expr = build_call_expr (built_in_decls[scalbn], 2, tmp,
  			      fold_convert (integer_type_node, args[1]));
    se->expr = fold_convert (type, se->expr);
--- 3387,3393 ----
    tmp = gfc_create_var (integer_type_node, NULL);
    tmp = build_call_expr (built_in_decls[frexp], 2,
  			 fold_convert (type, args[0]),
! 			 gfc_build_addr_expr (NULL_TREE, tmp));
    se->expr = build_call_expr (built_in_decls[scalbn], 2, tmp,
  			      fold_convert (integer_type_node, args[1]));
    se->expr = fold_convert (type, se->expr);
*************** gfc_conv_intrinsic_array_transfer (gfc_s
*** 3685,3691 ****
        if (!(arg->expr->expr_type == EXPR_VARIABLE
  	      && arg->expr->ref->u.ar.type == AR_FULL))
  	{
! 	  tmp = build_fold_addr_expr (argse.expr);
  
  	  if (gfc_option.warn_array_temp)
  	    gfc_warning ("Creating array temporary at %L", &expr->where);
--- 3685,3691 ----
        if (!(arg->expr->expr_type == EXPR_VARIABLE
  	      && arg->expr->ref->u.ar.type == AR_FULL))
  	{
! 	  tmp = gfc_build_addr_expr (NULL_TREE, argse.expr);
  
  	  if (gfc_option.warn_array_temp)
  	    gfc_warning ("Creating array temporary at %L", &expr->where);
*************** gfc_conv_intrinsic_transfer (gfc_se * se
*** 3924,3930 ****
        moldsize = size_in_bytes (type);
  
        /* Use memcpy to do the transfer.  */
!       tmp = build_fold_addr_expr (tmpdecl);
        tmp = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3,
  			     fold_convert (pvoid_type_node, tmp),
  			     fold_convert (pvoid_type_node, ptr),
--- 3924,3930 ----
        moldsize = size_in_bytes (type);
  
        /* Use memcpy to do the transfer.  */
!       tmp = gfc_build_addr_expr (NULL_TREE, tmpdecl);
        tmp = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3,
  			     fold_convert (pvoid_type_node, tmp),
  			     fold_convert (pvoid_type_node, ptr),
*************** gfc_conv_intrinsic_si_kind (gfc_se *se,
*** 4097,4103 ****
  
    /* The argument to SELECTED_INT_KIND is INTEGER(4).  */
    type = gfc_get_int_type (4); 
!   arg = build_fold_addr_expr (fold_convert (type, arg));
  
    /* Convert it to the required type.  */
    type = gfc_typenode_for_spec (&expr->ts);
--- 4097,4103 ----
  
    /* The argument to SELECTED_INT_KIND is INTEGER(4).  */
    type = gfc_get_int_type (4); 
!   arg = gfc_build_addr_expr (NULL_TREE, fold_convert (type, arg));
  
    /* Convert it to the required type.  */
    type = gfc_typenode_for_spec (&expr->ts);
*************** gfc_conv_intrinsic_trim (gfc_se * se, gf
*** 4173,4179 ****
    len = gfc_create_var (gfc_get_int_type (4), "len");
  
    gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
!   args[0] = build_fold_addr_expr (len);
    args[1] = addr;
  
    if (expr->ts.kind == 1)
--- 4173,4179 ----
    len = gfc_create_var (gfc_get_int_type (4), "len");
  
    gfc_conv_intrinsic_function_args (se, expr, &args[2], num_args - 2);
!   args[0] = gfc_build_addr_expr (NULL_TREE, len);
    args[1] = addr;
  
    if (expr->ts.kind == 1)
Index: alias-improvements/gcc/fortran/trans-io.c
===================================================================
*** alias-improvements.orig/gcc/fortran/trans-io.c	2009-01-09 10:39:57.000000000 +0100
--- alias-improvements/gcc/fortran/trans-io.c	2009-01-09 10:40:33.000000000 +0100
*************** gfc_trans_io_runtime_check (tree cond, t
*** 239,245 ****
    /* The code to generate the error.  */
    gfc_start_block (&block);
    
!   arg1 = build_fold_addr_expr (var);
    
    arg2 = build_int_cst (integer_type_node, error_code),
    
--- 239,245 ----
    /* The code to generate the error.  */
    gfc_start_block (&block);
    
!   arg1 = gfc_build_addr_expr (NULL_TREE, var);
    
    arg2 = build_int_cst (integer_type_node, error_code),
    
*************** set_parameter_ref (stmtblock_t *block, s
*** 530,536 ****
    if (TYPE_MODE (TREE_TYPE (se.expr))
        == TYPE_MODE (TREE_TYPE (TREE_TYPE (p->field))))
      {
!       addr = convert (TREE_TYPE (p->field), build_fold_addr_expr (se.expr));
  
        /* If this is for the iostat variable initialize the
  	 user variable to LIBERROR_OK which is zero.  */
--- 530,536 ----
    if (TYPE_MODE (TREE_TYPE (se.expr))
        == TYPE_MODE (TREE_TYPE (TREE_TYPE (p->field))))
      {
!       addr = convert (TREE_TYPE (p->field), gfc_build_addr_expr (NULL_TREE, se.expr));
  
        /* If this is for the iostat variable initialize the
  	 user variable to LIBERROR_OK which is zero.  */
*************** set_parameter_ref (stmtblock_t *block, s
*** 552,558 ****
  	gfc_add_modify (block, tmpvar,
  			     build_int_cst (TREE_TYPE (tmpvar), LIBERROR_OK));
  
!       addr = build_fold_addr_expr (tmpvar);
  	/* After the I/O operation, we set the variable from the temporary.  */
        tmp = convert (TREE_TYPE (se.expr), tmpvar);
        gfc_add_modify (postblock, se.expr, tmp);
--- 552,558 ----
  	gfc_add_modify (block, tmpvar,
  			     build_int_cst (TREE_TYPE (tmpvar), LIBERROR_OK));
  
!       addr = gfc_build_addr_expr (NULL_TREE, tmpvar);
  	/* After the I/O operation, we set the variable from the temporary.  */
        tmp = convert (TREE_TYPE (se.expr), tmpvar);
        gfc_add_modify (postblock, se.expr, tmp);
*************** gfc_convert_array_to_string (gfc_se * se
*** 621,627 ****
      {
        size = fold_build2 (MINUS_EXPR, gfc_array_index_type, size,
  		TREE_OPERAND (se->expr, 1));
!       se->expr = build_fold_addr_expr (se->expr);
      }
  
    tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type));
--- 621,627 ----
      {
        size = fold_build2 (MINUS_EXPR, gfc_array_index_type, size,
  		TREE_OPERAND (se->expr, 1));
!       se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
      }
  
    tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type));
*************** gfc_trans_open (gfc_code * code)
*** 966,972 ****
    else
      set_parameter_const (&block, var, IOPARM_common_unit, 0);
  
!   tmp = build_fold_addr_expr (var);
    tmp = build_call_expr (iocall[IOCALL_OPEN], 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
--- 966,972 ----
    else
      set_parameter_const (&block, var, IOPARM_common_unit, 0);
  
!   tmp = gfc_build_addr_expr (NULL_TREE, var);
    tmp = build_call_expr (iocall[IOCALL_OPEN], 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
*************** gfc_trans_close (gfc_code * code)
*** 1018,1024 ****
    else
      set_parameter_const (&block, var, IOPARM_common_unit, 0);
  
!   tmp = build_fold_addr_expr (var);
    tmp = build_call_expr (iocall[IOCALL_CLOSE], 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
--- 1018,1024 ----
    else
      set_parameter_const (&block, var, IOPARM_common_unit, 0);
  
!   tmp = gfc_build_addr_expr (NULL_TREE, var);
    tmp = build_call_expr (iocall[IOCALL_CLOSE], 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
*************** build_filepos (tree function, gfc_code *
*** 1068,1074 ****
    else
      set_parameter_const (&block, var, IOPARM_common_unit, 0);
  
!   tmp = build_fold_addr_expr (var);
    tmp = build_call_expr (function, 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
--- 1068,1074 ----
    else
      set_parameter_const (&block, var, IOPARM_common_unit, 0);
  
!   tmp = gfc_build_addr_expr (NULL_TREE, var);
    tmp = build_call_expr (function, 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
*************** gfc_trans_inquire (gfc_code * code)
*** 1325,1331 ****
    else
      set_parameter_const (&block, var, IOPARM_common_unit, 0);
  
!   tmp = build_fold_addr_expr (var);
    tmp = build_call_expr (iocall[IOCALL_INQUIRE], 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
--- 1325,1331 ----
    else
      set_parameter_const (&block, var, IOPARM_common_unit, 0);
  
!   tmp = gfc_build_addr_expr (NULL_TREE, var);
    tmp = build_call_expr (iocall[IOCALL_INQUIRE], 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
*************** gfc_trans_wait (gfc_code * code)
*** 1374,1380 ****
    if (p->unit)
      set_parameter_value (&block, var, IOPARM_common_unit, p->unit);
  
!   tmp = build_fold_addr_expr (var);
    tmp = build_call_expr (iocall[IOCALL_WAIT], 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
--- 1374,1380 ----
    if (p->unit)
      set_parameter_value (&block, var, IOPARM_common_unit, p->unit);
  
!   tmp = gfc_build_addr_expr (NULL_TREE, var);
    tmp = build_call_expr (iocall[IOCALL_WAIT], 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
*************** nml_get_addr_expr (gfc_symbol * sym, gfc
*** 1488,1494 ****
  
    /* Now build the address expression.  */
  
!   tmp = build_fold_addr_expr (tmp);
  
    /* If scalar dummy, resolve indirect reference now.  */
  
--- 1488,1494 ----
  
    /* Now build the address expression.  */
  
!   tmp = gfc_build_addr_expr (NULL_TREE, tmp);
  
    /* If scalar dummy, resolve indirect reference now.  */
  
*************** transfer_namelist_element (stmtblock_t *
*** 1581,1587 ****
       The call for the scalar part transfers:
       (address, name, type, kind or string_length, dtype)  */
  
!   dt_parm_addr = build_fold_addr_expr (dt_parm);
  
    if (ts->type == BT_CHARACTER)
      tmp = ts->cl->backend_decl;
--- 1581,1587 ----
       The call for the scalar part transfers:
       (address, name, type, kind or string_length, dtype)  */
  
!   dt_parm_addr = gfc_build_addr_expr (NULL_TREE, dt_parm);
  
    if (ts->type == BT_CHARACTER)
      tmp = ts->cl->backend_decl;
*************** build_dt (tree function, gfc_code * code
*** 1791,1797 ****
    else
      set_parameter_const (&block, var, IOPARM_common_flags, mask);
  
!   tmp = build_fold_addr_expr (var);
    tmp = build_call_expr (function, 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
--- 1791,1797 ----
    else
      set_parameter_const (&block, var, IOPARM_common_flags, mask);
  
!   tmp = gfc_build_addr_expr (NULL_TREE, var);
    tmp = build_call_expr (function, 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
*************** gfc_trans_dt_end (gfc_code * code)
*** 1871,1877 ****
        gcc_unreachable ();
      }
  
!   tmp = build_fold_addr_expr (dt_parm);
    tmp = build_call_expr (function, 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
    gfc_add_block_to_block (&block, dt_post_end_block);
--- 1871,1877 ----
        gcc_unreachable ();
      }
  
!   tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
    tmp = build_call_expr (function, 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
    gfc_add_block_to_block (&block, dt_post_end_block);
*************** transfer_array_component (tree expr, gfc
*** 1955,1961 ****
  
    /* Now se.expr contains an element of the array.  Take the address and pass
       it to the IO routines.  */
!   tmp = build_fold_addr_expr (se.expr);
    transfer_expr (&se, &cm->ts, tmp, NULL);
  
    /* We are done now with the loop body.  Wrap up the scalarizer and
--- 1955,1961 ----
  
    /* Now se.expr contains an element of the array.  Take the address and pass
       it to the IO routines.  */
!   tmp = gfc_build_addr_expr (NULL_TREE, se.expr);
    transfer_expr (&se, &cm->ts, tmp, NULL);
  
    /* We are done now with the loop body.  Wrap up the scalarizer and
*************** transfer_expr (gfc_se * se, gfc_typespec
*** 2053,2059 ****
  	    }
  	  arg3 = build_int_cst (NULL_TREE, kind);
  	  function = iocall[IOCALL_X_CHARACTER_WIDE];
! 	  tmp = build_fold_addr_expr (dt_parm);
  	  tmp = build_call_expr (function, 4, tmp, addr_expr, arg2, arg3);
  	  gfc_add_expr_to_block (&se->pre, tmp);
  	  gfc_add_block_to_block (&se->pre, &se->post);
--- 2053,2059 ----
  	    }
  	  arg3 = build_int_cst (NULL_TREE, kind);
  	  function = iocall[IOCALL_X_CHARACTER_WIDE];
! 	  tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
  	  tmp = build_call_expr (function, 4, tmp, addr_expr, arg2, arg3);
  	  gfc_add_expr_to_block (&se->pre, tmp);
  	  gfc_add_block_to_block (&se->pre, &se->post);
*************** transfer_expr (gfc_se * se, gfc_typespec
*** 2093,2099 ****
            else
              {
                if (!c->attr.pointer)
!                 tmp = build_fold_addr_expr (tmp);
                transfer_expr (se, &c->ts, tmp, code);
              }
  	}
--- 2093,2099 ----
            else
              {
                if (!c->attr.pointer)
!                 tmp = gfc_build_addr_expr (NULL_TREE, tmp);
                transfer_expr (se, &c->ts, tmp, code);
              }
  	}
*************** transfer_expr (gfc_se * se, gfc_typespec
*** 2103,2109 ****
        internal_error ("Bad IO basetype (%d)", ts->type);
      }
  
!   tmp = build_fold_addr_expr (dt_parm);
    tmp = build_call_expr (function, 3, tmp, addr_expr, arg2);
    gfc_add_expr_to_block (&se->pre, tmp);
    gfc_add_block_to_block (&se->pre, &se->post);
--- 2103,2109 ----
        internal_error ("Bad IO basetype (%d)", ts->type);
      }
  
!   tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
    tmp = build_call_expr (function, 3, tmp, addr_expr, arg2);
    gfc_add_expr_to_block (&se->pre, tmp);
    gfc_add_block_to_block (&se->pre, &se->post);
*************** transfer_array_desc (gfc_se * se, gfc_ty
*** 2126,2132 ****
  
    kind_arg = build_int_cst (NULL_TREE, ts->kind);
  
!   tmp = build_fold_addr_expr (dt_parm);
    tmp = build_call_expr (iocall[IOCALL_X_ARRAY], 4,
  			 tmp, addr_expr, kind_arg, charlen_arg);
    gfc_add_expr_to_block (&se->pre, tmp);
--- 2126,2132 ----
  
    kind_arg = build_int_cst (NULL_TREE, ts->kind);
  
!   tmp = gfc_build_addr_expr (NULL_TREE, dt_parm);
    tmp = build_call_expr (iocall[IOCALL_X_ARRAY], 4,
  			 tmp, addr_expr, kind_arg, charlen_arg);
    gfc_add_expr_to_block (&se->pre, tmp);
*************** gfc_trans_transfer (gfc_code * code)
*** 2198,2204 ****
  	    {
  	      /* Get the descriptor.  */
  	      gfc_conv_expr_descriptor (&se, expr, ss);
! 	      tmp = build_fold_addr_expr (se.expr);
  	    }
  
  	  transfer_array_desc (&se, &expr->ts, tmp);
--- 2198,2204 ----
  	    {
  	      /* Get the descriptor.  */
  	      gfc_conv_expr_descriptor (&se, expr, ss);
! 	      tmp = gfc_build_addr_expr (NULL_TREE, se.expr);
  	    }
  
  	  transfer_array_desc (&se, &expr->ts, tmp);
Index: alias-improvements/gcc/fortran/trans-stmt.c
===================================================================
*** alias-improvements.orig/gcc/fortran/trans-stmt.c	2009-01-09 10:39:57.000000000 +0100
--- alias-improvements/gcc/fortran/trans-stmt.c	2009-01-09 10:40:33.000000000 +0100
*************** gfc_trans_allocate (gfc_code * code)
*** 3890,3896 ****
        tree gfc_int4_type_node = gfc_get_int_type (4);
  
        stat = gfc_create_var (gfc_int4_type_node, "stat");
!       pstat = build_fold_addr_expr (stat);
  
        error_label = gfc_build_label_decl (NULL_TREE);
        TREE_USED (error_label) = 1;
--- 3890,3896 ----
        tree gfc_int4_type_node = gfc_get_int_type (4);
  
        stat = gfc_create_var (gfc_int4_type_node, "stat");
!       pstat = gfc_build_addr_expr (NULL_TREE, stat);
  
        error_label = gfc_build_label_decl (NULL_TREE);
        TREE_USED (error_label) = 1;
*************** gfc_trans_deallocate (gfc_code * code)
*** 3996,4006 ****
  
        /* Variable used with the library call.  */
        stat = gfc_create_var (gfc_int4_type_node, "stat");
!       pstat = build_fold_addr_expr (stat);
  
        /* Running total of possible deallocation failures.  */
        astat = gfc_create_var (gfc_int4_type_node, "astat");
!       apstat = build_fold_addr_expr (astat);
  
        /* Initialize astat to 0.  */
        gfc_add_modify (&block, astat, build_int_cst (TREE_TYPE (astat), 0));
--- 3996,4006 ----
  
        /* Variable used with the library call.  */
        stat = gfc_create_var (gfc_int4_type_node, "stat");
!       pstat = gfc_build_addr_expr (NULL_TREE, stat);
  
        /* Running total of possible deallocation failures.  */
        astat = gfc_create_var (gfc_int4_type_node, "astat");
!       apstat = gfc_build_addr_expr (NULL_TREE, astat);
  
        /* Initialize astat to 0.  */
        gfc_add_modify (&block, astat, build_int_cst (TREE_TYPE (astat), 0));
Index: alias-improvements/gcc/fortran/trans.c
===================================================================
*** alias-improvements.orig/gcc/fortran/trans.c	2009-01-09 10:39:57.000000000 +0100
--- alias-improvements/gcc/fortran/trans.c	2009-01-09 10:40:33.000000000 +0100
*************** gfc_build_addr_expr (tree type, tree t)
*** 293,300 ****
      }
    else
      {
!       if (DECL_P (t))
!         TREE_ADDRESSABLE (t) = 1;
        t = fold_build1 (ADDR_EXPR, natural_type, t);
      }
  
--- 293,301 ----
      }
    else
      {
!       tree base = get_base_address (t);
!       if (base && DECL_P (base))
!         TREE_ADDRESSABLE (base) = 1;
        t = fold_build1 (ADDR_EXPR, natural_type, t);
      }
  
Index: alias-improvements/gcc/gimplify.c
===================================================================
*** alias-improvements.orig/gcc/gimplify.c	2009-01-09 10:39:57.000000000 +0100
--- alias-improvements/gcc/gimplify.c	2009-01-09 10:40:33.000000000 +0100
*************** mark_addressable (tree x)
*** 112,118 ****
  {
    while (handled_component_p (x))
      x = TREE_OPERAND (x, 0);
!   if (TREE_CODE (x) != VAR_DECL && TREE_CODE (x) != PARM_DECL)
      return ;
    TREE_ADDRESSABLE (x) = 1;
  }
--- 112,120 ----
  {
    while (handled_component_p (x))
      x = TREE_OPERAND (x, 0);
!   if (TREE_CODE (x) != VAR_DECL
!       && TREE_CODE (x) != PARM_DECL
!       && TREE_CODE (x) != RESULT_DECL)
      return ;
    TREE_ADDRESSABLE (x) = 1;
  }
*************** gimplify_modify_expr_to_memcpy (tree *ex
*** 3057,3065 ****
--- 3059,3069 ----
    to = TREE_OPERAND (*expr_p, 0);
    from = TREE_OPERAND (*expr_p, 1);
  
+   mark_addressable (from);
    from_ptr = build_fold_addr_expr (from);
    gimplify_arg (&from_ptr, seq_p, EXPR_LOCATION (*expr_p));
  
+   mark_addressable (to);
    to_ptr = build_fold_addr_expr (to);
    gimplify_arg (&to_ptr, seq_p, EXPR_LOCATION (*expr_p));
  
Index: alias-improvements/gcc/omp-low.c
===================================================================
*** alias-improvements.orig/gcc/omp-low.c	2009-01-09 10:39:57.000000000 +0100
--- alias-improvements/gcc/omp-low.c	2009-01-09 10:40:33.000000000 +0100
*************** create_omp_child_function (omp_context *
*** 1595,1600 ****
--- 1595,1601 ----
        DECL_ARG_TYPE (t) = ptr_type_node;
        DECL_CONTEXT (t) = current_function_decl;
        TREE_USED (t) = 1;
+       TREE_ADDRESSABLE (t) = 1;
        TREE_CHAIN (t) = DECL_ARGUMENTS (decl);
        DECL_ARGUMENTS (decl) = t;
      }
*************** lower_rec_input_clauses (tree clauses, g
*** 2316,2321 ****
--- 2317,2323 ----
  		  x = create_tmp_var_raw (TREE_TYPE (TREE_TYPE (new_var)),
  					  name);
  		  gimple_add_tmp_var (x);
+ 		  TREE_ADDRESSABLE (x) = 1;
  		  x = build_fold_addr_expr_with_type (x, TREE_TYPE (new_var));
  		}
  	      else
*************** lower_omp_taskreg (gimple_stmt_iterator
*** 6339,6344 ****
--- 6341,6347 ----
        ctx->sender_decl
  	= create_tmp_var (ctx->srecord_type ? ctx->srecord_type
  			  : ctx->record_type, ".omp_data_o");
+       TREE_ADDRESSABLE (ctx->sender_decl) = 1;
        gimple_omp_taskreg_set_data_arg (stmt, ctx->sender_decl);
      }
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]