[llvm] [Instrumentation] Fix EdgeCounts vector size in SetBranchWeights (PR #99064)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 12:31:57 PDT 2024
================
@@ -1623,10 +1623,12 @@ void PGOUseFunc::setBranchWeights() {
continue;
// We have a non-zero Branch BB.
- unsigned Size = BBCountInfo.OutEdges.size();
- SmallVector<uint64_t, 2> EdgeCounts(Size, 0);
+ unsigned OutEdgesCount = BBCountInfo.OutEdges.size();
+ unsigned SuccessorCount = BB.getTerminator()->getNumSuccessors();
+
+ SmallVector<uint64_t, 2> EdgeCounts(SuccessorCount, 0);
----------------
mtrofin wrote:
Can you add a comment as to why we need to dimension EdgeCounts like that? (basically "`Removed` edges don't appear in `OutEdges`). Also I'd add an `assert(OutEdgesCount <= SuccessorCount)
otherwise LGTM, but wait also for @ellishg and/or @xur-llvm
https://github.com/llvm/llvm-project/pull/99064
More information about the llvm-commits
mailing list