Hi!

On the following testcase we ICE, because fn is __builtin_unreachable
that doesn't have to have a cgraph node created.
The name method on cgraph nodes calls decl_printable_name, so the following
patch does that even if the cgraph node is NULL.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-01-05  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/69141
        * tree-ssa-pre.c: Include langhooks.h.
        (eliminate_dom_walker::before_dom_children): Use
        lang_hooks.decl_printable_name instead of
        cgraph_node::get ()->name ().

        * g++.dg/opt/pr69141.C: New test.

--- gcc/tree-ssa-pre.c.jj       2016-01-04 14:55:53.000000000 +0100
+++ gcc/tree-ssa-pre.c  2016-01-05 10:15:40.209497116 +0100
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.
 #include "tree-ssa-propagate.h"
 #include "ipa-utils.h"
 #include "tree-cfgcleanup.h"
+#include "langhooks.h"
 
 /* TODO:
 
@@ -4328,7 +4329,7 @@ eliminate_dom_walker::before_dom_childre
                      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
                                       "converting indirect call to "
                                       "function %s\n",
-                                      cgraph_node::get (fn)->name ());
+                                      lang_hooks.decl_printable_name (fn, 2));
                    }
                  gimple_call_set_fndecl (call_stmt, fn);
                  maybe_remove_unused_call_args (cfun, call_stmt);
--- gcc/testsuite/g++.dg/opt/pr69141.C.jj       2016-01-05 10:14:45.818265080 
+0100
+++ gcc/testsuite/g++.dg/opt/pr69141.C  2016-01-05 10:14:24.000000000 +0100
@@ -0,0 +1,15 @@
+// PR tree-optimization/69141
+// { dg-do compile }
+// { dg-options "-O2 -fdump-tree-fre" }
+
+struct B
+{
+  B *b;
+  B ();
+  virtual void f () = 0;
+};
+
+B::B () : b (this)
+{
+  b->f ();
+}

        Jakub

Reply via email to