[llvm-branch-commits] [mlir] [mlir][Transforms] Dialect conversion: Build unresolved materialization for replaced ops (PR #101514)

Jakub Kuderski via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 1 11:16:43 PDT 2024


================
@@ -2459,10 +2457,42 @@ OperationConverter::finalize(ConversionPatternRewriter &rewriter) {
     return failure();
   DenseMap<Value, SmallVector<Value>> inverseMapping =
       rewriterImpl.mapping.getInverse();
+  if (failed(legalizeConvertedOpResultTypes(rewriter, rewriterImpl,
+                                            inverseMapping)))
+    return failure();
   if (failed(legalizeUnresolvedMaterializations(rewriter, rewriterImpl,
                                                 inverseMapping)))
     return failure();
+  return success();
+}
 
+/// Finds a user of the given value, or of any other value that the given value
+/// replaced, that was not replaced in the conversion process.
+static Operation *findLiveUserOfReplaced(
+    Value initialValue, ConversionPatternRewriterImpl &rewriterImpl,
+    const DenseMap<Value, SmallVector<Value>> &inverseMapping) {
+  SmallVector<Value> worklist(1, initialValue);
----------------
kuhar wrote:

nit
```suggestion
  SmallVector<Value> worklist = {initialValue};
```

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


More information about the llvm-branch-commits mailing list