[PATCH] D78296: [MLIR] NFC use Operation::getParentWithTrait in alloca verifier
Uday Bondhugula via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 16 07:16:09 PDT 2020
bondhugula created this revision.
bondhugula added reviewers: jpienaar, mehdi_amini.
Herald added subscribers: llvm-commits, frgossen, grosul1, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, rriddle.
Herald added a project: LLVM.
Use recently added accessor Operation::getParentWithTrait in alloca
verifier.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78296
Files:
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
Index: mlir/lib/Dialect/StandardOps/IR/Ops.cpp
===================================================================
--- mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -324,14 +324,11 @@
return success();
// An alloca op needs to have an ancestor with an allocation scope trait.
- auto *parentOp = op.getParentOp();
- while (parentOp) {
- if (parentOp->template hasTrait<OpTrait::AutomaticAllocationScope>())
- return success();
- parentOp = parentOp->getParentOp();
- }
- return op.emitOpError(
- "requires an ancestor op with AutomaticAllocationScope trait");
+ if (!op.template getParentWithTrait<OpTrait::AutomaticAllocationScope>())
+ return op.emitOpError(
+ "requires an ancestor op with AutomaticAllocationScope trait");
+
+ return success();
}
namespace {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78296.258043.patch
Type: text/x-patch
Size: 849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200416/3021a406/attachment.bin>
More information about the llvm-commits
mailing list