[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
Thu Jul 11 00:51:57 PDT 2019


ro updated this revision to Diff 209138.
ro added a comment.

- Introduce new `profile_test.h` header to share the `ALIGNED` definition, now handling MSVC, too.
- Use it in affected tests.

Tested on `sparcv9-sun-solaris2.11` and `x86_64-pc-solaris2.11`.  I've no way of testing
on Windows, though.


Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64498/new/

https://reviews.llvm.org/D64498

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


Index: test/profile/profile_test.h
===================================================================
--- /dev/null
+++ test/profile/profile_test.h
@@ -0,0 +1,20 @@
+//===-- profile_test.h.h ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains definitions for the profile tests.
+//===----------------------------------------------------------------------===//
+#ifndef PROFILE_TEST_H
+#define PROFILE_TEST_H
+
+#if defined(_MSC_VER)
+# define ALIGNED(x) __declspec(align(x))
+#else  // _MSC_VER
+# define ALIGNED(x) __attribute__((aligned(x)))
+#endif
+
+#endif  // PROFILE_TEST_H
Index: test/profile/instrprof-merge.c
===================================================================
--- test/profile/instrprof-merge.c
+++ test/profile/instrprof-merge.c
@@ -8,6 +8,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include "profile_test.h"
 
 int __llvm_profile_runtime = 0;
 uint64_t __llvm_profile_get_size_for_buffer(void);
@@ -41,7 +42,7 @@
     return 1;
 
   const uint64_t MaxSize = 10000;
-  static char Buffer[MaxSize];
+  static ALIGNED(sizeof(uint64_t)) char Buffer[MaxSize];
 
   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
@@ -1,6 +1,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include "../profile_test.h"
 
 int __llvm_profile_runtime = 0;
 uint64_t __llvm_profile_get_size_for_buffer(void);
@@ -20,7 +21,7 @@
 
 int main(int argc, const char *argv[]) {
   const uint64_t MaxSize = 10000;
-  static char Buffer[MaxSize];
+  static char ALIGNED(sizeof(uint64_t)) Buffer[MaxSize];
 
   uint64_t Size = __llvm_profile_get_size_for_buffer();
   if (Size > MaxSize)


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


More information about the llvm-commits mailing list