aboutsummaryrefslogtreecommitdiff
path: root/gcc/calls.c
AgeCommit message (Collapse)AuthorFilesLines
2020-10-20Convert -Wrestrict pass to ranger.Aldy Hernandez1-2/+24
There is one adjustment to a C++ test which now gives a false positive. After talking with Martin Sebor, we've concluded this is expected. There is no way to communicate that libstdc++ allocated objects are always less than PTRDIFF_MAX. gcc/ChangeLog: * calls.c (get_size_range): Adjust to work with ranger. * calls.h (get_size_range): Add ranger argument to prototype. * gimple-ssa-warn-restrict.c (class wrestrict_dom_walker): Remove. (check_call): Pull out of wrestrict_dom_walker into a static function. (wrestrict_dom_walker::before_dom_children): Rename to... (wrestrict_walk): ...this. (pass_wrestrict::execute): Instantiate ranger. (class builtin_memref): Add stmt and query fields. (builtin_access::builtin_access): Add range_query field. (builtin_memref::builtin_memref): Same. (builtin_memref::extend_offset_range): Same. (builtin_access::builtin_access): Make work with ranger. (wrestrict_dom_walker::check_call): Pull out into... (check_call): ...here. (check_bounds_or_overlap): Add range_query argument. * gimple-ssa-warn-restrict.h (check_bounds_or_overlap): Add range_query and gimple stmt arguments. gcc/testsuite/ChangeLog: * gcc.dg/Wrestrict-22.c: New test. * g++.dg/torture/pr92421.C: Adjust for ranger. libstdc++-v3/ChangeLog: * testsuite/21_strings/basic_string/capacity/1.cc: Pass -Wno-stringop-overflow to test.
2020-10-12Generalize compute_objsize to return maximum size/offset instead of failing ↵Martin Sebor1-21/+48
(PR middle-end/97023). Also resolves: PR middle-end/97342 - bogus -Wstringop-overflow with nonzero signed and unsigned offsets PR middle-end/97023 - missing warning on buffer overflow in chained mempcpy PR middle-end/96384 - bogus -Wstringop-overflow= storing into multidimensional array with index in range gcc/ChangeLog: PR middle-end/97342 PR middle-end/97023 PR middle-end/96384 * builtins.c (access_ref::access_ref): Initialize new member. Use new enum. (access_ref::size_remaining): Define new member function. (inform_access): Handle expressions referencing objects. (gimple_call_alloc_size): Call get_size_range instead of get_range. (gimple_call_return_array): New function. (get_range): Rename... (get_offset_range): ...to this. Improve detection of ranges from types of expressions. (gimple_call_return_array): Adjust calls to get_range per above. (compute_objsize): Same. Set maximum size or offset instead of failing for unknown objects and handle more kinds of expressions. (compute_objsize): Call access_ref::size_remaining. (compute_objsize): Have transitional wrapper fail for pointers into unknown objects. (expand_builtin_strncmp): Call access_ref::size_remaining and handle new cases. * builtins.h (access_ref::size_remaining): Declare new member function. (access_ref::set_max_size_range): Define new member function. (access_ref::add_ofset, access_ref::add_max_ofset): Same. (access_ref::add_base0): New data member. * calls.c (get_size_range): Change argument type. Handle new condition. * calls.h (get_size_range): Adjust signature. (enum size_range_flags): Define new type. * gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Correct argument to get_size_range. * tree-ssa-strlen.c (get_range): Handle anti-ranges. (maybe_warn_overflow): Check DECL_P before assuming it's one. gcc/testsuite/ChangeLog: PR middle-end/97342 PR middle-end/97023 PR middle-end/96384 * c-c++-common/Wrestrict.c: Adjust comment. * gcc.dg/Wstringop-overflow-34.c: Remove xfail. * gcc.dg/Wstringop-overflow-43.c: Remove xfails. Adjust regex patterns. * gcc.dg/pr51683.c: Prune out expected warning. * gcc.target/i386/pr60693.c: Same. * g++.dg/warn/Wplacement-new-size-8.C: New test. * gcc.dg/Wstringop-overflow-41.c: New test. * gcc.dg/Wstringop-overflow-44.s: New test. * gcc.dg/Wstringop-overflow-45.c: New test. * gcc.dg/Wstringop-overflow-46.c: New test. * gcc.dg/Wstringop-overflow-47.c: New test. * gcc.dg/Wstringop-overflow-49.c: New test. * gcc.dg/Wstringop-overflow-50.c: New test. * gcc.dg/Wstringop-overflow-51.c: New test. * gcc.dg/Wstringop-overflow-52.c: New test. * gcc.dg/Wstringop-overflow-53.c: New test. * gcc.dg/Wstringop-overflow-54.c: New test. * gcc.dg/Wstringop-overflow-55.c: New test. * gcc.dg/Wstringop-overread-5.c: New test.
2020-10-02Commonize handling of attr-fnspecJan Hubicka1-17/+8
* attr-fnspec.h: New file. * calls.c (decl_return_flags): Use attr_fnspec. * gimple.c (gimple_call_arg_flags): Use attr_fnspec. (gimple_call_return_flags): Use attr_fnspec. * tree-into-ssa.c (pass_build_ssa::execute): Use attr_fnspec. * tree-ssa-alias.c (attr_fnspec::verify): New member fuction.
2020-09-29Correct and improve -Wnonnull for calls to functions with VLA arguments (PR ↵Martin Sebor1-35/+80
middle-end/97188). Resolves: PR middle-end/97188 - ICE passing a null VLA to a function expecting at least one element gcc/ChangeLog: PR middle-end/97188 * calls.c (maybe_warn_rdwr_sizes): Simplify warning messages. Correct handling of VLA argumments. gcc/testsuite/ChangeLog: PR middle-end/97188 * gcc.dg/Wstringop-overflow-23.c: Adjust text of expected warnings. * gcc.dg/Wnonnull-4.c: New test.
2020-09-19Extend -Wstringop-overflow to detect out-of-bounds accesses to array parameters.Martin Sebor1-93/+121
gcc/ChangeLog: PR c/50584 * builtins.c (warn_for_access): Add argument. Distinguish between reads and writes. (check_access): Add argument. Distinguish between reads and writes. (gimple_call_alloc_size): Set range even on failure. (gimple_parm_array_size): New function. (compute_objsize): Call it. (check_memop_access): Pass check_access an additional argument. (expand_builtin_memchr, expand_builtin_strcat): Same. (expand_builtin_strcpy, expand_builtin_stpcpy_1): Same. (expand_builtin_stpncpy, check_strncat_sizes): Same. (expand_builtin_strncat, expand_builtin_strncpy): Same. (expand_builtin_memcmp): Same. * builtins.h (compute_objsize): Declare a new overload. (gimple_parm_array_size): Declare. (check_access): Add argument. * calls.c (append_attrname): Simplify. (maybe_warn_rdwr_sizes): Handle internal attribute access. * tree-ssa-uninit.c (maybe_warn_pass_by_reference): Avoid adding quotes. gcc/testsuite/ChangeLog: PR c/50584 * c-c++-common/Wsizeof-pointer-memaccess1.c: Disable new expected warnings. * g++.dg/ext/attr-access.C: Update text of expected warnings. * gcc.dg/Wstringop-overflow-23.c: Same. * gcc.dg/Wstringop-overflow-24.c: Same. * gcc.dg/attr-access-none.c: Same. * gcc.dg/dfp/composite-type.c: Prune expected warnings. * gcc.dg/torture/pr57147-1.c: Add a member to an otherwise empty struct to avoid a warning. * gcc.dg/torture/pr57147-3.c: Same. * gcc.dg/Warray-bounds-30.c: Adjust. * gcc.dg/attr-access-none.c: Same. * gcc.dg/Wstringop-overflow-40.c: New test. * gcc.dg/attr-access-2.c: New test.
2020-09-19Infrastructure & C front end changes for array parameter checking (PR c/50584).Martin Sebor1-4/+4
gcc/ChangeLog: PR c/50584 * attribs.c (decl_attributes): Also pass decl along with type attributes to handlers. (init_attr_rdwr_indices): Change second argument to attribute chain. Handle internal attribute representation in addition to external. (get_parm_access): New function. (attr_access::to_internal_string): Define new member function. (attr_access::to_external_string): Define new member function. (attr_access::vla_bounds): Define new member function. * attribs.h (struct attr_access): Declare new members. (attr_access::from_mode_char): Define new member function. (get_parm_access): Declare new function. * calls.c (initialize_argument_information): Pass function type attributes to init_attr_rdwr_indices. * doc/invoke.texi (-Warray-parameter, -Wvla-parameter): Document. * tree-pretty-print.c (dump_generic_node): Correct handling of qualifiers. * tree-ssa-uninit.c (maybe_warn_pass_by_reference): Same. * tree.h (access_mode): Add new enumerator. gcc/c-family/ChangeLog: PR c/50584 * c-attribs.c (c_common_attribute_table): Add "arg spec" attribute. (handle_argspec_attribute): New function. (get_argument, get_argument_type): New functions. (append_access_attrs): Add overload. Handle internal attribute representation in addition to external. (handle_access_attribute): Handle internal attribute representation in addition to external. (build_attr_access_from_parms): New function. gcc/c-family/ChangeLog: PR c/50584 * c-common.h (warn_parm_array_mismatch): Declare new function. (has_attribute): Move declaration of an existing function. (build_attr_access_from_parms): Declare new function. * c-warn.c (parm_array_as_string): Define new function. (plus_one): Define new function. (warn_parm_ptrarray_mismatch): Define new function. (warn_parm_array_mismatch): Define new function. (vla_bound_parm_decl): New function. * c.opt (-Warray-parameter, -Wvla-parameter): New options. * c-pretty-print.c (pp_c_type_qualifier_list): Don't print array type qualifiers here... (c_pretty_printer::direct_abstract_declarator): ...but instead print them in brackets here. Also print [static]. Strip extraneous expressions from VLA bounds. gcc/c/ChangeLog: PR c/50584 * c-decl.c (lookup_last_decl): Define new function. (c_decl_attributes): Call it. (start_decl): Add argument and use it. (finish_decl): Call build_attr_access_from_parms and decl_attributes. (get_parm_array_spec): Define new function. (push_parm_decl): Call get_parm_array_spec. (start_function): Call warn_parm_array_mismatch. Build attribute access and add it to current function. * c-parser.c (c_parser_declaration_or_fndef): Diagnose mismatches in forms of array parameters. * c-tree.h (start_decl): Add argument. gcc/testsuite/ChangeLog: PR c/50584 * gcc.dg/attr-access-read-write-2.c: Adjust text of expected message. * c-c++-common/Warray-bounds-6.c: Correct C++ declaration, adjust text of expected diagnostics. * gcc.dg/Wbuiltin-declaration-mismatch-9.c: Prune expected warning. * gcc.dg/Warray-parameter-2.c: New test. * gcc.dg/Warray-parameter-3.c: New test. * gcc.dg/Warray-parameter-4.c: New test. * gcc.dg/Warray-parameter-5.c: New test. * gcc.dg/Warray-parameter.c: New test. * gcc.dg/Wvla-parameter-2.c: New test. * gcc.dg/Wvla-parameter-3.c: New test. * gcc.dg/Wvla-parameter.c: New test.
2020-08-28Add -Wstringop-overread for reading past the end by string functions.Martin Sebor1-32/+47
gcc/ChangeLog: * attribs.c (init_attr_rdwr_indices): Use global access_mode. * attribs.h (struct attr_access): Same. * builtins.c (fold_builtin_strlen): Add argument. (compute_objsize): Declare. (get_range): Declare. (check_read_access): New function. (access_ref::access_ref): Define ctor. (warn_string_no_nul): Add arguments. Handle -Wstrintop-overread. (check_nul_terminated_array): Handle source strings of different ranges of sizes. (expand_builtin_strlen): Remove warning code, call check_read_access instead. Declare locals closer to their initialization. (expand_builtin_strnlen): Same. (maybe_warn_for_bound): New function. (warn_for_access): Remove argument. Handle -Wstrintop-overread. (inform_access): Change argument type. (get_size_range): New function. (check_access): Remove unused arguments. Add new arguments. Handle -Wstrintop-overread. Move warning code to helpers and call them. Call check_nul_terminated_array. (check_memop_access): Remove unnecessary and provide additional arguments in calls. (expand_builtin_memchr): Call check_read_access. (expand_builtin_strcat): Remove unnecessary and provide additional arguments in calls. (expand_builtin_strcpy): Same. (expand_builtin_strcpy_args): Same. Avoid testing no-warning bit. (expand_builtin_stpcpy_1): Remove unnecessary and provide additional arguments in calls. (expand_builtin_stpncpy): Same. (check_strncat_sizes): Same. (expand_builtin_strncat): Remove unnecessary and provide additional arguments in calls. Adjust comments. (expand_builtin_strncpy): Remove unnecessary and provide additional arguments in calls. (expand_builtin_memcmp): Remove warning code. Call check_access. (expand_builtin_strcmp): Call check_access instead of check_nul_terminated_array. (expand_builtin_strncmp): Handle -Wstrintop-overread. (expand_builtin_fork_or_exec): Call check_access instead of check_nul_terminated_array. (expand_builtin): Same. (fold_builtin_1): Pass additional argument. (fold_builtin_n): Same. (fold_builtin_strpbrk): Remove calls to check_nul_terminated_array. (expand_builtin_memory_chk): Add comments. (maybe_emit_chk_warning): Remove unnecessary and provide additional arguments in calls. (maybe_emit_sprintf_chk_warning): Same. Adjust comments. * builtins.h (warn_string_no_nul): Add arguments. (struct access_ref): Add member and ctor argument. (struct access_data): Add members and ctor. (check_access): Adjust signature. * calls.c (maybe_warn_nonstring_arg): Return an indication of whether a warning was issued. Issue -Wstrintop-overread instead of -Wstringop-overflow. (append_attrname): Adjust to naming changes. (maybe_warn_rdwr_sizes): Same. Remove unnecessary and provide additional arguments in calls. * calls.h (maybe_warn_nonstring_arg): Return bool. * doc/invoke.texi (-Wstringop-overread): Document new option. * gimple-fold.c (gimple_fold_builtin_strcpy): Provide an additional argument in call. (gimple_fold_builtin_stpcpy): Same. * tree-ssa-uninit.c (maybe_warn_pass_by_reference): Adjust to naming changes. * tree.h (enum access_mode): New type. gcc/c-family/ChangeLog: * c.opt (Wstringop-overread): New option. gcc/testsuite/ChangeLog: * c-c++-common/Warray-bounds-7.c: Adjust expected warnings. * c-c++-common/Wrestrict.c: Remove xfail. * c-c++-common/attr-nonstring-3.c: Adjust text of expected warnings. * c-c++-common/attr-nonstring-6.c: Suppress -Wstringop-overread instead of -Wstringop-overflow. * c-c++-common/attr-nonstring-8.c: Adjust text of expected warnings. * g++.dg/torture/Wsizeof-pointer-memaccess1.C: Also suppress -Wstringop-overread. * g++.dg/torture/Wsizeof-pointer-memaccess2.C: Same. * gcc.dg/Warray-bounds-39.c: Adjust expected warnings. * gcc.dg/Warray-bounds-40.c: Also suppress -Wstringop-overread. * gcc.dg/Warray-bounds-58.c: Remove xfail. Also expect -Wstringop-overread. Adjust text of expected warnings. * gcc.dg/Wsizeof-pointer-memaccess1.c: Also suppress -Wstringop-overread. * gcc.dg/Wstringop-overflow-22.c: Adjust text of expected warnings. * gcc.dg/Wstringop-overflow-33.c: Expect -Wstringop-overread. * gcc.dg/Wstringop-overflow-9.c: Expect -Wstringop-overread. * gcc.dg/attr-nonstring-2.c: Adjust text of expected warnings. * gcc.dg/attr-nonstring-3.c: Same. * gcc.dg/attr-nonstring-4.c: Same. * gcc.dg/attr-nonstring.c: Expect -Wstringop-overread. * gcc.dg/builtin-stringop-chk-5.c: Adjust comment. * gcc.dg/builtin-stringop-chk-8.c: Enable -Wstringop-overread instead of -Wstringop-overflow. * gcc.dg/pr78902.c: Also expect -Wstringop-overread. * gcc.dg/pr79214.c: Adjust text of expected warnings. * gcc.dg/strcmpopt_10.c: Suppress valid -Wno-stringop-overread. * gcc.dg/strlenopt-57.c: Also expect -Wstringop-overread. * gcc.dg/torture/Wsizeof-pointer-memaccess1.c: Also suppress valid -Wno-stringop-overread. * gcc.dg/tree-ssa/builtins-folding-gimple-ub.c: Same. * gcc.dg/uninit-33.c: Same. * gcc.dg/warn-strnlen-no-nul-2.c: Adjust text of expected warning. * gcc.dg/warn-strnlen-no-nul.c: Same. * gcc.target/i386/strcmpopt_6.c: Suppress -Wstringop-overread. * gcc.dg/Wstringop-overread-2.c: New test. * gcc.dg/Wstringop-overread.c: New test.
2020-08-27vec: add exact argument for various grow functions.Martin Liska1-1/+1
gcc/ada/ChangeLog: * gcc-interface/trans.c (gigi): Set exact argument of a vector growth function to true. (Attribute_to_gnu): Likewise. gcc/ChangeLog: * alias.c (init_alias_analysis): Set exact argument of a vector growth function to true. * calls.c (internal_arg_pointer_based_exp_scan): Likewise. * cfgbuild.c (find_many_sub_basic_blocks): Likewise. * cfgexpand.c (expand_asm_stmt): Likewise. * cfgrtl.c (rtl_create_basic_block): Likewise. * combine.c (combine_split_insns): Likewise. (combine_instructions): Likewise. * config/aarch64/aarch64-sve-builtins.cc (function_expander::add_output_operand): Likewise. (function_expander::add_input_operand): Likewise. (function_expander::add_integer_operand): Likewise. (function_expander::add_address_operand): Likewise. (function_expander::add_fixed_operand): Likewise. * df-core.c (df_worklist_dataflow_doublequeue): Likewise. * dwarf2cfi.c (update_row_reg_save): Likewise. * early-remat.c (early_remat::init_block_info): Likewise. (early_remat::finalize_candidate_indices): Likewise. * except.c (sjlj_build_landing_pads): Likewise. * final.c (compute_alignments): Likewise. (grow_label_align): Likewise. * function.c (temp_slots_at_level): Likewise. * fwprop.c (build_single_def_use_links): Likewise. (update_uses): Likewise. * gcc.c (insert_wrapper): Likewise. * genautomata.c (create_state_ainsn_table): Likewise. (add_vect): Likewise. (output_dead_lock_vect): Likewise. * genmatch.c (capture_info::capture_info): Likewise. (parser::finish_match_operand): Likewise. * genrecog.c (optimize_subroutine_group): Likewise. (merge_pattern_info::merge_pattern_info): Likewise. (merge_into_decision): Likewise. (print_subroutine_start): Likewise. (main): Likewise. * gimple-loop-versioning.cc (loop_versioning::loop_versioning): Likewise. * gimple.c (gimple_set_bb): Likewise. * graphite-isl-ast-to-gimple.c (translate_isl_ast_node_user): Likewise. * haifa-sched.c (sched_extend_luids): Likewise. (extend_h_i_d): Likewise. * insn-addr.h (insn_addresses_new): Likewise. * ipa-cp.c (gather_context_independent_values): Likewise. (find_more_contexts_for_caller_subset): Likewise. * ipa-devirt.c (final_warning_record::grow_type_warnings): Likewise. (ipa_odr_read_section): Likewise. * ipa-fnsummary.c (evaluate_properties_for_edge): Likewise. (ipa_fn_summary_t::duplicate): Likewise. (analyze_function_body): Likewise. (ipa_merge_fn_summary_after_inlining): Likewise. (read_ipa_call_summary): Likewise. * ipa-icf.c (sem_function::bb_dict_test): Likewise. * ipa-prop.c (ipa_alloc_node_params): Likewise. (parm_bb_aa_status_for_bb): Likewise. (ipa_compute_jump_functions_for_edge): Likewise. (ipa_analyze_node): Likewise. (update_jump_functions_after_inlining): Likewise. (ipa_read_edge_info): Likewise. (read_ipcp_transformation_info): Likewise. (ipcp_transform_function): Likewise. * ipa-reference.c (ipa_reference_write_optimization_summary): Likewise. * ipa-split.c (execute_split_functions): Likewise. * ira.c (find_moveable_pseudos): Likewise. * lower-subreg.c (decompose_multiword_subregs): Likewise. * lto-streamer-in.c (input_eh_regions): Likewise. (input_cfg): Likewise. (input_struct_function_base): Likewise. (input_function): Likewise. * modulo-sched.c (set_node_sched_params): Likewise. (extend_node_sched_params): Likewise. (schedule_reg_moves): Likewise. * omp-general.c (omp_construct_simd_compare): Likewise. * passes.c (pass_manager::create_pass_tab): Likewise. (enable_disable_pass): Likewise. * predict.c (determine_unlikely_bbs): Likewise. * profile.c (compute_branch_probabilities): Likewise. * read-rtl-function.c (function_reader::parse_block): Likewise. * read-rtl.c (rtx_reader::read_rtx_code): Likewise. * reg-stack.c (stack_regs_mentioned): Likewise. * regrename.c (regrename_init): Likewise. * rtlanal.c (T>::add_single_to_queue): Likewise. * sched-deps.c (init_deps_data_vector): Likewise. * sel-sched-ir.c (sel_extend_global_bb_info): Likewise. (extend_region_bb_info): Likewise. (extend_insn_data): Likewise. * symtab.c (symtab_node::create_reference): Likewise. * tracer.c (tail_duplicate): Likewise. * trans-mem.c (tm_region_init): Likewise. (get_bb_regions_instrumented): Likewise. * tree-cfg.c (init_empty_tree_cfg_for_function): Likewise. (build_gimple_cfg): Likewise. (create_bb): Likewise. (move_block_to_fn): Likewise. * tree-complex.c (tree_lower_complex): Likewise. * tree-if-conv.c (predicate_rhs_code): Likewise. * tree-inline.c (copy_bb): Likewise. * tree-into-ssa.c (get_ssa_name_ann): Likewise. (mark_phi_for_rewrite): Likewise. * tree-object-size.c (compute_builtin_object_size): Likewise. (init_object_sizes): Likewise. * tree-predcom.c (initialize_root_vars_store_elim_1): Likewise. (initialize_root_vars_store_elim_2): Likewise. (prepare_initializers_chain_store_elim): Likewise. * tree-ssa-address.c (addr_for_mem_ref): Likewise. (multiplier_allowed_in_address_p): Likewise. * tree-ssa-coalesce.c (ssa_conflicts_new): Likewise. * tree-ssa-forwprop.c (simplify_vector_constructor): Likewise. * tree-ssa-loop-ivopts.c (addr_offset_valid_p): Likewise. (get_address_cost_ainc): Likewise. * tree-ssa-loop-niter.c (discover_iteration_bound_by_body_walk): Likewise. * tree-ssa-pre.c (add_to_value): Likewise. (phi_translate_1): Likewise. (do_pre_regular_insertion): Likewise. (do_pre_partial_partial_insertion): Likewise. (init_pre): Likewise. * tree-ssa-propagate.c (ssa_prop_init): Likewise. (update_call_from_tree): Likewise. * tree-ssa-reassoc.c (optimize_range_tests_cmp_bitwise): Likewise. * tree-ssa-sccvn.c (vn_reference_lookup_3): Likewise. (vn_reference_lookup_pieces): Likewise. (eliminate_dom_walker::eliminate_push_avail): Likewise. * tree-ssa-strlen.c (set_strinfo): Likewise. (get_stridx_plus_constant): Likewise. (zero_length_string): Likewise. (find_equal_ptrs): Likewise. (printf_strlen_execute): Likewise. * tree-ssa-threadedge.c (set_ssa_name_value): Likewise. * tree-ssanames.c (make_ssa_name_fn): Likewise. * tree-streamer-in.c (streamer_read_tree_bitfields): Likewise. * tree-vect-loop.c (vect_record_loop_mask): Likewise. (vect_get_loop_mask): Likewise. (vect_record_loop_len): Likewise. (vect_get_loop_len): Likewise. * tree-vect-patterns.c (vect_recog_mask_conversion_pattern): Likewise. * tree-vect-slp.c (vect_slp_convert_to_external): Likewise. (vect_bb_slp_scalar_cost): Likewise. (vect_bb_vectorization_profitable_p): Likewise. (vectorizable_slp_permutation): Likewise. * tree-vect-stmts.c (vectorizable_call): Likewise. (vectorizable_simd_clone_call): Likewise. (scan_store_can_perm_p): Likewise. (vectorizable_store): Likewise. * expr.c: Likewise. * vec.c (test_safe_grow_cleared): Likewise. * vec.h (vec_safe_grow): Likewise. (vec_safe_grow_cleared): Likewise. (vl_ptr>::safe_grow): Likewise. (vl_ptr>::safe_grow_cleared): Likewise. * config/c6x/c6x.c (insn_set_clock): Likewise. gcc/c/ChangeLog: * gimple-parser.c (c_parser_gimple_compound_statement): Set exact argument of a vector growth function to true. gcc/cp/ChangeLog: * class.c (build_vtbl_initializer): Set exact argument of a vector growth function to true. * constraint.cc (get_mapped_args): Likewise. * decl.c (cp_maybe_mangle_decomp): Likewise. (cp_finish_decomp): Likewise. * parser.c (cp_parser_omp_for_loop): Likewise. * pt.c (canonical_type_parameter): Likewise. * rtti.c (get_pseudo_ti_init): Likewise. gcc/fortran/ChangeLog: * trans-openmp.c (gfc_trans_omp_do): Set exact argument of a vector growth function to true. gcc/lto/ChangeLog: * lto-common.c (lto_file_finalize): Set exact argument of a vector growth function to true.
2020-07-28expander: Fix ICE in maybe_warn_rdwr_sizes [PR96335]Jakub Jelinek1-18/+2
The following testcase ICEs in maybe_warn_rdwr_sizes. The problem is that the caller uses its fndecl and fntype variables to fill up rdwr_map, and the fntype in that case is a prototype with the access attribute and all the checks needed for that performed. But the maybe_warn_rdwr_sizes function tries to rediscover fndecl/fntype itself and does it differently from how the caller did (for fndecl get_callee_fndecl and fntype from that FUNCTION_DECL, otherwise sets fntype to CALL_EXPR_FN's type). On the testcase, get_callee_fndecl does find a FUNCTION_DECL because it does STRIP_NOPS in between. Instead of trying to rediscover those, this patch just passes them down, like is done in several other functions. 2020-07-28 Jakub Jelinek <jakub@redhat.com> PR middle-end/96335 * calls.c (maybe_warn_rdwr_sizes): Add FNDECL and FNTYPE arguments, instead of trying to rediscover them in the body. (initialize_argument_information): Adjust caller. * gcc.dg/pr96335.c: New test.
2020-06-28Underline argument in -Wnonnull and in C++ extend warning to the this ↵Martin Sebor1-1/+3
pointer [PR c++/86568]. Resolves: PR c++/86568 - -Wnonnull warnings should highlight the relevant argument not the closing parenthesis gcc/c-family/ChangeLog: PR c++/86568 * c-common.c (struct nonnull_arg_ctx): Add members. (check_function_nonnull): Use nonnull_arg_ctx as argument. Handle C++ member functions specially. Consider the this pointer implicitly nonnull. (check_nonnull_arg): Use location of argument when available. (check_function_arguments): Use nonnull_arg_ctx as argument. gcc/ChangeLog: PR c++/86568 * calls.c (maybe_warn_rdwr_sizes): Use location of argument if available. * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Same. Adjust indentation. * tree.c (get_nonnull_args): Consider the this pointer implicitly nonnull. * var-tracking.c (deps_vec): New type. (var_loc_dep_vec): New function. (VAR_LOC_DEP_VEC): Use it. gcc/testsuite/ChangeLog: PR c++/86568 * g++.dg/warn/Wnonnull5.C: New test. * c-c++-common/pr28656.c: Adjust text of expected warning. * c-c++-common/pr66208.c: Same. * g++.dg/cpp0x/nullptr22.C: Same. * g++.dg/ext/attr-nonnull.C: Same. * g++.dg/ext/attrib49.C: Same. * g++.dg/pr71973-2.C: Same. * g++.dg/warn/Wnonnull3.C: Same. * g++.dg/warn/Wnonnull4.C: Same. * obj-c++.dg/attributes/method-nonnull-1.mm: Same. * objc.dg/attributes/method-nonnull-1.m: Same.
2020-06-04Implement a solution for PR middle-end/10138 and PR middle-end/95136.Martin Sebor1-72/+11
PR middle-end/10138 - warn for uninitialized arrays passed as const arguments PR middle-end/95136 - missing -Wuninitialized on an array access with a variable offset gcc/c-family/ChangeLog: PR middle-end/10138 PR middle-end/95136 * c-attribs.c (append_access_attrs): Handle attr_access::none. (handle_access_attribute): Same. gcc/ChangeLog: PR middle-end/10138 PR middle-end/95136 * attribs.c (init_attr_rdwr_indices): Move function here. * attribs.h (rdwr_access_hash, rdwr_map): Define. (attr_access): Add 'none'. (init_attr_rdwr_indices): Declared function. * builtins.c (warn_for_access)): New function. (check_access): Call it. * builtins.h (checK-access): Add an optional argument. * calls.c (rdwr_access_hash, rdwr_map): Move to attribs.h. (init_attr_rdwr_indices): Declare extern. (append_attrname): Handle attr_access::none. (maybe_warn_rdwr_sizes): Same. (initialize_argument_information): Update comments. * doc/extend.texi (attribute access): Document 'none'. * tree-ssa-uninit.c (struct wlimits): New. (maybe_warn_operand): New function. (maybe_warn_pass_by_reference): Same. (warn_uninitialized_vars): Refactor code into maybe_warn_operand. Also call for function calls. (pass_late_warn_uninitialized::execute): Adjust comments. (execute_early_warn_uninitialized): Same. gcc/testsuite/ChangeLog: PR middle-end/10138 PR middle-end/95136 * c-c++-common/Wsizeof-pointer-memaccess1.c: Prune out valid Wuninitialized. * c-c++-common/uninit-pr51010.c: Adjust expected warning format. * c-c++-common/goacc/uninit-dim-clause.c: Same. * c-c++-common/goacc/uninit-firstprivate-clause.c: Same. * c-c++-common/goacc/uninit-if-clause.c: Same. * c-c++-common/gomp/pr70550-1.c: Same. * c-c++-common/gomp/pr70550-2.c: Adjust. * g++.dg/20090107-1.C: Same. * g++.dg/20090121-1.C: Same. * g++.dg/ext/attr-access.C: Avoid -Wuninitialized. * gcc.dg/tree-ssa/forwprop-6.c: Prune out -Wuninitialized. * gcc.dg/Warray-bounds-52.c: Prune out valid -Wuninitialized. * gcc.dg/Warray-bounds-53.c: Same. * gcc.dg/Warray-bounds-54.c: Same. * gcc.dg/Wstringop-overflow-33.c: New test. * gcc.dg/attr-access-none.c: New test. * gcc.dg/attr-access-read-only.c: Adjust. * gcc.dg/attr-access-read-write.c: Same. * gcc.dg/attr-access-write-only.c: Same. * gcc.dg/pr71581.c: Adjust text of expected warning. * gcc.dg/uninit-15.c: Same. * gcc.dg/uninit-32.c: New test. * gcc.dg/uninit-33.c: New test. * gcc.dg/uninit-34.c: New test. * gcc.dg/uninit-36.c: New test. * gcc.dg/uninit-B-O0.c: Adjust text of expected warning. * gcc.dg/uninit-I-O0.c: Same. * gcc.dg/uninit-pr19430-O0.c: Same. * gcc.dg/uninit-pr19430.c: Same. * gcc.dg/uninit-pr95136.c: New test. * gfortran.dg/assignment_4.f90: Expect -Wuninitialized. * gfortran.dg/goacc/uninit-dim-clause.f95: Adjust text of expected warning. * gfortran.dg/goacc/uninit-firstprivate-clause.f95 * gfortran.dg/goacc/uninit-if-clause.f95 * gfortran.dg/pr66545_2.f90
2020-04-29calls: Remove FIXME for cxx17_empty_base_field_pRichard Sandiford1-0/+15
This predicate is now used by aarch64 targets. 2020-04-29 Richard Sandiford <richard.sandiford@arm.com> gcc/ * calls.h (cxx17_empty_base_field_p): Turn into a function declaration. * calls.c (cxx17_empty_base_field_p): New function. Check DECL_ARTIFICIAL and RECORD_OR_UNION_TYPE_P in addition to the previous checks.
2020-04-29c++, middle-end, rs6000: Fix C++17 ABI incompatibilities during class layout ↵Jakub Jelinek1-18/+0
and [[no_unique_address]] handling [PR94707] As reported by Iain and David, powerpc-darwin and powerpc-aix* have C++14 vs. C++17 ABI incompatibilities which are not fixed by mere adding of cxx17_empty_base_field_p calls. Unlike the issues that were seen on other targets where the artificial empty base field affected function argument passing or returning of values, on these two targets the difference is during class layout, not afterwards (e.g. struct empty_base {}; struct S : public empty_base { unsigned long long l[2]; }; will have different __alignof__ (S) between C++14 and C++17 (or possibly with double instead of unsigned long long too)). I've tried: struct X { }; struct Y { int : 0; }; struct Z { int : 0; Y y; }; struct U : public X { X q; }; struct A { float a, b, c, d; }; struct B : public X { float a, b, c, d; }; struct C : public Y { float a, b, c, d; }; struct D : public Z { float a, b, c, d; }; struct E : public U { float a, b, c, d; }; struct F { [[no_unique_address]] X x; float a, b, c, d; }; struct G { [[no_unique_address]] Y y; float a, b, c, d; }; struct H { [[no_unique_address]] Z z; float a, b, c, d; }; struct I { [[no_unique_address]] U u; float a, b, c, d; }; struct J { float a, b; [[no_unique_address]] X x; float c, d; }; struct K { float a, b; [[no_unique_address]] Y y; float c, d; }; struct L { float a, b; [[no_unique_address]] Z z; float c, d; }; struct M { float a, b; [[no_unique_address]] U u; float c, d; }; #define T(S, s) extern S s; extern void foo##s (S); int bar##s () { foo##s (s); return 0; } T (A, a) T (B, b) T (C, c) T (D, d) T (E, e) T (F, f) T (G, g) T (H, h) T (I, i) T (J, j) T (K, k) T (L, l) T (M, m) testcase on powerpc64-linux. Results: G++ 9 -std=c++14 A, B, C passed in fprs, the rest in gprs G++ 9 -std=c++17 A passed in fprs, the rest in gprs current trunk -std=c++14 & 17 A, B, C passed in fprs, the rest in gprs patched trunk -std=c++14 & 17 A, B, C, F, G, J, K passed in fprs, the rest in gprs clang++ [*] -std=c++14 & 17 A, B, C, F, G, J, K passed in fprs, the rest in gprs [*] clang version 11.0.0 (git@github.com:llvm/llvm-project.git 5c352e69e76a26e4eda075e20aa6a9bb7686042c) Is that what we want? I think it matches the stated intent of P0840R2 or what Jason/Jonathan said, and doing something different like e.g. not treating C, G and K as homogenous because of the int : 0 in empty bases or in zero sized [[no_unique_address] fields would be quite hard to implement (because for C++14 the FIELD_DECL just isn't there). 2020-04-29 Jakub Jelinek <jakub@redhat.com> PR target/94707 * tree-core.h (tree_decl_common): Note decl_flag_0 used for DECL_FIELD_ABI_IGNORED. * tree.h (DECL_FIELD_ABI_IGNORED): Define. * calls.h (cxx17_empty_base_field_p): Change into a temporary macro, check DECL_FIELD_ABI_IGNORED flag with no "no_unique_address" attribute. * calls.c (cxx17_empty_base_field_p): Remove. * tree-streamer-out.c (pack_ts_decl_common_value_fields): Handle DECL_FIELD_ABI_IGNORED. * tree-streamer-in.c (unpack_ts_decl_common_value_fields): Likewise. * lto-streamer-out.c (hash_tree): Likewise. * config/rs6000/rs6000-call.c (rs6000_aggregate_candidate): Rename cxx17_empty_base_seen to empty_base_seen, change type to int *, adjust recursive calls, use DECL_FIELD_ABI_IGNORED instead of cxx17_empty_base_field_p, if "no_unique_address" attribute is present, propagate that to the caller too. (rs6000_discover_homogeneous_aggregate): Adjust rs6000_aggregate_candidate caller, emit different diagnostics when c++17 empty base fields are present and when empty [[no_unique_address]] fields are present. * config/rs6000/rs6000.c (rs6000_special_round_type_align, darwin_rs6000_special_round_type_align): Skip DECL_FIELD_ABI_IGNORED fields. * class.c (build_base_field): Set DECL_FIELD_ABI_IGNORED on C++17 empty base artificial FIELD_DECLs. (layout_class_type): Set DECL_FIELD_ABI_IGNORED on empty class field_poverlapping_p FIELD_DECLs. * lto-common.c (compare_tree_sccs_1): Handle DECL_FIELD_ABI_IGNORED. * g++.target/powerpc/pr94707-1.C: New test. * g++.target/powerpc/pr94707-2.C: New test. * g++.target/powerpc/pr94707-3.C: New test. * g++.target/powerpc/pr94707-4.C: New test. * g++.target/powerpc/pr94707-5.C: New test. * g++.target/powerpc/pr94707-4.C: New test.
2020-04-22calls: Introduce cxx17_empty_base_field_p [PR94383]Jakub Jelinek1-0/+18
As multiple targets are affected apparently, I believe at least aarch64, arm, powerpc64le, s390{,x} and ia64, I think we should have a middle-end predicate for this, so that if we need to tweak it, we can do it in one spot. 2020-04-22 Jakub Jelinek <jakub@redhat.com> PR target/94383 * calls.h (cxx17_empty_base_field_p): Declare. * calls.c (cxx17_empty_base_field_p): Define.
2020-03-27PR c++/94098 - ICE on attribute access redeclarationMartin Sebor1-43/+39
gcc/c-family/ChangeLog: PR c++/94098 * c-attribs.c (handle_access_attribute): Avoid setting TYPE_ATTRIBUTES here. gcc/ChangeLog: PR c++/94098 * calls.c (init_attr_rdwr_indices): Iterate over all access attributes. gcc/testsuite/ChangeLog: PR c++/94098 * g++.dg/ext/attr-access-2.C: New test.
2020-03-01PR middle-end/92721 - checking ICE on attribute access redeclarationMartin Sebor1-0/+5
gcc/c-family/ChangeLog: PR c++/92721 * c-attribs.c (append_access_attrs): Correctly handle attribute. (handle_access_attribute): Same. gcc/ChangeLog: PR c++/92721 * calls.c (init_attr_rdwr_indices): Correctly handle attribute. gcc/testsuite/ChangeLog: PR c++/92721 g++.dg/ext/attr-access.C: New test.
2020-01-31calls.c: refactor special_function_p for use by analyzer (v2)David Malcolm1-12/+2
This patch refactors some code in special_function_p that checks for the function being sane to match by name, splitting it out into a new maybe_special_function_p, and using it it two places in the analyzer. gcc/analyzer/ChangeLog: * analyzer.cc (is_named_call_p): Replace tests for fndecl being extern at file scope and having a non-NULL DECL_NAME with a call to maybe_special_function_p. * function-set.cc (function_set::contains_decl_p): Add call to maybe_special_function_p. gcc/ChangeLog: * calls.c (special_function_p): Split out the check for DECL_NAME being non-NULL and fndecl being extern at file scope into a new maybe_special_function_p and call it. Drop check for fndecl being non-NULL that was after a usage of DECL_NAME (fndecl). * tree.h (maybe_special_function_p): New inline function.
2020-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r279813
2019-11-22PR middle-end/83859 - attributes to associate pointer arguments and sizesMartin Sebor1-0/+332
gcc/ChangeLog: PR middle-end/83859 * attribs.h (struct attr_access): New. * attribs.c (decl_attributes): Add an informational note. * builtins.c (check_access): Make extern. Consistently set no-warning after issuing a warning. Handle calls through function pointers. Set no-warning. * builtins.h (check_access): Declare. * calls.c (rdwr_access_hash): New type. (rdwr_map): Same. (init_attr_rdwr_indices): New function. (maybe_warn_rdwr_sizes): Same. (initialize_argument_information): Call init_attr_rdwr_indices. Call maybe_warn_rdwr_sizes. (get_size_range): Avoid null argument. * doc/extend.texi (attribute access): Document new attribute. gcc/c-family/ChangeLog: PR middle-end/83859 * c-attribs.c (handle_access_attribute): New function. (c_common_attribute_table): Add new attribute. (get_argument_type): New function. (append_access_attrs): New function. (get_nonnull_operand): Rename... (get_attribute_operand): ...to this. * c-common.c (get_nonnull_operand): Rename... (get_attribute_operand): ...to this. gcc/testsuite/ChangeLog: PR middle-end/83859 * c-c++-common/attr-nonstring-8.c: Adjust text of expected warning. * gcc.dg/Wstringop-overflow-23.c: New test. * gcc.dg/Wstringop-overflow-24.c: New test. * gcc.dg/attr-access-read-only.c: New test. * gcc.dg/attr-access-read-write.c: New test. * gcc.dg/attr-access-read-write-2.c: New test. * gcc.dg/attr-access-write-only.c: New test. From-SVN: r278624
2019-11-06introduce -fcallgraph-info optionEric Botcazou1-0/+6
This was first submitted many years ago https://gcc.gnu.org/ml/gcc-patches/2010-10/msg02468.html The command line option -fcallgraph-info is added and makes the compiler generate another output file (xxx.ci) for each compilation unit (or LTO partitoin), which is a valid VCG file (you can launch your favorite VCG viewer on it unmodified) and contains the "final" callgraph of the unit. "final" is a bit of a misnomer as this is actually the callgraph at RTL expansion time, but since most high-level optimizations are done at the Tree level and RTL doesn't usually fiddle with calls, it's final in almost all cases. Moreover, the nodes can be decorated with additional info: -fcallgraph-info=su adds stack usage info and -fcallgraph-info=da dynamic allocation info. for gcc/ChangeLog From Eric Botcazou <ebotcazou@adacore.com>, Alexandre Oliva <oliva@adacore.com> * common.opt (-fcallgraph-info[=]): New option. * doc/invoke.texi (Developer options): Document it. * opts.c (common_handle_option): Handle it. * builtins.c (expand_builtin_alloca): Record allocation if -fcallgraph-info=da. * calls.c (expand_call): If -fcallgraph-info, record the call. (emit_library_call_value_1): Likewise. * flag-types.h (enum callgraph_info_type): New type. * explow.c: Include stringpool.h. (set_stack_check_libfunc): Set SET_SYMBOL_REF_DECL on the symbol. * function.c (allocate_stack_usage_info): New. (allocate_struct_function): Call it for -fcallgraph-info. (prepare_function_start): Call it otherwise. (record_final_call, record_dynamic_alloc): New. * function.h (struct callinfo_callee): New. (CALLEE_FROM_CGRAPH_P): New. (struct callinfo_dalloc): New. (struct stack_usage): Add callees and dallocs. (record_final_call, record_dynamic_alloc): Declare. * gimplify.c (gimplify_decl_expr): Record dynamically-allocated object if -fcallgraph-info=da. * optabs-libfuncs.c (build_libfunc_function): Keep SYMBOL_REF_DECL. * print-tree.h (print_decl_identifier): Declare. (PRINT_DECL_ORIGIN, PRINT_DECL_NAME, PRINT_DECL_UNIQUE_NAME): New. * print-tree.c: Include print-tree.h. (print_decl_identifier): New function. * toplev.c: Include print-tree.h. (callgraph_info_file): New global variable. (callgraph_info_external_printed): Likewise. (output_stack_usage): Rename to... (output_stack_usage_1): ... this. Make it static, add cf parameter. If -fcallgraph-info=su, print stack usage to cf. If -fstack-usage, use print_decl_identifier for pretty-printing. (INDIRECT_CALL_NAME): New. (dump_final_node_vcg_start): New. (dump_final_callee_vcg, dump_final_node_vcg): New. (output_stack_usage): New. (lang_dependent_init): Open and start file if -fcallgraph-info. Allocated callgraph_info_external_printed. (finalize): If callgraph_info_file is not null, finish it, close it, and release callgraph_info_external_printed. for gcc/ada/ChangeLog * gcc-interface/misc.c (callgraph_info_file): Delete. Co-Authored-By: Alexandre Oliva <oliva@adacore.com> From-SVN: r277876
2019-10-29[AArch64] Add support for the SVE PCSRichard Sandiford1-2/+2
The AAPCS64 specifies that if a function takes arguments in SVE registers or returns them in SVE registers, it must preserve all of Z8-Z23 and all of P4-P11. (Normal functions only preserve the low 64 bits of Z8-Z15 and clobber all of the predicate registers.) This variation is known informally as the "SVE PCS" and functions that use it are known informally as "SVE functions". The SVE PCS is mutually interoperable with functions that follow the standard AAPCS64 rules and those that use the aarch64_vector_pcs attribute. (Note that it's an error to use the attribute for SVE functions.) One complication -- although it's not really that complicated -- is that SVE registers need to be saved at a VL-dependent offset while other registers need to be saved at a constant offset. The easiest way of handling this seemed to be to group the SVE registers together below the hard frame pointer. In common cases, the frame pointer is then usually an easy-to-compute VL multiple above the stack pointer and a constant amount below the incoming stack pointer. A bigger complication is that, because the base AAPCS64 specifies that only the low 64 bits of V8-V15 are preserved by calls, the associated DWARF frame registers are also treated as 64 bits by the unwinder. The 64 bits must also have the same layout as they would for a base AAPCS64 function, otherwise unwinding won't work correctly. (This is actually a problem for the existing aarch64_vector_pcs support too, but I'll fix that separately.) This falls out naturally for little-endian targets but not for big-endian targets. The easiest way of meeting the requirement for them was to use ST1D and LD1D to save and restore Z8-Z15, which also has the nice property of storing the 64 bits at the start of the slot. However, using ST1D and LD1D requires a spare predicate register, and since all of P0-P7 are either argument registers or call-preserved, we may need to spill P4 in order to save the vector registers, even if P4 wouldn't need to be saved otherwise. Since Z16-Z23 are fully clobbered by base AAPCS64 functions, we don't need to emit frame information for them at all. This avoids having to decide whether the registers should be treated as having 64 bits (as for Z8-Z15), 128 bits (for Advanced SIMD) or the full SVE width. There are two ways of dealing with stack-clash protection when saving SVE registers: (1) If the area between the hard frame pointer and the incoming stack pointer is allocated via a store with writeback (callee_adjust != 0), the SVE save area is allocated separately and becomes the "initial" allocation as far as stack-clash protection goes. In this case the store with writeback acts as a probe at the hard frame pointer position. (2) If the area between the hard frame pointer and the incoming stack pointer is allocated via aarch64_allocate_and_probe_stack_space, the SVE save area is added to this initial allocation, so that the SP ends up pointing at the SVE register saves. It's then necessary to use a temporary base register to save the non-SVE registers. Setting up this temporary register requires a single instruction only and so should be more efficient than doing two allocations and probes. When SVE registers need to be saved, saving them below the frame pointer makes it harder to rely on the LR save as a stack probe, since the LR register's offset won't usually be a compile-time constant. The patch copes with that by using the lowest SVE register save as a stack probe too, and thus prevents the save from being shrink-wrapped if stack clash protection is enabled. The changelog describes the low-level details. 2019-10-29 Richard Sandiford <richard.sandiford@arm.com> gcc/ * calls.c (pass_by_reference): Leave the target to decide whether POLY_INT_CST-sized arguments should be passed by value or reference, rather than forcing them to be passed by reference. (must_pass_in_stack_var_size): Likewise. * config/aarch64/aarch64.md (LAST_SAVED_REGNUM): Redefine from V31_REGNUM to P15_REGNUM. * config/aarch64/aarch64-protos.h (aarch64_init_cumulative_args): Take an extra "silent_p" parameter, defaulting to false. (aarch64_sve::svbool_type_p): Declare. (aarch64_sve::nvectors_if_data_type): Likewise. * config/aarch64/aarch64.h (NUM_PR_ARG_REGS): New macro. (aarch64_frame::reg_offset): Turn into poly_int64s. (aarch64_frame::save_regs_size): Likewise. (aarch64_frame::below_hard_fp_saved_regs_size): New field. (aarch64_frame::sve_callee_adjust): Likewise. (aarch64_frame::spare_reg_reg): Likewise. (ARM_PCS_SVE): New arm_pcs value. (CUMULATIVE_ARGS::aapcs_nprn): New field. (CUMULATIVE_ARGS::aapcs_nextnprn): Likewise. (CUMULATIVE_ARGS::silent_p): Likewise. (BITS_PER_SVE_PRED): New macro. * config/aarch64/aarch64.c (handle_aarch64_vector_pcs_attribute): New function. Reject aarch64_vector_pcs attributes on SVE functions. (aarch64_attribute_table): Use the above handler. (aarch64_sve_abi): New function. (aarch64_sve_argument_p): Likewise. (aarch64_returns_value_in_sve_regs_p): Likewise. (aarch64_takes_arguments_in_sve_regs_p): Likewise. (aarch64_fntype_abi): Check for SVE functions and return the SVE PCS descriptor for them. (aarch64_simd_decl_p): Delete. (aarch64_emit_cfi_for_reg_p): New function. (aarch64_reg_save_mode): Remove the fndecl argument and instead use crtl->abi to choose the mode for FP registers. Handle the SVE PCS. (aarch64_hard_regno_call_part_clobbered): Do not treat FP registers as partly clobbered for the SVE PCS. (aarch64_function_ok_for_sibcall): Check whether the two functions use the same ABI, rather than checking specifically for whether they're aarch64_vector_pcs functions. (aarch64_pass_by_reference): Raise an error for attempts to pass SVE arguments when SVE is disabled. Pass SVE arguments by reference if there are not enough free registers left, or if the argument is variadic. (aarch64_function_value): Handle SVE predicates, vectors and tuples. (aarch64_return_in_memory): Do not return SVE predicates, vectors and tuples in memory. (aarch64_layout_arg): Take a function_arg_info rather than individual properties. Handle SVE predicates, vectors and tuples. Raise an error if they are passed to unprototyped functions. (aarch64_function_arg): If the silent_p flag is set, suppress the usual error about using float registers without TARGET_FLOAT. (aarch64_init_cumulative_args): Take a silent_p parameter and store it in the cumulative_args structure. Initialize aapcs_nprn and aapcs_nextnprn. If the silent_p flag is set, suppress the usual error about using float registers without TARGET_FLOAT. If the silent_p flag is not set, also raise an error about using SVE functions when SVE is disabled. (aarch64_function_arg_advance): Update the call to aarch64_layout_arg, and call it for SVE functions too. Update aapcs_nprn similarly to the other register counts. (aarch64_layout_frame): If a big-endian function needs to save and restore Z8-Z15, search for a spare predicate that it can use. Store SVE predicates at the bottom of the register save area, followed by SVE vectors, then followed by the normal slots. Keep pointing the hard frame pointer at the base of the normal slots, above the SVE vectors. Update the various frame creation and tear-down strategies for the new layout, initializing the new sve_callee_adjust field. Add an additional layout for frames whose saved registers are all SVE registers. (aarch64_register_saved_on_entry): Cope with poly_int64 reg_offsets. (aarch64_return_address_signing_enabled): Likewise. (aarch64_push_regs, aarch64_pop_regs): Update calls to aarch64_reg_save_mode. (aarch64_adjust_sve_callee_save_base): New function. (aarch64_add_cfa_expression): Move earlier in file. Take the saved register as an rtx rather than a register number and use its mode for the MEM slot. (aarch64_save_callee_saves): Remove the mode argument and instead use aarch64_reg_save_mode to get the mode of each save slot. Add a hard_fp_valid_p parameter. Cope with poly_int64 register offsets. Allow GP offsets to be saved at a VL-based offset from the stack, handling this case using the frame pointer if available or a temporary register otherwise. Use ST1D to save Z8-Z15 for big-endian SVE functions; use normal moves for other SVE saves. Only mark the save as frame-related if aarch64_emit_cfi_for_reg_p returns true. Add explicit CFA notes when not storing via the stack pointer. Do not try to pair SVE saves. (aarch64_restore_callee_saves): Cope with poly_int64 register offsets. Use LD1D to restore Z8-Z15 for big-endian SVE functions; use normal moves for other SVE restores. Only add CFA restore notes if aarch64_emit_cfi_for_reg_p returns true. Do not try to pair SVE restores. (aarch64_get_separate_components): Always keep the first SVE save in the prologue if we need to use it as a stack probe. Don't allow Z8-Z15 saves and loads to be shrink-wrapped for big-endian targets. Likewise the spare predicate register that they need. Update the offset calculation to account for the SVE save area. Use the appropriate range check for SVE LDR and STR instructions. (aarch64_components_for_bb): Cope with poly_int64 reg_offsets. (aarch64_process_components): Likewise. Update the offset calculation to account for the SVE save area. Only mark the save as frame-related if aarch64_emit_cfi_for_reg_p returns true. Do not try to pair SVE saves. (aarch64_allocate_and_probe_stack_space): Cope with poly_int64 reg_offsets. When handling the final allocation, expect the first SVE register save to be part of the initial allocation and for it to act as a probe at SP. Account for the SVE callee save area in the dump information. (aarch64_expand_prologue): Update the frame diagram. Fold the SVE callee allocation into the initial allocation if stack clash protection is enabled. Use new variables to track the offset of the frame chain (and hard frame pointer) from the current stack pointer, and likewise the offset of the bottom of the register save area. Update calls to aarch64_save_callee_saves and aarch64_add_cfa_expression. Apply sve_callee_adjust before saving the FP&SIMD registers. Save the predicate registers. (aarch64_expand_epilogue): Take below_hard_fp_saved_regs_size into account when setting the stack pointer from the frame pointer, and when deciding whether we can inherit the initial adjustment amount from the prologue. Restore the predicate registers after the vector registers, then apply sve_callee_adjust, then restore the general registers. (aarch64_secondary_reload): Don't use secondary SVE reloads for VNx16BImode. (aapcs_vfp_sub_candidate): Assert that the type is not an SVE type. (aarch64_short_vector_p): Return false for SVE types. (aarch64_vfp_is_call_or_return_candidate): Initialize *is_ha at the start of the function. Return false for SVE types. (aarch64_asm_output_variant_pcs): Output .variant_pcs for SVE functions too. (TARGET_STRICT_ARGUMENT_NAMING): Redefine to request strict naming. * config/aarch64/aarch64-sve.md (*aarch64_sve_mov<mode>_le): Extend to big-endian targets for bytewise moves. (*aarch64_sve_mov<mode>_be): Exclude the bytewise case. gcc/testsuite/ * gcc.target/aarch64/sve/pcs/aarch64-sve-pcs.exp: New file. * gcc.target/aarch64/sve/pcs/annotate_1.c: New test. * gcc.target/aarch64/sve/pcs/annotate_2.c: Likewise. * gcc.target/aarch64/sve/pcs/annotate_3.c: Likewise. * gcc.target/aarch64/sve/pcs/annotate_4.c: Likewise. * gcc.target/aarch64/sve/pcs/annotate_5.c: Likewise. * gcc.target/aarch64/sve/pcs/annotate_6.c: Likewise. * gcc.target/aarch64/sve/pcs/annotate_7.c: Likewise. * gcc.target/aarch64/sve/pcs/args_1.c: Likewise. * gcc.target/aarch64/sve/pcs/args_10.c: Likewise. * gcc.target/aarch64/sve/pcs/args_11_nosc.c: Likewise. * gcc.target/aarch64/sve/pcs/args_11_sc.c: Likewise. * gcc.target/aarch64/sve/pcs/args_2.c: Likewise. * gcc.target/aarch64/sve/pcs/args_3.c: Likewise. * gcc.target/aarch64/sve/pcs/args_4.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_be_f16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_be_f32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_be_f64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_be_s16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_be_s32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_be_s64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_be_s8.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_be_u16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_be_u32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_be_u64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_be_u8.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_le_f16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_le_f32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_le_f64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_le_s16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_le_s32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_le_s64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_le_s8.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_le_u16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_le_u32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_le_u64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_5_le_u8.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_be_f16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_be_f32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_be_f64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_be_s16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_be_s32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_be_s64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_be_s8.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_be_u16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_be_u32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_be_u64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_be_u8.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_le_f16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_le_f32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_le_f64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_le_s16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_le_s32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_le_s64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_le_s8.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_le_u16.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_le_u32.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_le_u64.c: Likewise. * gcc.target/aarch64/sve/pcs/args_6_le_u8.c: Likewise. * gcc.target/aarch64/sve/pcs/args_7.c: Likewise. * gcc.target/aarch64/sve/pcs/args_8.c: Likewise. * gcc.target/aarch64/sve/pcs/args_9.c: Likewise. * gcc.target/aarch64/sve/pcs/nosve_1.c: Likewise. * gcc.target/aarch64/sve/pcs/nosve_2.c: Likewise. * gcc.target/aarch64/sve/pcs/nosve_3.c: Likewise. * gcc.target/aarch64/sve/pcs/nosve_4.c: Likewise. * gcc.target/aarch64/sve/pcs/nosve_5.c: Likewise. * gcc.target/aarch64/sve/pcs/nosve_6.c: Likewise. * gcc.target/aarch64/sve/pcs/nosve_7.c: Likewise. * gcc.target/aarch64/sve/pcs/nosve_8.c: Likewise. * gcc.target/aarch64/sve/pcs/return_1.c: Likewise. * gcc.target/aarch64/sve/pcs/return_1_1024.c: Likewise. * gcc.target/aarch64/sve/pcs/return_1_2048.c: Likewise. * gcc.target/aarch64/sve/pcs/return_1_256.c: Likewise. * gcc.target/aarch64/sve/pcs/return_1_512.c: Likewise. * gcc.target/aarch64/sve/pcs/return_2.c: Likewise. * gcc.target/aarch64/sve/pcs/return_3.c: Likewise. * gcc.target/aarch64/sve/pcs/return_4.c: Likewise. * gcc.target/aarch64/sve/pcs/return_4_1024.c: Likewise. * gcc.target/aarch64/sve/pcs/return_4_2048.c: Likewise. * gcc.target/aarch64/sve/pcs/return_4_256.c: Likewise. * gcc.target/aarch64/sve/pcs/return_4_512.c: Likewise. * gcc.target/aarch64/sve/pcs/return_5.c: Likewise. * gcc.target/aarch64/sve/pcs/return_5_1024.c: Likewise. * gcc.target/aarch64/sve/pcs/return_5_2048.c: Likewise. * gcc.target/aarch64/sve/pcs/return_5_256.c: Likewise. * gcc.target/aarch64/sve/pcs/return_5_512.c: Likewise. * gcc.target/aarch64/sve/pcs/return_6.c: Likewise. * gcc.target/aarch64/sve/pcs/return_6_1024.c: Likewise. * gcc.target/aarch64/sve/pcs/return_6_2048.c: Likewise. * gcc.target/aarch64/sve/pcs/return_6_256.c: Likewise. * gcc.target/aarch64/sve/pcs/return_6_512.c: Likewise. * gcc.target/aarch64/sve/pcs/return_7.c: Likewise. * gcc.target/aarch64/sve/pcs/return_8.c: Likewise. * gcc.target/aarch64/sve/pcs/return_9.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_1_be_nowrap.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_1_be_wrap.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_1_le_nowrap.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_1_le_wrap.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_2_be_nowrap.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_2_be_wrap.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_2_le_nowrap.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_2_le_wrap.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_3.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_4_be.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_4_le.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_5_be.c: Likewise. * gcc.target/aarch64/sve/pcs/saves_5_le.c: Likewise. * gcc.target/aarch64/sve/pcs/stack_clash_1.c: Likewise. * gcc.target/aarch64/sve/pcs/stack_clash_1_256.c: Likewise. * gcc.target/aarch64/sve/pcs/stack_clash_1_512.c: Likewise. * gcc.target/aarch64/sve/pcs/stack_clash_1_1024.c: Likewise. * gcc.target/aarch64/sve/pcs/stack_clash_1_2048.c: Likewise. * gcc.target/aarch64/sve/pcs/stack_clash_2.c: Likewise. * gcc.target/aarch64/sve/pcs/stack_clash_2_256.c: Likewise. * gcc.target/aarch64/sve/pcs/stack_clash_2_512.c: Likewise. * gcc.target/aarch64/sve/pcs/stack_clash_2_1024.c: Likewise. * gcc.target/aarch64/sve/pcs/stack_clash_2_2048.c: Likewise. * gcc.target/aarch64/sve/pcs/stack_clash_3.c: Likewise. * gcc.target/aarch64/sve/pcs/unprototyped_1.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_1.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_2_f16.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_2_f32.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_2_f64.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_2_s16.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_2_s32.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_2_s64.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_2_s8.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_2_u16.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_2_u32.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_2_u64.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_2_u8.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_3_nosc.c: Likewise. * gcc.target/aarch64/sve/pcs/varargs_3_sc.c: Likewise. * gcc.target/aarch64/sve/pcs/vpcs_1.c: Likewise. * g++.target/aarch64/sve/catch_7.C: Likewise. From-SVN: r277564
2019-10-09PR tree-optimization/90879 - fold zero-equality of strcmp between a longer ↵Martin Sebor1-0/+8
string and a smaller array gcc/c-family/ChangeLog: PR tree-optimization/90879 * c.opt (-Wstring-compare): New option. gcc/testsuite/ChangeLog: PR tree-optimization/90879 * gcc.dg/Wstring-compare-2.c: New test. * gcc.dg/Wstring-compare.c: New test. * gcc.dg/strcmpopt_3.c: Scan the optmized dump instead of strlen. * gcc.dg/strcmpopt_6.c: New test. * gcc.dg/strlenopt-65.c: Remove uinnecessary declarations, add test cases. * gcc.dg/strlenopt-66.c: Run it. * gcc.dg/strlenopt-68.c: New test. gcc/ChangeLog: PR tree-optimization/90879 * builtins.c (check_access): Avoid using maxbound when null. * calls.c (maybe_warn_nonstring_arg): Adjust to get_range_strlen change. * doc/invoke.texi (-Wstring-compare): Document new warning option. * gimple-fold.c (get_range_strlen_tree): Make setting maxbound conditional. (get_range_strlen): Overwrite initial maxbound when non-null. * gimple-ssa-sprintf.c (get_string_length): Adjust to get_range_strlen changes. * tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Same. (used_only_for_zero_equality): New function. (handle_builtin_memcmp): Call it. (determine_min_objsize): Return an integer instead of tree. (get_len_or_size, strxcmp_eqz_result): New functions. (maybe_warn_pointless_strcmp): New function. (handle_builtin_string_cmp): Call it. Fold zero-equality of strcmp between a longer string and a smaller array. (get_range_strlen_dynamic): Overwrite initial maxbound when non-null. From-SVN: r276773
2019-09-06function.c (assign_parm_find_data_types): Use RECORD_OR_UNION_TYPE_P before ↵Jakub Jelinek1-5/+2
testing TYPE_TRANSPARENT_AGGR. * function.c (assign_parm_find_data_types): Use RECORD_OR_UNION_TYPE_P before testing TYPE_TRANSPARENT_AGGR. * calls.c (initialize_argument_information, load_register_parameters): Likewise. From-SVN: r275472
2019-09-05re PR middle-end/91001 (internal compiler error: in extract_insn, at ↵Jakub Jelinek1-4/+8
recog.c:2310) PR middle-end/91001 PR middle-end/91105 PR middle-end/91106 * calls.c (load_register_parameters): For TYPE_TRANSPARENT_AGGR types, use type of their first field instead of type of args[i].tree_value. * gcc.c-torture/compile/pr91001.c: New test. From-SVN: r275408
2019-08-20Add a pass_by_reference flag to function_arg_infoRichard Sandiford1-0/+3
This patch adds a flag that tells targets whether an argument has been converted to pass-by-reference form. This replaces assign_parm_data_one::passed_pointer in function.c. The flag is set automatically for places that call apply_pass_by_reference_rules. Places that apply pass-by-reference manually need to set it themselves. (After previous changes, no targets apply pass-by-reference manually. They all go through apply_pass_by_reference_rules.) 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * calls.h (function_arg_info): Add a pass_by_reference field, defaulting to false. * calls.c (apply_pass_by_reference_rules): Set pass_by_reference when applying pass-by-reference semantics. (initialize_argument_information): Likewise. (emit_library_call_value_1): Likewise. * function.c (assign_parm_data_one): Remove passed_pointer field. (assign_parm_find_data_types): Don't set it. (assign_parm_find_stack_rtl, assign_parm_adjust_stack_rtl) (assign_parm_setup_reg, assign_parms, gimplify_parameters): Use arg.pass_by_reference instead of passed_pointer. From-SVN: r274707
2019-08-20Make calls.c use function_arg_info internallyRichard Sandiford1-29/+31
This patch makes the two main calls.c argument-processing routines track the state of the argument in a function_arg_info instead of using separate mode variables. 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * calls.c (emit_library_call_value_1): Merge arg and orig_arg into a single function_arg_info, updating its fields when we apply pass-by-reference and promotion semantics. Use the function_arg_info to track the mode rather than keeping it in a separate local variable. (initialize_argument_information): Likewise. Base the final arg_to_skip on this new function_arg_info rather than creating a new one from scratch. From-SVN: r274706
2019-08-20Add a apply_pass_by_reference_rules helperRichard Sandiford1-0/+16
This patch adds a helper routine that applies pass-by-reference semantics to an existing function_arg_info. The c6x part means that c6x_function_arg and c6x_function_arg_advance see the same "named" value as pass_by_reference did, rather than pass_by_reference seeing "true" and the others seeing "false". This doesn't matter because the c6x port doesn't care about namedness. The rs6000.c patch removes an assignment to "type", but the only later code to use it was the patched promote_mode line. (The reason for patching these places despite the above is that often target code gets used as a basis for new targets or changes to existing ones.) 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * calls.h (apply_pass_by_reference_rules): Declare. * calls.c (apply_pass_by_reference_rules): New function. * config/c6x/c6x.c (c6x_call_saved_register_used): Use it. * config/rs6000/rs6000-call.c (rs6000_parm_needs_stack): Likewise. * config/s390/s390.c (s390_call_saved_register_used): Likewise. * function.c (assign_parm_find_data_types): Likewise. * var-tracking.c (prepare_call_arguments): Likewise. From-SVN: r274704
2019-08-20Use function_arg_info for TARGET_MUST_PASS_IN_STACKRichard Sandiford1-16/+16
The hook is passed the promoted mode instead of the original type mode. The expr.h reference in the documentation is no longer correct, but pointing to calls.h or calls.c doesn't help much either. I just left this as-is since it's not related to the point of the series. After previous changes, most places already pass arg.mode and arg.type. Only i386 and mcore needed to construct a new one out of nothing. rs6000 needs to construct one slightly earlier than before. 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * target.def (must_pass_in_stack): Take a function_arg_info instead of a mode and a type. * doc/tm.texi: Regenerate. * calls.h (must_pass_in_stack_var_size): Take a function_arg_info instead of a mode and a type. (must_pass_in_stack_var_size_or_pad): Likewise. * calls.c (must_pass_in_stack_var_size): Likewise. (must_pass_in_stack_var_size_or_pad): Likewise. (initialize_argument_information): Update call to targetm.calls.must_pass_in_stack. (must_pass_va_arg_on_stack): Likewise. * function.c (assign_parm_find_entry_rtl): Likewise. * targhooks.c (hook_pass_by_reference_must_pass_in_stack): Likewise. * config/alpha/alpha.c (alpha_function_arg): Likewise. (alpha_function_arg_advance): Likewise. * config/cr16/cr16.c (cr16_function_arg): Likewise. (cr16_function_arg_advance): Likewise. * config/cris/cris.c (cris_pass_by_reference): Likewise. (cris_arg_partial_bytes): Likewise. * config/iq2000/iq2000.c (iq2000_pass_by_reference): Likewise. * config/lm32/lm32.c (lm32_function_arg): Likewise. * config/mcore/mcore.c (mcore_num_arg_regs): Likewise. (mcore_function_arg, mcore_arg_partial_bytes): Likewise. * config/mips/mips.c (mips_pass_by_reference): Likewise. * config/mmix/mmix.c (mmix_function_arg_advance): Likewise. (mmix_function_arg_1, mmix_pass_by_reference): Likewise. * config/sh/sh.c (sh_pass_by_reference): Likewise. * config/stormy16/stormy16.c (xstormy16_function_arg): Likewise. * config/xtensa/xtensa.c (xtensa_function_arg_advance): Likewise. * config/arm/arm.c (arm_must_pass_in_stack): Take a function_arg_info instead of a mode and a type. * config/fr30/fr30.c (fr30_must_pass_in_stack): Likewise. (fr30_num_arg_regs): Likewise. (fr30_setup_incoming_varargs): Update calls accordingly. (fr30_arg_partial_bytes, fr30_function_arg): Likewise. (fr30_function_arg_advance): Likewise. * config/frv/frv.c (frv_must_pass_in_stack): Take a function_arg_info instead of a mode and a type. * config/gcn/gcn.c (num_arg_regs): Likewise. (gcn_function_arg, gcn_function_arg_advance): Update calls to num_arg_regs and targetm.calls.must_pass_in_stack. (gcn_arg_partial_bytes): Likewise. * config/i386/i386.c (ix86_must_pass_in_stack): Take a function_arg_info instead of a mode and a type. (classify_argument): Update call accordingly. * config/nds32/nds32.c (nds32_must_pass_in_stack): Take a function_arg_info instead of a mode and a type. * config/rs6000/rs6000-internal.h (rs6000_must_pass_in_stack): Likewise. * config/rs6000/rs6000-call.c (rs6000_must_pass_in_stack): Likewise. (rs6000_parm_needs_stack): Update call accordingly. (setup_incoming_varargs): Likewise. From-SVN: r274703
2019-08-20Use function_arg_info for TARGET_CALLEE_COPIESRichard Sandiford1-11/+6
The hook is passed the unpromoted type mode instead of the promoted mode. The aarch64 definition is redundant, but worth keeping for emphasis. 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * target.def (callee_copies): Take a function_arg_info instead of a mode, type and named flag. * doc/tm.texi: Regenerate. * targhooks.h (hook_callee_copies_named): Take a function_arg_info instead of a mode, type and named flag. (hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false): Delete. (hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true): Likewise. (hook_bool_CUMULATIVE_ARGS_arg_info_true): New function. * targhooks.c (hook_callee_copies_named): Take a function_arg_info instead of a mode, type and named flag. (hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false): Delete. (hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true): Likewise. (hook_bool_CUMULATIVE_ARGS_arg_info_true): New function. * calls.h (reference_callee_copied): Take a function_arg_info instead of a mode, type and named flag. * calls.c (reference_callee_copied): Likewise. (initialize_argument_information): Update call accordingly. (emit_library_call_value_1): Likewise. * function.c (gimplify_parameters): Likewise. * config/aarch64/aarch64.c (TARGET_CALLEE_COPIES): Define to hook_bool_CUMULATIVE_ARGS_arg_info_false instead of hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false. * config/c6x/c6x.c (c6x_callee_copies): Delete. (TARGET_CALLEE_COPIES): Define to hook_bool_CUMULATIVE_ARGS_arg_info_true instead. * config/epiphany/epiphany.c (TARGET_CALLEE_COPIES): Define to hook_bool_CUMULATIVE_ARGS_arg_info_true instead of hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true. * config/mips/mips.c (mips_callee_copies): Take a function_arg_info instead of a mode, type and named flag. * config/mmix/mmix.c (TARGET_CALLEE_COPIES): Define to hook_bool_CUMULATIVE_ARGS_arg_info_true instead of hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true. * config/mn10300/mn10300.c (TARGET_CALLEE_COPIES): Likewise. * config/msp430/msp430.c (msp430_callee_copies): Delete. (TARGET_CALLEE_COPIES): Define to hook_bool_CUMULATIVE_ARGS_arg_info_true instead. * config/pa/pa.c (pa_callee_copies): Take a function_arg_info instead of a mode, type and named flag. * config/sh/sh.c (sh_callee_copies): Likewise. * config/v850/v850.c (TARGET_CALLEE_COPIES): Define to hook_bool_CUMULATIVE_ARGS_arg_info_true instead of hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true. From-SVN: r274702
2019-08-20Use function_arg_info for TARGET_FUNCTION_ARG_ADVANCERichard Sandiford1-4/+9
There seems to be a bit of confusion around this one. Almost all callers pass the same arguments as TARGET_FUNCTION_ARG, meaning that the mode is the promoted mode rather than the type mode. But the calls.c handling for normal typed arguments instead passes the unpromoted TYPE_MODE (despite passing the promoted mode to TARGET_FUNCTION_ARG). I've kept this behaviour with a ??? comment. (The calls.c handling of libgcc functions does pass the promoted mode though, as does the function.c handling of incoming arguments.) Also, a couple of the arm callers don't seem to be using the hook correctly. Again I kept the current choices and added a ??? comment. 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * target.def (function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * doc/tm.texi: Regenerate. * targhooks.h (default_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * targhooks.c (default_function_arg_advance): Likewise. * calls.c (initialize_argument_information): Update call to targetm.calls.function_arg_advance. (emit_library_call_value_1): Likewise. * dse.c (get_call_args): Likewise. * expr.c (block_move_libcall_safe_for_call_parm): Likewise. * function.c (assign_parms, gimplify_parameters): Likewise. * var-tracking.c (prepare_call_arguments): Likewise. * config/aarch64/aarch64.c (aarch64_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. (aarch64_setup_incoming_varargs): Update call accordingly. * config/alpha/alpha.c (alpha_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. (alpha_setup_incoming_varargs): Update call accordingly. * config/arc/arc.c (arc_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. (arc_setup_incoming_varargs): Update call accordingly. * config/arm/arm.c (arm_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. (cmse_func_args_or_return_in_stack): Update call accordingly. (arm_function_ok_for_sibcall): Likewise. (cmse_nonsecure_call_clear_caller_saved): Likewise. * config/avr/avr.c (avr_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * config/bfin/bfin.c (bfin_function_arg_advance): Likewise. * config/c6x/c6x.c (c6x_function_arg_advance): Likewise. (c6x_call_saved_register_used): Update call accordingly. * config/cr16/cr16.c (cr16_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * config/cris/cris.c (cris_function_arg_advance): Likewise. * config/csky/csky.c (csky_function_arg_advance): Likewise. (csky_setup_incoming_varargs): Update call accordingly. * config/epiphany/epiphany.c (epiphany_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * config/fr30/fr30.c (fr30_function_arg_advance): Likewise. * config/frv/frv.c (frv_function_arg_advance): Likewise. * config/ft32/ft32.c (ft32_function_arg_advance): Likewise. * config/gcn/gcn.c (gcn_function_arg_advance): Likewise. * config/h8300/h8300.c (h8300_function_arg_advance): Likewise. * config/i386/i386.c (ix86_function_arg_advance): Likewise. (ix86_setup_incoming_varargs): Update call accordingly. * config/ia64/ia64.c (ia64_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. (ia64_setup_incoming_varargs): Update call accordingly. * config/iq2000/iq2000.c (iq2000_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. (iq2000_expand_prologue): Update call accordingly. * config/lm32/lm32.c (lm32_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * config/m32c/m32c.c (m32c_function_arg_advance): Likewise. * config/m32r/m32r.c (m32r_function_arg_advance): Likewise. * config/m68k/m68k.c (m68k_function_arg_advance): Likewise. * config/mcore/mcore.c (mcore_function_arg_advance): Likewise. * config/microblaze/microblaze.c (microblaze_function_arg_advance): Likewise. (microblaze_expand_prologue): Update call accordingly. * config/mips/mips.c (mips_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. (mips_setup_incoming_varargs): Update call accordingly. (mips_output_args_xfer): Likewise. * config/mmix/mmix.c (mmix_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * config/mn10300/mn10300.c (mn10300_function_arg_advance): Likewise. * config/moxie/moxie.c (moxie_function_arg_advance): Likewise. * config/msp430/msp430.c (msp430_function_arg_advance): Likewise. * config/nds32/nds32.c (nds32_function_arg_advance): Likewise. * config/nios2/nios2.c (nios2_function_arg_advance): Likewise. (nios2_setup_incoming_varargs): Update call accordingly. * config/nvptx/nvptx.c (nvptx_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * config/or1k/or1k.c (or1k_function_arg_advance): Likewise. * config/pa/pa.c (pa_function_arg_advance): Likewise. * config/pdp11/pdp11.c (pdp11_function_arg_advance): Likewise. * config/pru/pru.c (pru_function_arg_advance): Likewise. * config/riscv/riscv.c (riscv_function_arg_advance): Likewise. (riscv_setup_incoming_varargs): Update call accordingly. * config/rl78/rl78.c (rl78_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * config/rs6000/rs6000-internal.h (rs6000_function_arg_advance): Likewise. * config/rs6000/rs6000-call.c (rs6000_function_arg_advance): Likewise. (rs6000_parm_needs_stack): Update call accordingly. * config/rx/rx.c (rx_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * config/s390/s390.c (s390_function_arg_advance): Likewise. (s390_call_saved_register_used): Update call accordingly. * config/sh/sh.c (sh_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. (sh_output_mi_thunk): Update call accordingly. * config/sparc/sparc.c (sparc_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * config/spu/spu.c (spu_function_arg_advance): Likewise. (spu_setup_incoming_varargs): Update call accordingly. * config/stormy16/stormy16.c (xstormy16_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * config/tilegx/tilegx.c (tilegx_function_arg_advance): Likewise. (tilegx_setup_incoming_varargs): Update call accordingly. * config/tilepro/tilepro.c (tilepro_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. (tilegx_setup_incoming_varargs): Update call accordingly. * config/v850/v850.c (v850_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. * config/vax/vax.c (vax_function_arg_advance): Likewise. * config/visium/visium.c (visium_function_arg_advance): Likewise. (visium_setup_incoming_varargs): Update call accordingly. * config/xtensa/xtensa.c (xtensa_function_arg_advance): Take a function_arg_info instead of a mode, type and named flag. From-SVN: r274701
2019-08-20Use function_arg_info for TARGET_FUNCTION_(INCOMING_)ARGRichard Sandiford1-18/+12
This patch makes both TARGET_FUNCTION_ARG and TARGET_FUNCTION_INCOMING_ARG take a function_arg_info. They have to be done together since many targets use the same function for both. The hooks are passed the promoted mode instead of the original type mode. 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * target.def (function_arg, function_incoming_arg): Take a function_arg_info instead of a mode, tree and named flag. * doc/tm.texi: Regenerate. * targhooks.h (default_function_arg): Take a function_arg_info instead of a mode, tree and named flag. (default_function_incoming_arg): Likewise. * targhooks.c (default_function_arg): Likewise. (default_function_incoming_arg): Likewise. * calls.h (function_arg_info::end_marker_p): New function. (function_arg_info::end_marker): Likewise. * calls.c (prepare_call_address, initialize_argument_information) (expand_call, emit_library_call_value_1): Update calls to targetm.calls.function_arg and targetm.calls.function_incoming_arg. * dse.c: Include calls.h. (get_call_args): Update call to targetm.calls.function_arg. * expr.c (block_move_libcall_safe_for_call_parm): Likewise. * var-tracking.c (prepare_call_arguments): Likewise. * function.c (assign_parm_find_entry_rtl): Update call to targetm.calls.function_incoming_arg. * config/aarch64/aarch64.c (aarch64_function_arg): Take a function_arg_info instead of a mode, tree and named flag. * config/alpha/alpha.c (alpha_function_arg): Likewise. * config/arc/arc.c (arc_function_arg): Likewise. * config/arm/arm.c (arm_function_arg): Likewise. (cmse_func_args_or_return_in_stack): Update call accordingly. (arm_function_ok_for_sibcall): Likewise. (cmse_nonsecure_call_clear_caller_saved): Likewise. * config/avr/avr.c (avr_function_arg): Take a function_arg_info instead of a mode, tree and named flag. * config/bfin/bfin.c (bfin_function_arg): Likewise. * config/c6x/c6x.c (c6x_function_arg): Likewise. (c6x_call_saved_register_used): Update call accordingly. * config/cr16/cr16.c (cr16_function_arg): Take a function_arg_info instead of a mode, tree and named flag. * config/cris/cris.c (cris_function_arg, cris_function_incoming_arg) (cris_function_arg_1): Likewise. * config/csky/csky.c (csky_function_arg): Likewise. * config/epiphany/epiphany.c (epiphany_function_arg): Likewise. * config/fr30/fr30.c (fr30_function_arg): Likewise. * config/frv/frv.c (frv_function_arg, frv_function_incoming_arg) (frv_function_arg_1): Likewise. * config/ft32/ft32.c (ft32_function_arg): Likewise. * config/gcn/gcn.c (gcn_function_arg): Likewise. * config/h8300/h8300.c (h8300_function_arg): Likewise. * config/i386/i386.c (ix86_function_arg): Likewise. * config/ia64/ia64.c (ia64_function_arg, ia64_function_incoming_arg) (ia64_function_arg_1): Likewise. * config/iq2000/iq2000.c (iq2000_function_arg): Likewise. (iq2000_expand_prologue, iq2000_pass_by_reference): Update call accordingly. * config/lm32/lm32.c (lm32_function_arg): Take a function_arg_info instead of a mode, tree and named flag. * config/m32c/m32c.c (m32c_function_arg): Likewise. * config/m32r/m32r.c (m32r_function_arg): Likewise. * config/m68k/m68k.c (m68k_function_arg): Likewise. * config/mcore/mcore.c (mcore_function_arg): Likewise. * config/microblaze/microblaze.c (microblaze_function_arg): Likewise. (microblaze_expand_prologue): Update call accordingly. * config/mips/mips.c (mips_function_arg): Take a function_arg_info instead of a mode, tree and named flag. * config/mmix/mmix.c (mmix_function_incoming_arg, mmix_function_arg) (mmix_function_arg_1): Likewise. * config/mn10300/mn10300.c (mn10300_function_arg): Likewise. * config/moxie/moxie.c (moxie_function_arg): Likewise. * config/msp430/msp430.c (msp430_function_arg): Likewise. * config/nds32/nds32.c (nds32_function_arg): Likewise. * config/nios2/nios2.c (nios2_function_arg): Likewise. * config/nvptx/nvptx.c (nvptx_function_arg): Likewise. (nvptx_function_incoming_arg): Likewise. * config/or1k/or1k.c (or1k_function_arg): Likewise. * config/pa/pa.c (pa_function_arg): Likewise. * config/pdp11/pdp11.c (pdp11_function_arg): Likewise. * config/pru/pru.c (pru_function_arg): Likewise. * config/riscv/riscv.c (riscv_function_arg): Likewise. * config/rl78/rl78.c (rl78_function_arg): Likewise. * config/rs6000/rs6000-internal.h (rs6000_function_arg): Likewise. * config/rs6000/rs6000-call.c (rs6000_function_arg): Likewise. (rs6000_parm_needs_stack): Update call accordingly. * config/rx/rx.c (rx_function_arg): Take a function_arg_info instead of a mode, tree and named flag. * config/s390/s390.c (s390_function_arg): Likewise. (s390_call_saved_register_used): Update call accordingly. * config/sh/sh.c (sh_function_arg): Take a function_arg_info instead of a mode, tree and named flag. (sh_output_mi_thunk): Update call accordingly. * config/sparc/sparc.c (sparc_function_arg_1, sparc_function_arg) (sparc_function_incoming_arg): Take a function_arg_info instead of a mode, tree and named flag. * config/spu/spu.c (spu_function_arg): Likewise. * config/stormy16/stormy16.c (xstormy16_function_arg): Likewise. * config/tilegx/tilegx.c (tilegx_function_arg): Likewise. * config/tilepro/tilepro.c (tilepro_function_arg): Likewise. * config/v850/v850.c (v850_function_arg): Likewise. * config/vax/vax.c (vax_function_arg): Likewise. * config/visium/visium.c (visium_function_arg): Likewise. * config/xtensa/xtensa.c (xtensa_function_arg_1, xtensa_function_arg) (xtensa_function_incoming_arg): Likewise. From-SVN: r274700
2019-08-20Use function_arg_info for TARGET_PASS_BY_REFERENCERichard Sandiford1-12/+11
The hook is passed the unpromoted type mode instead of the promoted mode. 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * target.def (pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * doc/tm.texi: Regenerate. * targhooks.h (hook_pass_by_reference_must_pass_in_stack): Update accordingly. (hook_bool_CUMULATIVE_ARGS_arg_info_false): Declare. * targhooks.c (hook_pass_by_reference_must_pass_in_stack): Take a function_arg_info instead of a mode, type and named flag. (hook_bool_CUMULATIVE_ARGS_arg_info_false): New function. * calls.h (pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * calls.c (pass_by_reference): Likewise. (pass_va_arg_by_reference): Update call accordingly. (initialize_argument_information): Likewise. (emit_library_call_value_1): Likewise. * function.c (assign_parm_find_data_types): Likewise. * var-tracking.c (prepare_call_arguments): Likewise. * stor-layout.c: Include calls.h. (compute_record_mode): Update call to targetm.calls.pass_by_reference. * config/aarch64/aarch64.c (aarch64_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/alpha/alpha.c (alpha_pass_by_reference): Likewise. * config/arc/arc.c (arc_pass_by_reference): Likewise. * config/arm/arm.c (arm_pass_by_reference): Likewise. * config/bfin/bfin.c (bfin_pass_by_reference): Likewise. * config/c6x/c6x.c (c6x_pass_by_reference): Likewise. (c6x_call_saved_register_used): Update call to pass_by_reference. * config/cris/cris.c (cris_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/epiphany/epiphany.c (epiphany_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. (epiphany_arg_partial_bytes): Update call accordingly. * config/ft32/ft32.c (ft32_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. (ft32_arg_partial_bytes): Update call accordingly. * config/i386/i386.c (ix86_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/iq2000/iq2000.c (iq2000_pass_by_reference): Likewise. * config/m32c/m32c.c (m32c_pass_by_reference): Likewise. * config/m32r/m32r.c (m32r_pass_by_reference): Likewise. (m32r_return_in_memory): Update call accordingly. * config/mips/mips.c (mips_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/mmix/mmix.c (mmix_pass_by_reference): Likewise. * config/mn10300/mn10300.c (mn10300_pass_by_reference): Likewise. * config/moxie/moxie.c (moxie_pass_by_reference): Likewise. (moxie_arg_partial_bytes): Update call accordingly. * config/msp430/msp430.c (msp430_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/nvptx/nvptx.c (nvptx_pass_by_reference): Likewise. * config/or1k/or1k.c (or1k_pass_by_reference): Likewise. * config/pa/pa.c (pa_pass_by_reference): Likewise. * config/riscv/riscv.c (riscv_pass_by_reference): Likewise. (riscv_return_in_memory): Update call accordingly. * config/rs6000/rs6000-internal.h (rs6000_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/rs6000/rs6000-call.c (rs6000_pass_by_reference): Likewise. (rs6000_parm_needs_stack): Update call to pass_by_reference. * config/s390/s390.c (s390_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. (s390_call_saved_register_used): Update call accordingly. * config/sh/sh.c (sh_pass_by_reference): Take a function_arg_info instead of a mode, type and named flag. * config/sparc/sparc.c (sparc_pass_by_reference): Likewise. * config/spu/spu.c (spu_pass_by_reference): Likewise. * config/tilegx/tilegx.c (tilegx_pass_by_reference): Likewise. * config/tilepro/tilepro.c (tilepro_pass_by_reference): Likewise. * config/v850/v850.c (v850_pass_by_reference): Likewise. * config/visium/visium.c (visium_pass_by_reference): Likewise. gcc/ada/ * gcc-interface/misc.c (default_pass_by_ref): Update call to pass_by_reference. From-SVN: r274698
2019-08-20Use function_arg_info for TARGET_ARG_PARTIAL_BYTESRichard Sandiford1-6/+6
This patch adds the function_arg_info class and uses it for TARGET_ARG_PARTIAL_BYTES. The hook is passed the promoted mode instead of the original type mode. The arguments aren't mentioned in the documentation, which is why the target.def change is so small. The patch changes "true" to "arg.named" in: gcc_assert (!epiphany_pass_by_reference (cum, mode, type, /* named */ true)); but epiphany_pass_by_reference doesn't care about the named flag. 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * target.def (arg_partial_bytes): Take a function_arg_info instead of a mode, type and named flag. * doc/tm.texi: Regenerate. * target.h (function_arg_info): Declare. * calls.h (function_arg_info): New class. * targhooks.h (hook_int_CUMULATIVE_ARGS_mode_tree_bool_0): Delete. (hook_int_CUMULATIVE_ARGS_arg_info_0): Declare. * targhooks.c (hook_int_CUMULATIVE_ARGS_mode_tree_bool_0): Delete. (hook_int_CUMULATIVE_ARGS_arg_info_0): New function. * calls.c (initialize_argument_information): Update call to targetm.calls.partial_bytes. (emit_library_call_value_1): Likewise. * expr.c (block_move_libcall_safe_for_call_parm): Likewise. * function.c (assign_parm_find_entry_rtl): Likewise. * config/alpha/alpha.c (alpha_arg_partial_bytes): Take a function_arg_info instead of a mode, type and named flag. * config/arc/arc.c (arc_arg_partial_bytes): Likewise. * config/arm/arm.c (arm_arg_partial_bytes): Likewise. (cmse_func_args_or_return_in_stack): Update accordingly. * config/bfin/bfin.c (bfin_arg_partial_bytes): Take a function_arg_info instead of a mode, type and named flag. * config/cris/cris.c (cris_arg_partial_bytes): Likewise. * config/csky/csky.c (csky_arg_partial_bytes): Likewise. * config/epiphany/epiphany.c (epiphany_arg_partial_bytes): Likewise. * config/fr30/fr30.c: Include calls.h. (fr30_arg_partial_bytes): Take a function_arg_info instead of a mode, type and named flag. * config/frv/frv.c: Include calls.h. (frv_arg_partial_bytes): Take a function_arg_info instead of a mode, type and named flag. * config/ft32/ft32.c (ft32_arg_partial_bytes): Likewise. * config/gcn/gcn.c (gcn_arg_partial_bytes): Likewise. * config/ia64/ia64.c (ia64_arg_partial_bytes): Likewise. * config/iq2000/iq2000.c (iq2000_arg_partial_bytes): Likewise. * config/m32r/m32r.c (m32r_arg_partial_bytes): Likewise. * config/mcore/mcore.c (mcore_arg_partial_bytes): Likewise. * config/microblaze/microblaze.c (function_arg_partial_bytes): Likewise. * config/mips/mips.c (mips_arg_partial_bytes): Likewise. * config/mn10300/mn10300.c (mn10300_arg_partial_bytes): Likewise. * config/moxie/moxie.c (moxie_arg_partial_bytes): Likewise. * config/msp430/msp430.c (msp430_arg_partial_bytes): Likewise. * config/nds32/nds32.c (nds32_arg_partial_bytes): Likewise. * config/nios2/nios2.c (nios2_arg_partial_bytes): Likewise. * config/pa/pa.c (pa_arg_partial_bytes): Likewise. * config/pru/pru.c (pru_arg_partial_bytes): Likewise. * config/riscv/riscv.c (riscv_arg_partial_bytes): Likewise. * config/rs6000/rs6000-internal.h (rs6000_arg_partial_bytes): Likewise. * config/rs6000/rs6000-call.c (rs6000_arg_partial_bytes): Likewise. (rs6000_parm_needs_stack): Update call accordingly. * config/sh/sh.c (sh_arg_partial_bytes): Take a function_arg_info instead of a mode, type and named flag. * config/sparc/sparc.c (sparc_arg_partial_bytes): Likewise. * config/v850/v850.c (v850_arg_partial_bytes): Likewise. From-SVN: r274697
2019-08-20Add must_pass_va_arg_in_stackRichard Sandiford1-0/+9
This patch splits out another idiom from the va_arg gimplification routines, so that there's only one place to update later. 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * calls.h (must_pass_va_arg_in_stack): Declare. * calls.c (must_pass_va_arg_in_stack): New function. * config/alpha/alpha.c (alpha_gimplify_va_arg_1): Use it. * config/sh/sh.c (sh_gimplify_va_arg_expr): Likewise. * config/stormy16/stormy16.c (xstormy16_gimplify_va_arg_expr): Likewise. * config/xtensa/xtensa.c (xtensa_gimplify_va_arg_expr): Likewise. From-SVN: r274696
2019-08-20Add pass_va_arg_by_referenceRichard Sandiford1-0/+9
This patch splits out a common idiom from the va_arg gimplification routines, so that there's only one place to update later. 2019-08-20 Richard Sandiford <richard.sandiford@arm.com> gcc/ * calls.h (pass_va_arg_by_reference): Declare. * calls.c (pass_va_arg_by_reference): New function. * config/aarch64/aarch64.c (aarch64_gimplify_va_arg_expr): Use it. * config/alpha/alpha.c (alpha_gimplify_va_arg): Likewise. * config/gcn/gcn.c (gcn_gimplify_va_arg_expr): Likewise. * config/i386/i386.c (ix86_gimplify_va_arg): Likewise. * config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise. * config/mips/mips.c (mips_std_gimplify_va_arg_expr): Likewise. (mips_gimplify_va_arg_expr): Likewise. * config/msp430/msp430.c (msp430_gimplify_va_arg_expr): Likewise. * config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise. * config/rs6000/rs6000-call.c (rs6000_gimplify_va_arg): Likewise. * config/s390/s390.c (s390_gimplify_va_arg): Likewise. * config/sparc/sparc.c (sparc_gimplify_va_arg): Likewise. * config/spu/spu.c (spu_gimplify_va_arg_expr): Likewise. * config/tilegx/tilegx.c (tilegx_gimplify_va_arg_expr): Likewise. * config/tilepro/tilepro.c (tilepro_gimplify_va_arg_expr): Likewise. * config/visium/visium.c (visium_gimplify_va_arg): Likewise. * config/xtensa/xtensa.c (xtensa_gimplify_va_arg_expr): Likewise. * targhooks.c (std_gimplify_va_arg_expr): Likewise. From-SVN: r274695
2019-08-13Protect some checks of DECL_FUNCTION_CODERichard Sandiford1-6/+4
This patch protects various uses of DECL_FUNCTION_CODE that didn't obviously check for BUILT_IN_NORMAL first (either directly or in callers). They could therefore trigger for functions that either aren't built-ins or are a different kind of built-in. Also, the patch removes a redundant GIMPLE_CALL check from optimize_stdarg_builtin, since it gave the impression that the stmt was less well checked than it actually is. 2019-08-13 Richard Sandiford <richard.sandiford@arm.com> gcc/ PR middle-end/91421 * attribs.c (decl_attributes): Check the DECL_BUILT_IN_CLASS before the DECL_FUNCTION_CODE. * calls.c (maybe_warn_alloc_args_overflow): Use fndecl_built_in_p to check for a BUILT_IN_ALLOCA call. * ipa-cp.c (ipa_get_indirect_edge_target_1): Likewise for BUILT_IN_UNREACHABLE. Don't check for a FUNCTION_TYPE. * ipa-devirt.c (possible_polymorphic_call_target_p): Likewise. * ipa-prop.c (try_make_edge_direct_virtual_call): Likewise. * gimple-ssa-isolate-paths.c (is_addr_local): Check specifically for BUILT_IN_NORMAL functions. * trans-mem.c (expand_block_edges): Use gimple_call_builtin_p to test for BUILT_IN_TM_ABORT. * tree-ssa-ccp.c (optimize_stack_restore): Use fndecl_built_in_p to check for a BUILT_IN_STACK_RESTORE call. (optimize_stdarg_builtin): Remove redundant check for GIMPLE_CALL. * tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts_at_dest): Check for a BUILT_IN_NORMAL decl before checking its DECL_FUNCTION_CODE. * tree-vect-patterns.c (vect_recog_pow_pattern): Use a positive test for a BUILT_IN_NORMAL call instead of a negative test for an internal function call. gcc/c/ PR middle-end/91421 * c-decl.c (header_for_builtin_fn): Take a FUNCTION_DECL instead of a built_in_function. (diagnose_mismatched_decls, implicitly_declare): Update accordingly. From-SVN: r274403
2019-07-25Come up with function_decl_type and use it in tree_function_decl.Martin Liska1-1/+1
2019-07-25 Martin Liska <mliska@suse.cz> * calls.c (maybe_warn_alloc_args_overflow): Use new macros (e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P). * coverage.c (coverage_begin_function): Likewise. * fold-const.c (tree_expr_nonzero_warnv_p): Likewise. * gimple.c (gimple_call_nonnull_result_p): Likewise. * ipa-icf.c (sem_item::compare_referenced_symbol_properties): Likewise. (sem_item::hash_referenced_symbol_properties): Likewise. * lto-streamer-out.c (hash_tree): Likewise. * predict.c (expr_expected_value_1): Likewise. * tree-inline.c (expand_call_inline): Likewise. * tree-streamer-in.c (unpack_ts_function_decl_value_fields): Likewise. * tree-streamer-out.c (pack_ts_function_decl_value_fields): Likewise. * tree-core.h (enum function_decl_type): New enum. (struct tree_function_decl): Remove operator_new_flag and lambda_function. * tree.h (FUNCTION_DECL_DECL_TYPE): New. (set_function_decl_type): Likewise. (DECL_IS_OPERATOR_NEW_P): New. (DECL_SET_IS_OPERATOR_NEW): Likewise. (DECL_LAMBDA_FUNCTION): Likewise. (DECL_LAMBDA_FUNCTION_P): Likewise. (DECL_IS_OPERATOR_NEW): Remove. (DECL_SET_LAMBDA_FUNCTION): Likewise. 2019-07-25 Martin Liska <mliska@suse.cz> * c-decl.c (merge_decls): Use new macros (e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P). 2019-07-25 Martin Liska <mliska@suse.cz> * decl.c (duplicate_decls): Use new macros (e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P). (cxx_init_decl_processing): Likewise. (grok_op_properties): Likewise. * parser.c (cp_parser_lambda_declarator_opt): Likewise. 2019-07-25 Martin Liska <mliska@suse.cz> * lto-common.c (compare_tree_sccs_1): Use new macros (e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P). From-SVN: r273790
2019-06-14Update preferred_stack_boundary only when expanding function callH.J. Lu1-0/+25
locate_and_pad_parm is called when expanding function call from initialize_argument_information and when generating function body from assign_parm_find_entry_rtl: /* Remember if the outgoing parameter requires extra alignment on the calling function side. */ if (crtl->stack_alignment_needed < boundary) crtl->stack_alignment_needed = boundary; if (crtl->preferred_stack_boundary < boundary) crtl->preferred_stack_boundary = boundary; stack_alignment_needed and preferred_stack_boundary should be updated only when expanding function call, not when generating function body. Add update_stack_alignment_for_call to update stack alignment when outgoing parameter is passed in the stack. gcc/ PR rtl-optimization/90765 * calls.c (update_stack_alignment_for_call): New function. (expand_call): Call update_stack_alignment_for_call when outgoing parameter is passed in the stack. (emit_library_call_value_1): Likewise. * function.c (locate_and_pad_parm): Don't update stack_alignment_needed and preferred_stack_boundary. gcc/testsuite/ PR rtl-optimization/90765 * gcc.target/i386/pr90765-1.c: New test. * gcc.target/i386/pr90765-2.c: Likewise. From-SVN: r272296
2019-05-16re PR fortran/90329 (Incompatibility between gfortran and C lapack calls)Jakub Jelinek1-0/+22
PR fortran/90329 * tree-core.h (struct tree_decl_common): Document decl_nonshareable_flag for PARM_DECLs. * tree.h (DECL_HIDDEN_STRING_LENGTH): Define. * calls.c (expand_call): Don't try tail call if caller has any DECL_HIDDEN_STRING_LENGTH PARM_DECLs that are or might be passed on the stack and callee needs to pass any arguments on the stack. * tree-streamer-in.c (unpack_ts_decl_common_value_fields): Use else if instead of series of mutually exclusive ifs. Handle DECL_HIDDEN_STRING_LENGTH for PARM_DECLs. * tree-streamer-out.c (pack_ts_decl_common_value_fields): Likewise. * trans-decl.c (create_function_arglist): Set DECL_HIDDEN_STRING_LENGTH on hidden string length PARM_DECLs if len is constant. From-SVN: r271285
2019-04-04PR middle-end/89957 - ICE calling strnlen with an int128_t bound in a known ↵Martin Sebor1-0/+3
range PR middle-end/89957 - ICE calling strnlen with an int128_t bound in a known range PR middle-end/89911 - [9 Regression] ICE in get_attr_nonstring_decl gcc/ChangeLog: PR middle-end/89957 PR middle-end/89911 * builtins.c (expand_builtin_strnlen): Make sure wi::ltu_p operands have the same precision since the function crashes otherwise. * calls.c (maybe_warn_nonstring_arg): Avoid assuming strnlen() call has non-zero arguments. gcc/testsuite/ChangeLog: PR middle-end/89957 PR middle-end/89911 * gcc.dg/Wstringop-overflow-13.c: New test. From-SVN: r270154
2019-02-13Clean up MPX-related stuff.Martin Liska1-13/+1
2019-02-13 Martin Liska <mliska@suse.cz> * builtins.h (expand_builtin_with_bounds): Remove declaration. * calls.c (struct arg_data): Remove special_slot, pointer_arg and pointer_offset fields. (initialize_argument_information): Remove usage of dead fields. * cgraph.h (struct cgraph_thunk_info): Remove add_pointer_bounds_args. * cgraphunit.c (cgraph_node::expand_thunk): Remove usage of dead fields. (cgraph_node::assemble_thunks_and_aliases): Remove usage of dead fields. * config/i386/i386.c (ix86_function_arg_advance): Remove unrelated comment. (struct builtin_isa): Remove leaf_p and nothrow_p fields. (def_builtin): Remove usage of dead fields. (ix86_add_new_builtins): Likewise. * ipa-fnsummary.c (compute_fn_summary): Likewise. * ipa-icf.c (sem_function::equals_wpa): Likewise. (sem_function::init): Likewise. (sem_variable::merge): Likewise. * ipa-visibility.c (function_and_variable_visibility): Likewise. * ipa.c (symbol_table::remove_unreachable_nodes): Likewise. * lto-cgraph.c (lto_output_node): Likewise. (lto_output_varpool_node): Likewise. (input_node): Likewise. (input_varpool_node): Likewise. * lto-streamer-out.c (lto_output): Likewise. * tree-inline.c (expand_call_inline): Remove usage of assign_stmts. * tree-inline.h (struct copy_body_data): Likewise. * varpool.c (varpool_node::dump): Likewise. From-SVN: r268844
2019-01-09PR other/16615 [1/5]Sandra Loosemore1-2/+2
2019-01-09 Sandra Loosemore <sandra@codesourcery.com> PR other/16615 [1/5] contrib/ * mklog: Mechanically replace "can not" with "cannot". gcc/ * Makefile.in: Mechanically replace "can not" with "cannot". * alias.c: Likewise. * builtins.c: Likewise. * calls.c: Likewise. * cgraph.c: Likewise. * cgraph.h: Likewise. * cgraphclones.c: Likewise. * cgraphunit.c: Likewise. * combine-stack-adj.c: Likewise. * combine.c: Likewise. * common/config/i386/i386-common.c: Likewise. * config/aarch64/aarch64.c: Likewise. * config/alpha/sync.md: Likewise. * config/arc/arc.c: Likewise. * config/arc/predicates.md: Likewise. * config/arm/arm-c.c: Likewise. * config/arm/arm.c: Likewise. * config/arm/arm.h: Likewise. * config/arm/arm.md: Likewise. * config/arm/cortex-r4f.md: Likewise. * config/csky/csky.c: Likewise. * config/csky/csky.h: Likewise. * config/darwin-f.c: Likewise. * config/epiphany/epiphany.md: Likewise. * config/i386/i386.c: Likewise. * config/i386/sol2.h: Likewise. * config/m68k/m68k.c: Likewise. * config/mcore/mcore.h: Likewise. * config/microblaze/microblaze.md: Likewise. * config/mips/20kc.md: Likewise. * config/mips/sb1.md: Likewise. * config/nds32/nds32.c: Likewise. * config/nds32/predicates.md: Likewise. * config/pa/pa.c: Likewise. * config/rs6000/e300c2c3.md: Likewise. * config/rs6000/rs6000.c: Likewise. * config/s390/s390.h: Likewise. * config/sh/sh.c: Likewise. * config/sh/sh.md: Likewise. * config/spu/vmx2spu.h: Likewise. * cprop.c: Likewise. * dbxout.c: Likewise. * df-scan.c: Likewise. * doc/cfg.texi: Likewise. * doc/extend.texi: Likewise. * doc/fragments.texi: Likewise. * doc/gty.texi: Likewise. * doc/invoke.texi: Likewise. * doc/lto.texi: Likewise. * doc/md.texi: Likewise. * doc/objc.texi: Likewise. * doc/rtl.texi: Likewise. * doc/tm.texi: Likewise. * dse.c: Likewise. * emit-rtl.c: Likewise. * emit-rtl.h: Likewise. * except.c: Likewise. * expmed.c: Likewise. * expr.c: Likewise. * fold-const.c: Likewise. * genautomata.c: Likewise. * gimple-fold.c: Likewise. * hard-reg-set.h: Likewise. * ifcvt.c: Likewise. * ipa-comdats.c: Likewise. * ipa-cp.c: Likewise. * ipa-devirt.c: Likewise. * ipa-fnsummary.c: Likewise. * ipa-icf.c: Likewise. * ipa-inline-transform.c: Likewise. * ipa-inline.c: Likewise. * ipa-polymorphic-call.c: Likewise. * ipa-profile.c: Likewise. * ipa-prop.c: Likewise. * ipa-pure-const.c: Likewise. * ipa-reference.c: Likewise. * ipa-split.c: Likewise. * ipa-visibility.c: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-conflicts.c: Likewise. * ira-costs.c: Likewise. * ira-int.h: Likewise. * ira-lives.c: Likewise. * ira.c: Likewise. * ira.h: Likewise. * loop-invariant.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lra-assigns.c: Likewise. * lra-constraints.c: Likewise. * lra-eliminations.c: Likewise. * lra-lives.c: Likewise. * lra-remat.c: Likewise. * lra-spills.c: Likewise. * lra.c: Likewise. * lto-cgraph.c: Likewise. * lto-streamer-out.c: Likewise. * postreload-gcse.c: Likewise. * predict.c: Likewise. * profile-count.h: Likewise. * profile.c: Likewise. * recog.c: Likewise. * ree.c: Likewise. * reload.c: Likewise. * reload1.c: Likewise. * reorg.c: Likewise. * resource.c: Likewise. * rtl.def: Likewise. * rtl.h: Likewise. * rtlanal.c: Likewise. * sched-deps.c: Likewise. * sched-ebb.c: Likewise. * sched-rgn.c: Likewise. * sel-sched-ir.c: Likewise. * sel-sched.c: Likewise. * shrink-wrap.c: Likewise. * simplify-rtx.c: Likewise. * symtab.c: Likewise. * target.def: Likewise. * toplev.c: Likewise. * tree-call-cdce.c: Likewise. * tree-cfg.c: Likewise. * tree-complex.c: Likewise. * tree-core.h: Likewise. * tree-eh.c: Likewise. * tree-inline.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-nrv.c: Likewise. * tree-profile.c: Likewise. * tree-sra.c: Likewise. * tree-ssa-alias.c: Likewise. * tree-ssa-dce.c: Likewise. * tree-ssa-dom.c: Likewise. * tree-ssa-forwprop.c: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-phionlycprop.c: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-propagate.c: Likewise. * tree-ssa-threadedge.c: Likewise. * tree-ssa-threadupdate.c: Likewise. * tree-ssa-uninit.c: Likewise. * tree-ssanames.c: Likewise. * tree-streamer-out.c: Likewise. * tree.c: Likewise. * tree.h: Likewise. * vr-values.c: Likewise. gcc/ada/ * exp_ch9.adb: Mechanically replace "can not" with "cannot". * libgnat/s-regpat.ads: Likewise. * par-ch4.adb: Likewise. * set_targ.adb: Likewise. * types.ads: Likewise. gcc/cp/ * cp-tree.h: Mechanically replace "can not" with "cannot". * parser.c: Likewise. * pt.c: Likewise. gcc/fortran/ * class.c: Mechanically replace "can not" with "cannot". * decl.c: Likewise. * expr.c: Likewise. * gfc-internals.texi: Likewise. * intrinsic.texi: Likewise. * invoke.texi: Likewise. * io.c: Likewise. * match.c: Likewise. * parse.c: Likewise. * primary.c: Likewise. * resolve.c: Likewise. * symbol.c: Likewise. * trans-array.c: Likewise. * trans-decl.c: Likewise. * trans-intrinsic.c: Likewise. * trans-stmt.c: Likewise. gcc/go/ * go-backend.c: Mechanically replace "can not" with "cannot". * go-gcc.cc: Likewise. gcc/lto/ * lto-partition.c: Mechanically replace "can not" with "cannot". * lto-symtab.c: Likewise. * lto.c: Likewise. gcc/objc/ * objc-act.c: Mechanically replace "can not" with "cannot". libbacktrace/ * backtrace.h: Mechanically replace "can not" with "cannot". libgcc/ * config/c6x/libunwind.S: Mechanically replace "can not" with "cannot". * config/tilepro/atomic.h: Likewise. * config/vxlib-tls.c: Likewise. * generic-morestack-thread.c: Likewise. * generic-morestack.c: Likewise. * mkmap-symver.awk: Likewise. libgfortran/ * caf/single.c: Mechanically replace "can not" with "cannot". * io/unit.c: Likewise. libobjc/ * class.c: Mechanically replace "can not" with "cannot". * objc/runtime.h: Likewise. * sendmsg.c: Likewise. liboffloadmic/ * include/coi/common/COIResult_common.h: Mechanically replace "can not" with "cannot". * include/coi/source/COIBuffer_source.h: Likewise. libstdc++-v3/ * include/ext/bitmap_allocator.h: Mechanically replace "can not" with "cannot". From-SVN: r267783
2019-01-03PR tree-optimization/88659 - ICE in maybe_warn_nonstring_argMartin Sebor1-1/+1
gcc/ChangeLog: * calls.c (maybe_warn_nonstring_arg): Avoid assuming maxlen is set. gcc/testsuite/ChangeLog: * gcc.dg/Wstringop-truncation-6.c: New test. From-SVN: r267569
2019-01-01gimple-fold.h (get_range_strlen): Update prototype.Martin Sebor1-16/+25
* gimple-fold.h (get_range_strlen): Update prototype. * builtins.c (check_access): Update call to get_range_strlen to use c_strlen_data pointer. Change various variable accesses to instead pull data from the c_strlen_data structure. (check_strncat_sizes, expand_builtin_strncat): Likewise. * calls.c (maybe_warn_nonstring_arg): Likewise. * tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Likewise. Reset minimum length if maximum lengh is unknown. * gimple-ssa-sprintf.c (get_string_length): Likewise. Drop code that used c_strlen, it's no longer needed. Restructure slightly. (format_string): Set unlikely range appropriately. * gimple-fold.c (get_range_strlen): Update comments. Fix minor formatting issues. (get_range_strlen): Accept c_strlen_data pointer for external call sites as well. Pass through to call to internal get_range_strlen. Adjust minlen, maxlen and maxbound as needed. (get_maxval_strlen): Update comments. (gimple_fold_builtin_strlen): Update call to get_range_strlen to use c_strlen_data pointer. Change variable accesses to instead use c_strlen_data data members. * gcc.dg/strlenopt-40.c: Disable a couple tests. * gcc.dg/strlenopt-48.c: Twiddle test. * gcc.dg/strlenopt-59.c: New test. * gcc.dg/tree-ssa/builtin-snprintf-5.c: New test. * g++.dg/init/strlen.C: New test. Co-Authored-By: Jeff Law <law@redhat.com> From-SVN: r267503
2019-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r267494
2018-12-14PR tree-optimization/88372 - alloc_size attribute is ignored on function ↵Martin Sebor1-14/+17
pointers gcc/ChangeLog: PR tree-optimization/88372 * calls.c (maybe_warn_alloc_args_overflow): Handle function pointers. * tree-object-size.c (alloc_object_size): Same. Simplify. * doc/extend.texi (Object Size Checking): Update. (Other Builtins): Add __builtin_object_size. (Common Type Attributes): Add alloc_size. (Common Variable Attributes): Ditto. gcc/testsuite/ChangeLog: PR tree-optimization/88372 * gcc.dg/Walloc-size-larger-than-18.c: New test. * gcc.dg/builtin-object-size-19.c: Same. From-SVN: r267158
2018-12-05re PR c/87028 (false positive -Wstringop-truncation strncpy with global ↵Jeff Law1-3/+12
variable source string) PR c/87028 * calls.c (get_attr_nonstring_decl): Avoid setting *REF to SSA_NAME_VAR. * gcc/gimple-low.c (lower_stmt): Fold builtin calls here. * gimplify (maybe_fold_stmt): Avoid folding builtin calls. PR c/87028 * c-c++-common/Wstringop-truncation.c: Remove xfails. * gcc.dg/Wstringop-truncation-5.c: New test. * gcc.dg/strcmpopt_1.c: Adjust. * gcc.dg/tree-ssa/pr79697.c: Same. From-SVN: r266833
2018-10-17bitmap.c (bitmap_head::dump): New.Aldy Hernandez1-1/+1
* bitmap.c (bitmap_head::dump): New. * bitmap.h (bitmap_head): Add dump(). * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::try_find_new_range): Adjust for value_range API. (evrp_range_analyzer::set_ssa_range_info): Same. (evrp_range_analyzer::record_ranges_from_phis): Same. (evrp_range_analyzer::record_ranges_from_stmt): Same. * gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Same. * gimple-ssa-sprintf.c (get_int_range): Same. (format_integer): Same. (sprintf_dom_walker::handle_gimple_call): Same. * ipa-cp.c (ipcp_vr_lattice::meet_with_1): Same. (ipcp_vr_lattice::top_p): Same. (ipcp_vr_lattice::bottom_p): Same. (ipcp_vr_lattice::set_to_bottom): Same. (ipa_vr_operation_and_type_effects): Same. (propagate_vr_across_jump_function): Same. (ipcp_store_vr_results): Same. * ipa-prop.c (struct ipa_vr_ggc_hash_traits): Same. (ipa_print_node_jump_functions_for_edge): Same. (ipa_get_value_range): Same. (ipa_compute_jump_functions_for_edge): Same. (ipa_write_jump_function): Same. * tree-ssa-dom.c (simplify_stmt_for_jump_threading): Same. * tree-ssa-threadedge.c (record_temporary_equivalences_from_phis): Same. * vr-values.c (set_value_range_to_nonnegative): Same. (set_value_range_to_truthvalue): Same. (vr_values::get_value_range): Same. (vr_values::set_defs_to_varying): Same. (vr_values::update_value_range): Same. (symbolic_range_based_on_p): Same. (vr_values::op_with_boolean_value_range_p): Same. (vr_values::extract_range_for_var_from_comparison_expr): Same. (vr_values::extract_range_from_ssa_name): Same. (vr_values::extract_range_from_binary_expr): Same. (vr_values::extract_range_from_unary_expr): Same. (vr_values::extract_range_from_cond_expr): Same. (vr_values::extract_range_from_comparison): Same. (vr_values::check_for_binary_op_overflow): Same. (vr_values::extract_range_basic): Same. (vr_values::extract_range_from_assignment): Same. (compare_ranges): Same. (compare_range_with_value): Same. (vr_values::adjust_range_with_scev): Same. (vrp_valueize): Same. (vrp_valueize_1): Same. (vr_values::get_vr_for_comparison): Same. (vr_values::compare_name_with_value): Same. (vr_values::compare_names): Same. (vr_values::vrp_evaluate_conditional): Same. (find_case_label_ranges): Same. (vr_values::vrp_visit_switch_stmt): Same. (vr_values::extract_range_from_phi_node): Same. (vr_values::simplify_div_or_mod_using_ranges): Same. (vr_values::simplify_bit_ops_using_ranges): Same. (test_for_singularity): Same. (range_fits_type_p): Same. (vr_values::simplify_cond_using_ranges_1): Same. (vr_values::simplify_switch_using_ranges): Same. (vr_values::simplify_float_conversion_using_ranges): Same. (vr_values::two_valued_val_range_p): Same. (vr_values::add_equivalence): Move to value_range::equiv_add. * vr-values.h (vr_values::add_equivalence): Remove. (VR_INITIALIZER): Remove. * tree-vrp.c (value_range::set): New. (value_range::equiv_add): New. (value_range::value_range): New. (value_range::deep_copy): New. (value_range::check): New. (value_range::equal_p): New. (value_range::ignore_equivs_equal_p): New. (value_range::operator==): New. (value_range::operator!=): New. (value_range::symbolic_p): New. (value_range::numeric_p): New. (value_range::set_undefined): New. (value_range::set_varying): New. (value_range::may_contain_p): New. (value_range::equiv_clear): New. (value_range::singleton_p): New. (value_range::intersect): New. (value_range::dump): New. (value_range::set_and_canonicalize): New. (set_value_range): Adjust for value_range API. (set_value_range_to_undefined): Same. (set_value_range_to_varying): Same. (set_and_canonicalize_value_range): Same. (set_value_range_to_nonnull): Same. (set_value_range_to_null): Same. (range_is_null): Same. (range_is_nonnull): Same. (range_int_cst_p): Same. (range_int_cst_singleton_p): Same. (symbolic_range_p): Same. (range_includes_zero_p): Same. (value_range_constant_singleton): Same. (vrp_set_zero_nonzero_bits): Same. (ranges_from_anti_range): Same. (extract_range_into_wide_ints): Same. (extract_range_from_multiplicative_op): Same. (set_value_range_with_overflow): Same. (extract_range_from_binary_expr_1): Same. (extract_range_from_unary_expr): Same. (dump_value_range): Same. (debug_value_range): Same. (vrp_prop::check_array_ref): Same. (vrp_prop::check_mem_ref): Same. (vrp_prop::vrp_initialize): Same. (vrp_prop::visit_stmt): Same. (intersect_ranges): Same. (vrp_prop::visit_phi): Same. (vrp_prop::vrp_finalize): Same. (determine_value_range_1): Same. (determine_value_range): Same. (vrp_intersect_ranges_1): Rename to... (vrp_intersect_1): this. (vrp_intersect_ranges): Rename to... (value_range::intersect_helper): ...this. (vrp_meet_1): Rename to... (value_range::union_helper): ...this. (vrp_meet): Rename to... (value_range::union_): ...this. (copy_value_range): Remove. * tree-vrp.h (struct value_range): Rewrite into a proper class. (value_range::vrtype): New. (value_range::type): New. (value_range::equiv): New. (value_range::min): New. (value_range::max): New. (value_range::varying_p): New. (value_range::undefined_p): New. (value_range::null_p): New. (value_range::equiv_add): New. (copy_value_range): Remove. From-SVN: r265241
2018-09-28calls.c (expand_call): Try to do a tail call for thunks at -O0 too.Eric Botcazou1-2/+1
* calls.c (expand_call): Try to do a tail call for thunks at -O0 too. * cgraph.h (struct cgraph_thunk_info): Add indirect_offset. (cgraph_node::create_thunk): Add indirect_offset parameter. (thunk_adjust): Likewise. * cgraph.c (cgraph_node::create_thunk): Add indirect_offset parameter and initialize the corresponding field with it. (cgraph_node::dump): Dump indirect_offset field. * cgraphclones.c (duplicate_thunk_for_node): Deal with indirect_offset. * cgraphunit.c (cgraph_node::analyze): Be prepared for external thunks. (thunk_adjust): Add indirect_offset parameter and deal with it. (cgraph_node::expand_thunk): Deal with the indirect_offset field and pass it to thunk_adjust. Do not call the target hook if it's non-zero or if the thunk is external or local. Fix formatting. Do not chain the RESULT_DECL to BLOCK_VARS. Pass the static chain to the target, if any, in the GIMPLE representation. * ipa-icf.c (sem_function::equals_wpa): Deal with indirect_offset. * lto-cgraph.c (lto_output_node): Write indirect_offset field. (input_node): Read indirect_offset field. * tree-inline.c (expand_call_inline): Pass indirect_offset field in the call to thunk_adjust. * tree-nested.c (struct nesting_info): Add thunk_p field. (create_nesting_tree): Set it. (convert_all_function_calls): Copy static chain from targets to thunks. (finalize_nesting_tree_1): Return early for thunks. (unnest_nesting_tree_1): Do not finalize thunks. (gimplify_all_functions): Do not gimplify thunks. cp/ * method.c (use_thunk): Adjust call to cgraph_node::create_thunk. ada/ * gcc-interface/decl.c (is_cplusplus_method): Do not require C++ convention on Interfaces. * gcc-interface/trans.c (Subprogram_Body_to_gnu): Try to create a bona-fide thunk and hand it over to the middle-end. (get_controlling_type): New function. (use_alias_for_thunk_p): Likewise. (thunk_labelno): New static variable. (make_covariant_thunk): New function. (maybe_make_gnu_thunk): Likewise. * gcc-interface/utils.c (finish_subprog_decl): Set DECL_CONTEXT of the result DECL here instead of... (end_subprog_body): ...here. Co-Authored-By: Pierre-Marie de Rodat <derodat@adacore.com> From-SVN: r264701
2018-08-28PR middle-end/86631 - missing -Walloc-size-larger-than on ILP32 hostsMartin Sebor1-2/+5
gcc/ChangeLog: PR middle-end/86631 * calls.c (alloc_max_size): Treat HOST_WIDE_INT special. * gimple-ssa-warn-alloca.c (adjusted_warn_limit): New function. (pass_walloca::gate): Use it. (alloca_call_type): Same. (pass_walloca::execute): Same. * stor-layout.c (layout_decl): Treat HOST_WIDE_INT special. gcc/testsuite/ChangeLog: PR middle-end/86631 * g++.dg/Walloca1.C: Adjust. From-SVN: r263928