Issue 176275
Summary [flang] Segmentation fault when parsing nested loop in OpenMP region
Labels flang
Assignees
Reporter ivan-pi
    When trying to compile the following OpenMP program flang 21 crashes with the error copied below. If I comment out the `ir` loop (L22-L24) it works.

```
! mwe.F90
module mwe
implicit none
#ifdef VERBOSE_MODE
logical, private :: VERBOSE = .true.
#else
logical, private :: VERBOSE = .false.
#endif
contains
   subroutine f(nd,nz,nq)
 integer, intent(in) :: nd, nz, nq
      integer, parameter :: ni = 2
 real, allocatable :: B(:,:,:)
      integer :: ib, ii
      allocate(B(nz, nq, ni))
      !$omp parallel do
      do ib = 1, nd
         if (VERBOSE) then
            block
               integer :: ir, ic
               do ii = 1, ni
                  do ir = 1, nz
                     write(*,*) (B(ir,ic,ii),ic=1,nq)
                  end do
               end do
 end block
         end if
      end do
   end subroutine
end module
```

```
$ flang -fopenmp mwe.f90
PLEASE submit a bug report to https://github.com/Homebrew/homebrew-core/issues and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/homebrew/Cellar/flang/21.1.8/libexec/flang -fc1 -triple arm64-apple-macosx26.0.0 -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -target-cpu apple-m1 -target-feature +v8.4a -target-feature +aes -target-feature +altnzcv -target-feature +ccdp -target-feature +ccpp -target-feature +complxnum -target-feature +crc -target-feature +dotprod -target-feature +flagm -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +fptoint -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +neon -target-feature +pauth -target-feature +perfmon -target-feature +predres -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sb -target-feature +sha2 -target-feature +sha3 -target-feature +specrestrict -target-feature +ssbs -fopenmp -resource-dir /opt/homebrew/opt/llvm/lib/clang/21 -mframe-pointer=non-leaf -o /var/folders/5h/txm_8yhd2n721_w7gsrvlkj8p3bpj9/T/mwe-7c2d62.o -x f95 mwe.f90
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM.dylib              0x0000000117707118 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  libLLVM.dylib 0x000000011770795c SignalHandler(int, __siginfo*, void*) + 372
2 libsystem_platform.dylib   0x00000001885d3744 _sigtramp + 56
3 libFortranLower.dylib      0x00000001045046e8 void Fortran::lower::privatizeSymbol<mlir::omp::PrivateClauseOp, mlir::omp::PrivateClauseOps>(Fortran::lower::AbstractConverter&, fir::FirOpBuilder&, Fortran::lower::SymMap&, llvm::SetVector<Fortran::semantics::Symbol const*, llvm::SmallVector<Fortran::semantics::Symbol const*, 0u>, llvm::DenseSet<Fortran::semantics::Symbol const*, llvm::DenseMapInfo<Fortran::semantics::Symbol const*, void>>, 0u>&, llvm::SmallSet<Fortran::semantics::Symbol const*, 16u, std::__1::less<Fortran::semantics::Symbol const*>>&, Fortran::semantics::Symbol const*, mlir::omp::PrivateClauseOps*) + 124
4 libFortranLower.dylib      0x0000000104483cf4 Fortran::lower::omp::DataSharingProcessor::privatize(mlir::omp::PrivateClauseOps*) + 92
5  libFortranLower.dylib      0x0000000104482868 Fortran::lower::omp::DataSharingProcessor::processStep1(mlir::omp::PrivateClauseOps*) + 180
6  libFortranLower.dylib      0x000000010449ca18 genOMPDispatch(Fortran::lower::AbstractConverter&, Fortran::lower::SymMap&, Fortran::semantics::SemanticsContext&, Fortran::lower::pft::Evaluation&, mlir::Location, llvm::SmallVector<tomp::DirectiveWithClauses<Fortran::lower::omp::Clause>, 0u> const&, tomp::DirectiveWithClauses<Fortran::lower::omp::Clause> const*) + 13256
7  libFortranLower.dylib      0x00000001044a4b44 createBodyOfOp(mlir::Operation&, OpWithBodyGenInfo const&, llvm::SmallVector<tomp::DirectiveWithClauses<Fortran::lower::omp::Clause>, 0u> const&, tomp::DirectiveWithClauses<Fortran::lower::omp::Clause> const*) + 3888
8  libFortranLower.dylib      0x000000010449e5fc genOMPDispatch(Fortran::lower::AbstractConverter&, Fortran::lower::SymMap&, Fortran::semantics::SemanticsContext&, Fortran::lower::pft::Evaluation&, mlir::Location, llvm::SmallVector<tomp::DirectiveWithClauses<Fortran::lower::omp::Clause>, 0u> const&, tomp::DirectiveWithClauses<Fortran::lower::omp::Clause> const*) + 20396
9  libFortranLower.dylib      0x00000001044a3924 genOMP(Fortran::lower::AbstractConverter&, Fortran::lower::SymMap&, Fortran::semantics::SemanticsContext&, Fortran::lower::pft::Evaluation&, Fortran::parser::OpenMPLoopConstruct const&) + 660
10 libFortranLower.dylib 0x0000000104496f5c Fortran::lower::genOpenMPConstruct(Fortran::lower::AbstractConverter&, Fortran::lower::SymMap&, Fortran::semantics::SemanticsContext&, Fortran::lower::pft::Evaluation&, Fortran::parser::OpenMPConstruct const&) + 200
11 libFortranLower.dylib      0x000000010404f2d0 void Fortran::common::log2visit::Log2VisitHelper<83ul, 93ul, void, Fortran::common::visitors<auto Fortran::lower::pft::ReferenceVariantBase<true, Fortran::parser::AllocateStmt, Fortran::parser::AssignmentStmt, Fortran::parser::BackspaceStmt, Fortran::parser::CallStmt, Fortran::parser::CloseStmt, Fortran::parser::ContinueStmt, Fortran::parser::CycleStmt, Fortran::parser::DeallocateStmt, Fortran::parser::EndfileStmt, Fortran::parser::EventPostStmt, Fortran::parser::EventWaitStmt, Fortran::parser::ExitStmt, Fortran::parser::FailImageStmt, Fortran::parser::FlushStmt, Fortran::parser::FormTeamStmt, Fortran::parser::GotoStmt, Fortran::parser::IfStmt, Fortran::parser::InquireStmt, Fortran::parser::LockStmt, Fortran::parser::NotifyWaitStmt, Fortran::parser::NullifyStmt, Fortran::parser::OpenStmt, Fortran::parser::PointerAssignmentStmt, Fortran::parser::PrintStmt, Fortran::parser::ReadStmt, Fortran::parser::ReturnStmt, Fortran::parser::RewindStmt, Fortran::parser::StopStmt, Fortran::parser::SyncAllStmt, Fortran::parser::SyncImagesStmt, Fortran::parser::SyncMemoryStmt, Fortran::parser::SyncTeamStmt, Fortran::parser::UnlockStmt, Fortran::parser::WaitStmt, Fortran::parser::WhereStmt, Fortran::parser::WriteStmt, Fortran::parser::ComputedGotoStmt, Fortran::parser::ForallStmt, Fortran::parser::ArithmeticIfStmt, Fortran::parser::AssignStmt, Fortran::parser::AssignedGotoStmt, Fortran::parser::PauseStmt, Fortran::parser::EntryStmt, Fortran::parser::FormatStmt, Fortran::parser::AssociateStmt, Fortran::parser::EndAssociateStmt, Fortran::parser::BlockStmt, Fortran::parser::EndBlockStmt, Fortran::parser::SelectCaseStmt, Fortran::parser::CaseStmt, Fortran::parser::EndSelectStmt, Fortran::parser::ChangeTeamStmt, Fortran::parser::EndChangeTeamStmt, Fortran::parser::CriticalStmt, Fortran::parser::EndCriticalStmt, Fortran::parser::NonLabelDoStmt, Fortran::parser::EndDoStmt, Fortran::parser::IfThenStmt, Fortran::parser::ElseIfStmt, Fortran::parser::ElseStmt, Fortran::parser::EndIfStmt, Fortran::parser::SelectRankStmt, Fortran::parser::SelectRankCaseStmt, Fortran::parser::SelectTypeStmt, Fortran::parser::TypeGuardStmt, Fortran::parser::WhereConstructStmt, Fortran::parser::MaskedElsewhereStmt, Fortran::parser::ElsewhereStmt, Fortran::parser::EndWhereStmt, Fortran::parser::ForallConstructStmt, Fortran::parser::EndForallStmt, Fortran::parser::EndProgramStmt, Fortran::parser::EndFunctionStmt, Fortran::parser::EndSubroutineStmt, Fortran::parser::EndMpSubprogramStmt, Fortran::parser::AssociateConstruct, Fortran::parser::BlockConstruct, Fortran::parser::CaseConstruct, Fortran::parser::ChangeTeamConstruct, Fortran::parser::CriticalConstruct, Fortran::parser::DoConstruct, Fortran::parser::IfConstruct, Fortran::parser::SelectRankConstruct, Fortran::parser::SelectTypeConstruct, Fortran::parser::WhereConstruct, Fortran::parser::ForallConstruct, Fortran::parser::CompilerDirective, Fortran::parser::OpenACCConstruct, Fortran::parser::OpenACCRoutineConstruct, Fortran::parser::OpenACCDeclarativeConstruct, Fortran::parser::OpenMPConstruct, Fortran::parser::OpenMPDeclarativeConstruct, Fortran::parser::OmpEndLoopDirective, Fortran::parser::CUFKernelDoConstruct>::visit<(anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&, bool)::'lambda'(auto const&)>(auto&&) const::'lambda'(auto)>, std::__1::variant<Fortran::common::Reference<Fortran::parser::AllocateStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::AssignmentStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::BackspaceStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::CallStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::CloseStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ContinueStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::CycleStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::DeallocateStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndfileStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EventPostStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EventWaitStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ExitStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::FailImageStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::FlushStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::FormTeamStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::GotoStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::IfStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::InquireStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::LockStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::NotifyWaitStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::NullifyStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::OpenStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::PointerAssignmentStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::PrintStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ReadStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ReturnStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::RewindStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::StopStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::SyncAllStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::SyncImagesStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::SyncMemoryStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::SyncTeamStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::UnlockStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::WaitStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::WhereStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::WriteStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ComputedGotoStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ForallStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ArithmeticIfStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::AssignStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::AssignedGotoStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::PauseStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EntryStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::FormatStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::AssociateStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndAssociateStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::BlockStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndBlockStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::SelectCaseStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::CaseStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndSelectStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ChangeTeamStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndChangeTeamStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::CriticalStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndCriticalStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::NonLabelDoStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndDoStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::IfThenStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ElseIfStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ElseStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndIfStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::SelectRankStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::SelectRankCaseStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::SelectTypeStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::TypeGuardStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::WhereConstructStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::MaskedElsewhereStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ElsewhereStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndWhereStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::ForallConstructStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndForallStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndProgramStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndFunctionStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndSubroutineStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::EndMpSubprogramStmt const>, Fortran::parser::AllocateStmt const<Fortran::parser::AssociateConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::BlockConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::CaseConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::ChangeTeamConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::CriticalConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::DoConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::IfConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::SelectRankConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::SelectTypeConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::WhereConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::ForallConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::CompilerDirective const>, Fortran::parser::AllocateStmt const<Fortran::parser::OpenACCConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::OpenACCRoutineConstruct const>, Fortran::parser::AllocateStmt const<Fortran::parser::OpenACCDeclarativeConstruct const>, Fortran::parser::AllocateStmt const<Fortra<truncated>Please see the issue for the entire body.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to