public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [committed] i386: Fix ICE with -fsplit-stack -mcmodel=large [PR112686]
Date: Fri, 24 Nov 2023 17:33:50 +0100	[thread overview]
Message-ID: <CAFULd4Zc_D8r1Hhg7hdKm1dyutf1j1kwNMZUOXin03o5nMLOnw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 381 bytes --]

For -mcmodel=large, we have to load function address to a register.

    PR target/112686

gcc/ChangeLog:

    * config/i386/i386.cc (ix86_expand_split_stack_prologue): Load
    function address to a register for ix86_cmodel == CM_LARGE.

gcc/testsuite/ChangeLog:

    * gcc.target/i386/pr112686.c: New test.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1651 bytes --]

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 7b922857d80..9390f525b99 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -10481,6 +10481,8 @@ ix86_expand_split_stack_prologue (void)
 	      SYMBOL_REF_FLAGS (split_stack_fn_large) |= SYMBOL_FLAG_LOCAL;
 	    }
 
+	  fn = split_stack_fn_large;
+
 	  if (ix86_cmodel == CM_LARGE_PIC)
 	    {
 	      rtx_code_label *label;
@@ -10494,16 +10496,15 @@ ix86_expand_split_stack_prologue (void)
 	      emit_insn (gen_set_rip_rex64 (reg10, label));
 	      emit_insn (gen_set_got_offset_rex64 (reg11, label));
 	      emit_insn (gen_add2_insn (reg10, reg11));
-	      x = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, split_stack_fn_large),
-				  UNSPEC_GOT);
+	      x = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, fn), UNSPEC_GOT);
 	      x = gen_rtx_CONST (Pmode, x);
 	      emit_move_insn (reg11, x);
 	      x = gen_rtx_PLUS (Pmode, reg10, reg11);
 	      x = gen_const_mem (Pmode, x);
 	      fn = copy_to_suggested_reg (x, reg11, Pmode);
 	    }
-	  else
-	    fn = split_stack_fn_large;
+	  else if (ix86_cmodel == CM_LARGE)
+	    fn = copy_to_suggested_reg (fn, reg11, Pmode);
 
 	  /* When using the large model we need to load the address
 	     into a register, and we've run out of registers.  So we
diff --git a/gcc/testsuite/gcc.target/i386/pr112686.c b/gcc/testsuite/gcc.target/i386/pr112686.c
new file mode 100644
index 00000000000..858e91ba727
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr112686.c
@@ -0,0 +1,5 @@
+/* PR target/112686 */
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-fsplit-stack -mcmodel=large" } */
+
+void foo (void) {}

             reply	other threads:[~2023-11-24 16:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-24 16:33 Uros Bizjak [this message]
2023-11-26 10:51 FX Coudert

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=CAFULd4Zc_D8r1Hhg7hdKm1dyutf1j1kwNMZUOXin03o5nMLOnw@mail.gmail.com \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@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).