[compiler-rt] r250200 - [PGO]: Eliminate calls to __llvm_profile_register_function for Linux.

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 13 11:40:00 PDT 2015


Author: davidxl
Date: Tue Oct 13 13:40:00 2015
New Revision: 250200

URL: http://llvm.org/viewvc/llvm-project?rev=250200&view=rev
Log:

[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.

Added:
    compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c
Modified:
    compiler-rt/trunk/lib/profile/CMakeLists.txt
    compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c

Modified: compiler-rt/trunk/lib/profile/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/CMakeLists.txt?rev=250200&r1=250199&r2=250200&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/profile/CMakeLists.txt Tue Oct 13 13:40:00 2015
@@ -6,6 +6,7 @@ set(PROFILE_SOURCES
   InstrProfilingBuffer.c
   InstrProfilingFile.c
   InstrProfilingPlatformDarwin.c
+  InstrProfilingPlatformLinux.c
   InstrProfilingPlatformOther.c
   InstrProfilingRuntime.cc
   InstrProfilingUtil.c)

Added: compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c?rev=250200&view=auto
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c (added)
+++ compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c Tue Oct 13 13:40:00 2015
@@ -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

Modified: compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c?rev=250200&r1=250199&r2=250200&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c Tue Oct 13 13:40:00 2015
@@ -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;




More information about the llvm-commits mailing list