Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Profile] Add binary profile correlation for code coverage. #69493

Merged
merged 14 commits into from
Dec 14, 2023

Conversation

ZequanWu
Copy link
Contributor

@ZequanWu ZequanWu commented Oct 18, 2023

Motivation

Since we don't need the metadata sections at runtime, we can somehow offload them from memory at runtime. Initially, I explored debug info correlation, which is used for PGO with value profiling disabled. However, it currently only works with DWARF and it's be hard to add such artificial debug info for every function in to CodeView which is used on Windows. So, offloading profile metadata sections at runtime seems to be a platform independent option.

Design

The idea is to use new section names for profile name and data sections and mark them as metadata sections. Under this mode, the new sections are non-SHF_ALLOC in ELF. So, they are not loaded into memory at runtime and can be stripped away as a post-linking step. After the process exits, the generated raw profiles will contains only headers + counters. llvm-profdata can be used correlate raw profiles with the unstripped binary to generate indexed profile.

Data

For chromium base_unittests with code coverage on linux, the binary size overhead due to instrumentation reduced from 64M to 38.8M (39.4%) and the raw profile files size reduce from 128M to 68M (46.9%)

$ bloaty out/cov/base_unittests.stripped -- out/no-cov/base_unittests.stripped
    FILE SIZE        VM SIZE
 --------------  --------------
  +121% +30.4Mi  +121% +30.4Mi    .text
  [NEW] +14.6Mi  [NEW] +14.6Mi    __llvm_prf_data
  [NEW] +10.6Mi  [NEW] +10.6Mi    __llvm_prf_names
  [NEW] +5.86Mi  [NEW] +5.86Mi    __llvm_prf_cnts
   +95% +1.75Mi   +95% +1.75Mi    .eh_frame
  +108%  +400Ki  +108%  +400Ki    .eh_frame_hdr
  +9.5%  +211Ki  +9.5%  +211Ki    .rela.dyn
  +9.2% +95.0Ki  +9.2% +95.0Ki    .data.rel.ro
  +5.0% +87.3Ki  +5.0% +87.3Ki    .rodata
  [ = ]       0   +13% +47.0Ki    .bss
   +40% +1.78Ki   +40% +1.78Ki    .got
   +12% +1.49Ki   +12% +1.49Ki    .gcc_except_table
  [ = ]       0   +65% +1.23Ki    .relro_padding
   +62% +1.20Ki  [ = ]       0    [Unmapped]
   +13%    +448   +19%    +448    .init_array
  +8.8%    +192  [ = ]       0    [ELF Section Headers]
  +0.0%    +136  +0.0%     +80    [7 Others]
  +0.1%     +96  +0.1%     +96    .dynsym
  +1.2%     +96  +1.2%     +96    .rela.plt
  +1.5%     +80  +1.2%     +64    .plt
  [ = ]       0 -99.2% -3.68Ki    [LOAD #5 [RW]]
  +195% +64.0Mi  +194% +64.0Mi    TOTAL
$ bloaty out/cov-cor/base_unittests.stripped -- out/no-cov/base_unittests.stripped
    FILE SIZE        VM SIZE
 --------------  --------------
  +121% +30.4Mi  +121% +30.4Mi    .text
  [NEW] +5.86Mi  [NEW] +5.86Mi    __llvm_prf_cnts
   +95% +1.75Mi   +95% +1.75Mi    .eh_frame
  +108%  +400Ki  +108%  +400Ki    .eh_frame_hdr
  +9.5%  +211Ki  +9.5%  +211Ki    .rela.dyn
  +9.2% +95.0Ki  +9.2% +95.0Ki    .data.rel.ro
  +5.0% +87.3Ki  +5.0% +87.3Ki    .rodata
  [ = ]       0   +13% +47.0Ki    .bss
   +40% +1.78Ki   +40% +1.78Ki    .got
   +12% +1.49Ki   +12% +1.49Ki    .gcc_except_table
   +13%    +448   +19%    +448    .init_array
  +0.1%     +96  +0.1%     +96    .dynsym
  +1.2%     +96  +1.2%     +96    .rela.plt
  +1.2%     +64  +1.2%     +64    .plt
  +2.9%     +64  [ = ]       0    [ELF Section Headers]
  +0.0%     +40  +0.0%     +40    .data
  +1.2%     +32  +1.2%     +32    .got.plt
  +0.0%     +24  +0.0%      +8    [5 Others]
  [ = ]       0 -22.9%    -872    [LOAD #5 [RW]]
 -74.5% -1.44Ki  [ = ]       0    [Unmapped]
  [ = ]       0 -76.5% -1.45Ki    .relro_padding
  +118% +38.8Mi  +117% +38.8Mi    TOTAL

A few things to note:

  1. llvm-profdata doesn't support filter raw profiles by binary id yet, so when a raw profile doesn't belongs to the binary being digested by llvm-profdata, merging will fail. Once this is implemented, llvm-profdata should be able to only merge raw profiles with the same binary id as the binary and discard the rest (with mismatched/missing binary id). The workflow I have in mind is to have scripts invoke llvm-profdata to get all binary ids for all raw profiles, and selectively choose the raw pnrofiles with matching binary id and the binary to llvm-profdata for merging.
  2. Note: In COFF, currently they are still loaded into memory but not used. I didn't do it in this patch because I noticed that .lcovmap and .lcovfunc are loaded into memory. A separate patch will address it.
  3. This should works with PGO when value profiling is disabled as debug info correlation currently doing, though I haven't tested this yet.

@llvmbot llvmbot added clang Clang issues not falling into any other category compiler-rt clang:codegen PGO Profile Guided Optimizations llvm:transforms llvm:binary-utilities labels Oct 18, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 18, 2023

@llvm/pr-subscribers-llvm-binary-utilities
@llvm/pr-subscribers-pgo
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Zequan Wu (ZequanWu)

Changes

This is similar to debug info correlation. The motivation is that debug info correlation doesn't work on Windows because it's hard to make codeview contains those artificial debug info.

The idea is to offload profile metadata(profile name and data sections) from binary by marking them as metadata sections, so that they can be stripped away as a post-linking step. The generated raw profiles will contains only headers + counters. llvm-profdata will use the unstripped binary to correlate the raw profiles to generate indexed profile.

A few things to note:

  1. This new mode and debug info correlation mode are under -profile-correlate= flag, since they are similar.
  2. llvm-profdata doesn't support filter raw profiles by binary id yet, so when a raw profile doesn't belongs to the binary being digested by llvm-profdata, merging will fail. Once this is implemented, llvm-profdata should be able to only merge raw profiles with the same binary id as the binary and discard the rest (with mismatched/missing binary id). The workflow I have in mind is to have scripts invoke llvm-profdata to get all binary ids for all raw profiles, and selectively choose the raw profiles with matching binary id and the binary to llvm-profdata for merging.

Patch is 62.18 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/69493.diff

31 Files Affected:

  • (modified) clang/lib/CodeGen/BackendUtil.cpp (+7-3)
  • (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+20)
  • (added) clang/test/CodeGen/coverage-profile-raw-version.c (+9)
  • (modified) compiler-rt/include/profile/InstrProfData.inc (+2)
  • (modified) compiler-rt/lib/profile/InstrProfiling.h (+3)
  • (modified) compiler-rt/lib/profile/InstrProfilingBuffer.c (+14)
  • (modified) compiler-rt/lib/profile/InstrProfilingMerge.c (+5-3)
  • (modified) compiler-rt/lib/profile/InstrProfilingPlatformWindows.c (-2)
  • (modified) compiler-rt/lib/profile/InstrProfilingWriter.c (+12-12)
  • (modified) compiler-rt/test/CMakeLists.txt (+3-2)
  • (modified) compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c (+2-2)
  • (modified) compiler-rt/test/profile/Linux/instrprof-debug-info-correlate-warnings.c (+1-1)
  • (modified) compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c (+3-3)
  • (modified) compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c (+3-3)
  • (added) compiler-rt/test/profile/instrprof-binary-correlate.c (+29)
  • (modified) llvm/docs/CommandGuide/llvm-profdata.rst (+9-4)
  • (modified) llvm/include/llvm/ProfileData/InstrProf.h (+3-3)
  • (modified) llvm/include/llvm/ProfileData/InstrProfCorrelator.h (+48-11)
  • (modified) llvm/include/llvm/ProfileData/InstrProfData.inc (+2)
  • (modified) llvm/include/llvm/ProfileData/InstrProfReader.h (+10)
  • (modified) llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h (-2)
  • (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+21-2)
  • (modified) llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp (+21-7)
  • (modified) llvm/lib/ProfileData/InstrProf.cpp (+4-4)
  • (modified) llvm/lib/ProfileData/InstrProfCorrelator.cpp (+167-40)
  • (modified) llvm/lib/ProfileData/InstrProfReader.cpp (+4-4)
  • (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+17-14)
  • (modified) llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (+2-1)
  • (modified) llvm/test/Instrumentation/InstrProfiling/debug-info-correlate-coverage.ll (+1-1)
  • (modified) llvm/test/Instrumentation/InstrProfiling/debug-info-correlate.ll (+1-1)
  • (modified) llvm/tools/llvm-profdata/llvm-profdata.cpp (+26-11)
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 70accce456d3c07..dad3c9a145b5049 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -42,6 +42,7 @@
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Passes/StandardInstrumentations.h"
+#include "llvm/ProfileData/InstrProfCorrelator.h"
 #include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -98,13 +99,16 @@ extern cl::opt<bool> PrintPipelinePasses;
 static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP(
     "sanitizer-early-opt-ep", cl::Optional,
     cl::desc("Insert sanitizers on OptimizerEarlyEP."), cl::init(false));
-}
+
+extern cl::opt<InstrProfCorrelator::ProfCorrelatorKind> ProfileCorrelate;
+} // namespace llvm
 
 namespace {
 
 // Default filename used for profile generation.
 std::string getDefaultProfileGenName() {
-  return DebugInfoCorrelate ? "default_%m.proflite" : "default_%m.profraw";
+  return ProfileCorrelate.getNumOccurrences() ? "default_%m.proflite"
+                                              : "default_%m.profraw";
 }
 
 class EmitAssemblyHelper {
@@ -197,7 +201,7 @@ class EmitAssemblyHelper {
   void EmitAssembly(BackendAction Action,
                     std::unique_ptr<raw_pwrite_stream> OS);
 };
-}
+} // namespace
 
 static SanitizerCoverageOptions
 getSancovOptsFromCGOpts(const CodeGenOptions &CGOpts) {
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 76ed10091b025be..daff0d1d50923f5 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -31,6 +31,10 @@
 // is textually included.
 #define COVMAP_V3
 
+namespace llvm {
+extern cl::opt<InstrProfCorrelator::ProfCorrelatorKind> ProfileCorrelate;
+} // namespace llvm
+
 static llvm::cl::opt<bool> EmptyLineCommentCoverage(
     "emptyline-comment-coverage",
     llvm::cl::desc("Emit emptylines and comment lines as skipped regions (only "
@@ -1831,6 +1835,22 @@ void CoverageMappingModuleGen::emit() {
                              llvm::GlobalValue::InternalLinkage, NamesArrVal,
                              llvm::getCoverageUnusedNamesVarName());
   }
+  const StringRef VarName(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));
+  llvm::Type *IntTy64 = llvm::Type::getInt64Ty(Ctx);
+  uint64_t ProfileVersion = INSTR_PROF_RAW_VERSION;
+  if (llvm::ProfileCorrelate == llvm::InstrProfCorrelator::BINARY)
+    ProfileVersion |= VARIANT_MASK_BIN_CORRELATE;
+  auto *VersionVariable = new llvm::GlobalVariable(
+      CGM.getModule(), llvm::Type::getInt64Ty(Ctx), true,
+      llvm::GlobalValue::WeakAnyLinkage,
+      llvm::Constant::getIntegerValue(IntTy64, llvm::APInt(64, ProfileVersion)),
+      VarName);
+  VersionVariable->setVisibility(llvm::GlobalValue::HiddenVisibility);
+  llvm::Triple TT(CGM.getModule().getTargetTriple());
+  if (TT.supportsCOMDAT()) {
+    VersionVariable->setLinkage(llvm::GlobalValue::ExternalLinkage);
+    VersionVariable->setComdat(CGM.getModule().getOrInsertComdat(VarName));
+  }
 }
 
 unsigned CoverageMappingModuleGen::getFileID(FileEntryRef File) {
diff --git a/clang/test/CodeGen/coverage-profile-raw-version.c b/clang/test/CodeGen/coverage-profile-raw-version.c
new file mode 100644
index 000000000000000..fc81179e1a33e06
--- /dev/null
+++ b/clang/test/CodeGen/coverage-profile-raw-version.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1  -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -mllvm -profile-correlate=binary -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -o - %s | FileCheck %s --check-prefix=BIN-CORRELATE
+
+// CHECK: @__llvm_profile_raw_version = {{.*}} i64 8
+// BIN-CORRELATE: @__llvm_profile_raw_version = {{.*}} i64 4294967304
+
+int main() {
+    return 0;
+}
diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc
index 8ba7e186d4fb1a6..1841ef348a70061 100644
--- a/compiler-rt/include/profile/InstrProfData.inc
+++ b/compiler-rt/include/profile/InstrProfData.inc
@@ -655,6 +655,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
  * version for other variants of profile. We set the 8th most significant bit 
  * (i.e. bit 56) to 1 to indicate if this is an IR-level instrumentation
  * generated profile, and 0 if this is a Clang FE generated profile.
+ * 1 in bit 32 indicates there is no profile name and data sections.
  * 1 in bit 57 indicates there are context-sensitive records in the profile.
  * The 59th bit indicates whether to use debug info to correlate profiles.
  * The 60th bit indicates single byte coverage instrumentation.
@@ -664,6 +665,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
  */
 #define VARIANT_MASKS_ALL 0xffffffff00000000ULL
 #define GET_VERSION(V) ((V) & ~VARIANT_MASKS_ALL)
+#define VARIANT_MASK_BIN_CORRELATE (0x1ULL << 32)
 #define VARIANT_MASK_IR_PROF (0x1ULL << 56)
 #define VARIANT_MASK_CSIR_PROF (0x1ULL << 57)
 #define VARIANT_MASK_INSTR_ENTRY (0x1ULL << 58)
diff --git a/compiler-rt/lib/profile/InstrProfiling.h b/compiler-rt/lib/profile/InstrProfiling.h
index 4433d7bd48871fc..8b9e029ee8baee5 100644
--- a/compiler-rt/lib/profile/InstrProfiling.h
+++ b/compiler-rt/lib/profile/InstrProfiling.h
@@ -267,6 +267,9 @@ uint64_t __llvm_profile_get_num_data(const __llvm_profile_data *Begin,
 uint64_t __llvm_profile_get_data_size(const __llvm_profile_data *Begin,
                                       const __llvm_profile_data *End);
 
+/*! \brief Get the size of the profile name section in bytes. */
+uint64_t __llvm_profile_get_name_size(const char *Begin, const char *End);
+
 /*! \brief Get the size in bytes of a single counter entry. */
 size_t __llvm_profile_counter_entry_size(void);
 
diff --git a/compiler-rt/lib/profile/InstrProfilingBuffer.c b/compiler-rt/lib/profile/InstrProfilingBuffer.c
index 61ac5d9c0285002..e60aa9fc04e7fac 100644
--- a/compiler-rt/lib/profile/InstrProfilingBuffer.c
+++ b/compiler-rt/lib/profile/InstrProfilingBuffer.c
@@ -53,6 +53,9 @@ uint64_t __llvm_profile_get_size_for_buffer(void) {
 COMPILER_RT_VISIBILITY
 uint64_t __llvm_profile_get_num_data(const __llvm_profile_data *Begin,
                                      const __llvm_profile_data *End) {
+  if ((__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) ||
+      (__llvm_profile_get_version() & VARIANT_MASK_BIN_CORRELATE))
+    return 0;
   intptr_t BeginI = (intptr_t)Begin, EndI = (intptr_t)End;
   return ((EndI + sizeof(__llvm_profile_data) - 1) - BeginI) /
          sizeof(__llvm_profile_data);
@@ -61,9 +64,20 @@ uint64_t __llvm_profile_get_num_data(const __llvm_profile_data *Begin,
 COMPILER_RT_VISIBILITY
 uint64_t __llvm_profile_get_data_size(const __llvm_profile_data *Begin,
                                       const __llvm_profile_data *End) {
+  if ((__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) ||
+      (__llvm_profile_get_version() & VARIANT_MASK_BIN_CORRELATE))
+    return 0;
   return __llvm_profile_get_num_data(Begin, End) * sizeof(__llvm_profile_data);
 }
 
+COMPILER_RT_VISIBILITY
+uint64_t __llvm_profile_get_name_size(const char *Begin, const char *End) {
+  if ((__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) ||
+      (__llvm_profile_get_version() & VARIANT_MASK_BIN_CORRELATE))
+    return 0;
+  return End - Begin;
+}
+
 COMPILER_RT_VISIBILITY size_t __llvm_profile_counter_entry_size(void) {
   if (__llvm_profile_get_version() & VARIANT_MASK_BYTE_COVERAGE)
     return sizeof(uint8_t);
diff --git a/compiler-rt/lib/profile/InstrProfilingMerge.c b/compiler-rt/lib/profile/InstrProfilingMerge.c
index 9cf12f251f7262d..554ce3693b6e464 100644
--- a/compiler-rt/lib/profile/InstrProfilingMerge.c
+++ b/compiler-rt/lib/profile/InstrProfilingMerge.c
@@ -66,8 +66,9 @@ int __llvm_profile_check_compatibility(const char *ProfileData,
       Header->NumCounters !=
           __llvm_profile_get_num_counters(__llvm_profile_begin_counters(),
                                           __llvm_profile_end_counters()) ||
-      Header->NamesSize != (uint64_t)(__llvm_profile_end_names() -
-                                      __llvm_profile_begin_names()) ||
+      Header->NamesSize !=
+          __llvm_profile_get_name_size(__llvm_profile_begin_names(),
+                                       __llvm_profile_end_names()) ||
       Header->ValueKindLast != IPVK_Last)
     return 1;
 
@@ -132,7 +133,8 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
 
   // Merge counters by iterating the entire counter section when debug info
   // correlation is enabled.
-  if (__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) {
+  if ((__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) ||
+      (__llvm_profile_get_version() & VARIANT_MASK_BIN_CORRELATE)) {
     for (SrcCounter = SrcCountersStart,
         DstCounter = __llvm_profile_begin_counters();
          SrcCounter < SrcCountersEnd;) {
diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
index dd576b2f8357dbb..23a7739355e2ed6 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
@@ -13,8 +13,6 @@
 
 #if defined(_MSC_VER)
 /* Merge read-write sections into .data. */
-#pragma comment(linker, "/MERGE:.lprfc=.data")
-#pragma comment(linker, "/MERGE:.lprfd=.data")
 #pragma comment(linker, "/MERGE:.lprfv=.data")
 #pragma comment(linker, "/MERGE:.lprfnd=.data")
 /* Do *NOT* merge .lprfn and .lcovmap into .rdata. llvm-cov must be able to find
diff --git a/compiler-rt/lib/profile/InstrProfilingWriter.c b/compiler-rt/lib/profile/InstrProfilingWriter.c
index 1e22398a4c0f64a..f3709694427d5c8 100644
--- a/compiler-rt/lib/profile/InstrProfilingWriter.c
+++ b/compiler-rt/lib/profile/InstrProfilingWriter.c
@@ -259,19 +259,19 @@ lprofWriteDataImpl(ProfDataWriter *Writer, const __llvm_profile_data *DataBegin,
                    const char *CountersBegin, const char *CountersEnd,
                    VPDataReaderType *VPDataReader, const char *NamesBegin,
                    const char *NamesEnd, int SkipNameDataWrite) {
-  int DebugInfoCorrelate =
-      (__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) != 0ULL;
+  int ProfileCorrelation =
+      (__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) ||
+      (__llvm_profile_get_version() & VARIANT_MASK_BIN_CORRELATE);
 
   /* Calculate size of sections. */
   const uint64_t DataSectionSize =
-      DebugInfoCorrelate ? 0 : __llvm_profile_get_data_size(DataBegin, DataEnd);
-  const uint64_t NumData =
-      DebugInfoCorrelate ? 0 : __llvm_profile_get_num_data(DataBegin, DataEnd);
+      __llvm_profile_get_data_size(DataBegin, DataEnd);
+  const uint64_t NumData = __llvm_profile_get_num_data(DataBegin, DataEnd);
   const uint64_t CountersSectionSize =
       __llvm_profile_get_counters_size(CountersBegin, CountersEnd);
   const uint64_t NumCounters =
       __llvm_profile_get_num_counters(CountersBegin, CountersEnd);
-  const uint64_t NamesSize = DebugInfoCorrelate ? 0 : NamesEnd - NamesBegin;
+  const uint64_t NamesSize = __llvm_profile_get_name_size(NamesBegin, NamesEnd);
 
   /* Create the header. */
   __llvm_profile_header Header;
@@ -298,7 +298,7 @@ lprofWriteDataImpl(ProfDataWriter *Writer, const __llvm_profile_data *DataBegin,
 #endif
 
   /* The data and names sections are omitted in lightweight mode. */
-  if (DebugInfoCorrelate) {
+  if (ProfileCorrelation) {
     Header.CountersDelta = 0;
     Header.NamesDelta = 0;
   }
@@ -314,19 +314,19 @@ lprofWriteDataImpl(ProfDataWriter *Writer, const __llvm_profile_data *DataBegin,
 
   /* Write the profile data. */
   ProfDataIOVec IOVecData[] = {
-      {DebugInfoCorrelate ? NULL : DataBegin, sizeof(uint8_t), DataSectionSize,
+      {ProfileCorrelation ? NULL : DataBegin, sizeof(uint8_t), DataSectionSize,
        0},
       {NULL, sizeof(uint8_t), PaddingBytesBeforeCounters, 1},
       {CountersBegin, sizeof(uint8_t), CountersSectionSize, 0},
       {NULL, sizeof(uint8_t), PaddingBytesAfterCounters, 1},
-      {(SkipNameDataWrite || DebugInfoCorrelate) ? NULL : NamesBegin,
+      {(SkipNameDataWrite || ProfileCorrelation) ? NULL : NamesBegin,
        sizeof(uint8_t), NamesSize, 0},
       {NULL, sizeof(uint8_t), PaddingBytesAfterNames, 1}};
   if (Writer->Write(Writer, IOVecData, sizeof(IOVecData) / sizeof(*IOVecData)))
     return -1;
-
-  /* Value profiling is not yet supported in continuous mode. */
-  if (__llvm_profile_is_continuous_mode_enabled())
+  /* Value profiling is not yet supported in continuous mode and profile
+   * correlation mode. */
+  if (__llvm_profile_is_continuous_mode_enabled() || ProfileCorrelation)
     return 0;
 
   return writeValueProfData(Writer, VPDataReader, DataBegin, DataEnd);
diff --git a/compiler-rt/test/CMakeLists.txt b/compiler-rt/test/CMakeLists.txt
index f9b01b15b0e62c6..7357604b1f651eb 100644
--- a/compiler-rt/test/CMakeLists.txt
+++ b/compiler-rt/test/CMakeLists.txt
@@ -37,8 +37,9 @@ if(NOT ANDROID)
   if(NOT COMPILER_RT_STANDALONE_BUILD AND NOT LLVM_RUNTIMES_BUILD)
     # Use LLVM utils and Clang from the same build tree.
     list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS
-      clang clang-resource-headers FileCheck count not llvm-config llvm-nm llvm-objdump
-      llvm-readelf llvm-readobj llvm-size llvm-symbolizer compiler-rt-headers sancov split-file)
+      clang clang-resource-headers FileCheck count not llvm-config llvm-nm 
+      llvm-objdump llvm-readelf llvm-readobj llvm-size llvm-symbolizer 
+      compiler-rt-headers sancov split-file llvm-strip)
     if (WIN32)
       list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
     endif()
diff --git a/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c b/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
index f347d439e2e0671..46d25a4e386dc3a 100644
--- a/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
+++ b/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
@@ -1,5 +1,5 @@
 // Value profiling is currently not supported in lightweight mode.
-// RUN: %clang_pgogen -o %t -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
+// RUN: %clang_pgogen -o %t -g -mllvm --profile-correlate=debug-info -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
 // RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t
 // RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.proflite
 
@@ -9,7 +9,7 @@
 
 // RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata)
 
-// RUN: %clang_pgogen -o %t.cov -g -mllvm --debug-info-correlate -mllvm -pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
+// RUN: %clang_pgogen -o %t.cov -g -mllvm --profile-correlate=debug-info -mllvm -pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
 // RUN: env LLVM_PROFILE_FILE=%t.cov.proflite %run %t.cov
 // RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov.dSYM %t.cov.proflite
 
diff --git a/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate-warnings.c b/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate-warnings.c
index 5069c6340b64fd2..25022f241a6d281 100644
--- a/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate-warnings.c
+++ b/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate-warnings.c
@@ -1,6 +1,6 @@
 // Disable full debug info and verify that we get warnings during merging
 
-// RUN: %clang_pgogen -o %t -gline-tables-only -mllvm --debug-info-correlate -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
+// RUN: %clang_pgogen -o %t -gline-tables-only -mllvm --profile-correlate=debug-info -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
 // RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t
 // RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.proflite --max-debug-info-correlation-warnings=2 2>&1 >/dev/null | FileCheck %s --check-prefixes=CHECK,LIMIT --implicit-check-not=warning
 // RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.proflite --max-debug-info-correlation-warnings=0 2>&1 >/dev/null | FileCheck %s --check-prefixes=CHECK,NOLIMIT --implicit-check-not=warning
diff --git a/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c b/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
index a918d7b6299005e..ccfd65b6f4c4b16 100644
--- a/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
+++ b/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
@@ -3,19 +3,19 @@
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.normal
 // RUN: llvm-profdata merge -o %t.normal.profdata %t.profraw
 
-// RUN: %clang_pgogen -o %t.d4 -g -gdwarf-4 -mllvm --debug-info-correlate -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
+// RUN: %clang_pgogen -o %t.d4 -g -gdwarf-4 -mllvm --profile-correlate=debug-info -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
 // RUN: env LLVM_PROFILE_FILE=%t.d4.proflite %run %t.d4
 // RUN: llvm-profdata merge -o %t.d4.profdata --debug-info=%t.d4 %t.d4.proflite
 
 // RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.d4.profdata)
 
-// RUN: %clang_pgogen -o %t -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
+// RUN: %clang_pgogen -o %t -g -mllvm --profile-correlate=debug-info -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
 // RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t
 // RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.proflite
 
 // RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata)
 
-// RUN: %clang_pgogen -o %t.cov -g -mllvm --debug-info-correlate -mllvm -pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
+// RUN: %clang_pgogen -o %t.cov -g -mllvm --profile-correlate=debug-info -mllvm -pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
 // RUN: env LLVM_PROFILE_FILE=%t.cov.proflite %run %t.cov
 // RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov %t.cov.proflite
 
diff --git a/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c b/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
index 226d678aca347a4..93bf40f98d3ab62 100644
--- a/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
+++ b/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
@@ -1,10 +1,10 @@
-// RUN: %clang_pgogen -o %t -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %s
+// RUN: %clang_pgogen -o %t -g -mllvm --profile-correlate=debug-info -mllvm --disable-vp=true %s
 // RUN: llvm-profdata show --debug-info=%t --detailed-summary --show-prof-sym-list | FileCheck %s
 // RUN: llvm-profdata show --debug-info=%t --show-format=yaml | FileCheck %s --match-full-lines --check-prefix YAML
 
-// RUN: %clang_pgogen -o %t.no.dbg -mllvm --debug-info-correlate -mllvm --disable-vp=true %s
+// RUN: %clang_pgogen -o %t.no.dbg -mllvm --profile-correlate=debug-info -mllvm --disable-vp=true %s
 // RUN: not llvm-profdata show --debug-info=%t.no.dbg 2>&1 | FileCheck %s --check-prefix NO-DBG
-// NO-DBG: unable to correlate profile: ...
[truncated]

@github-actions
Copy link

github-actions bot commented Oct 18, 2023

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 142e567cf00815f7d1b3d72aaf298212a3f83ab2 a30427f87812329cabc2bcefd068686dc187a92a -- compiler-rt/test/profile/instrprof-binary-correlate.c clang/lib/CodeGen/BackendUtil.cpp compiler-rt/include/profile/InstrProfData.inc compiler-rt/lib/profile/InstrProfilingPlatformWindows.c llvm/include/llvm/ProfileData/InstrProf.h llvm/include/llvm/ProfileData/InstrProfCorrelator.h llvm/include/llvm/ProfileData/InstrProfData.inc llvm/include/llvm/ProfileData/InstrProfReader.h llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp llvm/lib/ProfileData/InstrProf.cpp llvm/lib/ProfileData/InstrProfCorrelator.cpp llvm/lib/ProfileData/InstrProfReader.cpp llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp llvm/tools/llvm-profdata/llvm-profdata.cpp
View the diff from clang-format here.
diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc
index f5de23ff4b..061492eb41 100644
--- a/compiler-rt/include/profile/InstrProfData.inc
+++ b/compiler-rt/include/profile/InstrProfData.inc
@@ -160,40 +160,51 @@ INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last)
 #endif
 VALUE_PROF_FUNC_PARAM(uint64_t, TargetValue, Type::getInt64Ty(Ctx)) \
                       INSTR_PROF_COMMA
-VALUE_PROF_FUNC_PARAM(void *, Data, PointerType::getUnqual(Ctx)) INSTR_PROF_COMMA
-VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx))
+                      VALUE_PROF_FUNC_PARAM(void *, Data,
+                                            PointerType::getUnqual(Ctx))
+                      INSTR_PROF_COMMA
+                          VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex,
+                                                Type::getInt32Ty(Ctx))
 #undef VALUE_PROF_FUNC_PARAM
 #undef INSTR_PROF_COMMA
-/* VALUE_PROF_FUNC_PARAM end */
+                      /* VALUE_PROF_FUNC_PARAM end */
 
-/* VALUE_PROF_KIND start */
+                      /* VALUE_PROF_KIND start */
 #ifndef VALUE_PROF_KIND
 #define VALUE_PROF_KIND(Enumerator, Value, Descr)
 #else
 #define INSTR_PROF_DATA_DEFINED
 #endif
-/* For indirect function call value profiling, the addresses of the target
- * functions are profiled by the instrumented code. The target addresses are
- * written in the raw profile data and converted to target function name's MD5
- * hash by the profile reader during deserialization.  Typically, this happens
- * when the raw profile data is read during profile merging.
- *
- * For this remapping the ProfData is used.  ProfData contains both the function
- * name hash and the function address.
- */
-VALUE_PROF_KIND(IPVK_IndirectCallTarget, 0, "indirect call target")
-/* For memory intrinsic functions size profiling. */
-VALUE_PROF_KIND(IPVK_MemOPSize, 1, "memory intrinsic functions size")
-/* These two kinds must be the last to be
- * declared. This is to make sure the string
- * array created with the template can be
- * indexed with the kind value.
- */
-VALUE_PROF_KIND(IPVK_First, IPVK_IndirectCallTarget, "first")
-VALUE_PROF_KIND(IPVK_Last, IPVK_MemOPSize, "last")
+                          /* For indirect function call value profiling, the
+                           * addresses of the target functions are profiled by
+                           * the instrumented code. The target addresses are
+                           * written in the raw profile data and converted to
+                           * target function name's MD5 hash by the profile
+                           * reader during deserialization.  Typically, this
+                           * happens when the raw profile data is read during
+                           * profile merging.
+                           *
+                           * For this remapping the ProfData is used.  ProfData
+                           * contains both the function name hash and the
+                           * function address.
+                           */
+                          VALUE_PROF_KIND(IPVK_IndirectCallTarget, 0,
+                                          "indirect call target")
+                          /* For memory intrinsic functions size profiling. */
+                          VALUE_PROF_KIND(IPVK_MemOPSize, 1,
+                                          "memory intrinsic functions size")
+                          /* These two kinds must be the last to be
+                           * declared. This is to make sure the string
+                           * array created with the template can be
+                           * indexed with the kind value.
+                           */
+                          VALUE_PROF_KIND(
+                              IPVK_First, IPVK_IndirectCallTarget,
+                              "first") VALUE_PROF_KIND(IPVK_Last,
+                                                       IPVK_MemOPSize, "last")
 
 #undef VALUE_PROF_KIND
-/* VALUE_PROF_KIND end */
+                      /* VALUE_PROF_KIND end */
 
 #undef COVMAP_V2_OR_V3
 #ifdef COVMAP_V2
@@ -203,162 +214,221 @@ VALUE_PROF_KIND(IPVK_Last, IPVK_MemOPSize, "last")
 #define COVMAP_V2_OR_V3
 #endif
 
-/* COVMAP_FUNC_RECORD start */
-/* Definition of member fields of the function record structure in coverage
- * map.
- */
+                      /* COVMAP_FUNC_RECORD start */
+                      /* Definition of member fields of the function record
+                       * structure in coverage map.
+                       */
 #ifndef COVMAP_FUNC_RECORD
-#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Initializer)
+#define COVMAP_FUNC_RECORD(Type, LLVMType, Name,         \
+                                                 Initializer)
 #else
 #define INSTR_PROF_DATA_DEFINED
 #endif
 #ifdef COVMAP_V1
-COVMAP_FUNC_RECORD(const IntPtrT, llvm::PointerType::getUnqual(Ctx), \
-                   NamePtr, llvm::ConstantExpr::getBitCast(NamePtr, \
-                   llvm::PointerType::getUnqual(Ctx)))
-COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
-                   llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \
-                   NameValue.size()))
+                              COVMAP_FUNC_RECORD(
+                                  const IntPtrT,
+                                  llvm::PointerType::getUnqual(Ctx), NamePtr,
+                                  llvm::ConstantExpr::getBitCast(
+                                      NamePtr,
+                                      llvm::PointerType::getUnqual(Ctx)))
+                                  COVMAP_FUNC_RECORD(
+                                      const uint32_t,
+                                      llvm::Type::getInt32Ty(Ctx), NameSize,
+                                      llvm::ConstantInt::get(
+                                          llvm::Type::getInt32Ty(Ctx),
+                                          NameValue.size()))
 #endif
 #ifdef COVMAP_V2_OR_V3
-COVMAP_FUNC_RECORD(const int64_t, llvm::Type::getInt64Ty(Ctx), NameRef, \
-                   llvm::ConstantInt::get( \
-                     llvm::Type::getInt64Ty(Ctx), NameHash))
+                                      COVMAP_FUNC_RECORD(
+                                          const int64_t,
+                                          llvm::Type::getInt64Ty(Ctx), NameRef,
+                                          llvm::ConstantInt::get(
+                                              llvm::Type::getInt64Ty(Ctx),
+                                              NameHash))
 #endif
-COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), DataSize, \
-                   llvm::ConstantInt::get( \
-                     llvm::Type::getInt32Ty(Ctx), CoverageMapping.size()))
-COVMAP_FUNC_RECORD(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
-                   llvm::ConstantInt::get( \
-                     llvm::Type::getInt64Ty(Ctx), FuncHash))
+                                          COVMAP_FUNC_RECORD(
+                                              const uint32_t,
+                                              llvm::Type::getInt32Ty(Ctx),
+                                              DataSize,
+                                              llvm::ConstantInt::get(
+                                                  llvm::Type::getInt32Ty(Ctx),
+                                                  CoverageMapping.size()))
+                                              COVMAP_FUNC_RECORD(
+                                                  const uint64_t,
+                                                  llvm::Type::getInt64Ty(Ctx),
+                                                  FuncHash,
+                                                  llvm::ConstantInt::get(
+                                                      llvm::Type::getInt64Ty(
+                                                          Ctx),
+                                                      FuncHash))
 #ifdef COVMAP_V3
-COVMAP_FUNC_RECORD(const uint64_t, llvm::Type::getInt64Ty(Ctx), FilenamesRef, \
-                   llvm::ConstantInt::get( \
-                     llvm::Type::getInt64Ty(Ctx), FilenamesRef))
-COVMAP_FUNC_RECORD(const char, \
-                   llvm::ArrayType::get(llvm::Type::getInt8Ty(Ctx), \
-                                        CoverageMapping.size()), \
-                   CoverageMapping,
-                   llvm::ConstantDataArray::getRaw( \
-                     CoverageMapping, CoverageMapping.size(), \
-                     llvm::Type::getInt8Ty(Ctx)))
+                                                  COVMAP_FUNC_RECORD(
+                                                      const uint64_t,
+                                                      llvm::Type::getInt64Ty(
+                                                          Ctx),
+                                                      FilenamesRef,
+                                                      llvm::ConstantInt::get(
+                                                          llvm::Type::
+                                                              getInt64Ty(Ctx),
+                                                          FilenamesRef))
+                                                      COVMAP_FUNC_RECORD(
+                                                          const char,
+                                                          llvm::ArrayType::get(
+                                                              llvm::Type::
+                                                                  getInt8Ty(
+                                                                      Ctx),
+                                                              CoverageMapping
+                                                                  .size()),
+                                                          CoverageMapping,
+                                                          llvm::ConstantDataArray::
+                                                              getRaw(
+                                                                  CoverageMapping,
+                                                                  CoverageMapping
+                                                                      .size(),
+                                                                  llvm::Type::
+                                                                      getInt8Ty(
+                                                                          Ctx)))
 #endif
 #undef COVMAP_FUNC_RECORD
-/* COVMAP_FUNC_RECORD end.  */
+                      /* COVMAP_FUNC_RECORD end.  */
 
-/* COVMAP_HEADER start */
-/* Definition of member fields of coverage map header.
- */
+                      /* COVMAP_HEADER start */
+                      /* Definition of member fields of coverage map header.
+                       */
 #ifndef COVMAP_HEADER
 #define COVMAP_HEADER(Type, LLVMType, Name, Initializer)
 #else
 #define INSTR_PROF_DATA_DEFINED
 #endif
-COVMAP_HEADER(uint32_t, Int32Ty, NRecords, \
-              llvm::ConstantInt::get(Int32Ty, NRecords))
-COVMAP_HEADER(uint32_t, Int32Ty, FilenamesSize, \
-              llvm::ConstantInt::get(Int32Ty, FilenamesSize))
-COVMAP_HEADER(uint32_t, Int32Ty, CoverageSize, \
-              llvm::ConstantInt::get(Int32Ty, CoverageMappingSize))
-COVMAP_HEADER(uint32_t, Int32Ty, Version, \
-              llvm::ConstantInt::get(Int32Ty, CovMapVersion::CurrentVersion))
+                                                          COVMAP_HEADER(
+                                                              uint32_t, Int32Ty,
+                                                              NRecords,
+                                                              llvm::ConstantInt::
+                                                                  get(Int32Ty,
+                                                                      NRecords))
+                                                              COVMAP_HEADER(
+                                                                  uint32_t,
+                                                                  Int32Ty,
+                                                                  FilenamesSize,
+                                                                  llvm::ConstantInt::
+                                                                      get(Int32Ty,
+                                                                          FilenamesSize))
+                                                                  COVMAP_HEADER(
+                                                                      uint32_t,
+                                                                      Int32Ty,
+                                                                      CoverageSize,
+                                                                      llvm::ConstantInt::
+                                                                          get(Int32Ty,
+                                                                              CoverageMappingSize))
+                                                                      COVMAP_HEADER(
+                                                                          uint32_t,
+                                                                          Int32Ty,
+                                                                          Version,
+                                                                          llvm::ConstantInt::
+                                                                              get(Int32Ty,
+                                                                                  CovMapVersion::
+                                                                                      CurrentVersion))
 #undef COVMAP_HEADER
-/* COVMAP_HEADER end.  */
-
+                      /* COVMAP_HEADER end.  */
 
 #ifdef INSTR_PROF_SECT_ENTRY
 #define INSTR_PROF_DATA_DEFINED
-INSTR_PROF_SECT_ENTRY(IPSK_data, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_DATA_COMMON), \
-                      INSTR_PROF_DATA_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_cnts, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_CNTS_COMMON), \
-                      INSTR_PROF_CNTS_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_bitmap, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_BITS_COMMON), \
-                      INSTR_PROF_BITS_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_name, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_NAME_COMMON), \
-                      INSTR_PROF_NAME_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_vals, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_VALS_COMMON), \
-                      INSTR_PROF_VALS_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_vnodes, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_VNODES_COMMON), \
-                      INSTR_PROF_VNODES_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_covmap, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_COVMAP_COMMON), \
-                      INSTR_PROF_COVMAP_COFF, "__LLVM_COV,")
-INSTR_PROF_SECT_ENTRY(IPSK_covfun, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_COVFUN_COMMON), \
-                      INSTR_PROF_COVFUN_COFF, "__LLVM_COV,")
-INSTR_PROF_SECT_ENTRY(IPSK_orderfile, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_COMMON), \
-                      INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_COFF), "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_covdata, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_COVDATA_COMMON), \
-                      INSTR_PROF_COVDATA_COFF, "__LLVM_COV,")
-INSTR_PROF_SECT_ENTRY(IPSK_covname, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_COVNAME_COMMON), \
-                      INSTR_PROF_COVNAME_COFF, "__LLVM_COV,")
+                                                                          INSTR_PROF_SECT_ENTRY(IPSK_data,
+                                                                                                INSTR_PROF_QUOTE(
+                                                                                                    INSTR_PROF_DATA_COMMON),
+                                                                                                INSTR_PROF_DATA_COFF, "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_cnts, INSTR_PROF_QUOTE(INSTR_PROF_CNTS_COMMON), INSTR_PROF_CNTS_COFF, "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_bitmap, INSTR_PROF_QUOTE(INSTR_PROF_BITS_COMMON), INSTR_PROF_BITS_COFF, "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_name, INSTR_PROF_QUOTE(INSTR_PROF_NAME_COMMON), INSTR_PROF_NAME_COFF,
+                                                                                                                                                                                                                                                                                                                                                                                 "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_vals,
+                                                                                                                                                                                                                                                                                                                                                                                                                  INSTR_PROF_QUOTE(
+                                                                                                                                                                                                                                                                                                                                                                                                                      INSTR_PROF_VALS_COMMON),
+                                                                                                                                                                                                                                                                                                                                                                                                                  INSTR_PROF_VALS_COFF, "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_vnodes,
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                         INSTR_PROF_QUOTE(
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                             INSTR_PROF_VNODES_COMMON),
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                         INSTR_PROF_VNODES_COFF, "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_covmap, INSTR_PROF_QUOTE(INSTR_PROF_COVMAP_COMMON),
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  INSTR_PROF_COVMAP_COFF, "__LLVM_COV,") INSTR_PROF_SECT_ENTRY(IPSK_covfun, INSTR_PROF_QUOTE(INSTR_PROF_COVFUN_COMMON), INSTR_PROF_COVFUN_COFF,
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               "__LLVM_COV,") INSTR_PROF_SECT_ENTRY(IPSK_orderfile,
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    INSTR_PROF_QUOTE(
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        INSTR_PROF_ORDERFILE_COMMON),
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    INSTR_PROF_QUOTE(
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        INSTR_PROF_ORDERFILE_COFF),
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    "__DATA,")
+                                                                              INSTR_PROF_SECT_ENTRY(
+                                                                                  IPSK_covdata,
+                                                                                  INSTR_PROF_QUOTE(
+                                                                                      INSTR_PROF_COVDATA_COMMON),
+                                                                                  INSTR_PROF_COVDATA_COFF,
+                                                                                  "__LLVM_COV,")
+                                                                                  INSTR_PROF_SECT_ENTRY(
+                                                                                      IPSK_covname,
+                                                                                      INSTR_PROF_QUOTE(
+                                                                                          INSTR_PROF_COVNAME_COMMON),
+                                                                                      INSTR_PROF_COVNAME_COFF,
+                                                                                      "__LLVM_COV,")
 
 #undef INSTR_PROF_SECT_ENTRY
 #endif
 
