From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by sourceware.org (Postfix) with ESMTPS id D9FFF398544B for ; Wed, 14 Jul 2021 14:44:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D9FFF398544B Received: by mail-qk1-x730.google.com with SMTP id 201so1756721qkj.13 for ; Wed, 14 Jul 2021 07:44:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=PO3hxfXYS2SmN8DxJHeAY3YJFGBszdn2jhcu62dLQlE=; b=SXnFKq4cNf+Xt7/CkttDHeVSZ3weqi4Id1wcSNpghw1LaC22C9IZtuf2ZJxMIW3cZ/ MxEikU+wpsEJ7bv52cF/oQiB4NXyWd7VNMwnb+PRApAurAMLa50TE6U/ZdzHwa0nTHC9 egUMb9Eyihga4UPgOjDnWxwYOo7RglreOOuYMGV6Ls+GwUa0+vPp49OkojHCPk8I4l9T 2jcl5Fwe76M+SOstiacrr+NC0ERiOiwG91Oj3ScDhIWM8HqhIS8vSdCyE3qg39b3bg7X ekD2QXd0TgGoeuGIHaWAIanLIi7VB2jqGwVXSEw3j8ou6r96QntYo9Ita+zavoUT3hoc Tbsw== X-Gm-Message-State: AOAM531Oj6fbwAsOAzOyCMNGQQtDQTMnBoqlNkvKcCGrSvkXmctteSrU la1wRpkkw6+7PC/1vn/qJD4= X-Google-Smtp-Source: ABdhPJzqiOyfVcC+mRicW67swI58pN0n8TfJbKNtslRTTUfgmb3xdm7vdFEd2VYKHqcBHpOOzu1JOw== X-Received: by 2002:a05:620a:31a8:: with SMTP id bi40mr10640088qkb.283.1626273882498; Wed, 14 Jul 2021 07:44:42 -0700 (PDT) Received: from [192.168.0.41] (75-166-102-22.hlrn.qwest.net. [75.166.102.22]) by smtp.gmail.com with ESMTPSA id k186sm1094814qkb.29.2021.07.14.07.44.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Jul 2021 07:44:41 -0700 (PDT) Subject: Re: [PING][PATCH] define auto_vec copy ctor and assignment (PR 90904) To: Richard Biener Cc: Jason Merrill , gcc-patches , Jonathan Wakely References: <91545a73-12af-33b2-c6e7-119b5a21de60@gmail.com> <4d503394-4e82-1d36-41ca-34315042775b@redhat.com> <49569f1d-9856-55c7-b9e9-578bbd7c7b7a@gmail.com> <390c6652-0a1f-e8c4-d70d-56ced2f7b0fb@gmail.com> From: Martin Sebor Message-ID: <25191d67-b916-17d4-4423-9a218c98a02b@gmail.com> Date: Wed, 14 Jul 2021 08:44:39 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------0517D434F9B602AA537BD1C3" Content-Language: en-US X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jul 2021 14:44:48 -0000 This is a multi-part message in MIME format. --------------0517D434F9B602AA537BD1C3 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 7/12/21 5:02 AM, Richard Biener wrote: > On Wed, Jul 7, 2021 at 4:37 PM Martin Sebor wrote: >> >> On 7/7/21 1:28 AM, Richard Biener wrote: >>> On Tue, Jul 6, 2021 at 5:06 PM Martin Sebor wrote: >>>> >>>> Ping: https://gcc.gnu.org/pipermail/gcc-patches/2021-June/573968.html >>>> >>>> Any questions/suggestions on the final patch or is it okay to commit? >>> >>> I don't remember seeing one (aka saying "bootstrapped/tested, OK to commit?" >>> or so) - and the link above doesn't have one. >>> >>> So, can you re-post it please? >> >> The patch is attached to the email above with the following text >> at the end: >> >> Attached is a revised patch with these changes (a superset of >> those I sent in response to Jason's question), tested on x86_64. >> >> I've also attached it to this reply. > > Thanks - I was confused about the pipermail way of referencing attachments ... > > The pieces where you change vec<> passing to const vec<>& and the few > where you change vec<> * to const vec<> * are OK - this should make the > rest a smaller piece to review. In general const correctness changes should > be considered obvious (vec<> to const vec<>& passing isn't quite obvious > so I acked the cases explicitely). Okay. > > I think the vec<> -> vec<>& cases would either benefit from constification > of callers that make using const vec<>& not possible or from a change to > pass array_slice<> (not array_slice<>&), noting that the vec<> contents > are mutated but the vec<> size does not change. I've reviewed the patch and found a handful of instances I had missed where the vec& could be made const. The rest of the vec<> -> vec<>& changes are all to functions that modify the vec, either directly or by passing it to other functions that do. (I you see some you want me to double-check let me know.) As a reminder, there may still be APIs where an existing by-value or by-reference vec could be made const vec& if they don't have to be touched for other reasons (i.e., passing an auto_vec as an argument). Those should also be reviewed at some point. > > Somebody with more C++ knowledge than me needs to approve the > vec.h changes - I don't feel competent to assess all effects of the change. Ack. Attached is an updated patch with a few of the vec& -> const vec& changes and the removal of the static specifier on vNULL. Martin --------------0517D434F9B602AA537BD1C3 Content-Type: text/x-patch; charset=UTF-8; name="gcc-auto_vec-no-convert.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gcc-auto_vec-no-convert.diff" Disable implicit conversion from auto_vec to vec. * c-common.c (c_build_shufflevector): Adjust to vec change. * c-common.h (c_build_shufflevector): Same. gcc/c/ChangeLog: * c-parser.c (c_finish_omp_declare_simd): Adjust to vec change. (c_parser_omp_declare_simd): Same. * c-tree.h (c_build_function_call_vec): Same. * c-typeck.c (c_build_function_call_vec): Same. gcc/ChangeLog: * cfgloop.h (single_likely_exit): Adjust to vec change. * cfgloopanal.c (single_likely_exit): Same. * cgraph.h (struct cgraph_node): Same. * cgraphclones.c (cgraph_node::create_virtual_clone): Same. * dominance.c (prune_bbs_to_update_dominators): Same. (iterate_fix_dominators): Same. * dominance.h (iterate_fix_dominators): Same. * genautomata.c (merge_states): Same. * genextract.c (VEC_char_to_string): Same. * genmatch.c (dt_node::gen_kids_1): Same. (walk_captures): Same. * gimple-ssa-store-merging.c (check_no_overlap): Same. * gimple.c (gimple_build_call_vec): Same. (gimple_build_call_internal_vec): Same. (gimple_build_switch): Same. (sort_case_labels): Same. (preprocess_case_label_vec_for_gimple): Same. * gimple.h (gimple_build_call_vec): Same. (gimple_build_call_internal_vec): Same. (gimple_build_switch): Same. (sort_case_labels): Same. (preprocess_case_label_vec_for_gimple): Same. * haifa-sched.c (calc_priorities): Same. (haifa_sched_init): Same. (sched_init_luids): Same. (haifa_init_h_i_d): Same. * ipa-cp.c (ipa_get_indirect_edge_target_1): Same. (adjust_callers_for_value_intersection): Same. (find_more_scalar_values_for_callers_subset): Same. (find_more_contexts_for_caller_subset): Same. (find_aggregate_values_for_callers_subset): Same. (copy_useful_known_contexts): Same. * ipa-fnsummary.c (remap_edge_summaries): Same. (remap_freqcounting_predicate): Same. * ipa-inline.c (add_new_edges_to_heap): Same. * ipa-predicate.c (predicate::remap_after_inlining): Same. * ipa-predicate.h: * ipa-prop.c (ipa_find_agg_cst_for_param): Same. * ipa-prop.h (ipa_find_agg_cst_for_param): Same. * ira-build.c (ira_loop_tree_body_rev_postorder): Same. * read-rtl.c (apply_iterators): Same. * rtl.h (native_decode_rtx): Same. (native_decode_vector_rtx): Same. * sched-int.h (sched_init_luids): Same. (haifa_init_h_i_d): Same. * simplify-rtx.c (native_decode_vector_rtx): Same. (native_decode_rtx): Same. * tree-call-cdce.c (gen_shrink_wrap_conditions): Same. (shrink_wrap_one_built_in_call_with_conds): Same. (shrink_wrap_conditional_dead_built_in_calls): Same. * tree-data-ref.c (create_runtime_alias_checks): Same. (compute_all_dependences): Same. * tree-data-ref.h (compute_all_dependences): Same. (create_runtime_alias_checks): Same. (index_in_loop_nest): Same. * tree-if-conv.c (mask_exists): Same. * tree-loop-distribution.c (class loop_distribution): Same. (loop_distribution::create_rdg_vertices): Same. (dump_rdg_partitions): Same. (debug_rdg_partitions): Same. (partition_contains_all_rw): Same. (loop_distribution::distribute_loop): Same. * tree-parloops.c (oacc_entry_exit_ok_1): Same. (oacc_entry_exit_single_gang): Same. * tree-ssa-loop-im.c (hoist_memory_references): Same. (loop_suitable_for_sm): Same. * tree-ssa-loop-niter.c (bound_index): Same. * tree-ssa-pre.c (insert_into_preds_of_block): Same. * tree-ssa-reassoc.c (update_ops): Same. (swap_ops_for_binary_stmt): Same. (rewrite_expr_tree): Same. (rewrite_expr_tree_parallel): Same. * tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Same. * tree-ssa-sccvn.h (ao_ref_init_from_vn_reference): Same. * tree-ssa-structalias.c (process_all_all_constraints): Same. (make_constraints_to): Same. (find_func_aliases_for_call): Same. (sort_fieldstack): Same. (check_for_overlaps): Same. * tree-vect-data-refs.c (vect_check_nonzero_value): Same. (vect_enhance_data_refs_alignment): Same. (vect_check_lower_bound): Same. (vect_prune_runtime_alias_test_list): Same. (vect_permute_store_chain): Same. * tree-vect-loop-manip.c (vect_create_cond_for_align_checks): Same. (vect_create_cond_for_unequal_addrs): Same. (vect_create_cond_for_lower_bounds): Same. (vect_create_cond_for_alias_checks): Same. * tree-vect-slp-patterns.c (vect_normalize_conj_loc): Same. (vect_validate_multiplication): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. (vect_make_slp_decision): Same. (vect_slp_bbs): Same. (duplicate_and_interleave): Same. (vect_transform_slp_perm_load): Same. (vect_schedule_slp): Same. * tree-vect-stmts.c (vect_create_vectorized_demotion_stmts): Same. * tree-vectorizer.h (vect_permute_store_chain): Same. (vect_transform_slp_perm_load): Same. (vect_schedule_slp): Same. (duplicate_and_interleave): Same. * tree.c (build_vector_from_ctor): Same. (build_vector): Same. (check_vector_cst): Same. (check_vector_cst_duplicate): Same. (check_vector_cst_fill): Same. (check_vector_cst_stepped): Same. * tree.h (build_vector_from_ctor): Same. * vec.c (test_init): New. (vec_c_tests): Call test_init. * vec.h (struct vnull): Simplify. (auto_vec::to_vec): New member function. (vl_ptr>::copy): Use value initialization. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index c4eb2b1c920..9841a320f89 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1115,8 +1115,8 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask, and have vector types, V0 has the same element type as V1, and the number of elements the result is that of MASK. */ tree -c_build_shufflevector (location_t loc, tree v0, tree v1, vec mask, - bool complain) +c_build_shufflevector (location_t loc, tree v0, tree v1, + const vec &mask, bool complain) { tree ret; bool wrap = true; diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 88022d0b0a9..e43b12ae1dc 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1049,7 +1049,7 @@ extern bool vector_targets_convertible_p (const_tree t1, const_tree t2); extern bool vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note); extern tree c_build_vec_perm_expr (location_t, tree, tree, tree, bool = true); extern tree c_build_shufflevector (location_t, tree, tree, - vec, bool = true); + const vec &, bool = true); extern tree c_build_vec_convert (location_t, tree, location_t, tree, bool = true); extern void init_c_lex (void); diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 27034f88f49..b77e5b4f5c0 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1489,7 +1489,8 @@ static tree c_parser_std_attribute_specifier_sequence (c_parser *); static void c_parser_external_declaration (c_parser *); static void c_parser_asm_definition (c_parser *); static void c_parser_declaration_or_fndef (c_parser *, bool, bool, bool, - bool, bool, tree *, vec, + bool, bool, tree * = NULL, + vec * = NULL, bool have_attrs = false, tree attrs = NULL, struct oacc_routine_data * = NULL, @@ -1774,13 +1775,12 @@ c_parser_external_declaration (c_parser *parser) an @interface or @protocol with prefix attributes). We can only tell which after parsing the declaration specifiers, if any, and the first declarator. */ - c_parser_declaration_or_fndef (parser, true, true, true, false, true, - NULL, vNULL); + c_parser_declaration_or_fndef (parser, true, true, true, false, true); break; } } -static void c_finish_omp_declare_simd (c_parser *, tree, tree, vec); +static void c_finish_omp_declare_simd (c_parser *, tree, tree, vec &); static void c_finish_oacc_routine (struct oacc_routine_data *, tree, bool); /* Build and add a DEBUG_BEGIN_STMT statement with location LOC. */ @@ -1890,11 +1890,15 @@ static void c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool static_assert_ok, bool empty_ok, bool nested, bool start_attr_ok, - tree *objc_foreach_object_declaration, - vec omp_declare_simd_clauses, - bool have_attrs, tree attrs, - struct oacc_routine_data *oacc_routine_data, - bool *fallthru_attr_p) + tree *objc_foreach_object_declaration + /* = NULL */, + vec *omp_declare_simd_clauses + /* = NULL */, + bool have_attrs /* = false */, + tree attrs /* = NULL_TREE */, + struct oacc_routine_data *oacc_routine_data + /* = NULL */, + bool *fallthru_attr_p /* = NULL */) { struct c_declspecs *specs; tree prefix_attrs; @@ -2150,9 +2154,9 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, C_DTR_NORMAL, &dummy); if (declarator == NULL) { - if (omp_declare_simd_clauses.exists ()) + if (omp_declare_simd_clauses) c_finish_omp_declare_simd (parser, NULL_TREE, NULL_TREE, - omp_declare_simd_clauses); + *omp_declare_simd_clauses); if (oacc_routine_data) c_finish_oacc_routine (oacc_routine_data, NULL_TREE, false); c_parser_skip_to_end_of_block_or_statement (parser); @@ -2250,9 +2254,9 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, chainon (postfix_attrs, all_prefix_attrs)); if (!d) d = error_mark_node; - if (omp_declare_simd_clauses.exists ()) + if (omp_declare_simd_clauses) c_finish_omp_declare_simd (parser, d, NULL_TREE, - omp_declare_simd_clauses); + *omp_declare_simd_clauses); } else { @@ -2262,9 +2266,9 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, chainon (postfix_attrs, all_prefix_attrs)); if (!d) d = error_mark_node; - if (omp_declare_simd_clauses.exists ()) + if (omp_declare_simd_clauses) c_finish_omp_declare_simd (parser, d, NULL_TREE, - omp_declare_simd_clauses); + *omp_declare_simd_clauses); init_loc = c_parser_peek_token (parser)->location; rich_location richloc (line_table, init_loc); start_init (d, asm_name, global_bindings_p (), &richloc); @@ -2342,7 +2346,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, warn_parm_array_mismatch (lastloc, d, parms); } } - if (omp_declare_simd_clauses.exists ()) + if (omp_declare_simd_clauses) { tree parms = NULL_TREE; if (d && TREE_CODE (d) == FUNCTION_DECL) @@ -2360,7 +2364,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, if (parms) temp_store_parm_decls (d, parms); c_finish_omp_declare_simd (parser, d, parms, - omp_declare_simd_clauses); + *omp_declare_simd_clauses); if (parms) temp_pop_parm_decls (); } @@ -2496,11 +2500,11 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, while (c_parser_next_token_is_not (parser, CPP_EOF) && c_parser_next_token_is_not (parser, CPP_OPEN_BRACE)) c_parser_declaration_or_fndef (parser, false, false, false, - true, false, NULL, vNULL); + true, false); store_parm_decls (); - if (omp_declare_simd_clauses.exists ()) + if (omp_declare_simd_clauses) c_finish_omp_declare_simd (parser, current_function_decl, NULL_TREE, - omp_declare_simd_clauses); + *omp_declare_simd_clauses); if (oacc_routine_data) c_finish_oacc_routine (oacc_routine_data, current_function_decl, true); location_t startloc = c_parser_peek_token (parser)->location; @@ -5699,7 +5703,7 @@ c_parser_compound_statement_nostart (c_parser *parser) bool fallthru_attr_p = false; c_parser_declaration_or_fndef (parser, true, !have_std_attrs, true, true, true, NULL, - vNULL, have_std_attrs, std_attrs, + NULL, have_std_attrs, std_attrs, NULL, &fallthru_attr_p); if (last_stmt && !fallthru_attr_p) @@ -5731,7 +5735,7 @@ c_parser_compound_statement_nostart (c_parser *parser) last_label = false; mark_valid_location_for_stdc_pragma (false); c_parser_declaration_or_fndef (parser, true, true, true, true, - true, NULL, vNULL); + true); /* Following the old parser, __extension__ does not disable this diagnostic. */ restore_extension_diagnostics (ext); @@ -6782,7 +6786,7 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll, || c_parser_nth_token_starts_std_attributes (parser, 1)) { c_parser_declaration_or_fndef (parser, true, true, true, true, true, - &object_expression, vNULL); + &object_expression); parser->objc_could_be_foreach_context = false; if (c_parser_next_token_is_keyword (parser, RID_IN)) @@ -6813,7 +6817,7 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll, ext = disable_extension_diagnostics (); c_parser_consume_token (parser); c_parser_declaration_or_fndef (parser, true, true, true, true, - true, &object_expression, vNULL); + true, &object_expression); parser->objc_could_be_foreach_context = false; restore_extension_diagnostics (ext); @@ -11277,7 +11281,7 @@ c_parser_objc_methodprotolist (c_parser *parser) } else c_parser_declaration_or_fndef (parser, false, false, true, - false, true, NULL, vNULL); + false, true); break; } } @@ -17273,12 +17277,12 @@ c_parser_oacc_routine (c_parser *parser, enum pragma_context context) while (c_parser_next_token_is (parser, CPP_KEYWORD) && c_parser_peek_token (parser)->keyword == RID_EXTENSION); c_parser_declaration_or_fndef (parser, true, true, true, false, true, - NULL, vNULL, false, NULL, &data); + NULL, NULL, false, NULL, &data); restore_extension_diagnostics (ext); } else c_parser_declaration_or_fndef (parser, true, true, true, false, true, - NULL, vNULL, false, NULL, &data); + NULL, NULL, false, NULL, &data); } } @@ -18383,8 +18387,7 @@ c_parser_omp_for_loop (location_t loc, c_parser *parser, enum tree_code code, vec_safe_push (for_block, c_begin_compound_stmt (true)); this_pre_body = push_stmt_list (); c_in_omp_for = true; - c_parser_declaration_or_fndef (parser, true, true, true, true, true, - NULL, vNULL); + c_parser_declaration_or_fndef (parser, true, true, true, true, true); c_in_omp_for = false; if (this_pre_body) { @@ -20325,12 +20328,12 @@ c_parser_omp_declare_simd (c_parser *parser, enum pragma_context context) while (c_parser_next_token_is (parser, CPP_KEYWORD) && c_parser_peek_token (parser)->keyword == RID_EXTENSION); c_parser_declaration_or_fndef (parser, true, true, true, false, true, - NULL, clauses); + NULL, &clauses); restore_extension_diagnostics (ext); } else c_parser_declaration_or_fndef (parser, true, true, true, false, true, - NULL, clauses); + NULL, &clauses); break; case pragma_struct: case pragma_param: @@ -20351,7 +20354,7 @@ c_parser_omp_declare_simd (c_parser *parser, enum pragma_context context) if (c_parser_next_tokens_start_declaration (parser)) { c_parser_declaration_or_fndef (parser, true, true, true, true, - true, NULL, clauses); + true, NULL, &clauses); restore_extension_diagnostics (ext); break; } @@ -20360,7 +20363,7 @@ c_parser_omp_declare_simd (c_parser *parser, enum pragma_context context) else if (c_parser_next_tokens_start_declaration (parser)) { c_parser_declaration_or_fndef (parser, true, true, true, true, true, - NULL, clauses); + NULL, &clauses); break; } error ("%<#pragma omp declare %s%> must be followed by " @@ -20841,7 +20844,7 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms) static void c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, - vec clauses) + vec &clauses) { /* Normally first token is CPP_NAME "simd" or "variant". CPP_EOF there indicates error has been reported and CPP_PRAGMA that diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index a671a3eb740..ab6db3860f5 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -759,8 +759,9 @@ extern tree c_finish_omp_clauses (tree, enum c_omp_region_type); extern tree c_build_va_arg (location_t, tree, location_t, tree); extern tree c_finish_transaction (location_t, tree, int); extern bool c_tree_equal (tree, tree); -extern tree c_build_function_call_vec (location_t, vec, tree, - vec *, vec *); +extern tree c_build_function_call_vec (location_t, const vec&, + tree, vec *, + vec *); extern tree c_omp_clause_copy_ctor (tree, tree, tree); /* Set to 0 at beginning of a function definition, set to 1 if diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index d079ce4b05b..efd4810b901 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -3243,7 +3243,7 @@ build_function_call_vec (location_t loc, vec arg_loc, /* Like build_function_call_vec, but call also resolve_overloaded_builtin. */ tree -c_build_function_call_vec (location_t loc, vec arg_loc, +c_build_function_call_vec (location_t loc, const vec &arg_loc, tree function, vec *params, vec *origtypes) { diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index 5e699276c88..5c2b98db9e5 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -385,7 +385,7 @@ extern basic_block *get_loop_body_in_custom_order (const class loop *, void *, extern auto_vec get_loop_exit_edges (const class loop *, basic_block * = NULL); extern edge single_exit (const class loop *); -extern edge single_likely_exit (class loop *loop, vec); +extern edge single_likely_exit (class loop *loop, const vec &); extern unsigned num_loop_branches (const class loop *); extern edge loop_preheader_edge (const class loop *); diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c index 2db46c81036..4cd73c29776 100644 --- a/gcc/cfgloopanal.c +++ b/gcc/cfgloopanal.c @@ -470,7 +470,7 @@ mark_loop_exit_edges (void) to noreturn call. */ edge -single_likely_exit (class loop *loop, vec exits) +single_likely_exit (class loop *loop, const vec &exits) { edge found = single_exit (loop); unsigned i; diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 9f4338fdf87..8c776d6f3a8 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -949,7 +949,7 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node /* Create callgraph node clone with new declaration. The actual body will be copied later at compilation stage. The name of the new clone will be constructed from the name of the original node, SUFFIX and NUM_SUFFIX. */ - cgraph_node *create_virtual_clone (vec redirect_callers, + cgraph_node *create_virtual_clone (const vec &redirect_callers, vec *tree_map, ipa_param_adjustments *param_adjustments, const char * suffix, unsigned num_suffix); diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c index 9f86463b42d..125f1b92862 100644 --- a/gcc/cgraphclones.c +++ b/gcc/cgraphclones.c @@ -567,7 +567,7 @@ clone_function_name (tree decl, const char *suffix) bitmap interface. */ cgraph_node * -cgraph_node::create_virtual_clone (vec redirect_callers, +cgraph_node::create_virtual_clone (const vec &redirect_callers, vec *tree_map, ipa_param_adjustments *param_adjustments, const char * suffix, unsigned num_suffix) diff --git a/gcc/dominance.c b/gcc/dominance.c index 6a262ce8283..cc63391a39a 100644 --- a/gcc/dominance.c +++ b/gcc/dominance.c @@ -1227,7 +1227,7 @@ recompute_dominator (enum cdi_direction dir, basic_block bb) from BBS. */ static void -prune_bbs_to_update_dominators (vec bbs, +prune_bbs_to_update_dominators (vec &bbs, bool conservative) { unsigned i; @@ -1379,7 +1379,7 @@ determine_dominators_for_sons (struct graph *g, vec bbs, a block of BBS in the current dominance tree dominate it. */ void -iterate_fix_dominators (enum cdi_direction dir, vec bbs, +iterate_fix_dominators (enum cdi_direction dir, vec &bbs, bool conservative) { unsigned i; diff --git a/gcc/dominance.h b/gcc/dominance.h index 1a8c248ee98..970da02c594 100644 --- a/gcc/dominance.h +++ b/gcc/dominance.h @@ -78,7 +78,7 @@ checking_verify_dominators (cdi_direction dir) basic_block recompute_dominator (enum cdi_direction, basic_block); extern void iterate_fix_dominators (enum cdi_direction, - vec , bool); + vec &, bool); extern void add_to_dominance_info (enum cdi_direction, basic_block); extern void delete_from_dominance_info (enum cdi_direction, basic_block); extern basic_block first_dom_son (enum cdi_direction, basic_block); diff --git a/gcc/genautomata.c b/gcc/genautomata.c index 6bbfc684afa..e488c5f28ef 100644 --- a/gcc/genautomata.c +++ b/gcc/genautomata.c @@ -6137,7 +6137,7 @@ evaluate_equiv_classes (automaton_t automaton, vec *equiv_classes) /* The function merges equivalent states of AUTOMATON. */ static void -merge_states (automaton_t automaton, vec equiv_classes) +merge_states (automaton_t automaton, const vec &equiv_classes) { state_t curr_state; state_t new_state; diff --git a/gcc/genextract.c b/gcc/genextract.c index 6fe4a2524fc..3ed2f6846c9 100644 --- a/gcc/genextract.c +++ b/gcc/genextract.c @@ -214,7 +214,7 @@ VEC_safe_set_locstr (md_rtx_info *info, vec *vp, /* Another helper subroutine of walk_rtx: given a vec, convert it to a NUL-terminated string in malloc memory. */ static char * -VEC_char_to_string (vec v) +VEC_char_to_string (const vec &v) { size_t n = v.length (); char *s = XNEWVEC (char, n + 1); diff --git a/gcc/genmatch.c b/gcc/genmatch.c index 4d476720c9e..dfd793d1f9b 100644 --- a/gcc/genmatch.c +++ b/gcc/genmatch.c @@ -1628,8 +1628,9 @@ public: void gen_kids (FILE *, int, bool, int); void gen_kids_1 (FILE *, int, bool, int, - vec, vec, vec, - vec, vec, vec); + const vec &, const vec &, + const vec &, const vec &, + const vec &, const vec &); void analyze (sinfo_map_t &); }; @@ -2979,12 +2980,12 @@ dt_node::gen_kids (FILE *f, int indent, bool gimple, int depth) void dt_node::gen_kids_1 (FILE *f, int indent, bool gimple, int depth, - vec gimple_exprs, - vec generic_exprs, - vec fns, - vec generic_fns, - vec preds, - vec others) + const vec &gimple_exprs, + const vec &generic_exprs, + const vec &fns, + const vec &generic_fns, + const vec &preds, + const vec &others) { char buf[128]; char *kid_opname = buf; @@ -5027,7 +5028,7 @@ parser::parse_pattern () recursively. */ static void -walk_captures (operand *op, vec > cpts) +walk_captures (operand *op, vec > &cpts) { if (! op) return; diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c index 632947950e4..02ce068d9cf 100644 --- a/gcc/gimple-ssa-store-merging.c +++ b/gcc/gimple-ssa-store-merging.c @@ -2654,7 +2654,8 @@ gather_bswap_load_refs (vec *refs, tree val) go after the = _5 store and thus change behavior. */ static bool -check_no_overlap (vec m_store_info, unsigned int i, +check_no_overlap (const vec &m_store_info, + unsigned int i, bool all_integer_cst_p, unsigned int first_order, unsigned int last_order, unsigned HOST_WIDE_INT start, unsigned HOST_WIDE_INT end, unsigned int first_earlier, diff --git a/gcc/gimple.c b/gcc/gimple.c index f1044e9c630..108daeda43b 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -241,7 +241,7 @@ gimple_build_call_1 (tree fn, unsigned nargs) specified in vector ARGS. */ gcall * -gimple_build_call_vec (tree fn, vec args) +gimple_build_call_vec (tree fn, const vec &args) { unsigned i; unsigned nargs = args.length (); @@ -338,7 +338,7 @@ gimple_build_call_internal (enum internal_fn fn, unsigned nargs, ...) specified in vector ARGS. */ gcall * -gimple_build_call_internal_vec (enum internal_fn fn, vec args) +gimple_build_call_internal_vec (enum internal_fn fn, const vec &args) { unsigned i, nargs; gcall *call; @@ -802,7 +802,7 @@ gimple_build_switch_nlabels (unsigned nlabels, tree index, tree default_label) ARGS is a vector of labels excluding the default. */ gswitch * -gimple_build_switch (tree index, tree default_label, vec args) +gimple_build_switch (tree index, tree default_label, const vec &args) { unsigned i, nlabels = args.length (); @@ -3049,7 +3049,7 @@ compare_case_labels (const void *p1, const void *p2) /* Sort the case labels in LABEL_VEC in place in ascending order. */ void -sort_case_labels (vec label_vec) +sort_case_labels (vec &label_vec) { label_vec.qsort (compare_case_labels); } @@ -3074,7 +3074,7 @@ sort_case_labels (vec label_vec) found or not. */ void -preprocess_case_label_vec_for_gimple (vec labels, +preprocess_case_label_vec_for_gimple (vec &labels, tree index_type, tree *default_casep) { diff --git a/gcc/gimple.h b/gcc/gimple.h index e7dc2a45a13..aabf68eaea0 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1516,11 +1516,11 @@ void gimple_init (gimple *g, enum gimple_code code, unsigned num_ops); gimple *gimple_alloc (enum gimple_code, unsigned CXX_MEM_STAT_INFO); greturn *gimple_build_return (tree); void gimple_call_reset_alias_info (gcall *); -gcall *gimple_build_call_vec (tree, vec ); +gcall *gimple_build_call_vec (tree, const vec &); gcall *gimple_build_call (tree, unsigned, ...); gcall *gimple_build_call_valist (tree, unsigned, va_list); gcall *gimple_build_call_internal (enum internal_fn, unsigned, ...); -gcall *gimple_build_call_internal_vec (enum internal_fn, vec ); +gcall *gimple_build_call_internal_vec (enum internal_fn, const vec &); gcall *gimple_build_call_from_tree (tree, tree); gassign *gimple_build_assign (tree, tree CXX_MEM_STAT_INFO); gassign *gimple_build_assign (tree, enum tree_code, @@ -1547,7 +1547,7 @@ gtry *gimple_build_try (gimple_seq, gimple_seq, gimple *gimple_build_wce (gimple_seq); gresx *gimple_build_resx (int); gswitch *gimple_build_switch_nlabels (unsigned, tree, tree); -gswitch *gimple_build_switch (tree, tree, vec ); +gswitch *gimple_build_switch (tree, tree, const vec &); geh_dispatch *gimple_build_eh_dispatch (int); gdebug *gimple_build_debug_bind (tree, tree, gimple * CXX_MEM_STAT_INFO); gdebug *gimple_build_debug_source_bind (tree, tree, gimple * CXX_MEM_STAT_INFO); @@ -1626,8 +1626,8 @@ extern bool nonbarrier_call_p (gimple *); extern bool infer_nonnull_range (gimple *, tree); extern bool infer_nonnull_range_by_dereference (gimple *, tree); extern bool infer_nonnull_range_by_attribute (gimple *, tree); -extern void sort_case_labels (vec); -extern void preprocess_case_label_vec_for_gimple (vec, tree, tree *); +extern void sort_case_labels (vec &); +extern void preprocess_case_label_vec_for_gimple (vec &, tree, tree *); extern void gimple_seq_set_location (gimple_seq, location_t); extern void gimple_seq_discard (gimple_seq); extern void maybe_remove_unused_call_args (struct function *, gimple *); diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c index 9c88765d1fb..a166b706b8a 100644 --- a/gcc/haifa-sched.c +++ b/gcc/haifa-sched.c @@ -891,7 +891,7 @@ static void move_block_after_check (rtx_insn *); static void move_succs (vec **, basic_block); static void sched_remove_insn (rtx_insn *); static void clear_priorities (rtx_insn *, rtx_vec_t *); -static void calc_priorities (rtx_vec_t); +static void calc_priorities (const rtx_vec_t &); static void add_jump_dependencies (rtx_insn *, rtx_insn *); #endif /* INSN_SCHEDULING */ @@ -7375,10 +7375,10 @@ haifa_sched_init (void) basic_block bb; FOR_EACH_BB_FN (bb, cfun) bbs.quick_push (bb); - sched_init_luids (bbs); + sched_init_luids (bbs.to_vec ()); sched_deps_init (true); sched_extend_target (); - haifa_init_h_i_d (bbs); + haifa_init_h_i_d (bbs.to_vec ()); } sched_init_only_bb = haifa_init_only_bb; @@ -8923,7 +8923,7 @@ clear_priorities (rtx_insn *insn, rtx_vec_t *roots_ptr) changed. ROOTS is a vector of instructions whose priority computation will trigger initialization of all cleared priorities. */ static void -calc_priorities (rtx_vec_t roots) +calc_priorities (const rtx_vec_t &roots) { int i; rtx_insn *insn; @@ -8988,7 +8988,7 @@ sched_init_insn_luid (rtx_insn *insn) The hook common_sched_info->luid_for_non_insn () is used to determine if notes, labels, etc. need luids. */ void -sched_init_luids (bb_vec_t bbs) +sched_init_luids (const bb_vec_t &bbs) { int i; basic_block bb; @@ -9062,7 +9062,7 @@ init_h_i_d (rtx_insn *insn) /* Initialize haifa_insn_data for BBS. */ void -haifa_init_h_i_d (bb_vec_t bbs) +haifa_init_h_i_d (const bb_vec_t &bbs) { int i; basic_block bb; diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 57c18af2bab..ce28ada19fe 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -2946,9 +2946,9 @@ propagate_constants_across_call (struct cgraph_edge *cs) static tree ipa_get_indirect_edge_target_1 (struct cgraph_edge *ie, - vec known_csts, - vec known_contexts, - vec known_aggs, + const vec &known_csts, + const vec &known_contexts, + const vec &known_aggs, struct ipa_agg_replacement_value *agg_reps, bool *speculative) { @@ -2985,7 +2985,7 @@ ipa_get_indirect_edge_target_1 (struct cgraph_edge *ie, } if (!t) { - struct ipa_agg_value_set *agg; + const ipa_agg_value_set *agg; if (known_aggs.length () > (unsigned int) param_index) agg = &known_aggs[param_index]; else @@ -3045,7 +3045,7 @@ ipa_get_indirect_edge_target_1 (struct cgraph_edge *ie, if (!t && known_aggs.length () > (unsigned int) param_index && !ie->indirect_info->by_ref) { - struct ipa_agg_value_set *agg = &known_aggs[param_index]; + const ipa_agg_value_set *agg = &known_aggs[param_index]; t = ipa_find_agg_cst_for_param (agg, (unsigned) param_index < known_csts.length () @@ -4267,7 +4267,7 @@ get_info_about_necessary_edges (ipcp_value *val, cgraph_node *dest, this kind of adjustment is possible. */ static bool -adjust_callers_for_value_intersection (vec callers, +adjust_callers_for_value_intersection (vec &callers, cgraph_node *node) { for (unsigned i = 0; i < callers.length (); i++) @@ -4725,8 +4725,8 @@ self_recursive_agg_pass_through_p (cgraph_edge *cs, ipa_agg_jf_item *jfunc, static void find_more_scalar_values_for_callers_subset (struct cgraph_node *node, - vec known_csts, - vec callers) + vec &known_csts, + const vec &callers) { ipa_node_params *info = ipa_node_params_sum->get (node); int i, count = ipa_get_param_count (info); @@ -4818,7 +4818,7 @@ static void find_more_contexts_for_caller_subset (cgraph_node *node, vec *known_contexts, - vec callers) + const vec &callers) { ipa_node_params *info = ipa_node_params_sum->get (node); int i, count = ipa_get_param_count (info); @@ -5179,7 +5179,7 @@ intersect_aggregates_with_edge (struct cgraph_edge *cs, int index, static struct ipa_agg_replacement_value * find_aggregate_values_for_callers_subset (struct cgraph_node *node, - vec callers) + const vec &callers) { ipa_node_params *dest_info = ipa_node_params_sum->get (node); struct ipa_agg_replacement_value *res; @@ -5413,7 +5413,7 @@ known_contexts_useful_p (vec known_contexts) /* Return a copy of KNOWN_CSTS if it is not empty, otherwise return vNULL. */ static vec -copy_useful_known_contexts (vec known_contexts) +copy_useful_known_contexts (const vec &known_contexts) { if (known_contexts_useful_p (known_contexts)) return known_contexts.copy (); diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c index 95d28757f95..cf80ce3c040 100644 --- a/gcc/ipa-fnsummary.c +++ b/gcc/ipa-fnsummary.c @@ -3967,8 +3967,8 @@ remap_edge_summaries (struct cgraph_edge *inlined_edge, class ipa_fn_summary *info, class ipa_node_params *params_summary, class ipa_fn_summary *callee_info, - vec operand_map, - vec offset_map, + const vec &operand_map, + const vec &offset_map, clause_t possible_truths, predicate *toplev_predicate) { @@ -4028,8 +4028,8 @@ remap_freqcounting_predicate (class ipa_fn_summary *info, class ipa_node_params *params_summary, class ipa_fn_summary *callee_info, vec *v, - vec operand_map, - vec offset_map, + const vec &operand_map, + const vec &offset_map, clause_t possible_truths, predicate *toplev_predicate) diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 9d896beb2ac..413446bcc46 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -1774,7 +1774,7 @@ compute_max_insns (cgraph_node *node, int insns) /* Compute badness of all edges in NEW_EDGES and add them to the HEAP. */ static void -add_new_edges_to_heap (edge_heap_t *heap, vec new_edges) +add_new_edges_to_heap (edge_heap_t *heap, vec &new_edges) { while (new_edges.length () > 0) { diff --git a/gcc/ipa-predicate.c b/gcc/ipa-predicate.c index 6dd749b8ffa..e4b11ec3ae3 100644 --- a/gcc/ipa-predicate.c +++ b/gcc/ipa-predicate.c @@ -507,8 +507,8 @@ predicate predicate::remap_after_inlining (class ipa_fn_summary *info, class ipa_node_params *params_summary, class ipa_fn_summary *callee_info, - vec operand_map, - vec offset_map, + const vec &operand_map, + const vec &offset_map, clause_t possible_truths, const predicate &toplev_predicate) { diff --git a/gcc/ipa-predicate.h b/gcc/ipa-predicate.h index 3ed71046c0c..ac52b54aa36 100644 --- a/gcc/ipa-predicate.h +++ b/gcc/ipa-predicate.h @@ -243,7 +243,7 @@ public: predicate remap_after_inlining (class ipa_fn_summary *, class ipa_node_params *params_summary, class ipa_fn_summary *, - vec, vec, + const vec &, const vec &, clause_t, const predicate &); void stream_in (class lto_input_block *); diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index f74d2e17b69..43f46a578c6 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -3562,7 +3562,7 @@ ipa_find_agg_cst_from_init (tree scalar, HOST_WIDE_INT offset, bool by_ref) initializer of a constant. */ tree -ipa_find_agg_cst_for_param (struct ipa_agg_value_set *agg, tree scalar, +ipa_find_agg_cst_for_param (const ipa_agg_value_set *agg, tree scalar, HOST_WIDE_INT offset, bool by_ref, bool *from_global_constant) { diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index 3d28a6e8640..d1cd42263f5 100644 --- a/gcc/ipa-prop.h +++ b/gcc/ipa-prop.h @@ -499,10 +499,10 @@ public: get reallocated, the member vectors and the underlying auto_vecs would get out of sync. */ ipa_call_arg_values (ipa_auto_call_arg_values *aavals) - : m_known_vals (aavals->m_known_vals), - m_known_contexts (aavals->m_known_contexts), - m_known_aggs (aavals->m_known_aggs), - m_known_value_ranges (aavals->m_known_value_ranges) + : m_known_vals (aavals->m_known_vals.to_vec ()), + m_known_contexts (aavals->m_known_contexts.to_vec ()), + m_known_aggs (aavals->m_known_aggs.to_vec ()), + m_known_value_ranges (aavals->m_known_value_ranges.to_vec ()) {} /* If m_known_vals (vector of known "scalar" values) is sufficiantly long, @@ -1092,7 +1092,7 @@ ipa_bits *ipa_get_ipa_bits_for_value (const widest_int &value, void ipa_analyze_node (struct cgraph_node *); /* Aggregate jump function related functions. */ -tree ipa_find_agg_cst_for_param (struct ipa_agg_value_set *agg, tree scalar, +tree ipa_find_agg_cst_for_param (const ipa_agg_value_set *agg, tree scalar, HOST_WIDE_INT offset, bool by_ref, bool *from_global_constant = NULL); bool ipa_load_from_parm_agg (struct ipa_func_body_info *fbi, diff --git a/gcc/ira-build.c b/gcc/ira-build.c index 4031ce18287..42120656366 100644 --- a/gcc/ira-build.c +++ b/gcc/ira-build.c @@ -1672,7 +1672,7 @@ finish_cost_vectors (void) static vec ira_loop_tree_body_rev_postorder (ira_loop_tree_node_t loop_node ATTRIBUTE_UNUSED, - vec loop_preorder) + const vec &loop_preorder) { vec topsort_nodes = vNULL; unsigned int n_loop_preorder; diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c index 925402877ec..041166658d1 100644 --- a/gcc/read-rtl.c +++ b/gcc/read-rtl.c @@ -835,7 +835,7 @@ md_reader::handle_overloaded_name (rtx original, vec *iterators) gives the iterator associated with argument I of ONAME. */ static void -add_overload_instance (overloaded_name *oname, vec iterators, rtx x) +add_overload_instance (overloaded_name *oname, const vec &iterators, rtx x) { /* Create the instance. */ overloaded_instance *instance = new overloaded_instance; diff --git a/gcc/rtl.h b/gcc/rtl.h index 5ed0d6dd6fa..2faf4ac4f97 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2416,9 +2416,9 @@ extern void get_full_rtx_cost (rtx, machine_mode, enum rtx_code, int, struct full_rtx_costs *); extern bool native_encode_rtx (machine_mode, rtx, vec &, unsigned int, unsigned int); -extern rtx native_decode_rtx (machine_mode, vec, +extern rtx native_decode_rtx (machine_mode, const vec &, unsigned int); -extern rtx native_decode_vector_rtx (machine_mode, vec, +extern rtx native_decode_vector_rtx (machine_mode, const vec &, unsigned int, unsigned int, unsigned int); extern poly_uint64 subreg_lsb (const_rtx); extern poly_uint64 subreg_size_lsb (poly_uint64, poly_uint64, poly_uint64); diff --git a/gcc/sched-int.h b/gcc/sched-int.h index 4727ab28920..868f1eb6c89 100644 --- a/gcc/sched-int.h +++ b/gcc/sched-int.h @@ -43,12 +43,12 @@ extern void sched_init_bbs (void); extern void sched_extend_luids (void); extern void sched_init_insn_luid (rtx_insn *); -extern void sched_init_luids (bb_vec_t); +extern void sched_init_luids (const bb_vec_t &); extern void sched_finish_luids (void); extern void sched_extend_target (void); -extern void haifa_init_h_i_d (bb_vec_t); +extern void haifa_init_h_i_d (const bb_vec_t &); extern void haifa_finish_h_i_d (void); /* Hooks that are common to all the schedulers. */ diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index c82101c73a4..113991ddff4 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -6742,7 +6742,7 @@ native_encode_rtx (machine_mode mode, rtx x, vec &bytes, Return the vector on success, otherwise return NULL_RTX. */ rtx -native_decode_vector_rtx (machine_mode mode, vec bytes, +native_decode_vector_rtx (machine_mode mode, const vec &bytes, unsigned int first_byte, unsigned int npatterns, unsigned int nelts_per_pattern) { @@ -6787,7 +6787,7 @@ native_decode_vector_rtx (machine_mode mode, vec bytes, Return the rtx on success, otherwise return NULL_RTX. */ rtx -native_decode_rtx (machine_mode mode, vec bytes, +native_decode_rtx (machine_mode mode, const vec &bytes, unsigned int first_byte) { if (VECTOR_MODE_P (mode)) diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c index 666839755d0..d9b9b4c6e84 100644 --- a/gcc/tree-call-cdce.c +++ b/gcc/tree-call-cdce.c @@ -761,7 +761,7 @@ get_no_error_domain (enum built_in_function fnc) condition are separated by NULL tree in the vector. */ static void -gen_shrink_wrap_conditions (gcall *bi_call, vec conds, +gen_shrink_wrap_conditions (gcall *bi_call, const vec &conds, unsigned int *nconds) { gcall *call; @@ -797,7 +797,8 @@ gen_shrink_wrap_conditions (gcall *bi_call, vec conds, when it is non-null, it is called while all of the CONDS are true. */ static void -shrink_wrap_one_built_in_call_with_conds (gcall *bi_call, vec conds, +shrink_wrap_one_built_in_call_with_conds (gcall *bi_call, + const vec &conds, unsigned int nconds, gcall *bi_newcall = NULL) { @@ -1132,7 +1133,7 @@ use_internal_fn (gcall *call) wrapping transformation. */ static void -shrink_wrap_conditional_dead_built_in_calls (vec calls) +shrink_wrap_conditional_dead_built_in_calls (const vec &calls) { unsigned i = 0; diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index b6abd8b8de7..210ac2851a5 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -2643,7 +2643,7 @@ create_intersect_range_checks (class loop *loop, tree *cond_expr, void create_runtime_alias_checks (class loop *loop, - vec *alias_pairs, + const vec *alias_pairs, tree * cond_expr) { tree part_cond_expr; @@ -5635,9 +5635,9 @@ compute_affine_dependence (struct data_dependence_relation *ddr, is small enough to be handled. */ bool -compute_all_dependences (vec datarefs, +compute_all_dependences (const vec &datarefs, vec *dependence_relations, - vec loop_nest, + const vec &loop_nest, bool compute_self_and_rr) { struct data_dependence_relation *ddr; diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h index 8001cc54f51..a0ff2a80263 100644 --- a/gcc/tree-data-ref.h +++ b/gcc/tree-data-ref.h @@ -551,9 +551,9 @@ extern struct data_dependence_relation *initialize_data_dependence_relation extern void compute_affine_dependence (struct data_dependence_relation *, loop_p); extern void compute_self_dependence (struct data_dependence_relation *); -extern bool compute_all_dependences (vec , +extern bool compute_all_dependences (const vec &, vec *, - vec, bool); + const vec &, bool); extern tree find_data_references_in_bb (class loop *, basic_block, vec *); extern unsigned int dr_alignment (innermost_loop_behavior *); @@ -578,7 +578,8 @@ extern int data_ref_compare_tree (tree, tree); extern void prune_runtime_alias_test_list (vec *, poly_uint64); extern void create_runtime_alias_checks (class loop *, - vec *, tree*); + const vec *, + tree*); extern tree dr_direction_indicator (struct data_reference *); extern tree dr_zero_step_indicator (struct data_reference *); extern bool dr_known_forward_stride_p (struct data_reference *); @@ -666,7 +667,7 @@ ddr_dependence_level (ddr_p ddr) /* Return the index of the variable VAR in the LOOP_NEST array. */ static inline int -index_in_loop_nest (int var, vec loop_nest) +index_in_loop_nest (int var, const vec &loop_nest) { class loop *loopi; int var_index; diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 345488e2a19..49e89cffa1a 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -2208,7 +2208,7 @@ insert_gimplified_predicates (loop_p loop) mask if it was created for given SIZE and -1 otherwise. */ static int -mask_exists (int size, vec vec) +mask_exists (int size, const vec &vec) { unsigned int ix; int v; diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 65aa1df4aba..a984d2124f7 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -527,7 +527,8 @@ class loop_distribution /* Build the vertices of the reduced dependence graph RDG. Return false if that failed. */ - bool create_rdg_vertices (struct graph *rdg, vec stmts, loop_p loop); + bool create_rdg_vertices (struct graph *rdg, const vec &stmts, + loop_p loop); /* Initialize STMTS with all the statements of LOOP. We use topological order to discover all statements. The order is important because @@ -646,7 +647,7 @@ class loop_distribution statements from STMTS into separate loops. Returns the number of distributed loops. Set NB_CALLS to number of generated builtin calls. Set *DESTROY_P to whether LOOP needs to be destroyed. */ - int distribute_loop (class loop *loop, vec stmts, + int distribute_loop (class loop *loop, const vec &stmts, control_dependences *cd, int *nb_calls, bool *destroy_p, bool only_patterns_p); @@ -699,7 +700,8 @@ bb_top_order_cmp_r (const void *x, const void *y, void *loop) } bool -loop_distribution::create_rdg_vertices (struct graph *rdg, vec stmts, +loop_distribution::create_rdg_vertices (struct graph *rdg, + const vec &stmts, loop_p loop) { int i; @@ -1953,7 +1955,7 @@ loop_distribution::rdg_build_partitions (struct graph *rdg, /* Dump to FILE the PARTITIONS. */ static void -dump_rdg_partitions (FILE *file, vec partitions) +dump_rdg_partitions (FILE *file, const vec &partitions) { int i; partition *partition; @@ -1963,10 +1965,10 @@ dump_rdg_partitions (FILE *file, vec partitions) } /* Debug PARTITIONS. */ -extern void debug_rdg_partitions (vec ); +extern void debug_rdg_partitions (const vec &); DEBUG_FUNCTION void -debug_rdg_partitions (vec partitions) +debug_rdg_partitions (const vec &partitions) { dump_rdg_partitions (stderr, partitions); } @@ -2017,7 +2019,7 @@ number_of_rw_in_partition (struct graph *rdg, partition *partition) static bool partition_contains_all_rw (struct graph *rdg, - vec partitions) + const vec &partitions) { int i; partition *partition; @@ -2921,7 +2923,8 @@ loop_distribution::finalize_partitions (class loop *loop, Set *DESTROY_P to whether LOOP needs to be destroyed. */ int -loop_distribution::distribute_loop (class loop *loop, vec stmts, +loop_distribution::distribute_loop (class loop *loop, + const vec &stmts, control_dependences *cd, int *nb_calls, bool *destroy_p, bool only_patterns_p) { diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index fe1baef32a7..bb547572653 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -3713,7 +3713,7 @@ ref_conflicts_with_region (gimple_stmt_iterator gsi, ao_ref *ref, reduction results in REDUCTION_STORES. */ static bool -oacc_entry_exit_ok_1 (bitmap in_loop_bbs, vec region_bbs, +oacc_entry_exit_ok_1 (bitmap in_loop_bbs, const vec ®ion_bbs, reduction_info_table_type *reduction_list, bitmap reduction_stores) { @@ -3828,7 +3828,8 @@ oacc_entry_exit_ok_1 (bitmap in_loop_bbs, vec region_bbs, if any changes were made. */ static bool -oacc_entry_exit_single_gang (bitmap in_loop_bbs, vec region_bbs, +oacc_entry_exit_single_gang (bitmap in_loop_bbs, + const vec ®ion_bbs, bitmap reduction_stores) { tree gang_pos = NULL_TREE; diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index 7de47edbcb3..c778f7e87fd 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -2511,7 +2511,7 @@ sm_seq_valid_bb (class loop *loop, basic_block bb, tree vdef, static void hoist_memory_references (class loop *loop, bitmap mem_refs, - vec exits) + const vec &exits) { im_mem_ref *ref; unsigned i; @@ -2906,7 +2906,7 @@ find_refs_for_sm (class loop *loop, bitmap sm_executed, bitmap refs_to_sm) static bool loop_suitable_for_sm (class loop *loop ATTRIBUTE_UNUSED, - vec exits) + const vec &exits) { unsigned i; edge ex; diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index b5add827018..3f9954c88a3 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -3929,7 +3929,7 @@ wide_int_cmp (const void *p1, const void *p2) Lookup by binary search. */ static int -bound_index (vec bounds, const widest_int &bound) +bound_index (const vec &bounds, const widest_int &bound) { unsigned int end = bounds.length (); unsigned int begin = 0; diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index d86fe26bd07..a715cddc13d 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -3100,7 +3100,7 @@ create_expression_by_pieces (basic_block block, pre_expr expr, static bool insert_into_preds_of_block (basic_block block, unsigned int exprnum, - vec avail) + vec &avail) { pre_expr expr = expression_for_id (exprnum); pre_expr newphi; diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 2dd4435b981..8498cfc7aa8 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -4486,7 +4486,7 @@ get_ops (tree var, enum tree_code code, vec *ops, stmts. */ static tree -update_ops (tree var, enum tree_code code, vec ops, +update_ops (tree var, enum tree_code code, const vec &ops, unsigned int *pidx, class loop *loop) { gimple *stmt = SSA_NAME_DEF_STMT (var); @@ -5033,7 +5033,7 @@ remove_visited_stmt_chain (tree var) cases, but it is unlikely to be worth it. */ static void -swap_ops_for_binary_stmt (vec ops, +swap_ops_for_binary_stmt (const vec &ops, unsigned int opindex, gimple *stmt) { operand_entry *oe1, *oe2, *oe3; @@ -5104,7 +5104,8 @@ insert_stmt_before_use (gimple *stmt, gimple *stmt_to_insert) static tree rewrite_expr_tree (gimple *stmt, enum tree_code rhs_code, unsigned int opindex, - vec ops, bool changed, bool next_changed) + const vec &ops, bool changed, + bool next_changed) { tree rhs1 = gimple_assign_rhs1 (stmt); tree rhs2 = gimple_assign_rhs2 (stmt); @@ -5326,7 +5327,7 @@ get_reassociation_width (int ops_num, enum tree_code opc, static void rewrite_expr_tree_parallel (gassign *stmt, int width, - vec ops) + const vec &ops) { enum tree_code opcode = gimple_assign_rhs_code (stmt); int op_num = ops.length (); diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 64e3a707f5c..3451ff1f157 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -1040,9 +1040,8 @@ copy_reference_ops_from_ref (tree ref, vec *result) bool ao_ref_init_from_vn_reference (ao_ref *ref, alias_set_type set, alias_set_type base_set, - tree type, vec ops) + tree type, const vec &ops) { - vn_reference_op_t op; unsigned i; tree base = NULL_TREE; tree *op0_p = &base; @@ -1061,7 +1060,10 @@ ao_ref_init_from_vn_reference (ao_ref *ref, size = wi::to_poly_offset (size_tree); /* Lower the final access size from the outermost expression. */ - op = &ops[0]; + const_vn_reference_op_t cst_op = &ops[0]; + /* Cast away constness for the sake of the const-unsafe + FOR_EACH_VEC_ELT(). */ + vn_reference_op_t op = const_cast(cst_op); size_tree = NULL_TREE; if (op->opcode == COMPONENT_REF) size_tree = DECL_SIZE (op->op0); @@ -1092,7 +1094,7 @@ ao_ref_init_from_vn_reference (ao_ref *ref, && op->op0 && DECL_P (TREE_OPERAND (op->op0, 0))) { - vn_reference_op_t pop = &ops[i-1]; + const_vn_reference_op_t pop = &ops[i-1]; base = TREE_OPERAND (op->op0, 0); if (known_eq (pop->off, -1)) { diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h index 6df526c269b..96100596d2e 100644 --- a/gcc/tree-ssa-sccvn.h +++ b/gcc/tree-ssa-sccvn.h @@ -254,7 +254,7 @@ tree vn_nary_op_lookup_pieces (unsigned int, enum tree_code, vn_nary_op_t vn_nary_op_insert_pieces (unsigned int, enum tree_code, tree, tree *, tree, unsigned int); bool ao_ref_init_from_vn_reference (ao_ref *, alias_set_type, alias_set_type, - tree, vec ); + tree, const vec &); vec vn_reference_operands_for_lookup (tree); tree vn_reference_lookup_pieces (tree, alias_set_type, alias_set_type, tree, vec , diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 7163438e23d..e8e35362062 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -3713,8 +3713,8 @@ get_constraint_for_rhs (tree t, vec *results) entries in *LHSC. */ static void -process_all_all_constraints (vec lhsc, - vec rhsc) +process_all_all_constraints (const vec &lhsc, + const vec &rhsc) { struct constraint_expr *lhsp, *rhsp; unsigned i, j; @@ -3814,7 +3814,7 @@ do_structure_copy (tree lhsop, tree rhsop) /* Create constraints ID = { rhsc }. */ static void -make_constraints_to (unsigned id, vec rhsc) +make_constraints_to (unsigned id, const vec &rhsc) { struct constraint_expr *c; struct constraint_expr includes; @@ -4158,7 +4158,7 @@ handle_rhs_call (gcall *stmt, vec *results) the LHS point to global and escaped variables. */ static void -handle_lhs_call (gcall *stmt, tree lhs, int flags, vec rhsc, +handle_lhs_call (gcall *stmt, tree lhs, int flags, vec &rhsc, tree fndecl) { auto_vec lhsc; @@ -4609,9 +4609,10 @@ find_func_aliases_for_builtin_call (struct function *fn, gcall *t) case BUILT_IN_REALLOC: if (gimple_call_lhs (t)) { + auto_vec rhsc; handle_lhs_call (t, gimple_call_lhs (t), gimple_call_return_flags (t) | ERF_NOALIAS, - vNULL, fndecl); + rhsc, fndecl); get_constraint_for_ptr_offset (gimple_call_lhs (t), NULL_TREE, &lhsc); get_constraint_for_ptr_offset (gimple_call_arg (t, 0), @@ -5682,7 +5683,7 @@ fieldoff_compare (const void *pa, const void *pb) /* Sort a fieldstack according to the field offset and sizes. */ static void -sort_fieldstack (vec fieldstack) +sort_fieldstack (vec &fieldstack) { fieldstack.qsort (fieldoff_compare); } @@ -6092,7 +6093,7 @@ create_function_info_for (tree decl, const char *name, bool add_id, FIELDSTACK is assumed to be sorted by offset. */ static bool -check_for_overlaps (vec fieldstack) +check_for_overlaps (const vec &fieldstack) { fieldoff_s *fo = NULL; unsigned int i; diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 579149dfd61..1e929fa002c 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -208,7 +208,7 @@ vect_mark_for_runtime_alias_test (ddr_p ddr, loop_vec_info loop_vinfo) static void vect_check_nonzero_value (loop_vec_info loop_vinfo, tree value) { - vec checks = LOOP_VINFO_CHECK_NONZERO (loop_vinfo); + vec checks = LOOP_VINFO_CHECK_NONZERO (loop_vinfo).to_vec (); for (unsigned int i = 0; i < checks.length(); ++i) if (checks[i] == value) return; @@ -2346,7 +2346,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) if (do_versioning) { vec may_misalign_stmts - = LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo); + = LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo).to_vec (); stmt_vec_info stmt_info; /* It can now be assumed that the data references in the statements @@ -3360,7 +3360,8 @@ static void vect_check_lower_bound (loop_vec_info loop_vinfo, tree expr, bool unsigned_p, poly_uint64 min_value) { - vec lower_bounds = LOOP_VINFO_LOWER_BOUNDS (loop_vinfo); + vec lower_bounds + = LOOP_VINFO_LOWER_BOUNDS (loop_vinfo).to_vec (); for (unsigned int i = 0; i < lower_bounds.length (); ++i) if (operand_equal_p (lower_bounds[i].expr, expr, 0)) { @@ -3462,7 +3463,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo) typedef pair_hash tree_pair_hash; hash_set compared_objects; - vec may_alias_ddrs = LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo); + vec may_alias_ddrs = LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo).to_vec (); vec &comp_alias_ddrs = LOOP_VINFO_COMP_ALIAS_DDRS (loop_vinfo); vec &check_unequal_addrs @@ -5335,7 +5336,7 @@ vect_store_lanes_supported (tree vectype, unsigned HOST_WIDE_INT count, I4: 6 14 22 30 7 15 23 31. */ void -vect_permute_store_chain (vec_info *vinfo, vec dr_chain, +vect_permute_store_chain (vec_info *vinfo, vec &dr_chain, unsigned int length, stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c index 012f48bd487..9ff48fec729 100644 --- a/gcc/tree-vect-loop-manip.c +++ b/gcc/tree-vect-loop-manip.c @@ -3168,7 +3168,7 @@ vect_create_cond_for_align_checks (loop_vec_info loop_vinfo, tree *cond_expr, gimple_seq *cond_expr_stmt_list) { - vec may_misalign_stmts + const vec &may_misalign_stmts = LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo); stmt_vec_info stmt_info; int mask = LOOP_VINFO_PTR_MASK (loop_vinfo); @@ -3259,7 +3259,8 @@ vect_create_cond_for_align_checks (loop_vec_info loop_vinfo, static void vect_create_cond_for_unequal_addrs (loop_vec_info loop_vinfo, tree *cond_expr) { - vec pairs = LOOP_VINFO_CHECK_UNEQUAL_ADDRS (loop_vinfo); + const vec &pairs + = LOOP_VINFO_CHECK_UNEQUAL_ADDRS (loop_vinfo); unsigned int i; vec_object_pair *pair; FOR_EACH_VEC_ELT (pairs, i, pair) @@ -3278,7 +3279,8 @@ vect_create_cond_for_unequal_addrs (loop_vec_info loop_vinfo, tree *cond_expr) static void vect_create_cond_for_lower_bounds (loop_vec_info loop_vinfo, tree *cond_expr) { - vec lower_bounds = LOOP_VINFO_LOWER_BOUNDS (loop_vinfo); + const vec &lower_bounds + = LOOP_VINFO_LOWER_BOUNDS (loop_vinfo); for (unsigned int i = 0; i < lower_bounds.length (); ++i) { tree expr = lower_bounds[i].expr; @@ -3320,7 +3322,7 @@ vect_create_cond_for_lower_bounds (loop_vec_info loop_vinfo, tree *cond_expr) void vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo, tree * cond_expr) { - vec comp_alias_ddrs = + const vec &comp_alias_ddrs = LOOP_VINFO_COMP_ALIAS_DDRS (loop_vinfo); if (comp_alias_ddrs.is_empty ()) diff --git a/gcc/tree-vect-slp-patterns.c b/gcc/tree-vect-slp-patterns.c index d536494a1bd..571b29322c5 100644 --- a/gcc/tree-vect-slp-patterns.c +++ b/gcc/tree-vect-slp-patterns.c @@ -746,7 +746,7 @@ vect_match_call_complex_mla (slp_tree node, unsigned child, of the negate node. */ static inline bool -vect_normalize_conj_loc (vec args, bool *neg_first_p = NULL) +vect_normalize_conj_loc (vec &args, bool *neg_first_p = NULL) { gcc_assert (args.length () == 2); bool neg_found = false; @@ -790,7 +790,8 @@ is_eq_or_top (complex_perm_kinds_t perm, complex_perm_kinds_t kind) static inline bool vect_validate_multiplication (slp_tree_to_load_perm_map_t *perm_cache, - vec left_op, vec right_op, + const vec &left_op, + const vec &right_op, bool neg_first, bool *conj_first_operand, bool fms) { @@ -862,7 +863,8 @@ vect_validate_multiplication (slp_tree_to_load_perm_map_t *perm_cache, static inline bool vect_validate_multiplication (slp_tree_to_load_perm_map_t *perm_cache, - vec op, complex_perm_kinds_t permKind) + const vec &op, + complex_perm_kinds_t permKind) { /* The left node is the more common case, test it first. */ if (!is_eq_or_top (linear_loads_p (perm_cache, op[0]), permKind)) diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 227d6aa3ee8..5a4b6fe8b0c 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3316,7 +3316,8 @@ vect_analyze_slp_instance (vec_info *vinfo, else if (kind == slp_inst_kind_reduc_group) { /* Collect reduction statements. */ - vec reductions = as_a (vinfo)->reductions; + const vec &reductions + = as_a (vinfo)->reductions; scalar_stmts.create (reductions.length ()); for (i = 0; reductions.iterate (i, &next_info); i++) if (STMT_VINFO_RELEVANT_P (next_info) @@ -4047,7 +4048,8 @@ vect_make_slp_decision (loop_vec_info loop_vinfo) { unsigned int i; poly_uint64 unrolling_factor = 1; - vec slp_instances = LOOP_VINFO_SLP_INSTANCES (loop_vinfo); + const vec &slp_instances + = LOOP_VINFO_SLP_INSTANCES (loop_vinfo); slp_instance instance; int decided_to_slp = 0; @@ -5814,7 +5816,7 @@ vect_slp_region (vec bbs, vec datarefs, true if anything in the basic-block was vectorized. */ static bool -vect_slp_bbs (vec bbs) +vect_slp_bbs (const vec &bbs) { vec datarefs = vNULL; auto_vec dataref_groups; @@ -5959,7 +5961,7 @@ vect_slp_function (function *fun) void duplicate_and_interleave (vec_info *vinfo, gimple_seq *seq, tree vector_type, - vec elts, unsigned int nresults, + const vec &elts, unsigned int nresults, vec &results) { unsigned int nelts = elts.length (); @@ -6315,7 +6317,7 @@ vect_get_slp_defs (vec_info *, bool vect_transform_slp_perm_load (vec_info *vinfo, - slp_tree node, vec dr_chain, + slp_tree node, const vec &dr_chain, gimple_stmt_iterator *gsi, poly_uint64 vf, bool analyze_only, unsigned *n_perms, unsigned int *n_loads, bool dce_chain) @@ -7329,7 +7331,7 @@ vect_schedule_scc (vec_info *vinfo, slp_tree node, slp_instance instance, /* Generate vector code for SLP_INSTANCES in the loop/basic block. */ void -vect_schedule_slp (vec_info *vinfo, vec slp_instances) +vect_schedule_slp (vec_info *vinfo, const vec &slp_instances) { slp_instance instance; unsigned int i; diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 4ee11b2041a..7d99199b968 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -4437,7 +4437,7 @@ static void vect_create_vectorized_demotion_stmts (vec_info *vinfo, vec *vec_oprnds, int multi_step_cvt, stmt_vec_info stmt_info, - vec vec_dsts, + vec &vec_dsts, gimple_stmt_iterator *gsi, slp_tree slp_node, enum tree_code code) { diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index fa28336d429..a707f6e243c 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1927,8 +1927,8 @@ extern bool vect_grouped_store_supported (tree, unsigned HOST_WIDE_INT); extern bool vect_store_lanes_supported (tree, unsigned HOST_WIDE_INT, bool); extern bool vect_grouped_load_supported (tree, bool, unsigned HOST_WIDE_INT); extern bool vect_load_lanes_supported (tree, unsigned HOST_WIDE_INT, bool); -extern void vect_permute_store_chain (vec_info *, - vec ,unsigned int, stmt_vec_info, +extern void vect_permute_store_chain (vec_info *, vec &, + unsigned int, stmt_vec_info, gimple_stmt_iterator *, vec *); extern tree vect_setup_realignment (vec_info *, stmt_vec_info, gimple_stmt_iterator *, @@ -2009,12 +2009,12 @@ extern tree cse_and_gimplify_to_preheader (loop_vec_info, tree); extern void vect_slp_init (void); extern void vect_slp_fini (void); extern void vect_free_slp_instance (slp_instance); -extern bool vect_transform_slp_perm_load (vec_info *, slp_tree, vec, +extern bool vect_transform_slp_perm_load (vec_info *, slp_tree, const vec &, gimple_stmt_iterator *, poly_uint64, bool, unsigned *, unsigned * = nullptr, bool = false); extern bool vect_slp_analyze_operations (vec_info *); -extern void vect_schedule_slp (vec_info *, vec); +extern void vect_schedule_slp (vec_info *, const vec &); extern opt_result vect_analyze_slp (vec_info *, unsigned); extern bool vect_make_slp_decision (loop_vec_info); extern void vect_detect_hybrid_slp (loop_vec_info); @@ -2032,7 +2032,7 @@ extern bool can_duplicate_and_interleave_p (vec_info *, unsigned int, tree, unsigned int * = NULL, tree * = NULL, tree * = NULL); extern void duplicate_and_interleave (vec_info *, gimple_seq *, tree, - vec, unsigned int, vec &); + const vec &, unsigned int, vec &); extern int vect_get_place_in_interleaving_chain (stmt_vec_info, stmt_vec_info); extern bool vect_update_shared_vectype (stmt_vec_info, tree); extern slp_tree vect_create_new_slp_node (unsigned, tree_code); diff --git a/gcc/tree.c b/gcc/tree.c index 1aa6e557a04..bead1ac134c 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -2047,7 +2047,7 @@ make_vector (unsigned log2_npatterns, are extracted from V, a vector of CONSTRUCTOR_ELT. */ tree -build_vector_from_ctor (tree type, vec *v) +build_vector_from_ctor (tree type, const vec *v) { if (vec_safe_length (v) == 0) return build_zero_cst (type); @@ -14428,7 +14428,7 @@ test_labels () are given by VALS. */ static tree -build_vector (tree type, vec vals MEM_STAT_DECL) +build_vector (tree type, const vec &vals MEM_STAT_DECL) { gcc_assert (known_eq (vals.length (), TYPE_VECTOR_SUBPARTS (type))); tree_vector_builder builder (type, vals.length (), 1); @@ -14439,7 +14439,7 @@ build_vector (tree type, vec vals MEM_STAT_DECL) /* Check that VECTOR_CST ACTUAL contains the elements in EXPECTED. */ static void -check_vector_cst (vec expected, tree actual) +check_vector_cst (const vec &expected, tree actual) { ASSERT_KNOWN_EQ (expected.length (), TYPE_VECTOR_SUBPARTS (TREE_TYPE (actual))); @@ -14452,7 +14452,7 @@ check_vector_cst (vec expected, tree actual) and that its elements match EXPECTED. */ static void -check_vector_cst_duplicate (vec expected, tree actual, +check_vector_cst_duplicate (const vec &expected, tree actual, unsigned int npatterns) { ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual)); @@ -14468,7 +14468,7 @@ check_vector_cst_duplicate (vec expected, tree actual, EXPECTED. */ static void -check_vector_cst_fill (vec expected, tree actual, +check_vector_cst_fill (const vec &expected, tree actual, unsigned int npatterns) { ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual)); @@ -14483,7 +14483,7 @@ check_vector_cst_fill (vec expected, tree actual, and that its elements match EXPECTED. */ static void -check_vector_cst_stepped (vec expected, tree actual, +check_vector_cst_stepped (const vec &expected, tree actual, unsigned int npatterns) { ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual)); diff --git a/gcc/tree.h b/gcc/tree.h index 060ddee09dd..7043ae2cddc 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4474,7 +4474,7 @@ extern tree build_int_cst (tree, poly_int64); extern tree build_int_cstu (tree type, poly_uint64); extern tree build_int_cst_type (tree, poly_int64); extern tree make_vector (unsigned, unsigned CXX_MEM_STAT_INFO); -extern tree build_vector_from_ctor (tree, vec *); +extern tree build_vector_from_ctor (tree, const vec *); extern tree build_vector_from_val (tree, tree); extern tree build_uniform_cst (tree, tree); extern tree build_vec_series (tree, tree, tree); diff --git a/gcc/vec.c b/gcc/vec.c index f9dbb2cac31..6d767cc12c1 100644 --- a/gcc/vec.c +++ b/gcc/vec.c @@ -38,16 +38,6 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic-core.h" #endif -/* vNULL is an empty type with a template cast operation that returns - a zero-initialized vec instance. Use this when you want - to assign nil values to new vec instances or pass a nil vector as - a function call argument. - - We use this technique because vec must be PODs (they are - stored in unions and passed in vararg functions), this means that - they cannot have ctors/dtors. */ -vnull vNULL; - /* Vector memory usage. */ class vec_usage: public mem_usage { @@ -282,6 +272,42 @@ safe_push_range (vec &v, int start, int limit) v.safe_push (i); } +/* Verify forms of initialization. */ + +static void +test_init () +{ + { + vec v1{ }; + ASSERT_EQ (0, v1.length ()); + + vec v2 (v1); + ASSERT_EQ (0, v2.length ()); + } + + { + vec v1 = vec(); + ASSERT_EQ (0, v1.length ()); + + vec v2 = v1; + ASSERT_EQ (0, v2.length ()); + } + + { + vec v1 (vNULL); + ASSERT_EQ (0, v1.length ()); + v1.safe_push (1); + + vec v2 (v1); + ASSERT_EQ (1, v1.length ()); + v2.safe_push (1); + + ASSERT_EQ (2, v1.length ()); + ASSERT_EQ (2, v2.length ()); + v1.release (); + } +} + /* Verify that vec::quick_push works correctly. */ static void @@ -547,6 +573,7 @@ test_auto_delete_vec () void vec_c_tests () { + test_init (); test_quick_push (); test_safe_push (); test_truncate (); diff --git a/gcc/vec.h b/gcc/vec.h index 30ef9a69473..d005c908bf4 100644 --- a/gcc/vec.h +++ b/gcc/vec.h @@ -541,18 +541,16 @@ vec_copy_construct (T *dst, const T *src, unsigned n) ::new (static_cast(dst)) T (*src); } -/* Type to provide NULL values for vec. This is used to - provide nil initializers for vec instances. Since vec must be - a POD, we cannot have proper ctor/dtor for it. To initialize - a vec instance, you can assign it the value vNULL. This isn't - needed for file-scope and function-local static vectors, which - are zero-initialized by default. */ -struct vnull -{ - template - CONSTEXPR operator vec () const { return vec(); } -}; -extern vnull vNULL; +/* Type to provide zero-initialized values for vec. This is + used to provide nil initializers for vec instances. Since vec must + be a trivially copyable type that can be copied by memcpy and zeroed + out by memset, it must have defaulted default and copy ctor and copy + assignment. To initialize a vec either use value initialization + (e.g., vec() or vec v{ };) or assign it the value vNULL. This isn't + needed for file-scope and function-local static vectors, which are + zero-initialized by default. */ +struct vnull { }; +constexpr vnull vNULL{ }; /* Embeddable vector. These vectors are suitable to be embedded @@ -1431,10 +1429,34 @@ gt_pch_nx (vec *v, gt_pointer_operator op, void *cookie) As long as we use C++03, we cannot have constructors nor destructors in classes that are stored in unions. */ +template +class auto_vec; + template struct vec { public: + /* Default ctors to ensure triviality. Use value-initialization + (e.g., vec() or vec v{ };) or vNULL to create a zero-initialized + instance. */ + vec () = default; + vec (const vec &) = default; + /* Initialization from the generic vNULL. */ + vec (vnull): m_vec () { } + /* Same as default ctor: vec storage must be released manually. */ + ~vec () = default; + + /* Defaulted same as copy ctor. */ + vec& operator= (const vec &) = default; + + /* Prevent implicit conversion from auto_vec. Use auto_vec::to_vec() + instead. */ + template + vec (auto_vec &) = delete; + + template + void operator= (auto_vec &) = delete; + /* Memory allocation and deallocation for the embedded vector. Needed because we cannot have proper ctors/dtors defined. */ void create (unsigned nelems CXX_MEM_STAT_INFO); @@ -1522,7 +1544,7 @@ public: want to ask for internal storage for vectors on the stack because if the size of the vector is larger than the internal storage that space is wasted. */ -template +template class auto_vec : public vec { public: @@ -1549,6 +1571,13 @@ public: this->release (); } + /* Explicitly convert to the base class. There is no conversion + from a const auto_vec because a copy of the returned vec can + be used to modify *THIS. */ + vec to_vec () { + return *static_cast *>(this); + } + private: vec m_auto; T m_data[MAX (N - 1, 1)]; @@ -1602,6 +1631,13 @@ public: return *this; } + /* Explicitly convert to the base class. There is no conversion + from a const auto_vec because a copy of the returned vec can + be used to modify *THIS. */ + vec to_vec () { + return *static_cast *>(this); + } + // You probably don't want to copy a vector, so these are deleted to prevent // unintentional use. If you really need a copy of the vectors contents you // can use copy (). @@ -1781,7 +1817,7 @@ template inline vec vec::copy (ALONE_MEM_STAT_DECL) const { - vec new_vec = vNULL; + vec new_vec{ }; if (length ()) new_vec.m_vec = m_vec->copy (ALONE_PASS_MEM_STAT); return new_vec; --------------0517D434F9B602AA537BD1C3--