[PATCH] D14713: [ELF2] - Optimization for R_X86_64_GOTTPOFF relocation.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 16 10:06:09 PST 2015
ruiu added inline comments.
================
Comment at: ELF/InputSection.cpp:150-154
@@ -149,3 +149,7 @@
continue;
+ } else if (Body.isTLS() &&
+ Target->getTlsOptimization(Type, Body) == TargetInfo::ToLE) {
+ Target->relocateTlsToLe(BufLoc, BufEnd, Type, AddrLoc, SymVA);
+ continue;
}
Target->relocateOne(BufLoc, BufEnd, Type, AddrLoc,
----------------
Can you move this above line 137 just like "if (Target->isTlsGlobalDynamicReloc(Type)) { ... }"?
Also, do you think you can merge getTlsOptimization and relocateTlsToLe into one function? I'd probably write like this.
// Some TLS relocations are always compiled to use GOT, but the linker
// is sometimes able to rewrite it so that it doesn't use GOT. This may not
// only apply relocations but also modify preceding instructions.
if (applyOptimizeTls(BufLoc, Type, AddrLoc, Body))
continue;
================
Comment at: ELF/Target.cpp:356
@@ +355,3 @@
+
+void X86_64TargetInfo::relocateTlsToLe(uint8_t *Loc, uint8_t *BufEnd,
+ uint32_t Type, uint64_t P,
----------------
Please add a reference to Ulrich's document.
================
Comment at: ELF/Target.cpp:362-368
@@ +361,9 @@
+ uint8_t Reg = Loc[-1] >> 3;
+ // Originally it can be one of two:
+ // 1) movq foo at gottpoff(%rip), %reg
+ // We change it into one of:
+ // movq $foo, %reg
+ // addq $foo, %rsp (addressing with %rsp is special).
+ // 2) addq foo at gottpoff(%rip), %reg
+ // We change it into leaq foo(%reg), %reg.
+ bool RspAdd = (Ins != 0x8b && Reg == 4);
----------------
grimar wrote:
> I dont sure what to do here. How to check out of bound for negative idx. Should I check (will need BufBegin arg I guess) or we can assume its never be out ?
Is that actually a possible scenario that one wants to add a TLS value to SP register? Do you have to take care of that?
================
Comment at: ELF/Target.h:61
@@ -59,2 +60,3 @@
uint64_t P, uint64_t SA) const = 0;
-
+ virtual TlsOpt getTlsOptimization(unsigned Type, const SymbolBody &S) const;
+ virtual void relocateTlsToLe(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
----------------
Currently it only returns None or ToLE, so can you change the signature of the function so that it returns a boolean value?
http://reviews.llvm.org/D14713
More information about the llvm-commits
mailing list