diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -724,9 +724,18 @@ Block *newBlock = block->splitBlock(block->begin()); block->replaceAllUsesWith(newBlock); - // FIXME: We should map the new arguments to proper locations. + // Map all new arguments to the location of the argument they originate from. SmallVector newLocs(convertedTypes.size(), rewriter.getUnknownLoc()); + for (unsigned i = 0; i < origArgCount; ++i) { + auto inputMap = signatureConversion.getInputMapping(i); + if (!inputMap || inputMap->replacementValue) + continue; + Location origLoc = block->getArgument(i).getLoc(); + for (unsigned j = 0; j < inputMap->size; ++j) + newLocs[inputMap->inputNo + j] = origLoc; + } + SmallVector newArgRange( newBlock->addArguments(convertedTypes, newLocs)); ArrayRef newArgs(newArgRange);