Skip to content

Commit 938cdd6

Browse files
authored
correctly check uses of pattern descriptor transform ops (#118791)
In the transform dialect use-after-free chcker pass, account for pattern descriptor operations that intentionally have no declared side effects. They are not destroying any handles. Closes #118761.
1 parent e869103 commit 938cdd6

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

mlir/lib/Dialect/Transform/Transforms/CheckUses.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ class TransformOpMemFreeAnalysis {
338338
void collectFreedValues(Operation *root) {
339339
SmallVector<MemoryEffects::EffectInstance> instances;
340340
root->walk([&](Operation *child) {
341+
if (isa<transform::PatternDescriptorOpInterface>(child))
342+
return;
341343
// TODO: extend this to conservatively handle operations with undeclared
342344
// side effects as maybe freeing the operands.
343345
auto iface = cast<MemoryEffectOpInterface>(child);

mlir/test/Dialect/Transform/check-use-after-free.mlir

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,17 @@ transform.sequence failures(propagate) {
177177
^bb0(%arg1: !transform.any_op):
178178
}
179179
}
180+
181+
// -----
182+
183+
// This should not crash.
184+
185+
module attributes {transform.with_named_sequence} {
186+
transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {
187+
%0 = transform.structured.match ops{["func.func"]} in %arg0 : (!transform.any_op) -> !transform.any_op
188+
transform.apply_patterns to %0 {
189+
transform.apply_patterns.memref.extract_address_computations
190+
} : !transform.any_op
191+
transform.yield
192+
}
193+
}

0 commit comments

Comments
 (0)