Skip to content

[MLIR][Transforms] Fix dialect conversion inverse mapping #104648

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

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions mlir/lib/Transforms/Utils/DialectConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2527,6 +2527,7 @@ LogicalResult OperationConverter::legalizeConvertedOpResultTypes(
opReplacement->getConverter());
rewriterImpl.mapping.map(result, castValue);
inverseMapping[castValue].push_back(result);
llvm::erase(inverseMapping[newValue], result);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is probably a very short list. Open to changing it to a Set though.

Copy link
Member

Choose a reason for hiding this comment

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

I agree, list is usually very short, so a vector should be fine.

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: mlir-opt -test-target-materialization-with-no-uses %s | FileCheck %s
// RUN: mlir-opt -test-target-materialization-with-no-uses -split-input-file %s | FileCheck %s

// The conversion is set up as follows:
// - type_changer ops are illegal;
Expand All @@ -25,3 +25,12 @@ func.func @foo() {
"test.type_consumer"(%2) : (i64) -> ()
return
}

// -----
Copy link
Member

Choose a reason for hiding this comment

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

Can you add // ----- here and -split-input-file in the // RUN: line?


// CHECK-LABEL: @direct_forward
func.func @direct_forward(%arg0 : i16) -> i16 {
// CHECK-NEXT: return
%0 = "test.type_changer"(%arg0) : (i16) -> i16
return %0 : i16
}
Loading