Skip to content

Commit

Permalink
[Profile] Fix edge count read bug
Browse files Browse the repository at this point in the history
 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
  • Loading branch information
david-xl committed Aug 19, 2016
1 parent dfdbbee commit 0842b8d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Transforms/Instrumentation/PGOInstrumentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 0842b8d

Please sign in to comment.