This is an archive of the discontinued LLVM Phabricator instance.

[mlir][llvm] Add AliasAnalysis and AccessGroup interfaces.
ClosedPublic

Authored by gysit on Feb 27 2023, 12:54 AM.

Details

Summary

The revision introduces two interfaces that provide access to
the alias analysis and access group metadata attributes. The
AliasAnalysis interface combines all alias analysis related
attributes (alias, noalias, and tbaa) similar to LLVM's getAAMetadata
method, while the AccessGroup interface is dedicated to the
access group metadata.

Previously, only the load and store operations supported alias analysis
and access group metadata. This revision extends this support to the
atomic operations. A follow up revision will also add support for the
memcopy, memset, and memove intrinsics. The interfaces then provide
convenient access to the metadata attributes and eliminate the need
of TypeSwitch or string based attribute access.

The revision still relies on string based attribute access for
the translation to LLVM IR (except for tbaa metadata). Only once
the the memory access intrinsics also implement the new interfaces,
the translation to LLVM IR can be fully switched to use interface
based attribute accesses.

Depends on D144875

Diff Detail

Event Timeline

gysit created this revision.Feb 27 2023, 12:54 AM
Herald added a project: Restricted Project. · View Herald Transcript
gysit requested review of this revision.Feb 27 2023, 12:54 AM

It might make sense to split the change to have the LLVMInterfaces changes in a separate commit.

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
2872–2883

This is now basically an isa<...>, so it might make sense to replace the TypeSwitch with it

gysit updated this revision to Diff 500784.Feb 27 2023, 7:40 AM
gysit edited the summary of this revision. (Show Details)

Address review comments.

gysit marked an inline comment as done.Feb 27 2023, 7:41 AM
gysit added inline comments.
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
2872–2883

Good catch!

ftynse accepted this revision.Feb 27 2023, 11:48 AM
ftynse added inline comments.
mlir/include/mlir/Dialect/LLVMIR/LLVMInterfaces.td
53–54

Maybe mention here that the default implementation expects the op to have an ArrayAttr named access_groups to avoid mysterious failure-to-compile errors.

This revision is now accepted and ready to land.Feb 27 2023, 11:48 AM
gysit updated this revision to Diff 501122.Feb 28 2023, 6:46 AM
gysit marked 2 inline comments as done.

Address comments and rebase.

This revision was automatically updated to reflect the committed changes.