https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111074

            Bug ID: 111074
           Summary: RISC-V: segmentation fault during RTL pass: vsetvl
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: maksim.shabunin at gmail dot com
  Target Milestone: ---

Created attachment 55764
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55764&action=edit
Preprocessed source file

We are experiencing issues when building the OpenCV library for RISC-V with RVV
support:

    /work/chains/riscv-gcc-13.2.1/bin/riscv64-unknown-linux-gnu-g++
--sysroot=/work/chains/riscv-gcc-13.2.1/sysroot -D_USE_MATH_DEFINES
-D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS -I/work/opencv/modules/imgproc/include
-I/work/build-opencv-rvv/modules/imgproc -I/work/opencv/modules/core/include
-isystem /work/build-opencv-rvv -march=rv64gc  -fmax-errors=1 -Wfatal-errors
-fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress
-Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef
-Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized
-Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment
-Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option
-pthread -fomit-frame-pointer -ffunction-sections -fdata-sections 
-march=rv64gcv1p0 -DCV_RVV_SCALABLE -fvisibility=hidden
-fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG -fPIC -std=c++11 -MD -MT
modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/box_filter.dispatch.cpp.o -MF
modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/box_filter.dispatch.cpp.o.d
-o modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/box_filter.dispatch.cpp.o
-c /work/opencv/modules/imgproc/src/box_filter.dispatch.cpp -freport-bug
    during RTL pass: vsetvl
    In file included from
/work/opencv/modules/imgproc/src/box_filter.dispatch.cpp:53:
    /work/opencv/modules/imgproc/src/box_filter.simd.hpp: In member function
'virtual void cv::cpu_baseline::{anonymous}::ColumnSum<int,
float>::operator()(const cv::hal_baseline::uchar**, cv::hal_baseline::uchar*,
int, int, int)':
    /work/opencv/modules/imgproc/src/box_filter.simd.hpp:1162:5: internal
compiler error: Segmentation fault
     1162 |     }
          |     ^
    0xe038c3 crash_signal
        ../.././gcc/gcc/toplev.cc:314
    0x7fb2b9e4251f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
    0x6bdea2 hash_set<rtl_ssa::set_info*, false,
default_hash_traits<rtl_ssa::set_info*> >::iterator::operator*()
        ../.././gcc/gcc/hash-set.h:125
    0x6bdea2 extract_single_source
        ../.././gcc/gcc/config/riscv/riscv-vsetvl.cc:1186
    0x6bdea2 extract_single_source
        ../.././gcc/gcc/config/riscv/riscv-vsetvl.cc:1176
    0x119ae7e pass_vsetvl::propagate_avl() const
        ../.././gcc/gcc/config/riscv/riscv-vsetvl.cc:4089
    0x119cf8f pass_vsetvl::execute(function*)
        ../.././gcc/gcc/config/riscv/riscv-vsetvl.cc:4346
    0x119cf8f pass_vsetvl::execute(function*)
        ../.././gcc/gcc/config/riscv/riscv-vsetvl.cc:4327
    Please submit a full bug report, with preprocessed source.
    Please include the complete backtrace with any bug report.
    See <https://gcc.gnu.org/bugs/> for instructions.
    The bug is not reproducible, so it is likely a hardware or OS problem.


* Compiler version is:
    riscv64-unknown-linux-gnu-g++ (g91a5bdf2941) 13.2.1 20230818
* Issue does not reproduce with -fwrapv option.
* Preprocessed file is in the attachment (compressed), problematic loop starts
at line 86506.

We did not manage to make minimal reproducer, but we've been able to avoid it
by disabling one RVV-optimized block in our code (CV_SIMD_SCALABLE is enabled
for RVV), it does not look very different from other optimized blocks in this
or other files:
https://github.com/opencv/opencv/pull/24166/commits/8ab6c22e9a04f84cf1bf65e17c72f05e0b2b0825

Reply via email to