This is an archive of the discontinued LLVM Phabricator instance.

[Flang,MLIR,OpenMP] Fix a few tests that were not converting to LLVM
ClosedPublic

Authored by kiranchandramohan on Jun 6 2022, 2:59 AM.

Details

Summary

A few OpenMP tests were retaining the FIR operands even after running
the LLVM conversion pass. To fix these tests the legality checkes for
OpenMP conversion are made stricter to include operands and results.
The Flush, Single and Sections operations are added to conversions or
legality checks. The RegionLessOpConversion is appropriately renamed
to clarify that it works only for operations with Variable operands.
The operands of the flush operation are changed to match those of
Variable Operands.

Fix for an OpenMP issue mentioned in
https://github.com/llvm/llvm-project/issues/55210.

Diff Detail

Event Timeline

Herald added a reviewer: ftynse. · View Herald Transcript
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
kiranchandramohan requested review of this revision.Jun 6 2022, 2:59 AM
shraiysh accepted this revision.Jun 6 2022, 3:04 AM

LGTM. Thank you!

This revision is now accepted and ready to land.Jun 6 2022, 3:04 AM
awarzynski added inline comments.Jun 6 2022, 3:27 AM
flang/test/Lower/OpenMP/flush.f90
12–13

[nit] I'd be inclined to change this to:

!LLVMIRDialect-NOT: ((.*}}!fir{{.*}}

Basically, the actual operation is irrelevant. What's important is the fhat there are no fir operations. And once you keep it generic, you will never have to worry about the type of the operation (might be handy when fir.ref is replaced with something else).

peixin accepted this revision.Jun 6 2022, 4:08 AM

LGTM

flang/test/Lower/OpenMP/flush.f90
4

Nit: Should this be moved to test/Fir since the tests under Lower/OpenMP are targeted for lowering test? It's also OK to do this when you upstream and refactor all the OpenMP lowering tests.

Fix MLIR tests.

flang/test/Lower/OpenMP/flush.f90
4

Yes, will do this as a separate patch.

12–13

As @peixin suggests above, we will move the conversion test to a different file. This test will only retain the FIR+OpenMP lowering and in that case, retaining the FIR type is important.

awarzynski added inline comments.Jun 6 2022, 5:19 AM
flang/test/Lower/OpenMP/flush.f90
12–13

So you'll be removing the fir-to-llvm-ir conversion from here?

Also, after re-rereading this, I'm finally realizing what was meant here. Below is my interpretation:

!FIRDialect: omp.flush(%{{.*}}, %{{.*}}, %{{.*}} : !fir.ref<i32>, !fir.ref<i32>, !fir.ref<i32>)
!LLVMIRDialect: omp.flush(%{{.*}}, %{{.*}}, %{{.*}} : !llvm.ptr<i32>, !llvm.ptr<i32>, !llvm.ptr<i32>)

I probably would prefer the above (it's more explicit). For the following, it is hard to guess that !OMPDialect and !FIRDialect/!LLVMDialect are to be matched on the same line:

!OMPDialect: omp.flush(%{{.*}}, %{{.*}}, %{{.*}} :
!FIRDialect: !fir.ref<i32>, !fir.ref<i32>, !fir.ref<i32>)
!LLVMIRDialect: !llvm.ptr<i32>, !llvm.ptr<i32>, !llvm.ptr<i32>)

I think that the real problem here is that lowering and conversion are tested in one file, but that's going to change anyway, right?

flang/test/Lower/OpenMP/flush.f90
12–13

Yes, we will be moving fir-to-llvm-conversion to a separate test file that tests the conversion to LLVM.

Yes, you are correct that the real problem is the twin testing in this file. Once it moves then we will be replacing all these with just CHECK lines and the operation and the operands will hence be in the same line.

Given the above, is it OK to proceed with this patch as it is?