mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 03:50:17 +08:00
[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`
This commit is contained in:
@@ -121,12 +121,13 @@ LogicalResult MatchQuery::run(llvm::raw_ostream &os, QuerySession &qs) const {
|
||||
Operation *rootOp = qs.getRootOp();
|
||||
int matchCount = 0;
|
||||
matcher::MatchFinder finder;
|
||||
|
||||
StringRef functionName = matcher.getFunctionName();
|
||||
auto matches = finder.collectMatches(rootOp, std::move(matcher));
|
||||
|
||||
// An extract call is recognized by considering if the matcher has a name.
|
||||
// TODO: Consider making the extract more explicit.
|
||||
if (matcher.hasFunctionName()) {
|
||||
auto functionName = matcher.getFunctionName();
|
||||
if (!functionName.empty()) {
|
||||
std::vector<Operation *> flattenedMatches =
|
||||
finder.flattenMatchedOps(matches);
|
||||
Operation *function =
|
||||
|
||||
@@ -319,7 +319,6 @@ public:
|
||||
void mergeChildren(AsyncChildrenMap &&other) {
|
||||
for (auto &thread : other) {
|
||||
mergeChildren(std::move(thread.second));
|
||||
assert(thread.second.empty());
|
||||
}
|
||||
other.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user