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
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. |
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.