This is an archive of the discontinued LLVM Phabricator instance.

[Polly] Avoid use of `getStmtFor(BB)` in PolyhedralInfo. NFC
ClosedPublic

Authored by nandini12396 on Jul 12 2017, 5:13 AM.

Details

Summary

Since there will be no more a 1-1 correspondence between statements and basic block, we would like to get rid of the method getStmtFor(BB) and its uses. Here we remove one of its uses in PolyhedralInfo, as suggested by Michael Sir.

Diff Detail

Repository
rL LLVM

Event Timeline

nandini12396 created this revision.Jul 12 2017, 5:13 AM
bollu added inline comments.Jul 12 2017, 6:45 AM
include/polly/ScopInfo.h
2562 ↗(On Diff #106180)

If we are eliminating getStmtFor, can this be removed?

lib/Analysis/PolyhedralInfo.cpp
135 ↗(On Diff #106180)

Undesired change?

lib/Analysis/ScopInfo.cpp
4916 ↗(On Diff #106180)

Please add an assert message along with the assert.

assert(StmtMapIt->second.size() == 1 && "We currently only have one Stmt per BB");
nandini12396 added inline comments.Jul 12 2017, 9:11 AM
include/polly/ScopInfo.h
2562 ↗(On Diff #106180)

yes, I am planning to remove it once I delete all its uses.

lib/Analysis/PolyhedralInfo.cpp
135 ↗(On Diff #106180)

oh, this happened after polly-update-format. Thanks for pointing out.

lib/Analysis/ScopInfo.cpp
4916 ↗(On Diff #106180)

oh, yes. Thanks I will add it.

Meinersbur added inline comments.Jul 13 2017, 9:50 AM
include/polly/ScopInfo.h
2565 ↗(On Diff #106180)

Please do not return a copy of the entire vector. You can return:

  1. A const std::vector<ScopStmt *>&
  2. An ArrayRef<ScopStmt*>
  3. An llvm::iterator_range<std::vector<ScopStmt *>::const_iterator>
lib/Analysis/PolyhedralInfo.cpp
129–130 ↗(On Diff #106180)

These two loops only iterate once over all statements in a loop. It is simpler to do with

for (auto &SS : *S)
  if (L->contains(SS.getSurroundingLoop()))

which also protects from iterating region statements multiple times.

However, I am also fine with using getStmtListFor if we need it for other purposes as well.

grosser edited edge metadata.Jul 13 2017, 1:51 PM

I like Michael's idea! It does not even nee the getStmtList function.

grosser requested changes to this revision.Jul 14 2017, 12:38 AM

Marking this as requesting changes to make sure I get notified when you update the commit.

This revision now requires changes to proceed.Jul 14 2017, 12:38 AM
nandini12396 edited edge metadata.
nandini12396 edited the summary of this revision. (Show Details)
grosser accepted this revision.Jul 15 2017, 3:45 PM

This looks good to me

Let's wait for Michael's feedback!

This revision is now accepted and ready to land.Jul 15 2017, 3:45 PM
This revision was automatically updated to reflect the committed changes.