[PATCH] D39979: [Polly][SI] Fix a potential use-after-free

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 06:35:18 PST 2017


Meinersbur accepted this revision.
Meinersbur added a comment.
This revision is now accepted and ready to land.

LGMT, thanks.



================
Comment at: lib/Analysis/ScopInfo.cpp:4843
 
-  auto &LoopData = LoopStack.back();
-  LoopData.NumBlocksProcessed += getNumBlocksInRegionNode(RN);
+  auto LoopData = LoopStack.rbegin();
+  LoopData->NumBlocksProcessed += getNumBlocksInRegionNode(RN);
----------------
Could you consider adding an assertion `LoopData != LoopStack.rend()` as well?


================
Comment at: lib/Analysis/ScopInfo.cpp:4861
   // completed by this node.
-  while (LoopData.L &&
-         LoopData.NumBlocksProcessed == getNumBlocksInLoop(LoopData.L)) {
-    auto *Schedule = LoopData.Schedule;
-    auto NumBlocksProcessed = LoopData.NumBlocksProcessed;
+  auto Dimension = LoopStack.size();
+  while (LoopData->L &&
----------------
[Nit] `LoopStack.size()` returns `size_t`, no "almost-always-auto" as of [[ https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable | LLVM coding standards ]].


================
Comment at: lib/Analysis/ScopInfo.cpp:4880
   }
+  LoopStack.erase(LoopStack.begin() + Dimension, LoopStack.end());
 }
----------------
Could you consider adding a comment on why the stack has to be popped only at the end?


https://reviews.llvm.org/D39979





More information about the llvm-commits mailing list