[PATCH] D111150: [AMDGPU] Remove dead frame indices after sgpr spill.

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 6 01:00:55 PDT 2021


foad added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp:459
 
+  for (auto DFI : DeadFrameIndices)
+    SGPRToVGPRSpills.erase(DFI);
----------------
cdevadas wrote:
> hsmhsm wrote:
> > cdevadas wrote:
> > > Isn't it possible to avoid this loop by handling the erase inside the original loop itself?
> > > Maybe convert the range-based loop above into an iterator-based one?
> > As I understand it, it does not help. The llvm DensMap<>::erase() function does not return next iterator. So, erasing DensMap entries while iterating it seems to be *not* possible. Please let me know if you have any idea.
> If erase doesn't return the iterator, better retain this loop. Thanks.
If you write the loop as `for (auto &R : make_early_inc_range(SGPRToVGPRSpills))` then you can erase R inside the loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111150



More information about the llvm-commits mailing list