[llvm] [Instrumentation] Fix EdgeCounts vector size in SetBranchWeights (PR #99064)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 7 11:35:01 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);
uint64_t MaxCount = 0;
- for (unsigned s = 0; s < Size; s++) {
+ for (unsigned s = 0; s < OutEdgesCount; s++) {
----------------
mtrofin wrote:
nit: while at it, can you please change `s` to `S` or `It` or something conforming to the coding style? thanks.
https://github.com/llvm/llvm-project/pull/99064
More information about the llvm-commits
mailing list