This is an archive of the discontinued LLVM Phabricator instance.

[flang] automatically load FIR dialect with hlfir
ClosedPublic

Authored by tblah on Feb 13 2023, 10:10 AM.

Details

Summary

MLIR loads dialects lazily so if a hlfir type (or operation) is found
before any fir type (or operation), the fir dialect will not have been
loaded when the hlfir thing is verified. Verification of some hlfir
operations does depend on fir types (e.g. hlfir.sum needs
fir::SequenceType).

Diff Detail

Event Timeline

tblah created this revision.Feb 13 2023, 10:10 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 13 2023, 10:10 AM
tblah requested review of this revision.Feb 13 2023, 10:10 AM

Makes sense. Would adding let dependentDialects = ["fir::FIROpsDialect"]; in hlfir_Dialect declaration in [1] also work ?
If so, that is probably more in line with the tablegen dialect definition approach.

[1]: https://github.com/llvm/llvm-project/blob/3ad26060e4bceb2cf9f4959d659cbb29d88344cf/flang/include/flang/Optimizer/HLFIR/HLFIROpBase.td#L39.

tblah updated this revision to Diff 497258.Feb 14 2023, 2:52 AM

Updated to make the change in tablegen

tblah added a comment.Feb 14 2023, 2:52 AM

Makes sense. Would adding let dependentDialects = ["fir::FIROpsDialect"]; in hlfir_Dialect declaration in [1] also work ?
If so, that is probably more in line with the tablegen dialect definition approach.

[1]: https://github.com/llvm/llvm-project/blob/3ad26060e4bceb2cf9f4959d659cbb29d88344cf/flang/include/flang/Optimizer/HLFIR/HLFIROpBase.td#L39.

Thanks for suggesting this - that's much cleaner

jeanPerier accepted this revision.Feb 14 2023, 5:18 AM

Thanks, LGTM

This revision is now accepted and ready to land.Feb 14 2023, 5:18 AM
This revision was automatically updated to reflect the committed changes.