diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7a811a3f6e4..60b327b569c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,59 @@ +2016-04-18 Michael Matz + + * tree.h (TYPE_ALIGN, DECL_ALIGN): Return shifted amount. + (SET_TYPE_ALIGN, SET_DECL_ALIGN): New. + * tree-core.h (tree_type_common.align): Use bit-field. + (tree_type_common.spare): New. + (tree_decl_common.off_align): Make smaller. + (tree_decl_common.align): Use bit-field. + + * expr.c (expand_expr_addr_expr_1): Use SET_TYPE_ALIGN. + * omp-low.c (install_var_field): Use SET_DECL_ALIGN. + (scan_sharing_clauses): Ditto. + (finish_taskreg_scan): Use SET_DECL_ALIGN and SET_TYPE_ALIGN. + (omp_finish_file): Ditto. + * stor-layout.c (do_type_align): Use SET_DECL_ALIGN. + (layout_decl): Ditto. + (relayout_decl): Ditto. + (finalize_record_size): Use SET_TYPE_ALIGN. + (finalize_type_size): Ditto. + (finish_builtin_struct): Ditto. + (layout_type): Ditto. + (initialize_sizetypes): Ditto. + * targhooks.c (std_gimplify_va_arg_expr): Use SET_TYPE_ALIGN. + * tree-nested.c (insert_field_into_struct): Use SET_TYPE_ALIGN. + (lookup_field_for_decl): Use SET_DECL_ALIGN. + (get_chain_field): Ditto. + (get_trampoline_type): Ditto. + (get_nl_goto_field): Ditto. + * tree-streamer-in.c (unpack_ts_decl_common_value_fields): Use + SET_DECL_ALIGN. + (unpack_ts_type_common_value_fields): Use SET_TYPE_ALIGN. + * gimple-expr.c (copy_var_decl): Use SET_DECL_ALIGN. + * tree.c (make_node_stat): Use SET_DECL_ALIGN and SET_TYPE_ALIGN. + (build_qualified_type): Use SET_TYPE_ALIGN. + (build_aligned_type, build_range_type_1): Ditto. + (build_atomic_base): Ditto. + (build_common_tree_nodes): Ditto. + * cfgexpand.c (align_local_variable): Use SET_DECL_ALIGN. + (expand_one_stack_var_at): Ditto. + * coverage.c (build_var): Use SET_DECL_ALIGN. + * except.c (init_eh): Ditto. + * function.c (assign_parm_setup_block): Ditto. + * symtab.c (increase_alignment_1): Ditto. + * tree-ssa-ccp.c (fold_builtin_alloca_with_align): Ditto. + * tree-vect-stmts.c (ensure_base_align): Ditto. + * varasm.c (align_variable): Ditto. + (assemble_variable): Ditto. + (build_constant_desc): Ditto. + (output_constant_def_contents): Ditto. + + * config/arm/arm.c (arm_relayout_function): Use SET_DECL_ALIGN. + * config/avr/avr.c (avr_adjust_type_node): Use SET_TYPE_ALIGN. + * config/mips/mips.c (mips_std_gimplify_va_arg_expr): Ditto. + * config/msp430/msp430.c (msp430_gimplify_va_arg_expr): Ditto. + * config/spu/spu.c (spu_build_builtin_va_list): Use SET_DECL_ALIGN. + 2016-04-18 H.J. Lu PR target/70708 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index cc95c820b13..1ad6083afe6 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,19 @@ +2016-04-18 Michael Matz + + * gcc-interface/decl.c (gnat_to_gnu_entity): Use SET_TYPE_ALIGN. + (gnat_to_gnu_field): Ditto. + (components_to_record): Ditto. + (create_variant_part_from): Ditto. + (copy_and_substitute_in_size): Ditto. + (substitute_in_type): Ditto. + * gcc-interface/utils.c (make_aligning_type): Use SET_TYPE_ALIGN. + (make_packable_type): Ditto. + (maybe_pad_type): Ditto. + (finish_fat_pointer_type): Ditto. + (finish_record_type): Ditto and use SET_DECL_ALIGN. + (rest_of_record_type_compilation): Use SET_TYPE_ALIGN. + (create_field_decl): Use SET_DECL_ALIGN. + 2016-04-18 Arnaud Charlet * einfo.adb (Overridden_Operation): assert that diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index c1f409de011..8ea72b5f7fa 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -1888,8 +1888,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) This means that bit-packed arrays are given "ceil" alignment for their size by default, which may seem counter-intuitive but makes it possible to overlay them on modular types easily. */ - TYPE_ALIGN (gnu_type) - = align > 0 ? align : TYPE_ALIGN (gnu_field_type); + SET_TYPE_ALIGN (gnu_type, + align > 0 ? align : TYPE_ALIGN (gnu_field_type)); /* Propagate the reverse storage order flag to the record type so that the required byte swapping is performed when retrieving the @@ -1953,7 +1953,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) TYPE_SIZE (gnu_type) = TYPE_SIZE (gnu_field_type); TYPE_SIZE_UNIT (gnu_type) = TYPE_SIZE_UNIT (gnu_field_type); SET_TYPE_ADA_SIZE (gnu_type, TYPE_RM_SIZE (gnu_field_type)); - TYPE_ALIGN (gnu_type) = align; + SET_TYPE_ALIGN (gnu_type, align); relate_alias_sets (gnu_type, gnu_field_type, ALIAS_SET_COPY); /* Don't declare the field as addressable since we won't be taking @@ -2265,9 +2265,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if (No (Packed_Array_Impl_Type (gnat_entity)) && Known_Alignment (gnat_entity)) { - TYPE_ALIGN (tem) - = validate_alignment (Alignment (gnat_entity), gnat_entity, - TYPE_ALIGN (tem)); + SET_TYPE_ALIGN (tem, + validate_alignment (Alignment (gnat_entity), + gnat_entity, + TYPE_ALIGN (tem))); if (Present (Alignment_Clause (gnat_entity))) TYPE_USER_ALIGN (tem) = 1; } @@ -2296,7 +2297,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) TYPE_POINTER_TO (gnu_type) = gnu_fat_type; TYPE_REFERENCE_TO (gnu_type) = gnu_fat_type; SET_TYPE_MODE (gnu_type, BLKmode); - TYPE_ALIGN (gnu_type) = TYPE_ALIGN (tem); + SET_TYPE_ALIGN (gnu_type, TYPE_ALIGN (tem)); /* If the maximum size doesn't overflow, use it. */ if (gnu_max_size @@ -3035,11 +3036,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* Always set the alignment on the record type here so that it can get the proper layout. */ if (has_align) - TYPE_ALIGN (gnu_type) - = validate_alignment (Alignment (gnat_entity), gnat_entity, 0); + SET_TYPE_ALIGN (gnu_type, + validate_alignment (Alignment (gnat_entity), + gnat_entity, 0)); else { - TYPE_ALIGN (gnu_type) = 0; + SET_TYPE_ALIGN (gnu_type, 0); /* If a type needs strict alignment, the minimum size will be the type size instead of the RM size (see validate_size). Cap the @@ -3138,7 +3140,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) be created with a component clause below, then we need to apply the same adjustment as in gnat_to_gnu_field. */ if (has_rep && TYPE_ALIGN (gnu_type) < TYPE_ALIGN (gnu_parent)) - TYPE_ALIGN (gnu_type) = TYPE_ALIGN (gnu_parent); + SET_TYPE_ALIGN (gnu_type, TYPE_ALIGN (gnu_parent)); /* Finally we fix up both kinds of twisted COMPONENT_REF we have initially built. The discriminants must reference the fields @@ -4565,8 +4567,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* Set a default alignment to speed up accesses. But we shouldn't increase the size of the structure too much, lest it doesn't fit in return registers anymore. */ - TYPE_ALIGN (gnu_return_type) - = get_mode_alignment (ptr_mode); + SET_TYPE_ALIGN (gnu_return_type, + get_mode_alignment (ptr_mode)); } gnu_field @@ -4613,8 +4615,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if (mode != BLKmode) { SET_TYPE_MODE (gnu_return_type, mode); - TYPE_ALIGN (gnu_return_type) - = GET_MODE_ALIGNMENT (mode); + SET_TYPE_ALIGN (gnu_return_type, + GET_MODE_ALIGNMENT (mode)); TYPE_SIZE (gnu_return_type) = bitsize_int (GET_MODE_BITSIZE (mode)); TYPE_SIZE_UNIT (gnu_return_type) @@ -6796,7 +6798,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, const unsigned int type_align = TYPE_ALIGN (gnu_field_type); if (TYPE_ALIGN (gnu_record_type) < type_align) - TYPE_ALIGN (gnu_record_type) = type_align; + SET_TYPE_ALIGN (gnu_record_type, type_align); /* If the position is not a multiple of the alignment of the type, then error out and reset the position. */ @@ -7283,7 +7285,7 @@ components_to_record (tree gnu_record_type, Node_Id gnat_component_list, = make_node (unchecked_union ? UNION_TYPE : QUAL_UNION_TYPE); TYPE_NAME (gnu_union_type) = gnu_union_name; - TYPE_ALIGN (gnu_union_type) = 0; + SET_TYPE_ALIGN (gnu_union_type, 0); TYPE_PACKED (gnu_union_type) = TYPE_PACKED (gnu_record_type); TYPE_REVERSE_STORAGE_ORDER (gnu_union_type) = TYPE_REVERSE_STORAGE_ORDER (gnu_record_type); @@ -7336,7 +7338,7 @@ components_to_record (tree gnu_record_type, Node_Id gnat_component_list, /* Set the alignment of the inner type in case we need to make inner objects into bitfields, but then clear it out so the record actually gets only the alignment required. */ - TYPE_ALIGN (gnu_variant_type) = TYPE_ALIGN (gnu_record_type); + SET_TYPE_ALIGN (gnu_variant_type, TYPE_ALIGN (gnu_record_type)); TYPE_PACKED (gnu_variant_type) = TYPE_PACKED (gnu_record_type); TYPE_REVERSE_STORAGE_ORDER (gnu_variant_type) = TYPE_REVERSE_STORAGE_ORDER (gnu_record_type); @@ -7568,9 +7570,9 @@ components_to_record (tree gnu_record_type, Node_Id gnat_component_list, SET_DECL_OFFSET_ALIGN (gnu_field, BIGGEST_ALIGNMENT); DECL_FIELD_BIT_OFFSET (gnu_field) = bitsize_zero_node; if (field_is_aliased (gnu_field)) - TYPE_ALIGN (gnu_record_type) - = MAX (TYPE_ALIGN (gnu_record_type), - TYPE_ALIGN (TREE_TYPE (gnu_field))); + SET_TYPE_ALIGN (gnu_record_type, + MAX (TYPE_ALIGN (gnu_record_type), + TYPE_ALIGN (TREE_TYPE (gnu_field)))); MOVE_FROM_FIELD_LIST_TO (gnu_zero_list); continue; } @@ -7681,7 +7683,7 @@ components_to_record (tree gnu_record_type, Node_Id gnat_component_list, gnu_field_list = chainon (gnu_field_list, gnu_variant_part); if (cancel_alignment) - TYPE_ALIGN (gnu_record_type) = 0; + SET_TYPE_ALIGN (gnu_record_type, 0); TYPE_ARTIFICIAL (gnu_record_type) = artificial; @@ -8794,7 +8796,7 @@ create_variant_part_from (tree old_variant_part, SET_TYPE_ADA_SIZE (new_union_type, size_binop (MINUS_EXPR, TYPE_ADA_SIZE (record_type), first_bit)); - TYPE_ALIGN (new_union_type) = TYPE_ALIGN (old_union_type); + SET_TYPE_ALIGN (new_union_type, TYPE_ALIGN (old_union_type)); relate_alias_sets (new_union_type, old_union_type, ALIAS_SET_COPY); } else @@ -8891,7 +8893,7 @@ copy_and_substitute_in_size (tree new_type, tree old_type, TYPE_SIZE (new_type) = TYPE_SIZE (old_type); TYPE_SIZE_UNIT (new_type) = TYPE_SIZE_UNIT (old_type); SET_TYPE_ADA_SIZE (new_type, TYPE_ADA_SIZE (old_type)); - TYPE_ALIGN (new_type) = TYPE_ALIGN (old_type); + SET_TYPE_ALIGN (new_type, TYPE_ALIGN (old_type)); relate_alias_sets (new_type, old_type, ALIAS_SET_COPY); if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (new_type))) @@ -9034,7 +9036,7 @@ substitute_in_type (tree t, tree f, tree r) return t; nt = build_nonshared_array_type (component, domain); - TYPE_ALIGN (nt) = TYPE_ALIGN (t); + SET_TYPE_ALIGN (nt, TYPE_ALIGN (t)); TYPE_USER_ALIGN (nt) = TYPE_USER_ALIGN (t); SET_TYPE_MODE (nt, TYPE_MODE (t)); TYPE_SIZE (nt) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r); diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 9bd2773ba9e..d568dff8e01 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -904,7 +904,7 @@ make_aligning_type (tree type, unsigned int align, tree size, pos, 1, -1); TYPE_FIELDS (record_type) = field; - TYPE_ALIGN (record_type) = base_align; + SET_TYPE_ALIGN (record_type, base_align); TYPE_USER_ALIGN (record_type) = 1; TYPE_SIZE (record_type) @@ -963,7 +963,7 @@ make_packable_type (tree type, bool in_record) if (in_record && size <= MAX_FIXED_MODE_SIZE) { align = ceil_pow2 (size); - TYPE_ALIGN (new_type) = align; + SET_TYPE_ALIGN (new_type, align); new_size = (size + align - 1) & -align; } else @@ -983,7 +983,7 @@ make_packable_type (tree type, bool in_record) return type; align = new_size & -new_size; - TYPE_ALIGN (new_type) = MIN (TYPE_ALIGN (type), align); + SET_TYPE_ALIGN (new_type, MIN (TYPE_ALIGN (type), align)); } TYPE_USER_ALIGN (new_type) = 1; @@ -1295,7 +1295,7 @@ maybe_pad_type (tree type, tree size, unsigned int align, else if (Present (gnat_entity)) TYPE_NAME (record) = create_concat_name (gnat_entity, "PAD"); - TYPE_ALIGN (record) = align ? align : orig_align; + SET_TYPE_ALIGN (record, align ? align : orig_align); TYPE_SIZE (record) = size ? size : orig_size; TYPE_SIZE_UNIT (record) = convert (sizetype, @@ -1650,7 +1650,7 @@ finish_fat_pointer_type (tree record_type, tree field_list) { /* Make sure we can put it into a register. */ if (STRICT_ALIGNMENT) - TYPE_ALIGN (record_type) = MIN (BIGGEST_ALIGNMENT, 2 * POINTER_SIZE); + SET_TYPE_ALIGN (record_type, MIN (BIGGEST_ALIGNMENT, 2 * POINTER_SIZE)); /* Show what it really is. */ TYPE_FAT_POINTER_P (record_type) = 1; @@ -1697,7 +1697,8 @@ finish_record_type (tree record_type, tree field_list, int rep_level, that just means some initializations; otherwise, layout the record. */ if (rep_level > 0) { - TYPE_ALIGN (record_type) = MAX (BITS_PER_UNIT, TYPE_ALIGN (record_type)); + SET_TYPE_ALIGN (record_type, MAX (BITS_PER_UNIT, + TYPE_ALIGN (record_type))); if (!had_size_unit) TYPE_SIZE_UNIT (record_type) = size_zero_node; @@ -1775,7 +1776,7 @@ finish_record_type (tree record_type, tree field_list, int rep_level, maximum alignment, if any. */ if (TYPE_ALIGN (record_type) >= align) { - DECL_ALIGN (field) = MAX (DECL_ALIGN (field), align); + SET_DECL_ALIGN (field, MAX (DECL_ALIGN (field), align)); DECL_BIT_FIELD (field) = 0; } else if (!had_align @@ -1784,8 +1785,8 @@ finish_record_type (tree record_type, tree field_list, int rep_level, && (!TYPE_MAX_ALIGN (record_type) || TYPE_MAX_ALIGN (record_type) >= align)) { - TYPE_ALIGN (record_type) = align; - DECL_ALIGN (field) = MAX (DECL_ALIGN (field), align); + SET_TYPE_ALIGN (record_type, align); + SET_DECL_ALIGN (field, MAX (DECL_ALIGN (field), align)); DECL_BIT_FIELD (field) = 0; } } @@ -1808,8 +1809,8 @@ finish_record_type (tree record_type, tree field_list, int rep_level, /* A type must be as aligned as its most aligned field that is not a bit-field. But this is already enforced by layout_type. */ if (rep_level > 0 && !DECL_BIT_FIELD (field)) - TYPE_ALIGN (record_type) - = MAX (TYPE_ALIGN (record_type), DECL_ALIGN (field)); + SET_TYPE_ALIGN (record_type, + MAX (TYPE_ALIGN (record_type), DECL_ALIGN (field))); switch (code) { @@ -1980,7 +1981,7 @@ rest_of_record_type_compilation (tree record_type) = concat_name (orig_name, TREE_CODE (record_type) == QUAL_UNION_TYPE ? "XVU" : "XVE"); TYPE_NAME (new_record_type) = new_name; - TYPE_ALIGN (new_record_type) = BIGGEST_ALIGNMENT; + SET_TYPE_ALIGN (new_record_type, BIGGEST_ALIGNMENT); TYPE_STUB_DECL (new_record_type) = create_type_stub_decl (new_name, new_record_type); DECL_IGNORED_P (TYPE_STUB_DECL (new_record_type)) @@ -2072,7 +2073,7 @@ rest_of_record_type_compilation (tree record_type) if (align != 0 && TYPE_ALIGN (field_type) > align) { field_type = copy_node (field_type); - TYPE_ALIGN (field_type) = align; + SET_TYPE_ALIGN (field_type, align); } var = true; } @@ -2620,7 +2621,7 @@ create_field_decl (tree name, tree type, tree record_type, tree size, tree pos, || (!pos && AGGREGATE_TYPE_P (type) && aggregate_type_contains_array_p (type)))) - DECL_ALIGN (field_decl) = BITS_PER_UNIT; + SET_DECL_ALIGN (field_decl, BITS_PER_UNIT); /* If a size is specified, use it. Otherwise, if the record type is packed compute a size to use, which may differ from the object's natural size. @@ -2667,9 +2668,9 @@ create_field_decl (tree name, tree type, tree record_type, tree size, tree pos, { if (TYPE_ALIGN (record_type) != 0 && TYPE_ALIGN (record_type) < TYPE_ALIGN (type)) - DECL_ALIGN (field_decl) = TYPE_ALIGN (record_type); + SET_DECL_ALIGN (field_decl, TYPE_ALIGN (record_type)); else - DECL_ALIGN (field_decl) = TYPE_ALIGN (type); + SET_DECL_ALIGN (field_decl, TYPE_ALIGN (type)); } } @@ -2685,10 +2686,10 @@ create_field_decl (tree name, tree type, tree record_type, tree size, tree pos, : packed && TYPE_MODE (type) != BLKmode ? BITS_PER_UNIT : 0); if (bit_align > DECL_ALIGN (field_decl)) - DECL_ALIGN (field_decl) = bit_align; + SET_DECL_ALIGN (field_decl, bit_align); else if (!bit_align && TYPE_ALIGN (type) > DECL_ALIGN (field_decl)) { - DECL_ALIGN (field_decl) = TYPE_ALIGN (type); + SET_DECL_ALIGN (field_decl, TYPE_ALIGN (type)); DECL_USER_ALIGN (field_decl) = TYPE_USER_ALIGN (type); } } diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 5cf0e84a741..7ae6903eb7e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2016-04-18 Michael Matz + + * c-common.c (handle_aligned_attribute): Use SET_TYPE_ALIGN + and SET_DECL_ALIGN. + 2016-04-17 Eric Botcazou * c-ada-spec.c (get_underlying_decl): Return the typedef, if any. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index f2846bb26e7..cae2faf5c4f 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -7837,7 +7837,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args, else *type = build_variant_type_copy (*type); - TYPE_ALIGN (*type) = (1U << i) * BITS_PER_UNIT; + SET_TYPE_ALIGN (*type, (1U << i) * BITS_PER_UNIT); TYPE_USER_ALIGN (*type) = 1; } else if (! VAR_OR_FUNCTION_DECL_P (decl) @@ -7871,7 +7871,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args, } else { - DECL_ALIGN (decl) = (1U << i) * BITS_PER_UNIT; + SET_DECL_ALIGN (decl, (1U << i) * BITS_PER_UNIT); DECL_USER_ALIGN (decl) = 1; } diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 7257f79e0b2..b46df1f0a49 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2016-04-18 Michael Matz + + * c-decl.c (merge_decls): Use SET_DECL_ALIGN and SET_TYPE_ALIGN. + (grokdeclarator, parser_xref_tag, finish_enum): Use SET_TYPE_ALIGN. + 2016-04-15 Marek Polacek PR c/70671 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 0dd2121b868..f0c677b1cef 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -2369,7 +2369,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) if (TYPE_USER_ALIGN (tem)) { if (TYPE_ALIGN (tem) > TYPE_ALIGN (newtype)) - TYPE_ALIGN (newtype) = TYPE_ALIGN (tem); + SET_TYPE_ALIGN (newtype, TYPE_ALIGN (tem)); TYPE_USER_ALIGN (newtype) = true; } @@ -2410,7 +2410,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) DECL_MODE (newdecl) = DECL_MODE (olddecl); if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl)) { - DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl); + SET_DECL_ALIGN (newdecl, DECL_ALIGN (olddecl)); DECL_USER_ALIGN (newdecl) |= DECL_USER_ALIGN (olddecl); } } @@ -6763,7 +6763,7 @@ grokdeclarator (const struct c_declarator *declarator, /* Apply _Alignas specifiers. */ if (alignas_align) { - DECL_ALIGN (decl) = alignas_align * BITS_PER_UNIT; + SET_DECL_ALIGN (decl, alignas_align * BITS_PER_UNIT); DECL_USER_ALIGN (decl) = 1; } @@ -7205,7 +7205,7 @@ parser_xref_tag (location_t loc, enum tree_code code, tree name) /* Give the type a default layout like unsigned int to avoid crashing if it does not get defined. */ SET_TYPE_MODE (ref, TYPE_MODE (unsigned_type_node)); - TYPE_ALIGN (ref) = TYPE_ALIGN (unsigned_type_node); + SET_TYPE_ALIGN (ref, TYPE_ALIGN (unsigned_type_node)); TYPE_USER_ALIGN (ref) = 0; TYPE_UNSIGNED (ref) = 1; TYPE_PRECISION (ref) = TYPE_PRECISION (unsigned_type_node); @@ -8101,7 +8101,7 @@ finish_enum (tree enumtype, tree values, tree attributes) TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (tem); TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (tem); TYPE_UNSIGNED (enumtype) = TYPE_UNSIGNED (tem); - TYPE_ALIGN (enumtype) = TYPE_ALIGN (tem); + SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (tem)); TYPE_SIZE (enumtype) = 0; TYPE_PRECISION (enumtype) = TYPE_PRECISION (tem); @@ -8163,7 +8163,7 @@ finish_enum (tree enumtype, tree values, tree attributes) TYPE_SIZE_UNIT (tem) = TYPE_SIZE_UNIT (enumtype); SET_TYPE_MODE (tem, TYPE_MODE (enumtype)); TYPE_PRECISION (tem) = TYPE_PRECISION (enumtype); - TYPE_ALIGN (tem) = TYPE_ALIGN (enumtype); + SET_TYPE_ALIGN (tem, TYPE_ALIGN (enumtype)); TYPE_USER_ALIGN (tem) = TYPE_USER_ALIGN (enumtype); TYPE_UNSIGNED (tem) = TYPE_UNSIGNED (enumtype); TYPE_LANG_SPECIFIC (tem) = TYPE_LANG_SPECIFIC (enumtype); diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 1341c14ce2b..3ed2270e881 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -369,7 +369,7 @@ align_local_variable (tree decl) else { align = LOCAL_DECL_ALIGNMENT (decl); - DECL_ALIGN (decl) = align; + SET_DECL_ALIGN (decl, align); } return align / BITS_PER_UNIT; } @@ -1018,7 +1018,7 @@ expand_one_stack_var_at (tree decl, rtx base, unsigned base_align, alignment here, but (at least) the i386 port does exactly this via the MINIMUM_ALIGNMENT hook. */ - DECL_ALIGN (decl) = align; + SET_DECL_ALIGN (decl, align); DECL_USER_ALIGN (decl) = 0; } diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 5974c65d314..4d9f6f1ad7e 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -29981,8 +29981,8 @@ arm_relayout_function (tree fndecl) if (!callee_tree) callee_tree = target_option_default_node; - DECL_ALIGN (fndecl) = - FUNCTION_BOUNDARY_P (TREE_TARGET_OPTION (callee_tree)->x_target_flags); + struct cl_target_option *opts = TREE_TARGET_OPTION (callee_tree); + SET_DECL_ALIGN (fndecl, FUNCTION_BOUNDARY_P (opts->x_target_flags)); } /* Inner function to process the attribute((target(...))), take an argument and diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index a7728e3b10c..8de39e0a660 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -911,7 +911,7 @@ avr_adjust_type_node (tree *node, machine_mode mode, int sat_p) TYPE_IBIT (*node) = GET_MODE_IBIT (mode); TYPE_FBIT (*node) = GET_MODE_FBIT (mode); TYPE_PRECISION (*node) = GET_MODE_BITSIZE (mode); - TYPE_ALIGN (*node) = 8; + SET_TYPE_ALIGN (*node, 8); SET_TYPE_MODE (*node, mode); layout_type (*node); diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 5af3d1e6505..399f231791d 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -6304,7 +6304,7 @@ mips_std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, if (boundary < TYPE_ALIGN (type)) { type = build_variant_type_copy (type); - TYPE_ALIGN (type) = boundary; + SET_TYPE_ALIGN (type, boundary); } /* Compute the rounded size of the type. */ diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index 6f6311672aa..2e2a02c0d1a 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -1461,7 +1461,7 @@ msp430_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, if (boundary < TYPE_ALIGN (type)) { type = build_variant_type_copy (type); - TYPE_ALIGN (type) = boundary; + SET_TYPE_ALIGN (type, boundary); } /* Compute the rounded size of the type. */ diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index 401c295b138..c3757eb029e 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -3915,11 +3915,11 @@ spu_build_builtin_va_list (void) FIELD_DECL, get_identifier ("__skip"), ptr_type_node); DECL_FIELD_CONTEXT (f_args) = record; - DECL_ALIGN (f_args) = 128; + SET_DECL_ALIGN (f_args, 128); DECL_USER_ALIGN (f_args) = 1; DECL_FIELD_CONTEXT (f_skip) = record; - DECL_ALIGN (f_skip) = 128; + SET_DECL_ALIGN (f_skip, 128); DECL_USER_ALIGN (f_skip) = 1; TYPE_STUB_DECL (record) = type_decl; diff --git a/gcc/coverage.c b/gcc/coverage.c index b1fce7d0e7a..67cc908cbf5 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -751,7 +751,7 @@ build_var (tree fn_decl, tree type, int counter) TREE_STATIC (var) = 1; TREE_ADDRESSABLE (var) = 1; DECL_NONALIASED (var) = 1; - DECL_ALIGN (var) = TYPE_ALIGN (type); + SET_DECL_ALIGN (var, TYPE_ALIGN (type)); return var; } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 104da7b58d2..c50c6abd616 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,22 @@ +2016-04-18 Michael Matz + + * class.c (build_vtable): Use SET_DECL_ALIGN and SET_TYPE_ALIGN. + (layout_class_type): Ditto. + (build_base_field): Use SET_DECL_ALIGN. + (fixup_attribute_variants): Use SET_TYPE_ALIGN. + * decl.c (duplicate_decls): Use SET_DECL_ALIGN. + (record_unknown_type): Use SET_TYPE_ALIGN. + (cxx_init_decl_processing): Ditto. + (copy_type_enum): Ditto. + (grokfndecl): Use SET_DECL_ALIGN. + (copy_type_enum): Use SET_TYPE_ALIGN. + * pt.c (instantiate_class_template_1): Use SET_TYPE_ALIGN. + (tsubst): Ditto. + * tree.c (cp_build_qualified_type_real): Use SET_TYPE_ALIGN. + * lambda.c (maybe_add_lambda_conv_op): Use SET_DECL_ALIGN. + * method.c (implicitly_declare_fn): Use SET_DECL_ALIGN. + * rtti.c (emit_tinfo_decl): Ditto. + 2016-04-18 Jason Merrill PR c++/70690 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 2c5ce7384da..2705e189afa 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -801,7 +801,7 @@ build_vtable (tree class_type, tree name, tree vtable_type) TREE_STATIC (decl) = 1; TREE_READONLY (decl) = 1; DECL_VIRTUAL_P (decl) = 1; - DECL_ALIGN (decl) = TARGET_VTABLE_ENTRY_ALIGN; + SET_DECL_ALIGN (decl, TARGET_VTABLE_ENTRY_ALIGN); DECL_USER_ALIGN (decl) = true; DECL_VTABLE_OR_VTT_P (decl) = 1; set_linkage_according_to_type (class_type, decl); @@ -2035,7 +2035,7 @@ fixup_attribute_variants (tree t) valign = MAX (valign, TYPE_ALIGN (variants)); else TYPE_USER_ALIGN (variants) = user_align; - TYPE_ALIGN (variants) = valign; + SET_TYPE_ALIGN (variants, valign); if (may_alias) fixup_may_alias (variants); } @@ -4484,7 +4484,7 @@ build_base_field (record_layout_info rli, tree binfo, { DECL_SIZE (decl) = CLASSTYPE_SIZE (basetype); DECL_SIZE_UNIT (decl) = CLASSTYPE_SIZE_UNIT (basetype); - DECL_ALIGN (decl) = CLASSTYPE_ALIGN (basetype); + SET_DECL_ALIGN (decl, CLASSTYPE_ALIGN (basetype)); DECL_USER_ALIGN (decl) = CLASSTYPE_USER_ALIGN (basetype); DECL_MODE (decl) = TYPE_MODE (basetype); DECL_FIELD_IS_BASE (decl) = 1; @@ -6404,7 +6404,7 @@ layout_class_type (tree t, tree *virtuals_p) } DECL_SIZE (field) = TYPE_SIZE (integer_type); - DECL_ALIGN (field) = TYPE_ALIGN (integer_type); + SET_DECL_ALIGN (field, TYPE_ALIGN (integer_type)); DECL_USER_ALIGN (field) = TYPE_USER_ALIGN (integer_type); layout_nonempty_base_or_field (rli, field, NULL_TREE, empty_base_offsets); @@ -6539,7 +6539,7 @@ layout_class_type (tree t, tree *virtuals_p) size_binop (MULT_EXPR, fold_convert (bitsizetype, eoc), bitsize_int (BITS_PER_UNIT))); - TYPE_ALIGN (base_t) = rli->record_align; + SET_TYPE_ALIGN (base_t, rli->record_align); TYPE_USER_ALIGN (base_t) = TYPE_USER_ALIGN (t); /* Copy the fields from T. */ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 38e6bd83a2a..461822ba167 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2066,7 +2066,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) if (TYPE_USER_ALIGN (tem)) { if (TYPE_ALIGN (tem) > TYPE_ALIGN (newtype)) - TYPE_ALIGN (newtype) = TYPE_ALIGN (tem); + SET_TYPE_ALIGN (newtype, TYPE_ALIGN (tem)); TYPE_USER_ALIGN (newtype) = true; } @@ -2490,7 +2490,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) /* Likewise for DECL_ALIGN, DECL_USER_ALIGN and DECL_PACKED. */ if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl)) { - DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl); + SET_DECL_ALIGN (newdecl, DECL_ALIGN (olddecl)); DECL_USER_ALIGN (newdecl) |= DECL_USER_ALIGN (olddecl); } DECL_USER_ALIGN (olddecl) = DECL_USER_ALIGN (newdecl); @@ -3919,7 +3919,7 @@ record_unknown_type (tree type, const char* name) DECL_IGNORED_P (decl) = 1; TYPE_DECL_SUPPRESS_DEBUG (decl) = 1; TYPE_SIZE (type) = TYPE_SIZE (void_type_node); - TYPE_ALIGN (type) = 1; + SET_TYPE_ALIGN (type, 1); TYPE_USER_ALIGN (type) = 0; SET_TYPE_MODE (type, TYPE_MODE (void_type_node)); } @@ -4174,7 +4174,7 @@ cxx_init_decl_processing (void) TYPE_UNSIGNED (nullptr_type_node) = 1; TYPE_PRECISION (nullptr_type_node) = GET_MODE_BITSIZE (ptr_mode); if (abi_version_at_least (9)) - TYPE_ALIGN (nullptr_type_node) = GET_MODE_ALIGNMENT (ptr_mode); + SET_TYPE_ALIGN (nullptr_type_node, GET_MODE_ALIGNMENT (ptr_mode)); SET_TYPE_MODE (nullptr_type_node, ptr_mode); record_builtin_type (RID_MAX, "decltype(nullptr)", nullptr_type_node); nullptr_node = build_int_cst (nullptr_type_node, 0); @@ -7924,7 +7924,7 @@ grokfndecl (tree ctype, parms = parm; /* Allocate space to hold the vptr bit if needed. */ - DECL_ALIGN (decl) = MINIMUM_METHOD_BOUNDARY; + SET_DECL_ALIGN (decl, MINIMUM_METHOD_BOUNDARY); } DECL_ARGUMENTS (decl) = parms; for (t = parms; t; t = DECL_CHAIN (t)) @@ -13115,7 +13115,7 @@ copy_type_enum (tree dst, tree src) valign = MAX (valign, TYPE_ALIGN (t)); else TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (src); - TYPE_ALIGN (t) = valign; + SET_TYPE_ALIGN (t, valign); TYPE_UNSIGNED (t) = TYPE_UNSIGNED (src); } } diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index cdc11febcff..374a78b1b4f 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -1006,7 +1006,7 @@ maybe_add_lambda_conv_op (tree type) tree convfn = build_lang_decl (FUNCTION_DECL, name, fntype); tree fn = convfn; DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); - DECL_ALIGN (fn) = MINIMUM_METHOD_BOUNDARY; + SET_DECL_ALIGN (fn, MINIMUM_METHOD_BOUNDARY); SET_OVERLOADED_OPERATOR_CODE (fn, TYPE_EXPR); grokclassfn (type, fn, NO_SPECIAL); set_linkage_according_to_type (type, fn); diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 38f2a5427cc..862451f249b 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1865,7 +1865,7 @@ implicitly_declare_fn (special_function_kind kind, tree type, SET_OVERLOADED_OPERATOR_CODE (fn, NOP_EXPR); } - DECL_ALIGN (fn) = MINIMUM_METHOD_BOUNDARY; + SET_DECL_ALIGN (fn, MINIMUM_METHOD_BOUNDARY); /* Create the explicit arguments. */ if (rhs_parm_type) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 325351fbee5..a6d56d147bb 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9856,7 +9856,7 @@ instantiate_class_template_1 (tree type) DECL_SOURCE_LOCATION (typedecl); TYPE_PACKED (type) = TYPE_PACKED (pattern); - TYPE_ALIGN (type) = TYPE_ALIGN (pattern); + SET_TYPE_ALIGN (type, TYPE_ALIGN (pattern)); TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (pattern); TYPE_FOR_JAVA (type) = TYPE_FOR_JAVA (pattern); /* For libjava's JArray */ if (ANON_AGGR_TYPE_P (pattern)) @@ -13403,7 +13403,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (TYPE_USER_ALIGN (t)) { - TYPE_ALIGN (r) = TYPE_ALIGN (t); + SET_TYPE_ALIGN (r, TYPE_ALIGN (t)); TYPE_USER_ALIGN (r) = 1; } diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 244c34d0580..43d5f15fa3f 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -1603,7 +1603,7 @@ emit_tinfo_decl (tree decl) /* Avoid targets optionally bumping up the alignment to improve vector instruction accesses, tinfo are never accessed this way. */ #ifdef DATA_ABI_ALIGNMENT - DECL_ALIGN (decl) = DATA_ABI_ALIGNMENT (decl, TYPE_ALIGN (TREE_TYPE (decl))); + SET_DECL_ALIGN (decl, DATA_ABI_ALIGNMENT (decl, TYPE_ALIGN (TREE_TYPE (decl)))); DECL_USER_ALIGN (decl) = true; #endif return true; diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index e34215c961e..112c8c7a565 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1074,7 +1074,7 @@ cp_build_qualified_type_real (tree type, { t = build_variant_type_copy (t); TYPE_NAME (t) = TYPE_NAME (type); - TYPE_ALIGN (t) = TYPE_ALIGN (type); + SET_TYPE_ALIGN (t, TYPE_ALIGN (type)); TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (type); } } diff --git a/gcc/except.c b/gcc/except.c index 2a1073f80cc..cf1df8cc6ec 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -300,7 +300,7 @@ init_eh (void) #ifdef DONT_USE_BUILTIN_SETJMP /* We don't know what the alignment requirements of the runtime's jmp_buf has. Overestimate. */ - DECL_ALIGN (f_jbuf) = BIGGEST_ALIGNMENT; + SET_DECL_ALIGN (f_jbuf, BIGGEST_ALIGNMENT); DECL_USER_ALIGN (f_jbuf) = 1; #endif DECL_FIELD_CONTEXT (f_jbuf) = sjlj_fc_type_node; diff --git a/gcc/expr.c b/gcc/expr.c index 29d22b07256..248d3d7bf82 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -7712,7 +7712,7 @@ expand_expr_addr_expr_1 (tree exp, rtx target, machine_mode tmode, { inner = copy_node (inner); TREE_TYPE (inner) = copy_node (TREE_TYPE (inner)); - TYPE_ALIGN (TREE_TYPE (inner)) = TYPE_ALIGN (TREE_TYPE (exp)); + SET_TYPE_ALIGN (TREE_TYPE (inner), TYPE_ALIGN (TREE_TYPE (exp))); TYPE_USER_ALIGN (TREE_TYPE (inner)) = 1; } result = expand_expr_addr_expr_1 (inner, subtarget, tmode, modifier, as); diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e2f216d2bc6..086a516b6bc 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-04-18 Michael Matz + + * trans-io.c (gfc_build_io_library_fndecls): Use SET_TYPE_ALIGN. + * trans-common.c (build_common_decl): Use SET_DECL_ALIGN. + * trans-types.c (gfc_add_field_to_struct): Use SET_DECL_ALIGN. + 2016-04-13 Dominique d'Humieres PR fortran/67039 diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c index 21d19287d15..44787aebfde 100644 --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -438,7 +438,7 @@ build_common_decl (gfc_common_head *com, tree union_type, bool is_init) TREE_STATIC (decl) = 1; DECL_IGNORED_P (decl) = 1; if (!com->is_bind_c) - DECL_ALIGN (decl) = BIGGEST_ALIGNMENT; + SET_DECL_ALIGN (decl, BIGGEST_ALIGNMENT); else { /* Do not set the alignment for bind(c) common blocks to @@ -449,7 +449,7 @@ build_common_decl (gfc_common_head *com, tree union_type, bool is_init) tree field = NULL_TREE; field = TYPE_FIELDS (TREE_TYPE (decl)); if (DECL_CHAIN (field) == NULL_TREE) - DECL_ALIGN (decl) = TYPE_ALIGN (TREE_TYPE (field)); + SET_DECL_ALIGN (decl, TYPE_ALIGN (TREE_TYPE (field))); } DECL_USER_ALIGN (decl) = 0; GFC_DECL_COMMON_OR_EQUIV (decl) = 1; diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c index 23080f0fc6e..7f649978863 100644 --- a/gcc/fortran/trans-io.c +++ b/gcc/fortran/trans-io.c @@ -309,8 +309,8 @@ gfc_build_io_library_fndecls (void) alignment that is at least as large as the needed alignment for those types. See the st_parameter_dt structure in libgfortran/io/io.h for what really goes into this space. */ - TYPE_ALIGN (types[IOPARM_type_pad]) = MAX (TYPE_ALIGN (pchar_type_node), - TYPE_ALIGN (gfc_get_int_type (gfc_intio_kind))); + SET_TYPE_ALIGN (types[IOPARM_type_pad], MAX (TYPE_ALIGN (pchar_type_node), + TYPE_ALIGN (gfc_get_int_type (gfc_intio_kind)))); for (ptype = IOPARM_ptype_common; ptype < IOPARM_ptype_num; ptype++) gfc_build_st_parameter ((enum ioparam_type) ptype, types); diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index a71cf0bcd27..dd945aa059a 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -2275,7 +2275,7 @@ gfc_add_field_to_struct (tree context, tree name, tree type, tree **chain) tree decl = gfc_add_field_to_struct_1 (context, name, type, chain); DECL_INITIAL (decl) = 0; - DECL_ALIGN (decl) = 0; + SET_DECL_ALIGN (decl, 0); DECL_USER_ALIGN (decl) = 0; return decl; diff --git a/gcc/function.c b/gcc/function.c index 1ac8e26daab..43a80b42875 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -2925,7 +2925,7 @@ assign_parm_setup_block (struct assign_parm_data_all *all, size_stored = CEIL_ROUND (size, UNITS_PER_WORD); if (stack_parm == 0) { - DECL_ALIGN (parm) = MAX (DECL_ALIGN (parm), BITS_PER_WORD); + SET_DECL_ALIGN (parm, MAX (DECL_ALIGN (parm), BITS_PER_WORD)); stack_parm = assign_stack_local (BLKmode, size_stored, DECL_ALIGN (parm)); if (GET_MODE_SIZE (GET_MODE (entry_parm)) == size) diff --git a/gcc/gimple-expr.c b/gcc/gimple-expr.c index 29e9c0a33dc..ed012ccfdc6 100644 --- a/gcc/gimple-expr.c +++ b/gcc/gimple-expr.c @@ -377,7 +377,7 @@ copy_var_decl (tree var, tree name, tree type) DECL_ATTRIBUTES (copy) = DECL_ATTRIBUTES (var); if (DECL_USER_ALIGN (var)) { - DECL_ALIGN (copy) = DECL_ALIGN (var); + SET_DECL_ALIGN (copy, DECL_ALIGN (var)); DECL_USER_ALIGN (copy) = 1; } diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 6c6ed9dcf6d..f3b419b44a9 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,7 @@ +2016-04-18 Michael Matz + + * go-gcc.cc (Gcc_backend::implicit_variable): Use SET_DECL_ALIGN. + 2016-02-12 Jakub Jelinek * gofrontend/lex.cc: Spelling fixes - behaviour -> behavior and diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index 2793bb6090d..1cb3242d501 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -2687,7 +2687,7 @@ Gcc_backend::implicit_variable(const std::string& name, Btype* type, } if (alignment != 0) { - DECL_ALIGN(decl) = alignment * BITS_PER_UNIT; + SET_DECL_ALIGN(decl, alignment * BITS_PER_UNIT); DECL_USER_ALIGN(decl) = 1; } diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 9be4b7402cf..7c20b060cc8 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,10 @@ +2016-04-18 Michael Matz + + * class.c (add_method_1): Use SET_DECL_ALIGN. + (make_class_data): Ditto. + (emit_register_classes_in_jcr_section): Ditto. + * typeck.c (build_java_array_type): Ditto. + 2016-01-04 Jakub Jelinek Update copyright years. diff --git a/gcc/java/class.c b/gcc/java/class.c index 4f567161eb9..35874867170 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -773,7 +773,7 @@ add_method_1 (tree this_class, int access_flags, tree name, tree function_type) TYPE_METHODS (this_class) = fndecl; if (!(access_flags & ACC_STATIC)) - DECL_ALIGN (fndecl) = MINIMUM_METHOD_BOUNDARY; + SET_DECL_ALIGN (fndecl, MINIMUM_METHOD_BOUNDARY); /* Notice that this is a finalizer and update the class type accordingly. This is used to optimize instance allocation. */ @@ -2207,11 +2207,11 @@ make_class_data (tree type) FINISH_RECORD_CONSTRUCTOR (cons, v2, class_type_node); DECL_INITIAL (decl) = cons; - + /* Hash synchronization requires at least 64-bit alignment. */ if (flag_hash_synchronization && POINTER_SIZE < 64) - DECL_ALIGN (decl) = 64; - + SET_DECL_ALIGN (decl, 64); + if (flag_indirect_classes) { TREE_READONLY (decl) = 1; @@ -2790,7 +2790,7 @@ emit_register_classes_in_jcr_section (void) cdecl = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier ("_Jv_JCR_SECTION_data"), class_array_type); - DECL_ALIGN (cdecl) = POINTER_SIZE; + SET_DECL_ALIGN (cdecl, POINTER_SIZE); DECL_USER_ALIGN (cdecl) = 1; DECL_INITIAL (cdecl) = build_constructor (class_array_type, init); TREE_CONSTANT (DECL_INITIAL (cdecl)) = 1; diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c index 1214eae9f0b..d2e3db6e4b3 100644 --- a/gcc/java/typeck.c +++ b/gcc/java/typeck.c @@ -305,7 +305,7 @@ build_java_array_type (tree element_type, HOST_WIDE_INT length) FIELD_DECL, get_identifier ("data"), atype); DECL_CONTEXT (arfld) = t; DECL_CHAIN (fld) = arfld; - DECL_ALIGN (arfld) = TYPE_ALIGN (element_type); + SET_DECL_ALIGN (arfld, TYPE_ALIGN (element_type)); /* We could layout_class, but that loads java.lang.Object prematurely. * This is called by the parser, and it is a bad idea to do load_class diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index c940f202bae..3b3f0f5c616 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,7 @@ +2016-04-18 Michael Matz + + * objc-act.c (objc_build_struct): Use SET_DECL_ALIGN. + 2016-02-12 Jakub Jelinek * objc-act.c: Spelling fixes - behaviour -> behavior and diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 8109507c05e..48564572fa6 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -2115,7 +2115,7 @@ objc_build_struct (tree klass, tree fields, tree super_name) = size_binop (FLOOR_DIV_EXPR, convert (sizetype, DECL_SIZE (base)), size_int (BITS_PER_UNIT)); DECL_ARTIFICIAL (base) = 1; - DECL_ALIGN (base) = 1; + SET_DECL_ALIGN (base, 1); DECL_FIELD_CONTEXT (base) = s; #ifdef OBJCPLUS DECL_FIELD_IS_BASE (base) = 1; diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 7282cc8a382..50ad68ece77 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1445,12 +1445,12 @@ install_var_field (tree var, bool by_ref, int mask, omp_context *ctx, DECL_ABSTRACT_ORIGIN (field) = var; if (type == TREE_TYPE (var)) { - DECL_ALIGN (field) = DECL_ALIGN (var); + SET_DECL_ALIGN (field, DECL_ALIGN (var)); DECL_USER_ALIGN (field) = DECL_USER_ALIGN (var); TREE_THIS_VOLATILE (field) = TREE_THIS_VOLATILE (var); } else - DECL_ALIGN (field) = TYPE_ALIGN (type); + SET_DECL_ALIGN (field, TYPE_ALIGN (type)); if ((mask & 3) == 3) { @@ -1460,7 +1460,7 @@ install_var_field (tree var, bool by_ref, int mask, omp_context *ctx, sfield = build_decl (DECL_SOURCE_LOCATION (var), FIELD_DECL, DECL_NAME (var), type); DECL_ABSTRACT_ORIGIN (sfield) = var; - DECL_ALIGN (sfield) = DECL_ALIGN (field); + SET_DECL_ALIGN (sfield, DECL_ALIGN (field)); DECL_USER_ALIGN (sfield) = DECL_USER_ALIGN (field); TREE_THIS_VOLATILE (sfield) = TREE_THIS_VOLATILE (field); insert_field_into_struct (ctx->srecord_type, sfield); @@ -2153,7 +2153,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx, tree field = build_decl (OMP_CLAUSE_LOCATION (c), FIELD_DECL, NULL_TREE, ptr_type_node); - DECL_ALIGN (field) = TYPE_ALIGN (ptr_type_node); + SET_DECL_ALIGN (field, TYPE_ALIGN (ptr_type_node)); insert_field_into_struct (ctx->record_type, field); splay_tree_insert (ctx->field_map, (splay_tree_key) decl, (splay_tree_value) field); @@ -2804,18 +2804,18 @@ finish_taskreg_scan (omp_context *ctx) TREE_TYPE (field) = build_pointer_type (TREE_TYPE (decl)); TREE_THIS_VOLATILE (field) = 0; DECL_USER_ALIGN (field) = 0; - DECL_ALIGN (field) = TYPE_ALIGN (TREE_TYPE (field)); + SET_DECL_ALIGN (field, TYPE_ALIGN (TREE_TYPE (field))); if (TYPE_ALIGN (ctx->record_type) < DECL_ALIGN (field)) - TYPE_ALIGN (ctx->record_type) = DECL_ALIGN (field); + SET_TYPE_ALIGN (ctx->record_type, DECL_ALIGN (field)); if (ctx->srecord_type) { tree sfield = lookup_sfield (decl, ctx); TREE_TYPE (sfield) = TREE_TYPE (field); TREE_THIS_VOLATILE (sfield) = 0; DECL_USER_ALIGN (sfield) = 0; - DECL_ALIGN (sfield) = DECL_ALIGN (field); + SET_DECL_ALIGN (sfield, DECL_ALIGN (field)); if (TYPE_ALIGN (ctx->srecord_type) < DECL_ALIGN (sfield)) - TYPE_ALIGN (ctx->srecord_type) = DECL_ALIGN (sfield); + SET_TYPE_ALIGN (ctx->srecord_type, DECL_ALIGN (sfield)); } } } @@ -18486,8 +18486,8 @@ omp_finish_file (void) num_vars * 2); tree funcs_decl_type = build_array_type_nelts (pointer_sized_int_node, num_funcs); - TYPE_ALIGN (vars_decl_type) = TYPE_ALIGN (pointer_sized_int_node); - TYPE_ALIGN (funcs_decl_type) = TYPE_ALIGN (pointer_sized_int_node); + SET_TYPE_ALIGN (vars_decl_type, TYPE_ALIGN (pointer_sized_int_node)); + SET_TYPE_ALIGN (funcs_decl_type, TYPE_ALIGN (pointer_sized_int_node)); tree ctor_v = build_constructor (vars_decl_type, v_v); tree ctor_f = build_constructor (funcs_decl_type, v_f); TREE_CONSTANT (ctor_v) = TREE_CONSTANT (ctor_f) = 1; @@ -18503,8 +18503,8 @@ omp_finish_file (void) otherwise a joint table in a binary will contain padding between tables from multiple object files. */ DECL_USER_ALIGN (funcs_decl) = DECL_USER_ALIGN (vars_decl) = 1; - DECL_ALIGN (funcs_decl) = TYPE_ALIGN (funcs_decl_type); - DECL_ALIGN (vars_decl) = TYPE_ALIGN (vars_decl_type); + SET_DECL_ALIGN (funcs_decl, TYPE_ALIGN (funcs_decl_type)); + SET_DECL_ALIGN (vars_decl, TYPE_ALIGN (vars_decl_type)); DECL_INITIAL (funcs_decl) = ctor_f; DECL_INITIAL (vars_decl) = ctor_v; set_decl_section_name (funcs_decl, OFFLOAD_FUNC_TABLE_SECTION_NAME); diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index d1738d280b3..5bae23bb4e5 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -579,7 +579,7 @@ do_type_align (tree type, tree decl) { if (TYPE_ALIGN (type) > DECL_ALIGN (decl)) { - DECL_ALIGN (decl) = TYPE_ALIGN (type); + SET_DECL_ALIGN (decl, TYPE_ALIGN (type)); if (TREE_CODE (decl) == FIELD_DECL) DECL_USER_ALIGN (decl) = TYPE_USER_ALIGN (type); } @@ -672,7 +672,7 @@ layout_decl (tree decl, unsigned int known_align) #ifdef EMPTY_FIELD_BOUNDARY if (EMPTY_FIELD_BOUNDARY > DECL_ALIGN (decl)) { - DECL_ALIGN (decl) = EMPTY_FIELD_BOUNDARY; + SET_DECL_ALIGN (decl, EMPTY_FIELD_BOUNDARY); DECL_USER_ALIGN (decl) = 0; } #endif @@ -694,7 +694,7 @@ layout_decl (tree decl, unsigned int known_align) && !(xalign > BITS_PER_UNIT && DECL_PACKED (decl)) && (known_align == 0 || known_align >= xalign)) { - DECL_ALIGN (decl) = MAX (xalign, DECL_ALIGN (decl)); + SET_DECL_ALIGN (decl, MAX (xalign, DECL_ALIGN (decl))); DECL_MODE (decl) = xmode; DECL_BIT_FIELD (decl) = 0; } @@ -719,7 +719,7 @@ layout_decl (tree decl, unsigned int known_align) DECL_USER_ALIGN, so we need to check old_user_align instead. */ if (packed_p && !old_user_align) - DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), BITS_PER_UNIT); + SET_DECL_ALIGN (decl, MIN (DECL_ALIGN (decl), BITS_PER_UNIT)); if (! packed_p && ! DECL_USER_ALIGN (decl)) { @@ -727,11 +727,11 @@ layout_decl (tree decl, unsigned int known_align) to a lower boundary than alignment of variables unless it was overridden by attribute aligned. */ #ifdef BIGGEST_FIELD_ALIGNMENT - DECL_ALIGN (decl) - = MIN (DECL_ALIGN (decl), (unsigned) BIGGEST_FIELD_ALIGNMENT); + SET_DECL_ALIGN (decl, MIN (DECL_ALIGN (decl), + (unsigned) BIGGEST_FIELD_ALIGNMENT)); #endif #ifdef ADJUST_FIELD_ALIGN - DECL_ALIGN (decl) = ADJUST_FIELD_ALIGN (decl, DECL_ALIGN (decl)); + SET_DECL_ALIGN (decl, ADJUST_FIELD_ALIGN (decl, DECL_ALIGN (decl))); #endif } @@ -741,7 +741,7 @@ layout_decl (tree decl, unsigned int known_align) mfa = maximum_field_alignment; /* Should this be controlled by DECL_USER_ALIGN, too? */ if (mfa != 0) - DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), mfa); + SET_DECL_ALIGN (decl, MIN (DECL_ALIGN (decl), mfa)); } /* Evaluate nonconstant size only once, either now or as soon as safe. */ @@ -791,7 +791,7 @@ relayout_decl (tree decl) DECL_SIZE (decl) = DECL_SIZE_UNIT (decl) = 0; DECL_MODE (decl) = VOIDmode; if (!DECL_USER_ALIGN (decl)) - DECL_ALIGN (decl) = 0; + SET_DECL_ALIGN (decl, 0); SET_DECL_RTL (decl, 0); layout_decl (decl, 0); @@ -1572,10 +1572,10 @@ finalize_record_size (record_layout_info rli) /* Determine the desired alignment. */ #ifdef ROUND_TYPE_ALIGN - TYPE_ALIGN (rli->t) = ROUND_TYPE_ALIGN (rli->t, TYPE_ALIGN (rli->t), - rli->record_align); + SET_TYPE_ALIGN (rli->t, ROUND_TYPE_ALIGN (rli->t, TYPE_ALIGN (rli->t), + rli->record_align)); #else - TYPE_ALIGN (rli->t) = MAX (TYPE_ALIGN (rli->t), rli->record_align); + SET_TYPE_ALIGN (rli->t, MAX (TYPE_ALIGN (rli->t), rli->record_align)); #endif /* Compute the size so far. Be sure to allow for extra bits in the @@ -1732,15 +1732,15 @@ finalize_type_size (tree type) alignment of one of the fields. */ if (mode_align >= TYPE_ALIGN (type)) { - TYPE_ALIGN (type) = mode_align; + SET_TYPE_ALIGN (type, mode_align); TYPE_USER_ALIGN (type) = 0; } } /* Do machine-dependent extra alignment. */ #ifdef ROUND_TYPE_ALIGN - TYPE_ALIGN (type) - = ROUND_TYPE_ALIGN (type, TYPE_ALIGN (type), BITS_PER_UNIT); + SET_TYPE_ALIGN (type, + ROUND_TYPE_ALIGN (type, TYPE_ALIGN (type), BITS_PER_UNIT)); #endif /* If we failed to find a simple way to calculate the unit size @@ -1793,7 +1793,7 @@ finalize_type_size (tree type) valign = MAX (valign, TYPE_ALIGN (variant)); else TYPE_USER_ALIGN (variant) = user_align; - TYPE_ALIGN (variant) = valign; + SET_TYPE_ALIGN (variant, valign); TYPE_PRECISION (variant) = precision; SET_TYPE_MODE (variant, mode); } @@ -2087,7 +2087,7 @@ finish_builtin_struct (tree type, const char *name, tree fields, if (align_type) { - TYPE_ALIGN (type) = TYPE_ALIGN (align_type); + SET_TYPE_ALIGN (type, TYPE_ALIGN (align_type)); TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (align_type); } @@ -2200,7 +2200,7 @@ layout_type (tree type) Instead, query a target hook, defaulting to natural alignment. This prevents ABI changes depending on whether or not native vector modes are supported. */ - TYPE_ALIGN (type) = targetm.vector_alignment (type); + SET_TYPE_ALIGN (type, targetm.vector_alignment (type)); /* However, if the underlying mode requires a bigger alignment than what the target hook provides, we cannot use the mode. For now, @@ -2212,7 +2212,7 @@ layout_type (tree type) case VOID_TYPE: /* This is an incomplete type and so doesn't have a size. */ - TYPE_ALIGN (type) = 1; + SET_TYPE_ALIGN (type, 1); TYPE_USER_ALIGN (type) = 0; SET_TYPE_MODE (type, VOIDmode); break; @@ -2337,7 +2337,7 @@ layout_type (tree type) #else align = MAX (align, BITS_PER_UNIT); #endif - TYPE_ALIGN (type) = align; + SET_TYPE_ALIGN (type, align); SET_TYPE_MODE (type, BLKmode); if (TYPE_SIZE (type) != 0 && ! targetm.member_type_forces_blk (type, VOIDmode) @@ -2609,13 +2609,13 @@ initialize_sizetypes (void) /* Now layout both types manually. */ SET_TYPE_MODE (sizetype, smallest_mode_for_size (precision, MODE_INT)); - TYPE_ALIGN (sizetype) = GET_MODE_ALIGNMENT (TYPE_MODE (sizetype)); + SET_TYPE_ALIGN (sizetype, GET_MODE_ALIGNMENT (TYPE_MODE (sizetype))); TYPE_SIZE (sizetype) = bitsize_int (precision); TYPE_SIZE_UNIT (sizetype) = size_int (GET_MODE_SIZE (TYPE_MODE (sizetype))); set_min_and_max_values_for_integral_type (sizetype, precision, UNSIGNED); SET_TYPE_MODE (bitsizetype, smallest_mode_for_size (bprecision, MODE_INT)); - TYPE_ALIGN (bitsizetype) = GET_MODE_ALIGNMENT (TYPE_MODE (bitsizetype)); + SET_TYPE_ALIGN (bitsizetype, GET_MODE_ALIGNMENT (TYPE_MODE (bitsizetype))); TYPE_SIZE (bitsizetype) = bitsize_int (bprecision); TYPE_SIZE_UNIT (bitsizetype) = size_int (GET_MODE_SIZE (TYPE_MODE (bitsizetype))); diff --git a/gcc/symtab.c b/gcc/symtab.c index e69dc1789f0..9bf33273fe1 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -2153,7 +2153,7 @@ increase_alignment_1 (symtab_node *n, void *v) if (DECL_ALIGN (n->decl) < align && n->can_increase_alignment_p ()) { - DECL_ALIGN (n->decl) = align; + SET_DECL_ALIGN (n->decl, align); DECL_USER_ALIGN (n->decl) = 1; } return false; diff --git a/gcc/targhooks.c b/gcc/targhooks.c index a34227705d2..6b4601b719a 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1856,7 +1856,7 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, if (boundary < TYPE_ALIGN (type)) { type = build_variant_type_copy (type); - TYPE_ALIGN (type) = boundary; + SET_TYPE_ALIGN (type, boundary); } /* Compute the rounded size of the type. */ diff --git a/gcc/tree-core.h b/gcc/tree-core.h index 41c1a9bd329..0d48ff59d52 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1441,7 +1441,13 @@ struct GTY(()) tree_type_common { unsigned lang_flag_5 : 1; unsigned lang_flag_6 : 1; - unsigned int align; + /* TYPE_ALIGN in log2; this has to be large enough to hold values + of the maximum of BIGGEST_ALIGNMENT and MAX_OFILE_ALIGNMENT, + the latter being usually the larger. For ELF it is 8<<28, + so we need to store the value 32 (not 31, as we need the zero + as well), hence six bits. */ + unsigned align : 6; + unsigned spare : 26; alias_set_type alias_set; tree pointer_to; tree reference_to; @@ -1542,12 +1548,12 @@ struct GTY(()) tree_decl_common { unsigned decl_nonshareable_flag : 1; /* DECL_OFFSET_ALIGN, used only for FIELD_DECLs. */ - unsigned int off_align : 8; - - /* 24 bits unused. */ + unsigned int off_align : 6; /* DECL_ALIGN. It should have the same size as TYPE_ALIGN. */ - unsigned int align; + unsigned int align : 6; + + /* 20 bits unused. */ /* UID for points-to sets, stable over copying from inlining. */ unsigned int pt_uid; diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 8563687e9e5..25a92aaa04b 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -192,7 +192,7 @@ insert_field_into_struct (tree type, tree field) /* Set correct alignment for frame struct type. */ if (TYPE_ALIGN (type) < DECL_ALIGN (field)) - TYPE_ALIGN (type) = DECL_ALIGN (field); + SET_TYPE_ALIGN (type, DECL_ALIGN (field)); } /* Build or return the RECORD_TYPE that describes the frame state that is @@ -275,14 +275,14 @@ lookup_field_for_decl (struct nesting_info *info, tree decl, if (use_pointer_in_frame (decl)) { TREE_TYPE (field) = build_pointer_type (TREE_TYPE (decl)); - DECL_ALIGN (field) = TYPE_ALIGN (TREE_TYPE (field)); + SET_DECL_ALIGN (field, TYPE_ALIGN (TREE_TYPE (field))); DECL_NONADDRESSABLE_P (field) = 1; } else { TREE_TYPE (field) = TREE_TYPE (decl); DECL_SOURCE_LOCATION (field) = DECL_SOURCE_LOCATION (decl); - DECL_ALIGN (field) = DECL_ALIGN (decl); + SET_DECL_ALIGN (field, DECL_ALIGN (decl)); DECL_USER_ALIGN (field) = DECL_USER_ALIGN (decl); TREE_ADDRESSABLE (field) = TREE_ADDRESSABLE (decl); DECL_NONADDRESSABLE_P (field) = !TREE_ADDRESSABLE (decl); @@ -361,7 +361,7 @@ get_chain_field (struct nesting_info *info) field = make_node (FIELD_DECL); DECL_NAME (field) = get_identifier ("__chain"); TREE_TYPE (field) = type; - DECL_ALIGN (field) = TYPE_ALIGN (type); + SET_DECL_ALIGN (field, TYPE_ALIGN (type)); DECL_NONADDRESSABLE_P (field) = 1; insert_field_into_struct (get_frame_type (info), field); @@ -474,7 +474,7 @@ get_trampoline_type (struct nesting_info *info) t = build_array_type (char_type_node, t); t = build_decl (DECL_SOURCE_LOCATION (info->context), FIELD_DECL, get_identifier ("__data"), t); - DECL_ALIGN (t) = align; + SET_DECL_ALIGN (t, align); DECL_USER_ALIGN (t) = 1; trampoline_type = make_node (RECORD_TYPE); @@ -548,7 +548,7 @@ get_nl_goto_field (struct nesting_info *info) field = make_node (FIELD_DECL); DECL_NAME (field) = get_identifier ("__nl_goto_buf"); TREE_TYPE (field) = type; - DECL_ALIGN (field) = TYPE_ALIGN (type); + SET_DECL_ALIGN (field, TYPE_ALIGN (type)); TREE_ADDRESSABLE (field) = 1; insert_field_into_struct (get_frame_type (info), field); diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index a501d2cf03f..2568a415eea 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -2114,7 +2114,7 @@ fold_builtin_alloca_with_align (gimple *stmt) n_elem = size * 8 / BITS_PER_UNIT; array_type = build_array_type_nelts (elem_type, n_elem); var = create_tmp_var (array_type); - DECL_ALIGN (var) = TREE_INT_CST_LOW (gimple_call_arg (stmt, 1)); + SET_DECL_ALIGN (var, TREE_INT_CST_LOW (gimple_call_arg (stmt, 1))); { struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs); if (pi != NULL && !pi->pt.anything) diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c index 91c72eb293e..2ad2f9212fa 100644 --- a/gcc/tree-streamer-in.c +++ b/gcc/tree-streamer-in.c @@ -230,10 +230,10 @@ unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) DECL_PRESERVE_P (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_EXTERNAL (expr) = (unsigned) bp_unpack_value (bp, 1); DECL_GIMPLE_REG_P (expr) = (unsigned) bp_unpack_value (bp, 1); - DECL_ALIGN (expr) = (unsigned) bp_unpack_var_len_unsigned (bp); + SET_DECL_ALIGN (expr, (unsigned) bp_unpack_var_len_unsigned (bp)); #ifdef ACCEL_COMPILER if (DECL_ALIGN (expr) > targetm.absolute_biggest_alignment) - DECL_ALIGN (expr) = targetm.absolute_biggest_alignment; + SET_DECL_ALIGN (expr, targetm.absolute_biggest_alignment); #endif if (TREE_CODE (expr) == LABEL_DECL) { @@ -378,10 +378,10 @@ unpack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr) else if (TREE_CODE (expr) == ARRAY_TYPE) TYPE_NONALIASED_COMPONENT (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_PRECISION (expr) = bp_unpack_var_len_unsigned (bp); - TYPE_ALIGN (expr) = bp_unpack_var_len_unsigned (bp); + SET_TYPE_ALIGN (expr, bp_unpack_var_len_unsigned (bp)); #ifdef ACCEL_COMPILER if (TYPE_ALIGN (expr) > targetm.absolute_biggest_alignment) - TYPE_ALIGN (expr) = targetm.absolute_biggest_alignment; + SET_TYPE_ALIGN (expr, targetm.absolute_biggest_alignment); #endif } diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index cd5afeafebd..5f054c53447 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -5131,7 +5131,7 @@ ensure_base_align (stmt_vec_info stmt_info, struct data_reference *dr) symtab_node::get (base_decl)->increase_alignment (TYPE_ALIGN (vectype)); else { - DECL_ALIGN (base_decl) = TYPE_ALIGN (vectype); + SET_DECL_ALIGN (base_decl, TYPE_ALIGN (vectype)); DECL_USER_ALIGN (base_decl) = 1; } DR_VECT_AUX (dr)->base_misaligned = false; diff --git a/gcc/tree.c b/gcc/tree.c index c64d7204acb..6de46a84695 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1020,11 +1020,11 @@ make_node_stat (enum tree_code code MEM_STAT_DECL) { if (code == FUNCTION_DECL) { - DECL_ALIGN (t) = FUNCTION_BOUNDARY; + SET_DECL_ALIGN (t, FUNCTION_BOUNDARY); DECL_MODE (t) = FUNCTION_MODE; } else - DECL_ALIGN (t) = 1; + SET_DECL_ALIGN (t, 1); } DECL_SOURCE_LOCATION (t) = input_location; if (TREE_CODE (t) == DEBUG_EXPR_DECL) @@ -1041,7 +1041,7 @@ make_node_stat (enum tree_code code MEM_STAT_DECL) case tcc_type: TYPE_UID (t) = next_type_uid++; - TYPE_ALIGN (t) = BITS_PER_UNIT; + SET_TYPE_ALIGN (t, BITS_PER_UNIT); TYPE_USER_ALIGN (t) = 0; TYPE_MAIN_VARIANT (t) = t; TYPE_CANONICAL (t) = t; @@ -6646,7 +6646,7 @@ build_qualified_type (tree type, int type_quals) /* Ensure the alignment of this type is compatible with the required alignment of the atomic type. */ if (TYPE_ALIGN (atomic_type) > TYPE_ALIGN (t)) - TYPE_ALIGN (t) = TYPE_ALIGN (atomic_type); + SET_TYPE_ALIGN (t, TYPE_ALIGN (atomic_type)); } } @@ -6685,7 +6685,7 @@ build_aligned_type (tree type, unsigned int align) return t; t = build_variant_type_copy (type); - TYPE_ALIGN (t) = align; + SET_TYPE_ALIGN (t, align); return t; } @@ -8135,7 +8135,7 @@ build_range_type_1 (tree type, tree lowval, tree highval, bool shared) SET_TYPE_MODE (itype, TYPE_MODE (type)); TYPE_SIZE (itype) = TYPE_SIZE (type); TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (type); - TYPE_ALIGN (itype) = TYPE_ALIGN (type); + SET_TYPE_ALIGN (itype, TYPE_ALIGN (type)); TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (type); if (!shared) @@ -10036,7 +10036,7 @@ build_atomic_base (tree type, unsigned int align) set_type_quals (t, TYPE_QUAL_ATOMIC); if (align) - TYPE_ALIGN (t) = align; + SET_TYPE_ALIGN (t, align); return t; } @@ -10185,7 +10185,7 @@ build_common_tree_nodes (bool signed_char) /* We are not going to have real types in C with less than byte alignment, so we might as well not have any types that claim to have it. */ - TYPE_ALIGN (void_type_node) = BITS_PER_UNIT; + SET_TYPE_ALIGN (void_type_node, BITS_PER_UNIT); TYPE_USER_ALIGN (void_type_node) = 0; void_node = make_node (VOID_CST); diff --git a/gcc/tree.h b/gcc/tree.h index 87e756390f6..33833a7abe6 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -916,10 +916,7 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, of this type is aligned at least to the alignment of the type, even if it doesn't appear that it is. We see this, for example, in object-oriented languages where a tag field may show this is an object of a more-aligned - variant of the more generic type. - - In an SSA_NAME node, nonzero if the SSA_NAME node is on the SSA_NAME - freelist. */ + variant of the more generic type. */ #define TYPE_ALIGN_OK(NODE) (TYPE_CHECK (NODE)->base.nothrow_flag) /* Used in classes in C++. */ @@ -1865,8 +1862,15 @@ extern machine_mode element_mode (const_tree t); #define TYPE_ATTRIBUTES(NODE) (TYPE_CHECK (NODE)->type_common.attributes) /* The alignment necessary for objects of this type. - The value is an int, measured in bits. */ -#define TYPE_ALIGN(NODE) (TYPE_CHECK (NODE)->type_common.align) + The value is an int, measured in bits and must be a power of two. + We support also an "alignement" of zero. */ +#define TYPE_ALIGN(NODE) \ + (TYPE_CHECK (NODE)->type_common.align \ + ? ((unsigned)1) << ((NODE)->type_common.align - 1) : 0) + +/* Specify that TYPE_ALIGN(NODE) is X. */ +#define SET_TYPE_ALIGN(NODE, X) \ + (TYPE_CHECK (NODE)->type_common.align = ffs_hwi (X)) /* 1 if the alignment for this type was requested by "aligned" attribute, 0 if it is the default for this type. */ @@ -2306,8 +2310,16 @@ extern machine_mode element_mode (const_tree t); #define DECL_SIZE(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.size) /* Likewise for the size in bytes. */ #define DECL_SIZE_UNIT(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.size_unit) -/* Holds the alignment required for the datum, in bits. */ -#define DECL_ALIGN(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.align) +/* Returns the alignment required for the datum, in bits. It must + be a power of two, but an "alignment" of zero is supported + (e.g. as "uninitialized" sentinel). */ +#define DECL_ALIGN(NODE) \ + (DECL_COMMON_CHECK (NODE)->decl_common.align \ + ? ((unsigned)1) << ((NODE)->decl_common.align - 1) : 0) +/* Specify that DECL_ALIGN(NODE) is X. */ +#define SET_DECL_ALIGN(NODE, X) \ + (DECL_COMMON_CHECK (NODE)->decl_common.align = ffs_hwi (X)) + /* The alignment of NODE, in bytes. */ #define DECL_ALIGN_UNIT(NODE) (DECL_ALIGN (NODE) / BITS_PER_UNIT) /* Set if the alignment of this DECL has been set by the user, for @@ -2510,7 +2522,7 @@ extern void decl_value_expr_insert (tree, tree); #define DECL_OFFSET_ALIGN(NODE) \ (((unsigned HOST_WIDE_INT)1) << FIELD_DECL_CHECK (NODE)->decl_common.off_align) -/* Specify that DECL_ALIGN(NODE) is a multiple of X. */ +/* Specify that DECL_OFFSET_ALIGN(NODE) is X. */ #define SET_DECL_OFFSET_ALIGN(NODE, X) \ (FIELD_DECL_CHECK (NODE)->decl_common.off_align = ffs_hwi (X) - 1) diff --git a/gcc/varasm.c b/gcc/varasm.c index b0f2af03de4..d71defac590 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1053,7 +1053,7 @@ align_variable (tree decl, bool dont_output_data) /* Reset the alignment in case we have made it tighter, so we can benefit from it in get_pointer_alignment. */ - DECL_ALIGN (decl) = align; + SET_DECL_ALIGN (decl, align); } /* Return DECL_ALIGN (decl), possibly increased for optimization purposes @@ -2187,8 +2187,8 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, && asan_protect_global (decl)) { asan_protected = true; - DECL_ALIGN (decl) = MAX (DECL_ALIGN (decl), - ASAN_RED_ZONE_SIZE * BITS_PER_UNIT); + SET_DECL_ALIGN (decl, MAX (DECL_ALIGN (decl), + ASAN_RED_ZONE_SIZE * BITS_PER_UNIT)); } set_mem_align (decl_rtl, DECL_ALIGN (decl)); @@ -3249,7 +3249,7 @@ build_constant_desc (tree exp) architectures so use DATA_ALIGNMENT as well, except for strings. */ if (TREE_CODE (exp) == STRING_CST) { - DECL_ALIGN (decl) = CONSTANT_ALIGNMENT (exp, DECL_ALIGN (decl)); + SET_DECL_ALIGN (decl, CONSTANT_ALIGNMENT (exp, DECL_ALIGN (decl))); } else align_variable (decl, 0); @@ -3404,8 +3404,8 @@ output_constant_def_contents (rtx symbol) && asan_protect_global (exp)) { asan_protected = true; - DECL_ALIGN (decl) = MAX (DECL_ALIGN (decl), - ASAN_RED_ZONE_SIZE * BITS_PER_UNIT); + SET_DECL_ALIGN (decl, MAX (DECL_ALIGN (decl), + ASAN_RED_ZONE_SIZE * BITS_PER_UNIT)); } /* If the constant is part of an object block, make sure that the diff --git a/libcc1/ChangeLog b/libcc1/ChangeLog index a65af09c6e6..1ce7671b201 100644 --- a/libcc1/ChangeLog +++ b/libcc1/ChangeLog @@ -1,3 +1,7 @@ +2016-04-18 Michael Matz + + * plugin.cc (plugin_finish_record_or_union): Use SET_TYPE_ALIGN. + 2016-04-11 Segher Boessenkool PR bootstrap/70173 @@ -60,7 +64,7 @@ * configure.ac (libcc1_cv_lib_sockets): Check for -lsocket -lnsl. * configure: Regenerate. * connection.cc: Include . - * libcc1.cc (libcc1_compile): Use AF_UNIX instead of AF_LOCAL. + * libcc1.cc (libcc1_compile): Use AF_UNIX instead of AF_LOCAL. 2014-11-11 Francois-Xavier Coudert diff --git a/libcc1/plugin.cc b/libcc1/plugin.cc index 57fca7c9a7b..44d0d607022 100644 --- a/libcc1/plugin.cc +++ b/libcc1/plugin.cc @@ -553,8 +553,8 @@ plugin_finish_record_or_union (cc1_plugin::connection *, { // FIXME there's no way to get this from DWARF, // or even, it seems, a particularly good way to deduce it. - TYPE_ALIGN (record_or_union_type) - = TYPE_PRECISION (pointer_sized_int_node); + SET_TYPE_ALIGN (record_or_union_type, + TYPE_PRECISION (pointer_sized_int_node)); TYPE_SIZE (record_or_union_type) = bitsize_int (size_in_bytes * BITS_PER_UNIT);