This is an archive of the discontinued LLVM Phabricator instance.

[Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering
ClosedPublic

Authored by agozillon on Apr 11 2023, 12:34 PM.

Details

Summary

This patch ports the fopenmp-host-ir-file-path flag from Clang to Flang-new, this flag
is added by the driver to the device pass when doing two phase compilation (device + host).

This flag is then applied to the module when compiling during the OpenMP device phase.
This file can then be utilised during lowering of the OpenMP dialect to LLVM-IR, which
allows the device and host to maintain 1:1 mapping of OpenMP metadata for variables
during lowering via the OpenMPIRBuilders loadOffloadInfoMetadata facilities
(which is used for declare target and I believe target regions as well).

Diff Detail

Event Timeline

agozillon created this revision.Apr 11 2023, 12:34 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
agozillon requested review of this revision.Apr 11 2023, 12:35 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
agozillon edited the summary of this revision. (Show Details)Apr 11 2023, 12:36 PM

Adding missing newline

Just a small ping to keep this patch on peoples radar and to try and get some reviewer attention (I am aware you're all quite busy, so thank you very much for any time you can spare) for more review feedback to push this patch further along the pipeline!

awarzynski added inline comments.Apr 19 2023, 2:09 PM
clang/include/clang/Driver/Options.td
6562–6564

With both options using identical Flags, could you use let Flags = ?

clang/lib/Driver/ToolChains/Flang.cpp
198
200

[nit] You could refer to a specific method in Clang (I did that in the past in a few places)

flang/include/flang/Frontend/LangOptions.h
18

[nit] Empty line between

flang/lib/Frontend/CompilerInvocation.cpp
734

I think that this is expecting a bit too much from CompilerInvocation. Instead, whatever is going to use this file should complain if the file does not exist (CompilerInvocation is merely a messenger here, and file I/O can be quite expensive, hence my reservations).

Is it possible to create a test for "invalid file path" wherever this becomes relevant?

agozillon updated this revision to Diff 515305.Apr 20 2023, 6:26 AM
  • Resolve some of the reviewer comments
agozillon marked 4 inline comments as done.Apr 20 2023, 6:34 AM

Addressed 4/5 of your comments in the latest patch @awarzynski, I've replied to the final one to give a little more information to add to the final decision you make!

flang/lib/Frontend/CompilerInvocation.cpp
734

I believe the follow up patch I have here which uses the file, emits an error if it can't find it: https://reviews.llvm.org/D148370
However, in this case it's an assert rather than more useful Diagnostics unfortunately.

Although, this segment of code does currently just mimic what Clang does in it's own
CompilerInvocation: https://github.com/llvm/llvm-project/blob/main/clang/lib/Frontend/CompilerInvocation.cpp#L3883

So it depends if we wish to try to maintain the status quo for the shared argument across the compiler frontends!

So whichever you prefer, I am happy to remove the check at this level and let the lowering handle the problem if it arises :-) but I do like sharing the commonality with Clang where possible.

awarzynski added inline comments.Apr 23 2023, 9:25 AM
flang/lib/Frontend/CompilerInvocation.cpp
734

Consistency with Clang is a good idea 👍🏻 Though I would appreciate a test that demonstrates that this diagnostic is indeed issues when a non-existing files is specified :)

agozillon updated this revision to Diff 516374.Apr 24 2023, 6:01 AM
  • Resolve some of the reviewer comments
  • [Flang][OpenMP][Driver][MLIR] Add diagnostic error test
agozillon marked an inline comment as done.Apr 24 2023, 6:06 AM
agozillon added inline comments.
flang/lib/Frontend/CompilerInvocation.cpp
734

Thank you for pointing out a test was required! I've added one now :-)

awarzynski accepted this revision.Apr 24 2023, 6:29 AM

LGTM, thanks for addressing my comments!

This revision is now accepted and ready to land.Apr 24 2023, 6:29 AM
This revision was landed with ongoing or failed builds.Apr 24 2023, 8:06 AM
This revision was automatically updated to reflect the committed changes.
agozillon marked an inline comment as done.

LGTM, thanks for addressing my comments!

Thank you for your time and the great review comments as always!

awarzynski added a comment.EditedApr 24 2023, 9:04 AM

LGTM, thanks for addressing my comments!

Thank you for your time and the great review comments as always!

Thank you 🙏🏻