On Fri, Dec 29, 2017 at 2:55 PM, Tom de Vries <tom_devr...@mentor.com> wrote: > [ was: Re: [libgomp, openacc, openmp, PR83046] Prune removed funcs from > offload table ] > > On 12/28/2017 05:06 PM, Jakub Jelinek wrote: >> >> On Thu, Dec 28, 2017 at 04:53:29PM +0100, Tom de Vries wrote: >>> >>> --- a/gcc/lto-cgraph.c >>> +++ b/gcc/lto-cgraph.c >>> @@ -1111,6 +1111,16 @@ output_offload_tables (void) >>> struct lto_simple_output_block *ob >>> = lto_create_simple_output_block (LTO_section_offload_table); >>> + for (unsigned i = 0; i < vec_safe_length (offload_funcs);) >>> + { >>> + if (!cgraph_node::get ((*offload_funcs)[i])) >>> + { >>> + offload_funcs->ordered_remove (i); >>> + continue; >>> + } >>> + i++; >>> + } > > >> This has O(n^2) complexity for n == vec_safe_length (offload_funcs). >> Can't you instead just have 2 IVs, one for where we read the vector elt >> and >> one for where we write it if the 2 are different, then truncate the vector >> if needed at the end? > > > I wonder if it makes sense to add this function to the vec interface. > > Any comments?
Hmm. We do have quite some cases in the tree doing this kind of operation - can you try finding one or two and see if it fits? If we only could use lambdas here... Oh, and I somehow miss a start/end index for operating on a vector part? Richard. > Thanks, > - Tom