public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r10-10708] i386: Fix ICE caused by ix86_emit_i387_log1p [PR105214]
Date: Tue, 10 May 2022 08:26:22 +0000 (GMT)	[thread overview]
Message-ID: <20220510082622.E654338346B3@sourceware.org> (raw)

https://gcc.gnu.org/g:39a2a85e96bc8c9f82807d143dbf8421d8a93091

commit r10-10708-g39a2a85e96bc8c9f82807d143dbf8421d8a93091
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Apr 12 09:19:11 2022 +0200

    i386: Fix ICE caused by ix86_emit_i387_log1p [PR105214]
    
    The following testcase ICEs, because ix86_emit_i387_log1p attempts to
    emit something like
      if (cond)
        some_code1;
      else
        some_code2;
    and emits a conditional jump using emit_jump_insn (standard way in
    the file) and an unconditional jump using emit_jump.
    The problem with that is that if there is pending stack adjustment,
    it isn't emitted before the conditional jump, but is before the
    unconditional jump and therefore stack is adjusted only conditionally
    (at the end of some_code1 above), which makes dwarf2 pass unhappy about it
    but is a serious wrong-code even if it doesn't ICE.
    
    This can be fixed either by emitting pending stack adjust before the
    conditional jump as the following patch does, or by not using
      emit_jump (label2);
    and instead hand inlining what that function does except for the
    pending stack adjustment, like:
      emit_jump_insn (targetm.gen_jump (label2));
      emit_barrier ();
    In that case there will be no stack adjustment in the sequence and
    it will be done later on somewhere else.
    
    2022-04-12  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/105214
            * config/i386/i386-expand.c (ix86_emit_i387_log1p): Call
            do_pending_stack_adjust.
    
            * gcc.dg/asan/pr105214.c: New test.
    
    (cherry picked from commit d481d13786cb84f6294833538133dbd6f39d2e55)

Diff:
---
 gcc/config/i386/i386-expand.c        |  5 +++++
 gcc/testsuite/gcc.dg/asan/pr105214.c | 16 ++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index cbe57fd904d..011bad04770 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -15320,6 +15320,11 @@ void ix86_emit_i387_log1p (rtx op0, rtx op1)
   rtx cst, cstln2, cst1;
   rtx_insn *insn;
 
+  /* The emit_jump call emits pending stack adjust, make sure it is emitted
+     before the conditional jump, otherwise the stack adjustment will be
+     only conditional.  */
+  do_pending_stack_adjust ();
+
   cst = const_double_from_real_value
     (REAL_VALUE_ATOF ("0.29289321881345247561810596348408353", XFmode), XFmode);
   cstln2 = force_reg (XFmode, standard_80387_constant_rtx (4)); /* fldln2 */
diff --git a/gcc/testsuite/gcc.dg/asan/pr105214.c b/gcc/testsuite/gcc.dg/asan/pr105214.c
new file mode 100644
index 00000000000..a755336c7d8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr105214.c
@@ -0,0 +1,16 @@
+/* PR target/105214 */
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */
+/* { dg-options "-Ofast -fnon-call-exceptions -fexceptions -fstack-check=generic -fsanitize=address -fno-finite-math-only -fsignaling-nans -fno-associative-math" } */
+
+float f;
+void bar (int *);
+
+void
+foo (void)
+{
+  int a[1600], b[1];
+  f += __builtin_log1pf (f);
+  bar (a);
+  bar (b);
+}


                 reply	other threads:[~2022-05-10  8:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220510082622.E654338346B3@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@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).