-
 #ifdef INSTR_PROF_VALUE_PROF_DATA
 #define INSTR_PROF_DATA_DEFINED
 
 #define INSTR_PROF_MAX_NUM_VAL_PER_SITE 255
-/*!
- * This is the header of the data structure that defines the on-disk
- * layout of the value profile data of a particular kind for one function.
- */
-typedef struct ValueProfRecord {
-  /* The kind of the value profile record. */
-  uint32_t Kind;
-  /*
-   * The number of value profile sites. It is guaranteed to be non-zero;
-   * otherwise the record for this kind won't be emitted.
-   */
-  uint32_t NumValueSites;
-  /*
-   * The first element of the array that stores the number of profiled
-   * values for each value site. The size of the array is NumValueSites.
-   * Since NumValueSites is greater than zero, there is at least one
-   * element in the array.
-   */
-  uint8_t SiteCountArray[1];
-
-  /*
-   * The fake declaration is for documentation purpose only.
-   * Align the start of next field to be on 8 byte boundaries.
-  uint8_t Padding[X];
-   */
-
-  /* The array of value profile data. The size of the array is the sum
-   * of all elements in SiteCountArray[].
-  InstrProfValueData ValueData[];
-   */
+                          /*!
+                           * This is the header of the data structure that
+                           * defines the on-disk layout of the value profile
+                           * data of a particular kind for one function.
+                           */
+                          typedef struct ValueProfRecord {
+                        /* The kind of the value profile record. */
+                        uint32_t Kind;
+                        /*
+                         * The number of value profile sites. It is guaranteed
+                         * to be non-zero; otherwise the record for this kind
+                         * won't be emitted.
+                         */
+                        uint32_t NumValueSites;
+                        /*
+                         * The first element of the array that stores the number
+                         * of profiled values for each value site. The size of
+                         * the array is NumValueSites. Since NumValueSites is
+                         * greater than zero, there is at least one element in
+                         * the array.
+                         */
+                        uint8_t SiteCountArray[1];
+
+                        /*
+                         * The fake declaration is for documentation purpose
+                        only.
+                         * Align the start of next field to be on 8 byte
+                        boundaries. uint8_t Padding[X];
+                         */
+
+                        /* The array of value profile data. The size of the
+                        array is the sum
+                         * of all elements in SiteCountArray[].
+                        InstrProfValueData ValueData[];
+                         */
 
 #ifdef __cplusplus
-  /*!
-   * Return the number of value sites.
-   */
-  uint32_t getNumValueSites() const { return NumValueSites; }
-  /*!
-   * Read data from this record and save it to Record.
-   */
-  void deserializeTo(InstrProfRecord &Record,
-                     InstrProfSymtab *SymTab);
-  /*
-   * In-place byte swap:
-   * Do byte swap for this instance. \c Old is the original order before
-   * the swap, and \c New is the New byte order.
-   */
-  void swapBytes(llvm::endianness Old, llvm::endianness New);
+                        /*!
+                         * Return the number of value sites.
+                         */
+                        uint32_t getNumValueSites() const {
+                          return NumValueSites;
+                        }
+                        /*!
+                         * Read data from this record and save it to Record.
+                         */
+                        void deserializeTo(InstrProfRecord &Record,
+                                           InstrProfSymtab *SymTab);
+                        /*
+                         * In-place byte swap:
+                         * Do byte swap for this instance. \c Old is the
+                         * original order before the swap, and \c New is the New
+                         * byte order.
+                         */
+                        void swapBytes(llvm::endianness Old,
+                                       llvm::endianness New);
 #endif
-} ValueProfRecord;
+                      } ValueProfRecord;
 
 /*!
  * Per-function header/control data structure for value profiling
diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc
index f5de23ff4b..061492eb41 100644
--- a/llvm/include/llvm/ProfileData/InstrProfData.inc
+++ b/llvm/include/llvm/ProfileData/InstrProfData.inc
@@ -160,40 +160,51 @@ INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last)
 #endif
 VALUE_PROF_FUNC_PARAM(uint64_t, TargetValue, Type::getInt64Ty(Ctx)) \
                       INSTR_PROF_COMMA
-VALUE_PROF_FUNC_PARAM(void *, Data, PointerType::getUnqual(Ctx)) INSTR_PROF_COMMA
-VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx))
+                      VALUE_PROF_FUNC_PARAM(void *, Data,
+                                            PointerType::getUnqual(Ctx))
+                      INSTR_PROF_COMMA
+                          VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex,
+                                                Type::getInt32Ty(Ctx))
 #undef VALUE_PROF_FUNC_PARAM
 #undef INSTR_PROF_COMMA
-/* VALUE_PROF_FUNC_PARAM end */
+                      /* VALUE_PROF_FUNC_PARAM end */
 
