public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "lukas.graetz@tu-darmstadt.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/111896] call with wrong stack alignment
Date: Fri, 20 Oct 2023 16:02:47 +0000	[thread overview]
Message-ID: <bug-111896-4-C5Xv5stZht@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111896-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Lukas Grätz <lukas.graetz@tu-darmstadt.de> ---
(In reply to Andrew Pinski from comment #1)
> No I think you are looking into the wrong location.
> 
> When a call happens, it pushes a value on the stack aligning the stack that
> is incoming into that function.
> 
> In the case of GCC 11.3 and above, there is inlining happening.

Well, I could be mistaken. But I couldn't see the inlining.

In GCC 11.3 and above I get something like:
======================
dlist_free_original.constprop.0:
        push    rbp
        push    rbx
...
        sub     rsp, 8
...
        call    do_line
======================

In GCC 11.2 and below it is something like:
=====================
dlist_free_original.constprop.0:
        push    rbp
...
        push    rbx
...
        call    do_line
===================

And I checked with the gdb debugger that the rsp is indeed misaligned at the
start of do_line(). The alignment was OK at the start of
"dlist_free_original.constprop.0".

======================
$ gdb busybox_unstripped
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
...
(gdb) break dlist_free_original.constprop.0
Breakpoint 1 at 0x59a7ac
(gdb) break do_line
Breakpoint 2 at 0x59a474
(gdb) run patch -R -i input.patch

Breakpoint 1, 0x000000000059a7ac in dlist_free_original.constprop ()
(gdb) i r rsp
rsp            0x7fffffffd998      0x7fffffffd998
(gdb) c
Continuing.

Breakpoint 2, 0x000000000059a474 in do_line ()
(gdb) i r rsp
rsp            0x7fffffffd980      0x7fffffffd980
======================

  parent reply	other threads:[~2023-10-20 16:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-20 14:29 [Bug c/111896] New: " lukas.graetz@tu-darmstadt.de
2023-10-20 15:33 ` [Bug target/111896] " pinskia at gcc dot gnu.org
2023-10-20 16:02 ` lukas.graetz@tu-darmstadt.de [this message]
2023-10-20 16:31 ` pinskia at gcc dot gnu.org
2023-10-20 16:34 ` pinskia at gcc dot gnu.org
2023-10-20 16:35 ` lukas.graetz@tu-darmstadt.de

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-111896-4-C5Xv5stZht@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).