[llvm] [NFC][LLVM] Refactor MachineInstr operand accessors (PR #137261)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 25 07:17:57 PDT 2025


================
@@ -676,68 +672,61 @@ class MachineInstr
   const_mop_iterator operands_begin() const { return Operands; }
   const_mop_iterator operands_end() const { return Operands + NumOperands; }
 
-  iterator_range<mop_iterator> operands() {
-    return make_range(operands_begin(), operands_end());
+  MutableArrayRef<MachineOperand> operands() {
----------------
jurahul wrote:

Does iterator_range<> hide it any more than this? It does not AFAICT (unless I am mistaken). Using ArrayRef makes it possible to use take_front() and drop_front() etc which are more convenient to use. Code that uses vanilla iteration over these (as it most code) will continue to work in either case. Code that relies on specific type being returned by these will break in any case I think.

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


More information about the llvm-commits mailing list