-/* VALUE_PROF_KIND start */
+                      /* VALUE_PROF_KIND start */
 #ifndef VALUE_PROF_KIND
 #define VALUE_PROF_KIND(Enumerator, Value, Descr)
 #else
 #define INSTR_PROF_DATA_DEFINED
 #endif
-/* For indirect function call value profiling, the addresses of the target
- * functions are profiled by the instrumented code. The target addresses are
- * written in the raw profile data and converted to target function name's MD5
- * hash by the profile reader during deserialization.  Typically, this happens
- * when the raw profile data is read during profile merging.
- *
- * For this remapping the ProfData is used.  ProfData contains both the function
- * name hash and the function address.
- */
-VALUE_PROF_KIND(IPVK_IndirectCallTarget, 0, "indirect call target")
-/* For memory intrinsic functions size profiling. */
-VALUE_PROF_KIND(IPVK_MemOPSize, 1, "memory intrinsic functions size")
-/* These two kinds must be the last to be
- * declared. This is to make sure the string
- * array created with the template can be
- * indexed with the kind value.
- */
-VALUE_PROF_KIND(IPVK_First, IPVK_IndirectCallTarget, "first")
-VALUE_PROF_KIND(IPVK_Last, IPVK_MemOPSize, "last")
+                          /* For indirect function call value profiling, the
+                           * addresses of the target functions are profiled by
+                           * the instrumented code. The target addresses are
+                           * written in the raw profile data and converted to
+                           * target function name's MD5 hash by the profile
+                           * reader during deserialization.  Typically, this
+                           * happens when the raw profile data is read during
+                           * profile merging.
+                           *
+                           * For this remapping the ProfData is used.  ProfData
+                           * contains both the function name hash and the
+                           * function address.
+                           */
+                          VALUE_PROF_KIND(IPVK_IndirectCallTarget, 0,
+                                          "indirect call target")
+                          /* For memory intrinsic functions size profiling. */
+                          VALUE_PROF_KIND(IPVK_MemOPSize, 1,
+                                          "memory intrinsic functions size")
+                          /* These two kinds must be the last to be
+                           * declared. This is to make sure the string
+                           * array created with the template can be
+                           * indexed with the kind value.
+                           */
+                          VALUE_PROF_KIND(
+                              IPVK_First, IPVK_IndirectCallTarget,
+                              "first") VALUE_PROF_KIND(IPVK_Last,
+                                                       IPVK_MemOPSize, "last")
 
 #undef VALUE_PROF_KIND
