[PATCH] D92882: [MBP] Prevent rotating a chain contains entry block
Guozhi Wei via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 8 13:32:46 PST 2020
Carrot created this revision.
Carrot added reviewers: davidxl, xur.
Herald added a subscriber: hiraditya.
Carrot requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The entry block should always be the first BB in a function. So we should not rotate a chain contains the entry block.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D92882
Files:
llvm/lib/CodeGen/MachineBlockPlacement.cpp
Index: llvm/lib/CodeGen/MachineBlockPlacement.cpp
===================================================================
--- llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -2308,6 +2308,10 @@
if (Bottom == ExitingBB)
return;
+ // The entry block should always be the first BB in a function.
+ if (Top == &F->front())
+ return;
+
bool ViableTopFallthrough = hasViableTopFallthrough(Top, LoopBlockSet);
// If the header has viable fallthrough, check whether the current loop
@@ -2382,6 +2386,11 @@
BlockChain &LoopChain, const MachineLoop &L,
const BlockFilterSet &LoopBlockSet) {
auto RotationPos = LoopChain.end();
+ MachineBasicBlock *ChainHeaderBB = *LoopChain.begin();
+
+ // The entry block should always be the first BB in a function.
+ if (ChainHeaderBB == &F->front())
+ return;
BlockFrequency SmallestRotationCost = BlockFrequency::getMaxFrequency();
@@ -2400,7 +2409,6 @@
// chain head is not the loop header. As we only consider natural loops with
// single header, this computation can be done only once.
BlockFrequency HeaderFallThroughCost(0);
- MachineBasicBlock *ChainHeaderBB = *LoopChain.begin();
for (auto *Pred : ChainHeaderBB->predecessors()) {
BlockChain *PredChain = BlockToChain[Pred];
if (!LoopBlockSet.count(Pred) &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92882.310333.patch
Type: text/x-patch
Size: 1357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201208/191b1416/attachment.bin>
More information about the llvm-commits
mailing list