diff mbox

[PR,61160] IPA-CP and edges leading to thunks of clones

Message ID 20140530225358.GB23341@virgil.suse
State New
Headers show

Commit Message

Martin Jambor May 30, 2014, 10:53 p.m. UTC
Hi,

PR 61160 is actually two problems, this patch deals with the one
reported in comment one.  The underlying cause is that an IPA-CP test
whether an edge is already leading to a clone does not look through
thunks, which caused it to double count and doubly-redirect them.

Bootstrapped and tested on x86_64-linux, I will run the test on the
4.9 branch later.  OK for both if it passed everywhere?

Thanks,

Martin


2014-05-28  Martin Jambor  <mjambor@suse.cz>

	PR ipa/61160
	* ipa-cp.c (cgraph_edge_brings_value_p): Handle edges leading to
	thunks.

testsuite/
	* g++.dg/ipa/pr61160-1.C: New test.

Comments

Jan Hubicka June 1, 2014, 4:45 a.m. UTC | #1
> Hi,
> 
> PR 61160 is actually two problems, this patch deals with the one
> reported in comment one.  The underlying cause is that an IPA-CP test
> whether an edge is already leading to a clone does not look through
> thunks, which caused it to double count and doubly-redirect them.
> 
> Bootstrapped and tested on x86_64-linux, I will run the test on the
> 4.9 branch later.  OK for both if it passed everywhere?
> 
> Thanks,
> 
> Martin
> 
> 
> 2014-05-28  Martin Jambor  <mjambor@suse.cz>
> 
> 	PR ipa/61160
> 	* ipa-cp.c (cgraph_edge_brings_value_p): Handle edges leading to
> 	thunks.
OK, thanks!
Honza
diff mbox

Patch

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index d1f882a..2ebfd18 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -2482,7 +2482,8 @@  cgraph_edge_brings_value_p (struct cgraph_edge *cs,
 			    struct ipcp_value_source *src)
 {
   struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
-  struct ipa_node_params *dst_info = IPA_NODE_REF (cs->callee);
+  cgraph_node *real_dest = cgraph_function_node (cs->callee);
+  struct ipa_node_params *dst_info = IPA_NODE_REF (real_dest);
 
   if ((dst_info->ipcp_orig_node && !dst_info->is_all_contexts_clone)
       || caller_info->node_dead)
diff --git a/gcc/testsuite/g++.dg/ipa/pr61160-1.C b/gcc/testsuite/g++.dg/ipa/pr61160-1.C
new file mode 100644
index 0000000..a0fbb5f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr61160-1.C
@@ -0,0 +1,31 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O3"  } */
+
+struct CBase {
+  virtual void BaseFunc () {}
+};
+
+struct MMixin {
+  virtual void * MixinFunc (int, void *) = 0;
+};
+
+struct CExample: CBase, public MMixin
+{
+  void *MixinFunc (int arg, void *arg2)
+  {
+    if (arg != 1 || arg2)
+      return 0;
+    return this;
+  }
+};
+
+void *test (MMixin & anExample)
+{
+  return anExample.MixinFunc (1, 0);
+}
+
+int main ()
+{
+  CExample c;
+  return (test (c) != &c);
+}