[Mlir-commits] [mlir] [MLIR][LivenessAnalysis] Add custom visitCallOperation (PR #160984)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Sep 26 23:02:20 PDT 2025


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,h -- mlir/include/mlir/Analysis/DataFlow/LivenessAnalysis.h mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp
``````````

: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/include/mlir/Analysis/DataFlow/LivenessAnalysis.h b/mlir/include/mlir/Analysis/DataFlow/LivenessAnalysis.h
index e13822f06..a782c7f8c 100644
--- a/mlir/include/mlir/Analysis/DataFlow/LivenessAnalysis.h
+++ b/mlir/include/mlir/Analysis/DataFlow/LivenessAnalysis.h
@@ -83,8 +83,7 @@ public:
                                ArrayRef<const Liveness *> results) override;
 
   LogicalResult
-  visitCallOperation(CallOpInterface call,
-                     ArrayRef<Liveness *> operandLattices,
+  visitCallOperation(CallOpInterface call, ArrayRef<Liveness *> operandLattices,
                      ArrayRef<const Liveness *> resultLattices) override;
 
   void visitBranchOperand(OpOperand &operand) override;
diff --git a/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h b/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
index 53aa4d03f..b9eb7d212 100644
--- a/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
+++ b/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
@@ -537,10 +537,10 @@ public:
 
   // implementation-specific hook for visitCallOperation.
   virtual LogicalResult visitCallOperation(CallOpInterface call,
-                                       ArrayRef<StateT *> operands,
-                                       ArrayRef<const StateT *> results) {
-                                        return failure();
-                                       }
+                                           ArrayRef<StateT *> operands,
+                                           ArrayRef<const StateT *> results) {
+    return failure();
+  }
 
   /// Visit a call to an external function. This function is expected to set
   /// lattice values of the call operands. By default, calls `visitCallOperand`
@@ -606,7 +606,6 @@ private:
         {reinterpret_cast<const StateT *const *>(resultLattices.begin()),
          resultLattices.size()});
   }
-
 };
 
 } // end namespace dataflow
diff --git a/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp b/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp
index 6b1809bc8..d0102e053 100644
--- a/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp
@@ -117,18 +117,19 @@ LivenessAnalysis::visitOperation(Operation *op, ArrayRef<Liveness *> operands,
 }
 
 LogicalResult
-LivenessAnalysis::visitCallOperation(CallOpInterface call, ArrayRef<Liveness *> operands,
-                                 ArrayRef<const Liveness *> results) {
-  LDBG() << "[visitCallOperation] inspecting " <<  call;
+LivenessAnalysis::visitCallOperation(CallOpInterface call,
+                                     ArrayRef<Liveness *> operands,
+                                     ArrayRef<const Liveness *> results) {
+  LDBG() << "[visitCallOperation] inspecting " << call;
   // For thread-safety, check config first before accessing symbolTable.
   if (!getSolverConfig().isInterprocedural()) {
-      visitExternalCall(call, operands, results);
-      return success();
+    visitExternalCall(call, operands, results);
+    return success();
   }
   Operation *callableOp = call.resolveCallableInTable(&symbolTable);
   if (auto funcOp = dyn_cast<FunctionOpInterface>(callableOp)) {
     if (funcOp.isPublic()) {
-      LDBG() << "[visitCallOperation] encounter a public function " <<  funcOp
+      LDBG() << "[visitCallOperation] encounter a public function " << funcOp
              << " Treat it as external.";
       visitExternalCall(call, operands, results);
       return success();
diff --git a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp
index c7169bf97..6df3d0adb 100644
--- a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp
@@ -497,14 +497,15 @@ AbstractSparseBackwardDataFlowAnalysis::visitOperation(Operation *op) {
   if (auto call = dyn_cast<CallOpInterface>(op)) {
     LDBG() << "Processing CallOpInterface operation";
 
-    if (visitCallOperationImpl(call, operandLattices, resultLattices).succeeded()) {
+    if (visitCallOperationImpl(call, operandLattices, resultLattices)
+            .succeeded()) {
       return success();
     }
 
     //  Treat any function as external due to config.
     if (!getSolverConfig().isInterprocedural()) {
-        visitExternalCallImpl(call, operandLattices, resultLattices);
-        return success();
+      visitExternalCallImpl(call, operandLattices, resultLattices);
+      return success();
     }
 
     Operation *callableOp = call.resolveCallableInTable(&symbolTable);
@@ -513,8 +514,9 @@ AbstractSparseBackwardDataFlowAnalysis::visitOperation(Operation *op) {
       // stored in `unaccounted`.
       BitVector unaccounted(op->getNumOperands(), true);
 
-      // If the call invokes an external function, defer to the corresponding extension hook.
-      // By default, it just does `visitCallOperand` for all operands.
+      // If the call invokes an external function, defer to the corresponding
+      // extension hook. By default, it just does `visitCallOperand` for all
+      // operands.
       OperandRange argOperands = call.getArgOperands();
       MutableArrayRef<OpOperand> argOpOperands =
           operandsToOpOperands(argOperands);

``````````

</details>


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


More information about the Mlir-commits mailing list