aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2023-11-24 16:11:27 +0100
committerUros Bizjak <ubizjak@gmail.com>2023-11-24 16:11:27 +0100
commit404ea4c1381398aee162415a88e5cb81c44f8c69 (patch)
tree0d575db632c4000aea05bc0533a4e061e9ac4458 /gcc
parent449b6b817ed76173e6475debd02b195ea9dab0a0 (diff)
downloadgcc-404ea4c1381398aee162415a88e5cb81c44f8c69.zip
gcc-404ea4c1381398aee162415a88e5cb81c44f8c69.tar.gz
gcc-404ea4c1381398aee162415a88e5cb81c44f8c69.tar.bz2
i386: Fix ICE with -fsplit-stack -mcmodel=large [PR112686]
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/i386/i386.cc9
-rw-r--r--gcc/testsuite/gcc.target/i386/pr112686.c5
2 files changed, 10 insertions, 4 deletions
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 7b92285..9390f52 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 0000000..858e91b
--- /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) {}