public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ardb at kernel dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/102926] TLS register value is spilled to the stack instead of reloaded from the system register
Date: Mon, 25 Oct 2021 14:46:49 +0000	[thread overview]
Message-ID: <bug-102926-4-YHdTtrw1WW@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102926-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Ard Biesheuvel <ardb at kernel dot org> ---
Actually, I can reproduce the same behavior without the TLS register, where the
result of a MOVW/MOVT immediate assignment is also spilled to the stack.

    int ll[2];
    int foo(int);
    int bar(void)
    {
        int *l = ll;

        return foo(l[0]) + l[1];
    }

will produce this for armv7-a (with [r4-r11] fixed)

        push    {fp, lr}
        movw    r3, #:lower16:.LANCHOR0
        movt    r3, #:upper16:.LANCHOR0
        add     fp, sp, #4
        sub     sp, sp, #8
        ldr     r0, [r3]
        str     r3, [fp, #-8]
        bl      foo
        ldr     r3, [fp, #-8]
        ldr     r3, [r3, #4]
        add     r0, r0, r3
        sub     sp, fp, #4
        @ sp needed
        pop     {fp, pc}

whereas pre-v7 gives me

        ldr     r3, .L4
        push    {fp, lr}
        add     fp, sp, #4
        ldr     r0, [r3]
        bl      foo
        ldr     r3, .L4
        ldr     r3, [r3, #4]
        add     r0, r0, r3
        pop     {fp, pc}

i.e., the address is simply reloaded from the literal pool rather than spilled.

  parent reply	other threads:[~2021-10-25 14:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25 11:35 [Bug target/102926] New: " ardb at kernel dot org
2021-10-25 11:50 ` [Bug target/102926] " pinskia at gcc dot gnu.org
2021-10-25 12:02 ` rguenth at gcc dot gnu.org
2021-10-25 12:03 ` ardb at kernel dot org
2021-10-25 12:12 ` pinskia at gcc dot gnu.org
2021-10-25 14:46 ` ardb at kernel dot org [this message]
2021-10-25 15:24 ` rsandifo at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-102926-4-YHdTtrw1WW@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).