-/* VALUE_PROF_KIND end */
+                      /* VALUE_PROF_KIND end */
 
 #undef COVMAP_V2_OR_V3
 #ifdef COVMAP_V2
@@ -203,162 +214,221 @@ VALUE_PROF_KIND(IPVK_Last, IPVK_MemOPSize, "last")
 #define COVMAP_V2_OR_V3
 #endif
 
-/* COVMAP_FUNC_RECORD start */
-/* Definition of member fields of the function record structure in coverage
- * map.
- */
+                      /* COVMAP_FUNC_RECORD start */
+                      /* Definition of member fields of the function record
+                       * structure in coverage map.
+                       */
 #ifndef COVMAP_FUNC_RECORD
-#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Initializer)
+#define COVMAP_FUNC_RECORD(Type, LLVMType, Name,         \
+                                                 Initializer)
 #else
 #define INSTR_PROF_DATA_DEFINED
 #endif
 #ifdef COVMAP_V1
-COVMAP_FUNC_RECORD(const IntPtrT, llvm::PointerType::getUnqual(Ctx), \
-                   NamePtr, llvm::ConstantExpr::getBitCast(NamePtr, \
-                   llvm::PointerType::getUnqual(Ctx)))
-COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
-                   llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \
-                   NameValue.size()))
+                              COVMAP_FUNC_RECORD(
+                                  const IntPtrT,
+                                  llvm::PointerType::getUnqual(Ctx), NamePtr,
+                                  llvm::ConstantExpr::getBitCast(
+                                      NamePtr,
+                                      llvm::PointerType::getUnqual(Ctx)))
+                                  COVMAP_FUNC_RECORD(
+                                      const uint32_t,
+                                      llvm::Type::getInt32Ty(Ctx), NameSize,
+                                      llvm::ConstantInt::get(
+                                          llvm::Type::getInt32Ty(Ctx),
+                                          NameValue.size()))
 #endif
 #ifdef COVMAP_V2_OR_V3
