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

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 22:46:45 PDT 2020


mehdi_amini requested changes to this revision.
mehdi_amini added inline comments.
This revision now requires changes to proceed.


================
Comment at: mlir/include/mlir/Dialect/StandardOps/IR/Ops.td:279
 
-def AllocOp : AllocLikeOp<"alloc"> {
+def AllocOp : AllocLikeOp<"alloc", [MemoryEffects<[MemAlloc]>]> {
   let summary = "memory allocation operation";
----------------
rriddle wrote:
> Can we add to AllocLikeOp instead? Ideally marking the returned value directly.
Should this be rebased on top of https://reviews.llvm.org/D78619 ?


================
Comment at: mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp:40
       return v;
     Operation *defOp = v.getDefiningOp();
+    if (auto allocEffect = dyn_cast_or_null<MemoryEffectOpInterface>(defOp)) {
----------------
FYI, less operations:

```
Operation *defOp = v.getDefiningOp();
if (!defOp) return v;
```


================
Comment at: mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp:43
+      if (allocEffect.hasEffect<MemoryEffects::Allocate>() &&
+          defOp->getNumResults() == 1 &&
+          isStrided(v.getType().cast<MemRefType>()))
----------------
The "MemAlloc" trait can be attached to individual results, I believe that the right way here is to look-up which result is `v` for the operation and query the interface for the MemAlloc trait for this particular result.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78705/new/

https://reviews.llvm.org/D78705





More information about the llvm-commits mailing list