From 3ac0f5cbfde901277d45f4c2fc8f2074441cdb96 Mon Sep 17 00:00:00 2001 From: Thomas Fransham Date: Tue, 1 Oct 2024 18:34:56 +0100 Subject: [PATCH 1/2] 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() ``` --- compiler-rt/include/profile/InstrProfData.inc | 13 +++++++++++-- llvm/include/llvm/ProfileData/InstrProfData.inc | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc index c66b0465a0b548..8ad4c7adde644f 100644 --- a/compiler-rt/include/profile/InstrProfData.inc +++ b/compiler-rt/include/profile/InstrProfData.inc @@ -62,6 +62,15 @@ #define INSTR_PROF_VISIBILITY #endif +/* This is include is needed for symbol visibility macros used on + * ValueProfRecord\ValueProfData so there functions are exported from the + * LLVM shared library on windows. */ +#ifdef __cplusplus +#include "llvm/Support/Compiler.h" +#else +#define LLVM_ABI +#endif + // clang-format off:consider re-enabling clang-format if auto-formatted C macros // are readable (e.g., after `issue #82426` is fixed) /* INSTR_PROF_DATA start. */ @@ -373,7 +382,7 @@ INSTR_PROF_SECT_ENTRY(IPSK_covinit, \ * This is the header of the data structure that defines the on-disk * layout of the value profile data of a particular kind for one function. */ -typedef struct ValueProfRecord { +typedef struct LLVM_ABI ValueProfRecord { /* The kind of the value profile record. */ uint32_t Kind; /* @@ -423,7 +432,7 @@ typedef struct ValueProfRecord { * Per-function header/control data structure for value profiling * data in indexed format. */ -typedef struct ValueProfData { +typedef struct LLVM_ABI ValueProfData { /* * Total size in bytes including this field. It must be a multiple * of sizeof(uint64_t). diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc index c66b0465a0b548..8ad4c7adde644f 100644 --- a/llvm/include/llvm/ProfileData/InstrProfData.inc +++ b/llvm/include/llvm/ProfileData/InstrProfData.inc @@ -62,6 +62,15 @@ #define INSTR_PROF_VISIBILITY #endif +/* This is include is needed for symbol visibility macros used on + * ValueProfRecord\ValueProfData so there functions are exported from the + * LLVM shared library on windows. */ +#ifdef __cplusplus +#include "llvm/Support/Compiler.h" +#else +#define LLVM_ABI +#endif + // clang-format off:consider re-enabling clang-format if auto-formatted C macros // are readable (e.g., after `issue #82426` is fixed) /* INSTR_PROF_DATA start. */ @@ -373,7 +382,7 @@ INSTR_PROF_SECT_ENTRY(IPSK_covinit, \ * This is the header of the data structure that defines the on-disk * layout of the value profile data of a particular kind for one function. */ -typedef struct ValueProfRecord { +typedef struct LLVM_ABI ValueProfRecord { /* The kind of the value profile record. */ uint32_t Kind; /* @@ -423,7 +432,7 @@ typedef struct ValueProfRecord { * Per-function header/control data structure for value profiling * data in indexed format. */ -typedef struct ValueProfData { +typedef struct LLVM_ABI ValueProfData { /* * Total size in bytes including this field. It must be a multiple * of sizeof(uint64_t). From dd56b7828d3c37ce8dc6a31209a55bc02202fb36 Mon Sep 17 00:00:00 2001 From: Thomas Fransham Date: Sat, 26 Oct 2024 07:25:01 +0100 Subject: [PATCH 2/2] Fix comment --- compiler-rt/include/profile/InstrProfData.inc | 2 +- llvm/include/llvm/ProfileData/InstrProfData.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc index 8ad4c7adde644f..08ecaf0ed9fa5b 100644 --- a/compiler-rt/include/profile/InstrProfData.inc +++ b/compiler-rt/include/profile/InstrProfData.inc @@ -62,7 +62,7 @@ #define INSTR_PROF_VISIBILITY #endif -/* This is include is needed for symbol visibility macros used on +/* This include is needed for symbol visibility macros used on * ValueProfRecord\ValueProfData so there functions are exported from the * LLVM shared library on windows. */ #ifdef __cplusplus diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc index 8ad4c7adde644f..08ecaf0ed9fa5b 100644 --- a/llvm/include/llvm/ProfileData/InstrProfData.inc +++ b/llvm/include/llvm/ProfileData/InstrProfData.inc @@ -62,7 +62,7 @@ #define INSTR_PROF_VISIBILITY #endif -/* This is include is needed for symbol visibility macros used on +/* This include is needed for symbol visibility macros used on * ValueProfRecord\ValueProfData so there functions are exported from the * LLVM shared library on windows. */ #ifdef __cplusplus