-COVMAP_FUNC_RECORD(const int64_t, llvm::Type::getInt64Ty(Ctx), NameRef, \
-                   llvm::ConstantInt::get( \
-                     llvm::Type::getInt64Ty(Ctx), NameHash))
+                                      COVMAP_FUNC_RECORD(
+                                          const int64_t,
+                                          llvm::Type::getInt64Ty(Ctx), NameRef,
+                                          llvm::ConstantInt::get(
+                                              llvm::Type::getInt64Ty(Ctx),
+                                              NameHash))
 #endif
-COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), DataSize, \
-                   llvm::ConstantInt::get( \
-                     llvm::Type::getInt32Ty(Ctx), CoverageMapping.size()))
-COVMAP_FUNC_RECORD(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
-                   llvm::ConstantInt::get( \
-                     llvm::Type::getInt64Ty(Ctx), FuncHash))
+                                          COVMAP_FUNC_RECORD(
+                                              const uint32_t,
+                                              llvm::Type::getInt32Ty(Ctx),
+                                              DataSize,
+                                              llvm::ConstantInt::get(
+                                                  llvm::Type::getInt32Ty(Ctx),
+                                                  CoverageMapping.size()))
+                                              COVMAP_FUNC_RECORD(
+                                                  const uint64_t,
+                                                  llvm::Type::getInt64Ty(Ctx),
+                                                  FuncHash,
+                                                  llvm::ConstantInt::get(
+                                                      llvm::Type::getInt64Ty(
+                                                          Ctx),
+                                                      FuncHash))
 #ifdef COVMAP_V3
