[compiler-rt] 8287db2 - [InstrProf] Report error when merging temporal profiles

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 08:40:36 PDT 2023


Author: Ellis Hoag
Date: 2023-08-11T08:40:31-07:00
New Revision: 8287db22beb2ae3b436f80d646802ddcc261d476

URL: https://github.com/llvm/llvm-project/commit/8287db22beb2ae3b436f80d646802ddcc261d476
DIFF: https://github.com/llvm/llvm-project/commit/8287db22beb2ae3b436f80d646802ddcc261d476.diff

LOG: [InstrProf] Report error when merging temporal profiles

Temporal profiles do not support profile merging at runtime. The reason
is that each function can only store one timestamp and the
`llmv-profdata` tool is responsible for sampling traces during the merge
command. Report an error in `__llvm_profile_merge_from_buffer()` if
merging a temporal profile.

The added test also checks that lightweight profiles throw an error,
although this may be fixed in https://reviews.llvm.org/D157632

Reviewed By: MaskRay, zequanwu

Differential Revision: https://reviews.llvm.org/D157664

Added: 
    compiler-rt/test/profile/instrprof-merge-error.c

Modified: 
    compiler-rt/lib/profile/InstrProfilingMerge.c

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/profile/InstrProfilingMerge.c b/compiler-rt/lib/profile/InstrProfilingMerge.c
index 432e824955f8a7..9e72b9e4f88537 100644
--- a/compiler-rt/lib/profile/InstrProfilingMerge.c
+++ b/compiler-rt/lib/profile/InstrProfilingMerge.c
@@ -109,6 +109,12 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
         "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. "
+             "Instead, merge raw profiles using the llvm-profdata tool.");
+    return 1;
+  }
 
   __llvm_profile_data *SrcDataStart, *SrcDataEnd, *SrcData, *DstData;
   __llvm_profile_header *Header = (__llvm_profile_header *)ProfileData;

diff  --git a/compiler-rt/test/profile/instrprof-merge-error.c b/compiler-rt/test/profile/instrprof-merge-error.c
new file mode 100644
index 00000000000000..8039b4cfa08293
--- /dev/null
+++ b/compiler-rt/test/profile/instrprof-merge-error.c
@@ -0,0 +1,15 @@
+// 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
+
+// TIMEPROF: Temporal profiles do not support profile merging at runtime.
+
+int main() { return 0; }


        


More information about the llvm-commits mailing list