Skip to content

[mlir][Transforms][NFC] Dialect Conversion: Manually populate unresolvedMaterializations #144664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 5 additions & 4 deletions mlir/lib/Transforms/Utils/DialectConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,9 +869,10 @@ struct ConversionPatternRewriterImpl : public RewriterBase::Listener {
/// Append a rewrite. Rewrites are committed upon success and rolled back upon
/// failure.
template <typename RewriteTy, typename... Args>
void appendRewrite(Args &&...args) {
RewriteTy *appendRewrite(Args &&...args) {
rewrites.push_back(
std::make_unique<RewriteTy>(*this, std::forward<Args>(args)...));
return static_cast<RewriteTy *>(rewrites.back().get());
}

/// Undo the rewrites (motions, splits) one by one in reverse order until
Expand Down Expand Up @@ -1181,7 +1182,6 @@ UnresolvedMaterializationRewrite::UnresolvedMaterializationRewrite(
mappedValues(std::move(mappedValues)) {
assert((!originalType || kind == MaterializationKind::Target) &&
"original type is valid only for target materializations");
rewriterImpl.unresolvedMaterializations[op] = this;
}

void UnresolvedMaterializationRewrite::rollback() {
Expand Down Expand Up @@ -1471,8 +1471,9 @@ ValueRange ConversionPatternRewriterImpl::buildUnresolvedMaterialization(
mapping.map(valuesToMap, convertOp.getResults());
if (castOp)
*castOp = convertOp;
appendRewrite<UnresolvedMaterializationRewrite>(
convertOp, converter, kind, originalType, std::move(valuesToMap));
unresolvedMaterializations[convertOp] =
appendRewrite<UnresolvedMaterializationRewrite>(
convertOp, converter, kind, originalType, std::move(valuesToMap));
return convertOp.getResults();
}

Expand Down
Loading