forked from OSchip/llvm-project
[mlir:GreedyDriver] Return WalkResult::skip after deleting a known constant
This avoids use-after-free when trying to access the regions after visiting the operation.
This commit is contained in:
parent
dd12c3433e
commit
aa568e082b
|
@ -159,11 +159,15 @@ bool GreedyPatternRewriteDriver::simplify(MutableArrayRef<Region> regions) {
|
|||
}
|
||||
} else {
|
||||
// Add all nested operations to the worklist in preorder.
|
||||
for (auto ®ion : regions)
|
||||
for (auto ®ion : regions) {
|
||||
region.walk<WalkOrder::PreOrder>([&](Operation *op) {
|
||||
if (!insertKnownConstant(op))
|
||||
if (!insertKnownConstant(op)) {
|
||||
worklist.push_back(op);
|
||||
return WalkResult::advance();
|
||||
}
|
||||
return WalkResult::skip();
|
||||
});
|
||||
}
|
||||
|
||||
// Reverse the list so our pop-back loop processes them in-order.
|
||||
std::reverse(worklist.begin(), worklist.end());
|
||||
|
|
Loading…
Reference in New Issue