-COVMAP_FUNC_RECORD(const uint64_t, llvm::Type::getInt64Ty(Ctx), FilenamesRef, \
-                   llvm::ConstantInt::get( \
-                     llvm::Type::getInt64Ty(Ctx), FilenamesRef))
-COVMAP_FUNC_RECORD(const char, \
-                   llvm::ArrayType::get(llvm::Type::getInt8Ty(Ctx), \
-                                        CoverageMapping.size()), \
-                   CoverageMapping,
-                   llvm::ConstantDataArray::getRaw( \
-                     CoverageMapping, CoverageMapping.size(), \
-                     llvm::Type::getInt8Ty(Ctx)))
+                                                  COVMAP_FUNC_RECORD(
+                                                      const uint64_t,
+                                                      llvm::Type::getInt64Ty(
+                                                          Ctx),
+                                                      FilenamesRef,
+                                                      llvm::ConstantInt::get(
+                                                          llvm::Type::
+                                                              getInt64Ty(Ctx),
+                                                          FilenamesRef))
+                                                      COVMAP_FUNC_RECORD(
+                                                          const char,
+                                                          llvm::ArrayType::get(
+                                                              llvm::Type::
+                                                                  getInt8Ty(
+                                                                      Ctx),
+                                                              CoverageMapping
+                                                                  .size()),
+                                                          CoverageMapping,
+                                                          llvm::ConstantDataArray::
+                                                              getRaw(
+                                                                  CoverageMapping,
+                                                                  CoverageMapping
+                                                                      .size(),
+                                                                  llvm::Type::
+                                                                      getInt8Ty(
+                                                                          Ctx)))
 #endif
 #undef COVMAP_FUNC_RECORD
-/* COVMAP_FUNC_RECORD end.  */
+                      /* COVMAP_FUNC_RECORD end.  */
 
-/* COVMAP_HEADER start */
-/* Definition of member fields of coverage map header.
- */
+                      /* COVMAP_HEADER start */
+                      /* Definition of member fields of coverage map header.
+                       */
 #ifndef COVMAP_HEADER
 #define COVMAP_HEADER(Type, LLVMType, Name, Initializer)
 #else
 #define INSTR_PROF_DATA_DEFINED
 #endif
-COVMAP_HEADER(uint32_t, Int32Ty, NRecords, \
-              llvm::ConstantInt::get(Int32Ty, NRecords))
-COVMAP_HEADER(uint32_t, Int32Ty, FilenamesSize, \
-              llvm::ConstantInt::get(Int32Ty, FilenamesSize))
-COVMAP_HEADER(uint32_t, Int32Ty, CoverageSize, \
-              llvm::ConstantInt::get(Int32Ty, CoverageMappingSize))
-COVMAP_HEADER(uint32_t, Int32Ty, Version, \
-              llvm::ConstantInt::get(Int32Ty, CovMapVersion::CurrentVersion))
+                                                          COVMAP_HEADER(
+                                                              uint32_t, Int32Ty,
+                                                              NRecords,
+                                                              llvm::ConstantInt::
+                                                                  get(Int32Ty,
+                                                                      NRecords))
+                                                              COVMAP_HEADER(
+                                                                  uint32_t,
+                                                                  Int32Ty,
+                                                                  FilenamesSize,
+                                                                  llvm::ConstantInt::
+                                                                      get(Int32Ty,
+                                                                          FilenamesSize))
+                                                                  COVMAP_HEADER(
+                                                                      uint32_t,
+                                                                      Int32Ty,
+                                                                      CoverageSize,
+                                                                      llvm::ConstantInt::
+                                                                          get(Int32Ty,
+                                                                              CoverageMappingSize))
+                                                                      COVMAP_HEADER(
+                                                                          uint32_t,
+                                                                          Int32Ty,
+                                                                          Version,
+                                                                          llvm::ConstantInt::
+                                                                              get(Int32Ty,
+                                                                                  CovMapVersion::
+                                                                                      CurrentVersion))
 #undef COVMAP_HEADER
-/* COVMAP_HEADER end.  */
-
+                      /* COVMAP_HEADER end.  */
 
 #ifdef INSTR_PROF_SECT_ENTRY
 #define INSTR_PROF_DATA_DEFINED
