From 062dd406b1efd00483961ab3a4e75543e47b4859 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Mon, 18 Nov 2019 11:25:52 -0800 Subject: [PATCH] ConvertStandardToLLVM: replace assertion with graceful failure The assertion was introduced in the early days of dialect conversion infrastructure when we had the matching function separate from the rewriting function. The infrastructure evolved to have a common matchAndRewrite function and the separate matching function was dropped without chaning the rewriting that became matchAndRewrite. This has led to assertion being triggered. Return a matchFailure instead of failing an assertion on unsupported types. Closes tensorflow/mlir#230 PiperOrigin-RevId: 281113741 --- mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp index 59a112d..dc38ae3 100644 --- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp @@ -565,8 +565,8 @@ struct OneToOneLLVMOpLowering : public LLVMLegalizationPattern { if (numResults != 0) { packedType = this->lowering.packFunctionResults( llvm::to_vector<4>(op->getResultTypes())); - assert(packedType && "type conversion failed, such operation should not " - "have been matched"); + if (!packedType) + return this->matchFailure(); } auto newOp = rewriter.create(op->getLoc(), packedType, operands, -- 2.7.4