This is an archive of the discontinued LLVM Phabricator instance.

[IROutliner] Outlining branches with single entry and single exit
ClosedPublic

Authored by AndrewLitteken on Jul 28 2021, 12:58 PM.

Details

Summary

Using the similarity found from the IRSimilarity Identifier, we take regions with structural similarity, and deduplicate them into a separate function. The Code Extractor is able to provide most of this functionality.

For simplicity, we start by only outlining regions with a single entry and single exit branch, this reduces the complexity in handling phi nodes outside the region, and handling many sets of outputs for each of the different exit blocks.

Diff Detail

Event Timeline

AndrewLitteken requested review of this revision.Jul 28 2021, 12:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2021, 12:58 PM

Updating tests, fixing bugs, and bringing up to date with parent patches.

paquette added inline comments.Aug 26 2021, 4:00 PM
llvm/include/llvm/Transforms/IPO/IROutliner.h
397

just return EnableBranches?

llvm/lib/Transforms/IPO/IROutliner.cpp
36

maybe "DisableBranches" instead?

55

this sentence doesn't really make sense to me?

88

fold this if into the if above?

97

Comments?

142

Move this above the if and else, then you can early return from the if portion?

747

this loop could be an any_of?

776

else isn't necessary here

1375

assert that this isn't nullptr?

1431–1438

comments for this bit?

1432

can this be an any_of?

1459

fold this if into the if above?

1546

fold this if into the if above?

1704

assert that this isn't nullptr?

AndrewLitteken added inline comments.Aug 30 2021, 2:01 PM
llvm/lib/Transforms/IPO/IROutliner.cpp
747

I don't think so? We need to look at all of the successors, and for each one not contained in, it needs to get added to the set. So we need a boolean for each block so I think this makes sense.

Updating based on comments

paquette accepted this revision.Aug 31 2021, 3:05 PM

I think this looks fine with nits.

llvm/lib/Transforms/IPO/IROutliner.cpp
36

this could use a comment?

748

drop braces?

This revision is now accepted and ready to land.Aug 31 2021, 3:05 PM
This revision was landed with ongoing or failed builds.Sep 7 2021, 8:52 AM
This revision was automatically updated to reflect the committed changes.