[compiler-rt] r255688 - [PGO] Improve prof library portability

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 15 14:38:18 PST 2015


Author: davidxl
Date: Tue Dec 15 16:38:18 2015
New Revision: 255688

URL: http://llvm.org/viewvc/llvm-project?rev=255688&view=rev
Log:
[PGO] Improve prof library portability

Patch by: Johan Engelen

Introduce LLVM_LIBRARY_WEAK macro. Define LLVM_LIBRARY_WEAK
and LLVM_LIBRARY_VISIBIITY for MSVC


Modified:
    compiler-rt/trunk/lib/profile/InstrProfilingFile.c
    compiler-rt/trunk/lib/profile/InstrProfilingPort.h
    compiler-rt/trunk/lib/profile/InstrProfilingRuntime.cc

Modified: compiler-rt/trunk/lib/profile/InstrProfilingFile.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingFile.c?rev=255688&r1=255687&r2=255688&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingFile.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingFile.c Tue Dec 15 16:38:18 2015
@@ -56,8 +56,8 @@ static int writeFileWithName(const char
   return RetVal;
 }
 
-__attribute__((weak)) int __llvm_profile_OwnsFilename = 0;
-__attribute__((weak)) const char *__llvm_profile_CurrentFilename = NULL;
+LLVM_LIBRARY_WEAK int __llvm_profile_OwnsFilename = 0;
+LLVM_LIBRARY_WEAK const char *__llvm_profile_CurrentFilename = NULL;
 
 static void truncateCurrentFile(void) {
   const char *Filename;

Modified: compiler-rt/trunk/lib/profile/InstrProfilingPort.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingPort.h?rev=255688&r1=255687&r2=255688&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingPort.h (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingPort.h Tue Dec 15 16:38:18 2015
@@ -11,12 +11,15 @@
 #define PROFILE_INSTRPROFILING_PORT_H_
 
 #ifdef _MSC_VER
-# define LLVM_ALIGNAS(x) __declspec(align(x))
+#define LLVM_ALIGNAS(x) __declspec(align(x))
+#define LLVM_LIBRARY_VISIBILITY
+#define LLVM_LIBRARY_WEAK __declspec(selectany)
 #elif __GNUC__
 #define LLVM_ALIGNAS(x) __attribute__((aligned(x)))
+#define LLVM_LIBRARY_VISIBILITY __attribute__((visibility("hidden")))
+#define LLVM_LIBRARY_WEAK __attribute__((weak))
 #endif
 
-#define LLVM_LIBRARY_VISIBILITY __attribute__((visibility("hidden")))
 #define LLVM_SECTION(Sect) __attribute__((section(Sect)))
 
 #define PROF_ERR(Format, ...)                                                  \

Modified: compiler-rt/trunk/lib/profile/InstrProfilingRuntime.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingRuntime.cc?rev=255688&r1=255687&r2=255688&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingRuntime.cc (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingRuntime.cc Tue Dec 15 16:38:18 2015
@@ -11,8 +11,7 @@ extern "C" {
 
 #include "InstrProfiling.h"
 
-__attribute__((visibility("hidden"))) int __llvm_profile_runtime;
-
+LLVM_LIBRARY_VISIBILITY int __llvm_profile_runtime;
 }
 
 namespace {




More information about the llvm-commits mailing list