[PATCH] D12001: Implement __emutls_get_address

Chih-Hung Hsieh via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 09:17:27 PDT 2015


chh added inline comments.

================
Comment at: compiler-rt/lib/builtins/emutls.c:151
@@ +150,3 @@
+    */
+    return ((index + 1 + 15) & ~((uintptr_t)15)) - 1;
+}
----------------
compnerd wrote:
> If you are trying to round up to 16, shouldn't this be more like:
> 
>     (index + 16 - 1) & ~(16 - 1)
> 
> Which would be ideal as an inline function:
> 
>     inline size_t align_up(size_t value, unsigned alignment) {
>       return (value + alignment - 1) & ~(size_t)(alignment - 1);
>     }
It's trickier than that as we try to be compatible with gcc's structure of emutls_address_arrary. It has a 'data' array plus an extra pointer. So, here we want to round up (index + 1) to 16, but returns the new size of 'data' array.



http://reviews.llvm.org/D12001





More information about the llvm-commits mailing list