From: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
To: gcc Patches <gcc-patches@gcc.gnu.org>,
Richard Biener <richard.guenther@gmail.com>
Subject: [statistics.cc] ICE in get_function_name with fortran test-case
Date: Thu, 7 Jul 2022 16:13:30 +0530 [thread overview]
Message-ID: <CAAgBjMnynmyAupLFnn7evFhE5T0VOqd5P4XaQhnycER-6FydSw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1274 bytes --]
Hi,
My recent commit to emit asm name with -fdump-statistics-asmname
caused following ICE
for attached fortran test case.
during IPA pass: icf
power.fppized.f90:6:26:
6 | END SUBROUTINE power_print
| ^
internal compiler error: Segmentation fault
0xfddc13 crash_signal
../../gcc/gcc/toplev.cc:322
0x7f6f940de51f ???
./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xfc909d get_function_name
../../gcc/gcc/statistics.cc:124
0xfc929f statistics_fini_pass_2(statistics_counter**, void*)
../../gcc/gcc/statistics.cc:175
0xfc94a4 void hash_table<stats_counter_hasher, false,
xcallocator>::traverse_noresize<void*,
&(statistics_fini_pass_2(statistics_counter**, void*))>(void*)
../../gcc/gcc/hash-table.h:1084
0xfc94a4 statistics_fini_pass()
../../gcc/gcc/statistics.cc:219
0xef12bc execute_todo
../../gcc/gcc/passes.cc:2142
This happens because fn was passed NULL in get_function_name.
The patch adds a check to see if fn is NULL before checking for
DECL_ASSEMBLER_NAME_SET_P, which fixes the issue.
In case the fn is NULL, it calls function_name(NULL) as per old behavior,
which returns "(nofn)".
Bootstrap+tested on x86_64-linux-gnu.
OK to commit ?
Thanks,
Prathamesh
[-- Attachment #2: stats-fortran-bug-1.txt --]
[-- Type: text/plain, Size: 449 bytes --]
diff --git a/gcc/statistics.cc b/gcc/statistics.cc
index 6c21415bf65..01ad353e3a9 100644
--- a/gcc/statistics.cc
+++ b/gcc/statistics.cc
@@ -121,7 +121,7 @@ static const char *
get_function_name (struct function *fn)
{
if ((statistics_dump_flags & TDF_ASMNAME)
- && DECL_ASSEMBLER_NAME_SET_P (fn->decl))
+ && fn && DECL_ASSEMBLER_NAME_SET_P (fn->decl))
{
tree asmname = decl_assembler_name (fn->decl);
if (asmname)
[-- Attachment #3: power.fppized.f90 --]
[-- Type: application/octet-stream, Size: 157 bytes --]
MODULE power_mod
CONTAINS
SUBROUTINE power_print()
END SUBROUTINE power_print
SUBROUTINE power_interH()
END SUBROUTINE power_interH
END MODULE power_mod
next reply other threads:[~2022-07-07 10:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-07 10:43 Prathamesh Kulkarni [this message]
2022-07-07 11:44 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAgBjMnynmyAupLFnn7evFhE5T0VOqd5P4XaQhnycER-6FydSw@mail.gmail.com \
--to=prathamesh.kulkarni@linaro.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).