[PATCH] D15300: New lower emutls pass, fix linkage bugs.

Chih-Hung Hsieh via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 13 15:08:19 PST 2016


chh added inline comments.

================
Comment at: lib/CodeGen/LowerEmuTLS.cpp:42
@@ +41,3 @@
+  bool addEmuTlsVar(Module &M, const GlobalVariable *GV);
+  static void copyLinkageVisibility(const GlobalVariable *from,
+                                    GlobalVariable *to) {
----------------
rnk wrote:
> What about COMDAT TLS variables? Consider this code:
>   template <typename T> struct A { static thread_local int x; };
>   int getX() { return A<int>::x++; }
> 
> Multiple TUs may instantiate A<int>::x, and we need __emutls_v._ZN1AIiE1xE to go in a comdat section.
> 
> Perhaps we can handle this in a subsequent patch, but it's good to think about.
> 
Good catch. Please take a look of the new diff.
I added also some unit test to AArch64/emutls.ll.
Thanks.


================
Comment at: lib/CodeGen/LowerEmuTLS.cpp:105-106
@@ +104,4 @@
+  // sizeof(word) should be the same as sizeof(void*) on target.
+  EVT PtrVT = MVT::getIntegerVT(DL.getPointerSizeInBits(0));
+  IntegerType *WordType = IntegerType::get(C, PtrVT.getSizeInBits());
+  PointerType *InitPtrType = InitValue ?
----------------
rnk wrote:
> Don't create an EVT object in IR transforms, they aren't needed.
> 
> A better way to write this would be:
>   IntegerType *WordType = DL.getIntPtrType(C, 0);
Good suggestion. Thanks.



http://reviews.llvm.org/D15300





More information about the llvm-commits mailing list