[Mlir-commits] [mlir] [mlir][Transforms] Dialect conversion: fix crash when converting detached region (PR #100633)
River Riddle
llvmlistbot at llvm.org
Thu Jul 25 12:05:20 PDT 2024
================
@@ -685,6 +685,35 @@ namespace {
//===----------------------------------------------------------------------===//
// Region-Block Rewrite Testing
+/// This pattern applies a signature conversion to a block inside a detached
+/// region.
+struct TestDetachedSignatureConversion : public ConversionPattern {
+ TestDetachedSignatureConversion(MLIRContext *ctx)
+ : ConversionPattern("test.detached_signature_conversion", /*benefit=*/1,
+ ctx) {}
+
+ LogicalResult
+ matchAndRewrite(Operation *op, ArrayRef<Value> operands,
+ ConversionPatternRewriter &rewriter) const final {
+ if (op->getNumRegions() != 1)
+ return failure();
+ OperationState state(op->getLoc(), "test.legal_op_with_region", operands,
+ op->getResultTypes(), {}, BlockRange());
+ Region *newRegion = state.addRegion();
+ rewriter.inlineRegionBefore(op->getRegion(0), *newRegion,
+ newRegion->begin());
+ TypeConverter::SignatureConversion result(newRegion->getNumArguments());
+ for (unsigned i = 0; i < newRegion->getNumArguments(); ++i) {
+ result.addInputs(i, rewriter.getF64Type());
+ }
+ rewriter.applySignatureConversion(&newRegion->front(), result);
+ Operation *newOp = rewriter.create(state);
+ newOp->dump();
----------------
River707 wrote:
Is this leftover debug?
https://github.com/llvm/llvm-project/pull/100633
More information about the Mlir-commits
mailing list