Skip to content

Commit 0c46a91

Browse files
committed
[MLIR] Infer locations for block argument conversion
To enable signature conversions to be used in CIRCT, locations should no longer be dropped from block arguments. Reviewed By: Mogball, springerm Differential Revision: https://reviews.llvm.org/D157882
1 parent 57cb2f6 commit 0c46a91

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mlir/lib/Transforms/Utils/DialectConversion.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,18 @@ Block *ArgConverter::applySignatureConversion(
724724
Block *newBlock = block->splitBlock(block->begin());
725725
block->replaceAllUsesWith(newBlock);
726726

727-
// FIXME: We should map the new arguments to proper locations.
727+
// Map all new arguments to the location of the argument they originate from.
728728
SmallVector<Location> newLocs(convertedTypes.size(),
729729
rewriter.getUnknownLoc());
730+
for (unsigned i = 0; i < origArgCount; ++i) {
731+
auto inputMap = signatureConversion.getInputMapping(i);
732+
if (!inputMap || inputMap->replacementValue)
733+
continue;
734+
Location origLoc = block->getArgument(i).getLoc();
735+
for (unsigned j = 0; j < inputMap->size; ++j)
736+
newLocs[inputMap->inputNo + j] = origLoc;
737+
}
738+
730739
SmallVector<Value, 4> newArgRange(
731740
newBlock->addArguments(convertedTypes, newLocs));
732741
ArrayRef<Value> newArgs(newArgRange);

0 commit comments

Comments
 (0)