optrecord_json_writer::optinfo_to_json can in theory be called from any optimization pass, but currently uses get_fnname_from_decl, which is RTL-specific, which can lead to an ICE (PR middle-end/89725).
In that PR, Jakub suggested using either DECL_ASSEMBLER_NAME or the "printable name" (via current_function_name). This patch makes it use DECL_ASSEMBLER_NAME. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. OK for trunk? gcc/ChangeLog: PR middle-end/89725 * optinfo-emit-json.cc (optrecord_json_writer::optinfo_to_json): Use DECL_ASSEMBLER_NAME rather than get_fnname_from_decl. --- gcc/optinfo-emit-json.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/optinfo-emit-json.cc b/gcc/optinfo-emit-json.cc index 814446b..1cfcdfe 100644 --- a/gcc/optinfo-emit-json.cc +++ b/gcc/optinfo-emit-json.cc @@ -411,7 +411,8 @@ optrecord_json_writer::optinfo_to_json (const optinfo *optinfo) if (current_function_decl) { - const char *fnname = get_fnname_from_decl (current_function_decl); + const char *fnname + = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)); obj->set ("function", new json::string (fnname)); } -- 1.8.5.3