[flang][OpenMP] Crash on COLLAPSE applied to TILE
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Testcase
```fortran
subroutine f(a, b, k1, k2, k3, k4)
implicit none
real :: a(:,:,:), b(:,:,:)
integer :: k1, k2, k3, k4
integer :: j1, j2, j3
!$omp target teams distribute parallel do collapse(3)
!$omp tile sizes(1,256,1)
do j1 = 1, k1
do j2 = k2, k3
do j3 = 1, k4
a(j3,j1,j2) = b(j2,j3,j1)
enddo
enddo
enddo
!$omp end tile
!$omp end target teams distribute parallel do
end
```
Compile with
`flang -c -fopenmp -fopenmp-version=60 test.f90`
Result
```
warning: OpenMP support for version 60 in flang is still incomplete
flang: /work/kparzysz/git/llvm.org/flang/lib/Lower/OpenMP/Utils.cpp:813: pft::Evaluation *Fortran::lower::omp::getNestedDoConstruct(pft::Evaluation &): Assertion `nested.getIf() && "Unexpected construct in the nested evaluations"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /work2/kparzysz/c/org/bin/flang -fc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -fopenmp -fopenmp-version=60 -resource-dir /work2/kparzysz/c/org/lib/clang/23 -mframe-pointer=all -o tile2.o -x f95 tile2.f90
#0 0x00007c833d1d01a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work2/kparzysz/c/org/bin/../lib/libLLVMSupport.so.23.0git+0x1d01a8)
#1 0x00007c833d1cd045 llvm::sys::RunSignalHandlers() (/work2/kparzysz/c/org/bin/../lib/libLLVMSupport.so.23.0git+0x1cd045)
#2 0x00007c833d1d0fc1 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007c833c842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007c833c8969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007c833c8969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007c833c8969fc pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007c833c842476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007c833c8287f3 abort ./stdlib/abort.c:81:7
#9 0x00007c833c82871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007c833c839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00007c833b3c9a21 (/work2/kparzysz/c/org/bin/../lib/../lib/libFortranLower.so.23.0git+0x5c9a21)
#12 0x00007c833b31a13d Fortran::lower::omp::ClauseProcessor::processCollapse(mlir::Location, Fortran::lower::pft::Evaluation&, mlir::omp::LoopRelatedClauseOps&, mlir::omp::CollapseClauseOps&, llvm::SmallVectorImpl&) const (/work2/kparzysz/c/org/bin/../lib/../lib/libFortranLower.so.23.0git+0x51a13d)
#13 0x00007c833b3ae398 std::_Function_handler const&), processHostEvalClauses(Fortran::lower::AbstractConverter&, Fortran::semantics::SemanticsContext&, Fortran::lower::StatementContext&, Fortran::lower::pft::Evaluation&, mlir::Location)::$_0>::_M_invoke(std::_Any_data const&, Fortran::lower::pft::Evaluation&, llvm::SmallVector const&) OpenMP.cpp:0:0
#14 0x00007c833b3a265f genOMPDispatch(Fortran::lower::AbstractConverter&, Fortran::lower::SymMap&, Fortran::semantics::SemanticsContext&, Fortran::lower::pft::Evaluation&, mlir::Location, llvm::SmallVector, 0u> const&, tomp::DirectiveWithClauses const*) OpenMP.cpp:0:0
#15 0x00007c833b396ddc void Fortran::common::log2visit::Log2VisitHelper<0ul, 11ul, void, genOMP(Fortran::lower::AbstractConverter&, Fortran::lower::SymMap&, Fortran::semantics::SemanticsContext&, Fortran::lower::pft::Evaluation&, Fortran::parser::OpenMPConstruct const&)::$_0, std::variant const&>(genOMP(Fortran::lower::AbstractConverter&, Fortran::lower::SymMap&, Fortran::semantics::SemanticsContext&, Fortran::lower::pft::Evaluation&, Fortran::parser::OpenMPConstruct const&)::$_0&&, unsigned long, std::variant const&) OpenMP.cpp:0:0
#16 0x00007c833b39100a Fortran::lower::genOpenMPConstruct(Fortran::lower::AbstractConverter&, Fortran::lower::SymMap&, Fortran::semantics::SemanticsContext&, Fortran::lower::pft::Evaluation&, Fortran::parser::OpenMPConstruct const&) (/work2/kparzysz/c/org/bin/../lib/../lib/libFortranLower.so.23.0git+0x59100a)
#17 0x00007c833af6d694 auto auto Fortran::lower::pft::ReferenceVariantBase::visit<(anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&, bool)::'lambda'(auto const&)>(auto&&) const::'lambda'(auto)::operator()>(auto) const Bridge.cpp:0:0
#18 0x00007c833af39042 (anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&, bool) Bridge.cpp:0:0
#19 0x00007c833af72621 (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
#20 0x00007c833af2ea4e Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&) (/work2/kparzysz/c/org/bin/../lib/../lib/libFortranLower.so.23.0git+0x12ea4e)
#21 0x00007c8344399d7b Fortran::frontend::CodeGenAction::beginSourceFileAction() (/work2/kparzysz/c/org/bin/../lib/libflangFrontend.so.23.0git+0x147d7b)
#22 0x00007c8344397219 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/work2/kparzysz/c/org/bin/../lib/libflangFrontend.so.23.0git+0x145219)
#23 0x00007c8344271b43 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/work2/kparzysz/c/org/bin/../lib/libflangFrontend.so.23.0git+0x1fb43)
#24 0x00007c8344c19c1a Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/work2/kparzysz/c/org/bin/../lib/libflangFrontendTool.so.23.0git+0x4c1a)
#25 0x000057ab6249da3c fc1_main(llvm::ArrayRef, char const*) (/work2/kparzysz/c/org/bin/flang+0x8a3c)
#26 0x000057ab6249bc4a main (/work2/kparzysz/c/org/bin/flang+0x6c4a)
#27 0x00007c833c829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#28 0x00007c833c829e40 call_init ./csu/../csu/libc-start.c:128:20
#29 0x00007c833c829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#30 0x000057ab6249a9e5 _start (/work2/kparzysz/c/org/bin/flang+0x59e5)
flang-23: error: unable to execute command: Aborted (core dumped)
flang-23: error: flang frontend command failed with exit code -2 (use -v to see invocation)
flang version 23.0.0git (https://github.com/llvm/llvm-project af7c352fa38d49096888df6c99d010d274362aa6)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /work2/kparzysz/c/org/bin
Build config: +assertions
flang-23: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-23: note: diagnostic msg: /tmp/tile2-08b758
flang-23: note: diagnostic msg: /tmp/tile2-08b758.sh
flang-23: note: diagnostic msg:
********************
```
Contributor guide
Research direction
Start by reproducing the supplied Fortran testcase with flang -c -fopenmp -fopenmp-version=60. Trace ClauseProcessor::processCollapse in flang/lib/Lower/OpenMP/Utils.cpp, especially getNestedDoConstruct and the assertion at line 813, then add a regression test using this testcase. Done means the compiler no longer aborts when COLLAPSE is applied to TILE and the regression test passes.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100