Skip to content

Commit 6d076b0

Browse files
mingmingl-llvmmodiking
authored andcommitted
Reland "[TypeProf][InstrPGO] Introduce raw and instr profile format change for type profiling." (#82711)
New change on top of [reviewed patch](llvm/llvm-project#81691) are [in commits after this one](llvm/llvm-project@d0757f4). Previous commits are restored from the remote branch with timestamps. 1. Fix build breakage for non-ELF platforms, by defining the missing functions {`__llvm_profile_begin_vtables`, `__llvm_profile_end_vtables`, `__llvm_profile_begin_vtabnames `, `__llvm_profile_end_vtabnames`} everywhere. * Tested on mac laptop (for darwins) and Windows. Specifically, functions in `InstrProfilingPlatformWindows.c` returns `NULL` to make it more explicit that type prof isn't supported; see comments for the reason. * For the rest (AIX, other), mostly follow existing examples (like this [one](llvm/llvm-project@f95b2f1)) 2. Rename `__llvm_prf_vtabnames` -> `__llvm_prf_vns` for shorter section name, and make returned pointers [const](llvm/llvm-project@a825d2a#diff-4de780ce726d76b7abc9d3353aef95013e7b21e7bda01be8940cc6574fb0b5ffR120-R121) **Original Description** * Raw profile format - Header: records the byte size of compressed vtable names, and the number of profiled vtable entries (call it `VTableProfData`). Header also records padded bytes of each section. - Payload: adds a section for compressed vtable names, and a section to store `VTableProfData`. Both sections are padded so the size is a multiple of 8. * Indexed profile format - Header: records the byte offset of compressed vtable names. - Payload: adds a section to store compressed vtable names. This section is used by `llvm-profdata` to show the list of vtables profiled for an instrumented site. [The originally reviewed patch](llvm/llvm-project#66825) will have profile reader/write change and llvm-profdata change. - To ensure this PR has all the necessary profile format change along with profile version bump, created a copy of the originally reviewed patch in llvm/llvm-project#80761. The copy doesn't have profile format change, but it has the set of tests which covers type profile generation, profile read and profile merge. Tests pass there. rfc in https://discourse.llvm.org/t/rfc-dynamic-type-profiling-and-optimizations-in-llvm/74600 --------- Co-authored-by: modiking <[email protected]>
1 parent a3e8d13 commit 6d076b0

37 files changed

+557
-103
lines changed

compiler-rt/include/profile/InstrProfData.inc

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,25 @@ INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NumBitmapBytes, \
9494
#undef INSTR_PROF_DATA
9595
/* INSTR_PROF_DATA end. */
9696

97+
/* For a virtual table object, record the name hash to associate profiled
98+
* addresses with global variables, and record {starting address, size in bytes}
99+
* to map the profiled virtual table (which usually have an offset from the
100+
* starting address) back to a virtual table object. */
101+
#ifndef INSTR_PROF_VTABLE_DATA
102+
#define INSTR_PROF_VTABLE_DATA(Type, LLVMType, Name, Initializer)
103+
#else
104+
#define INSTR_PROF_VTABLE_DATA_DEFINED
105+
#endif
106+
INSTR_PROF_VTABLE_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), \
107+
VTableNameHash, ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \
108+
IndexedInstrProf::ComputeHash(PGOVTableName)))
109+
INSTR_PROF_VTABLE_DATA(const IntPtrT, llvm::PointerType::getUnqual(Ctx), \
110+
VTablePointer, VTableAddr)
111+
INSTR_PROF_VTABLE_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), VTableSize, \
112+
ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \
113+
VTableSizeVal))
114+
#undef INSTR_PROF_VTABLE_DATA
115+
/* INSTR_PROF_VTABLE_DATA end. */
97116

