[PATCH] D113344: [BPI] Push exit block rather than exiting ones in getSccExitBlocks

Bin Cheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 6 05:05:50 PDT 2021


bin.cheng created this revision.
bin.cheng added reviewers: asbirlea, yrouban.
bin.cheng added a project: LLVM.
Herald added a subscriber: hiraditya.
bin.cheng requested review of this revision.
Herald added a subscriber: llvm-commits.

Hi,
See comment before BranchProbabilityInfo::SccInfo::getSccExitBlocks:
"   /// Fills in \p Exits vector with all such blocks that don't belong to

  /// SCC with \p SccNum ID but there is an edge from a block belonging to the
  /// SCC."

Also see the comment/implementation of related function BranchProbabilityInfo::getLoopExitBlocks,
I believe the current implement has typo pushing copies of exiting block into result vector.  This simple
patch fixes the typo by pushing exit blocks.

I spot this when going through the code, unfortunately I didn't come up with any test for this. 
I tried to instrument the function if it's triggered, though the function is only called in one
function from spec2k17int, it's not really triggered because push_back operation is never executed.

Any comments?

Thanks,
bin


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113344

Files:
  llvm/lib/Analysis/BranchProbabilityInfo.cpp


Index: llvm/lib/Analysis/BranchProbabilityInfo.cpp
===================================================================
--- llvm/lib/Analysis/BranchProbabilityInfo.cpp
+++ llvm/lib/Analysis/BranchProbabilityInfo.cpp
@@ -167,7 +167,7 @@
     if (isSCCExitingBlock(BB, SccNum))
       for (const auto *Succ : successors(BB))
         if (getSCCNum(Succ) != SccNum)
-          Exits.push_back(const_cast<BasicBlock *>(BB));
+          Exits.push_back(const_cast<BasicBlock *>(Succ));
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113344.385263.patch
Type: text/x-patch
Size: 490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211106/2067f422/attachment.bin>


More information about the llvm-commits mailing list