Bug 91273 - [8/9/10 Regression] ICE in warn_types_mismatch at ipa-devirt.c:995
Summary: [8/9/10 Regression] ICE in warn_types_mismatch at ipa-devirt.c:995
Status: RESOLVED DUPLICATE of bug 91222
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 9.0
: P2 normal
Target Milestone: 8.4
Assignee: Jan Hubicka
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2019-07-27 10:07 UTC by Martin Liška
Modified: 2019-11-27 17:41 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 10.0, 7.4.0, 8.3.0, 9.1.0
Last reconfirmed: 2019-07-27 00:00:00


Attachments
1.ii (42 bytes, text/plain)
2019-07-29 10:53 UTC, Martin Liška
Details
2.F (41 bytes, text/plain)
2019-07-29 10:54 UTC, Martin Liška
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2019-07-27 10:07:23 UTC
I see following ICE from r224248:

$ cat 1.ii
cat 1.ii
extern "C" {
struct {
} ltregul_;
}

$ cat 2.F
	common /ltregul/ zeroeps
	end         

$ g++ 1.ii 2.F -flto -O2 
2.F:1:3: warning: type of ‘ltregul’ does not match original declaration [-Wlto-type-mismatch]
    1 |  common /ltregul/ zeroeps
      |   ^
lto1: internal compiler error: in warn_types_mismatch, at ipa-devirt.c:995
0x626616 warn_types_mismatch(tree_node*, tree_node*, unsigned int, unsigned int)
	/home/marxin/Programming/gcc/gcc/ipa-devirt.c:995
0x7e536c lto_symtab_merge_decls_2
	/home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:722
0x7e536c lto_symtab_merge_decls_1
	/home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:861
0x7e536c lto_symtab_merge_decls()
	/home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:887
0x7f0f28 read_cgraph_and_symbols(unsigned int, char const**)
	/home/marxin/Programming/gcc/gcc/lto/lto-common.c:2839
0x7d7702 lto_main()
	/home/marxin/Programming/gcc/gcc/lto/lto.c:616
Comment 1 Jan Hubicka 2019-07-29 10:10:28 UTC
This seems to work for me with current trunk

hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ cat ~/1.ii
extern "C" {
struct {
} ltregul_;
}
hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ cat ~/2.F
common /ltregul/ zeroeps
        end         
hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ ./gfortran -B ./ ~/1.ii ~/2.F -flto -O2     -B ../x86_64-pc-linux-gnu/libgfortran/
hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ ./xg++ -B ./ ~/1.ii ~/2.F -flto -O2     -B ../x86_64-pc-linux-gnu/libgfortran/
/usr/local/x86_64-pc-linux-gnu/bin/ld: /tmp/cck5WNC7.ltrans0.ltrans.o: in function `main':
<artificial>:(.text.startup+0x5): undefined reference to `_gfortran_set_args'
/usr/local/x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text.startup+0x14): undefined reference to `_gfortran_set_options'
collect2: error: ld returned 1 exit status
Comment 2 Martin Liška 2019-07-29 10:47:33 UTC
(In reply to Jan Hubicka from comment #1)
> This seems to work for me with current trunk

No, it's broken also on current trunk.

> 
> hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ cat ~/1.ii
> extern "C" {
> struct {
> } ltregul_;
> }
> hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ cat ~/2.F
> common /ltregul/ zeroeps
>         end         
> hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ ./gfortran -B ./ ~/1.ii
> ~/2.F -flto -O2     -B ../x86_64-pc-linux-gnu/libgfortran/
> hubicka@lomikamen-jh:/aux/hubicka/trunk4/build2/gcc$ ./xg++ -B ./ ~/1.ii
> ~/2.F -flto -O2     -B ../x86_64-pc-linux-gnu/libgfortran/
> /usr/local/x86_64-pc-linux-gnu/bin/ld: /tmp/cck5WNC7.ltrans0.ltrans.o: in
> function `main':
> <artificial>:(.text.startup+0x5): undefined reference to `_gfortran_set_args'
> /usr/local/x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text.startup+0x14):
> undefined reference to `_gfortran_set_options'
> collect2: error: ld returned 1 exit status

Please run it from a location where you have properly installed compiler:

