Skip to content

Commit dc7376d

Browse files
committed
[MLIR] Fix use-after-move issues
This patch addresses two use-after-move issues: 1. Timing.cpp A variable was std::moved and then immediately passed to an assert() check. Since the moved-from state made the assertion condition trivially true, the check was effectively useless. The assert() is removed. 2. Query.cpp The `matcher` object was moved-from and then subsequently used as if it still retained valid state. The fix removes the std::move to preserve the original object. It is possible to restructure the surrounding logic to maintain the move semantics, but doing so would reduce clarity. If needed, such restructuring can be considered later based on performance profiling. Testing: ninja check-mlir
1 parent 4c46ae3 commit dc7376d

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

mlir/lib/Query/Query.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ LogicalResult MatchQuery::run(llvm::raw_ostream &os, QuerySession &qs) const {
121121
Operation *rootOp = qs.getRootOp();
122122
int matchCount = 0;
123123
matcher::MatchFinder finder;
124-
auto matches = finder.collectMatches(rootOp, std::move(matcher));
124+
auto matches = finder.collectMatches(rootOp, matcher);
125125

126126
// An extract call is recognized by considering if the matcher has a name.
127127
// TODO: Consider making the extract more explicit.

mlir/lib/Support/Timing.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ class TimerImpl {
319319
void mergeChildren(AsyncChildrenMap &&other) {
320320
for (auto &thread : other) {
321321
mergeChildren(std::move(thread.second));
322-
assert(thread.second.empty());
323322
}
324323
other.clear();
325324
}

0 commit comments

Comments
 (0)