[JITLink] Optimize GOTPCRELX Relocations
authorluxufan <932494295@qq.com>
Thu, 19 Aug 2021 02:13:40 +0000 (10:13 +0800)
committerluxufan <932494295@qq.com>
Thu, 19 Aug 2021 02:30:22 +0000 (10:30 +0800)
commita9095f005fdae510fc262f13431c710e3217a0d0
treeb27126be9d9f370818e410d7478b5fe2b0100006
parent08dbed8a5725087a7be71c293e4d86ca0c4c0510
[JITLink] Optimize GOTPCRELX Relocations

This patch optimize the GOTPCRELX Reloations, which is described in X86-64 psabi chapter B.2. And Not all optimization of this chapter is implemented.

1. Convert call and jmp has been implemented
2. Convert mov, but the optimization that when the symbol is defined in the lower 32-bit address space, memory operand in `mov` can be convertted into immediate operand has not been implemented.
3. Conver Test and Binop has not been implemented.

The new test file named ELF_got_plt_optimizations.s has been added, and I moved some test cases about optimization of got/plt from ELF_x86_64_small_pic_relocations.s to the new test file.

By referencing the lld, so, the optimization `Convert call and jmp` is not same as what psabi says, and I have explained it in the comment.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D108280
llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h
llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
llvm/lib/ExecutionEngine/JITLink/x86_64.cpp
llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_common.s
llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_got_plt_optimizations.s [new file with mode: 0644]
llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_small_pic_relocations.s