This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferize][NFC] Rename DialectAnalysisState and move to OneShotAnalysis
ClosedPublic

Authored by springerm on Oct 2 2022, 7:18 PM.

Details

Summary

DialectAnalysisState is now OneShotAnalysisState::Extension.

This state extension mechanism is needed only for One-Shot Analysis, so it is moved from BufferizableOpInterface.h to OneShotAnalysis.h.

Extensions are now identified via TypeIDs instead of StringRefs. The API of state extensions is cleaned up and follows the same pattern as other extension mechanisms in MLIR (e.g., transform::TransformState::Extension).

Also delete some dead code.

Diff Detail

Event Timeline

springerm created this revision.Oct 2 2022, 7:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 2 2022, 7:18 PM
springerm requested review of this revision.Oct 2 2022, 7:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 2 2022, 7:18 PM
springerm edited the summary of this revision. (Show Details)Oct 31 2022, 8:43 AM
springerm edited the summary of this revision. (Show Details)Nov 22 2022, 1:15 AM
springerm edited the summary of this revision. (Show Details)Nov 22 2022, 1:16 AM
ftynse accepted this revision.Nov 22 2022, 3:59 AM

LGTM with comments addressed.

mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
412–414

It is dangerous to have a public constructor that takes TypeID because the caller can pass an arbitrary ID. Instead, consider adding an additional protected constructor and delegate to it. There's an even safer version of having an AnalysisBase CRTP class that handles all TypeID-related logic, but it may be too verbose for this use case.

420–422

Nit: there are some changes in how isa/dyn_cast are supposed to be set up (see https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html#advanced-use-cases), but I haven't followed them deeply enough to say if you want to use that instead of classof here.

428–429

You probably want to add MLIR_DECLARE/DEFINE_EXPLICIT_TYPE_ID macros for all relevant classes. See the documentation in TypeID.h

mlir/include/mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h
227

Nit: MLIR style has a newline after the template header.

238–257

One version is usually implemented by calling another with sufficient const_casting

This revision is now accepted and ready to land.Nov 22 2022, 3:59 AM
springerm updated this revision to Diff 477144.Nov 22 2022, 5:23 AM
springerm marked 4 inline comments as done.
springerm edited the summary of this revision. (Show Details)

rebase and address comments

springerm marked an inline comment as done.Nov 22 2022, 5:26 AM
springerm added inline comments.
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
420–422

classof seems easier for such small (and fixed) hierarchies. (following the same implementation approach as BlockArgumentImpl::classof)

springerm marked an inline comment as done.Nov 22 2022, 5:27 AM
This revision was landed with ongoing or failed builds.Nov 22 2022, 5:39 AM
This revision was automatically updated to reflect the committed changes.