diff options
Diffstat (limited to 'polly/lib/CodeGen/BlockGenerators.cpp')
-rw-r--r-- | polly/lib/CodeGen/BlockGenerators.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index 084f6d4643b..f53ab75c315 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -1168,17 +1168,22 @@ void RegionGenerator::generateScalarStores(ScopStmt &Stmt, LoopToScevMapT <S, // In case we add the store into an exiting block, we need to restore the // position for stores in the exit node. auto SavedInsertionPoint = Builder.GetInsertPoint(); + ValueMapT *LocalBBMap = &BBMap; // Implicit writes induced by PHIs must be written in the incoming blocks. if (isa<TerminatorInst>(ScalarInst)) { BasicBlock *ExitingBB = ScalarInst->getParent(); BasicBlock *ExitingBBCopy = BlockMap[ExitingBB]; Builder.SetInsertPoint(ExitingBBCopy->getTerminator()); + + // For the incoming blocks, use the block's BBMap instead of the one for + // the entire region. + LocalBBMap = &RegionMaps[ExitingBBCopy]; } auto Address = getOrCreateAlloca(*MA); - Val = getNewScalarValue(Val, R, Stmt, LTS, BBMap); + Val = getNewScalarValue(Val, R, Stmt, LTS, *LocalBBMap); Builder.CreateStore(Val, Address); // Restore the insertion point if necessary. |