@@ -378,39 +378,39 @@ static void diagnoseInvalidOperandDominance(Operation &op, unsigned operandNo) {
378
378
LogicalResult
379
379
OperationVerifier::verifyDominanceOfContainedRegions (Operation &op,
380
380
DominanceInfo &domInfo) {
381
- for (Region ®ion : op.getRegions ()) {
382
- // Verify the dominance of each of the held operations.
383
- for (Block &block : region) {
384
- // Dominance is only meaningful inside reachable blocks.
385
- bool isReachable = domInfo.isReachableFromEntry (&block);
386
-
387
- for (Operation &op : block) {
388
- if (isReachable) {
389
- // Check that operands properly dominate this use.
390
- for (const auto &operand : llvm::enumerate (op.getOperands ())) {
391
- if (domInfo.properlyDominates (operand.value (), &op))
392
- continue ;
393
-
394
- diagnoseInvalidOperandDominance (op, operand.index ());
395
- return failure ();
381
+ llvm::SmallVector<Operation *, 8 > worklist{&op};
382
+ while (!worklist.empty ()) {
383
+ auto *op = worklist.pop_back_val ();
384
+ for (auto ®ion : op->getRegions ())
385
+ for (auto &block : region.getBlocks ()) {
386
+ // Dominance is only meaningful inside reachable blocks.
387
+ bool isReachable = domInfo.isReachableFromEntry (&block);
388
+ for (auto &op : block) {
389
+ if (isReachable) {
390
+ // Check that operands properly dominate this use.
391
+ for (const auto &operand : llvm::enumerate (op.getOperands ())) {
392
+ if (domInfo.properlyDominates (operand.value (), &op))
393
+ continue ;
394
+
395
+ diagnoseInvalidOperandDominance (op, operand.index ());
396
+ return failure ();
397
+ }
396
398
}
397
- }
398
399
399
- // Recursively verify dominance within each operation in the block, even
400
- // if the block itself is not reachable, or we are in a region which
401
- // doesn't respect dominance.
402
- if (verifyRecursively && op.getNumRegions () != 0 ) {
403
- // If this operation is IsolatedFromAbove, then we'll handle it in the
404
- // outer verification loop.
405
- if (op.hasTrait <OpTrait::IsIsolatedFromAbove>())
406
- continue ;
407
-
408
- if (failed (verifyDominanceOfContainedRegions (op, domInfo)))
409
- return failure ();
400
+ // Recursively verify dominance within each operation in the block,
401
+ // even if the block itself is not reachable, or we are in a region
402
+ // which doesn't respect dominance.
403
+ if (verifyRecursively && op.getNumRegions () != 0 ) {
404
+ // If this operation is IsolatedFromAbove, then we'll handle it in
405
+ // the outer verification loop.
406
+ if (op.hasTrait <OpTrait::IsIsolatedFromAbove>())
407
+ continue ;
408
+ worklist.push_back (&op);
409
+ }
410
410
}
411
411
}
412
- }
413
412
}
413
+
414
414
return success ();
415
415
}
416
416
0 commit comments