[PATCH] D78705: [mlir][linalg] Use memory effect to detecting allocation
Lei Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 10:12:02 PDT 2020
antiagainst updated this revision to Diff 260365.
antiagainst marked 2 inline comments as done.
antiagainst added a comment.
Rebase and address comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78705/new/
https://reviews.llvm.org/D78705
Files:
mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp
Index: mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp
===================================================================
--- mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp
+++ mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp
@@ -37,12 +37,26 @@
while (true) {
if (v.isa<BlockArgument>())
return v;
+
Operation *defOp = v.getDefiningOp();
- if (auto alloc = dyn_cast_or_null<AllocOp>(defOp)) {
- if (isStrided(alloc.getType()))
- return alloc.getResult();
+ if (!defOp)
+ return v;
+
+ if (auto memEffect = dyn_cast<MemoryEffectOpInterface>(defOp)) {
+ // Collect all memory effects on `v`.
+ SmallVector<MemoryEffects::EffectInstance, 1> effects;
+ memEffect.getEffectsOnValue(v, effects);
+
+ // If we have the 'Allocate' memory effect on `v`, then `v` should be the
+ // original buffer.
+ if (llvm::any_of(
+ effects, [](const MemoryEffects::EffectInstance &instance) {
+ return isa<MemoryEffects::Allocate>(instance.getEffect());
+ }))
+ return v;
}
- if (auto viewLikeOp = dyn_cast_or_null<ViewLikeOpInterface>(defOp)) {
+
+ if (auto viewLikeOp = dyn_cast<ViewLikeOpInterface>(defOp)) {
auto it =
aliases.insert(std::make_pair(v, find(viewLikeOp.getViewSource())));
return it.first->second;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78705.260365.patch
Type: text/x-patch
Size: 1382 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/4455146f/attachment.bin>
More information about the llvm-commits
mailing list