re PR ipa/59265 (Segmentation fault in ipa_note_param_call for -fprofile-use in SPEC...
authorJan Hubicka <jh@suse.cz>
Sun, 15 Dec 2013 22:19:33 +0000 (23:19 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 15 Dec 2013 22:19:33 +0000 (22:19 +0000)
PR ipa/59265
* ipa-prop.c (ipa_analyze_call_uses): Skip already
devirtualized calls.
g++.dg/torture/pr59265.C: New testcase.

From-SVN: r206004

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

index 93e857df8dc124d387a51278b158762491404fc3..023a2291bac4692165447f67892fa5f17068e171 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 650e6002b8706b38e435ffdbfa0e1d2fdd4f268f..a753c040b9ed6e8e3602b86558b71e5ebbcdface 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 a04e6621e0c22aecce7a62c6ed8639b570c522b5..f143da257feafa009af84ac2c0a1e0f50caf047a 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() {}