ScopStmts were being used in the computation of the Domain of the SCoPs in ScopInfo. Once statements are split, there will not be a 1-to-1 correspondence between Stmts and Basic blocks. Thus this patch avoids the use of getStmtFor() by creating a map of BB to InvalidDomain and using it to compute the domain of the statements.
Details
Diff Detail
Event Timeline
lib/Analysis/ScopInfo.cpp | ||
---|---|---|
2624 | @Meinersbur : I would like to clarify again what it is to be done here. You said that the easiest approach would be to iterate over all statements that represent this BB and set their Invalid Domain. But I got confused why that is inefficient? Could you please repeat what you meant by using the DomainMap which maps BasicBlocks to their domains? |
lib/Analysis/ScopInfo.cpp | ||
---|---|---|
2624 | Ok, I think I understood what you meant. Create a map of BB to Invalid Domain. So there is no need of using getStmtFor(BB) by directly setting in the map and using it to get it. |
lib/Analysis/ScopInfo.cpp | ||
---|---|---|
2624 | Yes, I meant creating a map and in a first step, compute the domain only for that map. InvalidDomainMap[EntryBB] = ... Then, in a second step, apply the InvalidDomain to all statement for their BasicBlock. See Scop::DomainMap for a similar approach. |
Please don't remove an overload of getStmtFor if it is still called somewhere. It doesn't compile otherwise. It must also pass check-polly so we can see there are no unintended behavioral changes.
lib/Analysis/ScopInfo.cpp | ||
---|---|---|
2626–2627 | Please only iterate and setInvalidDomain only once at the end of the function, when InvalidDomainMap contains all latest entries. You cannot call getBasicBlock() on region statements. | |
2727 | Note that there are also region statements, which do not have a 1-to-1 correlation between statements and a BasicBlock. You might either normalize to a region's entry block, or use the RegionNodetype (the RN variable) instead. | |
2743–2744 | Update InvalidDomainMap instead. |
Hello Sir. I updated the diff to incorporate your comments. However, I don't know what I did wrong and there are 755 unexpected failures. Im still trying to understand that.
Sir, afaiu the problem seems to be that there maybe not be any ScopStmt, to which the first / last instruction of the BB belongs to; and hence the ScopStmt is null. So should I iterate over BB until I find the first/last instruction which corresponds to a ScopStmt ?
include/polly/ScopInfo.h | ||
---|---|---|
2510–2513 | Why did you move the location of this declaration? | |
lib/Analysis/ScopInfo.cpp | ||
1327 | As long as we did not remove getStmtFor(Instruction*), you can keep the assertion. | |
2655–2658 | There is ScopStmt::getEntryBlock() which returns you the (Entry-)Block for the two cases. | |
2770 | You must replace all occurrences of setInvalidDomain to update InvalidDomainMap instead. | |
2782 | Shouldn't this changed to update InvalidDomainMap? | |
3013 | The StmtMap does not contain all instructions. It never includes the terminator which PredBB->back() return. That is getStmtFor cannot any statement for its input. This applies similarly to getStmtFor(&BB->front() as well which can be a synthesizable value. |
The most appearing cause of failure of the test cases is:
opt: /home/nandini/llvm/tools/polly/lib/Analysis/ScopInfo.cpp:3058: bool polly::Scop::propagateDomainConstraints(llvm::Region*, llvm::DominatorTree&, llvm::LoopInfo&): Assertion `Domain' failed.
But I do not seem to understand the reason for this assertion fail. Can you please give me some pointers?
lib/Analysis/ScopInfo.cpp | ||
---|---|---|
1474 | @Meinersbur : I think I am doing something wrong here. Can you please help. |
lib/Analysis/ScopBuilder.cpp | ||
---|---|---|
956 ↗ | (On Diff #103408) | The ScopStmt's invalid domains have already set in buildDomains. That is, the elements of InvalidDomainMap have been consumed already and setting them has no effect. |
lib/Analysis/ScopInfo.cpp | ||
2131 | getBasicBlock() returns nullptr if Stmt is a region statement. | |
2654–2655 | When we have multiple statements per BasicBlock, this would consume the same InvalidDomainMap[Stmt.getEntryBlock()] twice, giving us an use-after-free sometime later. How are you sure that all entries of InvalidDomainMap are an entry block of some statement? There could be an BB from the middle of a region statement. Such a block's invalid domain would not be consumed, therefore leaking. | |
2830 | You are leaking isl objects here: InvalidDomainMap[ExitBB] may already contain a value. This is probably not the only leak. You can find some leak by using valgrind --leak-check=full on a failing test case with -polly-on-isl-error-abort=0 added could be useful to find those. |
I think it will be better to change the isl functions to their corresponding c++ version in another patch, since the change is large.
Could you make use of getFirstNonBoxedLoopFor? Then it LGTM.
lib/Analysis/ScopInfo.cpp | ||
---|---|---|
2784 | Please try to avoid unrelated and unnecessary changes. | |
2816–2817 | Could you extract this into its own function? We once had the following code in ScopHelper.cpp, you could revive them: llvm::Loop *polly::getFirstNonBoxedLoopFor(llvm::Loop *L, llvm::LoopInfo &LI, const BoxedLoopsSetTy &BoxedLoops) { while (BoxedLoops.count(L)) L = L->getParentLoop(); return L; } llvm::Loop *polly::getFirstNonBoxedLoopFor(llvm::BasicBlock *BB, llvm::LoopInfo &LI, const BoxedLoopsSetTy &BoxedLoops) { Loop *L = LI.getLoopFor(BB); return getFirstNonBoxedLoopFor(L, LI, BoxedLoops); } Please don't forget to also the change the other place where getFirstNonBoxedLoopFor could be used. |
LGTM, going to commit...
(When submitting a diff, please ensure that formatting is correct by running "make check-polly")
Why did you move the location of this declaration?