[ScopBuilder] Fix bug 38358 by preserving correct order of ScopStmts.
commit159c53ab58d55a21eacc766438a1265e2b6d2da9
authorMichael Kruse <llvm@meinersbur.de>
Thu, 17 Oct 2019 23:55:35 +0000 (17 23:55 +0000)
committerMichael Kruse <llvm@meinersbur.de>
Thu, 17 Oct 2019 23:55:35 +0000 (17 23:55 +0000)
tree7f3159a64b5979329020df260e2ebf112d3ce0cd
parent3c0043e195b5d1aa75f31457aba9014081fa2482
[ScopBuilder] Fix bug 38358 by preserving correct order of ScopStmts.

ScopBuilder::buildEqivClassBlockStmts creates ScopStmts for instruction
groups in basic block and inserts these ScopStmts into Scop::StmtMap,
however, as described in llvm.org/PR38358, comment #5, StmtScops are
inserted into vector ScopStmt[BB] in wrong order.  As a result,
ScopBuilder::buildSchedule creates wrong order sequence node.

Looking closer to code, it's clear there is no equivalent classes with
interleaving isOrderedInstruction(memory access) instructions after
joinOrderedInstructions.  Afterwards, ScopStmts need to be created and
inserted in the original order of memory access instructions, however,
at the moment ScopStmts are inserted in the order of leader instructions
which are probably not memory access instructions.

The fix is simple with a standalone loop scanning
isOrderedInstruction(memory access) instructions in basic block and
inserting elements into LeaderToInstList one by one.  The patch also
removes double reversing operations which are now unnecessary.

New test preserve-equiv-class-order-in-basic_block.ll is also added.

Differential Revision: https://reviews.llvm.org/D68941

git-svn-id: https://llvm.org/svn/llvm-project/polly/trunk@375192 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScopBuilder.cpp
test/ScopInfo/preserve-equiv-class-order-in-basic_block.ll [new file with mode: 0644]