PR ipa/59265
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 15 Dec 2013 22:19:33 +0000 (22:19 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 15 Dec 2013 22:19:33 +0000 (22:19 +0000)
* ipa-prop.c (ipa_analyze_call_uses): Skip already
devirtualized calls.
g++.dg/torture/pr59265.C: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206004 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ipa-prop.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr59265.C [new file with mode: 0644]

index 93e857d..023a229 100644 (file)
@@ -1,5 +1,10 @@
 2013-12-14   Jan Hubicka  <jh@suse.cz>
 
+       PR ipa/59265
+       * ipa-prop.c (ipa_analyze_call_uses): Skip already
+       devirtualized calls.
+
+2013-12-14   Jan Hubicka  <jh@suse.cz>
        PR middle-end/58477
        * ipa-prop.c (stmt_may_be_vtbl_ptr_store): Skip clobbers.
 
index 650e600..a753c04 100644 (file)
@@ -2024,8 +2024,17 @@ ipa_analyze_call_uses (struct cgraph_node *node,
                       struct param_analysis_info *parms_ainfo, gimple call)
 {
   tree target = gimple_call_fn (call);
+  struct cgraph_edge *cs;
 
-  if (!target)
+  if (!target
+      || (TREE_CODE (target) != SSA_NAME
+          && !virtual_method_call_p (target)))
+    return;
+
+  /* If we previously turned the call into a direct call, there is
+     no need to analyze.  */
+  cs = cgraph_edge (node, call);
+  if (cs && !cs->indirect_unknown_callee)
     return;
   if (TREE_CODE (target) == SSA_NAME)
     ipa_analyze_indirect_call_uses (node, info, parms_ainfo, call, target);
index a04e662..f143da2 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-14   Jan Hubicka  <jh@suse.cz>
+
+       PR ipa/59265
+       g++.dg/torture/pr59265.C: New testcase.
+
 2013-12-15  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.dg/vect/vect-nop-move.c (foo32x2_be): Call
diff --git a/gcc/testsuite/g++.dg/torture/pr59265.C b/gcc/testsuite/g++.dg/torture/pr59265.C
new file mode 100644 (file)
index 0000000..880c454
--- /dev/null
@@ -0,0 +1,22 @@
+// { dg-do compile }
+// { dg-options "-fprofile-use -std=gnu++11" }
+
+class A {
+  int m_fn1() const;
+  unsigned m_fn2() const;
+};
+class B {
+public:
+  virtual void m_fn1();
+};
+class C final : B {
+  C();
+  virtual void m_fn2() { m_fn1(); }
+};
+int a;
+unsigned A::m_fn2() const {
+  if (m_fn1())
+    return 0;
+  a = m_fn2();
+}
+C::C() {}