[PATCH] D58336: [X86] Fix tls variable lowering issue with large code model

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 22 16:05:11 PST 2019


rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm



================
Comment at: test/CodeGen/X86/code-model-elf.ll:411
+; LARGE-PIC:       # %bb.0:
+; LARGE-PIC-NEXT:    movq    thread_data at GOTTPOFF(%rip), %rax
+; LARGE-PIC-NEXT:    movl    %fs:(%rax), %eax
----------------
LuoYuanke wrote:
> rnk wrote:
> > Wouldn't this load need to be through the PIC register?
> Seems no, because in the test case, it specify the pie option "!2 = !{i32 7, !"PIE Level", i32 2}". We can generate the same result with gcc.
> 
> bash-4.2$ cat t.c
> extern __thread int x;
> int f(void) { return x; }
> 
> 
> bash-4.2$ gcc -S -fpic -fpie t.c -mcmodel=large -o -
>         .file   "t.c"
>         .text
>         .globl  f
>         .type   f, @function
> f:
> .LFB0:
>         .cfi_startproc
>         pushq   %rbp
>         .cfi_def_cfa_offset 16
>         .cfi_offset 6, -16
>         movq    %rsp, %rbp
>         .cfi_def_cfa_register 6
>         movq    x at gottpoff(%rip), %rax
>         movl    %fs:(%rax), %eax
>         popq    %rbp
>         .cfi_def_cfa 7, 8
>         ret
>         .cfi_endproc
> .LFE0:
>         .size   f, .-f
>         .ident  "GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-16)"
>         .section        .note.GNU-stack,"", at progbits
Hm, perhaps we really ought to fix the "PIC" checks to say "PIE".


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58336/new/

https://reviews.llvm.org/D58336





More information about the llvm-commits mailing list