[PGO] Improve prof library portability

Patch by: Johan Engelen

Introduce LLVM_LIBRARY_WEAK macro. Define LLVM_LIBRARY_WEAK
and LLVM_LIBRARY_VISIBIITY for MSVC

llvm-svn: 255688
This commit is contained in:
Xinliang David Li 2015-12-15 22:38:18 +00:00
parent f85b008de8
commit 1fbae3b76a
3 changed files with 8 additions and 6 deletions

View File

@ -56,8 +56,8 @@ static int writeFileWithName(const char *OutputName) {
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;

View File

@ -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, ...) \

View File

@ -11,8 +11,7 @@ extern "C" {
#include "InstrProfiling.h"
__attribute__((visibility("hidden"))) int __llvm_profile_runtime;
LLVM_LIBRARY_VISIBILITY int __llvm_profile_runtime;
}
namespace {