This is an archive of the discontinued LLVM Phabricator instance.

[Polly][ScopBuilder] Pass ScopStmts around instead of BasicBlocks. NFC.
ClosedPublic

Authored by Meinersbur on Jun 19 2017, 3:16 PM.

Details

Summary

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.

  1. 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.

  1. Get the statement representing the incoming block of a PHINode using getLastStmtOf.
  1. 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*).

Diff Detail

Repository
rL LLVM

Event Timeline

Meinersbur created this revision.Jun 19 2017, 3:16 PM
grosser accepted this revision.Jun 20 2017, 12:33 AM

LGTM.

This revision is now accepted and ready to land.Jun 20 2017, 12:33 AM
nandini12396 accepted this revision.Jun 21 2017, 12:24 AM

This is amazing, Sir!

lib/Analysis/ScopBuilder.cpp
668 ↗(On Diff #103112)

Can you please explain this to me?

This revision was automatically updated to reflect the committed changes.
Meinersbur added inline comments.Jun 24 2017, 3:14 AM
lib/Analysis/ScopBuilder.cpp
668 ↗(On Diff #103112)

The exit block is the one executed after the SCoP. It formally does not belong to the SCoP, but can have PHI nodes in it that need to be handled (MemoryAccesses to be added).

Because it does not belong to the SCoP, there is not ScopStmt for it, i.e. Stmt is nullptr. It is the only reason why Stmt could be nullptr, everything else in the SCoP should have a ScopStmt representing it.