On Thu, 20 Jul 2017, Tom de Vries wrote: > On 07/20/2017 12:10 PM, Richard Biener wrote: > > On Thu, 20 Jul 2017, Tom de Vries wrote: > > > > > 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. > > > > Hmm, I agree with #2. I think it conceptually is a LTO stream adjustment > > and thus we should do this at the time we stream in the > > optimization/target nodes (like we remap modes for example). Not > > sure if it's possible to do this at that point, but it looks like > > finish_options takes two option structs and thus we should be able to > > call it. > > > > With what parameters? Patch below tries with same option struct, but ... > > > Do you get the inform note? I suppose we don't really want that, no? > > > > ... I think that way we'll get the inform note (while the previous solution > did not). > > I've also tried with a tmp2 memset to 0, but that ran into problems when doing > a maybe_set_param_value.
Use global_options_set? That should do what the other patch did. > Thanks, > - Tom > > diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c > index 7f7ea7f..e0e792b 100644 > --- a/gcc/tree-streamer-in.c > +++ b/gcc/tree-streamer-in.c > @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see > #include "ipa-chkp.h" > #include "gomp-constants.h" > #include "asan.h" > +#include "opts.h" > > > /* Read a STRING_CST from the string table in DATA_IN using input > @@ -769,6 +770,20 @@ lto_input_ts_function_decl_tree_pointers (struct > lto_input_block *ib, > DECL_FUNCTION_SPECIFIC_TARGET (expr) = stream_read_tree (ib, data_in); > #endif > DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr) = stream_read_tree (ib, > data_in); > +#ifdef ACCEL_COMPILER > + { > + tree opts = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr); > + if (opts) > + { > + struct gcc_options tmp; > + cl_optimization_restore (&tmp, TREE_OPTIMIZATION (opts)); > + finish_options (&tmp, &tmp, DECL_SOURCE_LOCATION (expr)); > + opts = build_optimization_node (&tmp); > + > + DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr) = opts; > + } > + } > +#endif > > /* If the file contains a function with an EH personality set, > then it was compiled with -fexceptions. In that case, initialize > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)