[Bug target/114137] ICE when building lua-5.4.6 with -fharden-control-flow-redundancy on x86 (error: invalid rtl sharing found in the insn)

2024-03-08 Thread aoliva at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114137

--- Comment #6 from Alexandre Oliva  ---
Thanks for the report.

Something's very rotten here.  cfrvisited is an automatic variable, why oh why
would we have GOTOFF unspecs for it?!?

I'd be interested in a preprocessed testcase that will trigger the problem.

Failing that, I suppose I could try to drive a remote debug session if you're
up for it.  If it is indeed something related with GC as suggested (and it
sounds plausible), the exact details of when it hits will depend on local
hardware details and not necessarily carry over to other machines.

[Bug target/114137] ICE when building lua-5.4.6 with -fharden-control-flow-redundancy on x86 (error: invalid rtl sharing found in the insn)

2024-02-27 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114137

--- Comment #5 from Sam James  ---
I also now believe I've seen this on sparc with ncurses with
-fharden-control-flow-redundancy...

[Bug target/114137] ICE when building lua-5.4.6 with -fharden-control-flow-redundancy on x86 (error: invalid rtl sharing found in the insn)

2024-02-27 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114137

--- Comment #4 from Sam James  ---
I have another testcase where it works with -save-temps or the GC params.

bibtexu-3.71_p20210325:

