aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
AgeCommit message (Collapse)AuthorFilesLines
2020-10-23c, c++: Implement -Wsizeof-array-div [PR91741]Marek Polacek1-0/+19
This patch implements a new warning, -Wsizeof-array-div. It warns about code like int arr[10]; sizeof (arr) / sizeof (short); where we have a division of two sizeof expressions, where the first argument is an array, and the second sizeof does not equal the size of the array element. See e.g. <https://www.viva64.com/en/examples/v706/>. Clang makes it possible to suppress the warning by parenthesizing the second sizeof like this: sizeof (arr) / (sizeof (short)); so I followed suit. In the C++ FE this was rather easy, because finish_parenthesized_expr already set TREE_NO_WARNING. In the C FE I've added a new tree code, PAREN_SIZEOF_EXPR, to discern between the non-() and () versions. This warning is enabled by -Wall. An example of the output: x.c:5:23: warning: expression does not compute the number of elements in this array; element type is ‘int’, not ‘short int’ [-Wsizeof-array-div] 5 | return sizeof (arr) / sizeof (short); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ x.c:5:25: note: add parentheses around ‘sizeof (short int)’ to silence this warning 5 | return sizeof (arr) / sizeof (short); | ^~~~~~~~~~~~~~ | ( ) x.c:4:7: note: array ‘arr’ declared here 4 | int arr[10]; | ^~~ gcc/c-family/ChangeLog: PR c++/91741 * c-common.c (verify_tree): Handle PAREN_SIZEOF_EXPR. (c_common_init_ts): Likewise. * c-common.def (PAREN_SIZEOF_EXPR): New tree code. * c-common.h (maybe_warn_sizeof_array_div): Declare. * c-warn.c (sizeof_pointer_memaccess_warning): Unwrap NOP_EXPRs. (maybe_warn_sizeof_array_div): New function. * c.opt (Wsizeof-array-div): New option. gcc/c/ChangeLog: PR c++/91741 * c-parser.c (c_parser_binary_expression): Implement -Wsizeof-array-div. (c_parser_postfix_expression): Set PAREN_SIZEOF_EXPR. (c_parser_expr_list): Handle PAREN_SIZEOF_EXPR like SIZEOF_EXPR. * c-tree.h (char_type_p): Declare. * c-typeck.c (char_type_p): No longer static. gcc/cp/ChangeLog: PR c++/91741 * typeck.c (cp_build_binary_op): Implement -Wsizeof-array-div. gcc/ChangeLog: PR c++/91741 * doc/invoke.texi: Document -Wsizeof-array-div. gcc/testsuite/ChangeLog: PR c++/91741 * c-c++-common/Wsizeof-pointer-div.c: Add dg-warning. * c-c++-common/Wsizeof-array-div1.c: New test. * g++.dg/warn/Wsizeof-array-div1.C: New test. * g++.dg/warn/Wsizeof-array-div2.C: New test.
2020-10-23Add a if-exists-then-else built-in spec functionDouglas Rupp1-0/+13
This patch adds an if-exists-then-else builtin spec function, which tests for the existence of a file and returns one or the other of the following arguments depending on the result of the test. This differs from the existing if-exists or if-exists-else function which return the name of the tested file if it exists. This new function is of help to a forthcoming change for VxWorks where we check for the presence of a specific header file to decide the name of a library to include in the link closure. 2020-10-23 Douglas Rupp <rupp@adacore.com> gcc/ * gcc.c (if-exists-then-else): New built-in spec function. * doc/invoke.texi: Document it.
2020-10-23rs6000: Fix extraneous characters in the documentationTulio Magno Quites Machado Filho via Gcc-patches1-3/+3
Replace them with a whitespace in order to avoid artifacts in the HTML document. 2020-08-19 Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com> gcc/ * doc/extend.texi (PowerPC Built-in Functions): Replace extraneous characters with whitespace.
2020-10-22[PATCH, rs6000] VSX load/store rightmost element operationsWill Schmidt1-0/+31
Hi, This adds support for the VSX load/store rightmost element operations. This includes the instructions lxvrbx, lxvrhx, lxvrwx, lxvrdx, stxvrbx, stxvrhx, stxvrwx, stxvrdx; And the builtins vec_xl_sext() /* vector load sign extend */ vec_xl_zext() /* vector load zero extend */ vec_xst_trunc() /* vector store truncate */. Testcase results show that the instructions added with this patch show up at low/no optimization (-O0), with a number of those being replaced with other load and store instructions at higher optimization levels. For consistency I've left the tests at -O0. [v2] Refreshed per review comments. Comments cleaned up, indentation corrected. gcc/ChangeLog: * config/rs6000/altivec.h (vec_xl_zext, vec_xl_sext, vec_xst_trunc): New defines. * config/rs6000/rs6000-builtin.def (BU_P10V_OVERLOAD_X): New builtin macro. (BU_P10V_AV_X): New builtin macro. (se_lxvrhbx, se_lxrbhx, se_lxvrwx, se_lxvrdx): Define internal names for load and sign extend vector element. (ze_lxvrbx, ze_lxvrhx, ze_lxvrwx, ze_lxvrdx): Define internal names for load and zero extend vector element. (tr_stxvrbx, tr_stxvrhx, tr_stxvrwx, tr_stxvrdx): Define internal names for truncate and store vector element. (se_lxvrx, ze_lxvrx, tr_stxvrx): Define internal names for overloaded load/store rightmost element. * config/rs6000/rs6000-call.c (altivec_builtin_types): Define the internal monomorphs P10_BUILTIN_SE_LXVRBX, P10_BUILTIN_SE_LXVRHX, P10_BUILTIN_SE_LXVRWX, P10_BUILTIN_SE_LXVRDX, P10_BUILTIN_ZE_LXVRBX, P10_BUILTIN_ZE_LXVRHX, P10_BUILTIN_ZE_LXVRWX, P10_BUILTIN_ZE_LXVRDX, P10_BUILTIN_TR_STXVRBX, P10_BUILTIN_TR_STXVRHX, P10_BUILTIN_TR_STXVRWX, P10_BUILTIN_TR_STXVRDX, (altivec_expand_lxvr_builtin): New expansion for load element builtins. (altivec_expand_stv_builtin): Update to for truncate and store builtins. (altivec_expand_builtin): Add clases for load/store rightmost builtins. (altivec_init_builtins): Add def_builtin entries for __builtin_altivec_se_lxvrbx, __builtin_altivec_se_lxvrhx, __builtin_altivec_se_lxvrwx, __builtin_altivec_se_lxvrdx, __builtin_altivec_ze_lxvrbx, __builtin_altivec_ze_lxvrhx, __builtin_altivec_ze_lxvrwx, __builtin_altivec_ze_lxvrdx, __builtin_altivec_tr_stxvrbx, __builtin_altivec_tr_stxvrhx, __builtin_altivec_tr_stxvrwx, __builtin_altivec_tr_stxvrdx, __builtin_vec_se_lxvrx, __builtin_vec_ze_lxvrx, __builtin_vec_tr_stxvrx. * config/rs6000/vsx.md (vsx_lxvr<wd>x, vsx_stxvr<wd>x, vsx_stxvr<wd>x): New define_insn entries. * doc/extend.texi: Add documentation for vsx_xl_sext, vsx_xl_zext, and vec_xst_trunc. gcc/testsuite/ChangeLog: * gcc.target/powerpc/vsx-load-element-extend-char.c: New test. * gcc.target/powerpc/vsx-load-element-extend-int.c: New test. * gcc.target/powerpc/vsx-load-element-extend-longlong.c: New test. * gcc.target/powerpc/vsx-load-element-extend-short.c: New test. * gcc.target/powerpc/vsx-store-element-truncate-char.c: New test. * gcc.target/powerpc/vsx-store-element-truncate-int.c: New test. * gcc.target/powerpc/vsx-store-element-truncate-longlong.c: New test. * gcc.target/powerpc/vsx-store-element-truncate-short.c: New test.
2020-10-22Implement no_stack_protector attribute.Martin Liska1-0/+4
gcc/ChangeLog: 2020-05-18 Martin Liska <mliska@suse.cz> PR c/94722 * cfgexpand.c (stack_protect_decl_phase): Guard with lookup_attribute("no_stack_protector") at various places. (expand_used_vars): Likewise here. * doc/extend.texi: Document no_stack_protector attribute. gcc/ada/ChangeLog: 2020-05-18 Martin Liska <mliska@suse.cz> PR c/94722 * gcc-interface/utils.c (handle_no_stack_protect_attribute): New. (handle_stack_protect_attribute): Add error message for a no_stack_protector function. gcc/c-family/ChangeLog: 2020-05-18 Martin Liska <mliska@suse.cz> PR c/94722 * c-attribs.c (handle_no_stack_protect_function_attribute): New. (handle_stack_protect_attribute): Add error message for a no_stack_protector function. gcc/testsuite/ChangeLog: 2020-05-18 Martin Liska <mliska@suse.cz> PR c/94722 * g++.dg/no-stack-protector-attr-2.C: New test. * g++.dg/no-stack-protector-attr-3.C: New test. * g++.dg/no-stack-protector-attr.C: New test.
2020-10-20gcc/doc/invoke.texi: Fix @table syntaxTobias Burnus1-1/+1
gcc/ * doc/invoke.texi (NVPTX options): Use @item not @itemx.
2020-10-19doc: Add closing parenthesis to -ffat-lto-objects docsJonathan Wakely1-1/+1
gcc/ChangeLog: * doc/invoke.texi (OPptimize Options): Add missing closing parenthesis.
2020-10-15[nvptx] Remove -m32Tom de Vries1-4/+3
The nvptx port has an -m32 option, but it's not clear whether this was ever build/tested/used. Don't expose to user anymore. Tested on nvptx. gcc/ChangeLog: 2020-10-15 Tom de Vries <tdevries@suse.de> PR target/97436 * config/nvptx/nvptx.opt (m32): Comment out. * doc/invoke.texi (NVPTX options): Remove -m32. gcc/testsuite/ChangeLog: 2020-10-15 Tom de Vries <tdevries@suse.de> PR target/97436 * gcc.target/nvptx/atomic_fetch-3.c: Remove.
2020-10-15RISC-V: Add support for -mcpu option.Kito Cheng1-4/+20
- The behavior of -mcpu basically equal to -march plus -mtune, but it has lower priority than -march and -mtune. - The behavior and available options has sync with clang except we don't add few LLVM specific value, and add more sifive processor to the list. - -mtune also accept all available options of -mcpu, and use it setting. gcc/ChangeLog: * common/config/riscv/riscv-common.c (riscv_cpu_tables): New. (riscv_arch_str): Return empty string if current_subset_list is NULL. (riscv_find_cpu): New. (riscv_handle_option): Verify option value of -mcpu. (riscv_expand_arch): Using std::string. (riscv_default_mtune): New. (riscv_expand_arch_from_cpu): Ditto. * config/riscv/riscv-cores.def: New. * config/riscv/riscv-protos.h (riscv_find_cpu): New. (riscv_cpu_info): New. * config/riscv/riscv.c (riscv_tune_info): Rename ... (riscv_tune_param): ... to this. (riscv_cpu_info): Rename ... (riscv_tune_info): ... to this. (tune_info): Rename ... (tune_param): ... to this. (rocket_tune_info): Update data type name. (sifive_7_tune_info): Ditto. (optimize_size_tune_info): Ditto. (riscv_cpu_info_table): Rename ... (riscv_tune_info_table): ... to this. (riscv_parse_cpu): Rename ... (riscv_parse_tune): ... to this, and translate valid -mcpu option to -mtune option. (riscv_rtx_costs): Rename tune_info to tune_param. (riscv_class_max_nregs): Ditto. (riscv_memory_move_cost): Ditto. (riscv_init_machine_status): Use value of -mcpu if -mtune is not given, and rename tune_info to tune_param. * config/riscv/riscv.h (riscv_expand_arch_from_cpu): New. (riscv_default_mtune): Ditto. (EXTRA_SPEC_FUNCTIONS): Add riscv_expand_arch_from_cpu and riscv_default_mtune. (OPTION_DEFAULT_SPECS): Handle default value of -march/-mabi. (DRIVER_SELF_SPECS): Expand -march from -mcpu if -march is not given. * config/riscv/riscv.opt (-mcpu): New option. * config/riscv/t-riscv ($(common_out_file)): Add riscv-cores.def to dependency. * doc/invoke.texi (RISC-V Option): Add -mcpu, and update the description of default value for -mtune and -march. gcc/testsuite/ChangeLog: * gcc.target/riscv/mcpu-1.c: New. * gcc.target/riscv/mcpu-2.c: Ditto. * gcc.target/riscv/mcpu-3.c: Ditto. * gcc.target/riscv/mcpu-4.c: Ditto. * gcc.target/riscv/mcpu-5.c: Ditto. * gcc.target/riscv/mcpu-6.c: Ditto. * gcc.target/riscv/mcpu-7.c: Ditto.
2020-10-15Enable Intel HRESET InstructionHongyu Wang2-2/+10
gcc/ * common/config/i386/cpuinfo.h (get_available_features): Detect HRESET. * common/config/i386/i386-common.c (OPTION_MASK_ISA2_HRESET_SET, OPTION_MASK_ISA2_HRESET_UNSET): New macros. (ix86_handle_option): Handle -mhreset. * common/config/i386/i386-cpuinfo.h (enum processor_features): Add FEATURE_HRESET. * common/config/i386/i386-isas.h: Add ISA_NAMES_TABLE_ENTRY for hreset. * config.gcc: Add hresetintrin.h * config/i386/hresetintrin.h: New header file. * config/i386/x86gprintrin.h: Include hresetintrin.h. * config/i386/cpuid.h (bit_HRESET): New. * config/i386/i386-builtin.def: Add new builtin. * config/i386/i386-expand.c (ix86_expand_builtin): Handle new builtin. * config/i386/i386-c.c (ix86_target_macros_internal): Define __HRESET__. * config/i386/i386-options.c (isa2_opts): Add -mhreset. (ix86_valid_target_attribute_inner_p): Handle hreset. * config/i386/i386.h (TARGET_HRESET, TARGET_HRESET_P, PTA_HRESET): New. (PTA_ALDERLAKE): Add PTA_HRESET. * config/i386/i386.opt: Add option -mhreset. * config/i386/i386.md (UNSPECV_HRESET): New unspec. (hreset): New define_insn. * doc/invoke.texi: Document -mhreset. * doc/extend.texi: Document hreset. gcc/testsuite/ * gcc.target/i386/hreset-1.c: New test. * gcc.target/i386/funcspec-56.inc: Add new target attribute. * gcc.target/i386/x86gprintrin-1.c: Add -mhreset. * gcc.target/i386/x86gprintrin-2.c: Ditto. * gcc.target/i386/x86gprintrin-3.c: Ditto. * gcc.target/i386/x86gprintrin-4.c: Add mhreset. * gcc.target/i386/x86gprintrin-5.c: Ditto.
2020-10-15Enable gcc support for UINTRliuhongt2-3/+10
2020-05-20 Hongtao Liu <hongtao.liu@intel.com> gcc/ * common/config/i386/cpuinfo.h (get_available_features): Detect UINTR. * common/config/i386/i386-common.c (OPTION_MASK_ISA2_UINTR_SET OPTION_MASK_ISA2_UINTR_UNSET): New. (ix86_handle_option): Handle -muintr. * common/config/i386/i386-cpuinfo.h (enum processor_features): Add FEATURE_UINTR. * common/config/i386/i386-isas.h: Add ISA_NAMES_TABLE_ENTRY for uintr. * config.gcc: Add uintrintrin.h to extra_headers. * config/i386/uintrintrin.h: New. * config/i386/cpuid.h (bit_UINTR): New. * config/i386/i386-builtin-types.def: Add new types. * config/i386/i386-builtin.def: Add new builtins. * config/i386/i386-builtins.c (ix86_init_mmx_sse_builtins): Add __builtin_ia32_testui. * config/i386/i386-builtins.h (ix86_builtins): Add IX86_BUILTIN_TESTUI. * config/i386/i386-c.c (ix86_target_macros_internal): Define __UINTR__. * config/i386/i386-expand.c (ix86_expand_special_args_builtin): Handle UINT8_FTYPE_VOID. (ix86_expand_builtin): Handle IX86_BUILTIN_TESTUI. * config/i386/i386-options.c (isa2_opts): Add -muintr. (ix86_valid_target_attribute_inner_p): Handle UINTR. (ix86_option_override_internal): Add TARGET_64BIT check for UINTR. * config/i386/i386.h (TARGET_UINTR, TARGET_UINTR_P, PTA_UINTR): New. (PTA_SAPPHIRRAPIDS): Add PTA_UINTR. * config/i386/i386.opt: Add -muintr. * config/i386/i386.md (define_int_iterator UINTR_UNSPECV): New. (define_int_attr uintr_unspecv): New. (uintr_<uintr_unspecv>, uintr_senduipi, testui): New define_insn patterns. * config/i386/x86gprintrin.h: Include uintrintrin.h * doc/invoke.texi: Document -muintr. * doc/extend.texi: Document uintr. gcc/testsuite/ * gcc.target/i386/funcspec-56.inc: Add new target attribute. * gcc.target/i386/uintr-1.c: New test. * gcc.target/i386/uintr-2.c: Ditto. * gcc.target/i386/uintr-3.c: Ditto. * gcc.target/i386/uintr-4.c: Ditto. * gcc.target/i386/uintr-5.c: Ditto. * gcc.target/i386/x86gprintrin-1.c: Add -muintr for 64bit target. * gcc.target/i386/x86gprintrin-2.c: Ditto. * gcc.target/i386/x86gprintrin-3.c: Ditto. * gcc.target/i386/x86gprintrin-4.c: Add muintr for 64bit target. * gcc.target/i386/x86gprintrin-5.c: Ditto.
2020-10-14Support ofsetted parameters in local modrefJan Hubicka1-0/+3
2020-10-14 Jan Hubicka <hubicka@ucw.cz> * doc/invoke.texi: (ipa-jump-function-lookups): Document param. * ipa-modref.c (merge_call_side_effects): Use unadjusted_ptr_and_unit_offset. * ipa-prop.c (unadjusted_ptr_and_unit_offset): New function. * ipa-prop.h (unadjusted_ptr_and_unit_offset): Declare. * params.opt: (-param-ipa-jump-function-lookups): New.
2020-10-12analyzer: add warnings about writes to constant regions [PR95007]David Malcolm1-0/+28
This patch adds two new warnings: -Wanalyzer-write-to-const -Wanalyzer-write-to-string-literal for code paths where the analyzer detects a write to a constant region. As noted in the documentation part of the patch, the analyzer doesn't prioritize detection of such writes, in that the state-merging logic will blithely lose the distinction between const and non-const regions. Hence false negatives are likely to arise due to state-merging. However, if the analyzer does happen to spot such a write, it seems worth reporting, hence this patch. gcc/analyzer/ChangeLog: * analyzer.opt (Wanalyzer-write-to-const): New. (Wanalyzer-write-to-string-literal): New. * region-model-impl-calls.cc (region_model::impl_call_memcpy): Call check_for_writable_region. (region_model::impl_call_memset): Likewise. (region_model::impl_call_strcpy): Likewise. * region-model.cc (class write_to_const_diagnostic): New. (class write_to_string_literal_diagnostic): New. (region_model::check_for_writable_region): New. (region_model::set_value): Call check_for_writable_region. * region-model.h (region_model::check_for_writable_region): New decl. gcc/ChangeLog: * doc/invoke.texi: Document -Wanalyzer-write-to-const and -Wanalyzer-write-to-string-literal. gcc/testsuite/ChangeLog: PR c/83347 PR middle-end/90404 PR analyzer/95007 * gcc.dg/analyzer/write-to-const-1.c: New test. * gcc.dg/analyzer/write-to-string-literal-1.c: New test.
2020-10-12nvptx - invoke.texi: Update default of -misaTobias Burnus1-1/+1
Followup to commit 383400a6078d75bbfa1216c9af2c37f7e88740c9 gcc/ChangeLog * doc/invoke.texi (nvptx's -misa): Update default to sm_35.
2020-10-09Fixup gcc.dg/vect/pr65947-3.c when masked loads are availableRichard Biener1-0/+3
The following adds a effective target to properly allow the gcc.dg/vect/pr65947-3.c expected vectorization to be adjusted when run with, say, -march=cascadelake. 2020-10-09 Richard Biener <rguenther@suse.de> gcc/ * doc/sourcebuild.texi (vect_masked_load): Document. gcc/testsuite * lib/target-supports.exp (check_effective_target_vect_masked_load): New effective target. * gcc.dg/vect/pr65947-3.c: Update.
2020-10-08Improve documentation of -fallow-store-data-racesqing zhao1-1/+12
2020-10-08 John Henning <john.henning@oracle.com> gcc/ PR other/97309 * doc/invoke.texi: Improve documentation of -fallow-store-data-races.
2020-10-07Add -fdiagnostics-path-format=separate-events to -fdiagnostics-plain-outputDavid Malcolm1-1/+2
The path-printing default of -fdiagnostics-path-format=inline-events interacted poorly with -fdiagnostics-plain-output, so it makes most sense to add -fdiagnostics-path-format=separate-events to -fdiagnostics-plain-output. Seen when adding an experimental analyzer plugin to gcc.dg/plugin.exp. gcc/ChangeLog: * doc/invoke.texi (-fdiagnostics-plain-output): Add -fdiagnostics-path-format=separate-events to list of options injected by -fdiagnostics-plain-output. * opts-common.c (decode_cmdline_options_to_array): Likewise. gcc/testsuite/ChangeLog: * g++.dg/analyzer/analyzer.exp (DEFAULT_CXXFLAGS): Remove -fdiagnostics-path-format=separate-events. * gcc.dg/analyzer/analyzer.exp (DEFAULT_CFLAGS): Likewise. * gcc.dg/plugin/diagnostic-path-format-default.c: Rename to... * gcc.dg/plugin/diagnostic-path-format-plain.c: ...this. Remove dg-options directive. Copy remainder of test from diagnostic-path-format-separate-events.c. * gcc.dg/plugin/diagnostic-test-paths-2.c: Add -fdiagnostics-path-format=inline-events to options. Fix expected output for location of conditional within "for" loop. * gcc.dg/plugin/plugin.exp (plugin_test_list): Update for renaming. * gfortran.dg/analyzer/analyzer.exp (DEFAULT_FFLAGS): Remove -fdiagnostics-path-format=separate-events.
2020-10-06IBM Z: Doc: Add z15/arch13 to the list of -march/-mtune optionsAndreas Krebbel1-1/+1
gcc/ChangeLog: * doc/invoke.texi: Add z15/arch13 to the list of documented -march/-mtune options.
2020-10-03doc: Replace roudnevenl with roundevenlH.J. Lu1-1/+1
PR other/97280 * doc/extend.texi: Replace roudnevenl with roundevenl
2020-10-02ipa: Multiple predicates for loop properties, with frequenciesMartin Jambor1-0/+4
This patch enhances the ability of IPA to reason under what conditions loops in a function have known iteration counts or strides because it replaces single predicates which currently hold conjunction of predicates for all loops with vectors capable of holding multiple predicates, each with a cumulative frequency of loops with the property. This second property is then used by IPA-CP to much more aggressively boost its heuristic score for cloning opportunities which make iteration counts or strides of frequent loops compile time constant. gcc/ChangeLog: 2020-09-03 Martin Jambor <mjambor@suse.cz> * ipa-fnsummary.h (ipa_freqcounting_predicate): New type. (ipa_fn_summary): Change the type of loop_iterations and loop_strides to vectors of ipa_freqcounting_predicate. (ipa_fn_summary::ipa_fn_summary): Construct the new vectors. (ipa_call_estimates): New fields loops_with_known_iterations and loops_with_known_strides. * ipa-cp.c (hint_time_bonus): Multiply param_ipa_cp_loop_hint_bonus with the expected frequencies of loops with known iteration count or stride. * ipa-fnsummary.c (add_freqcounting_predicate): New function. (ipa_fn_summary::~ipa_fn_summary): Release the new vectors instead of just two predicates. (remap_hint_predicate_after_duplication): Replace with function remap_freqcounting_preds_after_dup. (ipa_fn_summary_t::duplicate): Use it or duplicate new vectors. (ipa_dump_fn_summary): Dump the new vectors. (analyze_function_body): Compute the loop property vectors. (ipa_call_context::estimate_size_and_time): Calculate also loops_with_known_iterations and loops_with_known_strides. Adjusted dumping accordinly. (remap_hint_predicate): Replace with function remap_freqcounting_predicate. (ipa_merge_fn_summary_after_inlining): Use it. (inline_read_section): Stream loopcounting vectors instead of two simple predicates. (ipa_fn_summary_write): Likewise. * params.opt (ipa-max-loop-predicates): New parameter. * doc/invoke.texi (ipa-max-loop-predicates): Document new param. gcc/testsuite/ChangeLog: 2020-09-03 Martin Jambor <mjambor@suse.cz> * gcc.dg/ipa/ipcp-loophint-1.c: New test.
2020-10-01PR target/97250: i386: Add support for x86-64-v2, x86-64-v3, x86-64-v4 ↵Florian Weimer1-1/+14
levels for x86-64 These micro-architecture levels are defined in the x86-64 psABI: https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/77566eb03bc6a326811cb7e9 PTA_NO_TUNE is introduced so that the new processor alias table entries do not affect the CPU tuning setting in ix86_tune. The tests depend on the macros added in commit 92e652d8c21bd7e66cbb0f900 ("i386: Define __LAHF_SAHF__ and __MOVBE__ macros, based on ISA flags"). gcc/: PR target/97250 * config/i386/i386.h (PTA_NO_TUNE, PTA_X86_64_BASELINE) (PTA_X86_64_V2, PTA_X86_64_V3, PTA_X86_64_V4): New. * common/config/i386/i386-common.c (processor_alias_table): Add "x86-64-v2", "x86-64-v3", "x86-64-v4". * config/i386/i386-options.c (ix86_option_override_internal): Handle new PTA_NO_TUNE processor table entries. * doc/invoke.texi (x86 Options): Document new -march values. gcc/testsuite/: PR target/97250 * gcc.target/i386/x86-64-v2.c: New test. * gcc.target/i386/x86-64-v3.c: New test. * gcc.target/i386/x86-64-v3-haswell.c: New test. * gcc.target/i386/x86-64-v3-skylake.c: New test. * gcc.target/i386/x86-64-v4.c: New test.
2020-09-30arm: add support for Cortex-A78 and Cortex-A78AEPrzemyslaw Wirkus1-0/+1
This patch introduces support for Cortex-A78 [0] and Cortex-A78AE [1] cpus. [0]: https://www.arm.com/products/silicon-ip-cpu/cortex-a/cortex-a78 [1]: https://www.arm.com/products/silicon-ip-cpu/cortex-a/cortex-a78ae OK for master branch ? kind regards Przemyslaw Wirkus gcc/ChangeLog: * config/arm/arm-cpus.in: Add Cortex-A78 and Cortex-A78AE cores. * config/arm/arm-tables.opt: Regenerate. * config/arm/arm-tune.md: Regenerate. * doc/invoke.texi: Update docs.
2020-09-30aarch64: add support for Cortex-A78 and Cortex-A78AEPrzemyslaw Wirkus1-0/+1
This patch introduces support for Cortex-A78 [0] and Cortex-A78AE [1] cpus. [0]: https://www.arm.com/products/silicon-ip-cpu/cortex-a/cortex-a78 [1]: https://www.arm.com/products/silicon-ip-cpu/cortex-a/cortex-a78ae OK for master branch ? kind regards Przemyslaw Wirkus gcc/ChangeLog: * config/aarch64/aarch64-cores.def: Add Cortex-A78 and Cortex-A78AE cores. * config/aarch64/aarch64-tune.md: Regenerate. * doc/invoke.texi: Add -mtune=cortex-a78 and -mtune=cortex-a78ae.
2020-09-30[nvptx] Add type arg to TARGET_LIBC_HAS_FUNCTIONTom de Vries1-2/+5
GCC has a target hook TARGET_LIBC_HAS_FUNCTION, which tells the compiler which functions it can expect to be present in libc. The default target hook does not include the sincos functions. The nvptx port of newlib does include sincos and sincosf, but not sincosl. The target hook TARGET_LIBC_HAS_FUNCTION does not distinguish between sincos, sincosf and sincosl, so if we enable it for the sincos functions, then for test.c: ... long double x, a, b; int main (void) { x = 0.5; a = sinl (x); b = cosl (x); printf ("a: %f\n", (double)a); printf ("b: %f\n", (double)b); return 0; } ... we introduce a regression: ... $ gcc test.c -lm -O2 unresolved symbol sincosl collect2: error: ld returned 1 exit status ... Add a type argument to target hook TARGET_LIBC_HAS_FUNCTION_TYPE, and use it in nvptx_libc_has_function_type to enable sincos and sincosf, but not sincosl. Build and reg-tested on x86_64-linux. Build and tested on nvptx. gcc/ChangeLog: 2020-09-28 Tobias Burnus <tobias@codesourcery.com> Tom de Vries <tdevries@suse.de> * builtins.c (expand_builtin_cexpi, fold_builtin_sincos): Update targetm.libc_has_function call. * builtins.def (DEF_C94_BUILTIN, DEF_C99_BUILTIN, DEF_C11_BUILTIN): (DEF_C2X_BUILTIN, DEF_C99_COMPL_BUILTIN, DEF_C99_C90RES_BUILTIN): Same. * config/darwin-protos.h (darwin_libc_has_function): Update prototype. * config/darwin.c (darwin_libc_has_function): Add arg. * config/linux-protos.h (linux_libc_has_function): Update prototype. * config/linux.c (linux_libc_has_function): Add arg. * config/i386/i386.c (ix86_libc_has_function): Update targetm.libc_has_function call. * config/nvptx/nvptx.c (nvptx_libc_has_function): New function. (TARGET_LIBC_HAS_FUNCTION): Redefine to nvptx_libc_has_function. * convert.c (convert_to_integer_1): Update targetm.libc_has_function call. * match.pd: Same. * target.def (libc_has_function): Add arg. * doc/tm.texi: Regenerate. * targhooks.c (default_libc_has_function, gnu_libc_has_function) (no_c99_libc_has_function): Add arg. * targhooks.h (default_libc_has_function, no_c99_libc_has_function) (gnu_libc_has_function): Update prototype. * tree-ssa-math-opts.c (pass_cse_sincos::execute): Update targetm.libc_has_function call. gcc/fortran/ChangeLog: 2020-09-30 Tom de Vries <tdevries@suse.de> * f95-lang.c (gfc_init_builtin_functions): Update targetm.libc_has_function call.
2020-09-29c++: Implement -Wrange-loop-construct [PR94695]Marek Polacek1-1/+20
This new warning can be used to prevent expensive copies inside range-based for-loops, for instance: struct S { char arr[128]; }; void fn () { S arr[5]; for (const auto x : arr) { } } where auto deduces to S and then we copy the big S in every iteration. Using "const auto &x" would not incur such a copy. With this patch the compiler will warn: q.C:4:19: warning: loop variable 'x' creates a copy from type 'const S' [-Wrange-loop-construct] 4 | for (const auto x : arr) { } | ^ q.C:4:19: note: use reference type 'const S&' to prevent copying 4 | for (const auto x : arr) { } | ^ | & As per Clang, this warning is suppressed for trivially copyable types whose size does not exceed 64B. The tricky part of the patch was how to figure out if using a reference would have prevented a copy. To that point, I'm using the new function called ref_conv_binds_directly_p. This warning is enabled by -Wall. Further warnings of similar nature should follow soon. gcc/c-family/ChangeLog: PR c++/94695 * c.opt (Wrange-loop-construct): New option. gcc/cp/ChangeLog: PR c++/94695 * call.c (ref_conv_binds_directly_p): New function. * cp-tree.h (ref_conv_binds_directly_p): Declare. * parser.c (warn_for_range_copy): New function. (cp_convert_range_for): Call it. gcc/ChangeLog: PR c++/94695 * doc/invoke.texi: Document -Wrange-loop-construct. gcc/testsuite/ChangeLog: PR c++/94695 * g++.dg/warn/Wrange-loop-construct.C: New test.
2020-09-29arm: add support for Cortex-X1Przemyslaw Wirkus1-1/+1
This adds support for the Arm Cortex-X1 CPU. For more information about this processor, see [0]. [0] : https://www.arm.com/products/cortex-x gcc/ChangeLog: * config/arm/arm-cpus.in: Add Cortex-X1 core. * config/arm/arm-tables.opt: Regenerate. * config/arm/arm-tune.md: Regenerate. * doc/invoke.texi: Update docs.
2020-09-29aarch64: add support for Cortex-X1Przemyslaw Wirkus1-1/+1
This adds support for the Arm Cortex-X1 CPU in AArch64 GCC. For more information about this processor, see [0]. [0] : https://www.arm.com/products/cortex-x gcc/ChangeLog: * config/aarch64/aarch64-cores.def: Add Cortex-X1 Arm core. * config/aarch64/aarch64-tune.md: Regenerate. * doc/invoke.texi: Add -mtune=cortex-x1 docs.
2020-09-29Revert "switch lowering: limit number of cluster attemps"Martin Liska1-4/+0
This reverts commit c6df6039e9180c580945266302ec14047d358364.
2020-09-28Enable GCC support for AMX-TILE,AMX-INT8,AMX-BF16.liuhongt3-0/+34
AMX-TILE:ldtilecfg/sttilecfg/tileloadd/tileloaddt1/tilezero/tilerelease AMX-INT8:tdpbssd/tdpbsud/tdpbusd/tdpbuud AMX-BF16:tdpbf16ps gcc/ChangeLog * common/config/i386/i386-common.c (OPTION_MASK_ISA2_AMX_TILE_SET, OPTION_MASK_ISA2_AMX_INT8_SET, OPTION_MASK_ISA2_AMX_BF16_SET, OPTION_MASK_ISA2_AMX_TILE_UNSET, OPTION_MASK_ISA2_AMX_INT8_UNSET, OPTION_MASK_ISA2_AMX_BF16_UNSET, OPTION_MASK_ISA2_XSAVE_UNSET): New marcos. (ix86_handle_option): Hanlde -mamx-tile, -mamx-int8, -mamx-bf16. * common/config/i386/i386-cpuinfo.h (processor_types): Add FEATURE_AMX_TILE, FEATURE_AMX_INT8, FEATURE_AMX_BF16. * common/config/i386/cpuinfo.h (XSTATE_TILECFG, XSTATE_TILEDATA, XCR_AMX_ENABLED_MASK): New macro. (get_available_features): Enable AMX features only if their states are suoorited by OSXSAVE. * common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for amx-tile, amx-int8, amx-bf16. * config.gcc: Add amxtileintrin.h, amxint8intrin.h, amxbf16intrin.h to extra headers. * config/i386/amxbf16intrin.h: New file. * config/i386/amxint8intrin.h: Ditto. * config/i386/amxtileintrin.h: Ditto. * config/i386/cpuid.h (bit_AMX_BF16, bit_AMX_TILE, bit_AMX_INT8): New macro. * config/i386/i386-c.c (ix86_target_macros_internal): Define __AMX_TILE__, __AMX_INT8__, AMX_BF16__. * config/i386/i386-options.c (ix86_target_string): Add -mamx-tile, -mamx-int8, -mamx-bf16. (ix86_option_override_internal): Handle AMX-TILE, AMX-INT8, AMX-BF16. * config/i386/i386.h (TARGET_AMX_TILE, TARGET_AMX_TILE_P, TARGET_AMX_INT8, TARGET_AMX_INT8_P, TARGET_AMX_BF16_P, PTA_AMX_TILE, PTA_AMX_INT8, PTA_AMX_BF16): New macros. * config/i386/i386.opt: Add -mamx-tile, -mamx-int8, -mamx-bf16. * config/i386/immintrin.h: Include amxtileintrin.h, amxint8intrin.h, amxbf16intrin.h. * doc/invoke.texi: Document -mamx-tile, -mamx-int8, -mamx-bf16. * doc/extend.texi: Document amx-tile, amx-int8, amx-bf16. * doc/sourcebuild.texi ((Effective-Target Keywords, Other hardware attributes): Document amx_int8, amx_tile, amx_bf16. gcc/testsuite/ChangeLog * lib/target-supports.exp (check_effective_target_amx_tile, check_effective_target_amx_int8, check_effective_target_amx_bf16): New proc. * g++.dg/other/i386-2.C: Add -mamx-tile, -mamx-int8, -mamx-bf16. * g++.dg/other/i386-3.C: Ditto. * gcc.target/i386/sse-12.c: Ditto. * gcc.target/i386/sse-13.c: Ditto. * gcc.target/i386/sse-14.c: Ditto. * gcc.target/i386/sse-22.c: Ditto. * gcc.target/i386/sse-23.c: Ditto. * gcc.target/i386/funcspec-56.inc: Add new target attribute. * gcc.target/i386/amx-check.h: New header file. * gcc.target/i386/amxbf16-asmatt-1.c: New test. * gcc.target/i386/amxint8-asmatt-1.c: New test. * gcc.target/i386/amxtile-asmatt-1.c: Ditto. * gcc.target/i386/amxbf16-asmintel-1.c: Ditto. * gcc.target/i386/amxint8-asmintel-1.c: Ditto. * gcc.target/i386/amxtile-asmintel-1.c: Ditto. * gcc.target/i386/amxbf16-dpbf16ps-2.c: Ditto. * gcc.target/i386/amxint8-dpbssd-2.c: Ditto. * gcc.target/i386/amxint8-dpbsud-2.c: Ditto. * gcc.target/i386/amxint8-dpbusd-2.c: Ditto. * gcc.target/i386/amxint8-dpbuud-2.c: Ditto. * gcc.target/i386/amxtile-2.c: Ditto.
2020-09-26Disable ipa-modref with live patchingJan Hubicka1-1/+1
2020-09-26 Jan Hubicka <hubicka@ucw.cz> * doc/invoke.texi: Add -fno-ipa-modref to flags disabled by -flive-patching. * opts.c (control_options_for_live_patching): Disable ipa-modref.
2020-09-24arm: Add support for Neoverse N2 CPUAlex Coplan1-3/+3
This adds support for Arm's Neoverse N2 CPU to the AArch32 backend. Neoverse N2 builds AArch32 at EL0 and therefore needs support in AArch32 GCC. gcc/ChangeLog: * config/arm/arm-cpus.in (neoverse-n2): New. * config/arm/arm-tables.opt: Regenerate. * config/arm/arm-tune.md: Regenerate. * doc/invoke.texi: Document support for Neoverse N2.
2020-09-24aarch64: Add support for Neoverse N2 CPUAlex Coplan1-2/+2
This patch adds support for Arm's Neoverse N2 CPU to the AArch64 backend. gcc/ChangeLog: * config/aarch64/aarch64-cores.def: Add Neoverse N2. * config/aarch64/aarch64-tune.md: Regenerate. * doc/invoke.texi: Document AArch64 support for Neoverse N2.
2020-09-24Add access through parameter derference tracking to modrefJan Hubicka1-4/+24
re-add tracking of accesses which was unfinished in David's patch. At the moment I only implemented tracking of the fact that access is based on derefernece of the parameter (so we track THIS pointers). Patch does not implement IPA propagation since it needs bit more work which I will post shortly: ipa-fnsummary needs to track when parameter points to local memory, summaries needs to be merged when function is inlined (because jump functions are) and propagation needs to be turned into iterative dataflow on SCC components. Patch also adds documentation of -fipa-modref and params that was left uncommited in my branch :(. Even without this change it does lead to nice increase of disambiguations for cc1plus build. Alias oracle query stats: refs_may_alias_p: 62758323 disambiguations, 72935683 queries ref_maybe_used_by_call_p: 139511 disambiguations, 63654045 queries call_may_clobber_ref_p: 23502 disambiguations, 29242 queries nonoverlapping_component_refs_p: 0 disambiguations, 37654 queries nonoverlapping_refs_since_match_p: 19417 disambiguations, 55555 must overlaps, 75721 queries aliasing_component_refs_p: 54665 disambiguations, 752449 queries TBAA oracle: 21917926 disambiguations 53054678 queries 15763411 are in alias set 0 10162238 queries asked about the same object 124 queries asked about the same alias set 0 access volatile 3681593 are dependent in the DAG 1529386 are aritificially in conflict with void * Modref stats: modref use: 8311 disambiguations, 32527 queries modref clobber: 742126 disambiguations, 1036986 queries 1987054 tbaa queries (1.916182 per modref query) 125479 base compares (0.121004 per modref query) PTA query stats: pt_solution_includes: 968314 disambiguations, 13609584 queries pt_solutions_intersect: 1019136 disambiguations, 13147139 queries So compared to https://gcc.gnu.org/pipermail/gcc-patches/2020-September/554605.html we get 41% more use disambiguations (with similar number of queries) and 8% more clobber disambiguations. For tramp3d: Alias oracle query stats: refs_may_alias_p: 2052256 disambiguations, 2312703 queries ref_maybe_used_by_call_p: 7122 disambiguations, 2089118 queries call_may_clobber_ref_p: 234 disambiguations, 234 queries nonoverlapping_component_refs_p: 0 disambiguations, 4299 queries nonoverlapping_refs_since_match_p: 329 disambiguations, 10200 must overlaps, 10616 queries aliasing_component_refs_p: 857 disambiguations, 34555 queries TBAA oracle: 885546 disambiguations 1677080 queries 132105 are in alias set 0 469030 queries asked about the same object 0 queries asked about the same alias set 0 access volatile 190084 are dependent in the DAG 315 are aritificially in conflict with void * Modref stats: modref use: 426 disambiguations, 1881 queries modref clobber: 10042 disambiguations, 16202 queries 19405 tbaa queries (1.197692 per modref query) 2775 base compares (0.171275 per modref query) PTA query stats: pt_solution_includes: 313908 disambiguations, 526183 queries pt_solutions_intersect: 130510 disambiguations, 416084 queries Here uses decrease by 4 disambiguations and clobber improve by 3.5%. I think the difference is caused by fact that gcc has much more alias set 0 accesses originating from gimple and tree unions as I mentioned in original mail. After pushing out the IPA propagation I will re-add code to track offsets and sizes that further improve disambiguation. On tramp3d it enables a lot of DSE for structure fields not acessed by uninlined function. gcc/ * doc/invoke.texi: Document -fipa-modref, ipa-modref-max-bases, ipa-modref-max-refs, ipa-modref-max-accesses, ipa-modref-max-tests. * ipa-modref-tree.c (test_insert_search_collapse): Update. (test_merge): Update. (gt_ggc_mx): New function. * ipa-modref-tree.h (struct modref_access_node): New structure. (struct modref_ref_node): Add every_access and accesses array. (modref_ref_node::modref_ref_node): Update ctor. (modref_ref_node::search): New member function. (modref_ref_node::collapse): New member function. (modref_ref_node::insert_access): New member function. (modref_base_node::insert_ref): Do not collapse base if ref is 0. (modref_base_node::collapse): Copllapse also refs. (modref_tree): Add accesses. (modref_tree::modref_tree): Initialize max_accesses. (modref_tree::insert): Add access parameter. (modref_tree::cleanup): New member function. (modref_tree::merge): Add parm_map; merge accesses. (modref_tree::copy_from): New member function. (modref_tree::create_ggc): Add max_accesses. * ipa-modref.c (dump_access): New function. (dump_records): Dump accesses. (dump_lto_records): Dump accesses. (get_access): New function. (record_access): Record access. (record_access_lto): Record access. (analyze_call): Compute parm_map. (analyze_function): Update construction of modref records. (modref_summaries::duplicate): Likewise; use copy_from. (write_modref_records): Stream accesses. (read_modref_records): Sream accesses. (pass_ipa_modref::execute): Update call of merge. * params.opt (-param=modref-max-accesses): New. * tree-ssa-alias.c (alias_stats): Add modref_baseptr_tests. (dump_alias_stats): Update. (base_may_alias_with_dereference_p): New function. (modref_may_conflict): Check accesses. (ref_maybe_used_by_call_p_1): Update call to modref_may_conflict. (call_may_clobber_ref_p_1): Update call to modref_may_conflict.
2020-09-23analyzer: add -fno-analyzer-feasibilityDavid Malcolm2-1/+14
This patch provides a new option "-fno-analyzer-feasibility" as a way to disable feasibility-checking of the constraints along the control flow paths for -fanalyzer diagnostics. I'm adding this in the hope of making it easier to debug issues involving the feasibility-checking logic. The patch adds a new rejected_constraint object which is captured if exploded_path::feasible_p fails, and adds logic that uses this to emit an additional custom_event within the checker_path for the diagnostic, showing where in the control flow path the diagnostic would have been rejected, and giving details of why. gcc/analyzer/ChangeLog: * analyzer.h (struct rejected_constraint): New decl. * analyzer.opt (fanalyzer-feasibility): New option. * diagnostic-manager.cc (path_builder::path_builder): Add "problem" param and use it to initialize new field. (path_builder::get_feasibility_problem): New accessor. (path_builder::m_feasibility_problem): New field. (dedupe_winners::add): Remove inversion of logic in "if" clause, swapping if/else suites. In the !feasible_p suite, inspect flag_analyzer_feasibility and add code to handle when this is off, accepting the infeasible path, but recording the feasibility_problem. (diagnostic_manager::emit_saved_diagnostic): Pass the feasibility_problem to the path_builder. (diagnostic_manager::add_events_for_eedge): If we have a feasibility_problem at this edge, use it to add a custom event. * engine.cc (exploded_path::feasible_p): Pass a rejected_constraint ** to model.maybe_update_for_edge and transfer ownership of any created instance to any feasibility_problem. (feasibility_problem::dump_to_pp): New. * exploded-graph.h (feasibility_problem::feasibility_problem): Drop "model" param; add rejected_constraint * param. (feasibility_problem::~feasibility_problem): New. (feasibility_problem::dump_to_pp): New decl. (feasibility_problem::m_model): Drop field. (feasibility_problem::m_rc): New field. * program-point.cc (function_point::get_location): Handle PK_BEFORE_SUPERNODE and PK_AFTER_SUPERNODE. * program-state.cc (program_state::on_edge): Pass NULL to new param of region_model::maybe_update_for_edge. * region-model.cc (region_model::add_constraint): New overload adding a rejected_constraint ** param. (region_model::maybe_update_for_edge): Add rejected_constraint ** param and pass it to the various apply_constraints_for_ calls. (region_model::apply_constraints_for_gcond): Add rejected_constraint ** param and pass it to add_constraint calls. (region_model::apply_constraints_for_gswitch): Likewise. (region_model::apply_constraints_for_exception): Likewise. (rejected_constraint::dump_to_pp): New. * region-model.h (region_model::maybe_update_for_edge): Add rejected_constraint ** param. (region_model::add_constraint): New overload adding a rejected_constraint ** param. (region_model::apply_constraints_for_gcond): Add rejected_constraint ** param. (region_model::apply_constraints_for_gswitch): Likewise. (region_model::apply_constraints_for_exception): Likewise. (struct rejected_constraint): New. gcc/ChangeLog: * doc/analyzer.texi (Analyzer Paths): Add note about -fno-analyzer-feasibility. * doc/invoke.texi (Static Analyzer Options): Add -fno-analyzer-feasibility. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/feasibility-2.c: New test.
2020-09-24rs6000: Add 'd' for doubleword variant of vector insertPaul A. Clarke1-4/+4
When the "Vector Insert" section was added to the documentation, the doubleword ('d') variant was omitted. Add it. 2020-09-23 Paul A. Clarke <pc@us.ibm.com> gcc/ * doc/extend.texi: Add 'd' for doubleword variant of vector insert instruction.
2020-09-23arm: Add support for Neoverse V1 CPUAlex Coplan1-3/+3
This adds support for Arm's Neoverse V1 CPU to the AArch32 backend. --- gcc/ChangeLog: * config/arm/arm-cpus.in (neoverse-v1): New. * config/arm/arm-tables.opt: Regenerate. * config/arm/arm-tune.md: Regenerate. * doc/invoke.texi: Document support for Neoverse V1.
2020-09-23aarch64: Add support for Neoverse V1 CPUAlex Coplan1-1/+2
This adds support for Arm's Neoverse V1 CPU to the AArch64 backend. --- gcc/ChangeLog: * config/aarch64/aarch64-cores.def: Add Neoverse V1. * config/aarch64/aarch64-tune.md: Regenerate. * doc/invoke.texi: Document support for Neoverse V1.
2020-09-22analyzer: add -fdump-analyzer-jsonDavid Malcolm2-0/+10
I've found this useful for debugging state explosions in the analyzer. gcc/analyzer/ChangeLog: * analysis-plan.cc: Include "json.h". * analyzer.opt (fdump-analyzer-json): New. * call-string.cc: Include "json.h". (call_string::to_json): New. * call-string.h (call_string::to_json): New decl. * checker-path.cc: Include "json.h". * constraint-manager.cc: Include "json.h". (equiv_class::to_json): New. (constraint::to_json): New. (constraint_manager::to_json): New. * constraint-manager.h (equiv_class::to_json): New decl. (constraint::to_json): New decl. (constraint_manager::to_json): New decl. * diagnostic-manager.cc: Include "json.h". (saved_diagnostic::to_json): New. (diagnostic_manager::to_json): New. * diagnostic-manager.h (saved_diagnostic::to_json): New decl. (diagnostic_manager::to_json): New decl. * engine.cc: Include "json.h", <zlib.h>. (exploded_node::status_to_str): New. (exploded_node::to_json): New. (exploded_edge::to_json): New. (exploded_graph::to_json): New. (dump_analyzer_json): New. (impl_run_checkers): Call it. * exploded-graph.h (exploded_node::status_to_str): New decl. (exploded_node::to_json): New. (exploded_edge::to_json): New. (exploded_graph::to_json): New. * pending-diagnostic.cc: Include "json.h". * program-point.cc: Include "json.h". (program_point::to_json): New. * program-point.h (program_point::to_json): New decl. * program-state.cc: Include "json.h". (extrinsic_state::to_json): New. (sm_state_map::to_json): New. (program_state::to_json): New. * program-state.h (extrinsic_state::to_json): New decl. (sm_state_map::to_json): New decl. (program_state::to_json): New decl. * region-model-impl-calls.cc: Include "json.h". * region-model-manager.cc: Include "json.h". * region-model-reachability.cc: Include "json.h". * region-model.cc: Include "json.h". * region-model.h (svalue::to_json): New decl. (region::to_json): New decl. * region.cc: Include "json.h". (region::to_json: New. * sm-file.cc: Include "json.h". * sm-malloc.cc: Include "json.h". * sm-pattern-test.cc: Include "json.h". * sm-sensitive.cc: Include "json.h". * sm-signal.cc: Include "json.h". (signal_delivery_edge_info_t::to_json): New. * sm-taint.cc: Include "json.h". * sm.cc: Include "diagnostic.h", "tree-diagnostic.h", and "json.h". (state_machine::state::to_json): New. (state_machine::to_json): New. * sm.h (state_machine::state::to_json): New. (state_machine::to_json): New. * state-purge.cc: Include "json.h". * store.cc: Include "json.h". (binding_key::get_desc): New. (binding_map::to_json): New. (binding_cluster::to_json): New. (store::to_json): New. * store.h (binding_key::get_desc): New decl. (binding_map::to_json): New decl. (binding_cluster::to_json): New decl. (store::to_json): New decl. * supergraph.cc: Include "json.h". (supergraph::to_json): New. (supernode::to_json): New. (superedge::to_json): New. * supergraph.h (supergraph::to_json): New decl. (supernode::to_json): New decl. (superedge::to_json): New decl. * svalue.cc: Include "json.h". (svalue::to_json): New. gcc/ChangeLog: * doc/analyzer.texi (Other Debugging Techniques): Mention -fdump-analyzer-json. * doc/invoke.texi (Static Analyzer Options): Add -fdump-analyzer-json.
2020-09-22switch lowering: limit number of cluster attempsMartin Liska1-0/+4
gcc/ChangeLog: PR tree-optimization/96979 * doc/invoke.texi: Document new param max-switch-clustering-attempts. * params.opt: Add new parameter. * tree-switch-conversion.c (jump_table_cluster::find_jump_tables): Limit number of attempts. (bit_test_cluster::find_bit_tests): Likewise. gcc/testsuite/ChangeLog: PR tree-optimization/96979 * g++.dg/tree-ssa/pr96979.C: New test.
2020-09-21c++: Implement -Wctad-maybe-unsupported.Marek Polacek1-1/+21
I noticed that clang++ has this CTAD warning and thought that it might be useful to have it. From clang++: "Some style guides want to allow using CTAD only on types that "opt-in"; i.e. on types that are designed to support it and not just types that *happen* to work with it." So this warning warns when CTAD deduced a type, but the type does not define any deduction guides. In that case CTAD worked only because the compiler synthesized the implicit deduction guides. That might not be intended. It can be suppressed by adding a deduction guide that will never be considered: struct allow_ctad_t; template <typename T> struct S { S(T) {} }; S(allow_ctad_t) -> S<void>; This warning is off by default. It doesn't warn when the type comes from a system header unless -Wsystem-headers. gcc/c-family/ChangeLog: * c.opt (Wctad-maybe-unsupported): New option. gcc/cp/ChangeLog: * pt.c (deduction_guides_for): Add a bool parameter. Set it. (do_class_deduction): Warn when CTAD succeeds but the type doesn't have any explicit deduction guides. gcc/ChangeLog: * doc/invoke.texi: Document -Wctad-maybe-unsupported. gcc/testsuite/ChangeLog: * g++.dg/warn/Wctad-maybe-unsupported.C: New test. * g++.dg/warn/Wctad-maybe-unsupported2.C: New test. * g++.dg/warn/Wctad-maybe-unsupported3.C: New test. * g++.dg/warn/Wctad-maybe-unsupported.h: New file.
2020-09-19Infrastructure & C front end changes for array parameter checking (PR c/50584).Martin Sebor1-0/+88
gcc/ChangeLog: PR c/50584 * attribs.c (decl_attributes): Also pass decl along with type attributes to handlers. (init_attr_rdwr_indices): Change second argument to attribute chain. Handle internal attribute representation in addition to external. (get_parm_access): New function. (attr_access::to_internal_string): Define new member function. (attr_access::to_external_string): Define new member function. (attr_access::vla_bounds): Define new member function. * attribs.h (struct attr_access): Declare new members. (attr_access::from_mode_char): Define new member function. (get_parm_access): Declare new function. * calls.c (initialize_argument_information): Pass function type attributes to init_attr_rdwr_indices. * doc/invoke.texi (-Warray-parameter, -Wvla-parameter): Document. * tree-pretty-print.c (dump_generic_node): Correct handling of qualifiers. * tree-ssa-uninit.c (maybe_warn_pass_by_reference): Same. * tree.h (access_mode): Add new enumerator. gcc/c-family/ChangeLog: PR c/50584 * c-attribs.c (c_common_attribute_table): Add "arg spec" attribute. (handle_argspec_attribute): New function. (get_argument, get_argument_type): New functions. (append_access_attrs): Add overload. Handle internal attribute representation in addition to external. (handle_access_attribute): Handle internal attribute representation in addition to external. (build_attr_access_from_parms): New function. gcc/c-family/ChangeLog: PR c/50584 * c-common.h (warn_parm_array_mismatch): Declare new function. (has_attribute): Move declaration of an existing function. (build_attr_access_from_parms): Declare new function. * c-warn.c (parm_array_as_string): Define new function. (plus_one): Define new function. (warn_parm_ptrarray_mismatch): Define new function. (warn_parm_array_mismatch): Define new function. (vla_bound_parm_decl): New function. * c.opt (-Warray-parameter, -Wvla-parameter): New options. * c-pretty-print.c (pp_c_type_qualifier_list): Don't print array type qualifiers here... (c_pretty_printer::direct_abstract_declarator): ...but instead print them in brackets here. Also print [static]. Strip extraneous expressions from VLA bounds. gcc/c/ChangeLog: PR c/50584 * c-decl.c (lookup_last_decl): Define new function. (c_decl_attributes): Call it. (start_decl): Add argument and use it. (finish_decl): Call build_attr_access_from_parms and decl_attributes. (get_parm_array_spec): Define new function. (push_parm_decl): Call get_parm_array_spec. (start_function): Call warn_parm_array_mismatch. Build attribute access and add it to current function. * c-parser.c (c_parser_declaration_or_fndef): Diagnose mismatches in forms of array parameters. * c-tree.h (start_decl): Add argument. gcc/testsuite/ChangeLog: PR c/50584 * gcc.dg/attr-access-read-write-2.c: Adjust text of expected message. * c-c++-common/Warray-bounds-6.c: Correct C++ declaration, adjust text of expected diagnostics. * gcc.dg/Wbuiltin-declaration-mismatch-9.c: Prune expected warning. * gcc.dg/Warray-parameter-2.c: New test. * gcc.dg/Warray-parameter-3.c: New test. * gcc.dg/Warray-parameter-4.c: New test. * gcc.dg/Warray-parameter-5.c: New test. * gcc.dg/Warray-parameter.c: New test. * gcc.dg/Wvla-parameter-2.c: New test. * gcc.dg/Wvla-parameter-3.c: New test. * gcc.dg/Wvla-parameter.c: New test.
2020-09-19Move loop and switch tree data structures from cp/ to c-family/.Sandra Loosemore1-22/+34
This patch moves the definitions for DO_STMT, FOR_STMT, WHILE_STMT, SWITCH_STMT, BREAK_STMT, and CONTINUE_STMT from the C++ front end to c-family. This includes the genericizers, pretty-printers, and dump support as well as the tree definitions and accessors. Some related code for OMP_FOR and similar OMP constructs is also moved. 2020-08-12 Sandra Loosemore <sandra@codesourcery.com> gcc/c-family/ * c-common.c (c_block_may_fallthrough): New, split from cxx_block_may_fallthrough in the cp front end. (c_common_init_ts): Move handling of loop and switch-related statements here from the cp front end. * c-common.def (FOR_STMT, WHILE_STMT, DO_STMT): Move here from cp front end. (BREAK_STMT, CONTINUE_STMT, SWITCH_STMT): Likewise. * c-common.h (c_block_may_fallthru): Declare. (bc_state_t): Move here from cp front end. (save_bc_state, restore_bc_state): Declare. (c_genericize_control_stmt): Declare. (WHILE_COND, WHILE_BODY): Likewise. (DO_COND, DO_BODY): Likewise. (FOR_INIT_STMT, FOR_COND, FOR_EXPR, FOR_BODY, FOR_SCOPE): Likewise. (SWITCH_STMT_COND, SWITCH_STMT_BODY): Likewise. (SWITCH_STMT_TYPE, SWITCH_STMT_SCOPE): Likewise. (SWITCH_STMT_ALL_CASES_P, SWITCH_STMT_NO_BREAK_P): Likewise. (LABEL_DECL_BREAK, LABEL_DECL_CONTINUE): Likewise. * c-dump.c (dump_stmt): Copy from cp front end. (c_dump_tree): Move code to handle structured loop and switch tree nodes here from cp front end. * c-gimplify.c: Adjust includes. (enum bc_t, bc_label, begin_bc_block, finish_bc_block): Move from cp front end. (save_bc_state, restore_bc_state): New functions using old code from cp front end. (get_bc_label, expr_loc_or_loc): Move from cp front end. (genericize_c_loop): Move from cp front end. (genericize_for_stmt, genericize_while_stmt): Likewise. (genericize_do_stmt, genericize_switch_stmt): Likewise. (genericize_continue_stmt, genericize_break_stmt): Likewise. (genericize_omp_for_stmt): Likewise. (c_genericize_control_stmt): New function using code split from cp front end. (c_genericize_control_r): New. (c_genericize): Call walk_tree with c_genericize_control_r. * c-pretty-print.c (c_pretty_printer::statement): Move code to handle structured loop and switch tree nodes here from cp front end. gcc/cp/ * cp-gimplify.c (enum bc_t, bc_label): Move to c-family. (begin_bc_block, finish_bc_block, get_bc_label): Likewise. (genericize_cp_loop): Likewise. (genericize_for_stmt, genericize_while_stmt): Likewise. (genericize_do_stmt, genericize_switch_stmt): Likewise. (genericize_continue_stmt, genericize_break_stmt): Likewise. (genericize_omp_for_stmt): Likewise. (cp_genericize_r): Call c_genericize_control_stmt instead of above functions directly. (cp_genericize): Call save_bc_state and restore_bc_state instead of manipulating bc_label directly. * cp-objcp-common.c (cxx_block_may_fallthru): Defer to c_block_may_fallthru instead of handling SWITCH_STMT here. (cp_common_init_ts): Move handling of loop and switch-related statements to c-family. * cp-tree.def (FOR_STMT, WHILE_STMT, DO_STMT): Move to c-family. (BREAK_STMT, CONTINUE_STMT, SWITCH_STMT): Likewise. * cp-tree.h (LABEL_DECL_BREAK, LABEL_DECL_CONTINUE): Likewise. (WHILE_COND, WHILE_BODY): Likewise. (DO_COND, DO_BODY): Likewise. (FOR_INIT_STMT, FOR_COND, FOR_EXPR, FOR_BODY, FOR_SCOPE): Likewise. (SWITCH_STMT_COND, SWITCH_STMT_BODY): Likewise. (SWITCH_STMT_TYPE, SWITCH_STMT_SCOPE): Likewise. (SWITCH_STMT_ALL_CASES_P, SWITCH_STMT_NO_BREAK_P): Likewise. * cxx-pretty-print.c (cxx_pretty_printer::statement): Move code to handle structured loop and switch tree nodes to c-family. * dump.c (cp_dump_tree): Likewise. gcc/ * doc/generic.texi (Basic Statements): Document SWITCH_EXPR here, not SWITCH_STMT. (Statements for C and C++): Rename node to reflect what the introduction already says about sharing between C and C++ front ends. Copy-edit and correct documentation for structured loops and switch.
2020-09-18MSP430: Add 'd', 'e', 'f' and 'g' asm operand modifiersJozef Lawrynowicz1-0/+36
The new operand modifiers can be used to select odd-numbered bytes of a memory reference or constant value. gcc/ChangeLog: * config/msp430/msp430.c (msp430_print_operand): Update comment. Cast to long when printing values formatted as long. Support 'd', 'e', 'f' and 'g' modifiers. Extract operand value with a single operation for all modifiers. * doc/extend.texi (msp430Operandmodifiers): New. gcc/testsuite/ChangeLog: * gcc.target/msp430/operand-modifiers.c: Extend test to handle new modifiers. * gcc.target/msp430/operand-modifiers-bad.c: New test.
2020-09-17Document -Wuninitialized for allocated objects.Martin Sebor1-8/+21
gcc/ChangeLog: * doc/invoke.texi (-Wuninitialized): Document -Wuninitialized for allocated objects. (-Wmaybe-uninitialized): Same.
2020-09-17C-SKY: Add -msim optionJojo R1-1/+6
gcc/ChangeLog: * config/csky/csky.opt (msim): New. * doc/invoke.texi (C-SKY Options): Document -msim. * config/csky/csky-elf.h (LIB_SPEC): Add simulator runtime.
2020-09-17doc: use @code{} instead of @samp{@command{}} around 'date %s'Sergei Trofimovich1-1/+1
Before the change 'man gcc' rendered "SOURCE_DATE_EPOCH" section as: ... the output of @command{date +%s} on GNU/Linux ... After the change it renders as: ... the output of "date +%s" on GNU/Linux ... gcc/ChangeLog: * doc/cppenv.texi: Use @code{} instead of @samp{@command{}} around 'date %s'.
2020-09-14doc: fix spelling of -fprofile-reproducibilitySergei Trofimovich1-4/+5
gcc/ChangeLog: * doc/invoke.texi: fix '-fprofile-reproducibility' option spelling in manual.
2020-09-14options: Save and restore opts_set for Optimization and Target optionsJakub Jelinek1-2/+2
> 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-09-10aarch64: Add support for Cortex-R82Alex Coplan1-2/+2
This adds support for Arm's Cortex-R82 CPU to GCC. For more information about this CPU, see [0]. [0] : https://developer.arm.com/ip-products/processors/cortex-r/cortex-r82 gcc/ChangeLog: * config/aarch64/aarch64-cores.def: Add Cortex-R82. * config/aarch64/aarch64-tune.md: Regenerate. * doc/invoke.texi: Add entry for Cortex-R82.
2020-09-10aarch64: Add support for Armv8-RAlex Coplan1-0/+1
This adds support for Armv8-R AArch64 to GCC. It adds the -march value armv8-r and sets the ACLE feature macro __ARM_ARCH_PROFILE correctly when -march is set to armv8-r. gcc/ChangeLog: * common/config/aarch64/aarch64-common.c (aarch64_get_extension_string_for_isa_flags): Don't force +crc for Armv8-R. * config/aarch64/aarch64-arches.def: Add entry for Armv8-R. * config/aarch64/aarch64-c.c (aarch64_define_unconditional_macros): Set __ARM_ARCH_PROFILE correctly for Armv8-R. * config/aarch64/aarch64.h (AARCH64_FL_V8_R): New. (AARCH64_FL_FOR_ARCH8_R): New. (AARCH64_ISA_V8_R): New. * doc/invoke.texi: Add Armv8-R to architecture table. gcc/testsuite/ChangeLog: * gcc.target/aarch64/acle/armv8-r.c: New test.