Skip to content

Commit dfcc403

Browse files
committed
[MLIR] NFC use Operation::getParentWithTrait in alloca verifier
Use recently added accessor Operation::getParentWithTrait in alloca verifier. Differential Revision: https://reviews.llvm.org/D78296
1 parent 8812b0c commit dfcc403

File tree

1 file changed

+5
-8
lines changed
  • mlir/lib/Dialect/StandardOps/IR

1 file changed

+5
-8
lines changed

mlir/lib/Dialect/StandardOps/IR/Ops.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,11 @@ static LogicalResult verify(AllocLikeOp op) {
324324
return success();
325325

326326
// An alloca op needs to have an ancestor with an allocation scope trait.
327-
auto *parentOp = op.getParentOp();
328-
while (parentOp) {
329-
if (parentOp->template hasTrait<OpTrait::AutomaticAllocationScope>())
330-
return success();
331-
parentOp = parentOp->getParentOp();
332-
}
333-
return op.emitOpError(
334-
"requires an ancestor op with AutomaticAllocationScope trait");
327+
if (!op.template getParentWithTrait<OpTrait::AutomaticAllocationScope>())
328+
return op.emitOpError(
329+
"requires an ancestor op with AutomaticAllocationScope trait");
330+
331+
return success();
335332
}
336333

337334
namespace {

0 commit comments

Comments
 (0)