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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Feb 21 12:19:49 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-core

Author: Chao Chen (chencha3)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/82530.diff


1 Files Affected:

- (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+5-2) 


``````````diff
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,

``````````

</details>


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


More information about the Mlir-commits mailing list