public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/99234] [10/11 regression] wrong result for 1.0/3.0 with -O2 -fno-omit-frame-pointer -frounding-math
Date: Mon, 01 Mar 2021 07:12:57 +0000	[thread overview]
Message-ID: <bug-99234-4-0YQDWjYpTa@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99234-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #21 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Eric Botcazou
<ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:838adf69533ca15a259d47dd67e056c4101af368

commit r9-9258-g838adf69533ca15a259d47dd67e056c4101af368
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Mon Mar 1 07:53:05 2021 +0100

    Fix wrong result for 1.0/3.0 at -O2 -fno-omit-frame-pointer -frounding-math

    This wrong-code PR for the C++ compiler on x86-64/Windows is a regression
    in GCC 9 and later, but the underlying issue has probably been there since
    SEH was implemented and is exposed by this comment in config/i386/winnt.c:

      /* SEH records saves relative to the "current" stack pointer, whether
         or not there's a frame pointer in place.  This tracks the current
         stack pointer offset from the CFA.  */
      HOST_WIDE_INT sp_offset;

    That's not what the (current) Microsoft documentation says; instead it
says:

      /* SEH records offsets relative to the lowest address of the fixed stack
         allocation.  If there is no frame pointer, these offsets are from the
         stack pointer; if there is a frame pointer, these offsets are from the
         value of the stack pointer when the frame pointer was established,
i.e.
         the frame pointer minus the offset in the .seh_setframe directive.  */

    That's why the implementation is correct only under the condition that the
    frame pointer be established *after* the fixed stack allocation; as a
matter
    of fact, that's clearly the model underpinning SEH, but is the opposite of
    what is done e.g. on Linux.

    However the issue is mostly papered over in practice because:

      1. SEH forces use_fast_prologue_epilogue to false, which in turns forces
    save_regs_using_mov to false, so the general regs are always pushed when
    they need to be saved, which eliminates the offset computation for them.

      2. As soon as a frame is larger than 240 bytes, the frame pointer is
fixed
    arbitrarily to 128 bytes above the stack pointer, which of course requires
    that it be established after the fixed stack allocation.

    So you need a small frame clobbering one of the call-saved XMM registers in
    order to generate wrong SEH unwind info.

    The attached fix makes sure that the frame pointer is always established
    after the fixed stack allocation by pointing it at or below the lowest used
    register save area, i.e. the SSE save area, and removing the special early
    saves in the prologue; the end result is a uniform prologue sequence for
    SEH whatever the frame size.  And it avoids a discrepancy between cases
    where the number of saved general regs is even and cases where it is odd.

    gcc/
            PR target/99234
            * config/i386/i386.c (ix86_compute_frame_layout): For a SEH target,
            point the hard frame pointer to the SSE register save area instead
            of the general register save area.  Perform only minimal adjustment
            for small frames if it is initially not correctly aligned.
            (ix86_expand_prologue): Remove early saves for a SEH target.
            * config/i386/winnt.c (struct seh_frame_state): Document
constraint.
    gcc/testsuite/
            * g++.dg/eh/seh-xmm-unwind.C: New test.

  parent reply	other threads:[~2021-03-01  7:12 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24  1:07 [Bug c++/99234] New: Regression: wrong result for 1.0/3.0 when -fno-omit-frame-pointer -frounding-math used together vz-gcc at zeitlins dot org
2021-02-24 15:54 ` [Bug target/99234] " jakub at gcc dot gnu.org
2021-02-24 16:19 ` vz-gcc at zeitlins dot org
2021-02-24 16:19 ` vz-gcc at zeitlins dot org
2021-02-24 16:23 ` vz-gcc at zeitlins dot org
2021-02-24 16:25 ` vz-gcc at zeitlins dot org
2021-02-25  8:56 ` jakub at gcc dot gnu.org
2021-02-25  9:34 ` ebotcazou at gcc dot gnu.org
2021-02-25  9:36 ` [Bug target/99234] [10/11 regression] wrong result for 1.0/3.0 with -O2 -fno-omit-frame-pointer -frounding-math ebotcazou at gcc dot gnu.org
2021-02-25  9:36 ` ebotcazou at gcc dot gnu.org
2021-02-25 12:07 ` jyong at gcc dot gnu.org
2021-02-25 12:35 ` ebotcazou at gcc dot gnu.org
2021-02-25 14:25 ` lh_mouse at 126 dot com
2021-02-25 18:18 ` ebotcazou at gcc dot gnu.org
2021-02-26  0:36 ` ebotcazou at gcc dot gnu.org
2021-02-26  6:00 ` lh_mouse at 126 dot com
2021-02-26  8:27 ` lh_mouse at 126 dot com
2021-02-26  9:17 ` ebotcazou at gcc dot gnu.org
2021-02-26 10:18 ` jakub at gcc dot gnu.org
2021-02-26 11:04 ` lh_mouse at 126 dot com
2021-03-01  6:59 ` cvs-commit at gcc dot gnu.org
2021-03-01  7:00 ` cvs-commit at gcc dot gnu.org
2021-03-01  7:12 ` cvs-commit at gcc dot gnu.org [this message]
2021-03-01  7:13 ` ebotcazou at gcc dot gnu.org
2021-03-01 11:49 ` vz-gcc at zeitlins dot org
2021-03-03 11:30 ` cvs-commit at gcc dot gnu.org
2021-03-03 11:31 ` cvs-commit at gcc dot gnu.org
2021-03-03 11:34 ` cvs-commit at gcc dot gnu.org
2021-05-05 20:55 ` cvs-commit at gcc dot gnu.org
2021-05-05 20:56 ` cvs-commit at gcc dot gnu.org
2021-05-05 20:58 ` cvs-commit at gcc dot gnu.org
2021-05-05 21:01 ` 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-99234-4-0YQDWjYpTa@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).