[Mlir-commits] [mlir] [Value] Mark getOperandNumber as Const (PR #189267)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Mar 29 10:23:30 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-core

Author: Michael Marjieh (mmarjieh)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/189267.diff


3 Files Affected:

- (modified) mlir/include/mlir/IR/BlockSupport.h (+1-1) 
- (modified) mlir/include/mlir/IR/Value.h (+1-1) 
- (modified) mlir/lib/IR/Value.cpp (+2-2) 


``````````diff
diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h
index a2e080ef4f63f..77c2f314a9345 100644
--- a/mlir/include/mlir/IR/BlockSupport.h
+++ b/mlir/include/mlir/IR/BlockSupport.h
@@ -35,7 +35,7 @@ class BlockOperand : public IROperand<BlockOperand, Block *> {
   static IRObjectWithUseList<BlockOperand> *getUseList(Block *value);
 
   /// Return which operand this is in the BlockOperand list of the Operation.
-  unsigned getOperandNumber();
+  unsigned getOperandNumber() const;
 };
 
 //===----------------------------------------------------------------------===//
diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h
index e72ace0920eb1..79d3fc5fd8a59 100644
--- a/mlir/include/mlir/IR/Value.h
+++ b/mlir/include/mlir/IR/Value.h
@@ -259,7 +259,7 @@ class OpOperand : public IROperand<OpOperand, Value> {
   }
 
   /// Return which operand this is in the OpOperand list of the Operation.
-  unsigned getOperandNumber();
+  unsigned getOperandNumber() const;
 
   /// Set the current value being used by this operand.
   void assign(Value value) { set(value); }
diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp
index fa550e4d5d5d0..cf793680f7efd 100644
--- a/mlir/lib/IR/Value.cpp
+++ b/mlir/lib/IR/Value.cpp
@@ -214,7 +214,7 @@ IRObjectWithUseList<BlockOperand> *BlockOperand::getUseList(Block *value) {
 }
 
 /// Return which operand this is in the operand list.
-unsigned BlockOperand::getOperandNumber() {
+unsigned BlockOperand::getOperandNumber() const {
   return this - &getOwner()->getBlockOperands()[0];
 }
 
@@ -223,6 +223,6 @@ unsigned BlockOperand::getOperandNumber() {
 //===----------------------------------------------------------------------===//
 
 /// Return which operand this is in the operand list.
-unsigned OpOperand::getOperandNumber() {
+unsigned OpOperand::getOperandNumber() const {
   return this - &getOwner()->getOpOperands()[0];
 }

``````````

</details>


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


More information about the Mlir-commits mailing list