This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][LLVM] Add accessor for LLVMModule and invoke convertDialectAttributes on GlobalOps
ClosedPublic

Authored by agozillon on Apr 26 2023, 12:03 PM.

Details

Summary

This patch seeks to do two things add an accessor method to
retrieve the ModuleTranslations contained LLVM Module for direct
usage by dialects that are being lowered to LLVM-IR. One particular
use case for this is in the OpenMP Dialect, when interfacing
with the OMPIRBuilder in certain cases it is useful to be able
to access the LLVM Module directly.

The second is invoking convertDialectAttributes on GlobalOp's
so as to be able to lower dialect specific attributes that are
applied or lowered onto GlobalOp's.

Diff Detail

Event Timeline

agozillon created this revision.Apr 26 2023, 12:03 PM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
agozillon requested review of this revision.Apr 26 2023, 12:03 PM

Perhaps these are unreasonable changes (or the wrong way to go about things), so please do mention if they are. I've found some use for these modifications in the OpenMP Dialect when lowering an attribute applied to globals (declare target) which utilises some shared methods between Clang and the OpenMP dialect to lower the attribute https://reviews.llvm.org/D149162 to LLVM-IR. The LLVM Module accessor is to help with interfacing with the shared functions and the conversion of attributes helps to have access to the attribute during lowering within the OpenMPToLLVMTranslation phase.

ftynse accepted this revision.Apr 27 2023, 11:05 AM

Please add a test for translating attributes on globals.

This revision is now accepted and ready to land.Apr 27 2023, 11:05 AM

Please add a test for translating attributes on globals.

Thank you very much @ftynse for the quick review!

I don't have the lowering that makes use of these changes available upstream just yet, so I unfortunately can't add a test at the moment (although the lowering, which I am in the process of making a phabricator review of will have tests that depend on these changes and will thus test them). Unless there is an alternative attribute (or method of testing) I can test with at the moment.

So I could either upstream this patch as-is without a test for the moment (but the phabricator reviews that it relies on for testing could take some time to reach acceptance themselves) or leave this patch in it's accepted state until the other phabricator reviews that depend on the change have reached an accepted state as well?

I'm fine landing this.