The entry block should always be the first BB in a function. So we should not rotate a chain contains the entry block.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Can we add a test for this?
llvm/lib/CodeGen/MachineBlockPlacement.cpp | ||
---|---|---|
2390 | Consider using the helper MachineBasicBlock::isEntryBlock here and above. |
Sorry, no small test case for it.
It was triggered by https://reviews.llvm.org/D89088, when build firefox and chrome with LTO+PGO. This patch has been verified for them.
It doesn't have any performance impact.
If user doesn't notice anything, there is no such case for them.
If someone encountered such case, he should get a compiler crash in LiveDebugVariable pass.
It is possible to synthesize a test case that rotates the entry without the fix, no? The expected output is that the entry is not rotated (no need to reproduce crash).
The key is to generate an entry block and make the following condition in buildCFGChains() evaluated as false:
if (!TII->analyzeBranch(*BB, TBB, FBB, Cond) || !FI->canFallThrough()) break;
It means the entry block must end with an unanalyzable branch and it must also fall through to following block, so the entry block will be pre-merged with the following block, the following block is a loop header, so later it can be rotated by rotateLoop.
I failed to construct such a test case after a whole day's experiments :(
thanks for working on the test -- good to add later if possible. LGTM after addressing snehasish's comment.
Consider using the helper MachineBasicBlock::isEntryBlock here and above.