[PATCH] D78705: [mlir][linalg] Use memory effect to detecting allocation

Lei Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 05:21:51 PDT 2020


antiagainst created this revision.
antiagainst added reviewers: rriddle, nicolasvasilache, mravishankar.
Herald added subscribers: llvm-commits, Kayjukh, frgossen, grosul1, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, shauheen, jpienaar, mehdi_amini.
Herald added a project: LLVM.
antiagainst added a parent revision: D78645: [mlir] Add a ViewLikeOpInterface.

This allows the dependency analysis to be more general
and recognize other allocation-like operations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78705

Files:
  mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
  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
@@ -38,9 +38,11 @@
     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 (auto allocEffect = dyn_cast_or_null<MemoryEffectOpInterface>(defOp)) {
+      if (allocEffect.hasEffect<MemoryEffects::Allocate>() &&
+          defOp->getNumResults() == 1 &&
+          isStrided(v.getType().cast<MemRefType>()))
+        return v;
     }
     if (auto viewLikeOp = dyn_cast_or_null<ViewLikeOpInterface>(defOp)) {
       auto it =
Index: mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
===================================================================
--- mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
+++ mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
@@ -276,7 +276,7 @@
 // AllocOp
 //===----------------------------------------------------------------------===//
 
-def AllocOp : AllocLikeOp<"alloc"> {
+def AllocOp : AllocLikeOp<"alloc", [MemoryEffects<[MemAlloc]>]> {
   let summary = "memory allocation operation";
   let description = [{
     The `alloc` operation allocates a region of memory, as specified by its


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78705.259529.patch
Type: text/x-patch
Size: 1449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200423/d9eaf3e9/attachment.bin>


More information about the llvm-commits mailing list