98117
/* This is an internal data structure used by value profiler. It
99118
* is defined here to allow serialization code sharing by LLVM
@@ -143,6 +162,8 @@ INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta,
143162
INSTR_PROF_RAW_HEADER(uint64_t, BitmapDelta,
144163
(uintptr_t)BitmapBegin - (uintptr_t)DataBegin)
145164
INSTR_PROF_RAW_HEADER(uint64_t, NamesDelta, (uintptr_t)NamesBegin)
165+
INSTR_PROF_RAW_HEADER(uint64_t, NumVTables, NumVTables)
166+
INSTR_PROF_RAW_HEADER(uint64_t, VNamesSize, VNamesSize)
146167
INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last)
147168
#undef INSTR_PROF_RAW_HEADER
148169
/* INSTR_PROF_RAW_HEADER end */
@@ -184,13 +205,26 @@ VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx))
184205
VALUE_PROF_KIND(IPVK_IndirectCallTarget, 0, "indirect call target")
185206
/* For memory intrinsic functions size profiling. */
186207
VALUE_PROF_KIND(IPVK_MemOPSize, 1, "memory intrinsic functions size")
208+
/* For virtual table address profiling, the address point of the virtual table
209+
* (i.e., the address contained in objects pointing to a virtual table) are
210+
* profiled. Note this may not be the address of the per C++ class virtual table
211+
* object (e.g., there might be an offset).
212+
*
213+
* The profiled addresses are stored in raw profile, together with the following
214+
* two types of information.
215+
* 1. The (starting and ending) addresses of per C++ class virtual table objects.
216+
* 2. The (compressed) virtual table object names.
217+
* RawInstrProfReader converts profiled virtual table addresses to virtual table
218+
* objects' MD5 hash.
219+
*/
220+
VALUE_PROF_KIND(IPVK_VTableTarget, 2, "The profiled address point of the vtable")
187221
/* These two kinds must be the last to be
188222
* declared. This is to make sure the string
189223
* array created with the template can be
190224
* indexed with the kind value.
191225
*/
192226
VALUE_PROF_KIND(IPVK_First, IPVK_IndirectCallTarget, "first")
193-
VALUE_PROF_KIND(IPVK_Last, IPVK_MemOPSize, "last")
227+
VALUE_PROF_KIND(IPVK_Last, IPVK_VTableTarget, "last")
194228

