* Fix stack checking emulation in Ada
@ 2016-03-12 11:34 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2016-03-12 11:34 UTC (permalink / raw)
To: gcc-patches
[-- 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);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-03-12 11:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-12 11:34 Fix stack checking emulation in Ada Eric Botcazou
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).