[PATCH] D111223: [GlobalISel] Simplify RegBankSelect

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 25 07:00:59 PDT 2021


foad added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp:702
     MIRBuilder.setMBB(*MBB);
-    for (MachineBasicBlock::iterator MII = MBB->begin(), End = MBB->end();
-         MII != End;) {
-      // MI might be invalidated by the assignment, so move the
-      // iterator before hand.
-      MachineInstr &MI = *MII++;
+    SmallVector<MachineInstr *> WorkList;
+    for (MachineInstr &MI : reverse(MBB->instrs()))
----------------
sebastian-ne wrote:
> foad wrote:
> > Pass (MBB->instr_rbegin(), MBB->instr_rend()) into the constructor here?
> I just tried and couldn’t get it working. I guess the iterator returns a `MachineInstr&` and no pointer, but `SmallVector<MachineInstr&>` doesn’t work.
Ugh. This might work:
```
SmallVector<MachineInstr *> WorkList(make_pointer_range(reverse(MBB->instrs())));
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111223/new/

https://reviews.llvm.org/D111223



More information about the llvm-commits mailing list