This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add support for querying the ModRef behavior from the AliasAnalysis class
ClosedPublic

Authored by rriddle on Apr 30 2021, 4:11 PM.

Details

Summary

This allows for checking if a given operation may modify/reference/or both a given value. Right now this API is limited to Value based memory locations, but we should expand this to include attribute based values at some point. This is left for future work because the rest of the AliasAnalysis API also has this restriction.

Diff Detail

Event Timeline

rriddle created this revision.Apr 30 2021, 4:11 PM
rriddle requested review of this revision.Apr 30 2021, 4:11 PM
silvas accepted this revision.Apr 30 2021, 5:38 PM
silvas added inline comments.
mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp
346

This looks like it could get very expensive for multiple nested scf.if ops. It even looks like it could go quadratic for certain kinds of query patterns (e.g. calling getModRef on each operation in a function)

This revision is now accepted and ready to land.Apr 30 2021, 5:38 PM
bondhugula added inline comments.
mlir/include/mlir/Analysis/AliasAnalysis.h
94

The class doc comment refers to memory access and memory alone, while an aliasing relation is being referred to here. I think a line or two is missing on the connection in the class doc comment.

150–155

Comment copied.

mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp
198

?

Similar to ModRefInfo, you used an unscoped enum to facilitate the logical operations. Is a design based on a type-safe scoped enum too verbose?

rriddle updated this revision to Diff 346820.May 20 2021, 12:15 PM
rriddle marked 4 inline comments as done.

update

Similar to ModRefInfo, you used an unscoped enum to facilitate the logical operations. Is a design based on a type-safe scoped enum too verbose?

IMO yeah. Just switched to using static creation methods, given that access to the kind isn't really necessary anyways. I'll switch AliasResult to do the same in a followup.

mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp
198

It's marking what the section corresponds to, given that I use the same LocalAliasAnalysis below.

346

Yeah, I agree. For now just added a TODO, will handle as necessary in a followup.