This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][OpenMPIRBuilder] Migrate loadOffloadInfoMetadata from clang to OMPIRbuilder
ClosedPublic

Authored by TIFitis on Oct 27 2022, 11:48 AM.

Details

Summary

This patch moves the implementation of the loadOffloadInfoMetadata to the OMPIRbuilder.

Diff Detail

Event Timeline

TIFitis created this revision.Oct 27 2022, 11:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2022, 11:48 AM
TIFitis published this revision for review.Oct 27 2022, 11:50 AM
TIFitis added reviewers: ABataev, jhuber6.
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 27 2022, 11:50 AM
jdoerfert added inline comments.Oct 27 2022, 12:13 PM
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
2180

Why is this in llvm namespace? This should be qualified further, e.g. part of the OMPIRBuilder. Also, no llvm::

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
4717

Why do we call it if isDevice is false? Module should be available to the IRBuilder.

4765

No llvm::. Put "omp_offload.info" into a global constant, either in OMPIRBuilder or OMPConstants.

TIFitis updated this revision to Diff 471528.Oct 28 2022, 6:40 AM

Moved loadOffloadInfoMetadata inside OpenMPIRBuilder class.

TIFitis marked 3 inline comments as done.Oct 28 2022, 6:44 AM
TIFitis added inline comments.
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
4717

loadOffloadInfoMetadata is called from clang with a different Module generated using parseBitcodeFile. I've checked that the module available from OMPIRBuilder and the one passed by clang are different and cause errors.

TIFitis marked an inline comment as done and an inline comment as not done.Oct 28 2022, 6:45 AM

@jsjodin Can you take a look and accept once it looks ok.

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
4717

I see. Then document this explicitly in the doxygen comment of the declaration, please. Also check isDevice at the call site.

TIFitis updated this revision to Diff 471672.Oct 28 2022, 3:23 PM

Added doxygen comment to explain why module must be passed to OMPIRBuilder.

TIFitis marked an inline comment as done.Oct 28 2022, 3:27 PM
TIFitis added inline comments.
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
4717

Added doxygen comment. isDevice is checked at call site through CGM.getLangOpts().OpenMPIsDevice.

TIFitis updated this revision to Diff 471674.Oct 28 2022, 3:31 PM
TIFitis marked an inline comment as done.

Removed isDevice() check from function definition.

TIFitis updated this revision to Diff 472041.Oct 31 2022, 9:06 AM

Fix build errors

jsjodin added inline comments.Oct 31 2022, 11:44 AM
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
4712

isDevice must be true (add assertion at the call site) remove the parameter, and the assertions in this function. Document that this function is only intended to be used with device code generation.

jdoerfert added inline comments.Oct 31 2022, 11:58 AM
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
1685

Drive by, add doxygen documentation to all methods + members please.

TIFitis updated this revision to Diff 472094.Oct 31 2022, 12:23 PM

Removed isDevice from parameters. Added documentation.

TIFitis marked 2 inline comments as done.Oct 31 2022, 12:27 PM
TIFitis added inline comments.
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
4712

I've removed isDevice as a parameter. At the call site, isDevice is checked inside an if condition and it returns on false, thus I haven't added the assertion back at the call site.

TIFitis updated this revision to Diff 472270.Nov 1 2022, 6:07 AM
TIFitis marked an inline comment as done.

Fixed comments

jsjodin accepted this revision.Nov 1 2022, 6:10 AM
This revision is now accepted and ready to land.Nov 1 2022, 6:10 AM

@jdoerfert do you have any other comments?