[PATCH] D15779: [ELF] - Implemented optimization for R_X86_64_GOTPCREL relocation.
Rafael Ávila de Espíndola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 19 07:10:08 PST 2016
rafael added a comment.
One thing to keep in mind is the possibility of overflow (https://sourceware.org/bugzilla/show_bug.cgi?id=18591). No need to handle it now since llvm is also broken (pr 26208). I will try to fix the LLVM, at which point we should probably check for overflows in lld.
================
Comment at: ELF/Target.cpp:698
@@ +697,3 @@
+// R_X86_64_GOTPCREL if we perform additional check of instructions. Both gold
+// and bfd do the same.
+bool X86_64TargetInfo::canOptimizeGotPcRel(uint32_t Type, const SymbolBody &S,
----------------
Update the comment to say that we can do mov -> lea with R_X86_64_GOTPCREL, but we need R_X86_64_GOTPCRELX for the other optimizations
================
Comment at: ELF/Target.cpp:702
@@ +701,3 @@
+ uint64_t Off) const {
+ if (Type != R_X86_64_GOTPCREL || Off <= 2 || isGnuIFunc<ELF64LE>(S))
+ return false;
----------------
Could canBePreempted take care of the ifunc check?
================
Comment at: ELF/Target.cpp:955
@@ -906,1 +954,3 @@
case R_X86_64_GOTPCREL:
+ if (S && canOptimizeGotPcRel(Type, *S, Loc, (uint64_t)-1))
+ optimizeGotPcRel(Loc);
----------------
You are passing -1 in here because the offset is not available, correct?
Is there any point in ever passing the offset if we cannot pass it here?
http://reviews.llvm.org/D15779
More information about the llvm-commits
mailing list