[PATCH] D14468: Add zero size dummy data to ensure section symbol is always created

David Li via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 8 20:11:49 PST 2015


davidxl updated this revision to Diff 39663.
davidxl added a comment.

Update patch: 
do not dump a header when there is no data to be dumped.


http://reviews.llvm.org/D14468

Files:
  lib/profile/InstrProfilingBuffer.c
  lib/profile/InstrProfilingFile.c
  lib/profile/InstrProfilingPlatformLinux.c

Index: lib/profile/InstrProfilingPlatformLinux.c
===================================================================
--- lib/profile/InstrProfilingPlatformLinux.c
+++ lib/profile/InstrProfilingPlatformLinux.c
@@ -21,6 +21,13 @@
 extern char __start___llvm_prf_names __attribute__((visibility("hidden")));
 extern char __stop___llvm_prf_names __attribute__((visibility("hidden")));
 
+/* 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")));
+
 __attribute__((visibility("hidden"))) const __llvm_profile_data *
 __llvm_profile_begin_data(void) {
   return &__start___llvm_prf_data;
Index: lib/profile/InstrProfilingFile.c
===================================================================
--- lib/profile/InstrProfilingFile.c
+++ lib/profile/InstrProfilingFile.c
@@ -36,6 +36,10 @@
 
   /* Create the header. */
   __llvm_profile_header Header;
+
+  if (!DataSize)
+    return 0;
+
   Header.Magic = __llvm_profile_get_magic();
   Header.Version = __llvm_profile_get_version();
   Header.DataSize = DataSize;
Index: lib/profile/InstrProfilingBuffer.c
===================================================================
--- lib/profile/InstrProfilingBuffer.c
+++ lib/profile/InstrProfilingBuffer.c
@@ -79,6 +79,10 @@
 
   /* Create the header. */
   __llvm_profile_header Header;
+
+  if (!DataSize)
+    return 0;
+
   Header.Magic = __llvm_profile_get_magic();
   Header.Version = __llvm_profile_get_version();
   Header.DataSize = DataSize;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14468.39663.patch
Type: text/x-patch
Size: 1715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151109/70cdf387/attachment.bin>


More information about the llvm-commits mailing list