[PATCH] D15000: [ELF] - Implemented @tlsgd optimization (GD->IE case, x64).

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 3 09:38:52 PST 2015


grimar added inline comments.

================
Comment at: ELF/OutputSections.cpp:221-226
@@ -220,2 +220,8 @@
   if (Body && Target->isTlsGlobalDynamicReloc(Type)) {
+    if (Target->isTlsOptimized(Type, Body)) {
+      P->setSymbolAndType(Body->getDynamicSymbolTableIndex(),
+                          Target->getTlsGotReloc(), Config->Mips64EL);
+      P->r_offset = Out<ELFT>::Got->getEntryAddr(*Body);
+      return true;
+    }
     P->setSymbolAndType(Body->getDynamicSymbolTableIndex(),
----------------
ruiu wrote:
> Can you reduce the nest level by moving this `if` outside of the outer `if? I mean
> 
>   if (Body && Target->isTlsOptimized(Type, Body)) {
>     P->setSymbolAndType(Body->getDynamicSymbolTableIndex(),
>                         Target->getTlsGotReloc(), Config->Mips64EL);
>     P->r_offset = Out<ELFT>::Got->getEntryAddr(*Body);
>     return true;
>   }
> 
>   if (Body && Target->isTlsGlobalDynamicReloc(Type)) {
>     ...
>   }
Refactored, what about this one ?

================
Comment at: ELF/Target.cpp:494-495
@@ -489,3 +493,4 @@
 
-bool X86_64TargetInfo::isTlsOptimized(unsigned Type,
-                                      const SymbolBody *S) const {
+// Returns optimization level. 0 - not optimized,
+// 1 - partial, other values - full.
+uint32_t X86_64TargetInfo::isTlsOptimized(unsigned Type,
----------------
ruiu wrote:
> I don't think these magic numbers are good. In fact it seems that you don't need them. Please see the comment below.
Cool ! Fixed.

================
Comment at: ELF/Target.cpp:624
@@ +623,3 @@
+  case R_X86_64_TLSGD: {
+    if (isTlsOptimized(Type, &S) == 1)
+      relocateTlsGdToIe(Loc, BufEnd, P, SA);
----------------
ruiu wrote:
> This can be
> 
>   if (canBePreempted(&S, true))
Done.


http://reviews.llvm.org/D15000





More information about the llvm-commits mailing list