[PATCH] D47563: Relax GOTPCREL relocations for tail jmp instructions
Sriraman Tallam via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 30 16:03:45 PDT 2018
tmsriram created this revision.
tmsriram added a reviewer: rnk.
R_X86_64_GOTPCREL is not relaxed if opcode is a 64-bit tail jmp.
foo.c
extern int foo();
int main() {
return foo();
}
$ clang -O2 -fno-plt -mrelax-relocations=yes foo.cc -c
$ objdump -dr foo.o
0000000000000000 <main>:
0: ff 25 00 00 00 00 jmpq *0x0(%rip) # 6 <main+0x6>
2: R_X86_64_GOTPCREL foo-0x4
Adding --save-temps to the above command-line will generate R_X86_64_GOTPCRELX
This is because in the former case, opcode is JMP64m but in the latter case it is a TAILJMPm64.
Repository:
rL LLVM
https://reviews.llvm.org/D47563
Files:
lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
test/CodeGen/X86/tailjmp_gotpcrel_relax_relocation.ll
Index: test/CodeGen/X86/tailjmp_gotpcrel_relax_relocation.ll
===================================================================
--- test/CodeGen/X86/tailjmp_gotpcrel_relax_relocation.ll
+++ test/CodeGen/X86/tailjmp_gotpcrel_relax_relocation.ll
@@ -0,0 +1,15 @@
+; RUN: llc -filetype=obj -relax-elf-relocations=true -mtriple=x86_64-linux-gnu -o - %s | llvm-objdump - -d -r | FileCheck %s
+
+; CHECK: jmpq *(%rip)
+; CHECK-NEXT: R_X86_64_GOTPCRELX
+
+define i32 @main() {
+entry:
+ %call = tail call i32 @foo()
+ ret i32 %call
+}
+
+; Function Attrs: nonlazybind
+declare i32 @foo() #1
+
+attributes #1 = { nonlazybind }
Index: lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
===================================================================
--- lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
+++ lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
@@ -399,6 +399,7 @@
return X86::reloc_riprel_4byte_movq_load;
case X86::CALL64m:
case X86::JMP64m:
+ case X86::TAILJMPm64:
case X86::TEST64mr:
case X86::ADC64rm:
case X86::ADD64rm:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47563.149213.patch
Type: text/x-patch
Size: 1083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180530/412731db/attachment.bin>
More information about the llvm-commits
mailing list