[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.
git-svn-id: https://llvm.org/svn/llvm-project/polly/trunk@326643 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/PPCGCodeGeneration.cpp b/lib/CodeGen/PPCGCodeGeneration.cpp
index 5bf31e6..2366b5e 100644
--- a/lib/CodeGen/PPCGCodeGeneration.cpp
+++ b/lib/CodeGen/PPCGCodeGeneration.cpp
@@ -1555,20 +1555,16 @@
}
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) {