This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fatal error when failing to register a new pass [eg from plugin]
- From: Basile STARYNKEVITCH <basile at starynkevitch dot net>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 13 Oct 2009 08:41:41 +0200
- Subject: fatal error when failing to register a new pass [eg from plugin]
Hello All,
passes can not only be registered within gcc, but also inside plugins.
The trunk's 152697 register_pass in file gcc/passes.c fails silently
with gcc_unreachable when a pass cannot be registered. So I believe
http://gcc.gnu.org/ml/gcc-patches/2009-09/msg02006.html was too quick!
The attached simple patch makes a more explanatory fatal error when a
pass fails to register.
gcc/ChangeLog:
2009-10-13 Basile Starynkevitch <basile@starynkevitch.net>
* passes.c (register_pass): Replaced gcc_unreachable by
fatal_error on failure.
I think we really should give some explicit fatal error message to the
power user of a plugin which registers something bad.
Ok if it bootstraps?
Regards.
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***
Index: gcc/passes.c
===================================================================
--- gcc/passes.c (revision 152697)
+++ gcc/passes.c (working copy)
@@ -601,14 +601,14 @@ void
register_pass (struct register_pass_info *pass_info)
{
if (!pass_info->pass)
- {
- gcc_unreachable ();
- }
+ fatal_error ("can%'t register a null pass");
+ if (!pass_info->pass->name)
+ fatal_error ("can%'t register an unamed pass");
+
if (!pass_info->reference_pass_name)
- {
- gcc_unreachable ();
- }
+ fatal_error ("can%'t register new pass %s without a reference pass name",
+ pass_info->pass->name);
/* Try to insert the new pass to the pass lists. We need to check all
three lists as the reference pass could be in one (or all) of them. */
@@ -617,7 +617,8 @@ register_pass (struct register_pass_info *pass_inf
&& !position_pass (pass_info, &all_regular_ipa_passes)
&& !position_pass (pass_info, &all_lto_gen_passes)
&& !position_pass (pass_info, &all_passes))
- gcc_unreachable ();
+ fatal_error ("can%'t position new pass %s referencing pass %s",
+ pass_info->pass->name, pass_info->reference_pass_name);
else
{
/* OK, we have successfully inserted the new pass. We need to register