Linking two pre-compiled objects from ruby-3.4.1 with lot enabled produces: SSA corruption. Compiler error does not occur if the two objects were built without enabling lto. x86_64-pc-linux-gnu-gcc -shared -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-soname,libruby34.so.3.4 -fstack-protector-strong -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs ractor.o thread.o -o libruby34.so.3.4.1 Unable to coalesce ssa_names 33 and 35 which are marked as MUST COALESCE. _ec_33(ab) and _ec_35(ab) during RTL pass: expand ../../var/tmp/portage/dev-lang/ruby-3.4.1-r1/work/ruby-3.4.1/ractor.c: In function ‘ractor_check_ints.constprop’: ../../var/tmp/portage/dev-lang/ruby-3.4.1-r1/work/ruby-3.4.1/ractor.c:592:1: internal compiler error: SSA corruption 592 | ractor_check_ints(rb_execution_context_t *ec, rb_ractor_t *cr, ractor_sleep_cleanup_function cf_func, void *cf_data) | ^ 0x5598c7ae8234 internal_error(char const*, ...) /usr/src/debug/sys-devel/gcc-15.0.1_pre20250126/gcc-15-20250126/gcc/diagnostic-global-context.cc:517 0x5598c61b8565 fail_abnormal_edge_coalesce /usr/src/debug/sys-devel/gcc-15.0.1_pre20250126/gcc-15-20250126/gcc/tree-ssa-coalesce.cc:1012 0x5598c61b8565 coalesce_partitions /usr/src/debug/sys-devel/gcc-15.0.1_pre20250126/gcc-15-20250126/gcc/tree-ssa-coalesce.cc:1444 0x5598c61b94ad coalesce_ssa_name(_var_map*) /usr/src/debug/sys-devel/gcc-15.0.1_pre20250126/gcc-15-20250126/gcc/tree-ssa-coalesce.cc:1898 0x5598c6105d61 remove_ssa_form /usr/src/debug/sys-devel/gcc-15.0.1_pre20250126/gcc-15-20250126/gcc/tree-outof-ssa.cc:1069 0x5598c6105d61 rewrite_out_of_ssa(ssaexpand*) /usr/src/debug/sys-devel/gcc-15.0.1_pre20250126/gcc-15-20250126/gcc/tree-outof-ssa.cc:1357 0x5598c5871ed3 execute /usr/src/debug/sys-devel/gcc-15.0.1_pre20250126/gcc-15-20250126/gcc/cfgexpand.cc:6955 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://bugs.gentoo.org/> for instructions. make: *** [/tmp/ccolZslg.mk:2: /tmp/ccGLHZqh.ltrans0.ltrans.o] Error 1 lto-wrapper: fatal error: make returned 2 exit status compilation terminated. /usr/lib/gcc/x86_64-pc-linux-gnu/15/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status '''' Fails (lto enabled): x86_64-pc-linux-gnu-gcc -march=native -O3 -flto -mprefer-vector-width=512 -fno-vect-cost-model -pipe -fno-omit-frame-pointer -fno-strict-aliasing -fPIC -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -o thread.o -c thread.i x86_64-pc-linux-gnu-gcc -march=native -O3 -flto -mprefer-vector-width=512 -fno-vect-cost-model -pipe -fno-omit-frame-pointer -fno-strict-aliasing -fPIC -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -o ractor.o -c ractor.i x86_64-pc-linux-gnu-gcc -shared -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-soname,libruby34.so.3.4 -fstack-protector-strong -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs ractor.o thread.o -o libruby34.so.3.4.1 '''' Works (no lto): x86_64-pc-linux-gnu-gcc -march=native -O3 -mprefer-vector-width=512 -fno-vect-cost-model -pipe -fno-omit-frame-pointer -fno-strict-aliasing -fPIC -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -o thread.o -c thread.i x86_64-pc-linux-gnu-gcc -march=native -O3 -mprefer-vector-width=512 -fno-vect-cost-model -pipe -fno-omit-frame-pointer -fno-strict-aliasing -fPIC -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -o ractor.o -c ractor.i x86_64-pc-linux-gnu-gcc -shared -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-soname,libruby34.so.3.4 -fstack-protector-strong -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs ractor.o thread.o -o libruby34.so.3.4.1
Created attachment 60340 [details] ractor.i file
Created attachment 60341 [details] thread.i file
-march=native expands to: -march=sapphirerapids -mabm -mno-sgx -mrtm -mshstk --param=l1-cache-line-size=64 --param=l1-cache-size=48 --param=l2-cache-size=76800
Reducing ...
fwiw this showed up when I started to force using `setjmp` instead of `__builtin_setjmp` in ruby a few days ago. I haven't looked at how (if at all) we treat those differently because on mobile
(In reply to Sam James from comment #5) > fwiw this showed up when I started to force using `setjmp` instead of > `__builtin_setjmp` in ruby a few days ago. I haven't looked at how (if at > all) we treat those differently because on mobile Well __builtin_setjmp should be treated as return twice but maybe it is not exactly. Anyways __builtin_setjmp should really not be used as it is not equal to setjmp which is why I assume you were forcing to use setjmp instead.
I Have ractor.i down to ~56 lines. I am reducing thread.i right now. and then will try to get a decent testcase together.
Created attachment 60345 [details] -O2 testcase (no lto required)
Created attachment 60346 [details] Further reduced and slightly cleaned up
Confirmed.
With my new reduced testcase it goes further back and fails in GCC 11.1.0 also.
Broken by cselim: - <bb 9> [local count: 713752698]: - if (_23 != 0) - goto <bb 10>; [50.00%] - else - goto <bb 11>; [50.00%] - - <bb 10> [local count: 356876349]: - _ec_4(ab)->tag = 0; - goto <bb 12>; [100.00%] - - <bb 11> [local count: 356876349]: - _ec_4(ab)->tag = 0; - - <bb 12> [local count: 1072883005]: - # _ec_6(ab) = PHI <_ec_4(ab)(11), _ec_4(ab)(10)> + <bb 9> [local count: 1072883005]: + # _ec_6(ab) = PHI <_ec_4(ab)(8)> + # cstore_22 = PHI <0(8)> + _ec_4(ab)->tag = cstore_22;
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:fbcbbfe2bf83eb8b1347144eeca37b06be5a8bb5 commit r15-7331-gfbcbbfe2bf83eb8b1347144eeca37b06be5a8bb5 Author: Richard Biener <rguenther@suse.de> Date: Mon Feb 3 09:55:50 2025 +0100 tree-optimization/118717 - store commoning vs. abnormals When we sink common stores in cselim or the sink pass we have to make sure to not introduce overlapping lifetimes for abnormals used in the ref. The easiest is to avoid sinking stmts which reference abnormals at all which is what the following does. PR tree-optimization/118717 * tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Do not common stores referencing abnormal SSA names. * tree-ssa-sink.cc (sink_common_stores_to_bb): Likewise. * gcc.dg/torture/pr118717.c: New testcase.
The releases/gcc-14 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:93e7442f0845e4ee5222a2370eb1a83d513939aa commit r14-11339-g93e7442f0845e4ee5222a2370eb1a83d513939aa Author: Richard Biener <rguenther@suse.de> Date: Mon Feb 3 09:55:50 2025 +0100 tree-optimization/118717 - store commoning vs. abnormals When we sink common stores in cselim or the sink pass we have to make sure to not introduce overlapping lifetimes for abnormals used in the ref. The easiest is to avoid sinking stmts which reference abnormals at all which is what the following does. PR tree-optimization/118717 * tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Do not common stores referencing abnormal SSA names. * tree-ssa-sink.cc (sink_common_stores_to_bb): Likewise. * gcc.dg/torture/pr118717.c: New testcase. (cherry picked from commit fbcbbfe2bf83eb8b1347144eeca37b06be5a8bb5)
The releases/gcc-13 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:08852469a263da1a05f020041c647e42c5cff09a commit r13-9394-g08852469a263da1a05f020041c647e42c5cff09a Author: Richard Biener <rguenther@suse.de> Date: Mon Feb 3 09:55:50 2025 +0100 tree-optimization/118717 - store commoning vs. abnormals When we sink common stores in cselim or the sink pass we have to make sure to not introduce overlapping lifetimes for abnormals used in the ref. The easiest is to avoid sinking stmts which reference abnormals at all which is what the following does. PR tree-optimization/118717 * tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Do not common stores referencing abnormal SSA names. * tree-ssa-sink.cc (sink_common_stores_to_bb): Likewise. * gcc.dg/torture/pr118717.c: New testcase. (cherry picked from commit fbcbbfe2bf83eb8b1347144eeca37b06be5a8bb5)
The releases/gcc-12 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:8eca273335750e100efff8f45aee285290be3c46 commit r12-11017-g8eca273335750e100efff8f45aee285290be3c46 Author: Richard Biener <rguenther@suse.de> Date: Mon Feb 3 09:55:50 2025 +0100 tree-optimization/118717 - store commoning vs. abnormals When we sink common stores in cselim or the sink pass we have to make sure to not introduce overlapping lifetimes for abnormals used in the ref. The easiest is to avoid sinking stmts which reference abnormals at all which is what the following does. PR tree-optimization/118717 * tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Do not common stores referencing abnormal SSA names. * tree-ssa-sink.cc (sink_common_stores_to_bb): Likewise. * gcc.dg/torture/pr118717.c: New testcase. (cherry picked from commit fbcbbfe2bf83eb8b1347144eeca37b06be5a8bb5)
Fixed.