[compiler-rt] r253845 - [PGO] Compiler-rt cleanup -- introduces macros for various macros
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 22 20:38:18 PST 2015
Author: davidxl
Date: Sun Nov 22 22:38:17 2015
New Revision: 253845
URL: http://llvm.org/viewvc/llvm-project?rev=253845&view=rev
Log:
[PGO] Compiler-rt cleanup -- introduces macros for various macros
This makes code more readable and be made more portable in the future.
There is no functional change.
Modified:
compiler-rt/trunk/lib/profile/InstrProfiling.c
compiler-rt/trunk/lib/profile/InstrProfiling.h
compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c
compiler-rt/trunk/lib/profile/InstrProfilingFile.c
compiler-rt/trunk/lib/profile/InstrProfilingPlatformDarwin.c
compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c
compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c
compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
compiler-rt/trunk/lib/profile/InstrProfilingWriter.c
Modified: compiler-rt/trunk/lib/profile/InstrProfiling.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfiling.c?rev=253845&r1=253844&r2=253845&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfiling.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfiling.c Sun Nov 22 22:38:17 2015
@@ -17,7 +17,7 @@ typedef struct ValueProfNode {
struct ValueProfNode *Next;
} ValueProfNode;
-__attribute__((visibility("hidden"))) uint64_t __llvm_profile_get_magic(void) {
+LLVM_LIBRARY_VISIBILITY uint64_t __llvm_profile_get_magic(void) {
/* Magic number to detect file format and endianness.
*
* Use 255 at one end, since no UTF-8 file can use that character. Avoid 0,
@@ -36,18 +36,17 @@ __attribute__((visibility("hidden"))) ui
/* Return the number of bytes needed to add to SizeInBytes to make it
* the result a multiple of 8.
*/
-__attribute__((visibility("hidden"))) uint8_t
+LLVM_LIBRARY_VISIBILITY uint8_t
__llvm_profile_get_num_padding_bytes(uint64_t SizeInBytes) {
return 7 & (sizeof(uint64_t) - SizeInBytes % sizeof(uint64_t));
}
-__attribute__((visibility("hidden"))) uint64_t
-__llvm_profile_get_version(void) {
+LLVM_LIBRARY_VISIBILITY uint64_t __llvm_profile_get_version(void) {
/* This should be bumped any time the output format changes. */
return 2;
}
-__attribute__((visibility("hidden"))) void __llvm_profile_reset_counters(void) {
+LLVM_LIBRARY_VISIBILITY void __llvm_profile_reset_counters(void) {
uint64_t *I = __llvm_profile_begin_counters();
uint64_t *E = __llvm_profile_end_counters();
@@ -82,10 +81,9 @@ __attribute__((visibility("hidden"))) vo
static uint64_t TotalValueDataSize = 0;
#ifdef _MIPS_ARCH
-__attribute__((visibility("hidden"))) void
+LLVM_LIBRARY_VISIBILITY void
__llvm_profile_instrument_target(uint64_t TargetValue, void *Data_,
- uint32_t CounterIndex) {
-}
+ uint32_t CounterIndex) {}
#else
@@ -119,7 +117,7 @@ static int allocateValueProfileCounters(
return 1;
}
-__attribute__((visibility("hidden"))) void
+LLVM_LIBRARY_VISIBILITY void
__llvm_profile_instrument_target(uint64_t TargetValue, void *Data,
uint32_t CounterIndex) {
@@ -172,7 +170,7 @@ __llvm_profile_instrument_target(uint64_
}
#endif
-__attribute__((visibility("hidden"))) uint64_t
+LLVM_LIBRARY_VISIBILITY uint64_t
__llvm_profile_gather_value_data(uint8_t **VDataArray) {
if (!VDataArray || 0 == TotalValueDataSize)
Modified: compiler-rt/trunk/lib/profile/InstrProfiling.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfiling.h?rev=253845&r1=253844&r2=253845&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfiling.h (original)
+++ compiler-rt/trunk/lib/profile/InstrProfiling.h Sun Nov 22 22:38:17 2015
@@ -13,9 +13,12 @@
#ifdef _MSC_VER
# define LLVM_ALIGNAS(x) __declspec(align(x))
#elif __GNUC__
-# define LLVM_ALIGNAS(x) __attribute__((aligned(x)))
+#define LLVM_ALIGNAS(x) __attribute__((aligned(x)))
#endif
+#define LLVM_LIBRARY_VISIBILITY __attribute__((visibility("hidden")))
+#define LLVM_SECTION(Sect) __attribute__((section(Sect)))
+
#if defined(__FreeBSD__) && defined(__i386__)
/* System headers define 'size_t' incorrectly on x64 FreeBSD (prior to
Modified: compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c?rev=253845&r1=253844&r2=253845&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c Sun Nov 22 22:38:17 2015
@@ -12,7 +12,7 @@
#include <string.h>
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
uint64_t __llvm_profile_get_size_for_buffer(void) {
const __llvm_profile_data *DataBegin = __llvm_profile_begin_data();
const __llvm_profile_data *DataEnd = __llvm_profile_end_data();
@@ -27,12 +27,11 @@ uint64_t __llvm_profile_get_size_for_buf
#define PROFILE_RANGE_SIZE(Range) (Range##End - Range##Begin)
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
uint64_t __llvm_profile_get_size_for_buffer_internal(
- const __llvm_profile_data *DataBegin,
- const __llvm_profile_data *DataEnd, const uint64_t *CountersBegin,
- const uint64_t *CountersEnd, const char *NamesBegin,
- const char *NamesEnd) {
+ const __llvm_profile_data *DataBegin, const __llvm_profile_data *DataEnd,
+ const uint64_t *CountersBegin, const uint64_t *CountersEnd,
+ const char *NamesBegin, const char *NamesEnd) {
/* Match logic in __llvm_profile_write_buffer(). */
const uint64_t NamesSize = PROFILE_RANGE_SIZE(Names) * sizeof(char);
const uint8_t Padding = __llvm_profile_get_num_padding_bytes(NamesSize);
@@ -56,12 +55,12 @@ static uint32_t bufferWriter(ProfDataIOV
return 0;
}
-__attribute__((visibility("hidden"))) int
+LLVM_LIBRARY_VISIBILITY
__llvm_profile_write_buffer(char *Buffer) {
return llvmWriteProfData(bufferWriter, Buffer, 0, 0);
}
-__attribute__((visibility("hidden"))) int __llvm_profile_write_buffer_internal(
+LLVM_LIBRARY_VISIBILITY int __llvm_profile_write_buffer_internal(
char *Buffer, const __llvm_profile_data *DataBegin,
const __llvm_profile_data *DataEnd, const uint64_t *CountersBegin,
const uint64_t *CountersEnd, const char *NamesBegin, const char *NamesEnd) {
Modified: compiler-rt/trunk/lib/profile/InstrProfilingFile.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingFile.c?rev=253845&r1=253844&r2=253845&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingFile.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingFile.c Sun Nov 22 22:38:17 2015
@@ -164,7 +164,7 @@ static void setFilenameAutomatically(voi
resetFilenameToDefault();
}
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
void __llvm_profile_initialize_file(void) {
/* Check if the filename has been initialized. */
if (__llvm_profile_CurrentFilename)
@@ -174,12 +174,12 @@ void __llvm_profile_initialize_file(void
setFilenameAutomatically();
}
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
void __llvm_profile_set_filename(const char *Filename) {
setFilenamePossiblyWithPid(Filename);
}
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
void __llvm_profile_override_default_filename(const char *Filename) {
/* If the env var is set, skip setting filename from argument. */
const char *Env_Filename = getenv("LLVM_PROFILE_FILE");
@@ -188,7 +188,7 @@ void __llvm_profile_override_default_fil
setFilenamePossiblyWithPid(Filename);
}
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
int __llvm_profile_write_file(void) {
int rc;
@@ -204,11 +204,9 @@ int __llvm_profile_write_file(void) {
return rc;
}
-static void writeFileWithoutReturn(void) {
- __llvm_profile_write_file();
-}
+static void writeFileWithoutReturn(void) { __llvm_profile_write_file(); }
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
int __llvm_profile_register_write_file_atexit(void) {
static int HasBeenRegistered = 0;
Modified: compiler-rt/trunk/lib/profile/InstrProfilingPlatformDarwin.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingPlatformDarwin.c?rev=253845&r1=253844&r2=253845&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingPlatformDarwin.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingPlatformDarwin.c Sun Nov 22 22:38:17 2015
@@ -11,33 +11,32 @@
#if defined(__APPLE__)
/* Use linker magic to find the bounds of the Data section. */
-__attribute__((visibility("hidden")))
-extern __llvm_profile_data DataStart __asm("section$start$__DATA$__llvm_prf_data");
-__attribute__((visibility("hidden")))
-extern __llvm_profile_data DataEnd __asm("section$end$__DATA$__llvm_prf_data");
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
+extern __llvm_profile_data
+ DataStart __asm("section$start$__DATA$__llvm_prf_data");
+LLVM_LIBRARY_VISIBILITY
+extern __llvm_profile_data DataEnd __asm("section$end$__DATA$__llvm_prf_data");
+LLVM_LIBRARY_VISIBILITY
extern char NamesStart __asm("section$start$__DATA$__llvm_prf_names");
-__attribute__((visibility("hidden")))
-extern char NamesEnd __asm("section$end$__DATA$__llvm_prf_names");
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
+extern char NamesEnd __asm("section$end$__DATA$__llvm_prf_names");
+LLVM_LIBRARY_VISIBILITY
extern uint64_t CountersStart __asm("section$start$__DATA$__llvm_prf_cnts");
-__attribute__((visibility("hidden")))
-extern uint64_t CountersEnd __asm("section$end$__DATA$__llvm_prf_cnts");
+LLVM_LIBRARY_VISIBILITY
+extern uint64_t CountersEnd __asm("section$end$__DATA$__llvm_prf_cnts");
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
const __llvm_profile_data *__llvm_profile_begin_data(void) {
return &DataStart;
}
-__attribute__((visibility("hidden")))
-const __llvm_profile_data *__llvm_profile_end_data(void) {
- return &DataEnd;
-}
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
+const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; }
+LLVM_LIBRARY_VISIBILITY
const char *__llvm_profile_begin_names(void) { return &NamesStart; }
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
const char *__llvm_profile_end_names(void) { return &NamesEnd; }
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
uint64_t *__llvm_profile_begin_counters(void) { return &CountersStart; }
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
uint64_t *__llvm_profile_end_counters(void) { return &CountersEnd; }
#endif
Modified: compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c?rev=253845&r1=253844&r2=253845&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c Sun Nov 22 22:38:17 2015
@@ -12,44 +12,36 @@
#if defined(__linux__) || defined(__FreeBSD__)
#include <stdlib.h>
-extern __llvm_profile_data __start___llvm_prf_data
- __attribute__((visibility("hidden")));
-extern __llvm_profile_data __stop___llvm_prf_data
- __attribute__((visibility("hidden")));
-extern uint64_t __start___llvm_prf_cnts __attribute__((visibility("hidden")));
-extern uint64_t __stop___llvm_prf_cnts __attribute__((visibility("hidden")));
-extern char __start___llvm_prf_names __attribute__((visibility("hidden")));
-extern char __stop___llvm_prf_names __attribute__((visibility("hidden")));
+extern __llvm_profile_data __start___llvm_prf_data LLVM_LIBRARY_VISIBILITY;
+extern __llvm_profile_data __stop___llvm_prf_data LLVM_LIBRARY_VISIBILITY;
+extern uint64_t __start___llvm_prf_cnts LLVM_LIBRARY_VISIBILITY;
+extern uint64_t __stop___llvm_prf_cnts LLVM_LIBRARY_VISIBILITY;
+extern char __start___llvm_prf_names LLVM_LIBRARY_VISIBILITY;
+extern char __stop___llvm_prf_names LLVM_LIBRARY_VISIBILITY;
/* Add dummy data to ensure the section is always created. */
-__llvm_profile_data __llvm_prof_sect_data[0]
- __attribute__((section("__llvm_prf_data")));
-uint64_t __llvm_prof_cnts_sect_data[0]
- __attribute__((section("__llvm_prf_cnts")));
-char __llvm_prof_nms_sect_data[0] __attribute__((section("__llvm_prf_names")));
+__llvm_profile_data __llvm_prof_sect_data[0] LLVM_SECTION("__llvm_prf_data");
+uint64_t __llvm_prof_cnts_sect_data[0] LLVM_SECTION("__llvm_prf_cnts");
+char __llvm_prof_nms_sect_data[0] LLVM_SECTION("__llvm_prf_names");
-__attribute__((visibility("hidden"))) const __llvm_profile_data *
+LLVM_LIBRARY_VISIBILITY const __llvm_profile_data *
__llvm_profile_begin_data(void) {
return &__start___llvm_prf_data;
}
-__attribute__((visibility("hidden"))) const __llvm_profile_data *
+LLVM_LIBRARY_VISIBILITY const __llvm_profile_data *
__llvm_profile_end_data(void) {
return &__stop___llvm_prf_data;
}
-__attribute__((visibility("hidden"))) const char *__llvm_profile_begin_names(
- void) {
+LLVM_LIBRARY_VISIBILITY const char *__llvm_profile_begin_names(void) {
return &__start___llvm_prf_names;
}
-__attribute__((visibility("hidden"))) const char *__llvm_profile_end_names(
- void) {
+LLVM_LIBRARY_VISIBILITY const char *__llvm_profile_end_names(void) {
return &__stop___llvm_prf_names;
}
-__attribute__((visibility("hidden"))) uint64_t *__llvm_profile_begin_counters(
- void) {
+LLVM_LIBRARY_VISIBILITY uint64_t *__llvm_profile_begin_counters(void) {
return &__start___llvm_prf_cnts;
}
-__attribute__((visibility("hidden"))) uint64_t *__llvm_profile_end_counters(
- void) {
+LLVM_LIBRARY_VISIBILITY uint64_t *__llvm_profile_end_counters(void) {
return &__stop___llvm_prf_cnts;
}
#endif
Modified: compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c?rev=253845&r1=253844&r2=253845&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c Sun Nov 22 22:38:17 2015
@@ -26,10 +26,10 @@ static uint64_t *CountersLast = NULL;
* calls are only required (and only emitted) on targets where we haven't
* implemented linker magic to find the bounds of the sections.
*/
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
void __llvm_profile_register_function(void *Data_) {
/* TODO: Only emit this function if we can't use linker magic. */
- const __llvm_profile_data *Data = (__llvm_profile_data*)Data_;
+ const __llvm_profile_data *Data = (__llvm_profile_data *)Data_;
if (!DataFirst) {
DataFirst = Data;
DataLast = Data + 1;
@@ -55,20 +55,16 @@ void __llvm_profile_register_function(vo
#undef UPDATE_LAST
}
-__attribute__((visibility("hidden")))
-const __llvm_profile_data *__llvm_profile_begin_data(void) {
- return DataFirst;
-}
-__attribute__((visibility("hidden")))
-const __llvm_profile_data *__llvm_profile_end_data(void) {
- return DataLast;
-}
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
+const __llvm_profile_data *__llvm_profile_begin_data(void) { return DataFirst; }
+LLVM_LIBRARY_VISIBILITY
+const __llvm_profile_data *__llvm_profile_end_data(void) { return DataLast; }
+LLVM_LIBRARY_VISIBILITY
const char *__llvm_profile_begin_names(void) { return NamesFirst; }
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
const char *__llvm_profile_end_names(void) { return NamesLast; }
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
uint64_t *__llvm_profile_begin_counters(void) { return CountersFirst; }
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
uint64_t *__llvm_profile_end_counters(void) { return CountersLast; }
#endif
Modified: compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingUtil.c?rev=253845&r1=253844&r2=253845&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingUtil.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingUtil.c Sun Nov 22 22:38:17 2015
@@ -8,6 +8,7 @@
\*===----------------------------------------------------------------------===*/
#include "InstrProfilingUtil.h"
+#include "InstrProfiling.h"
#ifdef _WIN32
#include <direct.h>
@@ -18,7 +19,7 @@ int mkdir(const char*, unsigned short);
#include <sys/types.h>
#endif
-__attribute__((visibility("hidden")))
+LLVM_LIBRARY_VISIBILITY
void __llvm_profile_recursive_mkdir(char *path) {
int i;
Modified: compiler-rt/trunk/lib/profile/InstrProfilingWriter.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingWriter.c?rev=253845&r1=253844&r2=253845&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingWriter.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingWriter.c Sun Nov 22 22:38:17 2015
@@ -10,9 +10,10 @@
#include "InstrProfiling.h"
#include "InstrProfilingInternal.h"
-__attribute__((visibility("hidden"))) int
-llvmWriteProfData(WriterCallback Writer, void *WriterCtx,
- const uint8_t *ValueDataBegin, const uint64_t ValueDataSize) {
+LLVM_LIBRARY_VISIBILITY int llvmWriteProfData(WriterCallback Writer,
+ void *WriterCtx,
+ const uint8_t *ValueDataBegin,
+ const uint64_t ValueDataSize) {
/* Match logic in __llvm_profile_write_buffer(). */
const __llvm_profile_data *DataBegin = __llvm_profile_begin_data();
const __llvm_profile_data *DataEnd = __llvm_profile_end_data();
@@ -25,7 +26,7 @@ llvmWriteProfData(WriterCallback Writer,
ValueDataSize, NamesBegin, NamesEnd);
}
-__attribute__((visibility("hidden"))) int llvmWriteProfDataImpl(
+LLVM_LIBRARY_VISIBILITY int llvmWriteProfDataImpl(
WriterCallback Writer, void *WriterCtx,
const __llvm_profile_data *DataBegin, const __llvm_profile_data *DataEnd,
const uint64_t *CountersBegin, const uint64_t *CountersEnd,
More information about the llvm-commits
mailing list