public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113874] New: GNU2 TLS descriptor calls do not follow psABI on x86_64-linux-gnu
@ 2024-02-11 13:59 fw at gcc dot gnu.org
  2024-02-11 14:03 ` [Bug target/113874] " fw at gcc dot gnu.org
                   ` (39 more replies)
  0 siblings, 40 replies; 41+ messages in thread
From: fw at gcc dot gnu.org @ 2024-02-11 13:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113874

            Bug ID: 113874
           Summary: GNU2 TLS descriptor calls do not follow psABI on
                    x86_64-linux-gnu
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fw at gcc dot gnu.org
  Target Milestone: ---
            Target: x86_64-linux-gnu

Consider this test case:

struct tls {
  long a, b, c, d;
};

extern __thread struct tls tls_var __attribute__ ((visibility ("hidden")));

void
apply_tls (struct tls *p)
{
  tls_var = *p;
}

With “-O2 -fpic -mtls-dialect=gnu2“, it gets compiled to:

apply_tls:
.LFB0:
        .cfi_startproc
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        movdqu  (%rdi), %xmm0
        leaq    tls_var@TLSDESC(%rip), %rax
        call    *tls_var@TLSCALL(%rax)
        addq    %fs:0, %rax
        movups  %xmm0, (%rax)
        movdqu  16(%rdi), %xmm1
        movups  %xmm1, 16(%rax)
        addq    $8, %rsp
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc

Note how %xmm0 is loaded before the descriptor call. The glibc implementation
assumes psABI, so %xmm0 is potentially clobbered by the call.

Discovered as a crash in the polymake testsuite
(/fan/objects/Geometry/PolyhedralFan/properties/Combinatorics/DUAL_GRAPH) if
its dependency nauty is compiled with -mtls-dialect=gnu2.

(i686-linux-gnu has the same issue with -msse2.)

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2024-02-13  9:00 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-11 13:59 [Bug target/113874] New: GNU2 TLS descriptor calls do not follow psABI on x86_64-linux-gnu fw at gcc dot gnu.org
2024-02-11 14:03 ` [Bug target/113874] " fw at gcc dot gnu.org
2024-02-11 14:56 ` jakub at gcc dot gnu.org
2024-02-11 15:05 ` hjl.tools at gmail dot com
2024-02-11 17:57 ` hjl.tools at gmail dot com
2024-02-11 18:00 ` jakub at gcc dot gnu.org
2024-02-11 18:37 ` fw at gcc dot gnu.org
2024-02-11 19:47 ` hjl.tools at gmail dot com
2024-02-11 21:05 ` jakub at gcc dot gnu.org
2024-02-12  7:01 ` fw at gcc dot gnu.org
2024-02-12  8:53 ` rguenth at gcc dot gnu.org
2024-02-12 10:46 ` fw at gcc dot gnu.org
2024-02-12 10:53 ` jakub at gcc dot gnu.org
2024-02-12 10:53 ` jakub at gcc dot gnu.org
2024-02-12 10:56 ` rguenth at gcc dot gnu.org
2024-02-12 11:01 ` jakub at gcc dot gnu.org
2024-02-12 11:30 ` rguenth at gcc dot gnu.org
2024-02-12 11:41 ` rguenth at gcc dot gnu.org
2024-02-12 12:17 ` fw at gcc dot gnu.org
2024-02-12 12:24 ` hjl.tools at gmail dot com
2024-02-12 12:32 ` fw at gcc dot gnu.org
2024-02-12 12:37 ` hjl.tools at gmail dot com
2024-02-12 14:27 ` jakub at gcc dot gnu.org
2024-02-12 14:41 ` hjl.tools at gmail dot com
2024-02-12 14:42 ` hjl.tools at gmail dot com
2024-02-12 14:45 ` jakub at gcc dot gnu.org
2024-02-12 16:53 ` hjl.tools at gmail dot com
2024-02-12 16:59 ` jakub at gcc dot gnu.org
2024-02-12 17:02 ` hjl.tools at gmail dot com
2024-02-12 17:03 ` matz at gcc dot gnu.org
2024-02-12 17:08 ` hjl.tools at gmail dot com
2024-02-12 17:13 ` matz at gcc dot gnu.org
2024-02-12 17:15 ` hjl.tools at gmail dot com
2024-02-12 17:16 ` hjl.tools at gmail dot com
2024-02-12 17:17 ` hjl.tools at gmail dot com
2024-02-12 17:21 ` schwab@linux-m68k.org
2024-02-12 17:30 ` hjl.tools at gmail dot com
2024-02-12 17:38 ` schwab@linux-m68k.org
2024-02-13  4:19 ` hjl.tools at gmail dot com
2024-02-13  8:34 ` rguenth at gcc dot gnu.org
2024-02-13  9:00 ` nsz at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).