[PATCH] D43872: [Polly][Acc] Fix for PR33208

Philip Pfaffe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 07:40:01 PST 2018


philip.pfaffe created this revision.
philip.pfaffe added a reviewer: Meinersbur.
philip.pfaffe added a project: Polly.
Herald added subscribers: llvm-commits, bollu, kbarton, nemanjai.
Herald added a reviewer: bollu.

During codegen, Polly attempts to clear all loops from ScalarEvolution and LoopInfo, and it does so one block at a time. This causes undefined behaviour, since this way a loop header might be removed from a loop before the entire loop is erased, causing ScalarEvolution to run into an error.

      

Instead, just delete the entire loop atomically.


Repository:
  rPLO Polly

https://reviews.llvm.org/D43872

Files:
  polly/lib/CodeGen/PPCGCodeGeneration.cpp


Index: polly/lib/CodeGen/PPCGCodeGeneration.cpp
===================================================================
--- polly/lib/CodeGen/PPCGCodeGeneration.cpp
+++ polly/lib/CodeGen/PPCGCodeGeneration.cpp
@@ -1557,16 +1557,20 @@
 }
 
 void GPUNodeBuilder::clearScalarEvolution(Function *F) {
-  for (auto *L : LI)
+  for (BasicBlock &BB : *F) {
+    Loop *L = LI.getLoopFor(&BB);
     if (L)
       SE.forgetLoop(L);
+  }
 }
 
 void GPUNodeBuilder::clearLoops(Function *F) {
-  clearScalarEvolution(F);
-  SmallVector<Loop *, 1> Loops(LI.begin(), LI.end());
-  for (auto *L : Loops)
-    LI.erase(L);
+  for (BasicBlock &BB : *F) {
+    Loop *L = LI.getLoopFor(&BB);
+    if (L)
+      SE.forgetLoop(L);
+    LI.removeBlock(&BB);
+  }
 }
 
 std::tuple<Value *, Value *> GPUNodeBuilder::getGridSizes(ppcg_kernel *Kernel) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43872.136293.patch
Type: text/x-patch
Size: 823 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180228/4af922bf/attachment.bin>


More information about the llvm-commits mailing list