195229
#undef VALUE_PROF_KIND
196230
/* VALUE_PROF_KIND end */
@@ -280,12 +314,18 @@ INSTR_PROF_SECT_ENTRY(IPSK_bitmap, \
280314
INSTR_PROF_SECT_ENTRY(IPSK_name, \
281315
INSTR_PROF_QUOTE(INSTR_PROF_NAME_COMMON), \
282316
INSTR_PROF_NAME_COFF, "__DATA,")
317+
INSTR_PROF_SECT_ENTRY(IPSK_vname, \
318+
INSTR_PROF_QUOTE(INSTR_PROF_VNAME_COMMON), \
319+
INSTR_PROF_VNAME_COFF, "__DATA,")
283320
INSTR_PROF_SECT_ENTRY(IPSK_vals, \
284321
INSTR_PROF_QUOTE(INSTR_PROF_VALS_COMMON), \
285322
INSTR_PROF_VALS_COFF, "__DATA,")
286323
INSTR_PROF_SECT_ENTRY(IPSK_vnodes, \
287324
INSTR_PROF_QUOTE(INSTR_PROF_VNODES_COMMON), \
288325
INSTR_PROF_VNODES_COFF, "__DATA,")
326+
INSTR_PROF_SECT_ENTRY(IPSK_vtab, \
327+
INSTR_PROF_QUOTE(INSTR_PROF_VTAB_COMMON), \
328+
INSTR_PROF_VTAB_COFF, "__DATA,")
289329
INSTR_PROF_SECT_ENTRY(IPSK_covmap, \
290330
INSTR_PROF_QUOTE(INSTR_PROF_COVMAP_COMMON), \
291331
INSTR_PROF_COVMAP_COFF, "__LLVM_COV,")
@@ -661,9 +701,9 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
661701
(uint64_t)'f' << 16 | (uint64_t)'R' << 8 | (uint64_t)129
662702

663703
/* Raw profile format version (start from 1). */
664-
#define INSTR_PROF_RAW_VERSION 9
704+
#define INSTR_PROF_RAW_VERSION 10
665705
/* Indexed profile format version (start from 1). */
666-
#define INSTR_PROF_INDEX_VERSION 11
706+
#define INSTR_PROF_INDEX_VERSION 12
667707
/* Coverage mapping format version (start from 0). */
668708
#define INSTR_PROF_COVMAP_VERSION 6
669709

@@ -701,10 +741,12 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
701741
than WIN32 */
702742
#define INSTR_PROF_DATA_COMMON __llvm_prf_data
703743
#define INSTR_PROF_NAME_COMMON __llvm_prf_names
744+
#define INSTR_PROF_VNAME_COMMON __llvm_prf_vns
704745
#define INSTR_PROF_CNTS_COMMON __llvm_prf_cnts
705746
#define INSTR_PROF_BITS_COMMON __llvm_prf_bits
706747
#define INSTR_PROF_VALS_COMMON __llvm_prf_vals
707748
#define INSTR_PROF_VNODES_COMMON __llvm_prf_vnds
749+
#define INSTR_PROF_VTAB_COMMON __llvm_prf_vtab
708750
#define INSTR_PROF_COVMAP_COMMON __llvm_covmap
709751
#define INSTR_PROF_COVFUN_COMMON __llvm_covfun
710752
#define INSTR_PROF_COVDATA_COMMON __llvm_covdata
@@ -715,10 +757,12 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
715757
*/
716758
#define INSTR_PROF_DATA_COFF ".lprfd$M"
717759
#define INSTR_PROF_NAME_COFF ".lprfn$M"
760+
#define INSTR_PROF_VNAME_COFF ".lprfvn$M"
718761
#define INSTR_PROF_CNTS_COFF ".lprfc$M"
719762
#define INSTR_PROF_BITS_COFF ".lprfb$M"
720763
#define INSTR_PROF_VALS_COFF ".lprfv$M"
721764
#define INSTR_PROF_VNODES_COFF ".lprfnd$M"
765+
#define INSTR_PROF_VTAB_COFF ".lprfvt$M"
722766
#define INSTR_PROF_COVMAP_COFF ".lcovmap$M"
723767
#define INSTR_PROF_COVFUN_COFF ".lcovfun$M"
724768
/* Since cov data and cov names sections are not allocated, we don't need to
@@ -734,6 +778,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
734778
#define INSTR_PROF_NAME_SECT_NAME INSTR_PROF_NAME_COFF
735779
#define INSTR_PROF_CNTS_SECT_NAME INSTR_PROF_CNTS_COFF
736780
#define INSTR_PROF_BITS_SECT_NAME INSTR_PROF_BITS_COFF
781+
#define INSTR_PROF_VTAB_SECT_NAME INSTR_PROF_VTAB_COFF
782+
#define INSTR_PROF_VNAME_SECT_NAME INSTR_PROF_VNAME_COFF
737783
/* Array of pointers. Each pointer points to a list
738784
* of value nodes associated with one value site.
739785
*/
@@ -751,6 +797,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
751797
#define INSTR_PROF_NAME_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_NAME_COMMON)
752798
#define INSTR_PROF_CNTS_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_CNTS_COMMON)
753799
#define INSTR_PROF_BITS_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_BITS_COMMON)
800+
#define INSTR_PROF_VTAB_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_VTAB_COMMON)
801+
#define INSTR_PROF_VNAME_SECT_NAME INSTR_PROF_QUOTE(INSTR_PROF_VNAME_COMMON)
754802
/* Array of pointers. Each pointer points to a list
755803
* of value nodes associated with one value site.
756804
*/

compiler-rt/lib/profile/InstrProfiling.h

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ typedef struct ValueProfNode {
3838
#include "profile/InstrProfData.inc"
3939
} ValueProfNode;
4040

41+
typedef void *IntPtrT;
42+
typedef struct COMPILER_RT_ALIGNAS(INSTR_PROF_DATA_ALIGNMENT) VTableProfData {
43+
#define INSTR_PROF_VTABLE_DATA(Type, LLVMType, Name, Initializer) Type Name;
44+
#include "profile/InstrProfData.inc"
45+
} VTableProfData;
46+
4147
/*!
4248
* \brief Return 1 if profile counters are continuously synced to the raw
4349
* profile via an mmap(). This is in contrast to the default mode, in which
@@ -86,12 +92,16 @@ const __llvm_profile_data *__llvm_profile_begin_data(void);
8692
const __llvm_profile_data *__llvm_profile_end_data(void);
8793
const char *__llvm_profile_begin_names(void);
8894
const char *__llvm_profile_end_names(void);
95+
const char *__llvm_profile_begin_vtabnames(void);
96+
const char *__llvm_profile_end_vtabnames(void);
8997
char *__llvm_profile_begin_counters(void);
9098
char *__llvm_profile_end_counters(void);
9199
char *__llvm_profile_begin_bitmap(void);
92100
char *__llvm_profile_end_bitmap(void);
93101
ValueProfNode *__llvm_profile_begin_vnodes();
94102
ValueProfNode *__llvm_profile_end_vnodes();
103+
const VTableProfData *__llvm_profile_begin_vtables();
104+
const VTableProfData *__llvm_profile_end_vtables();
95105
uint32_t *__llvm_profile_begin_orderfile();
96106

97107
/*!
@@ -288,20 +298,31 @@ uint64_t __llvm_profile_get_num_bitmap_bytes(const char *Begin,
288298
/*! \brief Get the size of the profile name section in bytes. */
289299
uint64_t __llvm_profile_get_name_size(const char *Begin, const char *End);
290300

291-
/* ! \brief Given the sizes of the data and counter information, return the
292-
* number of padding bytes before and after the counters, and after the names,
293-
* in the raw profile.
301+
/*! \brief Get the number of virtual table profile data entries */
302+
uint64_t __llvm_profile_get_num_vtable(const VTableProfData *Begin,
303+
const VTableProfData *End);
304+
305+
/*! \brief Get the size of virtual table profile data in bytes. */
306+
uint64_t __llvm_profile_get_vtable_section_size(const VTableProfData *Begin,
307+
const VTableProfData *End);
308+
309+
/* ! \brief Given the sizes of the data and counter information, computes the
310+
* number of padding bytes before and after the counter section, as well as the
311+
* number of padding bytes after other setions in the raw profile.
312+
* Returns -1 upon errors and 0 upon success. Output parameters should be used
313+
* iff return value is 0.
294314
*
295315
* Note: When mmap() mode is disabled, no padding bytes before/after counters
296316
* are needed. However, in mmap() mode, the counter section in the raw profile
297317
* must be page-aligned: this API computes the number of padding bytes
298318
* needed to achieve that.
299319
*/
300-
void __llvm_profile_get_padding_sizes_for_counters(
320+
int __llvm_profile_get_padding_sizes_for_counters(
301321
uint64_t DataSize, uint64_t CountersSize, uint64_t NumBitmapBytes,
302-
uint64_t NamesSize, uint64_t *PaddingBytesBeforeCounters,
303-
uint64_t *PaddingBytesAfterCounters, uint64_t *PaddingBytesAfterBitmap,
304-
uint64_t *PaddingBytesAfterNames);
322+
uint64_t NamesSize, uint64_t VTableSize, uint64_t VNameSize,
323+
uint64_t *PaddingBytesBeforeCounters, uint64_t *PaddingBytesAfterCounters,
324+
uint64_t *PaddingBytesAfterBitmap, uint64_t *PaddingBytesAfterNames,
325+
uint64_t *PaddingBytesAfterVTable, uint64_t *PaddingBytesAfterVNames);
305326

306327
/*!
307328
* \brief Set the flag that profile data has been dumped to the file.

compiler-rt/lib/profile/InstrProfilingBuffer.c

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ uint64_t __llvm_profile_get_size_for_buffer(void) {
4747
const char *BitmapEnd = __llvm_profile_end_bitmap();
4848
const char *NamesBegin = __llvm_profile_begin_names();
4949
const char *NamesEnd = __llvm_profile_end_names();
50+
const VTableProfData *VTableBegin = __llvm_profile_begin_vtables();
51+
const VTableProfData *VTableEnd = __llvm_profile_end_vtables();
52+
const char *VNamesBegin = __llvm_profile_begin_vtabnames();
53+
const char *VNamesEnd = __llvm_profile_end_vtabnames();
5054

5155
return __llvm_profile_get_size_for_buffer_internal(
5256
DataBegin, DataEnd, CountersBegin, CountersEnd, BitmapBegin, BitmapEnd,
53-
NamesBegin, NamesEnd);
57+
NamesBegin, NamesEnd, VTableBegin, VTableEnd, VNamesBegin, VNamesEnd);
5458
}
5559

5660
COMPILER_RT_VISIBILITY
@@ -59,6 +63,15 @@ uint64_t __llvm_profile_get_num_data(const __llvm_profile_data *Begin,
5963
if (hasCorrelation())
6064
return 0;
6165
intptr_t BeginI = (intptr_t)Begin, EndI = (intptr_t)End;
66+
// `sizeof(__llvm_profile_data) - 1` is required in the numerator when
67+
// [Begin, End] represents an inclusive range.
68+
// For ELF, [Begin, End) represents the address of linker-inserted
69+
// symbols `__start__<elf-section>` and `__stop_<elf-section>`.
70+
// Thereby, `End` is one byte past the inclusive range, and
71+
// `sizeof(__llvm_profile_data) - 1` is not necessary in the numerator to get
72+
// the correct number of profile data.
73+
// FIXME: Consider removing `sizeof(__llvm_profile_data) - 1` if this is true
74+
// across platforms.
6275
return ((EndI + sizeof(__llvm_profile_data) - 1) - BeginI) /
6376
sizeof(__llvm_profile_data);
6477
}
@@ -71,6 +84,26 @@ uint64_t __llvm_profile_get_data_size(const __llvm_profile_data *Begin,
7184
return __llvm_profile_get_num_data(Begin, End) * sizeof(__llvm_profile_data);
7285
}
7386

87+
// Counts the number of `VTableProfData` elements within the range of [Begin,
88+
// End). Caller should guarantee that End points to one byte past the inclusive
89+
// range.
90+
// FIXME: Add a compiler-rt test to make sure the number of vtables in the
91+
// raw profile is the same as the number of vtable elements in the instrumented
92+
// binary.
93+
COMPILER_RT_VISIBILITY
94+
uint64_t __llvm_profile_get_num_vtable(const VTableProfData *Begin,
95+
const VTableProfData *End) {
96+
// Convert pointers to intptr_t to use integer arithmetic.
97+
intptr_t EndI = (intptr_t)End, BeginI = (intptr_t)Begin;
98+
return (EndI - BeginI) / sizeof(VTableProfData);
99+
}
100+
101+
COMPILER_RT_VISIBILITY
102+
uint64_t __llvm_profile_get_vtable_section_size(const VTableProfData *Begin,
103+
const VTableProfData *End) {
104+
return (intptr_t)(End) - (intptr_t)(Begin);
105+
}
106+
74107
COMPILER_RT_VISIBILITY size_t __llvm_profile_counter_entry_size(void) {
75108
if (__llvm_profile_get_version() & VARIANT_MASK_BYTE_COVERAGE)
76109
return sizeof(uint8_t);
@@ -121,21 +154,33 @@ static int needsCounterPadding(void) {
121154
}
122155

123156
COMPILER_RT_VISIBILITY
124-
void __llvm_profile_get_padding_sizes_for_counters(
157+
int __llvm_profile_get_padding_sizes_for_counters(
125158
uint64_t DataSize, uint64_t CountersSize, uint64_t NumBitmapBytes,
126-
uint64_t NamesSize, uint64_t *PaddingBytesBeforeCounters,
127-
uint64_t *PaddingBytesAfterCounters, uint64_t *PaddingBytesAfterBitmapBytes,
128-
uint64_t *PaddingBytesAfterNames) {
159+
uint64_t NamesSize, uint64_t VTableSize, uint64_t VNameSize,
160+
uint64_t *PaddingBytesBeforeCounters, uint64_t *PaddingBytesAfterCounters,
161+
uint64_t *PaddingBytesAfterBitmapBytes, uint64_t *PaddingBytesAfterNames,
162+
uint64_t *PaddingBytesAfterVTable, uint64_t *PaddingBytesAfterVName) {
163+
// Counter padding is needed only if continuous mode is enabled.
129164
if (!needsCounterPadding()) {
130165
*PaddingBytesBeforeCounters = 0;
131166
*PaddingBytesAfterCounters =
132167
__llvm_profile_get_num_padding_bytes(CountersSize);
133168
*PaddingBytesAfterBitmapBytes =
134169
__llvm_profile_get_num_padding_bytes(NumBitmapBytes);
135170
*PaddingBytesAfterNames = __llvm_profile_get_num_padding_bytes(NamesSize);
136-
return;
171+
if (PaddingBytesAfterVTable != NULL)
172+
*PaddingBytesAfterVTable =
173+
__llvm_profile_get_num_padding_bytes(VTableSize);
174+
if (PaddingBytesAfterVName != NULL)
175+
*PaddingBytesAfterVName = __llvm_profile_get_num_padding_bytes(VNameSize);
176+
return 0;
137177
}
138178

179+
// Value profiling not supported in continuous mode at profile-write time.
180+
// Return -1 to alert the incompatibility.
181+
if (VTableSize != 0 || VNameSize != 0)
182+
return -1;
183+
139184
// In continuous mode, the file offsets for headers and for the start of
140185
// counter sections need to be page-aligned.
141186
*PaddingBytesBeforeCounters =
@@ -144,34 +189,52 @@ void __llvm_profile_get_padding_sizes_for_counters(
144189
*PaddingBytesAfterBitmapBytes =
145190
calculateBytesNeededToPageAlign(NumBitmapBytes);
146191
*PaddingBytesAfterNames = calculateBytesNeededToPageAlign(NamesSize);
192+
// Set these two variables to zero to avoid uninitialized variables
193+
// even if VTableSize and VNameSize are known to be zero.
194+
if (PaddingBytesAfterVTable != NULL)
195+
*PaddingBytesAfterVTable = 0;
196+
if (PaddingBytesAfterVName != NULL)
197+
*PaddingBytesAfterVName = 0;
198+
return 0;
147199
}
148200

149201
COMPILER_RT_VISIBILITY
150202
uint64_t __llvm_profile_get_size_for_buffer_internal(
151203
const __llvm_profile_data *DataBegin, const __llvm_profile_data *DataEnd,
152204
const char *CountersBegin, const char *CountersEnd, const char *BitmapBegin,
153-
const char *BitmapEnd, const char *NamesBegin, const char *NamesEnd) {
205+
const char *BitmapEnd, const char *NamesBegin, const char *NamesEnd,
206+
const VTableProfData *VTableBegin, const VTableProfData *VTableEnd,
207+
const char *VNamesBegin, const char *VNamesEnd) {
154208
/* Match logic in __llvm_profile_write_buffer(). */
155209
const uint64_t NamesSize = (NamesEnd - NamesBegin) * sizeof(char);
156210
uint64_t DataSize = __llvm_profile_get_data_size(DataBegin, DataEnd);
157211
uint64_t CountersSize =
158212
__llvm_profile_get_counters_size(CountersBegin, CountersEnd);
159213
const uint64_t NumBitmapBytes =
160214
__llvm_profile_get_num_bitmap_bytes(BitmapBegin, BitmapEnd);
215+
const uint64_t VTableSize =
216+
__llvm_profile_get_vtable_section_size(VTableBegin, VTableEnd);
217+
const uint64_t VNameSize =
218+
__llvm_profile_get_name_size(VNamesBegin, VNamesEnd);
161219

162220
/* Determine how much padding is needed before/after the counters and after
163221
* the names. */
164222
uint64_t PaddingBytesBeforeCounters, PaddingBytesAfterCounters,
165-
PaddingBytesAfterNames, PaddingBytesAfterBitmapBytes;
223+
PaddingBytesAfterNames, PaddingBytesAfterBitmapBytes,
224+
PaddingBytesAfterVTable, PaddingBytesAfterVNames;
166225
__llvm_profile_get_padding_sizes_for_counters(
167-
DataSize, CountersSize, NumBitmapBytes, NamesSize,
168-
&PaddingBytesBeforeCounters, &PaddingBytesAfterCounters,
169-
&PaddingBytesAfterBitmapBytes, &PaddingBytesAfterNames);
226+
DataSize, CountersSize, NumBitmapBytes, NamesSize, 0 /* VTableSize */,
227+
0 /* VNameSize */, &PaddingBytesBeforeCounters,
228+
&PaddingBytesAfterCounters, &PaddingBytesAfterBitmapBytes,
229+
&PaddingBytesAfterNames, &PaddingBytesAfterVTable,
230+
&PaddingBytesAfterVNames);
170231