-INSTR_PROF_SECT_ENTRY(IPSK_data, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_DATA_COMMON), \
-                      INSTR_PROF_DATA_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_cnts, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_CNTS_COMMON), \
-                      INSTR_PROF_CNTS_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_bitmap, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_BITS_COMMON), \
-                      INSTR_PROF_BITS_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_name, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_NAME_COMMON), \
-                      INSTR_PROF_NAME_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_vals, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_VALS_COMMON), \
-                      INSTR_PROF_VALS_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_vnodes, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_VNODES_COMMON), \
-                      INSTR_PROF_VNODES_COFF, "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_covmap, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_COVMAP_COMMON), \
-                      INSTR_PROF_COVMAP_COFF, "__LLVM_COV,")
-INSTR_PROF_SECT_ENTRY(IPSK_covfun, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_COVFUN_COMMON), \
-                      INSTR_PROF_COVFUN_COFF, "__LLVM_COV,")
-INSTR_PROF_SECT_ENTRY(IPSK_orderfile, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_COMMON), \
-                      INSTR_PROF_QUOTE(INSTR_PROF_ORDERFILE_COFF), "__DATA,")
-INSTR_PROF_SECT_ENTRY(IPSK_covdata, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_COVDATA_COMMON), \
-                      INSTR_PROF_COVDATA_COFF, "__LLVM_COV,")
-INSTR_PROF_SECT_ENTRY(IPSK_covname, \
-                      INSTR_PROF_QUOTE(INSTR_PROF_COVNAME_COMMON), \
-                      INSTR_PROF_COVNAME_COFF, "__LLVM_COV,")
+                                                                          INSTR_PROF_SECT_ENTRY(IPSK_data,
+                                                                                                INSTR_PROF_QUOTE(
+                                                                                                    INSTR_PROF_DATA_COMMON),
+                                                                                                INSTR_PROF_DATA_COFF, "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_cnts, INSTR_PROF_QUOTE(INSTR_PROF_CNTS_COMMON), INSTR_PROF_CNTS_COFF, "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_bitmap, INSTR_PROF_QUOTE(INSTR_PROF_BITS_COMMON), INSTR_PROF_BITS_COFF, "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_name, INSTR_PROF_QUOTE(INSTR_PROF_NAME_COMMON), INSTR_PROF_NAME_COFF,
+                                                                                                                                                                                                                                                                                                                                                                                 "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_vals,
+                                                                                                                                                                                                                                                                                                                                                                                                                  INSTR_PROF_QUOTE(
+                                                                                                                                                                                                                                                                                                                                                                                                                      INSTR_PROF_VALS_COMMON),
+                                                                                                                                                                                                                                                                                                                                                                                                                  INSTR_PROF_VALS_COFF, "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_vnodes,
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                         INSTR_PROF_QUOTE(
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                             INSTR_PROF_VNODES_COMMON),
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                         INSTR_PROF_VNODES_COFF, "__DATA,") INSTR_PROF_SECT_ENTRY(IPSK_covmap, INSTR_PROF_QUOTE(INSTR_PROF_COVMAP_COMMON),
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  INSTR_PROF_COVMAP_COFF, "__LLVM_COV,") INSTR_PROF_SECT_ENTRY(IPSK_covfun, INSTR_PROF_QUOTE(INSTR_PROF_COVFUN_COMMON), INSTR_PROF_COVFUN_COFF,
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               "__LLVM_COV,") INSTR_PROF_SECT_ENTRY(IPSK_orderfile,
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    INSTR_PROF_QUOTE(
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        INSTR_PROF_ORDERFILE_COMMON),
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    INSTR_PROF_QUOTE(
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        INSTR_PROF_ORDERFILE_COFF),
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    "__DATA,")
+                                                                              INSTR_PROF_SECT_ENTRY(
+                                                                                  IPSK_covdata,
+                                                                                  INSTR_PROF_QUOTE(
+                                                                                      INSTR_PROF_COVDATA_COMMON),
+                                                                                  INSTR_PROF_COVDATA_COFF,
+                                                                                  "__LLVM_COV,")
+                                                                                  INSTR_PROF_SECT_ENTRY(
+                                                                                      IPSK_covname,
+                                                                                      INSTR_PROF_QUOTE(
+                                                                                          INSTR_PROF_COVNAME_COMMON),
+                                                                                      INSTR_PROF_COVNAME_COFF,
+                                                                                      "__LLVM_COV,")
 
 #undef INSTR_PROF_SECT_ENTRY
 #endif
 
-
 #ifdef INSTR_PROF_VALUE_PROF_DATA
 #define INSTR_PROF_DATA_DEFINED
 
 #define INSTR_PROF_MAX_NUM_VAL_PER_SITE 255
