https://github.com/EthanLuisMcDonough updated 
https://github.com/llvm/llvm-project/pull/132966

>From e418000ddb31f6df2aa96061bea6fcc56d7b09a9 Mon Sep 17 00:00:00 2001
From: Ethan Luis McDonough <ethanluismcdono...@gmail.com>
Date: Tue, 25 Mar 2025 12:41:59 -0500
Subject: [PATCH 1/2] [PGO][Offload] Hide GPU entrypoint on Darwin

---
 clang/lib/Driver/ToolChains/Darwin.cpp       | 14 +++++---------
 compiler-rt/lib/profile/InstrProfilingFile.c | 12 +++++-------
 compiler-rt/lib/profile/InstrProfilingPort.h |  2 ++
 3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index e67997314da36..4c88722730598 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1481,15 +1481,11 @@ void Darwin::addProfileRTLibs(const ArgList &Args,
   // If we have a symbol export directive and we're linking in the profile
   // runtime, automatically export symbols necessary to implement some of the
   // runtime's functionality.
-  if (hasExportSymbolDirective(Args)) {
-    if (ForGCOV) {
-      addExportedSymbol(CmdArgs, "___gcov_dump");
-      addExportedSymbol(CmdArgs, "___gcov_reset");
-      addExportedSymbol(CmdArgs, "_writeout_fn_list");
-      addExportedSymbol(CmdArgs, "_reset_fn_list");
-    } else {
-      addExportedSymbol(CmdArgs, "___llvm_write_custom_profile");
-    }
+  if (hasExportSymbolDirective(Args) && ForGCOV) {
+    addExportedSymbol(CmdArgs, "___gcov_dump");
+    addExportedSymbol(CmdArgs, "___gcov_reset");
+    addExportedSymbol(CmdArgs, "_writeout_fn_list");
+    addExportedSymbol(CmdArgs, "_reset_fn_list");
   }
 
   // Align __llvm_prf_{cnts,bits,data} sections to the maximum expected page
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index 19467429cf4c3..9f75ce5ef97d1 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -1273,13 +1273,11 @@ COMPILER_RT_VISIBILITY int 
__llvm_profile_set_file_object(FILE *File,
   return 0;
 }
 
-int __llvm_write_custom_profile(const char *Target,
-                                const __llvm_profile_data *DataBegin,
-                                const __llvm_profile_data *DataEnd,
-                                const char *CountersBegin,
-                                const char *CountersEnd, const char 
*NamesBegin,
-                                const char *NamesEnd,
-                                const uint64_t *VersionOverride) {
+COMPILER_RT_GPU_ENTRYPOINT int __llvm_write_custom_profile(
+    const char *Target, const __llvm_profile_data *DataBegin,
+    const __llvm_profile_data *DataEnd, const char *CountersBegin,
+    const char *CountersEnd, const char *NamesBegin, const char *NamesEnd,
+    const uint64_t *VersionOverride) {
   int ReturnValue = 0, FilenameLength, TargetLength;
   char *FilenameBuf, *TargetFilename;
   const char *Filename;
diff --git a/compiler-rt/lib/profile/InstrProfilingPort.h 
b/compiler-rt/lib/profile/InstrProfilingPort.h
index 66d697885eaee..ed56beb6577a3 100644
--- a/compiler-rt/lib/profile/InstrProfilingPort.h
+++ b/compiler-rt/lib/profile/InstrProfilingPort.h
@@ -43,8 +43,10 @@
 
 #if defined(__APPLE__)
 #define COMPILER_RT_SEG "__DATA,"
+#define COMPILER_RT_GPU_ENTRYPOINT COMPILER_RT_VISIBILITY
 #else
 #define COMPILER_RT_SEG ""
+#define COMPILER_RT_GPU_ENTRYPOINT
 #endif
 
 #ifdef _MSC_VER

>From 64b85d93a48948a17244ad14e7f569997e2c16b6 Mon Sep 17 00:00:00 2001
From: Ethan Luis McDonough <ethanluismcdono...@gmail.com>
Date: Tue, 25 Mar 2025 20:51:34 -0500
Subject: [PATCH 2/2] [PGO][Offload] Don't define entrypoint on Darwin

---
 compiler-rt/lib/profile/InstrProfilingFile.c | 14 +++++++++-----
 compiler-rt/lib/profile/InstrProfilingPort.h |  1 -
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index 9f75ce5ef97d1..d48a870647e86 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -1273,11 +1273,14 @@ COMPILER_RT_VISIBILITY int 
__llvm_profile_set_file_object(FILE *File,
   return 0;
 }
 
-COMPILER_RT_GPU_ENTRYPOINT int __llvm_write_custom_profile(
-    const char *Target, const __llvm_profile_data *DataBegin,
-    const __llvm_profile_data *DataEnd, const char *CountersBegin,
-    const char *CountersEnd, const char *NamesBegin, const char *NamesEnd,
-    const uint64_t *VersionOverride) {
+#ifdef COMPILER_RT_GPU_ENTRYPOINT
+int __llvm_write_custom_profile(const char *Target,
+                                const __llvm_profile_data *DataBegin,
+                                const __llvm_profile_data *DataEnd,
+                                const char *CountersBegin,
+                                const char *CountersEnd, const char 
*NamesBegin,
+                                const char *NamesEnd,
+                                const uint64_t *VersionOverride) {
   int ReturnValue = 0, FilenameLength, TargetLength;
   char *FilenameBuf, *TargetFilename;
   const char *Filename;
@@ -1379,5 +1382,6 @@ COMPILER_RT_GPU_ENTRYPOINT int 
__llvm_write_custom_profile(
 
   return ReturnValue;
 }
+#endif
 
 #endif
diff --git a/compiler-rt/lib/profile/InstrProfilingPort.h 
b/compiler-rt/lib/profile/InstrProfilingPort.h
index ed56beb6577a3..7aea4e221ddc4 100644
--- a/compiler-rt/lib/profile/InstrProfilingPort.h
+++ b/compiler-rt/lib/profile/InstrProfilingPort.h
@@ -43,7 +43,6 @@
 
 #if defined(__APPLE__)
 #define COMPILER_RT_SEG "__DATA,"
-#define COMPILER_RT_GPU_ENTRYPOINT COMPILER_RT_VISIBILITY
 #else
 #define COMPILER_RT_SEG ""
 #define COMPILER_RT_GPU_ENTRYPOINT

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to