From cb3874dcf82bc80c2552ef62f57cf08c28fc686a Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 10 Aug 2020 11:11:05 +0200 Subject: vec: add exact argument for various grow functions. 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. --- gcc/ada/gcc-interface/trans.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index f74e0e7..e3d71bc 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -624,7 +624,7 @@ gigi (Node_Id gnat_root, constructor_elt *elt; fdesc_type_node = make_node (RECORD_TYPE); - vec_safe_grow (null_vec, TARGET_VTABLE_USES_DESCRIPTORS); + vec_safe_grow (null_vec, TARGET_VTABLE_USES_DESCRIPTORS, true); elt = (null_vec->address () + TARGET_VTABLE_USES_DESCRIPTORS - 1); for (j = 0; j < TARGET_VTABLE_USES_DESCRIPTORS; j++) @@ -1747,7 +1747,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) gnu_result = build1 (INDIRECT_REF, gnu_result_type, gnu_result); } - vec_safe_grow (gnu_vec, TARGET_VTABLE_USES_DESCRIPTORS); + vec_safe_grow (gnu_vec, TARGET_VTABLE_USES_DESCRIPTORS, true); elt = (gnu_vec->address () + TARGET_VTABLE_USES_DESCRIPTORS - 1); for (gnu_field = TYPE_FIELDS (gnu_result_type), i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; -- cgit v1.1 From 66a204a6567385638f633732bb61e2ac26b2eb02 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 10 Sep 2020 13:26:31 +0200 Subject: Add emergency dump after an ICE This is only for internal debugging purposes. gcc/ada/ChangeLog: * gcc-interface/misc.c: Include tree-pass.h. (internal_error_function): Call emergency_dump_function. --- gcc/ada/gcc-interface/misc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 3999f9c..183daf3 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -35,6 +35,7 @@ #include "stor-layout.h" #include "print-tree.h" #include "toplev.h" +#include "tree-pass.h" #include "langhooks.h" #include "langhooks-def.h" #include "plugin.h" @@ -307,6 +308,9 @@ internal_error_function (diagnostic_context *context, const char *msgid, /* Warn if plugins present. */ warn_if_plugins (); + /* Dump the representation of the function. */ + emergency_dump_function (); + /* Reset the pretty-printer. */ pp_clear_output_area (context->printer); -- cgit v1.1 From 71465223b95af43951c423ad77391e706f02901d Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 10 Sep 2020 17:47:32 +0200 Subject: Fix uninitialized variable with nested variant record types This fixes a wrong code issue with nested variant record types: the compiler generates move instructions that depend on an uninitialized variable, which was initially a SAVE_EXPR not instantiated early enough. gcc/ada/ChangeLog: * gcc-interface/decl.c (build_subst_list): For a definition, make sure to instantiate the SAVE_EXPRs generated by the elaboration of the constraints in front of the elaboration of the type itself. gcc/testsuite/ChangeLog: * gnat.dg/discr59.adb: New test. * gnat.dg/discr59_pkg1.ads: New helper. * gnat.dg/discr59_pkg2.ads: Likewise. --- gcc/ada/gcc-interface/decl.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 025714b..f85b2b5 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -8849,11 +8849,15 @@ build_subst_list (Entity_Id gnat_subtype, Entity_Id gnat_type, bool definition) if (!Is_Access_Type (Etype (Node (gnat_constr)))) { tree gnu_field = gnat_to_gnu_field_decl (gnat_discrim); - tree replacement = convert (TREE_TYPE (gnu_field), - elaborate_expression - (Node (gnat_constr), gnat_subtype, - get_entity_char (gnat_discrim), - definition, true, false)); + tree replacement + = elaborate_expression (Node (gnat_constr), gnat_subtype, + get_entity_char (gnat_discrim), + definition, true, false); + /* If this is a definition, we need to make sure that the SAVE_EXPRs + are instantiated on every possibly path in size computations. */ + if (definition && TREE_CODE (replacement) == SAVE_EXPR) + add_stmt (replacement); + replacement = convert (TREE_TYPE (gnu_field), replacement); subst_pair s = { gnu_field, replacement }; gnu_list.safe_push (s); } -- cgit v1.1 From e63eb26d22dbbbbb67f7f240ea5a7234cd2498cb Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 10 Sep 2020 17:59:11 +0200 Subject: Fix bogus error on Value_Size clause for variant record type This is a regression present on the mainline and 10 branch: the compiler rejects a Value_Size clause on a discriminated record type with variant. gcc/ada/ChangeLog: * gcc-interface/decl.c (set_rm_size): Do not take into account the Value_Size clause if it is not for the entity itself. gcc/testsuite/ChangeLog: * gnat.dg/specs/size_clause5.ads: New test. --- gcc/ada/gcc-interface/decl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index f85b2b5..8045fa5 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -9083,10 +9083,12 @@ set_rm_size (Uint uint_size, tree gnu_type, Entity_Id gnat_entity) if (uint_size == No_Uint) return; - /* Only issue an error if a Value_Size clause was explicitly given. - Otherwise, we'd be duplicating an error on the Size clause. */ + /* Only issue an error if a Value_Size clause was explicitly given for the + entity; otherwise, we'd be duplicating an error on the Size clause. */ gnat_attr_node = Get_Attribute_Definition_Clause (gnat_entity, Attr_Value_Size); + if (Present (gnat_attr_node) && Entity (gnat_attr_node) != gnat_entity) + gnat_attr_node = Empty; /* Get the size as an INTEGER_CST. Issue an error if a size was specified but cannot be represented in bitsizetype. */ -- cgit v1.1 From 7c919c12be147c72e5d7ef2f9436adadcf2c2f24 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 11 Sep 2020 10:41:28 +0200 Subject: Fix crash on array component with nonstandard index type This is a regression present on mainline, 10 and 9 branches: the compiler goes into an infinite recursion eventually exhausting the stack for the declaration of a discriminated record type with an array component having a discriminant as bound and an index type that is an enumeration type with a non-standard representation clause. gcc/ada/ChangeLog: * gcc-interface/decl.c (gnat_to_gnu_entity) : Only create extra subtypes for discriminants if the RM size of the base type of the index type is lower than that of the index type. gcc/testsuite/ChangeLog: * gnat.dg/specs/discr7.ads: New test. --- gcc/ada/gcc-interface/decl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 8045fa5..2b7392c 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -2480,8 +2480,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) tree gnu_base_orig_max = TYPE_MAX_VALUE (gnu_base_index_type); tree gnu_min, gnu_max, gnu_high; - /* We try to define subtypes for discriminants used as bounds - that are more restrictive than those declared by using the + /* We try to create subtypes for discriminants used as bounds + that are more restrictive than those declared, by using the bounds of the index type of the base array type. This will make it possible to calculate the maximum size of the record type more conservatively. This may have already been done by @@ -2489,8 +2489,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) there will be a conversion that needs to be removed first. */ if (CONTAINS_PLACEHOLDER_P (gnu_orig_min) && TYPE_RM_SIZE (gnu_base_index_type) - && !tree_int_cst_lt (TYPE_RM_SIZE (gnu_index_type), - TYPE_RM_SIZE (gnu_base_index_type))) + && tree_int_cst_lt (TYPE_RM_SIZE (gnu_base_index_type), + TYPE_RM_SIZE (gnu_index_type))) { gnu_orig_min = remove_conversions (gnu_orig_min, false); TREE_TYPE (gnu_orig_min) @@ -2501,8 +2501,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) if (CONTAINS_PLACEHOLDER_P (gnu_orig_max) && TYPE_RM_SIZE (gnu_base_index_type) - && !tree_int_cst_lt (TYPE_RM_SIZE (gnu_index_type), - TYPE_RM_SIZE (gnu_base_index_type))) + && tree_int_cst_lt (TYPE_RM_SIZE (gnu_base_index_type), + TYPE_RM_SIZE (gnu_index_type))) { gnu_orig_max = remove_conversions (gnu_orig_max, false); TREE_TYPE (gnu_orig_max) -- cgit v1.1 From 230e0dbdcbb55c5ec3cbb236db4302cd18a1a01d Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 11 Sep 2020 10:54:11 +0200 Subject: Drop GNAT encodings for fixed-point types GDB can now deal with the DWARF representation just fine. gcc/ada/ChangeLog: * gcc-interface/misc.c (gnat_get_fixed_point_type): Bail out only when the GNAT encodings are specifically used. --- gcc/ada/gcc-interface/misc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 183daf3..e6a563e 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -618,10 +618,9 @@ gnat_get_fixed_point_type_info (const_tree type, { tree scale_factor; - /* GDB cannot handle fixed-point types yet, so rely on GNAT encodings - instead for it. */ + /* Do nothing if the GNAT encodings are used. */ if (!TYPE_IS_FIXED_POINT_P (type) - || gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL) + || gnat_encodings == DWARF_GNAT_ENCODINGS_ALL) return false; scale_factor = TYPE_SCALE_FACTOR (type); -- cgit v1.1 From b5ffd55a61df01d226f3fa4260f108bda8565c16 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 11 Sep 2020 11:13:54 +0200 Subject: Add missing stride entry in debug info This adds a missing stride entry for bit-packed arrays of record types. gcc/ada/ChangeLog: * gcc-interface/misc.c (get_array_bit_stride): Return TYPE_ADA_SIZE for record and union types. --- gcc/ada/gcc-interface/misc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index e6a563e..781868e 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -1003,6 +1003,10 @@ get_array_bit_stride (tree comp_type) if (INTEGRAL_TYPE_P (comp_type)) return TYPE_RM_SIZE (comp_type); + /* Likewise for record or union types. */ + if (RECORD_OR_UNION_TYPE_P (comp_type) && !TYPE_FAT_POINTER_P (comp_type)) + return TYPE_ADA_SIZE (comp_type); + /* The gnat_get_array_descr_info debug hook expects a debug tyoe. */ comp_type = maybe_debug_type (comp_type); -- cgit v1.1 From ef4ab841d94a4f6ec975c9653c69faeeb85c78e8 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 11 Sep 2020 11:14:49 +0200 Subject: Fix ICE on nested packed variant record type This is a regression present on the mainline and 10 branch: the compiler aborts on code accessing a component of a packed record type whose type is a packed discriminated record type with variant part. gcc/ada/ChangeLog: * gcc-interface/utils.c (type_has_variable_size): New function. (create_field_decl): In the packed case, also force byte alignment when the type of the field has variable size. gcc/testsuite/ChangeLog: * gnat.dg/pack27.adb: New test. * gnat.dg/pack27_pkg.ads: New helper. --- gcc/ada/gcc-interface/utils.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index a96fde6..3065fcb 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -2905,6 +2905,31 @@ aggregate_type_contains_array_p (tree type, bool self_referential) } } +/* Return true if TYPE is a type with variable size or a padding type with a + field of variable size or a record that has a field with such a type. */ + +static bool +type_has_variable_size (tree type) +{ + tree field; + + if (!TREE_CONSTANT (TYPE_SIZE (type))) + return true; + + if (TYPE_IS_PADDING_P (type) + && !TREE_CONSTANT (DECL_SIZE (TYPE_FIELDS (type)))) + return true; + + if (!RECORD_OR_UNION_TYPE_P (type)) + return false; + + for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) + if (type_has_variable_size (TREE_TYPE (field))) + return true; + + return false; +} + /* Return a FIELD_DECL node. NAME is the field's name, TYPE is its type and RECORD_TYPE is the type of the enclosing record. If SIZE is nonzero, it is the specified size of the field. If POS is nonzero, it is the bit @@ -2974,13 +2999,15 @@ create_field_decl (tree name, tree type, tree record_type, tree size, tree pos, DECL_PACKED (field_decl) = pos ? DECL_BIT_FIELD (field_decl) : packed; - /* If FIELD_TYPE is BLKmode, we must ensure this is aligned to at least a - byte boundary since GCC cannot handle less-aligned BLKmode bitfields. + /* If FIELD_TYPE has BLKmode, we must ensure this is aligned to at least + a byte boundary since GCC cannot handle less aligned BLKmode bitfields. + Likewise if it has a variable size and no specified position because + variable-sized objects need to be aligned to at least a byte boundary. Likewise for an aggregate without specified position that contains an - array, because in this case slices of variable length of this array - must be handled by GCC and variable-sized objects need to be aligned - to at least a byte boundary. */ + array because, in this case, slices of variable length of this array + must be handled by GCC and have variable size. */ if (packed && (TYPE_MODE (type) == BLKmode + || (!pos && type_has_variable_size (type)) || (!pos && AGGREGATE_TYPE_P (type) && aggregate_type_contains_array_p (type, false)))) -- cgit v1.1 From 4965be0b3388557643114c1ec20bd206f0bda1df Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 12 Sep 2020 12:36:30 +0200 Subject: Accept absolute address clause for array of UNC nominal subtype This changes the compiler to accept again absolute address clause for aliased array of unconstrained nominal subtype, instead of erroring out in this case. gcc/ada/ChangeLog: * gcc-interface/decl.c (gnat_to_gnu_entity) : Only give a warning for the overlay of an aliased array with an unconstrained nominal subtype if the address is absolute. --- gcc/ada/gcc-interface/decl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 2b7392c..d19f5aa 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -1245,6 +1245,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) if (TREE_CODE (gnu_address) == POINTER_PLUS_EXPR && TREE_OPERAND (gnu_address, 1) == off) gnu_address = TREE_OPERAND (gnu_address, 0); + /* This is the pattern built for an overaligned object. */ else if (TREE_CODE (gnu_address) == POINTER_PLUS_EXPR && TREE_CODE (TREE_OPERAND (gnu_address, 1)) @@ -1255,6 +1256,18 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) = build2 (POINTER_PLUS_EXPR, gnu_type, TREE_OPERAND (gnu_address, 0), TREE_OPERAND (TREE_OPERAND (gnu_address, 1), 0)); + + /* We make an exception for an absolute address but we warn + that there is a descriptor at the start of the object. */ + else if (TREE_CODE (gnu_address) == INTEGER_CST) + { + post_error_ne ("??aliased object& with unconstrained " + "array nominal subtype", gnat_clause, + gnat_entity); + post_error ("\\starts with a descriptor whose size is " + "given by ''Descriptor_Size", gnat_clause); + } + else { post_error_ne ("aliased object& with unconstrained array " -- cgit v1.1 From b440715089382938b9729d20f5dcaf646e6372fd Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 12 Sep 2020 12:42:06 +0200 Subject: Minor tweak to line debug info This prevents the SLOC of the expression for a tag from being present in the line debug info every time it is referenced for coverage purposes. gcc/ada/ChangeLog: * gcc-interface/trans.c (gnat_to_gnu) : Clear the SLOC of the expression of a tag. --- gcc/ada/gcc-interface/trans.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index e3d71bc..aa4393c 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -6476,6 +6476,7 @@ gnat_to_gnu (Node_Id gnat_node) gnu_expr = gnat_to_gnu (Expression (gnat_node)); + /* First deal with erroneous expressions. */ if (TREE_CODE (gnu_expr) == ERROR_MARK) { /* If this is a named number for which we cannot manipulate @@ -6485,6 +6486,11 @@ gnat_to_gnu (Node_Id gnat_node) else if (type_annotate_only) gnu_expr = NULL_TREE; } + + /* Then a special case: we do not want the SLOC of the expression + of the tag to pop up every time it is referenced somewhere. */ + else if (EXPR_P (gnu_expr) && Is_Tag (gnat_temp)) + SET_EXPR_LOCATION (gnu_expr, UNKNOWN_LOCATION); } else gnu_expr = NULL_TREE; -- cgit v1.1 From fe47e8163928d2cc42ad84634cfd147f948aad4a Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 12 Sep 2020 12:47:39 +0200 Subject: Fix small inconsistency in new predicate This can result on the mainline in a segfault when an object declared at library level is used in the declaration of another, local object. gcc/ada/ChangeLog: * gcc-interface/trans.c (lvalue_for_aggr_p) : Return false unconditionally. --- gcc/ada/gcc-interface/trans.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index aa4393c..39d4d28 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -968,12 +968,8 @@ lvalue_for_aggregate_p (Node_Id gnat_node, tree gnu_type) get_unpadded_type (Etype (gnat_parent))); case N_Object_Declaration: - /* For an aggregate object declaration, return the constant at top level - in order to avoid generating elaboration code. */ - if (global_bindings_p ()) - return false; - - /* ... fall through ... */ + /* For an aggregate object declaration, return false consistently. */ + return false; case N_Assignment_Statement: /* For an aggregate assignment, decide based on the size. */ -- cgit v1.1 From f2d9f95e9ccac1376aee73345b8b4a00e803d67d Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 12 Sep 2020 12:59:09 +0200 Subject: Add preliminary support for 128-bit integer types This is only the gigi part, in preparation for the bulk of the implementation. gcc/ada/ChangeLog: * fe.h: Fix pilot error in previous change. * gcc-interface/gigi.h (enum standard_datatypes): Add ADT_mulv128_decl. (mulv128_decl): New macro. (get_target_long_long_long_size): Declare. * gcc-interface/decl.c (gnat_to_gnu_entity): Use a maximum size of 128 bits for discrete types if Enable_128bit_Types is true. * gcc-interface/targtyps.c: Include target.h. (get_target_long_long_long_size): New function. * gcc-interface/trans.c (gigi): Initialize mulv128_decl if need be. (build_binary_op_trapv): Call it for 128-bit multiplication. * gcc-interface/utils.c (make_type_from_size): Enforce a maximum size of 128 bits if Enable_128bit_Types is true. --- gcc/ada/gcc-interface/decl.c | 2 +- gcc/ada/gcc-interface/gigi.h | 5 +++++ gcc/ada/gcc-interface/targtyps.c | 10 ++++++++++ gcc/ada/gcc-interface/trans.c | 22 ++++++++++++++++++++++ gcc/ada/gcc-interface/utils.c | 2 +- 5 files changed, 39 insertions(+), 2 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index d19f5aa..c9c2a95 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -524,7 +524,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) else if (IN (kind, Access_Kind)) max_esize = POINTER_SIZE * 2; else - max_esize = LONG_LONG_TYPE_SIZE; + max_esize = Enable_128bit_Types ? 128 : LONG_LONG_TYPE_SIZE; if (esize > max_esize) esize = max_esize; diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index e43b3db..355178e 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -390,6 +390,9 @@ enum standard_datatypes /* Function decl node for 64-bit multiplication with overflow checking. */ ADT_mulv64_decl, + /* Function decl node for 128-bit multiplication with overflow checking. */ + ADT_mulv128_decl, + /* Identifier for the name of the _Parent field in tagged record types. */ ADT_parent_name_id, @@ -462,6 +465,7 @@ extern GTY(()) tree gnat_raise_decls_ext[(int) LAST_REASON_CODE + 1]; #define free_decl gnat_std_decls[(int) ADT_free_decl] #define realloc_decl gnat_std_decls[(int) ADT_realloc_decl] #define mulv64_decl gnat_std_decls[(int) ADT_mulv64_decl] +#define mulv128_decl gnat_std_decls[(int) ADT_mulv128_decl] #define parent_name_id gnat_std_decls[(int) ADT_parent_name_id] #define exception_data_name_id gnat_std_decls[(int) ADT_exception_data_name_id] #define jmpbuf_type gnat_std_decls[(int) ADT_jmpbuf_type] @@ -1035,6 +1039,7 @@ extern Pos get_target_short_size (void); extern Pos get_target_int_size (void); extern Pos get_target_long_size (void); extern Pos get_target_long_long_size (void); +extern Pos get_target_long_long_long_size (void); extern Pos get_target_pointer_size (void); extern Pos get_target_maximum_default_alignment (void); extern Pos get_target_system_allocator_alignment (void); diff --git a/gcc/ada/gcc-interface/targtyps.c b/gcc/ada/gcc-interface/targtyps.c index 9b2d241..60a37e1 100644 --- a/gcc/ada/gcc-interface/targtyps.c +++ b/gcc/ada/gcc-interface/targtyps.c @@ -29,6 +29,7 @@ #include "system.h" #include "coretypes.h" #include "tm.h" +#include "target.h" #include "tree.h" #include "ada.h" @@ -95,6 +96,15 @@ get_target_long_long_size (void) } Pos +get_target_long_long_long_size (void) +{ + if (targetm.scalar_mode_supported_p (TImode)) + return GET_MODE_BITSIZE (TImode); + else + return LONG_LONG_TYPE_SIZE; +} + +Pos get_target_pointer_size (void) { return POINTER_SIZE; diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 39d4d28..9be1295 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -439,6 +439,19 @@ gigi (Node_Id gnat_root, NULL_TREE, is_default, true, true, true, false, false, NULL, Empty); + if (Enable_128bit_Types) + { + tree int128_type = gnat_type_for_size (128, 0); + mulv128_decl + = create_subprog_decl (get_identifier ("__gnat_mulv128"), NULL_TREE, + build_function_type_list (int128_type, + int128_type, + int128_type, + NULL_TREE), + NULL_TREE, is_default, true, true, true, false, + false, NULL, Empty); + } + /* Name of the _Parent field in tagged record types. */ parent_name_id = get_identifier (Get_Name_String (Name_uParent)); @@ -9388,6 +9401,15 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left, convert (int64, rhs))); } + /* Likewise for a 128-bit mult and a 64-bit target. */ + else if (code == MULT_EXPR && precision == 128 && BITS_PER_WORD < 128) + { + tree int128 = gnat_type_for_size (128, 0); + return convert (gnu_type, build_call_n_expr (mulv128_decl, 2, + convert (int128, lhs), + convert (int128, rhs))); + } + enum internal_fn icode; switch (code) diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 3065fcb..048a0cf 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -1343,7 +1343,7 @@ make_type_from_size (tree type, tree size_tree, bool for_biased) not already have the proper size and the size is not too large. */ if (BIT_PACKED_ARRAY_TYPE_P (type) || (TYPE_PRECISION (type) == size && biased_p == for_biased) - || size > LONG_LONG_TYPE_SIZE) + || size > (Enable_128bit_Types ? 128 : LONG_LONG_TYPE_SIZE)) break; biased_p |= for_biased; -- cgit v1.1 From ba948b37768c99cd8eb9f5b6fbd45fcf4bd15b78 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 14 Sep 2020 09:04:45 +0200 Subject: options: Save and restore opts_set for Optimization and Target options > Seems a latent issue. > Neither cl_optimization_{save,restore} nor cl_target_option_{save,restore} > (nor any of the target hooks they call) saves or restores any opts_set > values, so I think opts_set can be trusted only during option processing (if > at all), but not later. > So, short term a fix would be IMHO just stop using opts_set altogether in > arm_configure_build_target, it doesn't make much sense to me, it should test > if those strings are non-NULL instead, or at least do that when it is > invoked from arm_option_restore (e.g. could be done by calling it with > opts instead of &global_options_set ). > Longer term, the question is if cl_optimization_{save,restore} and > cl_target_option_{save,restore} shouldn't be changed not to only > save/restore the options, but also save the opts_set flags. > It could be done e.g. by adding a bool array or set of bool members > to struct cl_optimization and struct cl_target_option , or even more compact > by using bitmasks, pack each 64 adjacent option flags into a UHWI element > of an array. So, I've tried under debugger how it behaves and seems global_options_set is really an or of whether an option has been ever seen as explicit, either on the command line or in any of the option pragmas or optimize/target attributes seen so far, so it isn't something that can be relied on. The following patch implements the saving/restoring of the opts_set bits (though only for the options/variables saved by the generic options-save.c code, for the target specific stuff that isn't handled by the generic code the opts_set argument is now passed to the hook and the backends can choose e.g. to use a TargetSave variable to save the flags either individually or together in some bitmask (or ignore it if they never need opts_set for the options). This patch itself doesn't fix the testcase failing on arm, but a follow up patch will. 2020-09-14 Jakub Jelinek gcc/ * opt-read.awk: Also initialize extra_target_var_types array. * opth-gen.awk: Emit explicit_mask arrays to struct cl_optimization and cl_target_option. Adjust cl_optimization_save, cl_optimization_restore, cl_target_option_save and cl_target_option_restore declarations. * optc-save-gen.awk: Add opts_set argument to cl_optimization_save, cl_optimization_restore, cl_target_option_save and cl_target_option_restore functions and save or restore opts_set next to the opts values into or from explicit_mask arrays. In cl_target_option_eq and cl_optimization_option_eq compare explicit_mask arrays, in cl_target_option_hash and cl_optimization_hash hash them and in cl_target_option_stream_out, cl_target_option_stream_in, cl_optimization_stream_out and cl_optimization_stream_in stream them. * tree.h (build_optimization_node, build_target_option_node): Add opts_set argument. * tree.c (build_optimization_node): Add opts_set argument, pass it to cl_optimization_save. (build_target_option_node): Add opts_set argument, pass it to cl_target_option_save. * function.c (invoke_set_current_function_hook): Adjust cl_optimization_restore caller. * ipa-inline-transform.c (inline_call): Adjust cl_optimization_restore and build_optimization_node callers. * target.def (TARGET_OPTION_SAVE, TARGET_OPTION_RESTORE): Add opts_set argument. * target-globals.c (save_target_globals_default_opts): Adjust cl_optimization_restore callers. * toplev.c (process_options): Adjust build_optimization_node and cl_optimization_restore callers. (target_reinit): Adjust cl_optimization_restore caller. * tree-streamer-in.c (lto_input_ts_function_decl_tree_pointers): Adjust build_optimization_node and cl_optimization_restore callers. * doc/tm.texi: Updated. * config/aarch64/aarch64.c (aarch64_override_options): Adjust build_target_option_node caller. (aarch64_option_save, aarch64_option_restore): Add opts_set argument. (aarch64_set_current_function): Adjust cl_target_option_restore caller. (aarch64_option_valid_attribute_p): Adjust cl_target_option_save, cl_target_option_restore, cl_optimization_restore, build_optimization_node and build_target_option_node callers. * config/aarch64/aarch64-c.c (aarch64_pragma_target_parse): Adjust cl_target_option_restore and build_target_option_node callers. * config/arm/arm.c (arm_option_save, arm_option_restore): Add opts_set argument. (arm_option_override): Adjust cl_target_option_save, build_optimization_node and build_target_option_node callers. (arm_set_current_function): Adjust cl_target_option_restore caller. (arm_valid_target_attribute_tree): Adjust build_target_option_node caller. (add_attribute): Formatting fix. (arm_valid_target_attribute_p): Adjust cl_optimization_restore, cl_target_option_restore, arm_valid_target_attribute_tree and build_optimization_node callers. * config/arm/arm-c.c (arm_pragma_target_parse): Adjust cl_target_option_restore callers. * config/csky/csky.c (csky_option_override): Adjust build_target_option_node and cl_target_option_save callers. * config/gcn/gcn.c (gcn_fixup_accel_lto_options): Adjust build_optimization_node and cl_optimization_restore callers. * config/i386/i386-builtins.c (get_builtin_code_for_version): Adjust cl_target_option_save and cl_target_option_restore callers. * config/i386/i386-c.c (ix86_pragma_target_parse): Adjust build_target_option_node and cl_target_option_restore callers. * config/i386/i386-options.c (ix86_function_specific_save, ix86_function_specific_restore): Add opts_set arguments. (ix86_valid_target_attribute_tree): Adjust build_target_option_node caller. (ix86_valid_target_attribute_p): Adjust build_optimization_node, cl_optimization_restore, cl_target_option_restore, ix86_valid_target_attribute_tree and build_optimization_node callers. (ix86_option_override_internal): Adjust build_target_option_node caller. (ix86_reset_previous_fndecl, ix86_set_current_function): Adjust cl_target_option_restore callers. * config/i386/i386-options.h (ix86_function_specific_save, ix86_function_specific_restore): Add opts_set argument. * config/nios2/nios2.c (nios2_option_override): Adjust build_target_option_node caller. (nios2_option_save, nios2_option_restore): Add opts_set argument. (nios2_valid_target_attribute_tree): Adjust build_target_option_node caller. (nios2_valid_target_attribute_p): Adjust build_optimization_node, cl_optimization_restore, cl_target_option_save and cl_target_option_restore callers. (nios2_set_current_function, nios2_pragma_target_parse): Adjust cl_target_option_restore callers. * config/pru/pru.c (pru_option_override): Adjust build_target_option_node caller. (pru_set_current_function): Adjust cl_target_option_restore callers. * config/rs6000/rs6000.c (rs6000_debug_reg_global): Adjust cl_target_option_save caller. (rs6000_option_override_internal): Adjust build_target_option_node caller. (rs6000_valid_attribute_p): Adjust build_optimization_node, cl_optimization_restore, cl_target_option_save, cl_target_option_restore and build_target_option_node callers. (rs6000_pragma_target_parse): Adjust cl_target_option_restore and build_target_option_node callers. (rs6000_activate_target_options): Adjust cl_target_option_restore callers. (rs6000_function_specific_save, rs6000_function_specific_restore): Add opts_set argument. * config/s390/s390.c (s390_function_specific_restore): Likewise. (s390_option_override_internal): Adjust s390_function_specific_restore caller. (s390_option_override, s390_valid_target_attribute_tree): Adjust build_target_option_node caller. (s390_valid_target_attribute_p): Adjust build_optimization_node, cl_optimization_restore and cl_target_option_restore callers. (s390_activate_target_options): Adjust cl_target_option_restore caller. * config/s390/s390-c.c (s390_cpu_cpp_builtins): Adjust cl_target_option_save caller. (s390_pragma_target_parse): Adjust build_target_option_node and cl_target_option_restore callers. gcc/c-family/ * c-attribs.c (handle_optimize_attribute): Adjust cl_optimization_save, cl_optimization_restore and build_optimization_node callers. * c-pragma.c (handle_pragma_optimize): Adjust build_optimization_node caller. (handle_pragma_push_options): Adjust build_optimization_node and build_target_option_node callers. (handle_pragma_pop_options, handle_pragma_reset_options): Adjust cl_optimization_restore callers. gcc/go/ * go-gcc.cc (Gcc_backend::function): Adjust cl_optimization_save, cl_optimization_restore and build_optimization_node callers. gcc/ada/ * gcc-interface/trans.c (gigi): Adjust build_optimization_node caller. --- gcc/ada/gcc-interface/trans.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 9be1295..3491451 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -691,7 +691,8 @@ gigi (Node_Id gnat_root, /* Save the current optimization options again after the above possible global_options changes. */ - optimization_default_node = build_optimization_node (&global_options); + optimization_default_node + = build_optimization_node (&global_options, &global_options_set); optimization_current_node = optimization_default_node; /* Now translate the compilation unit proper. */ -- cgit v1.1 From 88795e14ae7143bd8039af68d2d876ae34568799 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 28 Sep 2020 09:00:46 +0200 Subject: Fix bogus alignment warning on address clause The compiler gives a bogus alignment warning on an address clause and a discriminated record type with variable size. gcc/ada/ChangeLog: * gcc-interface/decl.c (maybe_saturate_size): Add ALIGN parameter and round down the result to ALIGN. (gnat_to_gnu_entity): Adjust calls to maybe_saturate_size. gcc/testsuite/ChangeLog: * gnat.dg/addr16.adb: New test. * gnat.dg/addr16_pkg.ads: New helper. --- gcc/ada/gcc-interface/decl.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index c9c2a95..cd0a50b 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -232,7 +232,7 @@ static tree build_position_list (tree, bool, tree, tree, unsigned int, tree); static vec build_subst_list (Entity_Id, Entity_Id, bool); static vec build_variant_list (tree, Node_Id, vec, vec); -static tree maybe_saturate_size (tree); +static tree maybe_saturate_size (tree, unsigned int align); static tree validate_size (Uint, tree, Entity_Id, enum tree_code, bool, bool, const char *, const char *); static void set_rm_size (Uint, tree, Entity_Id); @@ -4425,7 +4425,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) /* If the size is self-referential, annotate the maximum value after saturating it, if need be, to avoid a No_Uint value. */ if (CONTAINS_PLACEHOLDER_P (gnu_size)) - gnu_size = maybe_saturate_size (max_size (gnu_size, true)); + { + const unsigned int align + = UI_To_Int (Alignment (gnat_entity)) * BITS_PER_UNIT; + gnu_size + = maybe_saturate_size (max_size (gnu_size, true), align); + } /* If we are just annotating types and the type is tagged, the tag and the parent components are not generated by the front-end so @@ -4461,7 +4466,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) gnu_size = size_binop (PLUS_EXPR, gnu_size, offset); } - gnu_size = maybe_saturate_size (round_up (gnu_size, align)); + gnu_size + = maybe_saturate_size (round_up (gnu_size, align), align); Set_Esize (gnat_entity, annotate_value (gnu_size)); /* Tagged types are Strict_Alignment so RM_Size = Esize. */ @@ -8946,15 +8952,21 @@ build_variant_list (tree gnu_qual_union_type, Node_Id gnat_variant_part, } /* If SIZE has overflowed, return the maximum valid size, which is the upper - bound of the signed sizetype in bits; otherwise return SIZE unmodified. */ + bound of the signed sizetype in bits, rounded down to ALIGN. Otherwise + return SIZE unmodified. */ static tree -maybe_saturate_size (tree size) +maybe_saturate_size (tree size, unsigned int align) { if (TREE_CODE (size) == INTEGER_CST && TREE_OVERFLOW (size)) - size = size_binop (MULT_EXPR, - fold_convert (bitsizetype, TYPE_MAX_VALUE (ssizetype)), - build_int_cst (bitsizetype, BITS_PER_UNIT)); + { + size + = size_binop (MULT_EXPR, + fold_convert (bitsizetype, TYPE_MAX_VALUE (ssizetype)), + build_int_cst (bitsizetype, BITS_PER_UNIT)); + size = round_down (size, align); + } + return size; } -- cgit v1.1 From cc997e0cc4fcc9ae8e389757d94a0ae69d34cd50 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 28 Sep 2020 09:09:41 +0200 Subject: Add missing end location information In some cases we would fail to put the end location information on the outermost BIND_EXPR of a function, which is problematic when there is a dynamic stack allocation. gcc/ada/ChangeLog: * gcc-interface/trans.c (Subprogram_Body_to_gnu): Set the end locus of body and declaration earlier. --- gcc/ada/gcc-interface/trans.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'gcc/ada/gcc-interface') diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 3491451..f03d591 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -4017,6 +4017,11 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) gnat_poplevel (); gnu_result = end_stmt_group (); + /* Attempt setting the end_locus of our GCC body tree, typically a BIND_EXPR, + then the end_locus of our GCC subprogram declaration tree. */ + set_end_locus_from_node (gnu_result, gnat_node); + set_end_locus_from_node (gnu_subprog_decl, gnat_node); + /* If we populated the parameter attributes cache, we need to make sure that the cached expressions are evaluated on all the possible paths leading to their uses. So we force their evaluation on entry of the function. */ @@ -4111,12 +4116,6 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) gnu_return_label_stack->pop (); - /* Attempt setting the end_locus of our GCC body tree, typically a - BIND_EXPR or STATEMENT_LIST, then the end_locus of our GCC subprogram - declaration tree. */ - set_end_locus_from_node (gnu_result, gnat_node); - set_end_locus_from_node (gnu_subprog_decl, gnat_node); - /* On SEH targets, install an exception handler around the main entry point to catch unhandled exceptions. */ if (DECL_NAME (gnu_subprog_decl) == main_identifier_node -- cgit v1.1