Closed erykoff closed 3 years ago
thanks for the report, however it does not reproduce for me with a build from the current sources:
$ /opt/iains/aarch64-apple-darwin20/gcc-11-0-1/bin/gfortran --version GNU Fortran (GCC) 11.0.1 20210313 (experimental) [master-wip-apple-si revision r11-7708-g3d132a12726b]
$ /opt/iains/aarch64-apple-darwin20/gcc-11-0-1/bin/gfortran /src-local/specfun.f -O2 -ftree-slp-vectorize -S $ echo $? 0
$ /opt/iains/aarch64-apple-darwin20/gcc-11-0-1/bin/gfortran /src-local/specfun.f -O2 -ftree-loop-vectorize -S $ echo $? 0
Ah! It may be fixed on master, sorry I wasn't more thorough in my report. I was having trouble building and only had easy access to the latest hash released on conda-forge
.
Thanks @erykoff for opening this issue and @iains for confirming.
@erykoff, it looks like the segfault occurs only in our osx-x86_64->osx-arm64
cross compiler and not the native compiler.
With further investigation, it seems that this happens on the cross-compiler (at least) with the addition of -march=armv8.3-a
which is set with the conda forge FFLAGS
.
FWIW, I build a x86_64 X aarch64 every week on x86-64-darwin20 (and an aarch64 target/host built on x86_64 so a "native" or "canadian" cross). here:
$ /opt/iains/x86_64-apple-darwin20/gcc-11-0-1-asi/bin/aarch64-apple-darwin20-gfortran --version GNU Fortran (GCC) 11.0.1 20210313 (experimental) Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ /opt/iains/x86_64-apple-darwin20/gcc-11-0-1-asi/bin/aarch64-apple-darwin20-gfortran /source/test/fortran/specfun.f -O2 -ftree-loop-vectorize -S -w
seems OK there too.
@erykoff, I can reproduce with conda-forge compilers with -march=armv8.3-a -O2 -ftree-loop-vectorize
. I'll try updating to latest master.
adding -march=armv8.3-a makes no difference to either my native or cross compiler (at least with -O2 -ftree-loop-vectorize)
Of course, this is an experimental branch :)
Of course, this is an experimental branch :)
Of course and many thanks for doing the work to port gcc to aaarch64-apple-darwin. We @conda-forge and all our users appreciate it.
Latest commit fixes this segfault. This issue can be closed.
With e330c4193fcc9dfd030d14b309b573753aa0afb0, there's a new segfault.
compiling https://raw.githubusercontent.com/Reference-LAPACK/lapack/master/BLAS/SRC/cgemv.f
with
gfortran cgemv.f -O2 -march=armv8.3-a -ftree-vectorize -fPIC -fno-stack-protector -c
errors with,
during GIMPLE pass: slp
cgemv.f:157:22:
157 | SUBROUTINE CGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
| ^
internal compiler error: in vect_slp_analyze_node_operations_1, at tree-vect-slp.c:3727
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
whereas gfortran cgemv.f -O2 -march=armv8.2-a -ftree-vectorize -fPIC -fno-stack-protector -c
doesn't
I see this also on an x86_64 => aarch64 cross - here's the backtrace.
I think the next thing to check is whether this fires for a non-Darwin case - this is not part of the compiler I've touched with my port.
frame #3: 0x00000001017da973 f951`::__second_sect_of_vect_slp_analyze_node_operations() at tree-vect-slp.c:3727:3
frame #4: 0x00000001011e1d86 f951`::vect_slp_analyze_node_operations(vinfo=0x0000000144d1b210, node=<unavailable>, node_instance=0x0000000144d6e580, visited_set=0x00007ffeefbff030, visited_vec=<unavailable>, cost_vec=0x00007ffeefbff060) at tree-vect-slp.c:3913:46
frame #5: 0x00000001011e1d86 f951`::vect_slp_analyze_node_operations(vinfo=0x0000000144d1b210, node=<unavailable>, node_instance=0x0000000144d6e580, visited_set=0x00007ffeefbff030, visited_vec=<unavailable>, cost_vec=0x00007ffeefbff060) at tree-vect-slp.c:3913:46
frame #6: 0x00000001011e1d86 f951`::vect_slp_analyze_node_operations(vinfo=0x0000000144d1b210, node=<unavailable>, node_instance=0x0000000144d6e580, visited_set=0x00007ffeefbff030, visited_vec=<unavailable>, cost_vec=0x00007ffeefbff060) at tree-vect-slp.c:3913:46
frame #7: 0x00000001011e1d86 f951`::vect_slp_analyze_node_operations(vinfo=0x0000000144d1b210, node=<unavailable>, node_instance=0x0000000144d6e580, visited_set=0x00007ffeefbff030, visited_vec=<unavailable>, cost_vec=0x00007ffeefbff060) at tree-vect-slp.c:3913:46
frame #8: 0x00000001011e1d86 f951`::vect_slp_analyze_node_operations(vinfo=0x0000000144d1b210, node=<unavailable>, node_instance=0x0000000144d6e580, visited_set=0x00007ffeefbff030, visited_vec=<unavailable>, cost_vec=0x00007ffeefbff060) at tree-vect-slp.c:3913:46
frame #9: 0x00000001011e1d86 f951`::vect_slp_analyze_node_operations(vinfo=0x0000000144d1b210, node=<unavailable>, node_instance=0x0000000144d6e580, visited_set=0x00007ffeefbff030, visited_vec=<unavailable>, cost_vec=0x00007ffeefbff060) at tree-vect-slp.c:3913:46
frame #10: 0x00000001011e4af6 f951`vect_slp_analyze_operations(vinfo=<unavailable>) at tree-vect-slp.c:4120:45
frame #11: 0x00000001011e88a3 f951`::vect_slp_region(bbs=<unavailable>, datarefs=<unavailable>, dataref_groups=0x00007ffeefbff318, n_stmts=746) at tree-vect-slp.c:4899:36
frame #12: 0x00000001011ea630 f951`::vect_slp_bbs(bbs=vec<basic_block_def*, va_heap, vl_ptr> @ r14) at tree-vect-slp.c:5095:26
frame #13: 0x00000001011eaa5d f951`vect_slp_function(fun=0x00000001437e3000) at tree-vect-slp.c:5181:23
frame #14: 0x00000001011ee92a f951`pass_slp_vectorize::execute(this=<unavailable>, fun=0x00000001437e3000) const at tree-vectorizer.c:1450:21
frame #15: 0x0000000100db0ba2 f951`execute_one_pass(pass=0x0000000143512650) at passes.c:2567:30
frame #16: 0x0000000100db14b3 f951`::execute_pass_list_1(pass=0x0000000143512650) at passes.c:2656:28
frame #17: 0x0000000100db14c5 f951`::execute_pass_list_1(pass=0x0000000143511bd0) at passes.c:2657:22
frame #18: 0x0000000100db14c5 f951`::execute_pass_list_1(pass=0x0000000143510910) at passes.c:2657:22
frame #19: 0x0000000100db14f2 f951`execute_pass_list(fn=0x00000001437e3000, pass=<unavailable>) at passes.c:2667:23
frame #20: 0x0000000100895861 f951`cgraph_node::expand(this=0x00000001437f4000) at cgraphunit.c:1830:21
frame #21: 0x00000001008969cf f951`symbol_table::compile() at cgraphunit.c:1998:17
frame #22: 0x00000001008967bd f951`symbol_table::compile(this=<unavailable>)
frame #23: 0x0000000100899d76 f951`symbol_table::finalize_compilation_unit() [inlined] symbol_table::compile(this=<unavailable>) at cgraphunit.c:2275:3
frame #24: 0x0000000100899d65 f951`symbol_table::finalize_compilation_unit(this=0x0000000143606000)
frame #25: 0x0000000100ed3e11 f951`::compile_file() at toplev.c:482:41
frame #26: 0x0000000101817270 f951`toplev::main(int, char**) at toplev.c:2201:24
frame #27: 0x0000000101816f3e f951`toplev::main(this=0x00007ffeefbff73e, argc=<unavailable>, argv=<unavailable>)
frame #28: 0x0000000101819481 f951`main(argc=24, argv=0x00007ffeefbff770) at main.c:39:22
As suspected, not specific to the Darwin port.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99807 Bug 99807 - [11 Regression] ICE in vect_slp_analyze_node_operations_1, at tree-vect-slp.c:3727
This is fixed on master, the fix was 29 March, so will be pulled in on the next rebase (end of this week).
my local testing shows this fixed with the just-pushed branch. Please check and close this if so ...
Yes, it works for me. Thanks. @erykoff, we can close this issue.
Somewhere between commit https://github.com/iains/gcc-darwin-arm64/commits/62cfbb7cf8a06c2ec07d3343bfdc67ca8123239e and https://github.com/iains/gcc-darwin-arm64/commits/02d30eeb2534a593216564c07e94f4d49f0b679e (corresponding to builds 17 and 18 on conda-forge, https://github.com/conda-forge/gfortran_impl_osx-64-feedstock/commit/9656879871750f281983f16c31bf68894257695e ), the fortran compiler can segmentation fault on certain source files.
Specifically, https://github.com/scipy/scipy/blob/master/scipy/special/specfun/specfun.f will cause the compiler to segmentation fault if compiled with
-O2 -ftree-loop-vectorize
or-O2 -ftree-slp-vectorize
.