[compiler-rt] [llvm] Add explicit symbol visibility macros to InstrProfData.inc (PR #110732)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 1 13:04:47 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-pgo

Author: Thomas Fransham (fsfod)

<details>
<summary>Changes</summary>

Annotating these symbols will fix missing symbols for InstrProfTest when using LLVM_BUILD_LLVM_DYLIB builds on windows.
To allow the two header to be kept in sync I've added 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.

---
Full diff: https://github.com/llvm/llvm-project/pull/110732.diff


2 Files Affected:

- (modified) compiler-rt/include/profile/InstrProfData.inc (+11-2) 
- (modified) llvm/include/llvm/ProfileData/InstrProfData.inc (+11-2) 


``````````diff
diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc
index b9df3266fbcf8f..ea2903c92a5857 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. */
@@ -358,7 +367,7 @@ INSTR_PROF_SECT_ENTRY(IPSK_covname, \
  * 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;
   /*
@@ -408,7 +417,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 b9df3266fbcf8f..ea2903c92a5857 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. */
@@ -358,7 +367,7 @@ INSTR_PROF_SECT_ENTRY(IPSK_covname, \
  * 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;
   /*
@@ -408,7 +417,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).

``````````

</details>


https://github.com/llvm/llvm-project/pull/110732


More information about the llvm-commits mailing list