This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix PR ipa/59265


Hi,
the problem here is ipa-prop trying to analyze indirect call that has been
already turned to direct.  While early opts should optimize this call (and
in fact I have approved patch to do so I forgot to apply), we should
not ICE in this case.

Fixed thus,
bootstrapped/regtested x86_64-linux, will commit it shortly.

Honza

	PR ipa/59265
	* g++.dg/torture/pr59265.C: New testcase.
	* ipa-prop.c (ipa_analyze_call_uses): Do not analyze indirect calls
	that was already turned into direct calls.

Index: testsuite/g++.dg/torture/pr59265.C
===================================================================
--- testsuite/g++.dg/torture/pr59265.C	(revision 0)
+++ testsuite/g++.dg/torture/pr59265.C	(revision 0)
@@ -0,0 +1,22 @@
+// { dg-do compile }
+// { dg-options "-fprofile-use" }
+
+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() {}
Index: ipa-prop.c
===================================================================
--- ipa-prop.c	(revision 205993)
+++ ipa-prop.c	(working copy)
@@ -2024,8 +2024,17 @@ ipa_analyze_call_uses (struct cgraph_nod
 		       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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]