Skip to content

Commit f0edd03

Browse files
[mlir][Transforms] Detect mapping overwrites during block signature conversion
Add extra assertions to make sure that a value in the conversion value mapping is not overwritten during `applySignatureConversion`.
1 parent 1102603 commit f0edd03

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mlir/lib/Transforms/Utils/DialectConversion.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,14 @@ Block *ConversionPatternRewriterImpl::applySignatureConversion(
13641364
if (hasRewrite<BlockTypeConversionRewrite>(rewrites, block))
13651365
llvm::report_fatal_error("block was already converted");
13661366
#endif // MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS
1367+
#ifndef NDEBUG
1368+
// This check detects the following cases:
1369+
// * Attempting to convert the same block multiple times.
1370+
// * Block argument replaced, then attempting to convert the block.
1371+
for (BlockArgument arg : block->getArguments())
1372+
assert(mapping.lookupOrNull(arg).empty() &&
1373+
"cannot convert block whose arguments have been replaced");
1374+
#endif // NDEBUG
13671375

13681376
OpBuilder::InsertionGuard g(rewriter);
13691377

0 commit comments

Comments
 (0)