@@ -33,6 +33,10 @@ COMPILER_RT_VISIBILITY void __llvm_profile_enable_continuous_mode(void) {
33
33
ContinuouslySyncProfile = 1 ;
34
34
}
35
35
36
+ COMPILER_RT_VISIBILITY void __llvm_profile_disable_continuous_mode (void ) {
37
+ ContinuouslySyncProfile = 0 ;
38
+ }
39
+
36
40
COMPILER_RT_VISIBILITY void __llvm_profile_set_page_size (unsigned PS ) {
37
41
PageSize = PS ;
38
42
}
@@ -43,11 +47,14 @@ uint64_t __llvm_profile_get_size_for_buffer(void) {
43
47
const __llvm_profile_data * DataEnd = __llvm_profile_end_data ();
44
48
const char * CountersBegin = __llvm_profile_begin_counters ();
45
49
const char * CountersEnd = __llvm_profile_end_counters ();
50
+ const char * BitmapBegin = __llvm_profile_begin_bitmap ();
51
+ const char * BitmapEnd = __llvm_profile_end_bitmap ();
46
52
const char * NamesBegin = __llvm_profile_begin_names ();
47
53
const char * NamesEnd = __llvm_profile_end_names ();
48
54
49
55
return __llvm_profile_get_size_for_buffer_internal (
50
- DataBegin , DataEnd , CountersBegin , CountersEnd , NamesBegin , NamesEnd );
56
+ DataBegin , DataEnd , CountersBegin , CountersEnd , BitmapBegin , BitmapEnd ,
57
+ NamesBegin , NamesEnd );
51
58
}
52
59
53
60
COMPILER_RT_VISIBILITY
@@ -83,6 +90,17 @@ uint64_t __llvm_profile_get_counters_size(const char *Begin, const char *End) {
83
90
__llvm_profile_counter_entry_size ();
84
91
}
85
92
93
+ COMPILER_RT_VISIBILITY
94
+ uint64_t __llvm_profile_get_num_bitmap_bytes (const char * Begin ,
95
+ const char * End ) {
96
+ return (End - Begin );
97
+ }
98
+
99
+ COMPILER_RT_VISIBILITY
100
+ uint64_t __llvm_profile_get_name_size (const char * Begin , const char * End ) {
101
+ return End - Begin ;
102
+ }
103
+
86
104
/// Calculate the number of padding bytes needed to add to \p Offset in order
87
105
/// for (\p Offset + Padding) to be page-aligned.
88
106
static uint64_t calculateBytesNeededToPageAlign (uint64_t Offset ) {
@@ -102,12 +120,16 @@ static int needsCounterPadding(void) {
102
120
103
121
COMPILER_RT_VISIBILITY
104
122
void __llvm_profile_get_padding_sizes_for_counters (
105
- uint64_t DataSize , uint64_t CountersSize , uint64_t NamesSize ,
106
- uint64_t * PaddingBytesBeforeCounters , uint64_t * PaddingBytesAfterCounters ,
123
+ uint64_t DataSize , uint64_t CountersSize , uint64_t NumBitmapBytes ,
124
+ uint64_t NamesSize , uint64_t * PaddingBytesBeforeCounters ,
125
+ uint64_t * PaddingBytesAfterCounters , uint64_t * PaddingBytesAfterBitmapBytes ,
107
126
uint64_t * PaddingBytesAfterNames ) {
108
127
if (!needsCounterPadding ()) {
109
128
* PaddingBytesBeforeCounters = 0 ;
110
- * PaddingBytesAfterCounters = 0 ;
129
+ * PaddingBytesAfterCounters =
130
+ __llvm_profile_get_num_padding_bytes (CountersSize );
131
+ * PaddingBytesAfterBitmapBytes =
132
+ __llvm_profile_get_num_padding_bytes (NumBitmapBytes );
111
133
* PaddingBytesAfterNames = __llvm_profile_get_num_padding_bytes (NamesSize );
112
134
return ;
113
135
}
@@ -117,31 +139,37 @@ void __llvm_profile_get_padding_sizes_for_counters(
117
139
* PaddingBytesBeforeCounters =
118
140
calculateBytesNeededToPageAlign (sizeof (__llvm_profile_header ) + DataSize );
119
141
* PaddingBytesAfterCounters = calculateBytesNeededToPageAlign (CountersSize );
142
+ * PaddingBytesAfterBitmapBytes =
143
+ calculateBytesNeededToPageAlign (NumBitmapBytes );
120
144
* PaddingBytesAfterNames = calculateBytesNeededToPageAlign (NamesSize );
121
145
}
122
146
123
147
COMPILER_RT_VISIBILITY
124
148
uint64_t __llvm_profile_get_size_for_buffer_internal (
125
149
const __llvm_profile_data * DataBegin , const __llvm_profile_data * DataEnd ,
126
- const char * CountersBegin , const char * CountersEnd , const char * NamesBegin ,
127
- const char * NamesEnd ) {
150
+ const char * CountersBegin , const char * CountersEnd , const char * BitmapBegin ,
151
+ const char * BitmapEnd , const char * NamesBegin , const char * NamesEnd ) {
128
152
/* Match logic in __llvm_profile_write_buffer(). */
129
153
const uint64_t NamesSize = (NamesEnd - NamesBegin ) * sizeof (char );
130
154
uint64_t DataSize = __llvm_profile_get_data_size (DataBegin , DataEnd );
131
155
uint64_t CountersSize =
132
156
__llvm_profile_get_counters_size (CountersBegin , CountersEnd );
157
+ const uint64_t NumBitmapBytes =
158
+ __llvm_profile_get_num_bitmap_bytes (BitmapBegin , BitmapEnd );
133
159
134
160
/* Determine how much padding is needed before/after the counters and after
135
161
* the names. */
136
162
uint64_t PaddingBytesBeforeCounters , PaddingBytesAfterCounters ,
137
- PaddingBytesAfterNames ;
163
+ PaddingBytesAfterNames , PaddingBytesAfterBitmapBytes ;
138
164
__llvm_profile_get_padding_sizes_for_counters (
139
- DataSize , CountersSize , NamesSize , & PaddingBytesBeforeCounters ,
140
- & PaddingBytesAfterCounters , & PaddingBytesAfterNames );
165
+ DataSize , CountersSize , NumBitmapBytes , NamesSize ,
166
+ & PaddingBytesBeforeCounters , & PaddingBytesAfterCounters ,
167
+ & PaddingBytesAfterBitmapBytes , & PaddingBytesAfterNames );
141
168
142
169
return sizeof (__llvm_profile_header ) + __llvm_write_binary_ids (NULL ) +
143
170
DataSize + PaddingBytesBeforeCounters + CountersSize +
144
- PaddingBytesAfterCounters + NamesSize + PaddingBytesAfterNames ;
171
+ PaddingBytesAfterCounters + NumBitmapBytes +
172
+ PaddingBytesAfterBitmapBytes + NamesSize + PaddingBytesAfterNames ;
145
173
}
146
174
147
175
COMPILER_RT_VISIBILITY
@@ -159,9 +187,11 @@ COMPILER_RT_VISIBILITY int __llvm_profile_write_buffer(char *Buffer) {
159
187
COMPILER_RT_VISIBILITY int __llvm_profile_write_buffer_internal (
160
188
char * Buffer , const __llvm_profile_data * DataBegin ,
161
189
const __llvm_profile_data * DataEnd , const char * CountersBegin ,
162
- const char * CountersEnd , const char * NamesBegin , const char * NamesEnd ) {
190
+ const char * CountersEnd , const char * BitmapBegin , const char * BitmapEnd ,
191
+ const char * NamesBegin , const char * NamesEnd ) {
163
192
ProfDataWriter BufferWriter ;
164
193
initBufferWriter (& BufferWriter , Buffer );
165
194
return lprofWriteDataImpl (& BufferWriter , DataBegin , DataEnd , CountersBegin ,
166
- CountersEnd , 0 , NamesBegin , NamesEnd , 0 );
195
+ CountersEnd , BitmapBegin , BitmapEnd , 0 , NamesBegin ,
196
+ NamesEnd , 0 );
167
197
}
0 commit comments