public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Fix ICE with stack checking emulation at -O2
@ 2021-10-01  8:16 Eric Botcazou
  2021-10-01  8:23 ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Botcazou @ 2021-10-01  8:16 UTC (permalink / raw)
  To: gcc-patches

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

Hi,

this is a regression present on mainline, 11 and 10 branches: on bare-metal 
platforms, the Ada compiler emulates stack checking (it is required by the 
language and tested by ACATS) in the runtime via the stack_check_libfunc hook 
of the RTL middle-end.  Calls to the function are generated as libcalls but 
they now require a proper function type at -O2 or above.

Tested on powerpc-elf, OK for mainline, 11 and 10 branches?


2021-10-01  Eric Botcazou  <ebotcazou@adacore.com>

	* explow.c: Include langhooks.h.
	(set_stack_check_libfunc): Build a proper function type.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 981 bytes --]

diff --git a/gcc/explow.c b/gcc/explow.c
index b6da277f689..a35423f5d16 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "recog.h"
 #include "diagnostic-core.h"
 #include "stor-layout.h"
+#include "langhooks.h"
 #include "except.h"
 #include "dojump.h"
 #include "explow.h"
@@ -1641,8 +1642,14 @@ set_stack_check_libfunc (const char *libfunc_name)
 {
   gcc_assert (stack_check_libfunc == NULL_RTX);
   stack_check_libfunc = gen_rtx_SYMBOL_REF (Pmode, libfunc_name);
+  tree ptype
+    = Pmode == ptr_mode
+      ? ptr_type_node
+      : lang_hooks.types.type_for_mode (Pmode, 1);
+  tree ftype
+    = build_function_type_list (void_type_node, ptype, NULL_TREE);
   tree decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
-			  get_identifier (libfunc_name), void_type_node);
+			  get_identifier (libfunc_name), ftype);
   DECL_EXTERNAL (decl) = 1;
   SET_SYMBOL_REF_DECL (stack_check_libfunc, decl);
 }

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

end of thread, other threads:[~2021-10-01  8:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01  8:16 [patch] Fix ICE with stack checking emulation at -O2 Eric Botcazou
2021-10-01  8:23 ` Richard Biener
2021-10-01  8:30   ` Eric Botcazou
2021-10-01  8:43     ` Richard Biener

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