From d10c4e07f50fefd90342ee78e4ce85a32aa61200 Mon Sep 17 00:00:00 2001 From: Sriraman Tallam Date: Thu, 31 May 2018 18:12:33 +0000 Subject: [PATCH] Relax GOTPCREL relocations for tail jmp instructions. Differential Revision: https://reviews.llvm.org/D47563 llvm-svn: 333676 --- llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp | 1 + .../test/CodeGen/X86/tailjmp_gotpcrel_relax_relocation.ll | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 llvm/test/CodeGen/X86/tailjmp_gotpcrel_relax_relocation.ll diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp index 9e2d622..7e43417 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp @@ -399,6 +399,7 @@ void X86MCCodeEmitter::emitMemModRMByte(const MCInst &MI, unsigned Op, 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: diff --git a/llvm/test/CodeGen/X86/tailjmp_gotpcrel_relax_relocation.ll b/llvm/test/CodeGen/X86/tailjmp_gotpcrel_relax_relocation.ll new file mode 100644 index 0000000..3fb161c --- /dev/null +++ b/llvm/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 } -- 2.7.4