[Mlir-commits] [mlir] 98ceb45 - [mlir] Fix use-after-move issues (#165660)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Oct 30 00:25:14 PDT 2025


Author: Slava Gurevich
Date: 2025-10-30T00:25:10-07:00
New Revision: 98ceb458f42ed05e2c3e9fb5bc75cd6b1df7a438

URL: https://github.com/llvm/llvm-project/commit/98ceb458f42ed05e2c3e9fb5bc75cd6b1df7a438
DIFF: https://github.com/llvm/llvm-project/commit/98ceb458f42ed05e2c3e9fb5bc75cd6b1df7a438.diff

LOG: [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`

Added: 
    

Modified: 
    mlir/lib/Query/Query.cpp
    mlir/lib/Support/Timing.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Query/Query.cpp b/mlir/lib/Query/Query.cpp
index 375e82050a481..cf8a4d293299c 100644
--- a/mlir/lib/Query/Query.cpp
+++ b/mlir/lib/Query/Query.cpp
@@ -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 =

diff  --git a/mlir/lib/Support/Timing.cpp b/mlir/lib/Support/Timing.cpp
index fb6f82c283df5..16306d72815f7 100644
--- a/mlir/lib/Support/Timing.cpp
+++ b/mlir/lib/Support/Timing.cpp
@@ -319,7 +319,6 @@ class TimerImpl {
   void mergeChildren(AsyncChildrenMap &&other) {
     for (auto &thread : other) {
       mergeChildren(std::move(thread.second));
-      assert(thread.second.empty());
     }
     other.clear();
   }


        


More information about the Mlir-commits mailing list