https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98330

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
So modref allocates a fnspec_summary for an unknown indirect call (NULL callee)
but then in compute_parm_map calls function_or_virtual_thunk_symbol on
that NULL callee unconditionally.  We have a meaningful fnspec for the
call because the call type has a 'fn spec' attribute attached.

So I'm proposing the following which avoids the ICE (and undefined behavior
calling a member fn on a NULL object)

diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index 74ad876cf58..8a5669c7f9b 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -1247,11 +1247,13 @@ analyze_stmt (modref_summary *summary,
modref_summary_lto *summary_lto,
            && (!fnspec.global_memory_read_p ()
                || !fnspec.global_memory_written_p ()))
          {
-           fnspec_summaries->get_create
-                (cgraph_node::get (current_function_decl)->get_edge (stmt))
-                       ->fnspec = xstrdup (fnspec.get_str ());
-           if (dump_file)
-             fprintf (dump_file, "  Recorded fnspec %s\n", fnspec.get_str ());
+           cgraph_edge *e = cgraph_node::get (current_function_decl)->get_edge
(stmt);
+           if (e->callee)
+             {
+               fnspec_summaries->get_create (e)->fnspec = xstrdup
(fnspec.get_str ());
+               if (dump_file)
+                 fprintf (dump_file, "  Recorded fnspec %s\n", fnspec.get_str
());
+             }
          }
       }
      return true;

Reply via email to