[Mlir-commits] [mlir] [mlir][RemoveDeadValues] Use `SymbolUserMap` to avoid quadratic symbol lookups (PR #205448)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Jun 23 15:53:21 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- mlir/lib/Transforms/RemoveDeadValues.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/lib/Transforms/RemoveDeadValues.cpp b/mlir/lib/Transforms/RemoveDeadValues.cpp
index 7210e4982..671e06bc1 100644
--- a/mlir/lib/Transforms/RemoveDeadValues.cpp
+++ b/mlir/lib/Transforms/RemoveDeadValues.cpp
@@ -281,9 +281,8 @@ static void processFuncOp(FunctionOpInterface funcOp,
     return;
   }
   ArrayRef<Operation *> users = symbolUserMap.getUsers(funcOp);
-  if (llvm::any_of(users, [](Operation *user) {
-        return !isa<CallOpInterface>(user);
-      })) {
+  if (llvm::any_of(
+          users, [](Operation *user) { return !isa<CallOpInterface>(user); })) {
     // If a non-call operation references the function (e.g. spirv.EntryPoint),
     // we cannot safely remove arguments or return values since we don't know
     // what the user expects. Skip this function entirely.
@@ -769,8 +768,9 @@ void RemoveDeadValues::runOnOperation() {
   Operation *module = getOperation();
 
   // Build a symbol user map once up front so that processFuncOp can look up the
-  // callers of each function in O(1). Otherwise, each call would walk the entire
-  // module to find the callers, making the pass O(numFunctions * numOperations).
+  // callers of each function in O(1). Otherwise, each call would walk the
+  // entire module to find the callers, making the pass O(numFunctions *
+  // numOperations).
   SymbolTableCollection symbolTableCollection;
   SymbolUserMap symbolUserMap(symbolTableCollection, module);
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/205448


More information about the Mlir-commits mailing list