Message ID | CAAgBjMmCk7aBysr4726ypVbntVabBSoseSTD06026cw+9_f-aA@mail.gmail.com |
---|---|
State | Superseded |
Headers | show |
On Sun, Dec 18, 2016 at 05:41:23PM +0530, Prathamesh Kulkarni wrote: > --- a/gcc/c/gimple-parser.c > +++ b/gcc/c/gimple-parser.c > @@ -1046,6 +1046,17 @@ c_parser_gimple_pass_list (c_parser *parser) > if (! c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) > return NULL; > > + if (pass) > + { > + char *full_passname = (char *) xmalloc (strlen ("tree-") + strlen (pass) + 1); > + strcpy (full_passname, "tree-"); > + strcat (full_passname, pass); Use char *full_passname = concat ("tree-", pass, NULL); instead? Jakub
On Sun, 18 Dec 2016, Prathamesh Kulkarni wrote: > Hi Richard, > The attached patch attempts to reject invalid pass-name in startwith > and verified gimplefe tests pass with the patch (not sure if bootstrap > is required?) > Does it look OK ? No - get_pass_by_name works on dump file names while the startwith machinery counts the actual invocations of the pass (and supports "ccp" as alias to "ccp1" for example). So there is no 1:1 correspondence between startwith names and names get_pass_by_name expects. I'd say we instead want to diagnose when the pass pipeline execution fails to find "startwith". Thus ontop of my earlier patch which ends up with /* For skipping passes until startwith pass */ if (cfun && cfun->pass_startwith /* But we can't skip the lowering phase yet -- ideally we'd drive that phase fully via properties. */ && (cfun->curr_properties & PROP_ssa)) { size_t namelen = strlen (pass->name); /* We have to at least start when we leave SSA. */ if (pass->properties_destroyed & PROP_ssa) cfun->pass_startwith = NULL; else if (! strncmp (pass->name, cfun->pass_startwith, namelen)) { in the & PROP_ssa case, if pass->name doesn't match, diagnose a "failed to start pass execution at %s, starting with RTL expansion". Richard.
diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index ddecaec..ec1dbb3 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -1046,6 +1046,17 @@ c_parser_gimple_pass_list (c_parser *parser) if (! c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) return NULL; + if (pass) + { + char *full_passname = (char *) xmalloc (strlen ("tree-") + strlen (pass) + 1); + strcpy (full_passname, "tree-"); + strcat (full_passname, pass); + opt_pass *p = g->get_passes ()->get_pass_by_name (full_passname); + if (!p || p->type != GIMPLE_PASS) + error_at (c_parser_peek_token (parser)->location, + "%s is not a valid GIMPLE pass\n", pass); + free (full_passname); + } return pass; } diff --git a/gcc/testsuite/gcc.dg/gimplefe-19.c b/gcc/testsuite/gcc.dg/gimplefe-19.c new file mode 100644 index 0000000..bb5be33 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-19.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple" } */ + +void __GIMPLE (startwith ("combine")) foo () /* { dg-error "not a valid GIMPLE pass" } */ +{ + return; +}