summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-profdata
diff options
context:
space:
mode:
authorRong Xu <xur@google.com>2016-02-08 21:07:46 +0000
committerRong Xu <xur@google.com>2016-02-08 21:07:46 +0000
commit1288a19421232137ed288e4b9ba202f3b37b2006 (patch)
treea5c81a0b9a6c6f2ff258444f914e829610b6f3ab /llvm/tools/llvm-profdata
parent264d7e5b685a739f52e680089ba92f0129708687 (diff)
downloadbcm5719-llvm-1288a19421232137ed288e4b9ba202f3b37b2006.tar.gz
bcm5719-llvm-1288a19421232137ed288e4b9ba202f3b37b2006.zip
[PGO] Differentiate Clang instrumentation and IR level instrumentation profiles
This patch uses one bit in profile version to differentiate Clang instrumentation and IR level instrumentation profiles. PGOInstrumenation generates a COMDAT variable __llvm_profile_raw_version so that the compiler runtime can set the right profile kind. PGOInstrumenation now checks this bit to make sure it's an IR level instrumentation profile. Differential Revision: http://reviews.llvm.org/D15540 llvm-svn: 260146
Diffstat (limited to 'llvm/tools/llvm-profdata')
-rw-r--r--llvm/tools/llvm-profdata/llvm-profdata.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 2b6eacfb48a..c7760866b80 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -128,6 +128,10 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs,
exitWithErrorCode(ec, Input.Filename);
auto Reader = std::move(ReaderOrErr.get());
+ bool IsIRProfile = Reader->isIRLevelProfile();
+ if (Writer.setIsIRLevelProfile(IsIRProfile))
+ exitWithError("Merge IR generated profile with Clang generated profile.");
+
for (auto &I : *Reader) {
if (std::error_code EC = Writer.addRecord(std::move(I), Input.Weight)) {
// Only show hint the first time an error occurs.
@@ -269,6 +273,7 @@ static int showInstrProfile(std::string Filename, bool ShowCounts,
exitWithErrorCode(EC, Filename);
auto Reader = std::move(ReaderOrErr.get());
+ bool IsIRInstr = Reader->isIRLevelProfile();
size_t ShownFunctions = 0;
for (const auto &Func : *Reader) {
bool Show =
@@ -295,8 +300,9 @@ static int showInstrProfile(std::string Filename, bool ShowCounts,
OS << " " << Func.Name << ":\n"
<< " Hash: " << format("0x%016" PRIx64, Func.Hash) << "\n"
- << " Counters: " << Func.Counts.size() << "\n"
- << " Function count: " << Func.Counts[0] << "\n";
+ << " Counters: " << Func.Counts.size() << "\n";
+ if (!IsIRInstr)
+ OS << " Function count: " << Func.Counts[0] << "\n";
if (ShowIndirectCallTargets)
OS << " Indirect Call Site Count: "
@@ -304,8 +310,9 @@ static int showInstrProfile(std::string Filename, bool ShowCounts,
if (ShowCounts) {
OS << " Block counts: [";
- for (size_t I = 1, E = Func.Counts.size(); I < E; ++I) {
- OS << (I == 1 ? "" : ", ") << Func.Counts[I];
+ size_t Start = (IsIRInstr ? 0 : 1);
+ for (size_t I = Start, E = Func.Counts.size(); I < E; ++I) {
+ OS << (I == Start ? "" : ", ") << Func.Counts[I];
}
OS << "]\n";
}
OpenPOWER on IntegriCloud