[llvm] r279213 - [Profile] Fix edge count read bug

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 17:01:35 PDT 2016


yes -- one should be added.

On Fri, Aug 19, 2016 at 4:59 PM, Vedant Kumar <vsk at apple.com> wrote:
> Does this need a test (e.g some input which triggers EdgeCount > 2^32)?
>
> vedant
>
>> On Aug 18, 2016, at 11:31 PM, Xinliang David Li via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>>
>> 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];
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>


More information about the llvm-commits mailing list