Index: lib/ProfileData/InstrProf.cpp =================================================================== --- lib/ProfileData/InstrProf.cpp +++ lib/ProfileData/InstrProf.cpp @@ -493,8 +493,10 @@ if (I != IE && I->Value == J->Value) { bool Overflowed; I->Count = SaturatingMultiplyAdd(J->Count, Weight, I->Count, &Overflowed); - if (Overflowed) + if (Overflowed) { + outs() << "Warn from InstrProf:497\n"; Warn(instrprof_error::counter_overflow); + } ++I; continue; } @@ -507,8 +509,10 @@ for (auto I = ValueData.begin(), IE = ValueData.end(); I != IE; ++I) { bool Overflowed; I->Count = SaturatingMultiply(I->Count, Weight, &Overflowed); - if (Overflowed) + if (Overflowed) { + outs() << "Warn from InstrProf:513\n"; Warn(instrprof_error::counter_overflow); + } } } @@ -538,6 +542,7 @@ // If the number of counters doesn't match we either have bad data // or a hash collision. if (Counts.size() != Other.Counts.size()) { + // outs() << "Warn from InstrProf.cpp:545 which is a hard error like.\n"; Warn(instrprof_error::count_mismatch); return; } @@ -546,8 +551,12 @@ bool Overflowed; Counts[I] = SaturatingMultiplyAdd(Other.Counts[I], Weight, Counts[I], &Overflowed); - if (Overflowed) + if (Overflowed) { Warn(instrprof_error::counter_overflow); + //outs() << reinterpret_cast(&Other)->Name; + // outs() << Other.Counts[I] << " + " << Counts[I] << " * " << Weight; + // outs() << " Warn from InstrProf.cpp:556.\n"; + } } for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind) Index: lib/ProfileData/InstrProfReader.cpp =================================================================== --- lib/ProfileData/InstrProfReader.cpp +++ lib/ProfileData/InstrProfReader.cpp @@ -363,6 +363,9 @@ Data = reinterpret_cast *>( Start + DataOffset); DataEnd = Data + DataSize; + outs() << "Start = " << reinterpret_cast(Start) << "\n"; + outs() << "Data start = " << reinterpret_cast(Start + DataOffset) << "\n"; + outs() << "Data end = " << reinterpret_cast(Start + DataOffset + DataSize) << "\n"; CountersStart = reinterpret_cast(Start + CountersOffset); NamesStart = Start + NamesOffset; ValueDataStart = reinterpret_cast(Start + ValueDataOffset); @@ -392,10 +395,20 @@ InstrProfRecord &Record) { uint32_t NumCounters = swap(Data->NumCounters); IntPtrT CounterPtr = Data->CounterPtr; + if (((NamedInstrProfRecord*)&Record)->Name == "sqlite3.c:vdbeFreeOpArray") { + outs() << "Data = " << Data << "\n"; + // outs() << "XXXXXXXXXXXXXXXXXXXXXX\n"; + outs() << "CounterPtr = " << (uint64_t*)CounterPtr << "\n"; + } if (NumCounters == 0) return error(instrprof_error::malformed); auto RawCounts = makeArrayRef(getCounter(CounterPtr), NumCounters); + if (((NamedInstrProfRecord*)&Record)->Name == "vdbeFreeOpArray") { + for (uint64_t Count : RawCounts) { + outs() << Count << "\n"; + } + } auto *NamesStartAsCounter = reinterpret_cast(NamesStart); // Check bounds. Index: lib/ProfileData/InstrProfWriter.cpp =================================================================== --- lib/ProfileData/InstrProfWriter.cpp +++ lib/ProfileData/InstrProfWriter.cpp @@ -196,6 +196,8 @@ InstrProfRecord &Dest = Where->second; auto MapWarn = [&](instrprof_error E) { + outs() << Name << "\n"; + // outs() << Name << " in InstrProfWriter.cpp:199\n"; Warn(make_error(E)); }; Index: tools/llvm-profdata/llvm-profdata.cpp =================================================================== --- tools/llvm-profdata/llvm-profdata.cpp +++ tools/llvm-profdata/llvm-profdata.cpp @@ -225,6 +225,7 @@ return; } Reported = true; + // outs() << "Reported an error in llvm-profdata.cpp:228\n"; Dst->Err = std::move(E); }); } @@ -301,9 +302,11 @@ instrprof_error IPE = InstrProfError::take(std::move(WC->Err)); if (isFatalError(IPE)) exitWithError(make_error(IPE), WC->ErrWhence); - else + else { + // outs() << "warning from llvm-profdata.cpp:305\n"; warn(toString(make_error(IPE)), WC->ErrWhence); + } } InstrProfWriter &Writer = Contexts[0]->Writer;