From b94c2dc138c60636e3898b04c1026cbb1b868b26 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Tue, 1 May 2018 19:16:43 +0000 Subject: Add VEC_ORDERED_REMOVE_IF 2018-05-01 Tom de Vries PR other/83786 * vec.h (VEC_ORDERED_REMOVE_IF, VEC_ORDERED_REMOVE_IF_FROM_TO): Define. * vec.c (test_ordered_remove_if): New function. (vec_c_tests): Call test_ordered_remove_if. * dwarf2cfi.c (connect_traces): Use VEC_ORDERED_REMOVE_IF_FROM_TO. * lto-streamer-out.c (prune_offload_funcs): Use VEC_ORDERED_REMOVE_IF. * tree-vect-patterns.c (vect_pattern_recog_1): Use VEC_ORDERED_REMOVE_IF. From-SVN: r259808 --- gcc/lto-streamer-out.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'gcc/lto-streamer-out.c') diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 70476dc..f614aef 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -2360,24 +2360,14 @@ prune_offload_funcs (void) if (!offload_funcs) return; - unsigned int write_index = 0; - for (unsigned read_index = 0; read_index < vec_safe_length (offload_funcs); - read_index++) - { - tree fn_decl = (*offload_funcs)[read_index]; - bool remove_p = cgraph_node::get (fn_decl) == NULL; - if (remove_p) - continue; - - DECL_PRESERVE_P (fn_decl) = 1; - - if (write_index != read_index) - (*offload_funcs)[write_index] = (*offload_funcs)[read_index]; - - write_index++; - } - - offload_funcs->truncate (write_index); + unsigned ix, ix2; + tree *elem_ptr; + VEC_ORDERED_REMOVE_IF (*offload_funcs, ix, ix2, elem_ptr, + cgraph_node::get (*elem_ptr) == NULL); + + tree fn_decl; + FOR_EACH_VEC_ELT (*offload_funcs, ix, fn_decl) + DECL_PRESERVE_P (fn_decl) = 1; } /* Main entry point from the pass manager. */ -- cgit v1.1