Patchwork [2/5] Existing call graph infrastructure enhancement

login
register
mail settings
Submitter Martin Liška
Date July 17, 2014, 2:49 p.m.
Message ID <53C7E284.7050303@suse.cz>
Download mbox | patch
Permalink /patch/371191/
State New
Headers show

Comments

Martin Liška - July 17, 2014, 2:49 p.m.
On 06/30/2014 08:54 PM, Jeff Law wrote:
> On 06/30/14 05:49, Martin Liška wrote:
>>
>> On 06/17/2014 10:00 PM, Jeff Law wrote:
>>> On 06/13/14 04:26, mliska wrote:
>>>> Hi,
>>>>      this small patch prepares remaining needed infrastructure for
>>>> the new pass.
>>>>
>>>> Changelog:
>>>>
>>>> 2014-06-13  Martin Liska  <mliska@suse.cz>
>>>>         Honza Hubicka  <hubicka@ucw.cz>
>>>>
>>>>     * ipa-utils.h (polymorphic_type_binfo_p): Function marked external
>>>>     instead of static.
>>>>     * ipa-devirt.c (polymorphic_type_binfo_p): Likewise.
>>>>     * ipa-prop.h (count_formal_params): Likewise.
>>>>     * ipa-prop.c (count_formal_params): Likewise.
>>>>     * ipa-utils.c (ipa_merge_profiles): Be more tolerant if we merge
>>>>     profiles for semantically equivalent functions.
>>>>     * passes.c (do_per_function): If we load body of a function
>>>> during WPA,
>>>>     this condition should behave same.
>>>>     * varpool.c (ctor_for_folding): More tolerant assert for variable
>>>>     aliases created during WPA.
>>> Presumably we don't have any useful way to merge the cases where we
>>> have provides for SRC & DST in ipa_merge_profiles or even to guess
>>> which is more useful when presented with both?  Does it make sense to
>>> log this into a debugging file when we drop one?
>> Hello,
>>     this merge function was written by Honza, what do you think Honza
>> about this note?
>>
>>> I think this patch is fine.  If adding logging makes sense, then feel
>>> free to do so and consider that trivial change pre-approved.
>> I made a small change to this patch, where I moved
>> 'gsi_next_nonvirtual_phi' from the pass to gimple-iterator.h.
>>
>> Ready for trunk with this change?
> Yes.  I think with the exception of patch #3/5 everything looks good. I'll try to get another pass over #3 this week.  What I looked at last week was pretty good; I'm pretty confident this will be wrapped up shortly.
>
> If #1/#2 make sense to install independent of #3, go ahead.  #4/#5 are obviously dependent on #3.
>
> Jeff

Hello,
    thank you for approval, this final version removes few hunks that are not needed any more. Changes are just cosmetic and I will commit the patch at the beginning of next week.

Thanks,
Martin

Patch

diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h
index 909d58b..47168b9 100644
--- a/gcc/gimple-iterator.h
+++ b/gcc/gimple-iterator.h
@@ -281,6 +281,30 @@  gsi_last_nondebug_bb (basic_block bb)
   return i;
 }
 
+/* Iterates I statement iterator to the next non-virtual statement.  */
+
+static inline void
+gsi_next_nonvirtual_phi (gimple_stmt_iterator *i)
+{
+  gimple phi;
+
+  if (gsi_end_p (*i))
+    return;
+
+  phi = gsi_stmt (*i);
+  gcc_assert (phi != NULL);
+
+  while (virtual_operand_p (gimple_phi_result (phi)))
+    {
+      gsi_next (i);
+
+      if (gsi_end_p (*i))
+	return;
+
+      phi = gsi_stmt (*i);
+    }
+}
+
 /* Return the basic block associated with this iterator.  */
 
 static inline basic_block
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 40f696b..aecba07 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -211,7 +211,7 @@  ipa_populate_param_decls (struct cgraph_node *node,
 
 /* Return how many formal parameters FNDECL has.  */
 
-static inline int
+int
 count_formal_params (tree fndecl)
 {
   tree parm;
diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h
index 8886e93..bc6249e 100644
--- a/gcc/ipa-prop.h
+++ b/gcc/ipa-prop.h
@@ -529,6 +529,7 @@  void ipa_free_all_edge_args (void);
 void ipa_free_all_structures_after_ipa_cp (void);
 void ipa_free_all_structures_after_iinln (void);
 void ipa_register_cgraph_hooks (void);
+int count_formal_params (tree fndecl);
 
 /* This function ensures the array of node param infos is big enough to
    accommodate a structure for all nodes and reallocates it if not.  */
diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c
index c191210..d58b170 100644
--- a/gcc/ipa-utils.c
+++ b/gcc/ipa-utils.c
@@ -660,13 +660,8 @@  ipa_merge_profiles (struct cgraph_node *dst,
   if (dst->tp_first_run > src->tp_first_run && src->tp_first_run)
     dst->tp_first_run = src->tp_first_run;
 
-  if (src->profile_id)
-    {
-      if (!dst->profile_id)
-	dst->profile_id = src->profile_id;
-      else
-	gcc_assert (src->profile_id == dst->profile_id);
-    }
+  if (src->profile_id && !dst->profile_id)
+    dst->profile_id = src->profile_id;
 
   if (!dst->count)
     return;
diff --git a/gcc/passes.c b/gcc/passes.c
index 61b4c12..bae302b 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -1478,7 +1478,7 @@  do_per_function (void (*callback) (function *, void *data), void *data)
     {
       struct cgraph_node *node;
       FOR_EACH_DEFINED_FUNCTION (node)
-	if (node->analyzed && gimple_has_body_p (node->decl)
+	if (node->analyzed && (gimple_has_body_p (node->decl) && !in_lto_p)
 	    && (!node->clone_of || node->decl != node->clone_of->decl))
 	  callback (DECL_STRUCT_FUNCTION (node->decl), data);
     }
diff --git a/gcc/varpool.c b/gcc/varpool.c
index 04ce714..5662985 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -397,6 +397,7 @@  ctor_for_folding (tree decl)
   if (decl != real_decl)
     {
       gcc_assert (!DECL_INITIAL (decl)
+		  || (node->alias && varpool_alias_target (node) == real_node)
 		  || DECL_INITIAL (decl) == error_mark_node);
       if (node->weakref)
 	{