gimple-low.c (lower_stmt): If the call is noreturn, remove a subsequent GOTO or RETURN statement.

* gimple-low.c (lower_stmt) <GIMPLE_CALL>: If the call is noreturn,
	remove a subsequent GOTO or RETURN statement.

From-SVN: r152959
This commit is contained in:
Eric Botcazou 2009-10-17 22:17:26 +00:00
parent 7e90b362e1
commit 79ddec0279
5 changed files with 47 additions and 2 deletions

View File

@ -1,10 +1,15 @@
2009-10-17 Eric Botcazou <ebotcazou@adacore.com>
* gimple-low.c (lower_stmt) <GIMPLE_CALL>: If the call is noreturn,
remove a subsequent GOTO or RETURN statement.
2009-10-17 Andy Hutchinson <hutchinsonandy@aim.com>
* config/avr.md (*movqi): Add zero as equally preferable constraint
as general register.
(*movhi): Ditto.
(*movhi): Ditto.
2009-10-17 Eric Botcazou <ebotcazou@adacore.com>
2009-10-17 Eric Botcazou <ebotcazou@adacore.com>
* print-tree.c (print_node): Fix string for DECL_STRUCT_FUNCTION.

View File

@ -387,6 +387,19 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
lower_builtin_setjmp (gsi);
return;
}
/* After a noreturn call, remove a subsequent GOTO or RETURN that might
have been mechanically added; this will prevent the EH lowering pass
from adding useless edges and thus complicating the initial CFG. */
if (decl && (flags_from_decl_or_type (decl) & ECF_NORETURN))
{
gsi_next (gsi);
if (!gsi_end_p (*gsi)
&& (gimple_code (gsi_stmt (*gsi)) == GIMPLE_GOTO
|| gimple_code (gsi_stmt (*gsi)) == GIMPLE_RETURN))
gsi_remove (gsi, false);
return;
}
}
break;

View File

@ -1,3 +1,7 @@
2009-10-17 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/noreturn1.ad[sb]: New test.
2009-10-17 Janus Weil <janus@gcc.gnu.org>
Paul Thomas <pault@gcc.gnu.org>

View File

@ -0,0 +1,15 @@
-- { dg-compile }
package body Noreturn1 is
procedure Error (E : in Exception_Occurrence) is
Occurrence_Message : constant String := Exception_Message (E);
begin
if Occurrence_Message = "$" then
raise Program_Error;
else
raise Constraint_Error;
end if;
end;
end Noreturn1;

View File

@ -0,0 +1,8 @@
with Ada.Exceptions; use Ada.Exceptions;
package Noreturn1 is
procedure Error (E : in Exception_Occurrence);
pragma No_Return (Error);
end Noreturn1;