During the construction of MemoryAccesses in ScopBuilder, BasicBlocks were used in function parameters, assuming that the ScopStmt an be directly derived from it. This won't be true anymore once we split BasicBlocks into multiple ScopStmt. As a preparation for such a change in the future, we instead pass the ScopStmt and avoid the use of getStmtFor().
There are three occasions where a kind of mapping from BasicBlock to ScopStmt is still required.
- Initial enumeration all statements to create their MemoryAccesses. This uses getStmtsFor which returns a list of statement or getStmtFor for regions statements.
Using this could be avoided by just iterating linearly over all ScopStmts. This unfortunately changes the order of MemoryAccesses, which in turn would require changing a lot of regression tests.
- Get the statement representing the incoming block of a PHINode using getLastStmtOf.
- One statement is required to write a scalar to be readable by those which need it. This is most often the statement which contains its definition, which we get using getStmtFor(Instruction*).