From 9d0e94c16e862475dadd3dd81e1386beaf633fc1 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Mon, 14 Oct 2013 21:52:26 +0000 Subject: [PATCH] Revert part of a fix from 2010, changes since then: a) x86-64 TLS has been documented b) the code path should use movq for the correct relocation to be generated. I've also added a fixme for the test case that we should improve the code generated, it should look something like is documented in the tls abi document. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192631 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86InstrCompiler.td | 2 +- test/CodeGen/X86/x86-64-tls-1.ll | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Target/X86/X86InstrCompiler.td b/lib/Target/X86/X86InstrCompiler.td index f62d68ce293..9e1cdc90571 100644 --- a/lib/Target/X86/X86InstrCompiler.td +++ b/lib/Target/X86/X86InstrCompiler.td @@ -969,7 +969,7 @@ def : Pat<(store (i64 (X86Wrapper tblockaddress:$src)), addr:$dst), // tls has some funny stuff here... // This corresponds to movabs $foo@tpoff, %rax def : Pat<(i64 (X86Wrapper tglobaltlsaddr :$dst)), - (MOV64ri tglobaltlsaddr :$dst)>; + (MOV64ri32 tglobaltlsaddr :$dst)>; // This corresponds to add $foo@tpoff, %rax def : Pat<(add GR64:$src1, (X86Wrapper tglobaltlsaddr :$dst)), (ADD64ri32 GR64:$src1, tglobaltlsaddr :$dst)>; diff --git a/test/CodeGen/X86/x86-64-tls-1.ll b/test/CodeGen/X86/x86-64-tls-1.ll index 8d3b300da3b..fee712d30b6 100644 --- a/test/CodeGen/X86/x86-64-tls-1.ll +++ b/test/CodeGen/X86/x86-64-tls-1.ll @@ -1,6 +1,10 @@ ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s @tm_nest_level = internal thread_local global i32 0 define i64 @z() nounwind { -; CHECK: movabsq $tm_nest_level@TPOFF, %rcx +; FIXME: The codegen here is primative at best and could be much better. +; The add and the moves can be folded together. +; CHECK: movq $tm_nest_level@TPOFF, %rcx +; CHECK: movq %fs:0, %rax +; CHECK: addl %ecx, %eax ret i64 and (i64 ptrtoint (i32* @tm_nest_level to i64), i64 100) }