From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id 943933857C5B; Fri, 1 Oct 2021 08:59:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 943933857C5B MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9050] Fix ICE with stack checking emulation at -O2 X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 618b7cb3b3fb4d2d92434d31ea8b6746ffef2572 X-Git-Newrev: 3aaa884141f832b9a678d44a80e2ececfc9fc090 Message-Id: <20211001085917.943933857C5B@sourceware.org> Date: Fri, 1 Oct 2021 08:59:17 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Oct 2021 08:59:17 -0000 https://gcc.gnu.org/g:3aaa884141f832b9a678d44a80e2ececfc9fc090 commit r11-9050-g3aaa884141f832b9a678d44a80e2ececfc9fc090 Author: Eric Botcazou Date: Fri Oct 1 10:56:45 2021 +0200 Fix ICE with stack checking emulation at -O2 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. gcc/ * explow.c: Include langhooks.h. (set_stack_check_libfunc): Build a proper function type. Diff: --- gcc/explow.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); }