[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
This commit is contained in:
Xinliang David Li 2016-08-19 06:31:45 +00:00
parent dfdbbee55c
commit 0842b8d3d6

View File

@ -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];