Skip to content

[CfToHandshake] Do not replace the same value twice#754

Open
Jiahui17 wants to merge 1 commit intomainfrom
bugfix/jiahui/no-replace-use-twice
Open

[CfToHandshake] Do not replace the same value twice#754
Jiahui17 wants to merge 1 commit intomainfrom
bugfix/jiahui/no-replace-use-twice

Conversation

@Jiahui17
Copy link
Member

@Jiahui17 Jiahui17 commented Feb 28, 2026

In CfToHandshake, we are calling inlineBlockBefore after replaceAllUsesWith. Internally, inlineBlockBefore calls ConversionPatternRewriterImpl::replaceOp.

for (BlockArgument blockArg : block.getArguments()) {
Value mergeRes = argReplacements.at(blockArg);
replacements.push_back(mergeRes);
rewriter.replaceAllUsesWith(blockArg, mergeRes);
}
rewriter.inlineBlockBefore(&block, lastOp, replacements);

In the latest LLVM, ConversionPatternRewriterImpl::replaceOp asserts that the value that's being replaced must not have already been replaced, which is not true in the logic above.

To fix this, when constructing MC/LSQ, use the merge outputs directly rather than the block arguments for GAs and the number of stores. This omits the need to call replaceAllUsesWith

@Jiahui17
Copy link
Member Author

I pulled this out of #654. Does this still break FTD? @AyaElAkhras ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant