[Mlir-commits] [mlir] Update documentation for MutableOperandRange (PR #65865)

Roy Tu llvmlistbot at llvm.org
Sat Sep 9 15:15:46 PDT 2023


https://github.com/roytu created https://github.com/llvm/llvm-project/pull/65865:

See https://github.com/llvm/llvm-project/issues/65829

Caching `MutableOperandRange`'s within an op with `AttrSizedOperandSegments`, then accidentally invalidating them by editing an operand range, seems like a common issue. Added some documentation to perhaps help with this.

Note: I'm not sure if this is the best place to document something like this, or if we even need this at all -- please feel free to reject if you think it's too much of an edge case. Thanks :)

>From abeded9a7438e1bd7ed018df3be56e66be58dee8 Mon Sep 17 00:00:00 2001
From: Roy Tu <thatsnail at gmail.com>
Date: Sat, 9 Sep 2023 15:14:05 -0700
Subject: [PATCH] Update documentation for MutableOperandRange

See https://github.com/llvm/llvm-project/issues/65829

Caching `MutableOperandRange`'s within an op with `AttrSizedOperandSegments`, then accidentally invalidating them by editing an operand range, seems like a common issue. Added some documentation to perhaps help with this.
---
 mlir/include/mlir/IR/ValueRange.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mlir/include/mlir/IR/ValueRange.h b/mlir/include/mlir/IR/ValueRange.h
index 187185b47b66695..e57ccc1924685fd 100644
--- a/mlir/include/mlir/IR/ValueRange.h
+++ b/mlir/include/mlir/IR/ValueRange.h
@@ -112,6 +112,10 @@ class OperandRangeRange final
 
 /// This class provides a mutable adaptor for a range of operands. It allows for
 /// setting, inserting, and erasing operands from the given range.
+///
+/// (Note that when using AttrSizedOperandSegments, making changes to a
+/// MutableOperandRange invalidates other MutableOperandRange's in memory; you
+/// must get a new mutable adaptor for the other operand ranges).
 class MutableOperandRange {
 public:
   /// A pair of a named attribute corresponding to an operand segment attribute,



More information about the Mlir-commits mailing list