[PATCH] D89386: [AMDGPU] Fix access beyond the end of the basic block in execMayBeModifiedBeforeAnyUse.

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 14 06:00:51 PDT 2020


foad added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/SIInstrInfo.cpp:7096
 }
-
 bool llvm::execMayBeModifiedBeforeAnyUse(const MachineRegisterInfo &MRI,
----------------
Please leave the blank line!


================
Comment at: llvm/lib/Target/AMDGPU/SIInstrInfo.cpp:7122
   // Stop scan when we have seen all the uses.
   for (auto I = std::next(DefMI.getIterator()); ; ++I) {
+    assert(I != DefBB->end());
----------------
Is it possible to enter this loop with NumUse == 0? If so, I would expect the assert on the next line to fail.


================
Comment at: llvm/lib/Target/AMDGPU/SIInstrInfo.cpp:7131-7132
 
-    if (I->readsRegister(VReg))
-      if (--NumUseInst == 0)
-        return false;
+    for (unsigned OpI = 0, E = I->getNumOperands(); OpI != E; ++OpI) {
+      const auto &Op = I->getOperand(OpI);
 
----------------
Use a range-based for over I->operands() ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89386



More information about the llvm-commits mailing list