[PATCH] D65162: [llvm-profdata] Profile dump for compact binary format
Wenlei He via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 10:55:23 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL368731: [llvm-profdata] Profile dump for compact binary format (authored by wenlei, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D65162?vs=211571&id=214880#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65162/new/
https://reviews.llvm.org/D65162
Files:
llvm/trunk/include/llvm/ProfileData/SampleProfReader.h
llvm/trunk/lib/ProfileData/SampleProfReader.cpp
llvm/trunk/test/tools/llvm-profdata/Inputs/compat-sample.profdata
llvm/trunk/test/tools/llvm-profdata/compact-sample.proftext
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<StringRef, uint64_t> FuncOffsetTable;
/// The set containing the functions to use when compiling a module.
DenseSet<StringRef> 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/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
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<uint64_t> 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<const uint8_t *>(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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65162.214880.patch
Type: text/x-patch
Size: 2841 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190813/2f2b48ce/attachment.bin>
More information about the llvm-commits
mailing list