[Mlir-commits] [mlir] d23b9db - [mlir][tblgen] Avoid copies when iterating symbols (NFC) (#220910)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Sep 3 05:47:04 PDT 2026


Author: Mehdi Amini
Date: 2026-09-03T12:46:58Z
New Revision: d23b9dbc4e8b25fc673970b27fad53a2e7a7fe60

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

LOG: [mlir][tblgen] Avoid copies when iterating symbols (NFC) (#220910)

Use a const structured binding when looking up locally bound symbols.
The symbol name and SymbolInfo remain owned by localSymbolMap for the
duration of the lookup, so copying both values is unnecessary.

Found by Coverity.

Assisted-by: Codex

Added: 
    

Modified: 
    mlir/tools/mlir-tblgen/RewriterGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index 5bc2ac48b4726..a53ced0e394cb 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -430,10 +430,8 @@ void PatternEmitter::emitStaticMatchCall(DagNode tree, StringRef opName) {
   SymbolInfoMap localSymbolMap(loc);
   pattern.collectBoundSymbols(tree, localSymbolMap, /*isSrcPattern=*/true);
 
-  for (const auto &info : localSymbolMap) {
-    auto name = info.first;
-    auto symboInfo = info.second;
-    auto ret = symbolInfoMap.findBoundSymbol(name, symboInfo);
+  for (const auto &[name, symbolInfo] : localSymbolMap) {
+    auto ret = symbolInfoMap.findBoundSymbol(name, symbolInfo);
     os << formatv(", {0}", ret->second.getVarName(name));
   }
 


        


More information about the Mlir-commits mailing list