```
# i686-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I.   -DUNIX -DKPATHSEA
-DU_DISABLE_RENAMING=1 -I/usr/include  -DUTF_8  -Wimplicit -Wreturn-type -O3
-pipe -march=i686 -fdiagnostics-color=always -mfpmath=sse -msse -msse2
-fno-vect-cost-model -fharden-control-flow-redundancy -fpermissive -c -o
bibtexu-bibtex-4.o bibtex-4.c -fharden-control-flow-redundancy
during RTL pass: rtl pre
In file included from bibtex-4.c:130:
bibtex-4.c: In function ‘x_format_name’:
sysdep.h:210:37: internal compiler error: Segmentation fault
  210 | #define END }
  | ^
bibtex-4.c:1303:1: note: in expansion of macro ‘END’
 1303 | END
  | ^~~
0x579d3dc9 crash_signal
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/toplev.cc:319
0x586e7ff0 mark_used_flags
   
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/emit-rtl.cc:3364
0x586e6638 mark_used_flags
   
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/emit-rtl.cc:3416
0x586e6638 mark_used_flags
   
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/emit-rtl.cc:3411
0x586e6638 mark_used_flags
   
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/emit-rtl.cc:3411
0x586e6638 reset_used_flags(rtx_def*)
   
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/emit-rtl.cc:3428
0x586e6638 reset_insn_used_flags
   
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/emit-rtl.cc:3094
0x586e6638 reset_all_used_flags
   
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/emit-rtl.cc:3111
0x586e4737 verify_rtl_sharing()
   
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/emit-rtl.cc:3147
0x5832756c execute_function_todo
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/passes.cc:2109
0x5832756c do_per_function
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/passes.cc:1687
0x5832756c execute_todo
/usr/src/debug/sys-devel/gcc-14.0./gcc-14.0./gcc/passes.cc:2142
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

For both test cases, -fno-harden-control-flow-redundancy also suppresses the
ICE.

[Bug target/114137] ICE when building lua-5.4.6 with -fharden-control-flow-redundancy on x86 (error: invalid rtl sharing found in the insn)

2024-02-27 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114137

--- Comment #3 from Sam James  ---
==16482== Command: /usr/libexec/gcc/i686-pc-linux-gnu/14/cc1 -quiet -I . -I
./src -D PACKAGE_NAME="lua5.4" -D PACKAGE_TARNAME="lua" -D
PACKAGE_VERSION="5.4.6" -D PACKAGE_STRING="lua5.4\ 5.4.6" -D
PACKAGE_BUGREPORT="https://bugs.gentoo.org/; -D
PACKAGE_URL="http://www.lua.org; -D PACKAGE="lua" -D VERSION="5.4.6" -D
HAVE_STDIO_H=1 -D HAVE_STDLIB_H=1 -D HAVE_STRING_H=1 -D HAVE_INTTYPES_H=1 -D
HAVE_STDINT_H=1 -D HAVE_STRINGS_H=1 -D HAVE_SYS_STAT_H=1 -D HAVE_SYS_TYPES_H=1
-D HAVE_UNISTD_H=1 -D STDC_HEADERS=1 -D HAVE_DLFCN_H=1 -D LT_OBJDIR=".libs/" -D
LUA_USE_READLINE=1 -D LUA_USE_LINUX=1 -D LUA_COMPAT_5_3 -D PIC src/lvm.c -quiet
-dumpdir src/.libs/ -dumpbase lvm.c -dumpbase-ext .c -march=i686 -mfpmath=sse
-msse -msse2 -O3 -Wall -fdiagnostics-color=always -fvect-cost-model=unlimited
-fharden-control-flow-redundancy -fpermissive -fPIC -o -
==16482==
==16482== Conditional jump or move depends on uninitialised value(s)
==16482==at 0x232FE2A: UnknownInlinedFun (sparseset.h:146)
==16482==by 0x232FE2A: mark_pseudo_regno_live(int) (ira-lives.cc:327)
==16482==by 0x2324AE3: UnknownInlinedFun (ira-lives.cc:411)
==16482==by 0x2324AE3: UnknownInlinedFun (ira-lives.cc:425)
==16482==by 0x2324AE3: process_bb_node_lives(ira_loop_tree_node*)
(ira-lives.cc:1404)
==16482==by 0x2305DF9: ira_traverse_loop_tree(bool, ira_loop_tree_node*,
void (*)(ira_loop_tree_node*), void (*)(ira_loop_tree_node*))
(ira-build.cc:1809)
==16482==by 0x26CAB8B: ira_create_allocno_live_ranges() (ira-lives.cc:1818)
==16482==by 0x22FFD84: ira_build() (ira-build.cc:3491)
==16482==by 0x26AFBC9: UnknownInlinedFun (ira.cc:5793)
==16482==by 0x26AFBC9: (anonymous namespace)::pass_ira::execute(function*)
[clone .lto_priv.0] (ira.cc:6117)
==16482==by 0x1EA53B7: execute_one_pass(opt_pass*) (passes.cc:2646)
==16482==by 0x1F716AB: execute_pass_list_1(opt_pass*) (passes.cc:2755)
==16482==by 0x1F716C8: execute_pass_list_1(opt_pass*) (passes.cc:2756)
==16482==by 0x1F713E8: execute_pass_list(function*, opt_pass*)
(passes.cc:2766)
==16482==by 0x25CC292: cgraph_node::expand() (cgraphunit.cc:1845)
==16482==by 0x1E9FF59: UnknownInlinedFun (cgraphunit.cc:2028)
==16482==by 0x1E9FF59: symbol_table::compile() (cgraphunit.cc:2402)
==16482==
==16482== Conditional jump or move depends on uninitialised value(s)
==16482==at 0x232FF24: UnknownInlinedFun (sparseset.h:146)
==16482==by 0x232FF24: UnknownInlinedFun (sparseset.h:165)
==16482==by 0x232FF24: UnknownInlinedFun (ira-lives.cc:127)
==16482==by 0x232FF24: mark_pseudo_regno_live(int) (ira-lives.cc:331)
==16482==by 0x2324AE3: UnknownInlinedFun (ira-lives.cc:411)
==16482==by 0x2324AE3: UnknownInlinedFun (ira-lives.cc:425)
==16482==by 0x2324AE3: process_bb_node_lives(ira_loop_tree_node*)
(ira-lives.cc:1404)
==16482==by 0x2305DF9: ira_traverse_loop_tree(bool, ira_loop_tree_node*,
void (*)(ira_loop_tree_node*), void (*)(ira_loop_tree_node*))
(ira-build.cc:1809)
==16482==by 0x26CAB8B: ira_create_allocno_live_ranges() (ira-lives.cc:1818)
==16482==by 0x22FFD84: ira_build() (ira-build.cc:3491)
==16482==by 0x26AFBC9: UnknownInlinedFun (ira.cc:5793)
==16482==by 0x26AFBC9: (anonymous namespace)::pass_ira::execute(function*)
[clone .lto_priv.0] (ira.cc:6117)
==16482==by 0x1EA53B7: execute_one_pass(opt_pass*) (passes.cc:2646)
==16482==by 0x1F716AB: execute_pass_list_1(opt_pass*) (passes.cc:2755)
==16482==by 0x1F716C8: execute_pass_list_1(opt_pass*) (passes.cc:2756)
==16482==by 0x1F713E8: execute_pass_list(function*, opt_pass*)
(passes.cc:2766)
==16482==by 0x25CC292: cgraph_node::expand() (cgraphunit.cc:1845)
==16482==by 0x1E9FF59: UnknownInlinedFun (cgraphunit.cc:2028)
==16482==by 0x1E9FF59: symbol_table::compile() (cgraphunit.cc:2402)
[...]
==16482== Use of uninitialised value of size 4
==16482==at 0x238D41A: UnknownInlinedFun (sparseset.h:146)
==16482==by 0x238D41A: UnknownInlinedFun (sparseset.h:165)
==16482==by 0x238D41A: make_hard_regno_live(int) (lra-lives.cc:288)
==16482==by 0x23885B7: process_bb_lives(basic_block_def*, int&, bool)
(lra-lives.cc:960)
==16482==by 0x2386343: lra_create_live_ranges_1(bool, bool)
(lra-lives.cc:1416)
==16482==by 0x2385EF0: lra_create_live_ranges(bool, bool)
(lra-lives.cc:1486)
==16482==by 0x234E372: lra(_IO_FILE*, int) (lra.cc:2482)
==16482==by 0x26D1D2F: UnknownInlinedFun (ira.cc:5973)
==16482==by 0x26D1D2F: (anonymous
namespace)::pass_reload::execute(function*) [clone .lto_priv.0] (ira.cc:6161)
==16482==by 0x1EA53B7: execute_one_pass(opt_pass*) (passes.cc:2646)
==16482==by 0x1F716AB: execute_pass_list_1(opt_pass*) (passes.cc:2755)
==16482==by 0x1F716C8: execute_pass_list_1(opt_pass*) (passes.cc:2756)
==16482==by 0x1F713E8: execute_pass_list(function*, opt_pass*)
(passes.cc:2766)
==16482==by 0x25CC292: cgraph_node::expand() 

[Bug target/114137] ICE when building lua-5.4.6 with -fharden-control-flow-redundancy on x86 (error: invalid rtl sharing found in the insn)

2024-02-27 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114137

--- Comment #2 from Sam James  ---
The bug is very reproducible with the original command, but...

I can't reproduce it with the preprocessed source or with -save-temps on the
original command line, but pinskia suggested I try --param=ggc-min-expand=1
--param=ggc-min-heapsize=1 which fixes the original crash...