public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [statistics.cc] ICE in get_function_name with fortran test-case
@ 2022-07-07 10:43 Prathamesh Kulkarni
  2022-07-07 11:44 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Prathamesh Kulkarni @ 2022-07-07 10:43 UTC (permalink / raw)
  To: gcc Patches, Richard Biener

[-- 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [statistics.cc] ICE in get_function_name with fortran test-case
  2022-07-07 10:43 [statistics.cc] ICE in get_function_name with fortran test-case Prathamesh Kulkarni
@ 2022-07-07 11:44 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-07-07 11:44 UTC (permalink / raw)
  To: Prathamesh Kulkarni; +Cc: gcc Patches

On Thu, Jul 7, 2022 at 12:44 PM Prathamesh Kulkarni
<prathamesh.kulkarni@linaro.org> wrote:
>
> 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 ?
OK

>
> Thanks,
> Prathamesh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-07 11:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 10:43 [statistics.cc] ICE in get_function_name with fortran test-case Prathamesh Kulkarni
2022-07-07 11:44 ` Richard Biener

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).