[Mlir-commits] [mlir] [mlir][bufferization] Better analysis around allocs and block arguments (PR #67923)
Martin Erhart
llvmlistbot at llvm.org
Sun Oct 1 09:41:38 PDT 2023
================
@@ -49,19 +49,53 @@ static LogicalResult updateDeallocIfChanged(DeallocOp deallocOp,
return success();
}
-/// Checks if 'memref' may or must alias a MemRef in 'memrefList'. It is often a
+/// Given a memref value, return the "base" value by skipping over all
+/// ViewLikeOpInterface ops (if any) in the reverse use-def chain.
+static Value getViewBase(Value value) {
+ while (value) {
+ auto viewLikeOp = value.getDefiningOp<ViewLikeOpInterface>();
+ if (!viewLikeOp)
+ return value;
+ value = viewLikeOp.getViewSource();
+ }
+ return value;
----------------
maerhart wrote:
`value` shouldn't ever be a null value, right? Couldn't we do the following then:
```suggestion
while (auto viewLikeOp = value.getDefiningOp<ViewLikeOpInterface>())
value = viewLikeOp.getViewSource();
return value;
```
https://github.com/llvm/llvm-project/pull/67923
More information about the Mlir-commits
mailing list