This is an archive of the discontinued LLVM Phabricator instance.

[mlir][target][LLVMIR] Change translation order to translate non-LLVM ops before function bodies.
ClosedPublic

Authored by fmorac on Jul 25 2023, 7:01 PM.

Details

Summary

Convert function bodies after all other operations, breaking possible declaration-reference issues between top non-LLVM Ops and non-LLVM ops inside function bodies.

Example:

mydialect.global @myglobal : i32
llvm.func @bar(...) {
...
%address = mydialect.global_address @myglobal : llvm.ptr
...
}

With the previous scheme mydialect.global_address always got translated before mydialect.global, this change ensures mydialect.global gets translated first.

Diff Detail

Event Timeline

fmorac created this revision.Jul 25 2023, 7:01 PM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
fmorac edited the summary of this revision. (Show Details)Jul 25 2023, 7:07 PM
fmorac added a reviewer: mehdi_amini.
fmorac published this revision for review.Jul 25 2023, 7:23 PM
mehdi_amini added inline comments.Jul 26 2023, 12:40 PM
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
1406

Typo: function

1407

I don't understand the explanation in the comment.

I would think that the issue with translation is that we need to have declaration before we introduce references to these, but I can be mistaken about the issue at play here?

That LGTM when the comment will be fixed :)

fmorac updated this revision to Diff 544739.Jul 27 2023, 6:15 AM
fmorac marked 2 inline comments as done.

Changed the description in the comment.

fmorac edited the summary of this revision. (Show Details)Jul 27 2023, 6:18 AM
fmorac updated this revision to Diff 544970.Jul 27 2023, 3:45 PM

Updated the comment.

This revision is now accepted and ready to land.Jul 27 2023, 4:28 PM