This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] Avoid push/pop_cfun in IPA PTA analysis


This avoids the push/pop_cfun calls, they are not necessary.

Bootstrapped / tested on x86_64-unknown-linux-gnu, applied.

Richard.

2014-04-15  Richard Biener  <rguenther@suse.de>

	* tree-ssa-structalias.c (find_func_aliases_for_builtin_call):
	Add struct function argument and adjust.
	(find_func_aliases_for_call): Likewise.
	(find_func_aliases): Likewise.
	(find_func_clobbers): Likewise.
	(intra_create_variable_infos): Likewise.
	(compute_points_to_sets): Likewise.
	(ipa_pta_execute): Adjust.  Do not push/pop cfun.

Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c	(revision 207658)
--- gcc/tree-ssa-structalias.c	(working copy)
*************** get_fi_for_callee (gimple call)
*** 4126,4132 ****
     was handled, otherwise false.  */
  
  static bool
! find_func_aliases_for_builtin_call (gimple t)
  {
    tree fndecl = gimple_call_fndecl (t);
    vec<ce_s> lhsc = vNULL;
--- 4126,4132 ----
     was handled, otherwise false.  */
  
  static bool
! find_func_aliases_for_builtin_call (struct function *fn, gimple t)
  {
    tree fndecl = gimple_call_fndecl (t);
    vec<ce_s> lhsc = vNULL;
*************** find_func_aliases_for_builtin_call (gimp
*** 4440,4446 ****
  	     and otherwise are just all nonlocal variables.  */
  	  if (in_ipa_mode)
  	    {
! 	      fi = lookup_vi_for_tree (cfun->decl);
  	      rhs = get_function_part_constraint (fi, ~0);
  	      rhs.type = ADDRESSOF;
  	    }
--- 4440,4446 ----
  	     and otherwise are just all nonlocal variables.  */
  	  if (in_ipa_mode)
  	    {
! 	      fi = lookup_vi_for_tree (fn->decl);
  	      rhs = get_function_part_constraint (fi, ~0);
  	      rhs.type = ADDRESSOF;
  	    }
*************** find_func_aliases_for_builtin_call (gimp
*** 4465,4471 ****
  	{
  	  fi = NULL;
  	  if (!in_ipa_mode
! 	      || !(fi = get_vi_for_tree (cfun->decl)))
  	    make_constraint_from (get_varinfo (escaped_id), anything_id);
  	  else if (in_ipa_mode
  		   && fi != NULL)
--- 4465,4471 ----
  	{
  	  fi = NULL;
  	  if (!in_ipa_mode
! 	      || !(fi = get_vi_for_tree (fn->decl)))
  	    make_constraint_from (get_varinfo (escaped_id), anything_id);
  	  else if (in_ipa_mode
  		   && fi != NULL)
*************** find_func_aliases_for_builtin_call (gimp
*** 4492,4498 ****
  /* Create constraints for the call T.  */
  
  static void
! find_func_aliases_for_call (gimple t)
  {
    tree fndecl = gimple_call_fndecl (t);
    vec<ce_s> lhsc = vNULL;
--- 4492,4498 ----
  /* Create constraints for the call T.  */
  
  static void
! find_func_aliases_for_call (struct function *fn, gimple t)
  {
    tree fndecl = gimple_call_fndecl (t);
    vec<ce_s> lhsc = vNULL;
*************** find_func_aliases_for_call (gimple t)
*** 4501,4507 ****
  
    if (fndecl != NULL_TREE
        && DECL_BUILT_IN (fndecl)
!       && find_func_aliases_for_builtin_call (t))
      return;
  
    fi = get_fi_for_callee (t);
--- 4501,4507 ----
  
    if (fndecl != NULL_TREE
        && DECL_BUILT_IN (fndecl)
!       && find_func_aliases_for_builtin_call (fn, t))
      return;
  
    fi = get_fi_for_callee (t);
*************** find_func_aliases_for_call (gimple t)
*** 4611,4617 ****
     when building alias sets and computing alias grouping heuristics.  */
  
  static void
! find_func_aliases (gimple origt)
  {
    gimple t = origt;
    vec<ce_s> lhsc = vNULL;
--- 4611,4617 ----
     when building alias sets and computing alias grouping heuristics.  */
  
  static void
! find_func_aliases (struct function *fn, gimple origt)
  {
    gimple t = origt;
    vec<ce_s> lhsc = vNULL;
*************** find_func_aliases (gimple origt)
*** 4655,4661 ****
       In non-ipa mode, we need to generate constraints for each
       pointer passed by address.  */
    else if (is_gimple_call (t))
!     find_func_aliases_for_call (t);
      
    /* Otherwise, just a regular assignment statement.  Only care about
       operations with pointer result, others are dealt with as escape
--- 4655,4661 ----
       In non-ipa mode, we need to generate constraints for each
       pointer passed by address.  */
    else if (is_gimple_call (t))
!     find_func_aliases_for_call (fn, t);
      
    /* Otherwise, just a regular assignment statement.  Only care about
       operations with pointer result, others are dealt with as escape
*************** find_func_aliases (gimple origt)
*** 4746,4752 ****
      {
        fi = NULL;
        if (!in_ipa_mode
! 	  || !(fi = get_vi_for_tree (cfun->decl)))
  	make_escape_constraint (gimple_return_retval (t));
        else if (in_ipa_mode
  	       && fi != NULL)
--- 4746,4752 ----
      {
        fi = NULL;
        if (!in_ipa_mode
! 	  || !(fi = get_vi_for_tree (fn->decl)))
  	make_escape_constraint (gimple_return_retval (t));
        else if (in_ipa_mode
  	       && fi != NULL)
*************** process_ipa_clobber (varinfo_t fi, tree
*** 4849,4855 ****
     IPA constraint builder.  */
  
  static void
! find_func_clobbers (gimple origt)
  {
    gimple t = origt;
    vec<ce_s> lhsc = vNULL;
--- 4849,4855 ----
     IPA constraint builder.  */
  
  static void
! find_func_clobbers (struct function *fn, gimple origt)
  {
    gimple t = origt;
    vec<ce_s> lhsc = vNULL;
*************** find_func_clobbers (gimple origt)
*** 4867,4873 ****
      return;
  
    /* We'd better have function information for the current function.  */
!   fi = lookup_vi_for_tree (cfun->decl);
    gcc_assert (fi != NULL);
  
    /* Account for stores in assignments and calls.  */
--- 4867,4873 ----
      return;
  
    /* We'd better have function information for the current function.  */
!   fi = lookup_vi_for_tree (fn->decl);
    gcc_assert (fi != NULL);
  
    /* Account for stores in assignments and calls.  */
*************** find_func_clobbers (gimple origt)
*** 4879,4890 ****
        while (handled_component_p (tem))
  	tem = TREE_OPERAND (tem, 0);
        if ((DECL_P (tem)
! 	   && !auto_var_in_fn_p (tem, cfun->decl))
  	  || INDIRECT_REF_P (tem)
  	  || (TREE_CODE (tem) == MEM_REF
  	      && !(TREE_CODE (TREE_OPERAND (tem, 0)) == ADDR_EXPR
  		   && auto_var_in_fn_p
! 		        (TREE_OPERAND (TREE_OPERAND (tem, 0), 0), cfun->decl))))
  	{
  	  struct constraint_expr lhsc, *rhsp;
  	  unsigned i;
--- 4879,4890 ----
        while (handled_component_p (tem))
  	tem = TREE_OPERAND (tem, 0);
        if ((DECL_P (tem)
! 	   && !auto_var_in_fn_p (tem, fn->decl))
  	  || INDIRECT_REF_P (tem)
  	  || (TREE_CODE (tem) == MEM_REF
  	      && !(TREE_CODE (TREE_OPERAND (tem, 0)) == ADDR_EXPR
  		   && auto_var_in_fn_p
! 		        (TREE_OPERAND (TREE_OPERAND (tem, 0), 0), fn->decl))))
  	{
  	  struct constraint_expr lhsc, *rhsp;
  	  unsigned i;
*************** find_func_clobbers (gimple origt)
*** 4907,4918 ****
        while (handled_component_p (tem))
  	tem = TREE_OPERAND (tem, 0);
        if ((DECL_P (tem)
! 	   && !auto_var_in_fn_p (tem, cfun->decl))
  	  || INDIRECT_REF_P (tem)
  	  || (TREE_CODE (tem) == MEM_REF
  	      && !(TREE_CODE (TREE_OPERAND (tem, 0)) == ADDR_EXPR
  		   && auto_var_in_fn_p
! 		        (TREE_OPERAND (TREE_OPERAND (tem, 0), 0), cfun->decl))))
  	{
  	  struct constraint_expr lhs, *rhsp;
  	  unsigned i;
--- 4907,4918 ----
        while (handled_component_p (tem))
  	tem = TREE_OPERAND (tem, 0);
        if ((DECL_P (tem)
! 	   && !auto_var_in_fn_p (tem, fn->decl))
  	  || INDIRECT_REF_P (tem)
  	  || (TREE_CODE (tem) == MEM_REF
  	      && !(TREE_CODE (TREE_OPERAND (tem, 0)) == ADDR_EXPR
  		   && auto_var_in_fn_p
! 		        (TREE_OPERAND (TREE_OPERAND (tem, 0), 0), fn->decl))))
  	{
  	  struct constraint_expr lhs, *rhsp;
  	  unsigned i;
*************** debug_solution_for_var (unsigned int var
*** 5836,5849 ****
     function for intraprocedural mode.  */
  
  static void
! intra_create_variable_infos (void)
  {
    tree t;
  
    /* For each incoming pointer argument arg, create the constraint ARG
       = NONLOCAL or a dummy variable if it is a restrict qualified
       passed-by-reference argument.  */
!   for (t = DECL_ARGUMENTS (current_function_decl); t; t = DECL_CHAIN (t))
      {
        varinfo_t p = get_vi_for_tree (t);
  
--- 5836,5849 ----
     function for intraprocedural mode.  */
  
  static void
! intra_create_variable_infos (struct function *fn)
  {
    tree t;
  
    /* For each incoming pointer argument arg, create the constraint ARG
       = NONLOCAL or a dummy variable if it is a restrict qualified
       passed-by-reference argument.  */
!   for (t = DECL_ARGUMENTS (fn->decl); t; t = DECL_CHAIN (t))
      {
        varinfo_t p = get_vi_for_tree (t);
  
*************** intra_create_variable_infos (void)
*** 5895,5913 ****
      }
  
    /* Add a constraint for a result decl that is passed by reference.  */
!   if (DECL_RESULT (cfun->decl)
!       && DECL_BY_REFERENCE (DECL_RESULT (cfun->decl)))
      {
!       varinfo_t p, result_vi = get_vi_for_tree (DECL_RESULT (cfun->decl));
  
        for (p = result_vi; p; p = vi_next (p))
  	make_constraint_from (p, nonlocal_id);
      }
  
    /* Add a constraint for the incoming static chain parameter.  */
!   if (cfun->static_chain_decl != NULL_TREE)
      {
!       varinfo_t p, chain_vi = get_vi_for_tree (cfun->static_chain_decl);
  
        for (p = chain_vi; p; p = vi_next (p))
  	make_constraint_from (p, nonlocal_id);
--- 5895,5913 ----
      }
  
    /* Add a constraint for a result decl that is passed by reference.  */
!   if (DECL_RESULT (fn->decl)
!       && DECL_BY_REFERENCE (DECL_RESULT (fn->decl)))
      {
!       varinfo_t p, result_vi = get_vi_for_tree (DECL_RESULT (fn->decl));
  
        for (p = result_vi; p; p = vi_next (p))
  	make_constraint_from (p, nonlocal_id);
      }
  
    /* Add a constraint for the incoming static chain parameter.  */
!   if (fn->static_chain_decl != NULL_TREE)
      {
!       varinfo_t p, chain_vi = get_vi_for_tree (fn->static_chain_decl);
  
        for (p = chain_vi; p; p = vi_next (p))
  	make_constraint_from (p, nonlocal_id);
*************** compute_points_to_sets (void)
*** 6792,6798 ****
  
    init_alias_vars ();
  
!   intra_create_variable_infos ();
  
    /* Now walk all statements and build the constraint set.  */
    FOR_EACH_BB_FN (bb, cfun)
--- 6792,6798 ----
  
    init_alias_vars ();
  
!   intra_create_variable_infos (cfun);
  
    /* Now walk all statements and build the constraint set.  */
    FOR_EACH_BB_FN (bb, cfun)
*************** compute_points_to_sets (void)
*** 6804,6817 ****
  	  gimple phi = gsi_stmt (gsi);
  
  	  if (! virtual_operand_p (gimple_phi_result (phi)))
! 	    find_func_aliases (phi);
  	}
  
        for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
  	{
  	  gimple stmt = gsi_stmt (gsi);
  
! 	  find_func_aliases (stmt);
  	}
      }
  
--- 6804,6817 ----
  	  gimple phi = gsi_stmt (gsi);
  
  	  if (! virtual_operand_p (gimple_phi_result (phi)))
! 	    find_func_aliases (cfun, phi);
  	}
  
        for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
  	{
  	  gimple stmt = gsi_stmt (gsi);
  
! 	  find_func_aliases (cfun, stmt);
  	}
      }
  
*************** ipa_pta_execute (void)
*** 7166,7172 ****
  	}
  
        func = DECL_STRUCT_FUNCTION (node->decl);
!       push_cfun (func);
  
        /* For externally visible or attribute used annotated functions use
  	 local constraints for their arguments.
--- 7166,7172 ----
  	}
  
        func = DECL_STRUCT_FUNCTION (node->decl);
!       gcc_assert (cfun == NULL);
  
        /* For externally visible or attribute used annotated functions use
  	 local constraints for their arguments.
*************** ipa_pta_execute (void)
*** 7176,7182 ****
  	  || node->externally_visible
  	  || node->force_output)
  	{
! 	  intra_create_variable_infos ();
  
  	  /* We also need to make function return values escape.  Nothing
  	     escapes by returning from main though.  */
--- 7176,7182 ----
  	  || node->externally_visible
  	  || node->force_output)
  	{
! 	  intra_create_variable_infos (func);
  
  	  /* We also need to make function return values escape.  Nothing
  	     escapes by returning from main though.  */
*************** ipa_pta_execute (void)
*** 7211,7230 ****
  	      gimple phi = gsi_stmt (gsi);
  
  	      if (! virtual_operand_p (gimple_phi_result (phi)))
! 		find_func_aliases (phi);
  	    }
  
  	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
  	    {
  	      gimple stmt = gsi_stmt (gsi);
  
! 	      find_func_aliases (stmt);
! 	      find_func_clobbers (stmt);
  	    }
  	}
  
-       pop_cfun ();
- 
        if (dump_file)
  	{
  	  fprintf (dump_file, "\n");
--- 7211,7228 ----
  	      gimple phi = gsi_stmt (gsi);
  
  	      if (! virtual_operand_p (gimple_phi_result (phi)))
! 		find_func_aliases (func, phi);
  	    }
  
  	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
  	    {
  	      gimple stmt = gsi_stmt (gsi);
  
! 	      find_func_aliases (func, stmt);
! 	      find_func_clobbers (func, stmt);
  	    }
  	}
  
        if (dump_file)
  	{
  	  fprintf (dump_file, "\n");


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