[PATCH] D12001: Implement __emutls_get_address

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 20:16:53 PDT 2015


compnerd added inline comments.

================
Comment at: compiler-rt/lib/builtins/CMakeLists.txt:44
@@ -43,2 +43,3 @@
   divxc3.c
+  emutls.c
   enable_execute_stack.c
----------------
Please don't add this to GENERIC_SOURCES.  This is really not applicable to all targets.  It uses pthread, so it can't be used on say Windows.

This makes me wonder if this actually belongs in the compiler builtins in the first place.

================
Comment at: compiler-rt/lib/builtins/emutls.c:47
@@ +46,3 @@
+    char* object;
+    if ((object = malloc(align - 1 + sizeof(void*) + size)) == NULL)
+        abort();
----------------
Can you also pull out the alignment math into a macro or an inline function please?

================
Comment at: compiler-rt/lib/builtins/emutls.c:80
@@ +79,3 @@
+    /* Make sure that align is power of 2. */
+    if ((((align - 1) | align) + 1) != (align << 1))
+        abort();
----------------
Cant this be written more simply as

    (align & (align - 1) == 0)

================
Comment at: compiler-rt/lib/builtins/emutls.c:109
@@ +108,3 @@
+        }
+    }
+    free(ptr);
----------------
Remove the unnecessary braces here.


http://reviews.llvm.org/D12001





More information about the llvm-commits mailing list