[PATCH] D115747: [AMDGPU] Flush the vmcnt counter in loop preheader when necessary

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 22 06:50:42 PDT 2022


foad added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp:448
+      AMDGPU::Waitcnt Wait,
+      std::function<MachineBasicBlock::instr_iterator()> GetIterator,
+      MachineBasicBlock &Block, WaitcntBrackets &ScoreBrackets,
----------------
bsaleil wrote:
> foad wrote:
> > Why can't you just pass in an iterator? As Nicolai said, they should not get invalidated.
> Couldn't the iterator be invalidated by the call to `applyPreexistingWaitcnt` since we `eraseFromParent()` in it ?
If it erases the instruction that `It` points to then there's a serious problem, and using a callback will not solve it.

If it erases some other instruction then that's OK, the iterator should still be valid.

Instructions are in a doubly linked list and the iterator is more-or-less just a pointer to an instruction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115747



More information about the llvm-commits mailing list