[polly] r326643 - [Acc] Fix for PR33208

Philip Pfaffe via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 3 02:47:37 PST 2018


Author: pfaffe
Date: Sat Mar  3 02:47:37 2018
New Revision: 326643

URL: http://llvm.org/viewvc/llvm-project?rev=326643&view=rev
Log:
[Acc] Fix for PR33208

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. This fixes currently
failing testcases.

Modified:
    polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp

Modified: polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp?rev=326643&r1=326642&r2=326643&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Sat Mar  3 02:47:37 2018
@@ -1555,20 +1555,16 @@ void GPUNodeBuilder::clearDominators(Fun
 }
 
 void GPUNodeBuilder::clearScalarEvolution(Function *F) {
-  for (BasicBlock &BB : *F) {
-    Loop *L = LI.getLoopFor(&BB);
+  for (auto *L : LI)
     if (L)
       SE.forgetLoop(L);
-  }
 }
 
 void GPUNodeBuilder::clearLoops(Function *F) {
-  for (BasicBlock &BB : *F) {
-    Loop *L = LI.getLoopFor(&BB);
-    if (L)
-      SE.forgetLoop(L);
-    LI.removeBlock(&BB);
-  }
+  clearScalarEvolution(F);
+  SmallVector<Loop *, 1> Loops(LI.begin(), LI.end());
+  for (auto *L : Loops)
+    LI.erase(L);
 }
 
 std::tuple<Value *, Value *> GPUNodeBuilder::getGridSizes(ppcg_kernel *Kernel) {




More information about the llvm-commits mailing list