[Mlir-commits] [mlir] a2100da - [mlir][LLVMIR] Fix oneToOneRewrite for zero-result ops
Jeff Niu
llvmlistbot at llvm.org
Thu Aug 25 14:09:22 PDT 2022
Author: Jeff Niu
Date: 2022-08-25T14:08:58-07:00
New Revision: a2100daf12fb980a29fd1a9c85ccf8eaaaf79730
URL: https://github.com/llvm/llvm-project/commit/a2100daf12fb980a29fd1a9c85ccf8eaaaf79730
DIFF: https://github.com/llvm/llvm-project/commit/a2100daf12fb980a29fd1a9c85ccf8eaaaf79730.diff
LOG: [mlir][LLVMIR] Fix oneToOneRewrite for zero-result ops
`oneToOneRewrite` segfaulted for zero result-ops because a null type was being
passed to the op builders.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D132702
Added:
Modified:
mlir/lib/Conversion/LLVMCommon/Pattern.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/LLVMCommon/Pattern.cpp b/mlir/lib/Conversion/LLVMCommon/Pattern.cpp
index 73bb64d278237..96d83eec18056 100644
--- a/mlir/lib/Conversion/LLVMCommon/Pattern.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/Pattern.cpp
@@ -311,17 +311,18 @@ LogicalResult LLVM::detail::oneToOneRewrite(
LLVMTypeConverter &typeConverter, ConversionPatternRewriter &rewriter) {
unsigned numResults = op->getNumResults();
- Type packedType;
+ SmallVector<Type> resultTypes;
if (numResults != 0) {
- packedType = typeConverter.packFunctionResults(op->getResultTypes());
- if (!packedType)
+ resultTypes.push_back(
+ typeConverter.packFunctionResults(op->getResultTypes()));
+ if (!resultTypes.back())
return failure();
}
// Create the operation through state since we don't know its C++ type.
Operation *newOp =
rewriter.create(op->getLoc(), rewriter.getStringAttr(targetOp), operands,
- packedType, op->getAttrs());
+ resultTypes, op->getAttrs());
// If the operation produced 0 or 1 result, return them immediately.
if (numResults == 0)
More information about the Mlir-commits
mailing list