[PATCH] D12001: Implement __emutls_get_address

Chih-Hung Hsieh via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 11:48:00 PDT 2015


chh marked an inline comment as done.

================
Comment at: compiler-rt/lib/builtins/emutls.c:18
@@ +17,3 @@
+ * can use thread local data without heavier POSIX memory allocators.
+ */
+#ifndef EMUTLS_USE_POSIX_MEMALIGN
----------------
joerg wrote:
> IMO it would still be cleaner to provide two inline functions at the start and
> #undef posix_memalign / free and redefine them to map to those two functions. It leaves the complications of the Android issue out of the rest of the file.
Please take a look of the new diff.
I am not sure that is what what you want.
It has the posix_memalign/malloc/free functions factored out into two inline functions. Maybe it is easier to read.


================
Comment at: compiler-rt/lib/builtins/emutls.c:150
@@ +149,3 @@
+        if (index > size)
+            size = index + 16;  /* allocate 16 extra slots */
+        array = realloc(array, (size + 1) * sizeof(void*));
----------------
joerg wrote:
> I still think it would make sense to try to remember the current maximum index. It doesn't have to be thread-safe, just a global variable. Essentially, use something like roundup16(max(index, max_index)) here.
I think emutls_num_object is what you want as a max_index here.
It's shared by all threads and thread safe.
For every newly used TLS variable, its index will be ++emutls_num_object.



http://reviews.llvm.org/D12001





More information about the llvm-commits mailing list