This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C++ space optimization: omit EH info for thunks
On Fri, Aug 16, 2002 at 03:53:42PM -0700, Stuart Hastings wrote:
> /* Don't emit EH unwind info for leaf functions that don't need it. */
> - if (!flag_asynchronous_unwind_tables && for_eh && fde->nothrow
> - && ! fde->uses_eh_lsda)
> + if (!flag_asynchronous_unwind_tables && for_eh &&
> + (fde->all_throwers_are_sibcalls || (fde->nothrow && ! fde->uses_eh_lsda)))
> continue;
This is incorrect. You want:
if (!flag_asynchronous_unwind_tables && for_eh
&& (fde->nothrow || fde->all_throwers_are_sibcalls)
&& !fde->uses_eh_lsda)
Just because a function doesn't throw doesn't mean it doesn't
handle exceptions. For instance, given
void foo()
{
try
bar();
catch (...)
;
}
both nothrow and all_throwers_are_sibcalls are true, since
can_throw_external is false for the call to bar. However,
uses_eh_lsda will be true since we need to catch the exception.
> for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
> if (can_throw_external (insn))
> ! {
> ! current_function_nothrow = 0;
> ! cfun->all_throwers_are_sibcalls &= (GET_CODE (insn) == CALL_INSN && SIBLING_CALL_P (insn));
> ! /* If the current function has a possible thrower that isn't a sibcall, we're done. */
> ! if (!cfun->all_throwers_are_sibcalls)
> ! return;
This is incorrect. You're clearing leaving all_throwers_are_sibcalls
set when CALL_INSN is false. Something that cannot happen with C++
by default, but does happen with Java or with -fnon-call-exceptions.
In any case, I'd rather see this written:
if (GET_CODE (insn) == CALL_INSN && !SIBLING_CALL_P (insn))
{
cfun->all_throwers_are_sibcalls = 0;
return;
}
r~