Hi! This is a patch from James that has been sitting in bugzilla for a few weeks. The bug is that mips_register_frame_header_opt registers the pass from a static variable which has an automatic variable in the initializer, which means that the first time it is called it is registered properly, but if it is called multiple times (e.g. possible with gccjit or multiple --help options), then the second time it creates a new pass, but registers with the old pass (since the var isn't initialized again). register_pass doesn't store the address it is called with anywhere, just uses the fields of the struct and stores the pass (first field). All other spots that call register_pass in all backends do it properly it seems.
I've just fixed up formatting and added a testcase, tested with cross to mips and tested the testcase on x86_64-linux and i686-linux. Ok for trunk? 2017-11-21 James Cowgill <james.cowg...@imgtec.com> Jakub Jelinek <ja...@redhat.com> PR target/82880 * config/mips/frame-header-opt.c (mips_register_frame_header_opt): Remove static keyword from f variable. * gcc.dg/opts-8.c: New test. --- gcc/config/mips/frame-header-opt.c.jj 2017-06-07 10:45:51.000000000 +0200 +++ gcc/config/mips/frame-header-opt.c 2017-11-21 12:25:54.498746712 +0100 @@ -99,8 +99,7 @@ void mips_register_frame_header_opt (void) { opt_pass *p = make_pass_ipa_frame_header_opt (g); - static struct register_pass_info f = - {p, "comdats", 1, PASS_POS_INSERT_AFTER }; + struct register_pass_info f = { p, "comdats", 1, PASS_POS_INSERT_AFTER }; register_pass (&f); } --- gcc/testsuite/gcc.dg/opts-8.c.jj 2017-11-21 12:24:23.051868081 +0100 +++ gcc/testsuite/gcc.dg/opts-8.c 2017-11-21 12:32:47.023688118 +0100 @@ -0,0 +1,6 @@ +/* PR target/82880 */ +/* Test we don't ICE or hang. */ +/* { dg-do compile } */ +/* { dg-options "--help=target --help=optimizers" } */ +/* { dg-allow-blank-lines-in-output 1 } */ +/* { dg-prune-output ".*" } */ Jakub