[Flang][PFT] Skip continue insertion for OpenMP Loops
authorKiran Chandramohan <kiran.chandramohan@arm.com>
Mon, 5 Jun 2023 16:14:12 +0000 (16:14 +0000)
committerKiran Chandramohan <kiran.chandramohan@arm.com>
Mon, 5 Jun 2023 16:31:09 +0000 (16:31 +0000)
commit52ca6ad755b0cc2aa603cfb3124bf58c04a47005
treeb65ab0f59c4d34503464559a14255203dd5563ba
parent7a2b12b05b39bce08987968270b43ca05d9a4836
[Flang][PFT] Skip continue insertion for OpenMP Loops

Unstructured regions presents some issues for OpenMP code generation.
While there are no branches out of the OpenMP region, there can be
branches inside. This required the availability of an artificial
target at the end of an OpenMP region. This was implemented by
insertion an artifical `continue` and marking it as a target for
a branch.
(https://github.com/flang-compiler/f18-llvm-project/pull/1178)

The artificial target is not required for OpenMP loops. Since the
DO loop end can itself be a target of a branch. Moreover, insertion
of the continue between the end of the loop and the end of the
OpenMP loop construct presents problems since the OpenMP MLIR
loop construct models both the loop and the construct. This can
cause the terminator of the OpenMP loop construct to be missed.
This patch solves the issue by skipping the insertion of the
continue.

Note: This issue is only hit if the `end openmp loop` directive
is missed.

This patch fixes the issues in:
-> https://github.com/llvm/llvm-project/issues/58378
-> https://github.com/flang-compiler/f18-llvm-project/issues/1426

Fixes #58378

Reviewed By: vdonaldson

Differential Revision: https://reviews.llvm.org/D151700
flang/lib/Lower/PFTBuilder.cpp
flang/test/Lower/OpenMP/pre-fir-tree-loop.f90 [new file with mode: 0644]