Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions mlir/lib/Transforms/Utils/DialectConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1375,12 +1375,18 @@ Block *ConversionPatternRewriterImpl::applySignatureConversion(
// used as a replacement.
auto replArgs =
newBlock->getArguments().slice(inputMap->inputNo, inputMap->size);
auto insertPoint = OpBuilder::InsertPoint(newBlock, newBlock->begin());
if (replArgs.size() == 1) {
mapping.map(origArg, replArgs.front());
// We need an argument materialization to replace the block argument.
Value argMat = buildUnresolvedMaterialization(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be necessary. Argument materialization are a workaround around missing 1:N support, but this is a 1:1 replacement.

MaterializationKind::Argument, insertPoint, origArg.getLoc(),
/*valueToMap=*/origArg, /*inputs=*/replArgs,
/*outputType=*/origArg.getType(), /*originalType=*/Type(), converter);
mapping.map(origArg, argMat);
} else {
insertNTo1Materialization(
OpBuilder::InsertPoint(newBlock, newBlock->begin()), origArg.getLoc(),
/*replacements=*/replArgs, /*outputValue=*/origArg, converter);
insertNTo1Materialization(insertPoint, origArg.getLoc(),
/*replacements=*/replArgs,
/*originalValue=*/origArg, converter);
}
appendRewrite<ReplaceBlockArgRewrite>(block, origArg, converter);
}
Expand Down
Loading