[Mlir-commits] [mlir] [mlir] fix a segment fault in `ConversionPatternRewriter::applySignatureConversion` (PR #82530)

Chao Chen llvmlistbot at llvm.org
Wed Feb 21 12:18:57 PST 2024


https://github.com/chencha3 created https://github.com/llvm/llvm-project/pull/82530

ConversionPatternRewriter::applySignatureConversion accepts nulltpr for TypeConverter. But `ArgConverter::applySignatureConversion` failed to check it when it calls `converter->convertType(outputType)`. 

>From 30ba1d56c713b3d56a6ebee2424eeb9764c58e69 Mon Sep 17 00:00:00 2001
From: Chao Chen <chao.chen at intel.com>
Date: Wed, 21 Feb 2024 14:14:02 -0600
Subject: [PATCH] fix a segment fault

---
 mlir/lib/Transforms/Utils/DialectConversion.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 4989ddc3ec94fb..b5cc8ca223d1af 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -642,8 +642,11 @@ Block *ArgConverter::applySignatureConversion(
 
       // Legalize the argument output type.
       Type outputType = origOutputType;
-      if (Type legalOutputType = converter->convertType(outputType))
-        outputType = legalOutputType;
+      if (converter){
+        if (Type legalOutputType = converter->convertType(outputType))
+          outputType = legalOutputType;
+      }
+        
 
       newArg = buildUnresolvedArgumentMaterialization(
           rewriter, origArg.getLoc(), replArgs, origOutputType, outputType,



More information about the Mlir-commits mailing list