public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR81430] Use finalize_options in lto1
@ 2017-07-20  9:22 Tom de Vries
  2017-07-20 10:10 ` Richard Biener
  2017-07-21  9:49 ` [committed, nvptx] Add nvptx_override_options_after_change Tom de Vries
  0 siblings, 2 replies; 10+ messages in thread
From: Tom de Vries @ 2017-07-20  9:22 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches, Thomas Schwinge

[-- Attachment #1: Type: text/plain, Size: 2099 bytes --]

Hi,

this patch fixes PR81430, an ICE in the libgomp testsuite for both 
openmp and openacc test-cases for x86_64 with nvptx accelerator.

The scenario how we hit the ICE is as follows:
- a testcase is compiled with -O2
- ix86_option_optimization_table enables
   OPT_freorder_blocks_and_partition at -O2
- cc1 writes out the flag as part of DECL_FUNCTION_SPECIFIC_OPTIMIZATION
- lto1 reads in the flag as part of DECL_FUNCTION_SPECIFIC_OPTIMIZATION
- lto1 uses the flag, and runs pass_partition_blocks
- pass_partition_blocks ICEs, because it generates code that is not
   supported by the nvptx target.

Note that for standalone compilation for single-thread ptx execution, we 
don't attempt to run pass_partition_blocks. This is because for nvptx, 
TARGET_HAVE_NAMED_SECTIONS is set to false, and this bit in 
finish_options switches off pass_partition_blocks:
...
    /* If the target requested unwind info, then turn off the
       partitioning optimization with a different message.  Likewise, if
       the target does not support named sections.  */

   if (opts->x_flag_reorder_blocks_and_partition
       && (!targetm_common.have_named_sections
           || (opts->x_flag_unwind_tables
               && targetm_common.unwind_tables_default
               && (ui_except == UI_SJLJ || ui_except >= UI_TARGET))))
     {
       if (opts_set->x_flag_reorder_blocks_and_partition)
         inform (loc,
                 "-freorder-blocks-and-partition does not work "
                 "on this architecture");
       opts->x_flag_reorder_blocks_and_partition = 0;
       opts->x_flag_reorder_blocks = 1;
     }
...

The patch fixes this by calling finish_options in lto1 after 
cl_optimization_restore.

Points for review:
1. I'm uncertain though about the placement of the call. Perhaps it 
should be in cl_optimization_restore, before 
targetm.override_options_after_change?

2. I think that this is offloading specific, so perhaps this should be 
guarded with lto_stream_offload_p or #ifdef ACCEL_COMPILER or some such.

Bootstrapped and reg-tested on x86_64.

OK for trunk?

Thanks,
- Tom

[-- Attachment #2: 0001-Use-finalize_options-in-lto1.patch --]
[-- Type: text/x-patch, Size: 1009 bytes --]

Use finalize_options in lto1

2017-07-20  Tom de Vries  <tom@codesourcery.com>

	PR lto/81430
	* function.c (invoke_set_current_function_hook): Call finish_options in
	lto1 after cl_optimization_restore.

---
 gcc/function.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/function.c b/gcc/function.c
index f625489..ccb312b 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -77,6 +77,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "rtl-chkp.h"
 #include "tree-dfa.h"
 #include "tree-ssa.h"
+#include "opts.h"
 
 /* So we can assign to cfun in this file.  */
 #undef cfun
@@ -4793,6 +4794,11 @@ invoke_set_current_function_hook (tree fndecl)
 	{
 	  optimization_current_node = opts;
 	  cl_optimization_restore (&global_options, TREE_OPTIMIZATION (opts));
+	  if (in_lto_p)
+	    finish_options (&global_options, &global_options_set,
+			    (fndecl
+			     ? DECL_SOURCE_LOCATION (fndecl)
+			     : UNKNOWN_LOCATION));
 	}
 
       targetm.set_current_function (fndecl);

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-08-11 15:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-20  9:22 [PATCH, PR81430] Use finalize_options in lto1 Tom de Vries
2017-07-20 10:10 ` Richard Biener
2017-07-20 15:35   ` Tom de Vries
2017-07-21  9:41     ` Richard Biener
2017-07-21 13:40       ` Tom de Vries
2017-07-25 11:24         ` Richard Biener
2017-07-21  9:49 ` [committed, nvptx] Add nvptx_override_options_after_change Tom de Vries
2017-08-08  8:46   ` Thomas Schwinge
2017-08-08  8:58     ` Tom de Vries
2017-08-11 16:46       ` Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).