171232
return sizeof(__llvm_profile_header) + __llvm_write_binary_ids(NULL) +
172233
DataSize + PaddingBytesBeforeCounters + CountersSize +
173234
PaddingBytesAfterCounters + NumBitmapBytes +
174-
PaddingBytesAfterBitmapBytes + NamesSize + PaddingBytesAfterNames;
235+
PaddingBytesAfterBitmapBytes + NamesSize + PaddingBytesAfterNames +
236+
VTableSize + PaddingBytesAfterVTable + VNameSize +
237+
PaddingBytesAfterVNames;
175238
}
176239

177240
COMPILER_RT_VISIBILITY
@@ -193,7 +256,10 @@ COMPILER_RT_VISIBILITY int __llvm_profile_write_buffer_internal(
193256
const char *NamesBegin, const char *NamesEnd) {
194257
ProfDataWriter BufferWriter;
195258
initBufferWriter(&BufferWriter, Buffer);
196-
return lprofWriteDataImpl(&BufferWriter, DataBegin, DataEnd, CountersBegin,
197-
CountersEnd, BitmapBegin, BitmapEnd, 0, NamesBegin,
198-
NamesEnd, 0);
259+
// Set virtual table arguments to NULL since they are not supported yet.
260+
return lprofWriteDataImpl(
261+
&BufferWriter, DataBegin, DataEnd, CountersBegin, CountersEnd,
262+
BitmapBegin, BitmapEnd, /*VPDataReader=*/0, NamesBegin, NamesEnd,
263+
/*VTableBegin=*/NULL, /*VTableEnd=*/NULL, /*VNamesBegin=*/NULL,
264+
/*VNamesEnd=*/NULL, /*SkipNameDataWrite=*/0);
199265
}

0 commit comments

Comments
 (0)