[PATCH] D14870: [ELF2] - Implemented optimizations for @tlsld and @tlsgd

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 13:23:29 PST 2015


grimar added inline comments.

================
Comment at: ELF/InputSection.cpp:142
@@ +141,3 @@
+    if (Target->isTlsOptimized(Type, &Body)) {
+      I += Target->relocateTlsOptimize(BufLoc, BufEnd, Type, AddrLoc,
+                                       getSymVA<ELFT>(Body));
----------------
ruiu wrote:
> Please add a comment here.
> 
>   // By optimizing TLS relocations, it is sometimes needed to skip relocations
>   // that immediately follow TLS relocations. This function knows how many slots
>   // we need to skip.
Done.

================
Comment at: ELF/Target.cpp:469
@@ -409,1 +468,3 @@
 
+int8_t X86_64TargetInfo::relocateTlsOptimize(uint8_t *Loc, uint8_t *BufEnd,
+                                             uint32_t Type, uint64_t P,
----------------
ruiu wrote:
> ruiu wrote:
> > Please do not use int8_t just because it returns a small integer. If no specific size is in mind, use int.
> Add a comment
> 
>   // This function applies a TLS relocation with an optimization as described
>   // in the Ulrich's document. As a result of rewriting instructions at the relocation
>   // target, relocations immediately follow the TLS relocation (which would be applied
>   // to rewritten instructions) need to be skipped.
>   // This function returns a number of relocations that need to be skipped.
Done.

================
Comment at: ELF/Target.cpp:469
@@ -409,1 +468,3 @@
 
+int8_t X86_64TargetInfo::relocateTlsOptimize(uint8_t *Loc, uint8_t *BufEnd,
+                                             uint32_t Type, uint64_t P,
----------------
grimar wrote:
> ruiu wrote:
> > ruiu wrote:
> > > Please do not use int8_t just because it returns a small integer. If no specific size is in mind, use int.
> > Add a comment
> > 
> >   // This function applies a TLS relocation with an optimization as described
> >   // in the Ulrich's document. As a result of rewriting instructions at the relocation
> >   // target, relocations immediately follow the TLS relocation (which would be applied
> >   // to rewritten instructions) need to be skipped.
> >   // This function returns a number of relocations that need to be skipped.
> Done.
Done.

================
Comment at: ELF/Target.cpp:472-483
@@ +471,14 @@
+                                             uint64_t SA) const {
+  int8_t SkipRel = 0;
+  if (Type == R_X86_64_GOTTPOFF)
+    relocateTlsIeToLe(Loc, BufEnd, P, SA);
+  else if (Type == R_X86_64_TLSLD)
+    SkipRel += relocateTlsLdToLe(Loc, BufEnd, P, SA);
+  else if (Type == R_X86_64_TLSGD)
+    SkipRel += relocateTlsGdToLe(Loc, BufEnd, P, SA);
+  else if (Type == R_X86_64_DTPOFF32)
+    relocateOne(Loc, BufEnd, R_X86_64_TPOFF32, P, SA);
+  else
+    error("Unknown TLS optimization");
+  return SkipRel;
+}
----------------
ruiu wrote:
>   switch (Type) {
>   case R_X86_64_GOTTPOFF:
>     relocateTlsIeToLe(...);
>     return 0;
>   case R_X86_64_TLSLD:
>     relocateTlsLdToLe(...);
>     return 1;
>   case ...
>   }
Done.


http://reviews.llvm.org/D14870





More information about the llvm-commits mailing list