aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
AgeCommit message (Collapse)AuthorFilesLines
2021-05-28OpenMP: Add iterator support to Fortran's depend; add affinity clauseTobias Burnus1-0/+3
gcc/c-family/ChangeLog: * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_AFFINITY. gcc/c/ChangeLog: * c-parser.c (c_parser_omp_clause_affinity): New. (c_parser_omp_clause_name, c_parser_omp_variable_list, c_parser_omp_all_clauses, OMP_TASK_CLAUSE_MASK): Handle affinity clause. * c-typeck.c (handle_omp_array_sections_1, handle_omp_array_sections, c_finish_omp_clauses): Likewise. gcc/cp/ChangeLog: * parser.c (cp_parser_omp_clause_affinity): New. (cp_parser_omp_clause_name, cp_parser_omp_var_list_no_open, cp_parser_omp_all_clauses, OMP_TASK_CLAUSE_MASK): Handle affinity clause. * semantics.c (handle_omp_array_sections_1, handle_omp_array_sections, finish_omp_clauses): Likewise. gcc/fortran/ChangeLog: * dump-parse-tree.c (show_iterator): New. (show_omp_namelist): Handle iterators. (show_omp_clauses): Handle affinity. * gfortran.h (gfc_free_omp_namelist): New union with 'udr' and new 'ns'. * match.c (gfc_free_omp_namelist): Add are to choose union element. * openmp.c (gfc_free_omp_clauses, gfc_match_omp_detach, gfc_match_omp_clause_reduction, gfc_match_omp_flush): Update call to gfc_free_omp_namelist. (gfc_match_omp_variable_list): Likewise; permit preceeding whitespace. (enum omp_mask1): Add OMP_CLAUSE_AFFINITY. (gfc_match_iterator): New. (gfc_match_omp_clauses): Use it; update call to gfc_free_omp_namelist. (OMP_TASK_CLAUSES): Add OMP_CLAUSE_AFFINITY. (gfc_match_omp_taskwait): Match depend clause. (resolve_omp_clauses): Handle affinity; update for udr/union change. (gfc_resolve_omp_directive): Resolve clauses of taskwait. * st.c (gfc_free_statement): Update gfc_free_omp_namelist call. * trans-openmp.c (gfc_trans_omp_array_reduction_or_udr): Likewise (handle_iterator): New. (gfc_trans_omp_clauses): Handle iterators for depend/affinity clause. (gfc_trans_omp_taskwait): Handle depend clause. (gfc_trans_omp_directive): Update call. gcc/ChangeLog: * gimplify.c (gimplify_omp_affinity): New. (gimplify_scan_omp_clauses): Call it; remove affinity clause afterwards. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_AFFINITY. * tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_AFFINITY. * tree.c (omp_clause_num_ops, omp_clause_code_name): Add clause. (walk_tree_1): Handle OMP_CLAUSE_AFFINITY. libgomp/ChangeLog: * testsuite/libgomp.fortran/depend-iterator-2.f90: New test. gcc/testsuite/ChangeLog: * c-c++-common/gomp/affinity-1.c: New test. * c-c++-common/gomp/affinity-2.c: New test. * c-c++-common/gomp/affinity-3.c: New test. * c-c++-common/gomp/affinity-4.c: New test. * c-c++-common/gomp/affinity-5.c: New test. * c-c++-common/gomp/affinity-6.c: New test. * c-c++-common/gomp/affinity-7.c: New test. * gfortran.dg/gomp/affinity-clause-1.f90: New test. * gfortran.dg/gomp/affinity-clause-2.f90: New test. * gfortran.dg/gomp/affinity-clause-3.f90: New test. * gfortran.dg/gomp/affinity-clause-4.f90: New test. * gfortran.dg/gomp/affinity-clause-5.f90: New test. * gfortran.dg/gomp/affinity-clause-6.f90: New test. * gfortran.dg/gomp/depend-iterator-1.f90: New test. * gfortran.dg/gomp/depend-iterator-2.f90: New test. * gfortran.dg/gomp/depend-iterator-3.f90: New test. * gfortran.dg/gomp/taskwait.f90: New test.
2021-05-26Convert remaining passes to get_range_query.Aldy Hernandez1-6/+7
This patch converts the remaining users of get_range_info and get_ptr_nonnull to the get_range_query API. No effort was made to move passes away from VR_ANTI_RANGE, or any other use of deprecated methods. This was a straight up conversion to the new API, nothing else. gcc/ChangeLog: * builtins.c (check_nul_terminated_array): Convert to get_range_query. (expand_builtin_strnlen): Same. (determine_block_size): Same. * fold-const.c (expr_not_equal_to): Same. * gimple-fold.c (size_must_be_zero_p): Same. * gimple-match-head.c: Include gimple-range.h. * gimple-pretty-print.c (dump_ssaname_info): Convert to get_range_query. * gimple-ssa-warn-restrict.c (builtin_memref::extend_offset_range): Same. * graphite-sese-to-poly.c (add_param_constraints): Same. * internal-fn.c (get_min_precision): Same. * ipa-fnsummary.c (set_switch_stmt_execution_predicate): Same. * ipa-prop.c (ipa_compute_jump_functions_for_edge): Same. * match.pd: Same. * tree-data-ref.c (split_constant_offset): Same. (dr_step_indicator): Same. * tree-dfa.c (get_ref_base_and_extent): Same. * tree-scalar-evolution.c (iv_can_overflow_p): Same. * tree-ssa-loop-niter.c (refine_value_range_using_guard): Same. (determine_value_range): Same. (record_nonwrapping_iv): Same. (infer_loop_bounds_from_signedness): Same. (scev_var_range_cant_overflow): Same. * tree-ssa-phiopt.c (two_value_replacement): Same. * tree-ssa-pre.c (insert_into_preds_of_block): Same. * tree-ssa-reassoc.c (optimize_range_tests_to_bit_test): Same. * tree-ssa-strlen.c (handle_builtin_stxncpy_strncat): Same. (get_range): Same. (dump_strlen_info): Same. (set_strlen_range): Same. (maybe_diag_stxncpy_trunc): Same. (get_len_or_size): Same. (handle_integral_assign): Same. * tree-ssa-structalias.c (find_what_p_points_to): Same. * tree-ssa-uninit.c (find_var_cmp_const): Same. * tree-switch-conversion.c (bit_test_cluster::emit): Same. * tree-vect-patterns.c (vect_get_range_info): Same. (vect_recog_divmod_pattern): Same. * tree-vrp.c (intersect_range_with_nonzero_bits): Same. (register_edge_assert_for_2): Same. (determine_value_range_1): Same. * tree.c (get_range_pos_neg): Same. * vr-values.c (vr_values::get_lattice_entry): Same. (vr_values::update_value_range): Same. (simplify_conversion_using_ranges): Same.
2021-05-19Enable more WITH_SIZE_EXPR processingRichard Biener1-5/+2
This enables the alias machinery for WITH_SIZE_EXPR which can appear in call LHS and arguments. In particular this drops the NULL return from get_base_address and it adjusts get_ref_base_and_extent and friends to use the size information in WITH_SIZE_EXPR and look through it for further processing. 2021-05-19 Richard Biener <rguenther@suse.de> * builtins.c (get_object_alignment_1): Strip outer WITH_SIZE_EXPR. * tree-dfa.c (get_ref_base_and_extent): Handle outer WITH_SIZE_EXPR for size processing and process the containing ref. * tree-ssa-alias.c (ao_ref_base_alias_set): Strip outer WITH_SIZE_EXPR. (ao_ref_base_alias_ptr_type): Likewise. (refs_may_alias_p_2): Allow WITH_SIZE_EXPR in ref->ref and handle that accordingly, stripping it for the core alias workers. * tree.c (get_base_address): Handle WITH_SIZE_EXPR by looking through it instead of returning NULL.
2021-05-18PR100281 C++: Fix SImode pointer handlingAndreas Krebbel1-11/+18
The problem appears to be triggered by two locations in the front-end where non-POINTER_SIZE pointers aren't handled right now. 1. An assertion in strip_typedefs is triggered because the alignment of the types don't match. This in turn is caused by creating the new type with build_pointer_type instead of taking the type of the original pointer into account. 2. An assertion in cp_convert_to_pointer is triggered which expects the target type to always have POINTER_SIZE. gcc/cp/ChangeLog: PR c++/100281 * cvt.c (cp_convert_to_pointer): Use the size of the target pointer type. * tree.c (cp_build_reference_type): Call cp_build_reference_type_for_mode with VOIDmode. (cp_build_reference_type_for_mode): Rename from cp_build_reference_type. Add MODE argument and invoke build_reference_type_for_mode. (strip_typedefs): Use build_pointer_type_for_mode and cp_build_reference_type_for_mode for pointers and references. gcc/ChangeLog: PR c++/100281 * tree.c (build_reference_type_for_mode) (build_pointer_type_for_mode): Pick pointer mode if MODE argument is VOIDmode. (build_reference_type, build_pointer_type): Invoke build_*_type_for_mode with VOIDmode. gcc/testsuite/ChangeLog: PR c++/100281 * g++.target/s390/pr100281-1.C: New test. * g++.target/s390/pr100281-2.C: New test.
2021-05-17middle-end/100582 - fix array_at_struct_end_p for vector indexingRichard Biener1-5/+3
Vector indexing leaves us with ARRAY_REFs of VIEW_CONVERT_EXPRs, sth which array_at_struct_end_p considers a array-at-struct-end even when there's an underlying decl visible. The following fixes the latter. 2021-05-17 Richard Biener <rguenther@suse.de> PR middle-end/100582 * tree.c (array_at_struct_end_p): Get to the base of the reference before looking for the underlying decl. * gcc.target/i386/pr100582.c: New testcase.
2021-05-10Come up with startswith function.Martin Liska1-1/+1
gcc/ada/ChangeLog: * gcc-interface/utils.c (def_builtin_1): Use startswith function instead of strncmp. gcc/analyzer/ChangeLog: * sm-file.cc (is_file_using_fn_p): Use startswith function instead of strncmp. gcc/ChangeLog: * builtins.c (is_builtin_name): Use startswith function instead of strncmp. * collect2.c (main): Likewise. (has_lto_section): Likewise. (scan_libraries): Likewise. * coverage.c (coverage_checksum_string): Likewise. (coverage_init): Likewise. * dwarf2out.c (is_cxx): Likewise. (gen_compile_unit_die): Likewise. * gcc-ar.c (main): Likewise. * gcc.c (init_spec): Likewise. (read_specs): Likewise. (execute): Likewise. (check_live_switch): Likewise. * genattrtab.c (write_attr_case): Likewise. (IS_ATTR_GROUP): Likewise. * gencfn-macros.c (main): Likewise. * gengtype.c (type_for_name): Likewise. (gen_rtx_next): Likewise. (get_file_langdir): Likewise. (write_local): Likewise. * genmatch.c (get_operator): Likewise. (get_operand_type): Likewise. (expr::gen_transform): Likewise. * genoutput.c (validate_optab_operands): Likewise. * incpath.c (add_sysroot_to_chain): Likewise. * langhooks.c (lang_GNU_C): Likewise. (lang_GNU_CXX): Likewise. (lang_GNU_Fortran): Likewise. (lang_GNU_OBJC): Likewise. * lto-wrapper.c (run_gcc): Likewise. * omp-general.c (omp_max_simt_vf): Likewise. * omp-low.c (omp_runtime_api_call): Likewise. * opts-common.c (parse_options_from_collect_gcc_options): Likewise. * read-rtl-function.c (function_reader::read_rtx_operand_r): Likewise. * real.c (real_from_string): Likewise. * selftest.c (assert_str_startswith): Likewise. * timevar.c (timer::validate_phases): Likewise. * tree.c (get_file_function_name): Likewise. * ubsan.c (ubsan_use_new_style_p): Likewise. * varasm.c (default_function_rodata_section): Likewise. (incorporeal_function_p): Likewise. (default_section_type_flags): Likewise. * system.h (startswith): Define startswith. gcc/c-family/ChangeLog: * c-ada-spec.c (print_destructor): Use startswith function instead of strncmp. (dump_ada_declaration): Likewise. * c-common.c (disable_builtin_function): Likewise. (def_builtin_1): Likewise. * c-format.c (check_tokens): Likewise. (check_plain): Likewise. (convert_format_name_to_system_name): Likewise. gcc/c/ChangeLog: * c-aux-info.c (affix_data_type): Use startswith function instead of strncmp. * c-typeck.c (build_function_call_vec): Likewise. * gimple-parser.c (c_parser_gimple_parse_bb_spec): Likewise. gcc/cp/ChangeLog: * decl.c (duplicate_decls): Use startswith function instead of strncmp. (cxx_builtin_function): Likewise. (omp_declare_variant_finalize_one): Likewise. (grokfndecl): Likewise. * error.c (dump_decl_name): Likewise. * mangle.c (find_decomp_unqualified_name): Likewise. (write_guarded_var_name): Likewise. (decl_tls_wrapper_p): Likewise. * parser.c (cp_parser_simple_type_specifier): Likewise. (cp_parser_tx_qualifier_opt): Likewise. * pt.c (template_parm_object_p): Likewise. (dguide_name_p): Likewise. gcc/d/ChangeLog: * d-builtins.cc (do_build_builtin_fn): Use startswith function instead of strncmp. * dmd/dinterpret.c (evaluateIfBuiltin): Likewise. * dmd/dmangle.c: Likewise. * dmd/hdrgen.c: Likewise. * dmd/identifier.c (Identifier::toHChars2): Likewise. gcc/fortran/ChangeLog: * decl.c (variable_decl): Use startswith function instead of strncmp. (gfc_match_end): Likewise. * gfortran.h (gfc_str_startswith): Likewise. * module.c (load_omp_udrs): Likewise. (read_module): Likewise. * options.c (gfc_handle_runtime_check_option): Likewise. * primary.c (match_arg_list_function): Likewise. * trans-decl.c (gfc_get_symbol_decl): Likewise. * trans-expr.c (gfc_conv_procedure_call): Likewise. * trans-intrinsic.c (gfc_conv_ieee_arithmetic_function): Likewise. gcc/go/ChangeLog: * gofrontend/runtime.cc (Runtime::name_to_code): Use startswith function instead of strncmp. gcc/objc/ChangeLog: * objc-act.c (objc_string_ref_type_p): Use startswith function instead of strncmp. * objc-encoding.c (encode_type): Likewise. * objc-next-runtime-abi-02.c (has_load_impl): Likewise.
2021-04-28Move pass free_lang_data to its own file.Martin Sebor1-1251/+107
gcc/ChangeLog: * Makefile.in (OBJS): Add ipa-free-lang-data.o. * ipa-free-lang-data.cc: New file. * tree.c: Move pass free_lang_data to file above. (build_array_type_1): Declare extern. * tree.h (build_array_type_1): Declare.
2021-04-21Fix clang warnings.Martin Liska1-5/+13
gcc/ChangeLog: * config/i386/i386.c: Remove superfluous || TARGET_MACHO which remains to be '(... || 0)' and clang complains about it. * dwarf2out.c (AT_vms_delta): Declare conditionally. (add_AT_vms_delta): Likewise. * tree.c (fld_simplified_type): Use rather more common pattern for disabling of something (#if 0). (get_tree_code_name): Likewise. (verify_type_variant): Likewise.
2021-04-10Do not release body of declare_variant_altJan Hubicka1-1/+1
gcc/ChangeLog: 2021-04-10 Jan Hubicka <hubicka@ucw.cz> PR lto/99857 * tree.c (free_lang_data_in_decl): Do not release body of declare_variant_alt.
2021-03-10tree-optimization/99510 - fix type reuse of build_aligned_typeRichard Biener1-1/+3
The fix for PR94775 added more strict checking for type reuse to check_aligned_type, specifically matching TYPE_USER_ALIGN. But then build_aligned_type sets TYPE_USER_ALIGN on the built variant so if the type we build an aligned variant for does not have TYPE_USER_ALIGN we'll never re-use the newly created aligned variant. This results in ~35000 identical variants being created for polyhedron doduc. The following instead checks that the candidate has TYPE_USER_ALIGN set. 2021-03-10 Richard Biener <rguenther@suse.de> PR tree-optimization/99510 * tree.c (check_aligned_type): Check that the candidate has TYPE_USER_ALIGN set instead of matching with the original type.
2021-02-28typos: Fix various typos - mainly misspelled reference* [PR99304]Jakub Jelinek1-1/+1
The PR is about a typo in handle_malloc_attribute diagnostic message, but grepping around I found many other cases and while fixing those I've noticed a couple of other typos. 2021-02-28 Jakub Jelinek <jakub@redhat.com> PR c/99304 * ipa.c (symbol_table::remove_unreachable_nodes): Fix a comment typo - referneced -> referenced. * tree.c (component_ref_size): Fix comment typo - refernce -> reference. * tree-ssa-alias.c (access_path_may_continue_p): Fix comment typo - traling -> trailing. (aliasing_component_refs_p): Fix comment typos - refernce -> reference and refernece -> reference and traling -> trailing. (nonoverlapping_refs_since_match_p): Fix comment typo - referneces -> references. * doc/invoke.texi (--param modref-max-bases): Fix a typo - referneces -> references. gcc/c-family/ * c-attribs.c (handle_malloc_attribute): Fix a typo in inform message - refernced -> referenced. Remove superfluous space before closing paren of function calls. gcc/lto/ * lto-symtab.c (lto_symtab_prevailing_virtual_decl): Fix comment typos - refernced -> referenced and devirtualizaiton -> devirtualization.
2021-02-08lto/96591 - walk VECTOR_CST elements in walk_treeRichard Biener1-1/+12
This implements walking of VECTOR_CST elements in walk_tree, mimicing the walk of COMPLEX_CST elements. Without this free-lang-data fails to see some types in case they are only refered to via tree constants used only as VECTOR_CST elements. 2021-02-08 Richard Biener <rguenther@suse.de> PR lto/96591 * tree.c (walk_tree_1): Walk VECTOR_CST elements. * g++.dg/lto/pr96591_0.C: New testcase.
2021-01-28tree: Don't reuse types if TYPE_USER_ALIGN differ [PR94775]Marek Polacek1-1/+3
A year ago I submitted this patch: ~~ Here we trip on the TYPE_USER_ALIGN (t) assert in strip_typedefs: it gets "const d[0]" with TYPE_USER_ALIGN=0 but the result built by build_cplus_array_type is "const char[0]" with TYPE_USER_ALIGN=1. When we strip_typedefs the element of the array "const d", we see it's a typedef_variant_p, so we look at its DECL_ORIGINAL_TYPE, which is char, but we need to add the const qualifier, so we call cp_build_qualified_type -> build_qualified_type where get_qualified_type checks to see if we already have such a type by walking the variants list, which in this case is: char -> c -> const char -> const char -> d -> const d Because check_base_type only checks TYPE_ALIGN and not TYPE_USER_ALIGN, we choose the first const char, which has TYPE_USER_ALIGN set. If the element type of an array has TYPE_USER_ALIGN, the array type gets it too. So we can make check_base_type stricter. I was afraid that it might make us reuse types less often, but measuring showed that we build the same amount of types with and without the patch, while bootstrapping. ~~ However, the patch broke a few tests on STRICT_ALIGNMENT platforms and had to be reverted. This is another try. The original patch is kept unchanged, but I added the finalize_type_size hunk that ought to fix the STRICT_ALIGNMENT issues. The problem is that finalize_type_size can clear TYPE_USER_ALIGN on the main variant of a type, but doesn't clear it on any of the variants. Then we end up with types which share the same TYPE_MAIN_VARIANT, but their TYPE_CANONICAL differs and then the usual "canonical types differ for identical types" follows. I've created alignas19.C to exercise this scenario. What happens is: - when parsing the class S we create a type S in xref_tag, - we see alignas(8) so common_handle_aligned_attribute sets T_U_A in S, - we parse the member function fn and build_memfn_type creates a copy of S to add const; this variant has T_U_A set, - we finish_struct S which calls layout_class_type -> finish_record_type -> finalize_size_type where we reset T_U_A in S (but const S keeps it), - finish_non_static_data_member for arr calls maybe_dummy_object with type = S, - maybe_dummy_object calls same_type_ignoring_top_level_qualifiers_p to check if S and TREE_TYPE (current_class_ref), which is const S, are the same, - same_type_ignoring_top_level_qualifiers_p creates cv-unqualified versions of the passed types. Previously we'd use our main variant S when stripping "const S" of const, but since the T_U_A flags don't match (check_base_type), we create a new variant S'. Then we crash in comptypes because S and S' have the same TYPE_MAIN_VARIANT but different TYPE_CANONICALs. With my patch we'll clear T_U_A for S's variants too, and then instead of S' we'll just use S. gcc/ChangeLog: PR c++/94775 * stor-layout.c (finalize_type_size): If we reset TYPE_USER_ALIGN in the main variant, maybe reset it in its variants too. * tree.c (check_base_type): Return true only if TYPE_USER_ALIGN match. (check_aligned_type): Check if TYPE_USER_ALIGN match. gcc/testsuite/ChangeLog: PR c++/94775 * g++.dg/cpp0x/alignas19.C: New test. * g++.dg/warn/Warray-bounds15.C: New test.
2021-01-26middle-end/98726 - fix VECTOR_CST element accessRichard Biener1-5/+5
This fixes VECTOR_CST element access with POLY_INT elements and allows to produce dump files of the PR98726 testcase without ICEing. 2021-01-26 Richard Biener <rguenther@suse.de> PR middle-end/98726 * tree.h (vector_cst_int_elt): Remove. * tree.c (vector_cst_int_elt): Use poly_wide_int for computations, make static.
2021-01-25middle-end/98807 - more vector_element_bits fixesRichard Biener1-7/+1
This simplifies vector_element_bits further, avoiding any mode dependence and instead relying on boolean vector construction to populate element precision accordingly. 2021-01-25 Richard Biener <rguenther@suse.de> PR middle-end/98807 * tree.c (vector_element_bits): Always use precision of the element type for boolean vectors. * gcc.dg/pr98807.c: New testcase.
2021-01-22middle-end/98793 - properly handle BLKmode vectors in vector_element_bitsRichard Biener1-3/+3
The previous change made AVX512 mask vectors correct but disregarded the possibility of generic (BLKmode) boolean vectors which are exposed by the frontends already. 2021-01-22 Richard Biener <rguenther@suse.de> PR middle-end/98793 * tree.c (vector_element_bits): Key single-bit bool vector on integer mode rather than not vector mode. * gcc.dg/pr98793.c: New testcase.
2021-01-19PR middle-end/98664 - inconsistent -Wfree-nonheap-object for inlined calls ↵Martin Sebor1-4/+7
to system headers gcc/ChangeLog: PR middle-end/98664 * tree-ssa-live.c (remove_unused_scope_block_p): Keep scopes for all functions, even if they're not declared artificial or inline. * tree.c (tree_inlined_location): Use macro expansion location only if scope traversal fails to expose one. gcc/testsuite/ChangeLog: PR middle-end/98664 * gcc.dg/Wvla-larger-than-4.c: Adjust expected output. * gcc.dg/plugin/diagnostic-test-inlining-3.c: Same. * g++.dg/warn/Wfree-nonheap-object-5.C: New test. * gcc.dg/Wfree-nonheap-object-4.c: New test.
2021-01-16openmp: Add support for the OpenMP 5.0 task detach clauseKwok Cheung Yeung1-6/+9
2021-01-16 Kwok Cheung Yeung <kcy@codesourcery.com> gcc/ * builtin-types.def (BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT): Rename to... (BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR): ...this. Add extra argument. * gimplify.c (omp_default_clause): Ensure that event handle is firstprivate in a task region. (gimplify_scan_omp_clauses): Handle OMP_CLAUSE_DETACH. (gimplify_adjust_omp_clauses): Likewise. * omp-builtins.def (BUILT_IN_GOMP_TASK): Change function type to BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR. * omp-expand.c (expand_task_call): Add GOMP_TASK_FLAG_DETACH to flags if detach clause specified. Add detach argument when generating call to GOMP_task. * omp-low.c (scan_sharing_clauses): Setup data environment for detach clause. (finish_taskreg_scan): Move field for variable containing the event handle to the front of the struct. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DETACH. Fix ordering. * tree-nested.c (convert_nonlocal_omp_clauses): Handle OMP_CLAUSE_DETACH clause. (convert_local_omp_clauses): Handle OMP_CLAUSE_DETACH clause. * tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_DETACH. * tree.c (omp_clause_num_ops): Add entry for OMP_CLAUSE_DETACH. Fix ordering. (omp_clause_code_name): Add entry for OMP_CLAUSE_DETACH. Fix ordering. (walk_tree_1): Handle OMP_CLAUSE_DETACH. gcc/c-family/ * c-pragma.h (pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_DETACH. Redefine PRAGMA_OACC_CLAUSE_DETACH. gcc/c/ * c-parser.c (c_parser_omp_clause_detach): New. (c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH clause. (OMP_TASK_CLAUSE_MASK): Add mask for PRAGMA_OMP_CLAUSE_DETACH. * c-typeck.c (c_finish_omp_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH clause. Prevent use of detach with mergeable and overriding the data sharing mode of the event handle. gcc/cp/ * parser.c (cp_parser_omp_clause_detach): New. (cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH. (OMP_TASK_CLAUSE_MASK): Add mask for PRAGMA_OMP_CLAUSE_DETACH. * pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_DETACH clause. * semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_DETACH clause. Prevent use of detach with mergeable and overriding the data sharing mode of the event handle. gcc/fortran/ * dump-parse-tree.c (show_omp_clauses): Handle detach clause. * frontend-passes.c (gfc_code_walker): Walk detach expression. * gfortran.h (struct gfc_omp_clauses): Add detach field. (gfc_c_intptr_kind): New. * openmp.c (gfc_free_omp_clauses): Free detach clause. (gfc_match_omp_detach): New. (enum omp_mask1): Add OMP_CLAUSE_DETACH. (enum omp_mask2): Remove OMP_CLAUSE_DETACH. (gfc_match_omp_clauses): Handle OMP_CLAUSE_DETACH for OpenMP. (OMP_TASK_CLAUSES): Add OMP_CLAUSE_DETACH. (resolve_omp_clauses): Prevent use of detach with mergeable and overriding the data sharing mode of the event handle. * trans-openmp.c (gfc_trans_omp_clauses): Handle detach clause. * trans-types.c (gfc_c_intptr_kind): New. (gfc_init_kinds): Initialize gfc_c_intptr_kind. * types.def (BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT): Rename to... (BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR): ...this. Add extra argument. gcc/testsuite/ * c-c++-common/gomp/task-detach-1.c: New. * g++.dg/gomp/task-detach-1.C: New. * gcc.dg/gomp/task-detach-1.c: New. * gfortran.dg/gomp/task-detach-1.f90: New. include/ * gomp-constants.h (GOMP_TASK_FLAG_DETACH): New. libgomp/ * fortran.c (omp_fulfill_event_): New. * libgomp.h (struct gomp_task): Add detach and completion_sem fields. (struct gomp_team): Add task_detach_queue and task_detach_count fields. * libgomp.map (OMP_5.0.1): Add omp_fulfill_event and omp_fulfill_event_. * libgomp_g.h (GOMP_task): Add extra argument. * omp.h.in (enum omp_event_handle_t): New. (omp_fulfill_event): New. * omp_lib.f90.in (omp_event_handle_kind): New. (omp_fulfill_event): New. * omp_lib.h.in (omp_event_handle_kind): New. (omp_fulfill_event): Declare. * priority_queue.c (priority_tree_find): New. (priority_list_find): New. (priority_queue_find): New. * priority_queue.h (priority_queue_predicate): New. (priority_queue_find): New. * task.c (gomp_init_task): Initialize detach field. (task_fulfilled_p): New. (GOMP_task): Add detach argument. Ignore detach argument if GOMP_TASK_FLAG_DETACH not set in flags. Initialize completion_sem field. Copy address of completion_sem into detach argument and into the start of the data record. Wait for detach event if task not deferred. (gomp_barrier_handle_tasks): Queue tasks with unfulfilled events. Remove completed tasks and requeue dependent tasks. (omp_fulfill_event): New. * team.c (gomp_new_team): Initialize task_detach_queue and task_detach_count fields. (free_team): Free task_detach_queue field. * testsuite/libgomp.c-c++-common/task-detach-1.c: New testcase. * testsuite/libgomp.c-c++-common/task-detach-2.c: New testcase. * testsuite/libgomp.c-c++-common/task-detach-3.c: New testcase. * testsuite/libgomp.c-c++-common/task-detach-4.c: New testcase. * testsuite/libgomp.c-c++-common/task-detach-5.c: New testcase. * testsuite/libgomp.c-c++-common/task-detach-6.c: New testcase. * testsuite/libgomp.fortran/task-detach-1.f90: New testcase. * testsuite/libgomp.fortran/task-detach-2.f90: New testcase. * testsuite/libgomp.fortran/task-detach-3.f90: New testcase. * testsuite/libgomp.fortran/task-detach-4.f90: New testcase. * testsuite/libgomp.fortran/task-detach-5.f90: New testcase. * testsuite/libgomp.fortran/task-detach-6.f90: New testcase.
2021-01-05tree-optimization/98381 - fix live bool vector extractRichard Biener1-2/+7
This fixes extraction of live bool vector results for the case of integer mode vectors. 2021-01-05 Richard Biener <rguenther@suse.de> PR tree-optimization/98381 * tree.c (vector_element_bits): Properly compute bool vector element size. * tree-vect-loop.c (vectorizable_live_operation): Properly compute the last lane bit offset.
2021-01-04Update copyright years.Jakub Jelinek1-1/+1
2020-12-14Correct/improve maybe_emit_free_warning (PR middle-end/98166, PR c++/57111, ↵Martin Sebor1-1/+102
PR middle-end/98160). Resolves: PR middle-end/98166 - bogus -Wmismatched-dealloc on user-defined allocator and inlining PR c++/57111 - 57111 - Generalize -Wfree-nonheap-object to delete PR middle-end/98160 - ICE in default_tree_printer at gcc/tree-diagnostic.c:270 gcc/ChangeLog: PR middle-end/98166 PR c++/57111 PR middle-end/98160 * builtins.c (check_access): Call tree_inlined_location fndecl_alloc_p): Handle BUILT_IN_ALIGNED_ALLOC and BUILT_IN_GOMP_ALLOC. call_dealloc_p): Remove unused function. (new_delete_mismatch_p): Call valid_new_delete_pair_p and rework. (matching_alloc_calls_p): Handle built-in deallocation functions. (warn_dealloc_offset): Corrct the handling of user-defined operators delete. (maybe_emit_free_warning): Avoid assuming expression is a decl. Simplify. * doc/extend.texi (attribute malloc): Update. * tree-ssa-dce.c (valid_new_delete_pair_p): Factor code out into valid_new_delete_pair_p in tree.c. * tree.c (tree_inlined_location): Define new function. (valid_new_delete_pair_p): Define. * tree.h (tree_inlined_location): Declare. (valid_new_delete_pair_p): Declare. gcc/c-family/ChangeLog: PR middle-end/98166 PR c++/57111 PR middle-end/98160 * c-attribs.c (maybe_add_noinline): New function. (handle_malloc_attribute): Call it. Use ATTR_FLAG_INTERNAL. Implicitly add attribute noinline to functions not declared inline and warn on those. libstdc++-v3/ChangeLog: * testsuite/ext/vstring/requirements/exception/basic.cc: Suppress a false positive warning. * testsuite/ext/vstring/requirements/exception/propagation_consistent.cc: Same. gcc/testsuite/ChangeLog: PR middle-end/98166 PR c++/57111 PR middle-end/98160 * g++.dg/warn/Wmismatched-dealloc-2.C: Adjust test of expected warning. * g++.dg/warn/Wmismatched-new-delete.C: Same. * gcc.dg/Wmismatched-dealloc.c: Same. * c-c++-common/Wfree-nonheap-object-2.c: New test. * c-c++-common/Wfree-nonheap-object-3.c: New test. * c-c++-common/Wfree-nonheap-object.c: New test. * c-c++-common/Wmismatched-dealloc.c: New test. * g++.dg/warn/Wfree-nonheap-object-3.C: New test. * g++.dg/warn/Wfree-nonheap-object-4.C: New test. * g++.dg/warn/Wmismatched-dealloc-2.C: New test. * g++.dg/warn/Wmismatched-new-delete-2.C: New test. * g++.dg/warn/Wmismatched-new-delete.C: New test. * gcc.dg/Wmismatched-dealloc-2.c: New test. * gcc.dg/Wmismatched-dealloc-3.c: New test. * gcc.dg/Wmismatched-dealloc.c: New test.
2020-12-10drop __builtin_ from __clear_cache libnameAlexandre Oliva1-1/+1
I made a cut&pasto in my previous patch for tree.c, causing platforms that have CLEAR_INSN_CACHE defined, and none of the internal __clear_cache expansion overriders, to issue calls to symbols named __builtin___clear_cache rather than __clear_cache, on languages other than those in the C family. Oops. This patch removes __builtin_ from the string used as the libname for __buuiltin___clear_cache. for gcc/ChangeLog * tree.c (build_common_builtin_nodes): Drop __builtin_ from __clear_cache libname.
2020-12-04vec: Simplify use with C++11 range-based 'for'.Jason Merrill1-1/+1
It looks cleaner if we can use a vec* directly as a range for the C++11 range-based 'for' loop, without needing to indirect from it, and also works with null pointers. The change in cp_parser_late_parsing_default_args is an example of how this can be used to simplify a simple loop over a vector. Reverse or subset iteration will require adding range adaptors. I deliberately didn't format the new overloads for etags since they are trivial. gcc/ChangeLog: * vec.h (begin, end): Add overloads for vec*. * tree.c (build_constructor_from_vec): Remove *. gcc/cp/ChangeLog: * decl2.c (clear_consteval_vfns): Remove *. * pt.c (do_auto_deduction): Remove *. * parser.c (cp_parser_late_parsing_default_args): Change loop to use range 'for'.
2020-12-03fix __builtin___clear_cache overrider falloutAlexandre Oliva1-0/+6
Machines that had CLEAR_CACHE_INSN and that would thus issue calls to __clear_cache with the default call expander, would fail on languages that did not set up the __clear_cache builtin. This patch arranges for all languages to set up this builtin. Machines or multilibs that had ptr_mode != Pmode, such as aarch64 with -mabi=ilp32, would fail the RTL mode test of the arguments passed to __clear_cache, because we'd insist on ptr_mode. This patch arranges for Pmode to be accepted as well. for gcc/ChangeLog * tree.c (build_common_builtin_nodes): Declare __builtin___clear_cache for all languages. * builtins.c (maybe_emit_call_builtin___clear_cache): Accept Pmode arguments.
2020-12-01PR middle-end/97595 - bogus -Wstringop-overflow due to DECL_SIZE_UNIT ↵Martin Sebor1-3/+9
underreporting field size gcc/ChangeLog: PR middle-end/97595 * tree.c (component_ref_size): Fail when DECL_SIZE != TYPE_SIZE. * tree.h (DECL_SIZE, TYPE_SIZE): Update comment. gcc/testsuite/ChangeLog: PR middle-end/97595 * g++.dg/warn/Warray-bounds-14.C: New test. * g++.dg/warn/Wstringop-overflow-6.C: New test.
2020-11-21Additional small changes to support opaque modesAaron Sawdey1-0/+2
After building some larger codes using opaque types and some c++ codes using opaque types it became clear I needed to go through and look for places where opaque types and modes needed to be handled. A whole pile of one-liners. gcc/ * typeclass.h: Add opaque_type_class. * builtins.c (type_to_class): Identify opaque type class. * dwarf2out.c (is_base_type): Handle opaque types. (gen_type_die_with_usage): Handle opaque types. * expr.c (count_type_elements): Opaque types should never have initializers. * ipa-devirt.c (odr_types_equivalent_p): No type-specific handling for opaque types is needed as it eventually checks the underlying mode which is what is important. * tree-streamer.c (record_common_node): Handle opaque types. * tree.c (type_contains_placeholder_1): Handle opaque types. (type_cache_hasher::equal): No additional comparison needed for opaque types. gcc/c-family * c-pretty-print.c (c_pretty_printer::simple_type_specifier): Treat opaque types like other types. (c_pretty_printer::direct_abstract_declarator): Opaque types are supported types. gcc/c * c-aux-info.c (gen_type): Support opaque types. gcc/cp * error.c (dump_type): Handle opaque types. (dump_type_prefix): Handle opaque types. (dump_type_suffix): Handle opaque types. (dump_expr): Handle opaque types. * pt.c (tsubst): Allow opaque types in templates. (unify): Allow opaque types in templates. * typeck.c (structural_comptypes): Handle comparison of opaque types.
2020-11-19c, tree: Fix ICE from get_parm_array_spec [PR97860]Jakub Jelinek1-1/+11
The C and C++ FEs handle zero sized arrays differently, C uses NULL TYPE_MAX_VALUE on non-NULL TYPE_DOMAIN on complete ARRAY_TYPEs with bitsize_zero_node TYPE_SIZE, while C++ FE likes to set TYPE_MAX_VALUE to the largest value (and min to the lowest). Martin has used array_type_nelts in get_parm_array_spec where the function on the C form of [0] arrays returns error_mark_node and the code crashes soon afterwards. The following patch teaches array_type_nelts about this (e.g. dwarf2out already handles that as [0]). While it will change what is_empty_type returns for certain types (e.g. struct S { int a[0]; };), as those types occupy zero bits in C, it should make an ABI difference. So, the tree.c change makes the c-decl.c code handle the [0] arrays like any other constant extents, and the c-decl.c change just makes sure that if we'd run into error_mark_node e.g. from the VLA expressions, we don't crash on those. 2020-11-19 Jakub Jelinek <jakub@redhat.com> PR c/97860 * tree.c (array_type_nelts): For complete arrays with zero min and NULL max and zero size return -1. * c-decl.c (get_parm_array_spec): Bail out of nelts is error_operand_p. * gcc.dg/pr97860.c: New test.
2020-11-17extend cache_integer_cstNathan Sidwell1-9/+27
This modules-related patch extends cache_integer_cst. Currently, when given a small cst, that cst is added to the type's small and /must not/ already be there. Large values are fine if they are already in the large cache. This adds a parameter to indicate small duplicates are ok, and it returns the cached value -- either what was already tehre, or the newly inserted const. gcc/ * tree.h (cache_integer_cst): Add defaulted might_duplicate parm. * tree.c (cache_integer_cst): Return the integer cst, add might_duplicate parm to permit finding a small duplicate.
2020-11-17Add MODE_OPAQUEAaron Sawdey1-0/+1
After discussion with Richard Sandiford on IRC, he suggested adding a new mode class MODE_OPAQUE to deal with the problems (PR 96791) we had been having with POImode/PXImode in powerpc target. This patch is the accumulation of changes I needed to make to add this and make it useable for the purposes of what power10 MMA needed. MODE_OPAQUE modes allow you to have modes for which you can just define loads and stores. By design, optimization does not expect to know how to do arithmetic or subregs on these modes. This allows us to have modes for multi-register vector operations where we don't want to open Pandora's Box and define general arithmetic operations. This patch will be followed by a target specific patch to change the powerpc power10 MMA builtins to use opaque modes, and will also let use use the vector pair loads/stores defined with that in the inline expansion of memcpy/memmove, allowing me to fix PR 96791. gcc/ChangeLog PR target/96791 * mode-classes.def: Add MODE_OPAQUE. * machmode.def: Add OPAQUE_MODE. * tree.def: Add OPAQUE_TYPE for types that will use MODE_OPAQUE. * doc/generic.texi: Document OPAQUE_TYPE. * doc/rtl.texi: Document MODE_OPAQUE. * machmode.h: Add OPAQUE_MODE_P(). * genmodes.c (complete_mode): Add MODE_OPAQUE. (opaque_mode): New function. * tree.c (tree_code_size): Add OPAQUE_TYPE. * tree.h: Add OPAQUE_TYPE_P(). * stor-layout.c (int_mode_for_mode): Treat MODE_OPAQUE modes like BLKmode. * ira.c (find_moveable_pseudos): Treat MODE_OPAQUE modes more like integer/float modes here. * dbxout.c (dbxout_type): Treat OPAQUE_TYPE like VOID_TYPE. * tree-pretty-print.c (dump_generic_node): Treat OPAQUE_TYPE like like other types.
2020-11-16PR middle-end/97840 - Bogus -Wmaybe-uninitialized passing an empty object to ↵Martin Sebor1-5/+5
a function gcc/ChangeLog: * tree-ssa-uninit.c (maybe_warn_operand): Call is_empty_type. * tree.c (default_is_empty_type): Rename... (is_empty_type): ...to this. * tree.h (is_empty_type): Declare.
2020-11-11c++: Tweak tsubst_qualified_id location.Marek Polacek1-0/+4
Retain the location when tsubstituting a qualified-id so that our static_assert diagnostic can benefit. Don't create useless location wrappers for temporary variables. gcc/ChangeLog: PR c++/97518 * tree.c (maybe_wrap_with_location): Don't add a location wrapper around an artificial and ignored decl. gcc/cp/ChangeLog: PR c++/97518 * pt.c (tsubst_qualified_id): Use EXPR_LOCATION of the qualified-id. Use it to maybe_wrap_with_location the final expression. gcc/testsuite/ChangeLog: PR c++/97518 * g++.dg/diagnostic/static_assert3.C: New test.
2020-11-11Fix spelling.Martin Liska1-1/+1
gcc/ChangeLog: * tree.c (copy_node): Fix spelling.
2020-11-10Refactor copying decl section namesStrager Neds1-0/+27
gcc/ * cgraph.h (symtab_node::get_section): Constify. (symtab_node::set_section): Declare new overload. * symtab.c (symtab_node::set_section): Define new overload. (symtab_node::copy_visibility_from): Use new overload of symtab_node::set_section. (symtab_node::resolve_alias): Same. * tree.h (set_decl_section_name): Declare new overload. * tree.c (set_decl_section_name): Define new overload. * tree-emutls.c (get_emutls_init_templ_addr): Same. * cgraphclones.c (cgraph_node::create_virtual_clone): Use new overload of symtab_node::set_section. (cgraph_node::create_version_clone_with_body): Same. * trans-mem.c (ipa_tm_create_version): Same. gcc/c * c-decl.c (merge_decls): Use new overload of set_decl_section_name. gcc/cp * decl.c (duplicate_decls): Use new overload of set_decl_section_name. * method.c (use_thunk): Same. * optimize.c (maybe_clone_body): Same. * coroutines.cc (act_des_fn): Same. gcc/d * decl.cc (finish_thunk): Use new overload of set_decl_section_name
2020-11-02core: Synchronize tree-cst & wide-int caching expectationsNathan Sidwell1-5/+10
I fell over an ICE where wide_int_to_type_1's expectations of pointer value caching didn't match that of cache_integer_cst's behaviour. I don't know why it only exhibited on the modules branch, but it seems pretty wrong. This patch matches up the behaviours and adds a comment about that. gcc/ * tree.c (cache_integer_cst): Fixup pointer caching to match wide_int_to_type_1's expectations. Add comment.
2020-11-02Rewrite SLP induction vectorizationRichard Biener1-0/+16
This rewrites SLP induction vectorization to handle different inductions in the different SLP lanes. It also changes SLP build to represent the initial value (but not the cycle) so it can be enhanced to handle outer loop vectorization later. Note this FAILs gcc.dg/vect/costmodel/x86_64/costmodel-pr30843.c because it removes one CSE optimization that no longer works with non-uniform initial value and step. I'll see to recover from this after outer loop vectorization of inductions works. It might be a bit friendlier to variable-size vectors now but then we're now building the step vector from scalars ... 2020-11-02 Richard Biener <rguenther@suse.de> * tree.h (build_real_from_wide): Declare. * tree.c (build_real_from_wide): New function. * tree-vect-slp.c (vect_build_slp_tree_2): Remove restriction on induction vectorization, represent the initial value. * tree-vect-loop.c (vect_model_induction_cost): Inline ... (vectorizable_induction): ... here. Rewrite SLP code generation. * gcc.dg/vect/slp-49.c: New testcase.
2020-10-28openmp: Parsing and some semantic analysis of OpenMP allocate clauseJakub Jelinek1-0/+3
This patch adds parsing of OpenMP allocate clause, but still ignores it during OpenMP lowering where we should for privatized variables with allocate clause use the corresponding allocators rather than allocating them on the stack. 2020-10-28 Jakub Jelinek <jakub@redhat.com> gcc/ * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_ALLOCATE. * tree.h (OMP_CLAUSE_ALLOCATE_ALLOCATOR, OMP_CLAUSE_ALLOCATE_COMBINED): Define. * tree.c (omp_clause_num_ops, omp_clause_code_name): Add allocate clause. (walk_tree_1): Handle OMP_CLAUSE_ALLOCATE. * tree-pretty-print.c (dump_omp_clause): Likewise. * gimplify.c (gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses, gimplify_omp_for): Likewise. * tree-nested.c (convert_nonlocal_omp_clauses, convert_local_omp_clauses): Likewise. * omp-low.c (scan_sharing_clauses): Likewise. gcc/c-family/ * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_ALLOCATE. * c-omp.c: Include bitmap.h. (c_omp_split_clauses): Handle OMP_CLAUSE_ALLOCATE. gcc/c/ * c-parser.c (c_parser_omp_clause_name): Handle allocate. (c_parser_omp_clause_allocate): New function. (c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_ALLOCATE. (OMP_FOR_CLAUSE_MASK, OMP_SECTIONS_CLAUSE_MASK, OMP_PARALLEL_CLAUSE_MASK, OMP_SINGLE_CLAUSE_MASK, OMP_TASK_CLAUSE_MASK, OMP_TASKGROUP_CLAUSE_MASK, OMP_DISTRIBUTE_CLAUSE_MASK, OMP_TEAMS_CLAUSE_MASK, OMP_TARGET_CLAUSE_MASK, OMP_TASKLOOP_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_ALLOCATE. * c-typeck.c (c_finish_omp_clauses): Handle OMP_CLAUSE_ALLOCATE. gcc/cp/ * parser.c (cp_parser_omp_clause_name): Handle allocate. (cp_parser_omp_clause_allocate): New function. (cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_ALLOCATE. (OMP_FOR_CLAUSE_MASK, OMP_SECTIONS_CLAUSE_MASK, OMP_PARALLEL_CLAUSE_MASK, OMP_SINGLE_CLAUSE_MASK, OMP_TASK_CLAUSE_MASK, OMP_TASKGROUP_CLAUSE_MASK, OMP_DISTRIBUTE_CLAUSE_MASK, OMP_TEAMS_CLAUSE_MASK, OMP_TARGET_CLAUSE_MASK, OMP_TASKLOOP_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_ALLOCATE. * semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_ALLOCATE. * pt.c (tsubst_omp_clauses): Likewise. gcc/testsuite/ * c-c++-common/gomp/allocate-1.c: New test. * c-c++-common/gomp/allocate-2.c: New test. * c-c++-common/gomp/clauses-1.c (omp_allocator_handle_t): New typedef. (foo, bar, baz): Add allocate clauses where allowed.
2020-10-27Fix builtin decls generated in tree.cJan Hubicka1-4/+4
* tree.c (set_call_expr_flags): Fix string for ECF_RET1. (build_common_builtin_nodes): Do not set ECF_RET1 for memcpy, memmove, and memset. They are handled by builtin_fnspec.
2020-10-26middle-end/97521 - always use single-bit bools in mask vector typesRichard Biener1-2/+9
This makes us always use a single-bit boolean type component type for integer mode mask VECTOR_BOOLEAN_TYPE_P to match the RTL and target representation. This aovids the need for magic translation and the inconsistencies from the translation requirement now that we expose temporaries of those types on the GIMPLE level. 2020-10-23 Richard Biener <rguenther@suse.de> PR middle-end/97521 * expr.c (const_scalar_mask_from_tree): Remove. (expand_expr_real_1): Always VIEW_CONVERT integer mode vector constants to an integer type. * tree.c (build_truth_vector_type_for_mode): Use a single-bit boolean component type for non-vector-mode mask_mode. * gcc.target/i386/pr97521.c: New testcase.
2020-10-23Move thunks out of cgraph_nodeJan Hubicka1-1/+1
this patch moves thunk_info out of cgraph_node into a symbol summary. I also moved it to separate hearder file since cgraph.h became really too fat. I plan to contiue with similar breakup in order to cleanup interfaces and reduce WPA memory footprint (symbol table now consumes more memory than trees) gcc/ChangeLog: 2020-10-23 Jan Hubicka <hubicka@ucw.cz> * Makefile.in: Add symtab-thunks.o (GTFILES): Add symtab-thunks.h and symtab-thunks.cc; remove cgraphunit.c * cgraph.c: Include symtab-thunks.h. (cgraph_node::create_thunk): Update (symbol_table::create_edge): Update (cgraph_node::dump): Update (cgraph_node::call_for_symbol_thunks_and_aliases): Update (set_nothrow_flag_1): Update (set_malloc_flag_1): Update (set_const_flag_1): Update (collect_callers_of_node_1): Update (clone_of_p): Update (cgraph_node::verify_node): Update (cgraph_node::function_symbol): Update (cgraph_c_finalize): Call thunk_info::release. (cgraph_node::has_thunk_p): Update (cgraph_node::former_thunk_p): Move here from cgraph.h; reimplement. * cgraph.h (struct cgraph_thunk_info): Rename to symtab-thunks.h. (cgraph_node): Remove thunk field; add thunk bitfield. (cgraph_node::expand_thunk): Move to symtab-thunks.h (symtab_thunks_cc_finalize): Declare. (cgraph_node::has_gimple_body_p): Update. (cgraph_node::former_thunk_p): Update. * cgraphclones.c: Include symtab-thunks.h. (duplicate_thunk_for_node): Update. (cgraph_edge::redirect_callee_duplicating_thunks): Update. (cgraph_node::expand_all_artificial_thunks): Update. (cgraph_node::create_edge_including_clones): Update. * cgraphunit.c: Include symtab-thunks.h. (vtable_entry_type): Move to symtab-thunks.c. (cgraph_node::analyze): Update. (analyze_functions): Update. (mark_functions_to_output): Update. (thunk_adjust): Move to symtab-thunks.c (cgraph_node::expand_thunk): Move to symtab-thunks.c (cgraph_node::assemble_thunks_and_aliases): Update. (output_in_order): Update. (cgraphunit_c_finalize): Do not clear vtable_entry_type. (cgraph_node::create_wrapper): Update. * gengtype.c (open_base_files): Add symtab-thunks.h * ipa-comdats.c (propagate_comdat_group): UPdate. (ipa_comdats): Update. * ipa-cp.c (determine_versionability): UPdate. (gather_caller_stats): Update. (count_callers): Update (set_single_call_flag): Update (initialize_node_lattices): Update (call_passes_through_thunk_p): Update (call_passes_through_thunk): Update (propagate_constants_across_call): Update (find_more_scalar_values_for_callers_subset): Update (has_undead_caller_from_outside_scc_p): Update * ipa-fnsummary.c (evaluate_properties_for_edge): Update. (compute_fn_summary): Update. (inline_analyze_function): Update. * ipa-icf.c: Include symtab-thunks.h. (sem_function::equals_wpa): Update. (redirect_all_callers): Update. (sem_function::init): Update. (sem_function::parse): Update. * ipa-inline-transform.c: Include symtab-thunks.h. (inline_call): Update. (save_inline_function_body): Update. (preserve_function_body_p): Update. * ipa-inline.c (inline_small_functions): Update. * ipa-polymorphic-call.c: Include alloc-pool.h, symbol-summary.h, symtab-thunks.h (ipa_polymorphic_call_context::ipa_polymorphic_call_context): Update. * ipa-pure-const.c: Include symtab-thunks.h. (analyze_function): Update. * ipa-sra.c (check_for_caller_issues): Update. * ipa-utils.c (ipa_reverse_postorder): Update. (ipa_merge_profiles): Update. * ipa-visibility.c (non_local_p): Update. (cgraph_node::local_p): Update. (function_and_variable_visibility): Update. * ipa.c (symbol_table::remove_unreachable_nodes): Update. * lto-cgraph.c: Include alloc-pool.h, symbol-summary.h and symtab-thunks.h (lto_output_edge): Update. (lto_output_node): Update. (compute_ltrans_boundary): Update. (output_symtab): Update. (verify_node_partition): Update. (input_overwrite_node): Update. (input_node): Update. * lto-streamer-in.c (fixup_call_stmt_edges): Update. * symtab-thunks.cc: New file. * symtab-thunks.h: New file. * toplev.c (toplev::finalize): Call symtab_thunks_cc_finalize. * trans-mem.c (ipa_tm_mayenterirr_function): Update. (ipa_tm_execute): Update. * tree-inline.c (expand_call_inline): Update. * tree-nested.c (create_nesting_tree): Update. (convert_all_function_calls): Update. (gimplify_all_functions): Update. * tree-profile.c (tree_profiling): Update. * tree-ssa-structalias.c (associate_varinfo_to_alias): Update. * tree.c (free_lang_data_in_decl): Update. * value-prof.c (init_node_map): Update. gcc/c-family/ChangeLog: 2020-10-23 Jan Hubicka <hubicka@ucw.cz> * c-common.c (c_common_finalize_early_debug): Update for new thunk api. gcc/d/ChangeLog: 2020-10-23 Jan Hubicka <hubicka@ucw.cz> * decl.cc (finish_thunk): Update for new thunk api. gcc/lto/ChangeLog: 2020-10-23 Jan Hubicka <hubicka@ucw.cz> * lto-partition.c (add_symbol_to_partition_1): Update for new thunk api.
2020-10-12Correct handling of indices into arrays with elements larger than 1 (PR ↵Martin Sebor1-13/+25
c++/96511) Resolves: PR c++/96511 - Incorrect -Wplacement-new on POINTER_PLUS into an array with 4-byte elements PR middle-end/96384 - bogus -Wstringop-overflow= storing into multidimensional array with index in range gcc/ChangeLog: PR c++/96511 PR middle-end/96384 * builtins.c (get_range): Return full range of type when neither value nor its range is available. Fail for ranges inverted due to the signedness of offsets. (compute_objsize): Handle more special array members. Handle POINTER_PLUS_EXPR and VIEW_CONVERT_EXPR that come up in front end code. (access_ref::offset_bounded): Define new member function. * builtins.h (access_ref::eval): New data member. (access_ref::offset_bounded): New member function. (access_ref::offset_zero): New member function. (compute_objsize): Declare a new overload. * gimple-array-bounds.cc (array_bounds_checker::check_array_ref): Use enum special_array_member. * tree.c (component_ref_size): Use special_array_member. * tree.h (special_array_member): Define a new type. (component_ref_size): Change signature. gcc/cp/ChangeLog: PR c++/96511 PR middle-end/96384 * init.c (warn_placement_new_too_small): Call builtin_objsize instead of duplicating what it does. gcc/testsuite/ChangeLog: PR c++/96511 PR middle-end/96384 * g++.dg/init/strlen.C: Add expected warning. * g++.dg/warn/Wplacement-new-size-1.C: Relax warnings. * g++.dg/warn/Wplacement-new-size-2.C: Same. * g++.dg/warn/Wplacement-new-size-6.C: Same. * gcc.dg/Warray-bounds-58.c: Adjust * gcc.dg/Wstringop-overflow-37.c: Same. * g++.dg/warn/Wplacement-new-size-7.C: New test.
2020-09-23middle-end/96466 - fix VEC_COND isel/expansion issueRichard Biener1-1/+1
We need to avoid forcing BLKmode for truth vectors, instead do as other code and use VOIDmode so layout_type can pick a suitable and consistent mode. RTL expansion of vect_cond_mask also needs to deal with CONST_INT operands which means passing the mode explicitely. 2020-09-23 Richard Biener <rguenther@suse.de> PR middle-end/96466 * internal-fn.c (expand_vect_cond_mask_optab_fn): Use appropriate mode for force_reg. * tree.c (build_truth_vector_type_for): Pass VOIDmode to make_vector_type. * gcc.dg/pr96466.c: New testcase.
2020-09-14options: Save and restore opts_set for Optimization and Target optionsJakub Jelinek1-6/+8
> Seems a latent issue. > Neither cl_optimization_{save,restore} nor cl_target_option_{save,restore} > (nor any of the target hooks they call) saves or restores any opts_set > values, so I think opts_set can be trusted only during option processing (if > at all), but not later. > So, short term a fix would be IMHO just stop using opts_set altogether in > arm_configure_build_target, it doesn't make much sense to me, it should test > if those strings are non-NULL instead, or at least do that when it is > invoked from arm_option_restore (e.g. could be done by calling it with > opts instead of &global_options_set ). > Longer term, the question is if cl_optimization_{save,restore} and > cl_target_option_{save,restore} shouldn't be changed not to only > save/restore the options, but also save the opts_set flags. > It could be done e.g. by adding a bool array or set of bool members > to struct cl_optimization and struct cl_target_option , or even more compact > by using bitmasks, pack each 64 adjacent option flags into a UHWI element > of an array. So, I've tried under debugger how it behaves and seems global_options_set is really an or of whether an option has been ever seen as explicit, either on the command line or in any of the option pragmas or optimize/target attributes seen so far, so it isn't something that can be relied on. The following patch implements the saving/restoring of the opts_set bits (though only for the options/variables saved by the generic options-save.c code, for the target specific stuff that isn't handled by the generic code the opts_set argument is now passed to the hook and the backends can choose e.g. to use a TargetSave variable to save the flags either individually or together in some bitmask (or ignore it if they never need opts_set for the options). This patch itself doesn't fix the testcase failing on arm, but a follow up patch will. 2020-09-14 Jakub Jelinek <jakub@redhat.com> gcc/ * opt-read.awk: Also initialize extra_target_var_types array. * opth-gen.awk: Emit explicit_mask arrays to struct cl_optimization and cl_target_option. Adjust cl_optimization_save, cl_optimization_restore, cl_target_option_save and cl_target_option_restore declarations. * optc-save-gen.awk: Add opts_set argument to cl_optimization_save, cl_optimization_restore, cl_target_option_save and cl_target_option_restore functions and save or restore opts_set next to the opts values into or from explicit_mask arrays. In cl_target_option_eq and cl_optimization_option_eq compare explicit_mask arrays, in cl_target_option_hash and cl_optimization_hash hash them and in cl_target_option_stream_out, cl_target_option_stream_in, cl_optimization_stream_out and cl_optimization_stream_in stream them. * tree.h (build_optimization_node, build_target_option_node): Add opts_set argument. * tree.c (build_optimization_node): Add opts_set argument, pass it to cl_optimization_save. (build_target_option_node): Add opts_set argument, pass it to cl_target_option_save. * function.c (invoke_set_current_function_hook): Adjust cl_optimization_restore caller. * ipa-inline-transform.c (inline_call): Adjust cl_optimization_restore and build_optimization_node callers. * target.def (TARGET_OPTION_SAVE, TARGET_OPTION_RESTORE): Add opts_set argument. * target-globals.c (save_target_globals_default_opts): Adjust cl_optimization_restore callers. * toplev.c (process_options): Adjust build_optimization_node and cl_optimization_restore callers. (target_reinit): Adjust cl_optimization_restore caller. * tree-streamer-in.c (lto_input_ts_function_decl_tree_pointers): Adjust build_optimization_node and cl_optimization_restore callers. * doc/tm.texi: Updated. * config/aarch64/aarch64.c (aarch64_override_options): Adjust build_target_option_node caller. (aarch64_option_save, aarch64_option_restore): Add opts_set argument. (aarch64_set_current_function): Adjust cl_target_option_restore caller. (aarch64_option_valid_attribute_p): Adjust cl_target_option_save, cl_target_option_restore, cl_optimization_restore, build_optimization_node and build_target_option_node callers. * config/aarch64/aarch64-c.c (aarch64_pragma_target_parse): Adjust cl_target_option_restore and build_target_option_node callers. * config/arm/arm.c (arm_option_save, arm_option_restore): Add opts_set argument. (arm_option_override): Adjust cl_target_option_save, build_optimization_node and build_target_option_node callers. (arm_set_current_function): Adjust cl_target_option_restore caller. (arm_valid_target_attribute_tree): Adjust build_target_option_node caller. (add_attribute): Formatting fix. (arm_valid_target_attribute_p): Adjust cl_optimization_restore, cl_target_option_restore, arm_valid_target_attribute_tree and build_optimization_node callers. * config/arm/arm-c.c (arm_pragma_target_parse): Adjust cl_target_option_restore callers. * config/csky/csky.c (csky_option_override): Adjust build_target_option_node and cl_target_option_save callers. * config/gcn/gcn.c (gcn_fixup_accel_lto_options): Adjust build_optimization_node and cl_optimization_restore callers. * config/i386/i386-builtins.c (get_builtin_code_for_version): Adjust cl_target_option_save and cl_target_option_restore callers. * config/i386/i386-c.c (ix86_pragma_target_parse): Adjust build_target_option_node and cl_target_option_restore callers. * config/i386/i386-options.c (ix86_function_specific_save, ix86_function_specific_restore): Add opts_set arguments. (ix86_valid_target_attribute_tree): Adjust build_target_option_node caller. (ix86_valid_target_attribute_p): Adjust build_optimization_node, cl_optimization_restore, cl_target_option_restore, ix86_valid_target_attribute_tree and build_optimization_node callers. (ix86_option_override_internal): Adjust build_target_option_node caller. (ix86_reset_previous_fndecl, ix86_set_current_function): Adjust cl_target_option_restore callers. * config/i386/i386-options.h (ix86_function_specific_save, ix86_function_specific_restore): Add opts_set argument. * config/nios2/nios2.c (nios2_option_override): Adjust build_target_option_node caller. (nios2_option_save, nios2_option_restore): Add opts_set argument. (nios2_valid_target_attribute_tree): Adjust build_target_option_node caller. (nios2_valid_target_attribute_p): Adjust build_optimization_node, cl_optimization_restore, cl_target_option_save and cl_target_option_restore callers. (nios2_set_current_function, nios2_pragma_target_parse): Adjust cl_target_option_restore callers. * config/pru/pru.c (pru_option_override): Adjust build_target_option_node caller. (pru_set_current_function): Adjust cl_target_option_restore callers. * config/rs6000/rs6000.c (rs6000_debug_reg_global): Adjust cl_target_option_save caller. (rs6000_option_override_internal): Adjust build_target_option_node caller. (rs6000_valid_attribute_p): Adjust build_optimization_node, cl_optimization_restore, cl_target_option_save, cl_target_option_restore and build_target_option_node callers. (rs6000_pragma_target_parse): Adjust cl_target_option_restore and build_target_option_node callers. (rs6000_activate_target_options): Adjust cl_target_option_restore callers. (rs6000_function_specific_save, rs6000_function_specific_restore): Add opts_set argument. * config/s390/s390.c (s390_function_specific_restore): Likewise. (s390_option_override_internal): Adjust s390_function_specific_restore caller. (s390_option_override, s390_valid_target_attribute_tree): Adjust build_target_option_node caller. (s390_valid_target_attribute_p): Adjust build_optimization_node, cl_optimization_restore and cl_target_option_restore callers. (s390_activate_target_options): Adjust cl_target_option_restore caller. * config/s390/s390-c.c (s390_cpu_cpp_builtins): Adjust cl_target_option_save caller. (s390_pragma_target_parse): Adjust build_target_option_node and cl_target_option_restore callers. gcc/c-family/ * c-attribs.c (handle_optimize_attribute): Adjust cl_optimization_save, cl_optimization_restore and build_optimization_node callers. * c-pragma.c (handle_pragma_optimize): Adjust build_optimization_node caller. (handle_pragma_push_options): Adjust build_optimization_node and build_target_option_node callers. (handle_pragma_pop_options, handle_pragma_reset_options): Adjust cl_optimization_restore callers. gcc/go/ * go-gcc.cc (Gcc_backend::function): Adjust cl_optimization_save, cl_optimization_restore and build_optimization_node callers. gcc/ada/ * gcc-interface/trans.c (gigi): Adjust build_optimization_node caller.
2020-08-31c++: Implement P1009: Array size deduction in new-expressions.Marek Polacek1-0/+15
This patch implements C++20 P1009, allowing code like new double[]{1,2,3}; // array bound will be deduced Since this proposal makes the initialization rules more consistent, it is applied to all previous versions of C++ (thus, effectively, all the way back to C++11). My patch is based on Jason's patch that handled the basic case. I've extended it to work with ()-init and also the string literal case. Further testing revealed that to handle stuff like new int[]{t...}; in a template, we have to consider such a NEW_EXPR type-dependent. Obviously, we first have to expand the pack to be able to deduce the number of elements in the array. Curiously, while implementing this proposal, I noticed that we fail to accept new char[4]{"abc"}; so I've assigned 77841 to self. I think the fix will depend on the build_new_1 hunk in this patch. The new tree.c function build_constructor_from_vec helps us morph a vector into a CONSTRUCTOR more efficiently. gcc/cp/ChangeLog: PR c++/93529 * call.c (build_new_method_call_1): Use build_constructor_from_vec instead of build_tree_list_vec + build_constructor_from_list. * init.c (build_new_1): Handle new char[]{"foo"}. Use build_constructor_from_vec instead of build_tree_list_vec + build_constructor_from_list. (build_new): Deduce the array size in new-expression if not present. Handle ()-init. Handle initializing an array from a string literal. * parser.c (cp_parser_new_type_id): Leave [] alone. (cp_parser_direct_new_declarator): Allow []. * pt.c (type_dependent_expression_p): In a NEW_EXPR, consider array types whose dimension has to be deduced type-dependent. gcc/ChangeLog: PR c++/93529 * tree.c (build_constructor_from_vec): New. * tree.h (build_constructor_from_vec): Declare. gcc/testsuite/ChangeLog: PR c++/93529 * g++.dg/cpp0x/sfinae4.C: Adjust expected result after P1009. * g++.dg/cpp2a/new-array1.C: New test. * g++.dg/cpp2a/new-array2.C: New test. * g++.dg/cpp2a/new-array3.C: New test. * g++.dg/cpp2a/new-array4.C: New test. Co-authored-by: Jason Merrill <jason@redhat.com>
2020-08-11tree: Fix up get_narrower [PR96549]Jakub Jelinek1-1/+1
My changes to get_narrower to support COMPOUND_EXPRs apparently used a wrong type for the COMPOUND_EXPRs, while e.g. the rhs type was unsigned short, the COMPOUND_EXPR got int type as that was the original type of op. The type of COMPOUND_EXPR should be always the type of the rhs. 2020-08-11 Jakub Jelinek <jakub@redhat.com> PR c/96549 * tree.c (get_narrower): Use TREE_TYPE (ret) instead of TREE_TYPE (win) for COMPOUND_EXPRs. * gcc.c-torture/execute/pr96549.c: New test.
2020-08-03Removal of HSA offloading from gcc and libgompMartin Jambor1-3/+0
This patch removes the generation of HSAIL from the compiler, the HSA offloading plugin from libgomp and the associated testsuite tests and infrastructure bits from the respective testsuites. Apart from removal of the obvious files, I removed bits that I found by searching for HSA related terms and by re-tracing my steps and looking at the patches that introduced HSA in the first place. I did not remove everything these patches brought in, for example: - the mechanism to pass offload-target specific info from the application to the offloading plugin - but the same mechanism is also used to communicate number of teams and the thread limit to all offload targets. - run_func hook in gomp_device_descr stays too, although now it is not used. If some future offload target would like the ability to refuse to offload some functions, it can use it. It is easy to remove as a follow-up if it is considered clutter, though. - configure options --with-hsa-runtime=PATH, -with-hsa-runtime-include=PATH and --with-hsa-runtime-lib=PATH rmeain because GCN uses them too. - Surprisingly, GOMP_TARGET_ARG_HSA_KERNEL_ATTRIBUTES (a constant from gomp-constants.h) appears in the source of the amdgcn libgomp plugin, although I tend to think that code path is not ever used and this patch certainly removes it from the compiler. Nevertheless, it seems it has potential value beyond HSAIL and so I've kept it, it can of course always be easily removed in the future of GCN folk abandon it too. - I assume constants OFFLOAD_TARGET_TYPE_HSA and GOMP_DEVICE_HSA need to stay indefinitely too just so that no future offload target picks that number. - I have kept dg-require-effective-target offload_device_nonshared_as requirement of thests which have it. It is quite probable I missed some small HSA artifacts but those should be easy to remove later as we find them. include/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * gomp-constants.h (GOMP_VERSION_HSA): Remove. gcc/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * hsa-brig-format.h: Moved to brig/brigfrontend. * hsa-brig.c: Removed. * hsa-builtins.def: Likewise. * hsa-common.c: Likewise. * hsa-common.h: Likewise. * hsa-dump.c: Likewise. * hsa-gen.c: Likewise. * hsa-regalloc.c: Likewise. * ipa-hsa.c: Likewise. * omp-grid.c: Likewise. * omp-grid.h: Likewise. * Makefile.in (BUILTINS_DEF): Remove hsa-builtins.def. (OBJS): Remove hsa-common.o, hsa-gen.o, hsa-regalloc.o, hsa-brig.o, hsa-dump.o, ipa-hsa.c and omp-grid.o. (GTFILES): Removed hsa-common.c and omp-expand.c. * builtins.def: Remove processing of hsa-builtins.def. (DEF_HSA_BUILTIN): Remove. * common.opt (flag_disable_hsa): Remove. (-Whsa): Ignore. * config.in (ENABLE_HSA): Removed. * configure.ac: Removed handling configuration for hsa offloading. (ENABLE_HSA): Removed. * configure: Regenerated. * doc/install.texi (--enable-offload-targets): Remove hsa from the example. (--with-hsa-runtime): Reword to reference any HSA run-time, not specifically HSA offloading. * doc/invoke.texi (Option Summary): Remove -Whsa. (Warning Options): Likewise. (Optimize Options): Remove hsa-gen-debug-stores. * doc/passes.texi (Regular IPA passes): Remove section on IPA HSA pass. * gimple-low.c (lower_stmt): Remove GIMPLE_OMP_GRID_BODY case. * gimple-pretty-print.c (dump_gimple_omp_for): Likewise. (dump_gimple_omp_block): Likewise. (pp_gimple_stmt_1): Likewise. * gimple-walk.c (walk_gimple_stmt): Likewise. * gimple.c (gimple_build_omp_grid_body): Removed function. (gimple_copy): Remove GIMPLE_OMP_GRID_BODY case. * gimple.def (GIMPLE_OMP_GRID_BODY): Removed. * gimple.h (gf_mask): Removed GF_OMP_PARALLEL_GRID_PHONY, OMP_FOR_KIND_GRID_LOOP, GF_OMP_FOR_GRID_PHONY, GF_OMP_FOR_GRID_INTRA_GROUP, GF_OMP_FOR_GRID_GROUP_ITER and GF_OMP_TEAMS_GRID_PHONY. Renumbered GF_OMP_FOR_KIND_SIMD and GF_OMP_TEAMS_HOST. (gimple_build_omp_grid_body): Removed declaration. (gimple_has_substatements): Remove GIMPLE_OMP_GRID_BODY case. (gimple_omp_for_grid_phony): Removed. (gimple_omp_for_set_grid_phony): Likewise. (gimple_omp_for_grid_intra_group): Likewise. (gimple_omp_for_grid_intra_group): Likewise. (gimple_omp_for_grid_group_iter): Likewise. (gimple_omp_for_set_grid_group_iter): Likewise. (gimple_omp_parallel_grid_phony): Likewise. (gimple_omp_parallel_set_grid_phony): Likewise. (gimple_omp_teams_grid_phony): Likewise. (gimple_omp_teams_set_grid_phony): Likewise. (CASE_GIMPLE_OMP): Remove GIMPLE_OMP_GRID_BODY case. * lto-section-in.c (lto_section_name): Removed hsa. * lto-streamer.h (lto_section_type): Removed LTO_section_ipa_hsa. * lto-wrapper.c (compile_images_for_offload_targets): Remove special handling of hsa. * omp-expand.c: Do not include hsa-common.h and gt-omp-expand.h. (parallel_needs_hsa_kernel_p): Removed. (grid_launch_attributes_trees): Likewise. (grid_launch_attributes_trees): Likewise. (grid_create_kernel_launch_attr_types): Likewise. (grid_insert_store_range_dim): Likewise. (grid_get_kernel_launch_attributes): Likewise. (get_target_arguments): Remove code passing HSA grid sizes. (grid_expand_omp_for_loop): Remove. (grid_arg_decl_map): Likewise. (grid_remap_kernel_arg_accesses): Likewise. (grid_expand_target_grid_body): Likewise. (expand_omp): Remove call to grid_expand_target_grid_body. (omp_make_gimple_edges): Remove GIMPLE_OMP_GRID_BODY case. * omp-general.c: Do not include hsa-common.h. (omp_maybe_offloaded): Do not check for HSA offloading. (omp_context_selector_matches): Likewise. * omp-low.c: Do not include hsa-common.h and omp-grid.h. (build_outer_var_ref): Remove handling of GIMPLE_OMP_GRID_BODY. (scan_sharing_clauses): Remove handling of OMP_CLAUSE__GRIDDIM_. (scan_omp_parallel): Remove handling of the phoney variant. (check_omp_nesting_restrictions): Remove handling of GIMPLE_OMP_GRID_BODY and GF_OMP_FOR_KIND_GRID_LOOP. (scan_omp_1_stmt): Remove handling of GIMPLE_OMP_GRID_BODY. (lower_omp_for_lastprivate): Remove handling of gridified loops. (lower_omp_for): Remove phony loop handling. (lower_omp_taskreg): Remove phony construct handling. (lower_omp_teams): Likewise. (lower_omp_grid_body): Removed. (lower_omp_1): Remove GIMPLE_OMP_GRID_BODY case. (execute_lower_omp): Do not call omp_grid_gridify_all_targets. * opts.c (common_handle_option): Do not handle hsa when processing OPT_foffload_. * params.opt (hsa-gen-debug-stores): Remove. * passes.def: Remove pass_ipa_hsa and pass_gen_hsail. * timevar.def: Remove TV_IPA_HSA. * toplev.c: Do not include hsa-common.h. (compile_file): Do not call hsa_output_brig. * tree-core.h (enum omp_clause_code): Remove OMP_CLAUSE__GRIDDIM_. (tree_omp_clause): Remove union field dimension. * tree-nested.c (convert_nonlocal_omp_clauses): Remove the OMP_CLAUSE__GRIDDIM_ case. (convert_local_omp_clauses): Likewise. * tree-pass.h (make_pass_gen_hsail): Remove declaration. (make_pass_ipa_hsa): Likewise. * tree-pretty-print.c (dump_omp_clause): Remove GIMPLE_OMP_GRID_BODY case. * tree.c (omp_clause_num_ops): Remove the element corresponding to OMP_CLAUSE__GRIDDIM_. (omp_clause_code_name): Likewise. (walk_tree_1): Remove GIMPLE_OMP_GRID_BODY case. * tree.h (OMP_CLAUSE__GRIDDIM__DIMENSION): Remove. (OMP_CLAUSE__GRIDDIM__SIZE): Likewise. (OMP_CLAUSE__GRIDDIM__GROUP): Likewise. gcc/fortran/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * f95-lang.c (gfc_init_builtin_functions): Remove processing of hsa-builtins.def. gcc/brig/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * brigfrontend/brig-util.h (hsa_type_packed_p): Declared. * brigfrontend/brig-util.cc (hsa_type_packed_p): Moved here from removed gcc/hsa-common.c. libgomp/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * plugin/Makefrag.am: Remove configuration of HSA plugin. * aclocal.m4: Regenerated. * Makefile.in: Regenerated. * config.h.in: Regenerated. * configure: Regenerated. * plugin/configfrag.ac: Likewise. * plugin/hsa_ext_finalize.h: Removed. * plugin/plugin-hsa.c: Likewise. * testsuite/Makefile.in: Regenerated. * testsuite/lib/libgomp.exp (offload_target_to_openacc_device_type): Remove hsa case. (check_effective_target_hsa_offloading_selected_nocache): Removed (check_effective_target_hsa_offloading_selected): Likewise. (libgomp_init): Do not add -Wno-hsa to additional_flags. * testsuite/libgomp.hsa.c/alloca-1.c: Removed test. * testsuite/libgomp.hsa.c/bitfield-1.c: Likewise. * testsuite/libgomp.hsa.c/bits-insns.c: Likewise. * testsuite/libgomp.hsa.c/builtins-1.c: Likewise. * testsuite/libgomp.hsa.c/c.exp: Likewise. * testsuite/libgomp.hsa.c/complex-1.c: Likewise. * testsuite/libgomp.hsa.c/complex-align-2.c: Likewise. * testsuite/libgomp.hsa.c/formal-actual-args-1.c: Likewise. * testsuite/libgomp.hsa.c/function-call-1.c: Likewise. * testsuite/libgomp.hsa.c/get-level-1.c: Likewise. * testsuite/libgomp.hsa.c/gridify-1.c: Likewise. * testsuite/libgomp.hsa.c/gridify-2.c: Likewise. * testsuite/libgomp.hsa.c/gridify-3.c: Likewise. * testsuite/libgomp.hsa.c/gridify-4.c: Likewise. * testsuite/libgomp.hsa.c/memory-operations-1.c: Likewise. * testsuite/libgomp.hsa.c/pr69568.c: Likewise. * testsuite/libgomp.hsa.c/pr82416.c: Likewise. * testsuite/libgomp.hsa.c/rotate-1.c: Likewise. * testsuite/libgomp.hsa.c/staticvar.c: Likewise. * testsuite/libgomp.hsa.c/switch-1.c: Likewise. * testsuite/libgomp.hsa.c/switch-branch-1.c: Likewise. * testsuite/libgomp.hsa.c/switch-sbr-2.c: Likewise. * testsuite/libgomp.hsa.c/tiling-1.c: Likewise. * testsuite/libgomp.hsa.c/tiling-2.c: Likewise. gcc/testsuite/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * lib/target-supports.exp (check_effective_target_offload_hsa): Removed. * c-c++-common/gomp/gridify-1.c: Removed test. * c-c++-common/gomp/gridify-2.c: Likewise. * c-c++-common/gomp/gridify-3.c: Likewise. * c-c++-common/gomp/hsa-indirect-call-1.c: Likewise. * gfortran.dg/gomp/gridify-1.f90: Likewise. * gcc.dg/gomp/gomp.exp: Do not pass -Wno-hsa to tests. * g++.dg/gomp/gomp.exp: Likewise. * gfortran.dg/gomp/gomp.exp: Likewise.
2020-08-03Multi-range implementation for value_range (irange).Aldy Hernandez1-28/+57
Implement class irange, a generic multi-range implementation for value ranges. This class is API compatible with value_range, and is meant to seamlessly coexist with it. gcc/ChangeLog: * Makefile.in (GTFILES): Move value-range.h up. * gengtype-lex.l: Set yylval to handle GTY markers on templates. * ipa-cp.c (initialize_node_lattices): Call value_range constructor. (ipcp_propagate_stage): Use in-place new so value_range construct is called. * ipa-fnsummary.c (evaluate_conditions_for_known_args): Use std vec instead of GCC's vec<>. (evaluate_properties_for_edge): Adjust for std vec. (ipa_fn_summary_t::duplicate): Same. (estimate_ipcp_clone_size_and_time): Same. * ipa-prop.c (ipa_get_value_range): Use in-place new for value_range. * ipa-prop.h (struct GTY): Remove class keyword for m_vr. * range-op.cc (empty_range_check): Rename to... (empty_range_varying): ...this and adjust for varying. (undefined_shift_range_check): Adjust for irange. (range_operator::wi_fold): Same. (range_operator::fold_range): Adjust for irange. Special case single pairs for performance. (range_operator::op1_range): Adjust for irange. (range_operator::op2_range): Same. (value_range_from_overflowed_bounds): Same. (value_range_with_overflow): Same. (create_possibly_reversed_range): Same. (range_true): Same. (range_false): Same. (range_true_and_false): Same. (get_bool_state): Adjust for irange and tweak for performance. (operator_equal::fold_range): Adjust for irange. (operator_equal::op1_range): Same. (operator_equal::op2_range): Same. (operator_not_equal::fold_range): Same. (operator_not_equal::op1_range): Same. (operator_not_equal::op2_range): Same. (build_lt): Same. (build_le): Same. (build_gt): Same. (build_ge): Same. (operator_lt::fold_range): Same. (operator_lt::op1_range): Same. (operator_lt::op2_range): Same. (operator_le::fold_range): Same. (operator_le::op1_range): Same. (operator_le::op2_range): Same. (operator_gt::fold_range): Same. (operator_gt::op1_range): Same. (operator_gt::op2_range): Same. (operator_ge::fold_range): Same. (operator_ge::op1_range): Same. (operator_ge::op2_range): Same. (operator_plus::wi_fold): Same. (operator_plus::op1_range): Same. (operator_plus::op2_range): Same. (operator_minus::wi_fold): Same. (operator_minus::op1_range): Same. (operator_minus::op2_range): Same. (operator_min::wi_fold): Same. (operator_max::wi_fold): Same. (cross_product_operator::wi_cross_product): Same. (operator_mult::op1_range): New. (operator_mult::op2_range): New. (operator_mult::wi_fold): Adjust for irange. (operator_div::wi_fold): Same. (operator_exact_divide::op1_range): Same. (operator_lshift::fold_range): Same. (operator_lshift::wi_fold): Same. (operator_lshift::op1_range): New. (operator_rshift::op1_range): New. (operator_rshift::fold_range): Adjust for irange. (operator_rshift::wi_fold): Same. (operator_cast::truncating_cast_p): Abstract out from operator_cast::fold_range. (operator_cast::fold_range): Adjust for irange and tweak for performance. (operator_cast::inside_domain_p): Abstract out from fold_range. (operator_cast::fold_pair): Same. (operator_cast::op1_range): Use abstracted methods above. Adjust for irange and tweak for performance. (operator_logical_and::fold_range): Adjust for irange. (operator_logical_and::op1_range): Same. (operator_logical_and::op2_range): Same. (unsigned_singleton_p): New. (operator_bitwise_and::remove_impossible_ranges): New. (operator_bitwise_and::fold_range): New. (wi_optimize_and_or): Adjust for irange. (operator_bitwise_and::wi_fold): Same. (set_nonzero_range_from_mask): New. (operator_bitwise_and::simple_op1_range_solver): New. (operator_bitwise_and::op1_range): Adjust for irange. (operator_bitwise_and::op2_range): Same. (operator_logical_or::fold_range): Same. (operator_logical_or::op1_range): Same. (operator_logical_or::op2_range): Same. (operator_bitwise_or::wi_fold): Same. (operator_bitwise_or::op1_range): Same. (operator_bitwise_or::op2_range): Same. (operator_bitwise_xor::wi_fold): Same. (operator_bitwise_xor::op1_range): New. (operator_bitwise_xor::op2_range): New. (operator_trunc_mod::wi_fold): Adjust for irange. (operator_logical_not::fold_range): Same. (operator_logical_not::op1_range): Same. (operator_bitwise_not::fold_range): Same. (operator_bitwise_not::op1_range): Same. (operator_cst::fold_range): Same. (operator_identity::fold_range): Same. (operator_identity::op1_range): Same. (class operator_unknown): New. (operator_unknown::fold_range): New. (class operator_abs): Adjust for irange. (operator_abs::wi_fold): Same. (operator_abs::op1_range): Same. (operator_absu::wi_fold): Same. (class operator_negate): Same. (operator_negate::fold_range): Same. (operator_negate::op1_range): Same. (operator_addr_expr::fold_range): Same. (operator_addr_expr::op1_range): Same. (pointer_plus_operator::wi_fold): Same. (pointer_min_max_operator::wi_fold): Same. (pointer_and_operator::wi_fold): Same. (pointer_or_operator::op1_range): New. (pointer_or_operator::op2_range): New. (pointer_or_operator::wi_fold): Adjust for irange. (integral_table::integral_table): Add entries for IMAGPART_EXPR and POINTER_DIFF_EXPR. (range_cast): Adjust for irange. (build_range3): New. (range3_tests): New. (widest_irange_tests): New. (multi_precision_range_tests): New. (operator_tests): New. (range_tests): New. * range-op.h (class range_operator): Adjust for irange. (range_cast): Same. * tree-vrp.c (range_fold_binary_symbolics_p): Adjust for irange and tweak for performance. (range_fold_binary_expr): Same. (masked_increment): Change to extern. * tree-vrp.h (masked_increment): New. * tree.c (cache_wide_int_in_type_cache): New function abstracted out from wide_int_to_tree_1. (wide_int_to_tree_1): Cache 0, 1, and MAX for pointers. * value-range-equiv.cc (value_range_equiv::deep_copy): Use kind method. (value_range_equiv::move): Same. (value_range_equiv::check): Adjust for irange. (value_range_equiv::intersect): Same. (value_range_equiv::union_): Same. (value_range_equiv::dump): Same. * value-range.cc (irange::operator=): Same. (irange::maybe_anti_range): New. (irange::copy_legacy_range): New. (irange::set_undefined): Adjust for irange. (irange::swap_out_of_order_endpoints): Abstract out from set(). (irange::set_varying): Adjust for irange. (irange::irange_set): New. (irange::irange_set_anti_range): New. (irange::set): Adjust for irange. (value_range::set_nonzero): Move to header file. (value_range::set_zero): Move to header file. (value_range::check): Rename to... (irange::verify_range): ...this. (value_range::num_pairs): Rename to... (irange::legacy_num_pairs): ...this, and adjust for irange. (value_range::lower_bound): Rename to... (irange::legacy_lower_bound): ...this, and adjust for irange. (value_range::upper_bound): Rename to... (irange::legacy_upper_bound): ...this, and adjust for irange. (value_range::equal_p): Rename to... (irange::legacy_equal_p): ...this. (value_range::operator==): Move to header file. (irange::equal_p): New. (irange::symbolic_p): Adjust for irange. (irange::constant_p): Same. (irange::singleton_p): Same. (irange::value_inside_range): Same. (irange::may_contain_p): Same. (irange::contains_p): Same. (irange::normalize_addresses): Same. (irange::normalize_symbolics): Same. (irange::legacy_intersect): Same. (irange::legacy_union): Same. (irange::union_): Same. (irange::intersect): Same. (irange::irange_union): New. (irange::irange_intersect): New. (subtract_one): New. (irange::invert): Adjust for irange. (dump_bound_with_infinite_markers): New. (irange::dump): Adjust for irange. (debug): Add irange versions. (range_has_numeric_bounds_p): Adjust for irange. (vrp_val_max): Move to header file. (vrp_val_min): Move to header file. (DEFINE_INT_RANGE_GC_STUBS): New. (DEFINE_INT_RANGE_INSTANCE): New. * value-range.h (class irange): New. (class int_range): New. (class value_range): Rename to a instantiation of int_range. (irange::legacy_mode_p): New. (value_range::value_range): Remove. (irange::kind): New. (irange::num_pairs): Adjust for irange. (irange::type): Adjust for irange. (irange::tree_lower_bound): New. (irange::tree_upper_bound): New. (irange::type): Adjust for irange. (irange::min): Same. (irange::max): Same. (irange::varying_p): Same. (irange::undefined_p): Same. (irange::zero_p): Same. (irange::nonzero_p): Same. (irange::supports_type_p): Same. (range_includes_zero_p): Same. (gt_ggc_mx): New. (gt_pch_nx): New. (irange::irange): New. (int_range::int_range): New. (int_range::operator=): New. (irange::set): Moved from value-range.cc and adjusted for irange. (irange::set_undefined): Same. (irange::set_varying): Same. (irange::operator==): Same. (irange::lower_bound): Same. (irange::upper_bound): Same. (irange::union_): Same. (irange::intersect): Same. (irange::set_nonzero): Same. (irange::set_zero): Same. (irange::normalize_min_max): New. (vrp_val_max): Move from value-range.cc. (vrp_val_min): Same. * vr-values.c (vr_values::get_lattice_entry): Call value_range constructor.
2020-07-20Correct handling of constant representations containing embedded nuls.Martin Sebor1-14/+14
Resolves: PR middle-end/95189 - memcmp being wrongly stripped like strcm PR middle-end/95886 - suboptimal memcpy with embedded zero bytes gcc/ChangeLog: PR middle-end/95189 PR middle-end/95886 * builtins.c (inline_expand_builtin_string_cmp): Rename... (inline_expand_builtin_bytecmp): ...to this. (builtin_memcpy_read_str): Don't expect data to be nul-terminated. (expand_builtin_memory_copy_args): Handle object representations with embedded nul bytes. (expand_builtin_memcmp): Same. (expand_builtin_strcmp): Adjust call to naming change. (expand_builtin_strncmp): Same. * expr.c (string_constant): Create empty strings with nonzero size. * fold-const.c (c_getstr): Rename locals and update comments. * tree.c (build_string): Accept null pointer argument. (build_string_literal): Same. * tree.h (build_string): Provide a default. (build_string_literal): Same. gcc/testsuite/ChangeLog: PR middle-end/95189 PR middle-end/95886 * gcc.dg/memcmp-pr95189.c: New test. * gcc.dg/strncmp-3.c: New test. * gcc.target/i386/memcpy-pr95886.c: New test.
2020-07-14core: add tree-node commentsNathan Sidwell1-1/+5
As we've moved to 64-bit systems, the padding information has become conditionally inaccurate. I also hit cases where invalid tree codes did not get flagged as invalid. gcc/ * tree-core.h (tree_decl_with_vis, tree_function_decl): Note additional padding on 64-bits * tree.c (cache_integer_cst): Note why no caching of enum literals. (get_tree_code_name): Robustify error case.
2020-07-13ipa-devirt: Fix crash in obj_type_ref_class [PR95114]Richard Sandiford1-3/+4
The testcase has failed since r9-5035, because obj_type_ref_class tries to look up an ODR type when no ODR type information is available. (The information was available earlier in the compilation, but was freed during pass_ipa_free_lang_data.) We then crash dereferencing the null get_odr_type result. The test passes with -O2. However, it fails again if -fdump-tree-all is used, since obj_type_ref_class is called indirectly from the dump routines. Other code creates ODR type entries on the fly by passing “true” as the insert parameter. But obj_type_ref_class can't do that unconditionally, since it should have no side-effects when used from the dumping code. Following a suggestion from Honza, this patch adds parameters to say whether the routines are being called from dump routines and uses those to derive the insert parameter. gcc/ PR middle-end/95114 * tree.h (virtual_method_call_p): Add a default-false parameter that indicates whether the function is being called from dump routines. (obj_type_ref_class): Likewise. * tree.c (virtual_method_call_p): Likewise. * ipa-devirt.c (obj_type_ref_class): Likewise. Lazily add ODR type information for the type when the parameter is false. * tree-pretty-print.c (dump_generic_node): Update calls to virtual_method_call_p and obj_type_ref_class accordingly. gcc/testsuite/ PR middle-end/95114 * g++.target/aarch64/pr95114.C: New test.
2020-06-28Underline argument in -Wnonnull and in C++ extend warning to the this ↵Martin Sebor1-3/+10
pointer [PR c++/86568]. Resolves: PR c++/86568 - -Wnonnull warnings should highlight the relevant argument not the closing parenthesis gcc/c-family/ChangeLog: PR c++/86568 * c-common.c (struct nonnull_arg_ctx): Add members. (check_function_nonnull): Use nonnull_arg_ctx as argument. Handle C++ member functions specially. Consider the this pointer implicitly nonnull. (check_nonnull_arg): Use location of argument when available. (check_function_arguments): Use nonnull_arg_ctx as argument. gcc/ChangeLog: PR c++/86568 * calls.c (maybe_warn_rdwr_sizes): Use location of argument if available. * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Same. Adjust indentation. * tree.c (get_nonnull_args): Consider the this pointer implicitly nonnull. * var-tracking.c (deps_vec): New type. (var_loc_dep_vec): New function. (VAR_LOC_DEP_VEC): Use it. gcc/testsuite/ChangeLog: PR c++/86568 * g++.dg/warn/Wnonnull5.C: New test. * c-c++-common/pr28656.c: Adjust text of expected warning. * c-c++-common/pr66208.c: Same. * g++.dg/cpp0x/nullptr22.C: Same. * g++.dg/ext/attr-nonnull.C: Same. * g++.dg/ext/attrib49.C: Same. * g++.dg/pr71973-2.C: Same. * g++.dg/warn/Wnonnull3.C: Same. * g++.dg/warn/Wnonnull4.C: Same. * obj-c++.dg/attributes/method-nonnull-1.mm: Same. * objc.dg/attributes/method-nonnull-1.m: Same.