Skip to content

Commit 98ceb45

Browse files
authored
[mlir] Fix use-after-move issues (#165660)
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 ensures no subsequent use for the moved-from variable. Testing: `ninja check-mlir`
1 parent 4d7093b commit 98ceb45

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

mlir/lib/Query/Query.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,13 @@ LogicalResult MatchQuery::run(llvm::raw_ostream &os, QuerySession &qs) const {
121121
Operation *rootOp = qs.getRootOp();
122122
int matchCount = 0;
123123
matcher::MatchFinder finder;
124+
125+
StringRef functionName = matcher.getFunctionName();
124126
auto matches = finder.collectMatches(rootOp, std::move(matcher));
125127

126128
// An extract call is recognized by considering if the matcher has a name.
127129
// TODO: Consider making the extract more explicit.
128-
if (matcher.hasFunctionName()) {
129-
auto functionName = matcher.getFunctionName();
130+
if (!functionName.empty()) {
130131
std::vector<Operation *> flattenedMatches =
131132
finder.flattenMatchedOps(matches);
132133
Operation *function =

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)