[llvm] [MachineInstr] add insert method for variadic instructions (PR #67699)

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 27 16:04:37 PDT 2023


================
@@ -2475,3 +2475,45 @@ MachineInstr::getFirst5RegLLTs() const {
       Reg2, getRegInfo()->getType(Reg2), Reg3, getRegInfo()->getType(Reg3),
       Reg4, getRegInfo()->getType(Reg4));
 }
+
+void MachineInstr::insert(mop_iterator It, ArrayRef<MachineOperand> Ops) {
+  if (!It || Ops.empty())
----------------
MatzeB wrote:

Is it worth handling the `!It` case explicitely. Intuitively it feels odd to apply `!` to an iterator; I guess with `mop_iterator` being just a `MachineOperand*` this could happen, but it feels like an odd jump between abstraction levels...

I think in LLVM we typically rather code for "fail fast" instead of defensively. So would rather expect an `assert(It != nullptr && "invalid iterator")`  (or nothing at all) rather than adding code just to defend against a clearly invalid parameter value...

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


More information about the llvm-commits mailing list