[Mlir-commits] [mlir] 751e6c0 - [mlir][Transforms] Check for correct type converter rule implementation (#140347)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat May 17 17:05:05 PDT 2025
Author: Matthias Springer
Date: 2025-05-18T09:05:02+09:00
New Revision: 751e6c08b2f6cd40908b8810a2a2da476e88417e
URL: https://github.com/llvm/llvm-project/commit/751e6c08b2f6cd40908b8810a2a2da476e88417e
DIFF: https://github.com/llvm/llvm-project/commit/751e6c08b2f6cd40908b8810a2a2da476e88417e.diff
LOG: [mlir][Transforms] Check for correct type converter rule implementation (#140347)
If a type conversion rule fails to apply, it should not append any types
to the result. This commit just adds an assertion to detect such cases
of incorrect API usage.
Added:
Modified:
mlir/lib/Transforms/Utils/DialectConversion.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 0d208ce0f2f25..bd11bbe58a3f6 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -2880,6 +2880,8 @@ LogicalResult TypeConverter::convertType(Type t,
if (t.getContext()->isMultithreadingEnabled())
cacheWriteLock.lock();
if (!succeeded(*result)) {
+ assert(results.size() == currentCount &&
+ "failed type conversion should not change results");
cachedDirectConversions.try_emplace(t, nullptr);
return failure();
}
@@ -2889,6 +2891,9 @@ LogicalResult TypeConverter::convertType(Type t,
else
cachedMultiConversions.try_emplace(t, llvm::to_vector<2>(newTypes));
return success();
+ } else {
+ assert(results.size() == currentCount &&
+ "failed type conversion should not change results");
}
}
return failure();
More information about the Mlir-commits
mailing list