-/*!
- * This is the header of the data structure that defines the on-disk
- * layout of the value profile data of a particular kind for one function.
- */
-typedef struct ValueProfRecord {
-  /* The kind of the value profile record. */
-  uint32_t Kind;
-  /*
-   * The number of value profile sites. It is guaranteed to be non-zero;
-   * otherwise the record for this kind won't be emitted.
-   */
-  uint32_t NumValueSites;
-  /*
-   * The first element of the array that stores the number of profiled
-   * values for each value site. The size of the array is NumValueSites.
-   * Since NumValueSites is greater than zero, there is at least one
-   * element in the array.
-   */
-  uint8_t SiteCountArray[1];
-
-  /*
-   * The fake declaration is for documentation purpose only.
-   * Align the start of next field to be on 8 byte boundaries.
-  uint8_t Padding[X];
-   */
-
-  /* The array of value profile data. The size of the array is the sum
-   * of all elements in SiteCountArray[].
-  InstrProfValueData ValueData[];
-   */
+                          /*!
+                           * This is the header of the data structure that
+                           * defines the on-disk layout of the value profile
+                           * data of a particular kind for one function.
+                           */
+                          typedef struct ValueProfRecord {
+                        /* The kind of the value profile record. */
+                        uint32_t Kind;
+                        /*
+                         * The number of value profile sites. It is guaranteed
+                         * to be non-zero; otherwise the record for this kind
+                         * won't be emitted.
+                         */
+                        uint32_t NumValueSites;
+                        /*
+                         * The first element of the array that stores the number
+                         * of profiled values for each value site. The size of
+                         * the array is NumValueSites. Since NumValueSites is
+                         * greater than zero, there is at least one element in
+                         * the array.
+                         */
+                        uint8_t SiteCountArray[1];
+
+                        /*
+                         * The fake declaration is for documentation purpose
+                        only.
+                         * Align the start of next field to be on 8 byte
+                        boundaries. uint8_t Padding[X];
+                         */
+
+                        /* The array of value profile data. The size of the
+                        array is the sum
+                         * of all elements in SiteCountArray[].
+                        InstrProfValueData ValueData[];
+                         */
 
 #ifdef __cplusplus
-  /*!
-   * Return the number of value sites.
-   */
-  uint32_t getNumValueSites() const { return NumValueSites; }
-  /*!
-   * Read data from this record and save it to Record.
-   */
-  void deserializeTo(InstrProfRecord &Record,
-                     InstrProfSymtab *SymTab);
-  /*
-   * In-place byte swap:
-   * Do byte swap for this instance. \c Old is the original order before
-   * the swap, and \c New is the New byte order.
-   */
-  void swapBytes(llvm::endianness Old, llvm::endianness New);
+                        /*!
+                         * Return the number of value sites.
+                         */
+                        uint32_t getNumValueSites() const {
+                          return NumValueSites;
+                        }
+                        /*!
+                         * Read data from this record and save it to Record.
+                         */
+                        void deserializeTo(InstrProfRecord &Record,
+                                           InstrProfSymtab *SymTab);
+                        /*
+                         * In-place byte swap:
+                         * Do byte swap for this instance. \c Old is the
+                         * original order before the swap, and \c New is the New
+                         * byte order.
+                         */
+                        void swapBytes(llvm::endianness Old,
+                                       llvm::endianness New);
 #endif
-} ValueProfRecord;
+                      } ValueProfRecord;
 
 /*!
  * Per-function header/control data structure for value profiling

@@ -0,0 +1,11 @@
; RUN: opt < %s -passes=instrprof -profile-correlate=binary -S | FileCheck %s

; CHECK: @__profd_foo = private global { i64, i64, i64, ptr, ptr, i32, [2 x i16] } { i64 {{.*}}, i64 {{.*}}, i64 ptrtoint (ptr @__profc_foo to i64)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though the CounterPtr's type (3rd argument) is i64, not ptr, I found that when lowered to assembly, it is just the address of the counter label. I guess it's fine.

@david-xl
Copy link
Contributor

Can you send a RFC for this enhancement ? The first 2 paragraph of this PR can be expanded a little more to show motivations (RAM saving, or raw profile size saving and why) and the savings data.

@gulfemsavrun gulfemsavrun self-requested a review October 18, 2023 22:53
Copy link
Collaborator

@zmodem zmodem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be a proper Clang flag to control this, instead of requiring users to pass internal -mllvm flags. (Also the flag should be well documented.)

@rnk
Copy link
Collaborator

rnk commented Oct 19, 2023

I think there should be a proper Clang flag to control this, instead of requiring users to pass internal -mllvm flags. (Also the flag should be well documented.)

I believe Zequan did that at one point, but he ran into the problem that Rust and Clang need to agree on the coverage metadata section flags. Using an mllvm flag means we can opt into the new mode for both clang and rust simultaneously, hopefully without waiting for rustc changes.

It's interesting that historically we have discouraged mllvm flags, but in a new world of multiple frontends outside the llvm-project monorepo, having a direct command line interface to the middle-end becomes more valuable.

clang/lib/CodeGen/BackendUtil.cpp Show resolved Hide resolved
compiler-rt/lib/profile/InstrProfiling.h Outdated Show resolved Hide resolved
compiler-rt/lib/profile/InstrProfilingBuffer.c Outdated Show resolved Hide resolved
compiler-rt/lib/profile/InstrProfilingBuffer.c Outdated Show resolved Hide resolved
compiler-rt/lib/profile/InstrProfilingBuffer.c Outdated Show resolved Hide resolved
compiler-rt/lib/profile/InstrProfilingMerge.c Outdated Show resolved Hide resolved
compiler-rt/lib/profile/InstrProfilingWriter.c Outdated Show resolved Hide resolved
compiler-rt/lib/profile/InstrProfilingWriter.c Outdated Show resolved Hide resolved
llvm/include/llvm/ProfileData/InstrProfReader.h Outdated Show resolved Hide resolved
llvm/lib/ProfileData/InstrProfReader.cpp Outdated Show resolved Hide resolved
@ZequanWu
Copy link
Contributor Author

I think there should be a proper Clang flag to control this, instead of requiring users to pass internal -mllvm flags. (Also the flag should be well documented.)

I believe Zequan did that at one point, but he ran into the problem that Rust and Clang need to agree on the coverage metadata section flags. Using an mllvm flag means we can opt into the new mode for both clang and rust simultaneously, hopefully without waiting for rustc changes.

Since I modified clang CoverageMappingGen.cpp to conditionally add toggle this new mode in __llvm_profile_raw_version variable, rustc needs to do similar change at frontend in order to use this with code coverage.

The problem I ran into is chromium unittests have rust code. When I tried this mode for base_unittests, the Rust binaries are not able to use this mode while the C/C++ binaries uses it. So, the generated raw profiles are mixture of Rust raw profiles (counters + metadata sections) + C/C++ raw profiles (counters). llvm-profdata is currently not able to handle this.
My plan is to fix this in llvm-profdata later to allow merging with mixture raw profiles.

I'm not sure if we can pass -mllvm flag to rustc.

…s` (or `.lprfcovdata` and `.lprfcovnames` on COFF) under binary correlation mode.

The reason is that we don't want to rely on the bit in llvm profile version variable to indicate name/data sections are empty or not: llvm#71996. And simply making __llvm_prf_{data}/{names} sections not allocated in ELF does not make `&__stop___llvm_prf_data - &__start___llvm_prf_data == 0`. It still returns the size of the non-allocated sections. So, using different section names eliminate the need to perform runtime check for data/name section size.

With that, there is no need to have VARIANT_MASK_BIN_CORRELATE bit. Clang side codegen changes are not longer necessary.
Copy link
Contributor Author

@ZequanWu ZequanWu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"binary" is ambiguous. I wonder whether object file correlation is better. llvm-symbolizer has an option --obj=xxx.

llvm-symbolizer's --obj could take an pre-linking object file. But here we need to take post-linked binary for merging.

clang/lib/CodeGen/CoverageMappingGen.cpp Outdated Show resolved Hide resolved
clang/test/CodeGen/coverage-profile-raw-version.c Outdated Show resolved Hide resolved
compiler-rt/test/profile/instrprof-binary-correlate.c Outdated Show resolved Hide resolved
llvm/docs/CommandGuide/llvm-profdata.rst Outdated Show resolved Hide resolved
llvm/lib/ProfileData/InstrProfCorrelator.cpp Outdated Show resolved Hide resolved
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp Outdated Show resolved Hide resolved
llvm/tools/llvm-profdata/llvm-profdata.cpp Outdated Show resolved Hide resolved
llvm/tools/llvm-profdata/llvm-profdata.cpp Outdated Show resolved Hide resolved
@ZequanWu ZequanWu changed the title [Profile] Add binary profile correlation to offload profile metadata at runtime. [Profile] Add binary profile correlation for code coverage. Nov 15, 2023
@ZequanWu
Copy link
Contributor Author

Some further discussion/pre-work needed before proceeding with this PR.

These two discussions are addressed and this is ready to be reviewed.

  1. Support for merging with multiple correlation files will be done in a separate change.
  2. Removed the VARIANT_MASK_BIN_CORRELATE and runtime check for it to determine if name/data sections should be skipped. Instead, new section names are used (__llvm_covdata and __llvm_covnames).

@ZequanWu
Copy link
Contributor Author

Ping.

@@ -702,6 +708,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
#define INSTR_PROF_COVMAP_COMMON __llvm_covmap
#define INSTR_PROF_COVFUN_COMMON __llvm_covfun
#define INSTR_PROF_ORDERFILE_COMMON __llvm_orderfile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just a nit, but could you move orderfile here and elsewhere to the bottom so that all __llvm_cov* entries are next to each other for easier readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@petrhosek
Copy link
Member

Can you break up all the changes to tests that replace -debug-info-correlate with --profile-correlate=debug-info into a separate PR to reduce the size of this PR?

…reverted changes in tests that use debug info correlate
@ZequanWu
Copy link
Contributor Author

ZequanWu commented Dec 5, 2023

Can you break up all the changes to tests that replace -debug-info-correlate with --profile-correlate=debug-info into a separate PR to reduce the size of this PR?

Done.

@rnk
Copy link
Collaborator

rnk commented Dec 11, 2023

@david-xl , Zequan posted an RFC for this. Is there a PGO tag, or something we can use to increase visibility for PGO reviewers? I think most of the complexity for this new mode is in the PGO code, so I think the best person to review it would be someone with an interest in PGO.

I'll tag some folks, but let me know if there is a better way: @kparzysz @snehasish

@david-xl
Copy link
Contributor

@david-xl , Zequan posted an RFC for this. Is there a PGO tag, or something we can use to increase visibility for PGO reviewers? I think most of the complexity for this new mode is in the PGO code, so I think the best person to review it would be someone with an interest in PGO.

I'll tag some folks, but let me know if there is a better way: @kparzysz @snehasish

I am aware of this patch and it mostly look good to me. Since there is a long list of reviewers attached to this PR, better give more time for them to chime in. I am quite busy early part of this week, but will try to give it another round by the end of the week if no one else beats me to it.

@MaskRay
Copy link
Member

MaskRay commented Dec 12, 2023

We have this team: @llvm/pr-subscribers-pgo

Copy link
Contributor

@david-xl david-xl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the new feature. (Wait a few days in case other reviewers have additional comments).

@@ -1829,6 +1833,22 @@ void CoverageMappingModuleGen::emit() {
llvm::GlobalValue::InternalLinkage, NamesArrVal,
llvm::getCoverageUnusedNamesVarName());
}
const StringRef VarName(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some comments for this segment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already reverted changes in Clang because VARIANT_MASK_BIN_CORRELATE flag is no longer necessary: #69493 (comment)

llvm::Type *IntTy64 = llvm::Type::getInt64Ty(Ctx);
uint64_t ProfileVersion = INSTR_PROF_RAW_VERSION;
if (llvm::ProfileCorrelate == llvm::InstrProfCorrelator::BINARY)
ProfileVersion |= VARIANT_MASK_BIN_CORRELATE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might overwrite other modifier bits set else where.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -mllvm -profile-correlate=binary -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -o - %s | FileCheck %s --check-prefix=BIN-CORRELATE

// CHECK: @__llvm_profile_raw_version = {{.*}} i64 9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it 9?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@ZequanWu ZequanWu merged commit ab3430f into llvm:main Dec 14, 2023
3 of 5 checks passed
@ZequanWu ZequanWu deleted the binary-correlate branch December 14, 2023 19:17
@ilovepi
Copy link
Contributor

ilovepi commented Dec 14, 2023

I think our Linux CI is seeing failures related to this patch:
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-arm64/b8761705440671462977/overview

Profile-aarch64 :: instrprof-binary-correlate.c is failing on that bot for both x86_64 and arm64.

@ilovepi
Copy link
Contributor

ilovepi commented Dec 14, 2023

Test output:

******************** TEST 'Profile-aarch64 :: instrprof-binary-correlate.c' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
Binary files /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata and /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profdata differ

--
Command Output (stderr):
--
RUN: at line 3: /b/s/w/ir/x/w/llvm_build/./bin/clang    -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   -ldl -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal -fprofile-instr-generate -fcoverage-mapping /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-main.cpp /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-foo.cpp
+ /b/s/w/ir/x/w/llvm_build/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -ldl -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal -fprofile-instr-generate -fcoverage-mapping /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-main.cpp /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-foo.cpp
RUN: at line 4: env LLVM_PROFILE_FILE=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.profraw  /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal
+ env LLVM_PROFILE_FILE=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.profraw /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal
RUN: at line 5: llvm-profdata merge -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.profraw
+ llvm-profdata merge -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.profraw
RUN: at line 6: llvm-cov report --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal > /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.report
+ llvm-cov report --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal
RUN: at line 7: llvm-cov show --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal > /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.show
+ llvm-cov show --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal
RUN: at line 10: /b/s/w/ir/x/w/llvm_build/./bin/clang    -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   -ldl -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.exe -fprofile-instr-generate -fcoverage-mapping -mllvm -profile-correlate=binary /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-main.cpp /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-foo.cpp
+ /b/s/w/ir/x/w/llvm_build/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -ldl -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.exe -fprofile-instr-generate -fcoverage-mapping -mllvm -profile-correlate=binary /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-main.cpp /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-foo.cpp
RUN: at line 11: env LLVM_PROFILE_FILE=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profraw  /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.exe
+ env LLVM_PROFILE_FILE=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profraw /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.exe
RUN: at line 12: llvm-profdata merge -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profdata --binary-file=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.exe /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profraw
+ llvm-profdata merge -o /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profdata --binary-file=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.exe /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profraw
RUN: at line 13: llvm-cov report --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.exe > /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.report
+ llvm-cov report --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.exe
RUN: at line 14: llvm-cov show --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.exe > /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.show
+ llvm-cov show --instr-profile=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.exe
RUN: at line 15: diff /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profdata
+ diff /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp.normal.profdata /b/s/w/ir/x/w/llvm_build/runtimes/runtimes-aarch64-unknown-linux-gnu-bins/compiler-rt/test/profile/Profile-aarch64/Output/instrprof-binary-correlate.c.tmp-1.profdata

--

********************

Log: https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8761705440671462977/+/u/clang/test/stdout

@ilovepi
Copy link
Contributor

ilovepi commented Dec 14, 2023

Seems like a mismatch on the diff, so maybe the check is too stringent.

If this will take a while to fix, would you mind reverting until it can be addressed?

@ZequanWu
Copy link
Contributor Author

Seems like a mismatch on the diff, so maybe the check is too stringent.

If this will take a while to fix, would you mind reverting until it can be addressed?

It passed for me locally on x64. Maybe I should use diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.d4.profdata) like it does on debug-info correlate test:

// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.d4.profdata)

Sent a possible fix at: f343253, hope that fixes it.

@ilovepi
Copy link
Contributor

ilovepi commented Dec 14, 2023

Our next cI run should finish in about 25 minutes, so we'll find out soon. https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8761696932167687409/overview

@ilovepi
Copy link
Contributor

ilovepi commented Dec 14, 2023

Well, seems like someone broke ToT w/ a compiler error. I'll let you know if the forward fix fails to address the issue.

@ZequanWu
Copy link
Contributor Author

Well, seems like someone broke ToT w/ a compiler error. I'll let you know if the forward fix fails to address the issue.

The latest build passed: https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8761696377585255057/overview.

@ilovepi
Copy link
Contributor

ilovepi commented Dec 14, 2023

Indeed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen clang Clang issues not falling into any other category compiler-rt llvm:binary-utilities llvm:transforms PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants