aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-10-13 18:40:00 +0000
committerXinliang David Li <davidxl@google.com>2015-10-13 18:40:00 +0000
commitf556a7e3c349b2a4c51f661800e57c772d25ba6d (patch)
tree6277d483d618760c73bccb43128cd73f54746d8f
parent3dd8817d84214681d29d3bf7aca33fc652d7de96 (diff)
downloadllvm-f556a7e3c349b2a4c51f661800e57c772d25ba6d.zip
llvm-f556a7e3c349b2a4c51f661800e57c772d25ba6d.tar.gz
llvm-f556a7e3c349b2a4c51f661800e57c772d25ba6d.tar.bz2
[PGO]: Eliminate calls to __llvm_profile_register_function for Linux.
On Linux, the profile runtime can use __start_SECTNAME and __stop_SECTNAME symbols defined by the linker to locate the start and end location of a named section (with C name). This eliminates the need for instrumented binary to call __llvm_profile_register_function during start-up time. llvm-svn: 250200
-rw-r--r--compiler-rt/lib/profile/CMakeLists.txt1
-rw-r--r--compiler-rt/lib/profile/InstrProfilingPlatformLinux.c48
-rw-r--r--compiler-rt/lib/profile/InstrProfilingPlatformOther.c2
3 files changed, 50 insertions, 1 deletions
diff --git a/compiler-rt/lib/profile/CMakeLists.txt b/compiler-rt/lib/profile/CMakeLists.txt
index b9f5b0f..6b37b39 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -6,6 +6,7 @@ set(PROFILE_SOURCES
InstrProfilingBuffer.c
InstrProfilingFile.c
InstrProfilingPlatformDarwin.c
+ InstrProfilingPlatformLinux.c
InstrProfilingPlatformOther.c
InstrProfilingRuntime.cc
InstrProfilingUtil.c)
diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
new file mode 100644
index 0000000..6c3c26c
--- /dev/null
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
@@ -0,0 +1,48 @@
+/*===- InstrProfilingPlatformLinux.c - Profile data Linux platform ------===*\
+|*
+|* The LLVM Compiler Infrastructure
+|*
+|* This file is distributed under the University of Illinois Open Source
+|* License. See LICENSE.TXT for details.
+|*
+\*===----------------------------------------------------------------------===*/
+
+#include "InstrProfiling.h"
+
+#if defined(__linux__)
+#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")));
+
+__attribute__((visibility("hidden"))) const __llvm_profile_data *
+__llvm_profile_begin_data(void) {
+ return &__start___llvm_prf_data;
+}
+__attribute__((visibility("hidden"))) const __llvm_profile_data *
+__llvm_profile_end_data(void) {
+ return &__stop___llvm_prf_data;
+}
+__attribute__((visibility("hidden"))) const char *__llvm_profile_begin_names(
+ void) {
+ return &__start___llvm_prf_names;
+}
+__attribute__((visibility("hidden"))) const char *__llvm_profile_end_names(
+ void) {
+ return &__stop___llvm_prf_names;
+}
+__attribute__((visibility("hidden"))) uint64_t *__llvm_profile_begin_counters(
+ void) {
+ return &__start___llvm_prf_cnts;
+}
+__attribute__((visibility("hidden"))) uint64_t *__llvm_profile_end_counters(
+ void) {
+ return &__stop___llvm_prf_cnts;
+}
+#endif
diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
index 548d6a3..4d05900 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
@@ -9,7 +9,7 @@
#include "InstrProfiling.h"
-#if !defined(__APPLE__)
+#if !defined(__APPLE__) && !defined(__linux__)
#include <stdlib.h>
static const __llvm_profile_data *DataFirst = NULL;