[PATCH] D64498: [profile][test] Fix Profile-* :: instrprof-merge.c etc. on SPARC

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 07:46:24 PDT 2019


ro created this revision.
ro added a reviewer: void.
Herald added subscribers: Sanitizers, fedor.sergeev, jyknight.
Herald added projects: LLVM, Sanitizers.

While working on https://reviews.llvm.org/D40900 (which effectively is about enabling compiler-rt on sparc these days), I came across two failing profile testcases:

  Profile-sparc :: instrprof-merge-match.test
  Profile-sparc :: instrprof-merge.c
  Profile-sparcv9 :: instrprof-merge-match.test
  Profile-sparcv9 :: instrprof-merge.c

All of them crashed with a SIGBUS in `__llvm_profile_merge_from_buffer`:

  Thread 2 received signal SIGSEGV, Segmentation fault.
  [Switching to Thread 1 (LWP 1)]
  0x00012368 in __llvm_profile_merge_from_buffer (
      ProfileData=0x2384c <main.Buffer> "\377lprofR\201", ProfileSize=360)
      at /vol/llvm/src/llvm/local/projects/compiler-rt/lib/profile/InstrProfilingMerge.c:95
  95        SrcDataEnd = SrcDataStart + Header->DataSize;

where Header is insufficiently aligned for a strict-alignment target like SPARC.

Fixed by forcing the alignment to `uint64_t`, the members of `struct __llvm_profile_header`,
in the callers.

Tested on `sparcv9-sun-solaris2.11`.  Ok for trunk?


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D64498

Files:
  test/profile/Inputs/instrprof-merge-match.c
  test/profile/instrprof-merge.c


Index: test/profile/instrprof-merge.c
===================================================================
--- test/profile/instrprof-merge.c
+++ test/profile/instrprof-merge.c
@@ -41,7 +41,7 @@
     return 1;
 
   const uint64_t MaxSize = 10000;
-  static char Buffer[MaxSize];
+  static char Buffer[MaxSize] __attribute__((aligned(sizeof(uint64_t))));
 
   uint64_t Size = __llvm_profile_get_size_for_buffer();
   if (Size > MaxSize)
Index: test/profile/Inputs/instrprof-merge-match.c
===================================================================
--- test/profile/Inputs/instrprof-merge-match.c
+++ test/profile/Inputs/instrprof-merge-match.c
@@ -20,7 +20,7 @@
 
 int main(int argc, const char *argv[]) {
   const uint64_t MaxSize = 10000;
-  static char Buffer[MaxSize];
+  static char Buffer[MaxSize] __attribute__((aligned(sizeof(uint64_t))));
 
   uint64_t Size = __llvm_profile_get_size_for_buffer();
   if (Size > MaxSize)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64498.208961.patch
Type: text/x-patch
Size: 936 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190710/eb7ecd54/attachment.bin>


More information about the llvm-commits mailing list