aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
AgeCommit message (Collapse)AuthorFilesLines
2017-09-21Fix unguarded uses of tree_to_uhwiRichard Sandiford1-3/+2
This patch uses tree_fits_uhwi_p to protect a previously unguarded use of tree_to_uhwi. Previously we would ICE for variable-sized types. 2017-09-20 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.c (find_atomic_core_type): Check tree_fits_uhwi_p before calling tree_to_uhwi. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r253057
2017-09-14Use vec<> in build_vectorRichard Sandiford1-12/+15
This patch makes build_vector take the elements as a vec<> rather than a tree *. This is useful for SVE because it bundles the number of elements with the elements themselves, and enforces the fact that the number is constant. Also, I think things like the folds can be used with any generic GNU vector, not just those that match machine vectors, so the arguments to XALLOCAVEC had no clear limit. 2017-09-14 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (build_vector): Take a vec<tree> instead of a tree *. * tree.c (build_vector): Likewise. (build_vector_from_ctor): Update accordingly. (build_vector_from_val): Likewise. * gimple-fold.c (gimple_fold_stmt_to_constant_1): Likewise. * tree-ssa-forwprop.c (simplify_vector_constructor): Likewise. * tree-vect-generic.c (add_rshift): Likewise. (expand_vector_divmod): Likewise. (optimize_vector_constructor): Likewise. * tree-vect-slp.c (vect_get_constant_vectors): Likewise. (vect_transform_slp_perm_load): Likewise. (vect_schedule_slp_instance): Likewise. * tree-vect-stmts.c (vectorizable_bswap): Likewise. (vectorizable_call): Likewise. (vect_gen_perm_mask_any): Likewise. Add elements in order. * expmed.c (make_tree): Likewise. * fold-const.c (fold_negate_expr_1): Use auto_vec<tree> when building a vector passed to build_vector. (fold_convert_const): Likewise. (exact_inverse): Likewise. (fold_ternary_loc): Likewise. (fold_relational_const): Likewise. (const_binop): Likewise. Use VECTOR_CST_ELT directly when operating on VECTOR_CSTs, rather than going through vec_cst_ctor_to_array. (const_unop): Likewise. Store the reduction accumulator in a variable rather than an array. (vec_cst_ctor_to_array): Take the number of elements as a parameter. (fold_vec_perm): Update calls accordingly. Use auto_vec<tree> for the new vector, rather than constructing it after the input arrays. (native_interpret_vector): Use auto_vec<tree> when building a vector passed to build_vector. Add elements in order. * tree-vect-loop.c (get_initial_defs_for_reduction): Use auto_vec<tree> when building a vector passed to build_vector. (vect_create_epilog_for_reduction): Likewise. (vectorizable_induction): Likewise. (get_initial_def_for_reduction): Likewise. Fix indentation of case statements. * config/sparc/sparc.c (sparc_handle_vis_mul8x16): Change n_elts to a vec<tree> *. (sparc_fold_builtin): Use auto_vec<tree> when building a vector passed to build_vector. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r252760
2017-09-14Store VECTOR_CST_NELTS directly in tree_nodeRichard Sandiford1-1/+2
Previously VECTOR_CST_NELTS (t) read the number of elements from TYPE_VECTOR_SUBPARTS (TREE_TYPE (t)). There were two ways of handling this with variable TYPE_VECTOR_SUBPARTS: either forcibly convert the number to a constant (which is doable) or store the number directly in the VECTOR_CST. The latter seemed better, since it involves less pointer chasing and since the tree_node u field is otherwise unused for VECTOR_CST. It would still be easy to switch to the former in future if we need to free up the field for someting else. The patch also changes various bits of VECTOR_CST code to use VECTOR_CST_NELTS instead of TYPE_VECTOR_SUBPARTS when iterating over VECTOR_CST_ELTs. Also, when the two are checked for equality, the patch prefers to read VECTOR_CST_NELTS (which must be constant) and check against TYPE_VECTOR_SUBPARTS, instead of the other way around. 2017-09-14 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree-core.h (tree_base::u): Add an "nelts" field. (tree_vector): Use VECTOR_CST_NELTS as the length. * tree.c (tree_size): Likewise. (make_vector): Initialize VECTOR_CST_NELTS. * tree.h (VECTOR_CST_NELTS): Use the u.nelts field. * cfgexpand.c (expand_debug_expr): Use VECTOR_CST_NELTS instead of TYPE_VECTOR_SUBPARTS. * expr.c (const_vector_mask_from_tree): Consistently use "units" as the number of units, setting it from VECTOR_CST_NELTS. (const_vector_from_tree): Likewise. * fold-const.c (negate_expr_p): Use VECTOR_CST_NELTS instead of TYPE_VECTOR_SUBPARTS for the number of elements in a VECTOR_CST. (fold_negate_expr_1): Likewise. (fold_convert_const): Likewise. (const_binop): Likewise. Differentiate the number of output and input elements. (const_unop): Likewise. (fold_ternary_loc): Use VECTOR_CST_NELTS for the number of elements in a VECTOR_CST, asserting that it is the same as TYPE_VECTOR_SUBPARTS in cases that did the opposite. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r252758
2017-09-08PR c++/70029 - ICE with ref-qualifier and -fltoJason Merrill1-3/+1
PR c++/70029 - ICE with ref-qualifier and -flto gcc/ * langhooks.h (struct lang_hooks_for_types): Add copy_lang_qualifiers. * attribs.c (build_type_attribute_qual_variant): Use it. * langhooks-def.h (LANG_HOOKS_COPY_LANG_QUALIFIERS): Default to NULL. (LANG_HOOKS_FOR_TYPES_INITIALIZER): Use it. * tree.c (verify_type): Re-enable TYPE_CANONICAL main variant check. gcc/cp/ * tree.c (cxx_copy_lang_qualifiers): New. * cp-tree.h: Declare it. * cp-objcp-common.h: Define LANG_HOOKS_COPY_LANG_QUALIFIERS. From-SVN: r251911
2017-09-05Make targetm.get_mask_mode return an opt_modeRichard Sandiford1-4/+2
...for consistency with mode_for_vector. 2017-09-05 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * target.def (get_mask_mode): Change return type to opt_mode. Expand commentary. * doc/tm.texi: Regenerate. * targhooks.h (default_get_mask_mode): Return an opt_mode. * targhooks.c (default_get_mask_mode): Likewise. * config/i386/i386.c (ix86_get_mask_mode): Likewise. * optabs-query.c (can_vec_mask_load_store_p): Update use of targetm.get_mask_mode. * tree.c (build_truth_vector_type): Likewise. From-SVN: r251731
2017-08-30[65/77] Add a SCALAR_TYPE_MODE macroRichard Sandiford1-2/+3
This patch adds a SCALAR_TYPE_MODE macro, along the same lines as SCALAR_INT_TYPE_MODE and SCALAR_FLOAT_TYPE_MODE. It also adds two instances of as_a <scalar_mode> to c_common_type, when converting an unsigned fixed-point SCALAR_TYPE_MODE to the equivalent signed mode. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (SCALAR_TYPE_MODE): New macro. * expr.c (expand_expr_addr_expr_1): Use it. (expand_expr_real_2): Likewise. * fold-const.c (fold_convert_const_fixed_from_fixed): Likeise. (fold_convert_const_fixed_from_int): Likewise. (fold_convert_const_fixed_from_real): Likewise. (native_encode_fixed): Likewise (native_encode_complex): Likewise (native_encode_vector): Likewise. (native_interpret_fixed): Likewise. (native_interpret_real): Likewise. (native_interpret_complex): Likewise. (native_interpret_vector): Likewise. * omp-simd-clone.c (simd_clone_adjust_return_type): Likewise. (simd_clone_adjust_argument_types): Likewise. (simd_clone_init_simd_arrays): Likewise. (simd_clone_adjust): Likewise. * stor-layout.c (layout_type): Likewise. * tree.c (build_minus_one_cst): Likewise. * tree-cfg.c (verify_gimple_assign_ternary): Likewise. * tree-inline.c (estimate_move_cost): Likewise. * tree-ssa-math-opts.c (convert_plusminus_to_widen): Likewise. * tree-vect-loop.c (vect_create_epilog_for_reduction): Likewise. (vectorizable_reduction): Likewise. * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Likewise. (vect_recog_mixed_size_cond_pattern): Likewise. (check_bool_pattern): Likewise. (adjust_bool_pattern): Likewise. (search_type_for_mask_1): Likewise. * tree-vect-slp.c (vect_schedule_slp_instance): Likewise. * tree-vect-stmts.c (vectorizable_conversion): Likewise. (vectorizable_load): Likewise. (vectorizable_store): Likewise. * ubsan.c (ubsan_encode_value): Likewise. * varasm.c (output_constant): Likewise. gcc/c-family/ * c-lex.c (interpret_fixed): Use SCALAR_TYPE_MODE. * c-common.c (c_build_vec_perm_expr): Likewise. gcc/c/ * c-typeck.c (build_binary_op): Use SCALAR_TYPE_MODE. (c_common_type): Likewise. Use as_a <scalar_mode> when setting m1 and m2 to the signed equivalent of a fixed-point SCALAR_TYPE_MODE. gcc/cp/ * typeck.c (cp_build_binary_op): Use SCALAR_TYPE_MODE. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251516
2017-08-30[35/77] Add uses of as_a <scalar_int_mode>Richard Sandiford1-5/+4
This patch adds asserting as_a <scalar_int_mode> conversions to contexts in which the input is known to be a scalar integer mode. In expand_divmod, op1 is always a scalar_int_mode if op1_is_constant (but might not be otherwise). In expand_binop, the patch reverses a < comparison in order to avoid splitting a long line. gcc/ 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> * cfgexpand.c (convert_debug_memory_address): Use as_a <scalar_int_mode>. * combine.c (expand_compound_operation): Likewise. (make_extraction): Likewise. (change_zero_ext): Likewise. (simplify_comparison): Likewise. * cse.c (cse_insn): Likewise. * dwarf2out.c (minmax_loc_descriptor): Likewise. (mem_loc_descriptor): Likewise. (loc_descriptor): Likewise. * expmed.c (init_expmed_one_mode): Likewise. (synth_mult): Likewise. (emit_store_flag_1): Likewise. (expand_divmod): Likewise. Use HWI_COMPUTABLE_MODE_P instead of a comparison with size. * expr.c (expand_assignment): Use as_a <scalar_int_mode>. (reduce_to_bit_field_precision): Likewise. * function.c (expand_function_end): Likewise. * internal-fn.c (expand_arith_overflow_result_store): Likewise. * loop-doloop.c (doloop_modify): Likewise. * optabs.c (expand_binop): Likewise. (expand_unop): Likewise. (expand_copysign_absneg): Likewise. (prepare_cmp_insn): Likewise. (maybe_legitimize_operand): Likewise. * recog.c (const_scalar_int_operand): Likewise. * rtlanal.c (get_address_mode): Likewise. * simplify-rtx.c (simplify_unary_operation_1): Likewise. (simplify_cond_clz_ctz): Likewise. * tree-nested.c (get_nl_goto_field): Likewise. * tree.c (build_vector_type_for_mode): Likewise. * var-tracking.c (use_narrower_mode): Likewise. gcc/c-family/ 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> * c-common.c (c_common_type_for_mode): Use as_a <scalar_int_mode>. gcc/lto/ 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> * lto-lang.c (lto_type_for_mode): Use as_a <scalar_int_mode>. From-SVN: r251487
2017-08-30[34/77] Add a SCALAR_INT_TYPE_MODE macroRichard Sandiford1-1/+1
This patch adds a SCALAR_INT_TYPE_MODE macro that asserts that the type has a scalar integer mode and returns it as a scalar_int_mode. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (SCALAR_INT_TYPE_MODE): New macro. * builtins.c (expand_builtin_signbit): Use it. * cfgexpand.c (expand_debug_expr): Likewise. * dojump.c (do_jump): Likewise. (do_compare_and_jump): Likewise. * dwarf2cfi.c (expand_builtin_init_dwarf_reg_sizes): Likewise. * expmed.c (make_tree): Likewise. * expr.c (expand_expr_real_2): Likewise. (expand_expr_real_1): Likewise. (try_casesi): Likewise. * fold-const-call.c (fold_const_call_ss): Likewise. * fold-const.c (unextend): Likewise. (extract_muldiv_1): Likewise. (fold_single_bit_test): Likewise. (native_encode_int): Likewise. (native_encode_string): Likewise. (native_interpret_int): Likewise. * gimple-fold.c (gimple_fold_builtin_memset): Likewise. * internal-fn.c (expand_addsub_overflow): Likewise. (expand_neg_overflow): Likewise. (expand_mul_overflow): Likewise. (expand_arith_overflow): Likewise. * match.pd: Likewise. * stor-layout.c (layout_type): Likewise. * tree-cfg.c (verify_gimple_assign_ternary): Likewise. * tree-ssa-math-opts.c (convert_mult_to_widen): Likewise. * tree-ssanames.c (get_range_info): Likewise. * tree-switch-conversion.c (array_value_type) Likewise. * tree-vect-patterns.c (vect_recog_rotate_pattern): Likewise. (vect_recog_divmod_pattern): Likewise. (vect_recog_mixed_size_cond_pattern): Likewise. * tree-vrp.c (extract_range_basic): Likewise. (simplify_float_conversion_using_ranges): Likewise. * tree.c (int_fits_type_p): Likewise. * ubsan.c (instrument_bool_enum_load): Likewise. * varasm.c (mergeable_string_section): Likewise. (narrowing_initializer_constant_valid_p): Likewise. (output_constant): Likewise. gcc/cp/ * cvt.c (cp_convert_to_pointer): Use SCALAR_INT_TYPE_MODE. gcc/fortran/ * target-memory.c (size_integer): Use SCALAR_INT_TYPE_MODE. (size_logical): Likewise. gcc/objc/ * objc-encoding.c (encode_type): Use SCALAR_INT_TYPE_MODE. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251486
2017-08-30[20/77] Replace MODE_INT checks with is_int_modeRichard Sandiford1-2/+2
Replace checks of "GET_MODE_CLASS (...) == MODE_INT" with "is_int_mode (..., &var)", in cases where it becomes useful to refer to the mode as a scalar_int_mode. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * machmode.h (is_int_mode): New fuction. * combine.c (find_split_point): Use it. (combine_simplify_rtx): Likewise. (simplify_if_then_else): Likewise. (simplify_set): Likewise. (simplify_shift_const_1): Likewise. (simplify_comparison): Likewise. * config/aarch64/aarch64.c (aarch64_rtx_costs): Likewise. * cse.c (notreg_cost): Likewise. (cse_insn): Likewise. * cselib.c (cselib_lookup_1): Likewise. * dojump.c (do_jump_1): Likewise. (do_compare_rtx_and_jump): Likewise. * dse.c (get_call_args): Likewise. * dwarf2out.c (rtl_for_decl_init): Likewise. (native_encode_initializer): Likewise. * expmed.c (emit_store_flag_1): Likewise. (emit_store_flag): Likewise. * expr.c (convert_modes): Likewise. (store_field): Likewise. (expand_expr_real_1): Likewise. * fold-const.c (fold_read_from_constant_string): Likewise. * gimple-ssa-sprintf.c (get_format_string): Likewise. * optabs-libfuncs.c (gen_int_libfunc): Likewise. * optabs.c (expand_binop): Likewise. (expand_unop): Likewise. (expand_abs_nojump): Likewise. (expand_one_cmpl_abs_nojump): Likewise. * simplify-rtx.c (mode_signbit_p): Likewise. (val_signbit_p): Likewise. (val_signbit_known_set_p): Likewise. (val_signbit_known_clear_p): Likewise. (simplify_relational_operation_1): Likewise. * tree.c (vector_type_mode): Likewise. gcc/go/ * go-lang.c (go_langhook_type_for_mode): Use is_int_mode. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251472
2017-08-30[17/77] Add an int_mode_for_size helper functionRichard Sandiford1-4/+5
This patch adds a wrapper around mode_for_size for cases in which the mode class is MODE_INT (the commonest case). The return type can then be an opt_scalar_int_mode instead of a machine_mode. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * machmode.h (int_mode_for_size): New function. * builtins.c (set_builtin_user_assembler_name): Use int_mode_for_size instead of mode_for_size. * calls.c (save_fixed_argument_area): Likewise. Make use of BLKmode explicit. * combine.c (expand_field_assignment): Use int_mode_for_size instead of mode_for_size. (make_extraction): Likewise. (simplify_shift_const_1): Likewise. (simplify_comparison): Likewise. * dojump.c (do_jump): Likewise. * dwarf2out.c (mem_loc_descriptor): Likewise. * emit-rtl.c (init_derived_machine_modes): Likewise. * expmed.c (flip_storage_order): Likewise. (convert_extracted_bit_field): Likewise. * expr.c (copy_blkmode_from_reg): Likewise. * graphite-isl-ast-to-gimple.c (max_mode_int_precision): Likewise. * internal-fn.c (expand_mul_overflow): Likewise. * lower-subreg.c (simple_move): Likewise. * optabs-libfuncs.c (init_optabs): Likewise. * simplify-rtx.c (simplify_unary_operation_1): Likewise. * tree.c (vector_type_mode): Likewise. * tree-ssa-strlen.c (handle_builtin_memcmp): Likewise. * tree-vect-data-refs.c (vect_lanes_optab_supported_p): Likewise. * tree-vect-generic.c (expand_vector_parallel): Likewise. * tree-vect-stmts.c (vectorizable_load): Likewise. (vectorizable_store): Likewise. gcc/ada/ * gcc-interface/decl.c (gnat_to_gnu_entity): Use int_mode_for_size instead of mode_for_size. (gnat_to_gnu_subprog_type): Likewise. * gcc-interface/utils.c (make_type_from_size): Likewise. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251469
2017-08-30[13/77] Make floatn_mode return an opt_scalar_float_modeRichard Sandiford1-2/+2
As per subject. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * target.def (default_floatn_mode): Return an opt_scalar_float_mode. * doc/tm.texi: Regenerate. * config/arm/arm.c (arm_floatn_mode): Return an opt_scalar_float_mode. * config/powerpcspe/powerpcspe.c (rs6000_floatn_mode): Likewise. * config/rs6000/rs6000.c (rs6000_floatn_mode): Likewise. * targhooks.h (default_floatn_mode): Likewise. * targhooks.c (default_floatn_mode): Likewise. * tree.c (build_common_tree_nodes): Update accordingly. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251465
2017-08-21Move vector_type_mode to tree.cRichard Sandiford1-2/+42
...so that it's possible to use TYPE_MODE in tree.h. 2017-08-21 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * stor-layout.h (vector_type_mode): Move to... * tree.h (vector_type_mode): ...here. * stor-layout.c (vector_type_mode): Move to... * tree.c (vector_type_mode): ...here. Include rtl.h and regs.h. From-SVN: r251221
2017-08-21re PR go/78628 (GO fails to build a translation unit decl)Richard Biener1-1/+13
2017-08-21 Richard Biener <rguenther@suse.de> include/ * simple-object.h (simple_object_copy_lto_debug_sections): New function. libiberty/ * simple-object-common.h (struct simple_object_functions): Add copy_lto_debug_sections hook. * simple-object.c: Include fcntl.h. (handle_lto_debug_sections): New helper function. (simple_object_copy_lto_debug_sections): New function copying early LTO debug sections to regular debug sections in a new file. (simple_object_start_write): Handle NULL segment_name. * simple-object-coff.c (simple_object_coff_functions): Adjust for not implemented copy_lto_debug_sections hook. * simple-object-mach-o.c (simple_object_mach_o_functions): Likewise. * simple-object-xcoff.c (simple_object_xcoff_functions): Likewise. * simple-object-elf.c (SHT_NULL, SHT_SYMTAB, SHT_RELA, SHT_REL, SHT_GROUP): Add various sectopn header types. (SHF_EXCLUDE): Add flag. (Elf32_External_Sym, Elf64_External_Sym): Add symbol struct. (ELF_ST_BIND, ELF_ST_TYPE, ELF_ST_INFO): Add accessors. (STT_OBJECT, STT_FUNC, STT_TLS, STT_GNU_IFUNC): Add Symbol types. (STV_DEFAULT): Add symbol visibility. (SHN_COMMON): Add special section index name. (struct simple_object_elf_write): New. (simple_object_elf_start_write): Adjust for new private data. (simple_object_elf_write_shdr): Pass in values for all fields we write. (simple_object_elf_write_to_file): Adjust. Copy from recorded section headers if requested. (simple_object_elf_release_write): Release private data. (simple_object_elf_copy_lto_debug_sections): Copy and rename sections as denoted by PFN and all their dependences, symbols and relocations to the empty destination file. (simple_object_elf_functions): Adjust for copy_lto_debug_sections hook. gcc/ * debug.h (struct gcc_debug_hooks): Add die_ref_for_decl and register_external_die hooks. (debug_false_tree_charstarstar_uhwistar): Declare. (debug_nothing_tree_charstar_uhwi): Likewise. * debug.c (do_nothing_debug_hooks): Adjust. (debug_false_tree_charstarstar_uhwistar): New do nothing. (debug_nothing_tree_charstar_uhwi): Likewise. * dbxout.c (dbx_debug_hooks): Adjust. (xcoff_debug_hooks): Likewise. * sdbout.c (sdb_debug_hooks): Likewise. * vmsdbgout.c (vmsdbg_debug_hooks): Likewise. * dwarf2out.c (macinfo_label_base): New global. (dwarf2out_register_external_die): New function for the register_external_die hook. (dwarf2out_die_ref_for_decl): Likewise for die_ref_for_decl. (dwarf2_debug_hooks): Use them. (dwarf2_lineno_debug_hooks): Adjust. (struct die_struct): Add with_offset flag. (DEBUG_LTO_DWO_INFO_SECTION, DEBUG_LTO_INFO_SECTION, DEBUG_LTO_DWO_ABBREV_SECTION, DEBUG_LTO_ABBREV_SECTION, DEBUG_LTO_DWO_MACINFO_SECTION, DEBUG_LTO_MACINFO_SECTION, DEBUG_LTO_DWO_MACRO_SECTION, DEBUG_LTO_MACRO_SECTION, DEBUG_LTO_LINE_SECTION, DEBUG_LTO_DWO_STR_OFFSETS_SECTION, DEBUG_LTO_STR_DWO_SECTION, DEBUG_STR_LTO_SECTION): New macros defining section names for the early LTO debug variants. (reset_indirect_string): New helper. (add_AT_external_die_ref): Helper for dwarf2out_register_external_die. (print_dw_val): Add support for offsetted symbol references. (get_ultimate_context): Split out from is_cxx. (is_cxx): Use get_ultimate_context. (is_fortran): Add decl overload. (compute_comp_unit_symbol): Split out worker from compute_section_prefix. (compute_section_prefix): Call compute_comp_unit_symbol and set comdat_type_p here. (output_die): Skip DIE symbol output for the LTO added one. Handle DIE symbol references with offset. (output_comp_unit): Guard section name mangling properly. For LTO debug sections emit a symbol at the section beginning which we use to refer to its DIEs. (add_abstract_origin_attribute): For DIEs registered via dwarf2out_register_external_die directly refer to the early DIE rather than indirectly through the shadow one we created. Remove obsolete call to dwarf2out_abstract_function for non-function/block origins. (gen_array_type_die): When generating early LTO debug do not emit DW_AT_string_length. (gen_formal_parameter_die): Do not re-create DIEs for PARM_DECLs late when in LTO. As suggested place a gcc_unreachable for the DECL_ABSTRACT_P case. (gen_subprogram_die): Avoid another specification DIE for early built declarations/definitions for the late LTO case. (gen_variable_die): Add type references for late duplicated VLA dies when in late LTO. (gen_inlined_subroutine_die): Do not call dwarf2out_abstract_function, we have the abstract instance already. (process_scope_var): Adjust decl DIE contexts in LTO which first puts them in limbo. (gen_decl_die): Do not generate type DIEs late apart from types for VLAs or for decls we do not yet have a DIE. Do not call dwarf2out_abstract_function late. (dwarf2out_early_global_decl): Make sure to create DIEs for abstract instances of a decl first. (dwarf2out_late_global_decl): Adjust comment. (output_macinfo_op): With multiple macro sections use macinfo_label_base to distinguish labels. (output_macinfo): Likewise. Update macinfo_label_base. Pass in the line info label. (note_variable_value_in_expr): When generating LTO resolve all variable values here by generating DIEs as needed. (init_sections_and_labels): Add early LTO debug flag parameter and generate different sections and names if set. Add generation counter for the labels so we can have multiple of them. (reset_dies): Helper to allow DIEs to be output multiple times. (dwarf2out_finish): When outputting DIEs to the fat part of an LTO object first reset DIEs. (dwarf2out_early_finish): Output early DIEs when generating LTO. (modified_type_die): Check for decl_ultimate_origin being self before recursing. (gen_type_die_with_usage): Likewise. (gen_typedef_die): Allow decl_ultimate_origin being self. (set_decl_abstract_flags): Remove. (set_block_abstract_flags): Likewise. (dwarf2out_abstract_function): Treat the early generated DIEs as the abstract copy and only add DW_AT_inline and DW_AT_artificial here and call set_decl_origin_self. If the DIE has an abstract origin don't do anything. * tree.c (free_lang_data): Build a dummy TRANSLATION_UNIT_DECL if we have none yet (Go fails to build one, PR78628). (variably_modified_type_p): Prevent endless recursion for Ada cyclic pointer types. * lto-streamer-in.c: Include debug.h. (dref_queue): New global. (lto_read_tree_1): Stream in DIE references. (lto_input_tree): Register DIE references. (input_function): Stream DECL_DEBUG_ARGS. * lto-streamer-out.c: Include debug.h. (lto_write_tree_1): Output DIE references. (DFS::DFS_write_tree_body): Follow DECL_ABSTRACT_ORIGIN. Force a TRANSLATION_UNIT_DECL DECL_CONTEXT for file-scope decls. (output_function): Stream DECL_DEBUG_ARGS. * tree-streamer-in.c (lto_input_ts_decl_common_tree_pointers): Stream DECL_ABSTRACT_ORIGIN. * tree-streamer-out.c (write_ts_decl_common_tree_pointers): Likewise. (write_ts_decl_minimal_tree_pointers): Force a TRANSLATION_UNIT_DECL DECL_CONTEXT for file-scope decls. * lto-streamer.h (struct dref_entry): Declare. (dref_queue): Likewise. * cfgexpand.c (pass_expand::execute): Do not call the outlining_inline_function hook here. * lto-wrapper.c (debug_obj): New global. (tool_cleanup): Unlink it if required. (debug_objcopy): New function. (run_gcc): Handle early debug sections in the IL files by extracting them to separate files, partially linkin them and feeding the result back as result to the linker. * config/darwin.h (DEBUG_LTO_INFO_SECTION, DEBUG_LTO_ABBREV_SECTION, DEBUG_LTO_MACINFO_SECTION, DEBUG_LTO_LINE_SECTION, DEBUG_STR_LTO_SECTION, DEBUG_LTO_MACRO_SECTION): Put early debug sections into a separate segment. * config/darwin.c (darwin_asm_named_section): Handle __GNU_DWARF_LTO segments. (darwin_asm_dwarf_section): Likewise. (darwin_asm_output_dwarf_offset): Likewise. * config/i386/i386.c (make_resolver_func): Set DECL_IGNORED_P. lto/ * lto.c (unify_scc): Truncate DIE reference queue for dropped SCCs. (lto_read_decls): Process TRANSLATION_UNIT_DECLs. Remove TYPE_DECL debug processing, register DIE references from prevailing SCCs with the debug machinery. (lto_section_with_id): Handle LTO debug sections. libstdc++/ * testsuite/libstdc++-prettyprinters/prettyprinters.exp: Run all tests with -flto as well if supported. testsuite/ * c-c++-common/asan/global-overflow-1.c: Adjust diagnostic location regex to handle the LTO case. * c-c++-common/asan/heap-overflow-1.c: Likewise. * c-c++-common/asan/misalign-1.c: Likewise. * c-c++-common/asan/misalign-2.c: Likewise. * c-c++-common/asan/null-deref-1.c: Likewise. * c-c++-common/asan/stack-overflow-1.c: Likewise. * c-c++-common/asan/strncpy-overflow-1.c: Likewise. * c-c++-common/asan/use-after-free-1.c: Likewise. * c-c++-common/asan/alloca_big_alignment.c: Likewise. * c-c++-common/asan/alloca_detect_custom_size.c: Likewise. * c-c++-common/asan/alloca_overflow_partial.c: Likewise. * c-c++-common/asan/alloca_overflow_right.c: Likewise. * c-c++-common/asan/alloca_underflow_left.c: Likewise. * g++.dg/asan/large-func-test-1.C: Likewise. * gfortran.dg/save_6.f90: Add -flto -g variant of save_5.f90. From-SVN: r251220
2017-08-18Add warn_if_not_aligned attributeH.J. Lu1-0/+1
Add warn_if_not_aligned attribute as well as command line options: -Wif-not-aligned and -Wpacked-not-aligned. __attribute__((warn_if_not_aligned(N))) causes compiler to issue a warning if the field in a struct or union is not aligned to N: typedef unsigned long long __u64 __attribute__((aligned(4),warn_if_not_aligned(8))); struct foo { int i1; int i2; __u64 x; }; __u64 is aligned to 4 bytes. But inside struct foo, __u64 should be aligned at 8 bytes. It is used to define struct foo in such a way that struct foo has the same layout and x has the same alignment when __u64 is aligned at either 4 or 8 bytes. Since struct foo is normally aligned to 4 bytes, a warning will be issued: warning: alignment 4 of 'struct foo' is less than 8 Align struct foo to 8 bytes: struct foo { int i1; int i2; __u64 x; } __attribute__((aligned(8))); silences the warning. It also warns the field with misaligned offset: struct foo { int i1; int i2; int i3; __u64 x; } __attribute__((aligned(8))); warning: 'x' offset 12 in 'struct foo' isn't aligned to 8 This warning is controlled by -Wif-not-aligned and is enabled by default. When -Wpacked-not-aligned is used, the same warning is also issued for the field with explicitly specified alignment in a packed struct or union: struct __attribute__ ((aligned (8))) S8 { char a[8]; }; struct __attribute__ ((packed)) S { struct S8 s8; }; warning: alignment 1 of 'struct S' is less than 8 This warning is disabled by default and enabled by -Wall. gcc/ PR c/53037 * print-tree.c (print_node): Support DECL_WARN_IF_NOT_ALIGN and TYPE_WARN_IF_NOT_ALIGN. * stor-layout.c (do_type_align): Merge DECL_WARN_IF_NOT_ALIGN. (handle_warn_if_not_align): New. (place_union_field): Call handle_warn_if_not_align. (place_field): Call handle_warn_if_not_align. Copy TYPE_WARN_IF_NOT_ALIGN. (finish_builtin_struct): Copy TYPE_WARN_IF_NOT_ALIGN. (layout_type): Likewise. * tree-core.h (tree_type_common): Add warn_if_not_align. Set spare to 18. (tree_decl_common): Add warn_if_not_align. * tree.c (build_range_type_1): Copy TYPE_WARN_IF_NOT_ALIGN. * tree.h (TYPE_WARN_IF_NOT_ALIGN): New. (SET_TYPE_WARN_IF_NOT_ALIGN): Likewise. (DECL_WARN_IF_NOT_ALIGN): Likewise. (SET_DECL_WARN_IF_NOT_ALIGN): Likewise. * doc/extend.texi: Document warn_if_not_aligned attribute. * doc/invoke.texi: Document -Wif-not-aligned and -Wpacked-not-aligned. gcc/c-family/ PR c/53037 * c-attribs.c (handle_warn_if_not_aligned_attribute): New. (c_common_attribute_table): Add warn_if_not_aligned. (handle_aligned_attribute): Renamed to ... (common_handle_aligned_attribute): Remove argument, name, and add argument, warn_if_not_aligned. Handle warn_if_not_aligned. (handle_aligned_attribute): New. * c.opt: Add -Wif-not-aligned and -Wpacked-not-aligned. gcc/c/ PR c/53037 * c-decl.c (merge_decls): Also merge DECL_WARN_IF_NOT_ALIGN. (check_bitfield_type_and_width): Don't allow bit-field with warn_if_not_aligned type. gcc/cp/ PR c/53037 * decl.c (duplicate_decls): Also merge DECL_WARN_IF_NOT_ALIGN. * decl2.c (grokbitfield): Don't allow bit-field with warn_if_not_aligned type. gcc/testsuite/ PR c/53037 * c-c++-common/pr53037-5.c: New test. * g++.dg/pr53037-1.C: Likewise. * g++.dg/pr53037-2.C: Likewise. * g++.dg/pr53037-3.C: Likewise. * g++.dg/pr53037-4.C: Likewise. * gcc.dg/pr53037-1.c: Likewise. * gcc.dg/pr53037-2.c: Likewise. * gcc.dg/pr53037-3.c: Likewise. * gcc.dg/pr53037-4.c: Likewise. From-SVN: r251180
2017-08-16tree-core.h (tree_type_non_common): Rename binfo to lang_1.Nathan Sidwell1-86/+43
* tree-core.h (tree_type_non_common): Rename binfo to lang_1. * tree.h (TYPE_BINFO): Use type_non_common.maxval. (TYPE_LANG_SLOT_1): Use type_non_common.lang_1, for any type. * tree.c (free_lang_data_in_type): Use else-if chain. Always clear TYPE_LANG_1. Remove obsolete member-function stripping. (find_decls_types_r): Comment about TYPE_MAX_VALUES_RAW. (verify_type): Adjust for TYPE_BINFO move. * lto-streamer-out.c (DFS::DFS_write_tree_body): No need to process TYPE_BINFO directly. (hash_tree): Likewise. * tree-streamer-in.c (lto_input_ts_type_non_common_tree_pointers): Likewise. * tree-streamer-out.c (write_ts_type_non_common_tree_pointers): Likewise. lto/ * lto.c (mentions_vars_p_type): Use TYPE_LANG_SLOT_1. (compare_tree_sccs_1): No need to compare TYPE_BINFO directly. (lto_fixup_prevailing_decls): Use TYPE_LANG_SLOT_1. From-SVN: r251129
2017-08-08trans.c: Include header files.Martin Liska1-683/+2
. 2017-08-08 Martin Liska <mliska@suse.cz> * gcc-interface/trans.c: Include header files. 2017-08-08 Martin Liska <mliska@suse.cz> * objc-gnu-runtime-abi-01.c: Include header files. * objc-next-runtime-abi-01.c: Likewise. * objc-next-runtime-abi-02.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * asan.c: Include header files. * attribs.c (build_decl_attribute_variant): New function moved from tree.[ch]. (build_type_attribute_qual_variant): Likewise. (cmp_attrib_identifiers): Likewise. (simple_cst_list_equal): Likewise. (omp_declare_simd_clauses_equal): Likewise. (attribute_value_equal): Likewise. (comp_type_attributes): Likewise. (build_type_attribute_variant): Likewise. (lookup_ident_attribute): Likewise. (remove_attribute): Likewise. (merge_attributes): Likewise. (merge_type_attributes): Likewise. (merge_decl_attributes): Likewise. (merge_dllimport_decl_attributes): Likewise. (handle_dll_attribute): Likewise. (attribute_list_equal): Likewise. (attribute_list_contained): Likewise. * attribs.h (lookup_attribute): New function moved from tree.[ch]. (lookup_attribute_by_prefix): Likewise. * bb-reorder.c: Include header files. * builtins.c: Likewise. * calls.c: Likewise. * cfgexpand.c: Likewise. * cgraph.c: Likewise. * cgraphunit.c: Likewise. * convert.c: Likewise. * dwarf2out.c: Likewise. * final.c: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * gimple-expr.c: Likewise. * gimple-fold.c: Likewise. * gimple-pretty-print.c: Likewise. * gimple.c: Likewise. * gimplify.c: Likewise. * hsa-common.c: Likewise. * hsa-gen.c: Likewise. * internal-fn.c: Likewise. * ipa-chkp.c: Likewise. * ipa-cp.c: Likewise. * ipa-devirt.c: Likewise. * ipa-fnsummary.c: Likewise. * ipa-inline.c: Likewise. * ipa-visibility.c: Likewise. * ipa.c: Likewise. * lto-cgraph.c: Likewise. * omp-expand.c: Likewise. * omp-general.c: Likewise. * omp-low.c: Likewise. * omp-offload.c: Likewise. * omp-simd-clone.c: Likewise. * opts-global.c: Likewise. * passes.c: Likewise. * predict.c: Likewise. * sancov.c: Likewise. * sanopt.c: Likewise. * symtab.c: Likewise. * toplev.c: Likewise. * trans-mem.c: Likewise. * tree-chkp.c: Likewise. * tree-eh.c: Likewise. * tree-into-ssa.c: Likewise. * tree-object-size.c: Likewise. * tree-parloops.c: Likewise. * tree-profile.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa.c: Likewise. * tree-streamer-in.c: Likewise. * tree-vectorizer.c: Likewise. * tree-vrp.c: Likewise. * tsan.c: Likewise. * ubsan.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * tree.c: Remove functions moved to attribs.[ch]. * tree.h: Likewise. * config/aarch64/aarch64.c: Add attrs.h header file. * config/alpha/alpha.c: Likewise. * config/arc/arc.c: Likewise. * config/arm/arm.c: Likewise. * config/avr/avr.c: Likewise. * config/bfin/bfin.c: Likewise. * config/c6x/c6x.c: Likewise. * config/cr16/cr16.c: Likewise. * config/cris/cris.c: Likewise. * config/darwin.c: Likewise. * config/epiphany/epiphany.c: Likewise. * config/fr30/fr30.c: Likewise. * config/frv/frv.c: Likewise. * config/ft32/ft32.c: Likewise. * config/h8300/h8300.c: Likewise. * config/i386/winnt.c: Likewise. * config/ia64/ia64.c: Likewise. * config/iq2000/iq2000.c: Likewise. * config/lm32/lm32.c: Likewise. * config/m32c/m32c.c: Likewise. * config/m32r/m32r.c: Likewise. * config/m68k/m68k.c: Likewise. * config/mcore/mcore.c: Likewise. * config/microblaze/microblaze.c: Likewise. * config/mips/mips.c: Likewise. * config/mmix/mmix.c: Likewise. * config/mn10300/mn10300.c: Likewise. * config/moxie/moxie.c: Likewise. * config/msp430/msp430.c: Likewise. * config/nds32/nds32-isr.c: Likewise. * config/nds32/nds32.c: Likewise. * config/nios2/nios2.c: Likewise. * config/nvptx/nvptx.c: Likewise. * config/pa/pa.c: Likewise. * config/pdp11/pdp11.c: Likewise. * config/powerpcspe/powerpcspe.c: Likewise. * config/riscv/riscv.c: Likewise. * config/rl78/rl78.c: Likewise. * config/rx/rx.c: Likewise. * config/s390/s390.c: Likewise. * config/sh/sh.c: Likewise. * config/sol2.c: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/tilegx/tilegx.c: Likewise. * config/tilepro/tilepro.c: Likewise. * config/v850/v850.c: Likewise. * config/vax/vax.c: Likewise. * config/visium/visium.c: Likewise. * config/xtensa/xtensa.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * call.c: Include header files. * cp-gimplify.c: Likewise. * cp-ubsan.c: Likewise. * cvt.c: Likewise. * init.c: Likewise. * search.c: Likewise. * semantics.c: Likewise. * typeck.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * lto-lang.c: Include header files. * lto-symtab.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * c-convert.c: Include header files. * c-typeck.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * c-ada-spec.c: Include header files. * c-ubsan.c: Likewise. * c-warn.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * trans-types.c: Include header files. From-SVN: r250946
2017-08-07Canonicalize names of attributes.Martin Liska1-90/+14
2017-08-07 Martin Liska <mliska@suse.cz> * attribs.h (canonicalize_attr_name): New function. (cmp_attribs): Move from c-format.c and adjusted. (is_attribute_p): Moved from tree.h. * tree-inline.c: Add new includes. * tree.c (cmp_attrib_identifiers): Use cmp_attribs. (private_is_attribute_p): Remove. (private_lookup_attribute): Likewise. (private_lookup_attribute_by_prefix): Simplify. (remove_attribute): Use is_attribute_p. * tree.h: Remove removed declarations. 2017-08-07 Martin Liska <mliska@suse.cz> * array-notation-common.c: Add new includes. * c-format.c( handle_format_attribute): Canonicalize a format function name. * c-lex.c (c_common_has_attribute): Canonicalize name of an attribute. * c-pretty-print.c: Add new include. 2017-08-07 Martin Liska <mliska@suse.cz> * parser.c (cp_parser_gnu_attribute_list): Canonicalize name of an attribute. (cp_parser_std_attribute): Likewise. * tree.c: Add new include. 2017-08-07 Martin Liska <mliska@suse.cz> * c-parser.c (c_parser_attributes): Canonicalize name of an attribute. 2017-08-07 Martin Liska <mliska@suse.cz> * go-gcc.cc (Gcc_backend::function): Look up for no_split_stack and not __no_split_stack__. 2017-08-07 Martin Liska <mliska@suse.cz> * g++.dg/cpp0x/pr65558.C: Update scanned pattern. * gcc.dg/parm-impl-decl-1.c: Likewise. * gcc.dg/parm-impl-decl-3.c: Likewise. * gcc.dg/Wattributes-5.c: New test. From-SVN: r250911
2017-07-29use c++ for build_tree_list{,_vec}_statTrevor Saunders1-3/+3
gcc/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * tree.c (build_tree_list_vec_stat): Remove _stat from name. (build_tree_list_stat): Likewise. * tree.h (build_tree_list): Remove macro. (build_tree_list_vec): Likewise. From-SVN: r250706
2017-07-29use C++ for {make,build}_vector_statTrevor Saunders1-2/+2
gcc/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * tree.c (make_vector_stat): Remove _stat from name. (build_vector_stat): Likewise. * tree.h (make_vector_stat): Remove macro. (build_vector_stat): Likewise. From-SVN: r250705
2017-07-29use c++ for tree_cons_statTrevor Saunders1-1/+1
gcc/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * tree.c (tree_cons_stat): Remove _stat from name. * tree.h (tree_cons): Remove macro. From-SVN: r250703
2017-07-29use c++ instead of build_vl_exp_statTrevor Saunders1-1/+1
gcc/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * tree.c (build_vl_exp_stat): Remove _stat from name. * tree.h (build_vl_exp): Remove macro. From-SVN: r250702
2017-07-29use c++ instead of build_decl_statTrevor Saunders1-1/+1
gcc/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * tree.c (build_decl_stat): Remove _stat from name. * tree.h (build_decl): Remove macro. From-SVN: r250701
2017-07-29use c++ instead of {make,grow}_tree_vec_statTrevor Saunders1-2/+2
gcc/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * tree.c (make_tree_vec_stat): Remove _stat from name. (grow_tree_vec_stat): Likewise. * tree.h (make_tree_vec_stat): Adjust prototype. (grow_tree_vec_stat): Likewise. (make_tree_vec): Remove macro. (grow_tree_vec): Likewise. From-SVN: r250699
2017-07-29use c++ instead of buildN_stat{,_loc}Trevor Saunders1-9/+9
gcc/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * fold-const.c (fold_build1_stat_loc): Adjust. (fold_build2_stat_loc): Likewise. (fold_build3_stat_loc): Likewise. * tree.c (build0_stat): Remove _stat from name. (build1_stat): Likewise. (build2_stat): Likewise. (build3_stat): Likewise. (build4_stat): Likewise. (build5_stat): Likewise. * tree.h (build1_loc): Remove macro, and rename _stat function to this. (build2_loc): Likewise. (build3_loc): Likewise. (build4_loc): Likewise. (build5_loc): Likewise. From-SVN: r250698
2017-07-29use c++ for make_int_cst_statTrevor Saunders1-1/+1
gcc/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * tree.c (make_int_cst_stat): Remove _stat from name. * tree.h (make_int_cst_stat): Adjust prototype. (make_int_cst): Remove macro. From-SVN: r250697
2017-07-29use cxx instead of make_tree_binfo_statTrevor Saunders1-1/+1
gcc/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * tree.c (make_tre_binfo_stat): Remove _stat from name. * tree.h (make_tree_binfo_stat): Adjust prototype. (make_tree_binfo): Remove. From-SVN: r250696
2017-07-29use c++ instead of _stat for copy_node_statTrevor Saunders1-2/+2
gcc/cp/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * lex.c (copy_decl): Adjust. (copy_type): Likewise. gcc/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * tree.c (copy_node_stat): Rename to copy_node. (build_distinct_type_copy): Adjust. * tree.h (copy_node_stat): Adjust prototype. (copy_node): Remove macro. From-SVN: r250695
2017-07-29use c++ instead of make_node_statTrevor Saunders1-8/+8
gcc/ChangeLog: 2017-07-28 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> * tree.c (make_node_stat): rename to make_node. (build_tree_list_stat): Adjust. (build0_stat): Likewise. (build2_stat): Likewise. (build3_stat): Likewise. (build4_stat): Likewise. (build5_stat): Likewise. (build_decl_stat): Likewise. * tree.h (make_node_stat): Adjust prototype. (make_node): remove macro. From-SVN: r250694
2017-07-26re PR middle-end/70992 (Infinite recursion between fold_build2_stat_loc and ↵Marek Polacek1-2/+20
fold_binary_loc w/ -fwrapv) PR middle-end/70992 * tree.c (build2_stat): Don't set TREE_CONSTANT on divisions by zero. * gcc.dg/overflow-warn-1.c: Adjust dg-error. * gcc.dg/overflow-warn-2.c: Likewise. * gcc.dg/overflow-warn-3.c: Likewise. * gcc.dg/overflow-warn-4.c: Likewise. * gcc.dg/torture/pr70992-2.c: New test. * gcc.dg/torture/pr70992.c: New test. From-SVN: r250566
2017-07-21Remove TYPE_METHODS.Nathan Sidwell1-32/+15
gcc/ Remove TYPE_METHODS. * tree.h (TYPE_METHODS): Delete. * dwarf2out.c (gen_member_die): Member fns are on TYPE_FIELDS. * dbxout.c (dbxout_type_fields): Ignore FUNCTION_DECLs. (dbxout_type_methods): Scan TYPE_FIELDS. (dbxout_type): Don't check TYPE_METHODS here. * function.c (use_register_for_decl): Always ignore register for class types when not optimizing. * ipa-devirt.c (odr_types_equivalent_p): Delete TYPE_METHODS scan. * tree.c (free_lang_data_in_type): Stitch out member functions and templates from TYPE_FIELDS. (build_distinct_type_copy, verify_type_variant, verify_type): Member fns are on TYPE_FIELDS. * tree-dump.c (dequeue_and_dump): No TYPE_METHODS. * tree-pretty-print.c (dump_generic_node): Likewise. gcc/cp/ Remove TYPE_METHODS. * class.c (maybe_warn_about_overly_private_class, finish_struct_methods, one_inheriting_sig, count_fields, add_fields_to_record_type, check_field_decls, check_methods, clone_function_decl, set_method_tm_attributes, finalize_literal_type_property, check_bases_and_members, create_vtable_ptr, determine_key_method, unreverse_member_declarations, finish_struct, add_vcall_offset_vtbl_entries_1): Member fns are on TYPE_FIELDS. * decl.c (fixup_anonymous_aggr): Likewise. * decl2.c (reset_type_linkage_2): Likewise. * method.c (after_nsdmi_defaulted_late_checks, lazily_declare_fn): Likewise. * optimize.c (maybe_thunk_body, maybe_clone_body): Likewise. * pt.c (instantiate_class_template_1, tsubst_expr, do_type_instantiation, instantiate_pending_templates): Likewise. * search.c (lookup_field_1): Likewise. * semantics.c (finish_member_declaration, finish_omp_declare_simd_methods): Likewise. gcc/c-family/ Remove TYPE_METHODS. * c-ada-spec.c (is_tagged_type, has_nontrivial_methods, dump_ada_template, print_ada_methods, print_ada_declaration): Member fns are on TYPE_FIELDS. gcc/objc/ Remove TYPE_METHODS. * objc-runtime-shared-support.c (build_ivar_list_initializer): Don't presume first item is a FIELD_DECL. gcc/testsuite/ * g++.dg/ext/anon-struct6.C: Adjust diag. * g++.old-deja/g++.other/anon4.C: Adjust diag. libcc1/ Remove TYPE_METHODS. * libcp1plugin.cc (plugin_build_decl): Member fns are on TYPE_FIELDS. From-SVN: r250413
2017-07-19tree.h (TYPE_MINVAL, [...]): Rename to ...Nathan Sidwell1-6/+6
gcc/ * tree.h (TYPE_MINVAL, TYPE_MAXVAL): Rename to ... (TYPE_MIN_VALUE_RAW, TYPE_MAX_VALUE_RAW): ... these. * tree.c (find_decls_types_r, verify_type): Use TYPE_{MIN,MAX}_VALUE_RAW. * lto-streamer-out.c (DFS::DFS_write_tree_body): Likewise. (hash_tree): Likewise. * tree-streamer-in.c (lto_input_ts_type_non_common_tree_pointers): Likewise. * tree-streamer-out.c (write_ts_type_non_common_tree_pointers): Likewise. gcc/cp/ * cp-tree.h (PACK_EXPANSION_PARAMETER_PACKS, PACK_EXPANSION_EXTRA_ARGS): Use TYPE_{MIN,MAX}_VALUE_RAW. gcc/lto/ * lto.c (mentions_vars_p_type): Use TYPE_{MIN,MAX}_VALUE_RAW. (compare_tree_sccs_1, lto_fixup_prevailing_decls): Likewise. gcc/objc/ * objc-act.h (CLASS_NST_METHODS, CLASS_CLS_METHODS): Use TYPE_{MIN,MAX}_VALUE_RAW. From-SVN: r250337
2017-07-14Remove Java references in source code.Martin Liska1-46/+2
2017-07-14 Martin Liska <mliska@suse.cz> * cfgexpand.c (expand_gimple_basic_block): Remove dead comment. * dwarf2out.c (is_java): Remove the function. (output_pubname): Remove usage of the function. (lower_bound_default): Remove usage of DW_LANG_Java. (gen_compile_unit_die): Likewise. * gcc.c: Remove compiler defaults for .java and .zip files. * gimple-expr.c (remove_suffix): Change as there's no longer extension than 4-letter one. * gimplify.c (mostly_copy_tree_r): Remove Java-special part. (gimplify_save_expr): Likewise. * ipa-utils.h (polymorphic_type_binfo_p): Remove the comment as it's possible even for other languages than Java. * langhooks.h (struct lang_hooks): Remove Java from a comment. * lto-opts.c (lto_write_options): Remove reference to Java. * opts.c (strip_off_ending): Update file extension handling. * tree-cfg.c (verify_gimple_call): Remove comment with Java. * tree-eh.c (lower_resx): Likewise. * tree.c (free_lang_data_in_type): Remove dead code. (find_decls_types_r): Likewise. (build_common_builtin_nodes): Remove Java from a comment. (verify_type): Remove dead code. * varasm.c (assemble_external): Remove Java from a comment. From-SVN: r250199
2017-06-27fenv.h builtinsMarc Glisse1-2/+6
2017-06-27 Marc Glisse <marc.glisse@inria.fr> * builtin-types.def (BT_FENV_T_PTR, BT_CONST_FENV_T_PTR, BT_FEXCEPT_T_PTR, BT_CONST_FEXCEPT_T_PTR): New primitive types. (BT_FN_INT_FENV_T_PTR, BT_FN_INT_CONST_FENV_T_PTR, BT_FN_INT_FEXCEPT_T_PTR_INT, BT_FN_INT_CONST_FEXCEPT_T_PTR_INT): New function types. * builtins.def (BUILT_IN_FECLEAREXCEPT, BUILT_IN_FEGETENV, BUILT_IN_FEGETEXCEPTFLAG, BUILT_IN_FEGETROUND, BUILT_IN_FEHOLDEXCEPT, BUILT_IN_FERAISEEXCEPT, BUILT_IN_FESETENV, BUILT_IN_FESETEXCEPTFLAG, BUILT_IN_FESETROUND, BUILT_IN_FETESTEXCEPT, BUILT_IN_FEUPDATEENV): New builtins. * tree-core.h (TI_FENV_T_PTR_TYPE, TI_CONST_FENV_T_PTR_TYPE, TI_FEXCEPT_T_PTR_TYPE, TI_CONST_FEXCEPT_T_PTR_TYPE): New entries. * tree.h (fenv_t_ptr_type_node, const_fenv_t_ptr_type_node, fexcept_t_ptr_type_node, const_fexcept_t_ptr_type_node): New macros. (builtin_structptr_types): Adjust size. * tree.c (builtin_structptr_types): Add four entries. From-SVN: r249685
2017-06-23Refactor fileptr_type_node handlingMarc Glisse1-4/+18
2017-06-23 Marc Glisse <marc.glisse@inria.fr> gcc/ * tree.h (builtin_structptr_type): New type. (builtin_structptr_types): Declare new array. * tree.c (builtin_structptr_types): New array. (free_lang_data, build_common_tree_nodes): Use it. gcc/c-family/ * c-common.c (c_common_nodes_and_builtins): Use builtin_structptr_types. gcc/cp/ * decl.c (duplicate_decls): Use builtin_structptr_types. gcc/lto/ * lto-lang.c (lto_init): Use builtin_structptr_types. From-SVN: r249585
2017-06-11tree.h (id_equal): New.Jason Merrill1-1/+1
* tree.h (id_equal): New. * dwarf2out.c, hsa-gen.c, ipa-devirt.c, omp-expand.c, omp-simd-clone.c, read-rtl-function.c, tree-chkp.c, tree.c: Use it instead of strcmp of IDENTIFIER_POINTER. c-family/ * c-ada-spec.c, c-pragma.c: Use it. cp/ * cp-tree.h, decl2.c, mangle.c, parser.c, pt.c, semantics.c: Use it. From-SVN: r249103
2017-06-09builtin-attrs.def (ATTR_NORETURN_NOTHROW_LEAF_COLD_LIST, [...]): New.Jan Hubicka1-2/+5
* builtin-attrs.def (ATTR_NORETURN_NOTHROW_LEAF_COLD_LIST, ATTR_CONST_NORETURN_NOTHROW_LEAF_COLD_LIST, ATTR_TMPURE_NORETURN_NOTHROW_LEAF_COLD_LIST): New. * builtins.def (abort, trap, unreachable): Declare cold. * calls.c (flags_from_decl_or_type): Lookup ECF_COLD. * tree-core.h (ECF_COLD): New. * tree.c (set_call_expr_flags): Handle ECF_COLD. (build_common_builtin_nodes): Mark unreachable and abort as cold. * class.c (build_vtbl_initializer): Mark dvirt_fn as cold. * decl.c (cxx_init_decl_processing, push_throw_library_fn): Likewise. (excpet.c): Mark terminate as cold. * gcc.dg/predict-14.c: Avoid cold function detection. * gcc.target/i386/umod-3.c: Likewise. From-SVN: r249070
2017-05-25Allow some NOP conversions in (X+CST1)+CST2 in match.pdMarc Glisse1-0/+19
2017-05-25 Marc Glisse <marc.glisse@inria.fr> gcc/ * match.pd ((A +- CST1) +- CST2): Allow some conversions. * tree.c (drop_tree_overflow): Handle COMPLEX_CST and VECTOR_CST. gcc/testsuite/ * gcc.dg/tree-ssa/addadd.c: New file. From-SVN: r248448
2017-05-19* tree.c (make_tree_vec_stat, grow_tree_vec_stat): Use size_t.Jason Merrill1-3/+3
From-SVN: r248302
2017-05-16re PR sanitizer/80536 (UBSAN: compile time segfault)Marek Polacek1-9/+7
PR sanitizer/80536 PR sanitizer/80386 * cp-gimplify.c (cp_fold): Handle SAVE_EXPR. * tree.c (save_expr): Don't fold the expression. * c-c++-common/ubsan/pr80536.c: New test. * g++.dg/ubsan/pr80386.C: New test. From-SVN: r248124
2017-05-05tree.c (next_type_uid): Change type to unsigned.Jakub Jelinek1-1/+17
* tree.c (next_type_uid): Change type to unsigned. (type_hash_canon): Decrement back next_type_uid if freeing a type node with the highest TYPE_UID. For INTEGER_TYPEs also ggc_free TYPE_MIN_VALUE, TYPE_MAX_VALUE and TYPE_CACHED_VALUES if possible. From-SVN: r247628
2017-05-04tree.c (array_at_struct_end_p): Handle arrays at struct end with flexarrays ↵Richard Biener1-16/+47
more conservatively. 2017-05-04 Richard Biener <rguenther@suse.de> * tree.c (array_at_struct_end_p): Handle arrays at struct end with flexarrays more conservatively. Refactor and treat arrays of arrays or aggregates more strict. Fix VIEW_CONVERT_EXPR handling. Remove allow_compref argument. * tree.c (array_at_struct_end_p): Adjust prototype. * emit-rtl.c (set_mem_attributes_minus_bitpos): Adjust. * gimple-fold.c (get_range_strlen): Likewise. * tree-chkp.c (chkp_may_narrow_to_field): Likewise. From-SVN: r247581
2017-05-03Canonicalize canonical type hashingNathan Sidwell1-93/+87
Canonicalize canonical type hashing gcc/ * tree.h (type_hash_canon_hash): Declare. * tree.c (type_hash_list, attribute_hash_list): Move into type_hash_canon_hash. (build_type_attribute_qual_variant): Break out hash code calc into type_hash_canon_hash. (type_hash_canon_hash): New. Generic type hash computation. (build_range_type_1, build_array_type_1, build_function_type) build_method_type_directly, build_offset_type, build_complex_type, make_vector_type): Call it. gcc/c-family/ * c-common.c (complete_array_type): Use type_hash_canon. (--This line, and those below, will be ignored-- M gcc/tree.c M gcc/tree.h M gcc/c-family/ChangeLog M gcc/c-family/c-common.c M gcc/ChangeLog From-SVN: r247546
2017-05-01tree.c (substitute_in_expr): Also inline a call if the replacement ↵Eric Botcazou1-5/+19
expression is another instance of one of... * tree.c (substitute_in_expr) <tcc_vl_exp>: Also inline a call if the replacement expression is another instance of one of its arguments. From-SVN: r247431
2017-04-27re PR c++/80534 (7.1 RC - internal compiler error: in ↵Jakub Jelinek1-4/+12
finish_member_declaration, at cp/semantics.c:2963) PR c++/80534 * tree.c (type_cache_hasher::equal): Only compare TYPE_TYPELESS_STORAGE flag on non-aggregate element types. (build_array_type_1): Only hash TYPE_TYPELESS_STORAGE flag on non-aggregate element types. * tree.h (TYPE_TYPELESS_STORAGE): Fix comment typo, add more details about the flag on ARRAY_TYPEs in the comment, formatting fix. c-family/ * c-common.c (complete_array_type): Only hash TYPE_TYPELESS_STORAGE flag on non-aggregate element types. testsuite/ * g++.dg/other/pr80534-1.C: New test. * g++.dg/other/pr80534-2.C: New test. From-SVN: r247334
2017-04-26tree.h (crc32_unsigned_n): Declare.Nathan Sidwell1-29/+23
* tree.h (crc32_unsigned_n): Declare. (crc32_unsigned, crc32_unsigned): Make inline. * tree.c (crc32_unsigned_bits): Replace with ... (crc32_unsigned_n): ... this. (crc32_unsigned, crc32_byte): Remove. (crc32_string): Remove unnecessary braces. From-SVN: r247281
2017-04-21tree.h (build_qualified_type): Annotate with CXX_MEM_STAT_INFO.Richard Biener1-6/+6
2017-04-21 Richard Biener <rguenther@suse.de> * tree.h (build_qualified_type): Annotate with CXX_MEM_STAT_INFO. (build_distinct_type_copy): Likewise. (build_variant_type_copy): Likewise. * tree.c (build_qualified_type): Pass down mem-stat info. (build_distinct_type_copy): Likewise. (build_variant_type_copy): Likewise. cp/ * cp-tree.h (copy_decl): Annotate with CXX_MEM_STAT_INFO. (copy_type): Likewise. * lex.c (copy_decl): Pass down mem-stat info. (copy_type): Likewise. From-SVN: r247053
2017-04-20re PR middle-end/80423 (GC related -fcompare-debug failure)Jakub Jelinek1-6/+12
PR middle-end/80423 * tree.h (build_array_type): Add typeless_storage default argument. * tree.c (type_cache_hasher::equal): Also compare TYPE_TYPELESS_STORAGE flag for ARRAY_TYPEs. (build_array_type): Add typeless_storage argument, set TYPE_TYPELESS_STORAGE to it, if shared also hash it, and pass to recursive call. (build_nonshared_array_type): Adjust build_array_type_1 caller. (build_array_type): Likewise. Add typeless_storage argument. c-family/ * c-common.c (complete_array_type): Preserve TYPE_TYPELESS_STORAGE. cp/ * tree.c (build_cplus_array_type): Call build_array_type with the intended TYPE_TYPELESS_STORAGE flag value, instead of calling build_array_type and modifying later TYPE_TYPELESS_STORAGE on the shared type. testsuite/ * g++.dg/other/pr80423.C: New test. From-SVN: r247014
2017-04-07re PR middle-end/80341 (gcc miscompiles division of signed char)Richard Biener1-6/+14
2017-04-07 Richard Biener <rguenther@suse.de> PR middle-end/80341 * tree.c (get_unwidened): Also handle ! for_type case for INTEGER_CSTs. * convert.c (do_narrow): Split out from ... (convert_to_integer_1): ... here. Do not pass final truncation type to get_unwidened for TRUNC_DIV_EXPR. * gcc.dg/torture/pr80341.c: New testcase. From-SVN: r246756
2017-03-28Avoid name lookup warningMarkus Trippelsdorf1-1/+1
/home/markus/gcc/gcc/tree.c: In function ‘void inchash::add_expr(const_tree, inchash::hash&, unsigned int)’: /home/markus/gcc/gcc/tree.c:8013:11: warning: name lookup of ‘i’ changed for (i = TREE_OPERAND_LENGTH (t) - 1; i >= 0; --i) ^ /home/markus/gcc/gcc/tree.c:7773:7: warning: matches this ‘i’ under ISO standard rules int i; ^ /home/markus/gcc/gcc/tree.c:7869:16: warning: matches this ‘i’ under old rules for (int i = 0; i < TREE_VEC_LENGTH (t); ++i) ^ From-SVN: r246519
2017-03-09re PR c++/79672 (ICE with -Wduplicated-branches -fopenmp)Marek Polacek1-0/+4
PR c++/79672 * tree.c (inchash::add_expr): Handle TREE_VEC. * g++.dg/warn/Wduplicated-branches2.C: Fix PR. * g++.dg/warn/Wduplicated-branches3.C: New test. From-SVN: r245996