This is an archive of the discontinued LLVM Phabricator instance.

[Polly] Add handling of Top Level Regions
ClosedPublic

Authored by lksbhm on May 22 2017, 7:51 AM.

Details

Summary

My goal is to make the newly added AllowWholeFunctions options more usable/powerful.

The changes to ScopBuilder.cpp are exclusively checks to prevent Region.getExit() from being dereferenced, since Top Level Regions (TLRs) don't have an exit block.

In ScopDetection's isValidCFG, I removed a check that disallowed ReturnInstructions to have return values. This might of course have been intentional, so I would welcome your feedback on this and maybe a small explanation why return values are forbidden. Maybe it can be done but needs more changes elsewhere?

The remaining changes in ScopDetection are simply to consider the AllowWholeFunctions option in more places, i.e. allow TLRs when it is set and once again avoid derefererncing getExit() if it doesn't exist.

Finally, in ScopHelper.cpp I extended polly::isErrorBlock to handle regions without exit blocks as well: The original check was if a given BasicBlock dominates all predecessors of the exit block. Therefore I do the same for TLRs by regarding all BasicBlocks terminating with a ReturnInst as predecessors of a "virtual" function exit block.

Diff Detail

Repository
rL LLVM

Event Timeline

lksbhm created this revision.May 22 2017, 7:51 AM
grosser edited edge metadata.May 22 2017, 7:54 AM

Very cool! I will have a look later. Could you possibly add some test cases?

lksbhm updated this revision to Diff 100118.May 24 2017, 9:49 AM

I extended the full-function.ll testcase to reflect that we now analyze the TLR.
Since the testcase was previously failing, this edit also adds a patch for Scop::getRelativeLoopDepth: It made use of Region::outermostLoopInRegion which has an unintuitive corner case for TLRs (which is documented), namely that it always returns nullptr.

grosser accepted this revision.May 24 2017, 10:45 AM

LGTM, Philip feel free to commit.

This revision is now accepted and ready to land.May 24 2017, 10:45 AM
This revision was automatically updated to reflect the committed changes.