[PATCH] D148109: [mlir] Add a generic mem2reg implementation.
Tobias Gysi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 02:33:43 PDT 2023
gysit accepted this revision.
gysit added a comment.
This revision is now accepted and ready to land.
LGTM modulo the assertion comment.
================
Comment at: mlir/lib/Transforms/Mem2Reg.cpp:188
+
+ assert(isResultOrNewBlockArgument &&
+ "a slot must be a result of the allocator or an argument of the "
----------------
This may trigger a warning if compiled without assertion. The standard way to avoid this is putting
```
(void)isResultOrNewBlockArgument;
```
before the assertion. Also consider starting the search from the slot.ptr and then call get defining op / cast it to a block argument, e.g:
```
auto isResultOrBlockArgument = [&](Value value) {
if (value.getDefiningOp() == allocator)
return true;
if (BlockArgument arg = value.dyn_cast<BlockArgument>())
if (arg.getOwner()->getParentOp() == allocator)
return true;
return false;
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148109/new/
https://reviews.llvm.org/D148109
More information about the llvm-commits
mailing list