Skip to content

Commit 9b6b6bb

Browse files
committed
Revert "[Profile] Allow online merging with debug info correlation."
This reverts commit cf2cf19. This breaks merging profiles when nothing is instrumented, see comments in https://reviews.llvm.org/D157632. This also reverts follow-up commit bfc965c.
1 parent 4a35655 commit 9b6b6bb

File tree

5 files changed

+18
-67
lines changed

5 files changed

+18
-67
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ namespace {
102102

103103
// Default filename used for profile generation.
104104
std::string getDefaultProfileGenName() {
105-
return DebugInfoCorrelate ? "default_%m.proflite" : "default_%m.profraw";
105+
return DebugInfoCorrelate ? "default_%p.proflite" : "default_%m.profraw";
106106
}
107107

108108
class EmitAssemblyHelper {

compiler-rt/lib/profile/InstrProfilingMerge.c

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ uint64_t lprofGetLoadModuleSignature(void) {
4747
COMPILER_RT_VISIBILITY
4848
int __llvm_profile_check_compatibility(const char *ProfileData,
4949
uint64_t ProfileSize) {
50+
/* Check profile header only for now */
5051
__llvm_profile_header *Header = (__llvm_profile_header *)ProfileData;
5152
__llvm_profile_data *SrcDataStart, *SrcDataEnd, *SrcData, *DstData;
5253
SrcDataStart =
@@ -101,6 +102,13 @@ static uintptr_t signextIfWin64(void *V) {
101102
COMPILER_RT_VISIBILITY
102103
int __llvm_profile_merge_from_buffer(const char *ProfileData,
103104
uint64_t ProfileSize) {
105+
if (__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) {
106+
PROF_ERR(
107+
"%s\n",
108+
"Debug info correlation does not support profile merging at runtime. "
109+
"Instead, merge raw profiles using the llvm-profdata tool.");
110+
return 1;
111+
}
104112
if (__llvm_profile_get_version() & VARIANT_MASK_TEMPORAL_PROF) {
105113
PROF_ERR("%s\n",
106114
"Temporal profiles do not support profile merging at runtime. "
@@ -110,8 +118,7 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
110118

111119
__llvm_profile_data *SrcDataStart, *SrcDataEnd, *SrcData, *DstData;
112120
__llvm_profile_header *Header = (__llvm_profile_header *)ProfileData;
113-
char *SrcCountersStart, *DstCounter;
114-
const char *SrcCountersEnd, *SrcCounter;
121+
char *SrcCountersStart;
115122
const char *SrcNameStart;
116123
const char *SrcValueProfDataStart, *SrcValueProfData;
117124
uintptr_t CountersDelta = Header->CountersDelta;
@@ -121,36 +128,14 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
121128
Header->BinaryIdsSize);
122129
SrcDataEnd = SrcDataStart + Header->NumData;
123130
SrcCountersStart = (char *)SrcDataEnd;
124-
SrcCountersEnd = SrcCountersStart +
125-
Header->NumCounters * __llvm_profile_counter_entry_size();
126-
SrcNameStart = SrcCountersEnd;
131+
SrcNameStart = SrcCountersStart +
132+
Header->NumCounters * __llvm_profile_counter_entry_size();
127133
SrcValueProfDataStart =
128134
SrcNameStart + Header->NamesSize +
129135
__llvm_profile_get_num_padding_bytes(Header->NamesSize);
130136
if (SrcNameStart < SrcCountersStart)
131137
return 1;
132138

133-
// Merge counters when there is no data section and debug info correlation is
134-
// enabled.
135-
if (Header->NumData == 0) {
136-
if (!(__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE)) {
137-
PROF_ERR("%s\n", "Missing profile data section.");
138-
return 1;
139-
}
140-
for (SrcCounter = SrcCountersStart,
141-
DstCounter = __llvm_profile_begin_counters();
142-
SrcCounter < SrcCountersEnd;) {
143-
if (__llvm_profile_get_version() & VARIANT_MASK_BYTE_COVERAGE) {
144-
*DstCounter &= *SrcCounter;
145-
} else {
146-
*(uint64_t *)DstCounter += *(uint64_t *)SrcCounter;
147-
}
148-
SrcCounter += __llvm_profile_counter_entry_size();
149-
DstCounter += __llvm_profile_counter_entry_size();
150-
}
151-
return 0;
152-
}
153-
154139
for (SrcData = SrcDataStart,
155140
DstData = (__llvm_profile_data *)__llvm_profile_begin_data(),
156141
SrcValueProfData = SrcValueProfDataStart;

compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,3 @@
1818
// RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.cov.profraw
1919

2020
// RUN: diff <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)
21-
22-
// Test debug info correlate with online merging.
23-
24-
// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal
25-
// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal
26-
// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw
27-
28-
// RUN: rm -rf %t.profdir && mkdir %t.profdir
29-
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
30-
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
31-
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.profdir/
32-
33-
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata)
34-
35-
// RUN: rm -rf %t.profdir && mkdir %t.profdir
36-
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
37-
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
38-
// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov.dSYM %t.profdir/
39-
40-
// RUN: diff <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)

compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,3 @@
2424
// RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.cov.profraw
2525

2626
// RUN: diff <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)
27-
28-
// Test debug info correlate with online merging.
29-
30-
// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal
31-
// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal
32-
// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw
33-
34-
// RUN: rm -rf %t.profdir && mkdir %t.profdir
35-
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
36-
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
37-
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.profdir/
38-
39-
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata)
40-
41-
// RUN: rm -rf %t.profdir && mkdir %t.profdir
42-
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
43-
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
44-
// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov %t.profdir/
45-
46-
// RUN: diff <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// RUN: rm -rf %t; mkdir %t
22

3+
// RUN: %clang_pgogen -o %t/dbg -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %s
4+
// RUN: env LLVM_PROFILE_FILE=%t/dbg_%m.profdata %run %t/dbg 2>&1 | count 0
5+
// RUN: env LLVM_PROFILE_FILE=%t/dbg_%m.profdata %run %t/dbg 2>&1 | FileCheck %s --check-prefix=DBG
6+
7+
// DBG: Debug info correlation does not support profile merging at runtime.
8+
39
// RUN: %clang_pgogen -o %t/timeprof -mllvm -pgo-temporal-instrumentation %s
410
// RUN: env LLVM_PROFILE_FILE=%t/timeprof_%m.profdata %run %t/timeprof 2>&1 | count 0
511
// RUN: env LLVM_PROFILE_FILE=%t/timeprof_%m.profdata %run %t/timeprof 2>&1 | FileCheck %s --check-prefix=TIMEPROF

0 commit comments

Comments
 (0)