From: Eric Botcazou <ebotcazou@adacore.com>
To: gcc-patches@gcc.gnu.org
Subject: Fix stack checking emulation in Ada
Date: Sat, 12 Mar 2016 11:34:00 -0000 [thread overview]
Message-ID: <1938312.i6lz6spdUS@polaris> (raw)
[-- Attachment #1: Type: text/plain, Size: 1520 bytes --]
When stack checking cannot be done by means of probes, typically because of
the lack of MMU, the Ada compiler emulates it in the runtime (that's required
if you want to pass the ACATS testsuite) through calls to a specific routine.
Now calls to this routine are emitted as libcalls and libcalls are ECF_NOTHROW
by default:
/* By default, library functions cannot throw. */
flags = ECF_NOTHROW;
so this is problematic with optimization enabled because the compiler needs to
catch the Storage_Error exception for ACATS. That's why the attached patch
changes probe_stack_range to use a LCT_THROW libcall instead and also tweaks
emit_library_call_value_1 not to set ECF_NORETURN for it (the stack checking
routine obviously returns most of the time and throws only exceptionally).
This only affects the Ada compiler since stack_check_libfunc is set only in
Ada and LCT_THROW has been unused since 2009. That's an old issue which
recently resurfaced under PR ada/70017 because s390/Linux was still using
stack checking emulation; the PR was addressed for GCC 6 by switching to real
stack checking but I have applied the patch on the mainline for the other
platforms still using emulation, after testing it on x86-64/Linux.
2016-03-12 Eric Botcazou <ebotcazou@adacore.com>
PR ada/70017
* calls.c (emit_library_call_value_1): Clear the ECF_NOTHROW flag if
the libcall is LCT_THROW.
* explow.c (probe_stack_range): Pass LCT_THROW to emit_library_call
for the checking routine.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1169 bytes --]
Index: calls.c
===================================================================
--- calls.c (revision 234098)
+++ calls.c (working copy)
@@ -3852,7 +3852,7 @@ emit_library_call_value_1 (int retval, r
reg_parm_stack_space = REG_PARM_STACK_SPACE ((tree) 0);
#endif
- /* By default, library functions can not throw. */
+ /* By default, library functions cannot throw. */
flags = ECF_NOTHROW;
switch (fn_type)
@@ -3869,7 +3869,7 @@ emit_library_call_value_1 (int retval, r
flags |= ECF_NORETURN;
break;
case LCT_THROW:
- flags = ECF_NORETURN;
+ flags &= ~ECF_NOTHROW;
break;
case LCT_RETURNS_TWICE:
flags = ECF_RETURNS_TWICE;
Index: explow.c
===================================================================
--- explow.c (revision 234098)
+++ explow.c (working copy)
@@ -1566,7 +1566,7 @@ probe_stack_range (HOST_WIDE_INT first,
stack_pointer_rtx,
plus_constant (Pmode,
size, first)));
- emit_library_call (stack_check_libfunc, LCT_NORMAL, VOIDmode, 1, addr,
+ emit_library_call (stack_check_libfunc, LCT_THROW, VOIDmode, 1, addr,
Pmode);
}
reply other threads:[~2016-03-12 11:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1938312.i6lz6spdUS@polaris \
--to=ebotcazou@adacore.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).