[MLIR] NFC use Operation::getParentWithTrait in alloca verifier

Use recently added accessor Operation::getParentWithTrait in alloca
verifier.

Differential Revision: https://reviews.llvm.org/D78296
This commit is contained in:
Uday Bondhugula 2020-04-16 18:57:32 +05:30
parent 8812b0cc5c
commit dfcc403b2d
1 changed files with 5 additions and 8 deletions

View File

@ -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 {