[PATCH] D29993: Use pthreads to store current thread id on darwin

Francis Ricci via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 11:38:18 PST 2017


fjricci added inline comments.


================
Comment at: lib/lsan/lsan_common_mac.cc:35
 
-static int *get_tls_val(bool allocate) {
+static thread_info_t *get_tls_val() {
   pthread_once(&key_once, make_tls_key);
----------------
kubamracek wrote:
> We're removing the "allocate" argument.  Wasn't that necessary for something?  Why did we have it in the first place?
We had this so that we could return false for `DisabledInThisThread` without allocating any thread-local data if `DisableInThisThread` had never been called. It's possibly a small performance optimization, but I don't think it's significant, and now that we're using the pthread key for more data, I think it's now more complex than it's worth.

I believe the idea of doing it that way came about was a remnant from trying to use __thread, which would fail if you accessed the value too early in the initialization process.


https://reviews.llvm.org/D29993





More information about the llvm-commits mailing list