[clang] 9b6b6bb - Revert "[Profile] Allow online merging with debug info correlation."

Arthur Eubanks via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 22 14:35:29 PDT 2023


Author: Arthur Eubanks
Date: 2023-08-22T14:34:46-07:00
New Revision: 9b6b6bbc9127d604881cdc9dcea0e7c74ef821fd

URL: https://github.com/llvm/llvm-project/commit/9b6b6bbc9127d604881cdc9dcea0e7c74ef821fd
DIFF: https://github.com/llvm/llvm-project/commit/9b6b6bbc9127d604881cdc9dcea0e7c74ef821fd.diff

LOG: Revert "[Profile] Allow online merging with debug info correlation."

This reverts commit cf2cf195d5fb0a07c122c5c274bd6deb0790e015.
This breaks merging profiles when nothing is instrumented, see comments in https://reviews.llvm.org/D157632.

This also reverts follow-up commit bfc965c54fdbfe33a0785b45903b53fc11165f13.

Added: 
    

Modified: 
    clang/lib/CodeGen/BackendUtil.cpp
    compiler-rt/lib/profile/InstrProfilingMerge.c
    compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
    compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
    compiler-rt/test/profile/instrprof-merge-error.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 3e8b2b78a3928b..373d38672284d6 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -102,7 +102,7 @@ namespace {
 
 // Default filename used for profile generation.
 std::string getDefaultProfileGenName() {
-  return DebugInfoCorrelate ? "default_%m.proflite" : "default_%m.profraw";
+  return DebugInfoCorrelate ? "default_%p.proflite" : "default_%m.profraw";
 }
 
 class EmitAssemblyHelper {

diff  --git a/compiler-rt/lib/profile/InstrProfilingMerge.c b/compiler-rt/lib/profile/InstrProfilingMerge.c
index fdf7bd0c157ae2..241891da454bb4 100644
--- a/compiler-rt/lib/profile/InstrProfilingMerge.c
+++ b/compiler-rt/lib/profile/InstrProfilingMerge.c
@@ -47,6 +47,7 @@ uint64_t lprofGetLoadModuleSignature(void) {
 COMPILER_RT_VISIBILITY
 int __llvm_profile_check_compatibility(const char *ProfileData,
                                        uint64_t ProfileSize) {
+  /* Check profile header only for now  */
   __llvm_profile_header *Header = (__llvm_profile_header *)ProfileData;
   __llvm_profile_data *SrcDataStart, *SrcDataEnd, *SrcData, *DstData;
   SrcDataStart =
@@ -101,6 +102,13 @@ static uintptr_t signextIfWin64(void *V) {
 COMPILER_RT_VISIBILITY
 int __llvm_profile_merge_from_buffer(const char *ProfileData,
                                      uint64_t ProfileSize) {
+  if (__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) {
+    PROF_ERR(
+        "%s\n",
+        "Debug info correlation does not support profile merging at runtime. "
+        "Instead, merge raw profiles using the llvm-profdata tool.");
+    return 1;
+  }
   if (__llvm_profile_get_version() & VARIANT_MASK_TEMPORAL_PROF) {
     PROF_ERR("%s\n",
              "Temporal profiles do not support profile merging at runtime. "
@@ -110,8 +118,7 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
 
   __llvm_profile_data *SrcDataStart, *SrcDataEnd, *SrcData, *DstData;
   __llvm_profile_header *Header = (__llvm_profile_header *)ProfileData;
-  char *SrcCountersStart, *DstCounter;
-  const char *SrcCountersEnd, *SrcCounter;
+  char *SrcCountersStart;
   const char *SrcNameStart;
   const char *SrcValueProfDataStart, *SrcValueProfData;
   uintptr_t CountersDelta = Header->CountersDelta;
@@ -121,36 +128,14 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
                               Header->BinaryIdsSize);
   SrcDataEnd = SrcDataStart + Header->NumData;
   SrcCountersStart = (char *)SrcDataEnd;
-  SrcCountersEnd = SrcCountersStart +
-                   Header->NumCounters * __llvm_profile_counter_entry_size();
-  SrcNameStart = SrcCountersEnd;
+  SrcNameStart = SrcCountersStart +
+                 Header->NumCounters * __llvm_profile_counter_entry_size();
   SrcValueProfDataStart =
       SrcNameStart + Header->NamesSize +
       __llvm_profile_get_num_padding_bytes(Header->NamesSize);
   if (SrcNameStart < SrcCountersStart)
     return 1;
 
-  // Merge counters when there is no data section and debug info correlation is
-  // enabled.
-  if (Header->NumData == 0) {
-    if (!(__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE)) {
-      PROF_ERR("%s\n", "Missing profile data section.");
-      return 1;
-    }
-    for (SrcCounter = SrcCountersStart,
-        DstCounter = __llvm_profile_begin_counters();
-         SrcCounter < SrcCountersEnd;) {
-      if (__llvm_profile_get_version() & VARIANT_MASK_BYTE_COVERAGE) {
-        *DstCounter &= *SrcCounter;
-      } else {
-        *(uint64_t *)DstCounter += *(uint64_t *)SrcCounter;
-      }
-      SrcCounter += __llvm_profile_counter_entry_size();
-      DstCounter += __llvm_profile_counter_entry_size();
-    }
-    return 0;
-  }
-
   for (SrcData = SrcDataStart,
       DstData = (__llvm_profile_data *)__llvm_profile_begin_data(),
       SrcValueProfData = SrcValueProfDataStart;

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 f347d439e2e067..325e27503f3530 100644
--- a/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
+++ b/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
@@ -18,23 +18,3 @@
 // RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.cov.profraw
 
 // RUN: 
diff  <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)
-
-// Test debug info correlate with online merging.
-
-// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal
-// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal
-// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw
-
-// RUN: rm -rf %t.profdir && mkdir %t.profdir
-// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
-// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
-// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.profdir/
-
-// RUN: 
diff  <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata)
-
-// RUN: rm -rf %t.profdir && mkdir %t.profdir
-// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
-// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
-// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov.dSYM %t.profdir/
-
-// RUN: 
diff  <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)

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 a918d7b6299005..259592598efe45 100644
--- a/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
+++ b/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
@@ -24,23 +24,3 @@
 // RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.cov.profraw
 
 // RUN: 
diff  <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)
-
-// Test debug info correlate with online merging.
-
-// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal
-// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal
-// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw
-
-// RUN: rm -rf %t.profdir && mkdir %t.profdir
-// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
-// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
-// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.profdir/
-
-// RUN: 
diff  <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata)
-
-// RUN: rm -rf %t.profdir && mkdir %t.profdir
-// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
-// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
-// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov %t.profdir/
-
-// RUN: 
diff  <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)

diff  --git a/compiler-rt/test/profile/instrprof-merge-error.c b/compiler-rt/test/profile/instrprof-merge-error.c
index 4bd60d514c08b9..8039b4cfa08293 100644
--- a/compiler-rt/test/profile/instrprof-merge-error.c
+++ b/compiler-rt/test/profile/instrprof-merge-error.c
@@ -1,5 +1,11 @@
 // RUN: rm -rf %t; mkdir %t
 
+// RUN: %clang_pgogen -o %t/dbg -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %s
+// RUN: env LLVM_PROFILE_FILE=%t/dbg_%m.profdata %run %t/dbg 2>&1 | count 0
+// RUN: env LLVM_PROFILE_FILE=%t/dbg_%m.profdata %run %t/dbg 2>&1 | FileCheck %s --check-prefix=DBG
+
+// DBG: Debug info correlation does not support profile merging at runtime.
+
 // RUN: %clang_pgogen -o %t/timeprof -mllvm -pgo-temporal-instrumentation %s
 // RUN: env LLVM_PROFILE_FILE=%t/timeprof_%m.profdata %run %t/timeprof 2>&1 | count 0
 // RUN: env LLVM_PROFILE_FILE=%t/timeprof_%m.profdata %run %t/timeprof 2>&1 | FileCheck %s --check-prefix=TIMEPROF


        


More information about the cfe-commits mailing list