From: Michael Kruse Date: Tue, 12 Nov 2019 19:48:07 +0000 (-0600) Subject: [CodeGen] Fix getArrayAccessFor crashes as in bug 32534 with -polly-vectorizer=polly. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0aff3174dcc00516fd26c6554266b05a236166bb;p=platform%2Fupstream%2Fllvm.git [CodeGen] Fix getArrayAccessFor crashes as in bug 32534 with -polly-vectorizer=polly. Root cause is VectorBlockGenerator::copyStmt iterates all instructions in basic block, however some load instructions may be not unnecessary thus removed by simplification. As a result, these load instructions don't have a corresponding array. Looking at BlockGenerator::copyBB, it only iterates instructions list of ScopStmt. Given it must be a block type scop in case of vectorization, I think we should do the same in VectorBlockGenerator::copyStmt. Patch by bin.narwal Differential Revision: https://reviews.llvm.org/D70076 --- diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index 599ae6c..ca8d80f 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -1391,8 +1391,8 @@ void VectorBlockGenerator::copyStmt( generateScalarVectorLoads(Stmt, VectorBlockMap); - for (Instruction &Inst : *BB) - copyInstruction(Stmt, &Inst, VectorBlockMap, ScalarBlockMap, NewAccesses); + for (Instruction *Inst : Stmt.getInstructions()) + copyInstruction(Stmt, Inst, VectorBlockMap, ScalarBlockMap, NewAccesses); verifyNoScalarStores(Stmt); }