public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/110533] [x86-64] naked with -O0 and register-passed struct/int128 clobbers parameters/callee-saved regs
Date: Tue, 04 Jul 2023 08:47:00 +0000	[thread overview]
Message-ID: <bug-110533-4-R534ciAM7g@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110533-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> >clobbering other parameters and callee-saved registers.
> 
> 
> (insn 2 8 3 2 (set (reg:DI 84)
>         (reg:DI 5 di [ aD.2522 ])) "/app/example.cpp":3:25 -1
>      (nil))
> (insn 3 2 4 2 (set (reg:DI 85)
>         (reg:DI 4 si [ aD.2522+8 ])) "/app/example.cpp":3:25 -1
>      (nil))
> (insn 4 3 5 2 (set (reg:TI 83)
>         (subreg:TI (reg:DI 84) 0)) "/app/example.cpp":3:25 -1
>      (nil))
> (insn 5 4 6 2 (set (subreg:DI (reg:TI 83) 8)
>         (reg:DI 85)) "/app/example.cpp":3:25 -1
>      (nil))
> (insn 6 5 7 2 (set (reg/v:TI 82 [ aD.2522 ])
>         (reg:TI 83)) "/app/example.cpp":3:25 -1
>      (nil))

This is emitted by middle-end to reconstruct a function argument in cases when
argument is passed via multiple registers. Function argument is specified by
the same hook that is used for the caller and the callee, so it is not possible
to simple disable it for naked functions.

When -O2 is used, optimizers figure out that the reconstructed value is unused
and remove the whole reconstruction sequence. This is unfortunately not the
case with -O0.

So, middle-end should provide some sort of mechanism to suppress the generation
of reconstruction sequence. The above sequence is emitted in
function.cc/assign_parm_remove_parallels, but similar functionality can
probably be found elsewhere in the function handling code.

Or only pass simple arguments to naked function. Naked functions are
specialist's tool, not intended for "general public".

  parent reply	other threads:[~2023-07-04  8:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03 12:35 [Bug target/110533] New: " engelke at in dot tum.de
2023-07-03 20:17 ` [Bug target/110533] " pinskia at gcc dot gnu.org
2023-07-04  8:47 ` ubizjak at gmail dot com [this message]
2023-07-06 12:27 ` roger at nextmovesoftware dot com
2023-07-07 19:41 ` cvs-commit at gcc dot gnu.org
2023-07-22 20:55 ` cvs-commit 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-110533-4-R534ciAM7g@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).