[PATCH] D136434: [NFC] Fix invalid iterator dereferencing in MachineLoop::getBottomBlock

Sergei Kachkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 21 02:32:47 PDT 2022


kachkov98 created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
kachkov98 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

If bottom block of the loop is the last basic block in function,
dereferencing of end() iterator can occur (and for other basic
blocks the condition is always false); fix typo in this check.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136434

Files:
  llvm/lib/CodeGen/MachineLoopInfo.cpp


Index: llvm/lib/CodeGen/MachineLoopInfo.cpp
===================================================================
--- llvm/lib/CodeGen/MachineLoopInfo.cpp
+++ llvm/lib/CodeGen/MachineLoopInfo.cpp
@@ -80,7 +80,7 @@
     MachineBasicBlock *NextMBB = &*std::next(BotMBB->getIterator());
     while (contains(NextMBB)) {
       BotMBB = NextMBB;
-      if (BotMBB == &*std::next(BotMBB->getIterator()))
+      if (BotMBB->getIterator() == std::prev(End))
         break;
       NextMBB = &*std::next(BotMBB->getIterator());
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136434.469518.patch
Type: text/x-patch
Size: 525 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221021/6d9e8e4f/attachment.bin>


More information about the llvm-commits mailing list