[compiler-rt] r253897 - [PGO] Unify section name, section symbol definitions (Linux)

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 23 10:56:03 PST 2015


Author: davidxl
Date: Mon Nov 23 12:56:03 2015
New Revision: 253897

URL: http://llvm.org/viewvc/llvm-project?rev=253897&view=rev
Log:
[PGO] Unify section name, section symbol definitions (Linux)

 Replace hard-coded references to names to key section and section
 symbols with common macro definitions.




Modified:
    compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c

Modified: compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c?rev=253897&r1=253896&r2=253897&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingPlatformLinux.c Mon Nov 23 12:56:03 2015
@@ -12,36 +12,47 @@
 #if defined(__linux__) || defined(__FreeBSD__)
 #include <stdlib.h>
 
-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;
+#define PROF_DATA_START INSTR_PROF_SECT_START(INSTR_PROF_DATA_SECT_NAME)
+#define PROF_DATA_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_DATA_SECT_NAME)
+#define PROF_NAME_START INSTR_PROF_SECT_START(INSTR_PROF_NAME_SECT_NAME)
+#define PROF_NAME_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_NAME_SECT_NAME)
+#define PROF_CNTS_START INSTR_PROF_SECT_START(INSTR_PROF_CNTS_SECT_NAME)
+#define PROF_CNTS_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_CNTS_SECT_NAME)
+
+/* Declare section start and stop symbols for various sections
+ * generated by compiler instrumentation.
+ */
+extern __llvm_profile_data PROF_DATA_START LLVM_LIBRARY_VISIBILITY;
+extern __llvm_profile_data PROF_DATA_STOP LLVM_LIBRARY_VISIBILITY;
+extern uint64_t PROF_CNTS_START LLVM_LIBRARY_VISIBILITY;
+extern uint64_t PROF_CNTS_STOP LLVM_LIBRARY_VISIBILITY;
+extern char PROF_NAME_START LLVM_LIBRARY_VISIBILITY;
+extern char PROF_NAME_STOP LLVM_LIBRARY_VISIBILITY;
 
 /* Add dummy data to ensure the section is always created. */
-__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");
+__llvm_profile_data
+    __prof_data_sect_data[0] LLVM_SECTION(INSTR_PROF_DATA_SECT_NAME_STR);
+uint64_t __prof_cnts_sect_data[0] LLVM_SECTION(INSTR_PROF_CNTS_SECT_NAME_STR);
+char __prof_nms_sect_data[0] LLVM_SECTION(INSTR_PROF_NAME_SECT_NAME_STR);
 
 LLVM_LIBRARY_VISIBILITY const __llvm_profile_data *
 __llvm_profile_begin_data(void) {
-  return &__start___llvm_prf_data;
+  return &PROF_DATA_START;
 }
 LLVM_LIBRARY_VISIBILITY const __llvm_profile_data *
 __llvm_profile_end_data(void) {
-  return &__stop___llvm_prf_data;
+  return &PROF_DATA_STOP;
 }
 LLVM_LIBRARY_VISIBILITY const char *__llvm_profile_begin_names(void) {
-  return &__start___llvm_prf_names;
+  return &PROF_NAME_START;
 }
 LLVM_LIBRARY_VISIBILITY const char *__llvm_profile_end_names(void) {
-  return &__stop___llvm_prf_names;
+  return &PROF_NAME_STOP;
 }
 LLVM_LIBRARY_VISIBILITY uint64_t *__llvm_profile_begin_counters(void) {
-  return &__start___llvm_prf_cnts;
+  return &PROF_CNTS_START;
 }
 LLVM_LIBRARY_VISIBILITY uint64_t *__llvm_profile_end_counters(void) {
-  return &__stop___llvm_prf_cnts;
+  return &PROF_CNTS_STOP;
 }
 #endif




More information about the llvm-commits mailing list