Index: llvm/trunk/include/llvm/ProfileData/SampleProfReader.h =================================================================== --- llvm/trunk/include/llvm/ProfileData/SampleProfReader.h +++ llvm/trunk/include/llvm/ProfileData/SampleProfReader.h @@ -462,6 +462,8 @@ DenseMap FuncOffsetTable; /// The set containing the functions to use when compiling a module. DenseSet FuncsToUse; + /// Use all functions from the input profile. + bool UseAllFuncs = true; virtual std::error_code verifySPMagic(uint64_t Magic) override; virtual std::error_code readNameTable() override; /// Read a string indirectly via the name table. Index: llvm/trunk/lib/ProfileData/SampleProfReader.cpp =================================================================== --- llvm/trunk/lib/ProfileData/SampleProfReader.cpp +++ llvm/trunk/lib/ProfileData/SampleProfReader.cpp @@ -468,14 +468,26 @@ } std::error_code SampleProfileReaderCompactBinary::read() { - for (auto Name : FuncsToUse) { - auto GUID = std::to_string(MD5Hash(Name)); - auto iter = FuncOffsetTable.find(StringRef(GUID)); - if (iter == FuncOffsetTable.end()) - continue; + std::vector OffsetsToUse; + if (UseAllFuncs) { + for (auto FuncEntry : FuncOffsetTable) { + OffsetsToUse.push_back(FuncEntry.second); + } + } + else { + for (auto Name : FuncsToUse) { + auto GUID = std::to_string(MD5Hash(Name)); + auto iter = FuncOffsetTable.find(StringRef(GUID)); + if (iter == FuncOffsetTable.end()) + continue; + OffsetsToUse.push_back(iter->second); + } + } + + for (auto Offset : OffsetsToUse) { const uint8_t *SavedData = Data; Data = reinterpret_cast(Buffer->getBufferStart()) + - iter->second; + Offset; if (std::error_code EC = readFuncProfile()) return EC; Data = SavedData; @@ -591,6 +603,7 @@ } void SampleProfileReaderCompactBinary::collectFuncsToUse(const Module &M) { + UseAllFuncs = false; FuncsToUse.clear(); for (auto &F : M) { StringRef CanonName = FunctionSamples::getCanonicalFnName(F); Index: llvm/trunk/test/tools/llvm-profdata/compact-sample.proftext =================================================================== --- llvm/trunk/test/tools/llvm-profdata/compact-sample.proftext +++ llvm/trunk/test/tools/llvm-profdata/compact-sample.proftext @@ -0,0 +1,8 @@ +# Make sure "llvm-profdata show" works for sample profile in binary compact format + +# RUN: llvm-profdata show -sample %S/Inputs/compat-sample.profdata | FileCheck %s + +# CHECK: Function: 15822663052811949562: 17, 0, 6 sampled lines +# CHECK-NEXT: Samples collected in the function's body { +# CHECK: Samples collected in inlined callsites { +# CHECK-NEXT: 1: inlined callee: 6309742469962978389: 17, 0, 1