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