llvm / llvm/llvm-project

[flang][OpenMP] Assertion failure lowering `!$omp tile` with an unstructured loop body

Open
#216,701 2 comments 0 reactions 0 assignees View on GitHub
crash flang:ir flang:openmp
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Lowering an `!$omp tile` construct whose associated loop body is unstructured
fails an assertion in `createEmptyRegionBlocks`:

```
flang/include/flang/Lower/DirectivesCommon.h:57:
void Fortran::lower::createEmptyRegionBlocks(fir::FirOpBuilder &,
std::list &)
[TerminatorOps = ]:
Assertion `mlir::isa(terminatorOp) && "expected terminator op"' failed.
```

## Reproducer

`tile_unstructured.f90`:

```fortran
subroutine tile_unstructured(x, y, n)
implicit none
integer n, i, j
double precision x(*), y(*)
!$omp tile sizes(2,2)
do i = 1, n
do j = 1, n
if (x(i) > 0.0d0) then
y(1) = 0.0d0
cycle
end if
y(2) = 1.0d0
end do
end do
end subroutine
```

```
flang -fopenmp -fopenmp-version=51 -c tile_unstructured.f90
```

Contributor guide

Open the contributing guide

Research direction

Start with the reproducer in tile_unstructured.f90 and run flang -fopenmp -fopenmp-version=51 -c tile_unstructured.f90. Then inspect createEmptyRegionBlocks in flang/include/flang/Lower/DirectivesCommon.h to trace the assertion during lowering of the unstructured loop body. Done means the reproducer no longer triggers the assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
fortran
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.