[lto] Fixup loops before lto write-out 2018-04-23 Richard Biener Tom de Vries PR lto/85422 * lto-streamer-out.c (output_function): Fixup loops if required to match discovery done in the reader. * testsuite/libgomp.oacc-c-c++-common/pr85422.c: New test. --- gcc/lto-streamer-out.c | 4 ++++ libgomp/testsuite/libgomp.oacc-c-c++-common/pr85422.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 1d2ab97..70476dc 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -2120,6 +2120,9 @@ output_function (struct cgraph_node *node) debug info. */ if (gimple_has_body_p (function)) { + /* Fixup loops if required to match discovery done in the reader. */ + loop_optimizer_init (AVOID_CFG_MODIFICATIONS); + streamer_write_uhwi (ob, 1); output_struct_function_base (ob, fn); @@ -2177,6 +2180,7 @@ output_function (struct cgraph_node *node) output_cfg (ob, fn); + loop_optimizer_finalize (); pop_cfun (); } else diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/pr85422.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr85422.c new file mode 100644 index 0000000..bcc551d --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr85422.c @@ -0,0 +1,13 @@ +/* { dg-do link } */ + +int +main (void) +{ + #pragma acc parallel + #pragma acc loop + for (int i = 1; i < 10; i++) + for (;;) + ; + + return 0; +}