[llvm] r279213 - [Profile] Fix edge count read bug
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 18 23:31:46 PDT 2016
Author: davidxl
Date: Fri Aug 19 01:31:45 2016
New Revision: 279213
URL: http://llvm.org/viewvc/llvm-project?rev=279213&view=rev
Log:
[Profile] Fix edge count read bug
Use uint64_t to avoid value truncation before scaling.
Modified:
llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp?rev=279213&r1=279212&r2=279213&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp Fri Aug 19 01:31:45 2016
@@ -821,7 +821,7 @@ void PGOUseFunc::populateCounters() {
}
static void setProfMetadata(Module *M, TerminatorInst *TI,
- ArrayRef<unsigned> EdgeCounts, uint64_t MaxCount) {
+ ArrayRef<uint64_t> 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<unsigned, 2> EdgeCounts(Size, 0);
+ SmallVector<uint64_t, 2> EdgeCounts(Size, 0);
uint64_t MaxCount = 0;
for (unsigned s = 0; s < Size; s++) {
const PGOUseEdge *E = BBCountInfo.OutEdges[s];
More information about the llvm-commits
mailing list