[PATCH] D14925: [tsan] Fix stack_sync_reuse.cc test on OS X

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 23 06:34:37 PST 2015


kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, kcc, glider, samsonov.
kubabrecka added subscribers: llvm-commits, zaks.anna, ismailp.

The test relies on two variables in different frames to end up being on the same address.  For some reason, this isn't true on OS X.  This patch adds `__attribute__((aligned(64)))` to the variables, which actually makes the variables occupy the same address.    This is still not a guarantee, but it's more likely to work (the test looks very fragile already).

http://reviews.llvm.org/D14925

Files:
  test/tsan/stack_sync_reuse.cc

Index: test/tsan/stack_sync_reuse.cc
===================================================================
--- test/tsan/stack_sync_reuse.cc
+++ test/tsan/stack_sync_reuse.cc
@@ -31,16 +31,18 @@
 }
 
 void __attribute__((noinline)) foobar() {
-  long s;
+  __attribute__((aligned(64))) long s;
+
   addr = &s;
   __atomic_store_n(&s, 0, __ATOMIC_RELAXED);
   __atomic_store_n(&syncp, &s, __ATOMIC_RELEASE);
   while (__atomic_load_n(&syncp, __ATOMIC_RELAXED) != 0)
     usleep(1000);  // spin wait
 }
 
 void __attribute__((noinline)) barfoo() {
-  long s;
+  __attribute__((aligned(64))) long s;
+
   if (addr != &s) {
     printf("address mismatch addr=%p &s=%p\n", addr, &s);
     exit(1);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14925.40923.patch
Type: text/x-patch
Size: 691 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151123/5ec275f3/attachment.bin>


More information about the llvm-commits mailing list