diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index 4d6d89fa69a07..e773d199c3c23 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -131,10 +131,10 @@ class Value { void setLoc(Location loc); /// Return the Region in which this Value is defined. - Region *getParentRegion(); + Region *getParentRegion() const; /// Return the Block in which this Value is defined. - Block *getParentBlock(); + Block *getParentBlock() const; //===--------------------------------------------------------------------===// // UseLists diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp index fa550e4d5d5d0..2cffb962f8543 100644 --- a/mlir/lib/IR/Value.cpp +++ b/mlir/lib/IR/Value.cpp @@ -36,14 +36,14 @@ void Value::setLoc(Location loc) { } /// Return the Region in which this Value is defined. -Region *Value::getParentRegion() { +Region *Value::getParentRegion() const { if (auto *op = getDefiningOp()) return op->getParentRegion(); return llvm::cast(*this).getOwner()->getParent(); } /// Return the Block in which this Value is defined. -Block *Value::getParentBlock() { +Block *Value::getParentBlock() const { if (Operation *op = getDefiningOp()) return op->getBlock(); return llvm::cast(*this).getOwner();