Skip to content

Commit

Permalink
[compiler-rt] Don't change g_tls_size after initialization.
Browse files Browse the repository at this point in the history
Summary:
g_tls_size is not supposed to be changed after initialization. It's not
atomic, not guarded by a lock, nor thread_local. But it's read by
multiple threads.

The reason why it's mutated is mips and powerpc64 specific. We can
implement the same funcitonality without mutating g_tls_size.

I'm not sure how to write a test for this. Please advice. Thanks!

Reviewers: eugenis, kcc

Subscribers: kubamracek, dberris, llvm-commits

Differential Revision: https://reviews.llvm.org/D29236

llvm-svn: 293586
  • Loading branch information
timshen91 committed Jan 31, 2017
1 parent fa3d93a commit f63f58a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc
Expand Up @@ -270,9 +270,7 @@ static uptr TlsPreTcbSize() {
# endif
const uptr kTlsAlign = 16;
const uptr kTlsPreTcbSize =
(ThreadDescriptorSize() + kTcbHead + kTlsAlign - 1) & ~(kTlsAlign - 1);
InitTlsSize();
g_tls_size = (g_tls_size + kTlsPreTcbSize + kTlsAlign -1) & ~(kTlsAlign - 1);
RoundUpTo(ThreadDescriptorSize() + kTcbHead, kTlsAlign);
return kTlsPreTcbSize;
}
#endif
Expand Down Expand Up @@ -379,6 +377,8 @@ uptr GetTlsSize() {
uptr addr, size;
GetTls(&addr, &size);
return size;
#elif defined(__mips__) || defined(__powerpc64__)
return RoundUpTo(g_tls_size + TlsPreTcbSize(), 16);
#else
return g_tls_size;
#endif
Expand Down

0 comments on commit f63f58a

Please sign in to comment.