public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Avoid ICE with m68k-elf -malign-int and libcalls
@ 2024-01-04  9:23 Mikael Pettersson
  2024-01-04 21:39 ` Jeff Law
  0 siblings, 1 reply; 5+ messages in thread
From: Mikael Pettersson @ 2024-01-04  9:23 UTC (permalink / raw)
  To: gcc-patches; +Cc: Mikael Pettersson

emit_library_call_value_1 calls emit_push_insn with NULL_TREE
for TYPE.  Sometimes emit_push_insn needs to assign a temp with
that TYPE, which causes a segfault.

Fixed by computing the TYPE from MODE when needed.

Original patch by Thorsten Otto.

gcc/

2024-01-03  Thorsten Otto  <admin@tho-otto.de>
            Mikael Pettersson  <mikpelinux@gmail.com>

	PR target/82420
	PR target/111279
	* expr.cc (emit_push_insn): If TYPE is NULL compute it
	from MODE before calling assign_temp.

gcc/teststuite/

2024-01-03  Mikael Pettersson  <mikpelinux@gmail.com>

	PR target/82420
	* gcc.target/m68k/pr82420.c: New test.
---
 gcc/expr.cc                             | 6 +++++-
 gcc/testsuite/gcc.target/m68k/pr82420.c | 9 +++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/m68k/pr82420.c

diff --git a/gcc/expr.cc b/gcc/expr.cc
index 9fef2bf6585..7ab80ef176c 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -5304,7 +5304,11 @@ emit_push_insn (rtx x, machine_mode mode, tree type, rtx size,
 	  size = gen_int_mode (GET_MODE_SIZE (mode), Pmode);
 	  if (!MEM_P (xinner))
 	    {
-	      temp = assign_temp (type, 1, 1);
+	      tree atype = type;
+
+	      if (atype == NULL_TREE)
+		atype = lang_hooks.types.type_for_mode (mode, 0);
+	      temp = assign_temp (atype, 1, 1);
 	      emit_move_insn (temp, xinner);
 	      xinner = temp;
 	    }
diff --git a/gcc/testsuite/gcc.target/m68k/pr82420.c b/gcc/testsuite/gcc.target/m68k/pr82420.c
new file mode 100644
index 00000000000..5c84f292103
--- /dev/null
+++ b/gcc/testsuite/gcc.target/m68k/pr82420.c
@@ -0,0 +1,9 @@
+/* { do-do compile } */
+/* { dg-options "-march=68000 -malign-int" } */
+
+int a;
+
+void f(void)
+{
+    a /= 3;
+}
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-21 23:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-04  9:23 [PATCH] Avoid ICE with m68k-elf -malign-int and libcalls Mikael Pettersson
2024-01-04 21:39 ` Jeff Law
2024-01-16 16:55   ` Mikael Pettersson
2024-01-16 16:55     ` Mikael Pettersson
2024-01-21 23:00     ` Jeff Law

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).