Skip to content

Commit

Permalink
[MLIR] NFC use Operation::getParentWithTrait in alloca verifier
Browse files Browse the repository at this point in the history
Use recently added accessor Operation::getParentWithTrait in alloca
verifier.

Differential Revision: https://reviews.llvm.org/D78296
  • Loading branch information
bondhugula committed Apr 16, 2020
1 parent 8812b0c commit dfcc403
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions mlir/lib/Dialect/StandardOps/IR/Ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,11 @@ static LogicalResult verify(AllocLikeOp op) {
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 {
Expand Down

0 comments on commit dfcc403

Please sign in to comment.