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

Michael Marjieh llvmlistbot at llvm.org
Sun Mar 29 10:22:54 PDT 2026


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

None

>From 483509b21a2cba1eb5ff707454cdfcb382e03e0c Mon Sep 17 00:00:00 2001
From: Michael Marjieh <michael.marjieh at mobileye.com>
Date: Sun, 29 Mar 2026 20:22:08 +0300
Subject: [PATCH] [Value] Mark getOperandNumber as Const

---
 mlir/include/mlir/IR/BlockSupport.h | 2 +-
 mlir/include/mlir/IR/Value.h        | 2 +-
 mlir/lib/IR/Value.cpp               | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

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];
 }



More information about the Mlir-commits mailing list