Skip to content

Commit d7ca703

Browse files
authored
Add explicit symbol visibility macros to InstrProfData.inc (#110732)
Add explicit symbol visibility macros to InstrProfData.inc Annotating these symbols will fix missing symbols for InstrProfTest when using shared library builds on windows with explicit visibility macros enabled. Add a empty fallback definition for LLVM_ABI macro so the code works in compiler-rt. This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on window. ``` llvm\lld-link : error : undefined symbol: public: void ValueProfData::deserializeTo(InstrProfRecord&, InstrProfSymtab*) >>> referenced by unittests\ProfileData\InstrProfTest.cpp:1372 void ValueProfileReadWriteTest_value_prof_data_read_write_Test::TestBody() ```
1 parent 86f76c3 commit d7ca703

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

compiler-rt/include/profile/InstrProfData.inc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@
6262
#define INSTR_PROF_VISIBILITY
6363
#endif
6464

65+
/* This include is needed for symbol visibility macros used on
66+
* ValueProfRecord\ValueProfData so there functions are exported from the
67+
* LLVM shared library on windows. */
68+
#ifdef __cplusplus
69+
#include "llvm/Support/Compiler.h"
70+
#else
71+
#define LLVM_ABI
72+
#endif
73+
6574
// clang-format off:consider re-enabling clang-format if auto-formatted C macros
6675
// are readable (e.g., after `issue #82426` is fixed)
6776
/* INSTR_PROF_DATA start. */
@@ -373,7 +382,7 @@ INSTR_PROF_SECT_ENTRY(IPSK_covinit, \
373382
* This is the header of the data structure that defines the on-disk
374383
* layout of the value profile data of a particular kind for one function.
375384
*/
376-
typedef struct ValueProfRecord {
385+
typedef struct LLVM_ABI ValueProfRecord {
377386
/* The kind of the value profile record. */
378387
uint32_t Kind;
379388
/*
@@ -423,7 +432,7 @@ typedef struct ValueProfRecord {
423432
* Per-function header/control data structure for value profiling
424433
* data in indexed format.
425434
*/
426-
typedef struct ValueProfData {
435+
typedef struct LLVM_ABI ValueProfData {
427436
/*
428437
* Total size in bytes including this field. It must be a multiple
429438
* of sizeof(uint64_t).

llvm/include/llvm/ProfileData/InstrProfData.inc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@
6262
#define INSTR_PROF_VISIBILITY
6363
#endif
6464

65+
/* This include is needed for symbol visibility macros used on
66+
* ValueProfRecord\ValueProfData so there functions are exported from the
67+
* LLVM shared library on windows. */
68+
#ifdef __cplusplus
69+
#include "llvm/Support/Compiler.h"
70+
#else
71+
#define LLVM_ABI
72+
#endif
73+
6574
// clang-format off:consider re-enabling clang-format if auto-formatted C macros
6675
// are readable (e.g., after `issue #82426` is fixed)
6776
/* INSTR_PROF_DATA start. */
@@ -373,7 +382,7 @@ INSTR_PROF_SECT_ENTRY(IPSK_covinit, \
373382
* This is the header of the data structure that defines the on-disk
374383
* layout of the value profile data of a particular kind for one function.
375384
*/
376-
typedef struct ValueProfRecord {
385+
typedef struct LLVM_ABI ValueProfRecord {
377386
/* The kind of the value profile record. */
378387
uint32_t Kind;
379388
/*
@@ -423,7 +432,7 @@ typedef struct ValueProfRecord {
423432
* Per-function header/control data structure for value profiling
424433
* data in indexed format.
425434
*/
426-
typedef struct ValueProfData {
435+
typedef struct LLVM_ABI ValueProfData {
427436
/*
428437
* Total size in bytes including this field. It must be a multiple
429438
* of sizeof(uint64_t).

0 commit comments

Comments
 (0)