[llvm] 24201b6 - [SampleFDO] Set ProfileIsFS bit properly from the internal option
Rong Xu via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 25 09:17:34 PDT 2021
Author: Rong Xu
Date: 2021-08-25T09:07:34-07:00
New Revision: 24201b6437b2acad035fe474ec37f733e9045174
URL: https://github.com/llvm/llvm-project/commit/24201b6437b2acad035fe474ec37f733e9045174
DIFF: https://github.com/llvm/llvm-project/commit/24201b6437b2acad035fe474ec37f733e9045174.diff
LOG: [SampleFDO] Set ProfileIsFS bit properly from the internal option
We have "-profile-isfs" internal option for text, binary, and
compactbinary format (mostly for debug and test purpose). We
need to set the related flag in FunctionSamples so that ProfileIsFS
is written to the header in extbinary format.
Differential Revision: https://reviews.llvm.org/D108707
Added:
Modified:
llvm/lib/ProfileData/SampleProfReader.cpp
llvm/test/tools/llvm-profdata/sample-fs.test
Removed:
################################################################################
diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index 7fc95520951fb..b40361b3d971e 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -251,6 +251,7 @@ std::error_code SampleProfileReaderText::readImpl() {
bool SeenMetadata = false;
ProfileIsFS = ProfileIsFSDisciminator;
+ FunctionSamples::ProfileIsFS = ProfileIsFS;
for (; !LineIt.is_at_eof(); ++LineIt) {
if ((*LineIt)[(*LineIt).find_first_not_of(' ')] == '#')
continue;
@@ -599,6 +600,7 @@ SampleProfileReaderBinary::readFuncProfile(const uint8_t *Start) {
std::error_code SampleProfileReaderBinary::readImpl() {
ProfileIsFS = ProfileIsFSDisciminator;
+ FunctionSamples::ProfileIsFS = ProfileIsFS;
while (!at_eof()) {
if (std::error_code EC = readFuncProfile(Data))
return EC;
@@ -887,6 +889,7 @@ std::error_code SampleProfileReaderCompactBinary::readImpl() {
// given a module.
bool LoadFuncsToBeUsed = collectFuncsFromModule();
ProfileIsFS = ProfileIsFSDisciminator;
+ FunctionSamples::ProfileIsFS = ProfileIsFS;
std::vector<uint64_t> OffsetsToUse;
if (!LoadFuncsToBeUsed) {
// load all the function profiles.
diff --git a/llvm/test/tools/llvm-profdata/sample-fs.test b/llvm/test/tools/llvm-profdata/sample-fs.test
index 7ea56a667adae..d3d038b17ab70 100644
--- a/llvm/test/tools/llvm-profdata/sample-fs.test
+++ b/llvm/test/tools/llvm-profdata/sample-fs.test
@@ -52,3 +52,7 @@ RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs
RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Pass1 -o %t3-text
RUN:
diff %t3-binary %t3-text
+4- ProfileIsFS is set properly in extbinary format from the internal option
+RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs --extbinary -o %t_extbin.afdo
+RUN: llvm-profdata show --sample --show-sec-info-only %t_extbin.afdo | FileCheck %s --check-prefix=ISFSSET
+ISFSSET: Flags: {fs-discriminator}
More information about the llvm-commits
mailing list