This is an archive of the discontinued LLVM Phabricator instance.

CodeExtractor : Move exit block splitting logic from PartialInliner to CodeExtractor
AbandonedPublic

Authored by rriddle on Aug 10 2016, 3:15 AM.

Details

Reviewers
silvas
davide
Summary

Exit blocks (BBs that are branched to by blocks that are being extracted) that have phis with more than 1 incoming edge from the extracted region need to be split into two blocks, one in the extracted region and one on the outside. Move this logic from PartialInlining to CodeExtractor.

Diff Detail

Event Timeline

rriddle updated this revision to Diff 67499.Aug 10 2016, 3:15 AM
rriddle retitled this revision from to CodeExtractor : Move exit block splitting logic from PartialInliner to CodeExtractor.
rriddle updated this object.
rriddle added reviewers: silvas, davide.
rriddle added a subscriber: llvm-commits.
silvas added inline comments.Aug 11 2016, 4:11 PM
lib/Transforms/Utils/CodeExtractor.cpp
182

You may want to explicitly cast the result of 'Blocks.count(Pred)` to bool. Otherwise, I think the bool will promote to int which won't behave as intended.

852

We generally prefer DenseMap to std::unordered_map. Can you use DenseMap<BasicBlock *, unsigned>? If not, a comment would be useful.

http://llvm.org/docs/ProgrammersManual.html#llvm-adt-densemap-h

Also, this could use a comment explaining what the unsigned means. Maybe add to the comment just above ExitWeights?

test/Transforms/CodeExtractor/MultipleExitBranchProb.ll
34

The output of the compiler must be deterministic. You shouldn't be depending on the iteration order of a map or the numerical values of pointers (can be changed by ASLR etc.).

test/Transforms/CodeExtractor/SplitExitBlockPhiNodes.ll
1

You mentioned that this patch is just moving the logic from PartialInliner to CodeExtractor. So does this test case currently pass?

6

Explain which blocks get outlined and what split block we are supposed to be inserting.

27

You probably want a CHECK-LABEL for each function that you expect in the output. That way the CHECK for the phi node is restricted to being inside the function you want.

Also, you probably want to check a bit more, such as which BB's end up in which functions.

davide edited edge metadata.Dec 14 2016, 9:01 PM

River, are you still planning to work on this one?

rriddle abandoned this revision.Dec 15 2016, 3:48 AM