From 0842b8d3d6a3c211c0bec9af68f82c679ed556c2 Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Fri, 19 Aug 2016 06:31:45 +0000 Subject: [PATCH] [Profile] Fix edge count read bug Use uint64_t to avoid value truncation before scaling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279213 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/PGOInstrumentation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 0865d16756b..707329cf67e 100644 --- a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -821,7 +821,7 @@ void PGOUseFunc::populateCounters() { } static void setProfMetadata(Module *M, TerminatorInst *TI, - ArrayRef EdgeCounts, uint64_t MaxCount) { + ArrayRef EdgeCounts, uint64_t MaxCount) { MDBuilder MDB(M->getContext()); assert(MaxCount > 0 && "Bad max count"); uint64_t Scale = calculateCountScale(MaxCount); @@ -851,7 +851,7 @@ void PGOUseFunc::setBranchWeights() { // We have a non-zero Branch BB. const UseBBInfo &BBCountInfo = getBBInfo(&BB); unsigned Size = BBCountInfo.OutEdges.size(); - SmallVector EdgeCounts(Size, 0); + SmallVector EdgeCounts(Size, 0); uint64_t MaxCount = 0; for (unsigned s = 0; s < Size; s++) { const PGOUseEdge *E = BBCountInfo.OutEdges[s];