[PATCH] D92882: [MBP] Prevent rotating a chain contains entry block

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 14 12:49:47 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd50d7c37a159: [MBP] Prevent rotating a chain contains entry block (authored by Carrot).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92882/new/

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
@@ -2306,6 +2306,10 @@
   if (Bottom == ExitingBB)
     return;
 
+  // The entry block should always be the first BB in a function.
+  if (Top->isEntryBlock())
+    return;
+
   bool ViableTopFallthrough = hasViableTopFallthrough(Top, LoopBlockSet);
 
   // If the header has viable fallthrough, check whether the current loop
@@ -2380,6 +2384,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->isEntryBlock())
+    return;
 
   BlockFrequency SmallestRotationCost = BlockFrequency::getMaxFrequency();
 
@@ -2398,7 +2407,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.311676.patch
Type: text/x-patch
Size: 1359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201214/fd3d8ecf/attachment.bin>


More information about the llvm-commits mailing list