$ gcc -v
gcc --version
gcc (GCC) 10.0.0 20190723 (experimental

$ g++ 1.ii 2.F -flto -O2 
2.F:1:3: warning: type of ‘ltregul’ does not match original declaration [-Wlto-type-mismatch]
    1 |  common /ltregul/ zeroeps
      |   ^
lto1: internal compiler error: in warn_types_mismatch, at ipa-devirt.c:995
0xcab6f2 warn_types_mismatch(tree_node*, tree_node*, unsigned int, unsigned int)
	/home/marxin/Programming/gcc/gcc/ipa-devirt.c:995
0x89f8d7 lto_symtab_merge_decls_2
	/home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:722
0x89ffe9 lto_symtab_merge_decls_1
	/home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:861
0x8a00e3 lto_symtab_merge_decls()
	/home/marxin/Programming/gcc/gcc/lto/lto-symtab.c:887
0x8b4854 read_cgraph_and_symbols(unsigned int, char const**)
	/home/marxin/Programming/gcc/gcc/lto/lto-common.c:2839
0x885bb5 lto_main()
	/home/marxin/Programming/gcc/gcc/lto/lto.c:616
Comment 3 Jan Hubicka 2019-07-29 10:52:06 UTC
Still works for me
hubicka@lomikamen-jh:~$ /aux/hubicka/trunk-install/bin/g++ 1.ii 2.F -O2 -flto
/usr/local/bin/ld: /tmp/ccpfzvWm.ltrans0.ltrans.o: in function `main':
<artificial>:(.text.startup+0x5): undefined reference to `_gfortran_set_args'
/usr/local/bin/ld: <artificial>:(.text.startup+0x14): undefined reference to `_gfortran_set_options'
collect2: error: ld returned 1 exit status

also with system compiler on tumbleweed
There is extra cat in 1.ii, perhaps it is truncated?
Comment 4 Martin Liška 2019-07-29 10:53:50 UTC
Created attachment 46633 [details]
1.ii
Comment 5 Martin Liška 2019-07-29 10:54:16 UTC
Created attachment 46634 [details]
2.F
Comment 6 Martin Liška 2019-07-29 10:55:11 UTC
(In reply to Jan Hubicka from comment #3)
> Still works for me
> hubicka@lomikamen-jh:~$ /aux/hubicka/trunk-install/bin/g++ 1.ii 2.F -O2 -flto
> /usr/local/bin/ld: /tmp/ccpfzvWm.ltrans0.ltrans.o: in function `main':
> <artificial>:(.text.startup+0x5): undefined reference to `_gfortran_set_args'
> /usr/local/bin/ld: <artificial>:(.text.startup+0x14): undefined reference to
> `_gfortran_set_options'
> collect2: error: ld returned 1 exit status
> 
> also with system compiler on tumbleweed
> There is extra cat in 1.ii, perhaps it is truncated?

I've just uploaded test-cases, please test it. Using TW GCC:

$ g++ --version
g++ (SUSE Linux) 9.1.1 20190723 [gcc-9-branch revision 273734]

$ g++ 1.ii 2.F -flto -O2 
2.F:1:3: warning: type of ‘ltregul’ does not match original declaration [-Wlto-type-mismatch]
    1 |  common /ltregul/ zeroeps
      |   ^
lto1: internal compiler error: in warn_types_mismatch, at ipa-devirt.c:1133
0x7fc5fcd15bca __libc_start_main
	../csu/libc-start.c:308
Comment 7 Jan Hubicka 2019-07-29 11:08:49 UTC
aha, relies on indentation of common in 2.F.  i will check what goes wrong.
Comment 8 Xiong Hu XS Luo 2019-08-22 02:09:32 UTC
SPEC2017 case 507.cactuBSSN_r, also has ICE failure from r273571:

lto1: internal compiler error: in warn_types_mismatch, at ipa-devirt.c:995
0x105dad1f warn_types_mismatch(tree_node*, tree_node*, unsigned int, unsigned int)
        /home/gcc/gcc-10-trunk-2019-08-16/gcc/ipa-devirt.c:995
0x101dd147 lto_symtab_merge_decls_2
        /home/gcc/gcc-10-trunk-2019-08-16/gcc/lto/lto-symtab.c:723
0x101dd147 lto_symtab_merge_decls_1
        /home/gcc/gcc-10-trunk-2019-08-16/gcc/lto/lto-symtab.c:862
0x101dd147 lto_symtab_merge_decls()
        /home/gcc/gcc-10-trunk-2019-08-16/gcc/lto/lto-symtab.c:888
0x101f2e47 read_cgraph_and_symbols(unsigned int, char const**)
        /home/gcc/gcc-10-trunk-2019-08-16/gcc/lto/lto-common.c:2839
0x101c7def lto_main()

Compiler options used: "-O3 -mcpu=power9 -flto"
Comment 9 Martin Liška 2019-08-23 07:44:32 UTC
@Honza: Is there any progress?
Comment 10 Richard Biener 2019-11-14 07:58:11 UTC
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
Comment 11 Martin Liška 2019-11-27 17:41:05 UTC
Dup.

*** This bug has been marked as a duplicate of bug 91222 ***