[PATCH] D14870: [ELF2] - Implemented optimizations for @tlsld and @tlsgd
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 25 10:13:03 PST 2015
ruiu 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));
----------------
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.
================
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,
----------------
Please do not use int8_t just because it returns a small integer. If no specific size is in mind, use int.
================
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:
> 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.
================
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;
+}
----------------
switch (Type) {
case R_X86_64_GOTTPOFF:
relocateTlsIeToLe(...);
return 0;
case R_X86_64_TLSLD:
relocateTlsLdToLe(...);
return 1;
case ...
}
http://reviews.llvm.org/D14870
More information about the llvm-commits
mailing list