This is an archive of the discontinued LLVM Phabricator instance.

[Flang][OpenMP] Fixes for unnstructured OpenMP code
ClosedPublic

Authored by kiranchandramohan on May 24 2022, 5:20 AM.

Details

Summary

Since the FIR operations are mostly structured, it is only the functions
that could contain multiple blocks inside an operation. This changes
with OpenMP since OpenMP regions can contain multiple blocks. For
unstructured code, the blocks are created in advance and belong to the
top-level function. This caused code in OpenMP region to be placed under
the function level.

In this fix, if the OpenMP region is unstructured then new blocks are
created inside it.

Note1: This is part of upstreaming from the fir-dev branch of https://github.com/flang-compiler/f18-llvm-project.
The code in this patch is a subset of the changes in https://github.com/flang-compiler/f18-llvm-project/pull/1178 by @vdonaldson.

Co-authored-by: Val Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 24 2022, 5:20 AM
kiranchandramohan requested review of this revision.May 24 2022, 5:20 AM
flang/lib/Lower/OpenMP.cpp
157–165

Remove commented code.

flang/test/Lower/OpenMP/omp-unstructured.f90
22

The code for this particular test (ss1) was previously upstreamed. Can push this separately if required.

vdonaldson accepted this revision.May 24 2022, 11:20 AM

Looks ok to me. It probably is a good idea to remove the comment block in createEmptyRegionBlocks.

This revision is now accepted and ready to land.May 24 2022, 11:20 AM

Remove commented code block.

This revision was landed with ongoing or failed builds.May 24 2022, 2:42 PM
This revision was automatically updated to reflect the committed changes.

One small question @kiranchandramohan

flang/test/Lower/OpenMP/omp-unstructured.f90
53

Don't we want an omp.terminator or some form of FIR Operation translation for this exit here? Right now, it just feels like this is missed in the !CHECK: lines. Is that intended?

flang/test/Lower/OpenMP/omp-unstructured.f90
53

There is an MLIR cond_br for the exit that branches out of the loop to bb4 if the condition is true.

shraiysh added inline comments.May 25 2022, 2:15 AM
flang/test/Lower/OpenMP/omp-unstructured.f90
53

Right, okay. I missed that. Thanks for clarifying.