On Wed, Oct 26, 2016 at 11:54:36AM +0200, Georg-Johann Lay wrote: > gen-pass-instances.awk is sensitive to the order in which directives are > written down, e.g. in target-pass.def: If a pass that runs first is added > first, then the last pass is skipped and not added to pass-instances.def. > > Work around is to add the 2nd pass before adding the 1st pass... > > http://gcc.gnu.org/r241547 > > No so obvious, but committed anyway...
We shouldn't be working around bugs, but fixing them. Here is a fix (so far tested only with running for i in alpha avr i386 sparc aarch64; do awk -f ./gen-pass-instances.awk.jj passes.def config/$i/${i}-passes.def > /tmp/1 awk -f ./gen-pass-instances.awk passes.def config/$i/${i}-passes.def > /tmp/2 diff -up /tmp/1 /tmp/2 # and diff -upb done ), for avr for both avr-passes.def before your workaround and after it. Except for the desirable whitespace changes, the only change is in the pre-workaround avr-passes.def having the same output as after-workaround (except for the comments at the end of file). The fix for the avr issue is just the first hunk, the first part of the second hunk attempts to deal with NEXT_PASS ( avr_pass_casesi, 1); instead of the desirable NEXT_PASS (avr_pass_casesi, 1); (all arguments have the whitespace they have in *.def before them (after , or ( characters). So the first part of the second hunk strips away whitespace, so that one doesn't need to type INSERT_PASS_BEFORE (pass_free_cfg, 1,avr_pass_casesi); and the second part of the second hunk and third hunk deal with similar issue for the optional argument, we used to emit NEXT_PASS_WITH_ARG (pass_dominator, 1, false /* may_peel_loop_headers_p */); rather than NEXT_PASS_WITH_ARG (pass_dominator, 1, false /* may_peel_loop_headers_p */); because the space from NEXT_PASS (pass_dominator, false /* may_peel_loop_headers_p */); (in between , and false) is already there and we add another one. Ok for trunk if it passes bootstrap/regtest (though, as it doesn't change anything but whitespace on x86_64, it shouldn't make a difference)? 2016-10-26 Jakub Jelinek <ja...@redhat.com> * gen-pass-instances.awk (adjust_linenos): INcrement pass_lines[p] by increment rather than double it. (insert_remove_pass): Strip leading whitespace from args[3]. Don't emit a space before args[4]. (END): Don't emit a space before with_arg. --- gcc/gen-pass-instances.awk.jj 2016-10-10 10:41:32.000000000 +0200 +++ gcc/gen-pass-instances.awk 2016-10-26 12:30:20.637310242 +0200 @@ -90,7 +90,7 @@ function adjust_linenos(above, increment { for (p in pass_lines) if (pass_lines[p] >= above) - pass_lines[p] += pass_lines[p]; + pass_lines[p] += increment; if (increment > 0) for (i = lineno - 1; i >= above; i--) lines[i + increment] = lines[i]; @@ -100,16 +100,18 @@ function adjust_linenos(above, increment lineno += increment; } -function insert_remove_pass(line, fnname) +function insert_remove_pass(line, fnname, arg3) { parse_line($0, fnname); pass_name = args[1]; if (pass_name == "PASS") return 1; pass_num = args[2] + 0; - new_line = prefix "NEXT_PASS (" args[3]; + arg3 = args[3]; + sub(/^[ \t]*/, "", arg3); + new_line = prefix "NEXT_PASS (" arg3; if (args[4]) - new_line = new_line ", " args[4]; + new_line = new_line "," args[4]; new_line = new_line ")" postfix; if (!pass_lines[pass_name, pass_num]) { @@ -218,7 +220,7 @@ END { printf "NEXT_PASS"; printf " (%s, %s", pass_name, pass_num; if (with_arg) - printf ", %s", with_arg; + printf ",%s", with_arg; printf ")%s\n", postfix; } else Jakub