public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: gcc-patches@gcc.gnu.org, mjambor@suse.cz
Subject: Cgraph alias reorg 6/14 (ipa-sra update)
Date: Fri, 10 Jun 2011 12:17:00 -0000	[thread overview]
Message-ID: <20110610115421.GD28776@kam.mff.cuni.cz> (raw)

Hi,
this patch updates ipa-sra.  Again it is quite easy: function now can be local
even if they have aliases that are local as well.
Consequentely the analysis and transform code needs to be updated to walk
the aliases of the function being updated.

Bootstrapped/regtested x86_64-linux, will commit it shortly.

	* tree-sra.c (all_callers_have_enough_arguments_p): Rename to ...
	(not_all_callers_have_enough_arguments_p): ... this one; turn into
	worker for cgraph_for_node_and_aliases.
	(convert_callers_for_node): Break out from ...
	(convert_callers): ... here.
	(modify_function): Use collect_callers_of_node.
	(ipa_early_sra): Use cgraph_for_node_and_aliases.
Index: tree-sra.c
===================================================================
*** tree-sra.c	(revision 174895)
--- tree-sra.c	(working copy)
*************** sra_ipa_reset_debug_stmts (ipa_parm_adju
*** 4304,4334 ****
      }
  }
  
! /* Return true iff all callers have at least as many actual arguments as there
     are formal parameters in the current function.  */
  
  static bool
! all_callers_have_enough_arguments_p (struct cgraph_node *node)
  {
    struct cgraph_edge *cs;
    for (cs = node->callers; cs; cs = cs->next_caller)
      if (!callsite_has_enough_arguments_p (cs->call_stmt))
!       return false;
  
!   return true;
  }
  
  
! /* Convert all callers of NODE to pass parameters as given in ADJUSTMENTS.  */
! 
! static void
! convert_callers (struct cgraph_node *node, tree old_decl,
! 		 ipa_parm_adjustment_vec adjustments)
  {
!   tree old_cur_fndecl = current_function_decl;
!   struct cgraph_edge *cs;
!   basic_block this_block;
    bitmap recomputed_callers = BITMAP_ALLOC (NULL);
  
    for (cs = node->callers; cs; cs = cs->next_caller)
      {
--- 4304,4333 ----
      }
  }
  
! /* Return false iff all callers have at least as many actual arguments as there
     are formal parameters in the current function.  */
  
  static bool
! not_all_callers_have_enough_arguments_p (struct cgraph_node *node,
! 					 void *data ATTRIBUTE_UNUSED)
  {
    struct cgraph_edge *cs;
    for (cs = node->callers; cs; cs = cs->next_caller)
      if (!callsite_has_enough_arguments_p (cs->call_stmt))
!       return true;
  
!   return false;
  }
  
+ /* Convert all callers of NODE.  */
  
! static bool
! convert_callers_for_node (struct cgraph_node *node,
! 		          void *data)
  {
!   ipa_parm_adjustment_vec adjustments = (ipa_parm_adjustment_vec)data;
    bitmap recomputed_callers = BITMAP_ALLOC (NULL);
+   struct cgraph_edge *cs;
  
    for (cs = node->callers; cs; cs = cs->next_caller)
      {
*************** convert_callers (struct cgraph_node *nod
*** 4352,4357 ****
--- 4351,4371 ----
        compute_inline_parameters (cs->caller, true);
    BITMAP_FREE (recomputed_callers);
  
+   return true;
+ }
+ 
+ /* Convert all callers of NODE to pass parameters as given in ADJUSTMENTS.  */
+ 
+ static void
+ convert_callers (struct cgraph_node *node, tree old_decl,
+ 		 ipa_parm_adjustment_vec adjustments)
+ {
+   tree old_cur_fndecl = current_function_decl;
+   basic_block this_block;
+ 
+   cgraph_for_node_and_aliases (node, convert_callers_for_node,
+ 			       adjustments, false);
+ 
    current_function_decl = old_cur_fndecl;
  
    if (!encountered_recursive_call)
*************** static bool
*** 4388,4404 ****
  modify_function (struct cgraph_node *node, ipa_parm_adjustment_vec adjustments)
  {
    struct cgraph_node *new_node;
-   struct cgraph_edge *cs;
    bool cfg_changed;
!   VEC (cgraph_edge_p, heap) * redirect_callers;
!   int node_callers;
! 
!   node_callers = 0;
!   for (cs = node->callers; cs != NULL; cs = cs->next_caller)
!     node_callers++;
!   redirect_callers = VEC_alloc (cgraph_edge_p, heap, node_callers);
!   for (cs = node->callers; cs != NULL; cs = cs->next_caller)
!     VEC_quick_push (cgraph_edge_p, redirect_callers, cs);
  
    rebuild_cgraph_edges ();
    pop_cfun ();
--- 4402,4409 ----
  modify_function (struct cgraph_node *node, ipa_parm_adjustment_vec adjustments)
  {
    struct cgraph_node *new_node;
    bool cfg_changed;
!   VEC (cgraph_edge_p, heap) * redirect_callers = collect_callers_of_node (node);
  
    rebuild_cgraph_edges ();
    pop_cfun ();
*************** ipa_early_sra (void)
*** 4503,4509 ****
        goto simple_out;
      }
  
!   if (!all_callers_have_enough_arguments_p (node))
      {
        if (dump_file)
  	fprintf (dump_file, "There are callers with insufficient number of "
--- 4508,4515 ----
        goto simple_out;
      }
  
!   if (cgraph_for_node_and_aliases (node, not_all_callers_have_enough_arguments_p,
! 				   NULL, true))
      {
        if (dump_file)
  	fprintf (dump_file, "There are callers with insufficient number of "

                 reply	other threads:[~2011-06-10 11:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110610115421.GD28776@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mjambor@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).