aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2020-10-26IBM Z: Add vcond_mask expanderAndreas Krebbel1-0/+11
After adding vec_cmp expanders we have seen various performance related regression in the testsuite. These appear to be caused by a missing vcond_mask definition in the backend. Fixed with this patch. The patch fixes the following testsuite fails: FAIL: gcc.dg/vect/vect-21.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-21.c scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-23.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-23.c scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-24.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-24.c scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-live-6.c -flto -ffat-lto-objects scan-tree-dump vect "vectorized 1 loops" FAIL: gcc.dg/vect/vect-live-6.c scan-tree-dump vect "vectorized 1 loops" FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesrab\\t%v.?,%v.?,7 6 FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesraf\\t%v.?,%v.?,31 6 FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesrah\\t%v.?,%v.?,15 6 FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesrlb\\t%v.?,%v.?,7 4 FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesrlf\\t%v.?,%v.?,31 4 FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesrlh\\t%v.?,%v.?,15 4 FAIL: gcc.dg/vect/vect-21.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-21.c scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-23.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-23.c scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-24.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-24.c scan-tree-dump-times vect "vectorized 3 loops" 1 FAIL: gcc.dg/vect/vect-live-6.c -flto -ffat-lto-objects scan-tree-dump vect "vectorized 1 loops" FAIL: gcc.dg/vect/vect-live-6.c scan-tree-dump vect "vectorized 1 loops" FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesrab\\t%v.?,%v.?,7 6 FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesraf\\t%v.?,%v.?,31 6 FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesrah\\t%v.?,%v.?,15 6 FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesrlb\\t%v.?,%v.?,7 4 FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesrlf\\t%v.?,%v.?,31 4 FAIL: gcc.target/s390/vector/vcond-shift.c scan-assembler-times vesrlh\\t%v.?,%v.?,15 4 gcc/ChangeLog: * config/s390/vector.md ("vcond_mask_<mode><mode>"): New expander.
2020-10-26middle-end/97554 - avoid overflow in alloc size computeRichard Biener1-1/+2
This avoids overflow in the allocation size computations in sbitmap_vector_alloc when the result exceeds 2GB. 2020-10-26 Richard Biener <rguenther@suse.de> * sbitmap.c (sbitmap_vector_alloc): Use size_t for byte quantities to avoid overflow.
2020-10-26tree-optimization/97539 - reset out-of-loop debug uses before peelingRichard Biener2-1/+57
This makes sure to reset out-of-loop debug uses before vectorizer loop peeling as we cannot make sure to retain the use-def dominance relationship when there are no LC SSA nodes. 2020-10-26 Richard Biener <rguenther@suse.de> PR tree-optimization/97539 * tree-vect-loop-manip.c (vect_do_peeling): Reset out-of-loop debug uses before peeling. * gcc.dg/pr97539.c: New testcase.
2020-10-26Make default duplicate and insert methods of summaries abort; fix falloutJan Hubicka10-110/+210
the default duplicate and insert methods of sumaries produce empty summary that is not useful for anything and makes it easy to introduce bugs. This patch makes the default hooks to abort and summaries that do not need dupicaito/insertion disable the corresponding hooks. I also implemented missing insertion hook for ipa-sra which forced me to move analysis out of anonymous namespace. 2020-10-23 Jan Hubicka <hubicka@ucw.cz> * cgraph.h (struct cgraph_node): Make ipa_transforms_to_apply vl_ptr. * ipa-inline-analysis.c (initialize_growth_caches): Disable insertion and duplication hooks. * ipa-inline-transform.c (clone_inlined_nodes): Clear ipa_transforms_to_apply. (save_inline_function_body): Disable insertion hoook for ipa_saved_clone_sources. * ipa-prop.c (ipcp_transformation_initialize): Disable insertion hook. * ipa-prop.h (ipa_node_params_t): Disable insertion hook. * ipa-reference.c (propagate): Disable insertion hoook. * ipa-sra.c (ipa_sra_summarize_function): Move out of anonymous namespace. (ipa_sra_function_summaries::insert): New virtual function. * passes.c (execute_one_pass): Do not add transforms to inline clones. * symbol-summary.h (function_summary_base): Make insert and duplicate hooks fail instead of silently producing empty summaries; add way to disable duplication hooks (call_summary_base): Likewise. * tree-nested.c (nested_function_info::get_create): Disable insertion hooks (maybe_record_nested_function): Likewise.
2020-10-26[Ada] Handle Iterated_Component_Association with Others_ChoiceEd Schonberg1-6/+18
gcc/ada/ * exp_aggr.adb (Build_Array_Aggr_Code): If the aggregate includes an Others_Choice in an association that is an Iterated_Component_Association, generate a proper loop for it.
2020-10-26[Ada] Further small edition to documentation of Ada.Text_IO.Fixed_IOEric Botcazou2-3/+3
gcc/ada/ * libgnat/a-tifiio.adb: Add missing sign in documentation. * libgnat/s-imgrea.ads: Minor fixes in commentary.
2020-10-26[Ada] Replace GNAT_Extended_Ravenscar profile namePat Rogers2-18/+30
gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst: Include "Jorvik" in pragma Profile description. * gnat_rm.texi: Regenerate.
2020-10-26[Ada] Avoid crash on use of Ada 2020 featureBob Duff2-7/+6
gcc/ada/ * sem_attr.adb (Check_Image_Type): Remove "|", so the compiler will not crash. * errout.ads: Improve comment. This has nothing to do with -gnatQ.
2020-10-26[Ada] Further small edition to documentation of Ada.Text_IO.Fixed_IOEric Botcazou1-17/+14
gcc/ada/ * libgnat/a-tifiio.adb: Minor editions to documentation.
2020-10-26[Ada] Fix freezing of previous contractsPiotr Trojanek1-4/+15
gcc/ada/ * contracts.adb (Causes_Contract_Freezing): Extend condition to match the one in Analyze_Subprogram_Body_Helper. This routine is used both as an assertion at the very start of Freeze_Previous_Contracts and to detect previous declaration for which Freeze_Previous_Contracts has been executed.
2020-10-26[Ada] Another small edition to documentation of Ada.Text_IO.Fixed_IOEric Botcazou1-15/+14
gcc/ada/ * libgnat/a-tifiio.adb: Move around documentaton paragraph.
2020-10-26[Ada] Fix harmless assertion failure in GNATprove modePiotr Trojanek1-1/+18
gcc/ada/ * inline.adb (Establish_Actual_Mapping_For_Inlined_Call): Add guard for a call to Set_Last_Assignment with the same condition as the assertion in that routine and explain why this guard fails in GNATprove mode.
2020-10-26[Ada] Document characteristics of ordinary fixed point typesEric Botcazou2-14/+16
gcc/ada/ * doc/gnat_rm/implementation_defined_characteristics.rst: Adjust the entries of 3.5.9(8) and 3.5.9(10). * gnat_rm.texi: Regenerate.
2020-10-26[Ada] Relax assertion on Small in Ada.Text_IO.Fixed_IOEric Botcazou1-11/+11
gcc/ada/ * libgnat/a-tifiio.adb: Change the range of supported Small values. (E0, E1, E2): Adjust factors. (Exact): Return false if the Small does not fit in 64 bits.
2020-10-26[Ada] Fix Accept_Socket and Connect_Socket timeout supportDmitriy Anisimkov1-50/+25
gcc/ada/ * libgnat/g-socket.adb (Wait_On_Socket): Boolean parameter For_Read changed to Event parameter of type GNAT.Sockets.Poll.Wait_Event_Set. Implementation is simplified and based on call to GNAT.Sockets.Poll.Wait now.
2020-10-26[Ada] Minor editions to documentation of Ada.Text_IO.Fixed_IOEric Botcazou1-35/+33
gcc/ada/ * libgnat/a-tifiio.adb: Minor editions to documentation.
2020-10-26[Ada] Fix GNATprove crash on generics with access typesYannick Moy1-1/+9
gcc/ada/ * sem_ch12.adb (Restore_Private_Views): Do not lose the information provided by Is_Generic_Actual_Type in GNATprove mode.
2020-10-26[Ada] Suppress warnings on unreferenced parameters of dispatching opsArnaud Charlet2-12/+19
gcc/ada/ * sem_warn.adb (Warn_On_Unreferenced_Entity): Suppress warning on formal parameters of all dispatching operations. gcc/testsuite/ * gnat.dg/warn14.adb: Update expectations.
2020-10-26[Ada] Fix typos in error message for array delta aggregatesPiotr Trojanek1-1/+1
gcc/ada/ * sem_aggr.adb (Resolve_Delta_Array_Aggregate): Fix typos in error message.
2020-10-26[Ada] Restore hex addresses and improve symbolic backtracesOlivier Hainque1-9/+12
gcc/ada/ * libgnat/s-dwalin.adb (Symbolic_Traceback): Always emit the hex address at the beginning of an entry if suppression is not requested. Consistently output a "???" for the subprogram name when it is unknown.
2020-10-26[Ada] x86-lynx178elf - gcc build failsDoug Rupp1-0/+3
gcc/ada/ * s-oscons-tmplt.c (_nfds_t): Use sizeof (unsigned long int).
2020-10-26[Ada] Fix interference between iterated element-and-component associationPiotr Trojanek1-6/+6
gcc/ada/ * par-ch4.adb (P_Iterated_Component_Association): Move code for iterated_element_association to Build_Iterated_Element_Association.
2020-10-26[Ada] Do not instantiate generic bodies outside of main unit in GNATproveYannick Moy1-0/+10
gcc/ada/ * sem_ch12.adb (Needs_Body_Instantiated): In GNATprove mode, do not instantiate bodies outside of the main unit.
2020-10-26[Ada] Spurious error on Old attribute reference in delta aggregateEd Schonberg1-2/+7
gcc/ada/ * sem_aggr.adb (Resolve_Delta_Array_Aggregate): For an association that is an iterated component association, attach the copy of the expression to the tree prior to analysis, in order to preserve its context. This is needed when verifying static semantic rules that depend on context, for example that a use of 'Old appears only within a postcondition.
2020-10-26[Ada] gnatpp: Document that --no-comments-fill is now the defaultBob Duff1-2/+2
gcc/ada/ * doc/gnat_ugn/gnat_utility_programs.rst: Document that --no-comments-fill is now the default.
2020-10-26[Ada] Missing errors on extension aggregates with unknown discriminantsGary Dismukes1-4/+17
gcc/ada/ * sem_aggr.adb (Resolve_Extension_Aggregate): When testing for an aggregate that is illegal due to having an ancestor type that has unknown discriminants, add an "or else" condition testing whether the aggregate type has unknown discriminants and that Partial_View_Has_Unknown_Discr is also set on the ancestor type. Extend the comment, including adding ??? about a possible simpler test.
2020-10-26[Ada] Delete: set Position to No_ElementBob Duff3-0/+6
gcc/ada/ * libgnat/a-cihama.adb, libgnat/a-cohama.adb, libgnat/a-cohase.adb (Delete): Set Position.Position, and assert.
2020-10-26[Ada] Improve error on missing with clauseArnaud Charlet1-3/+19
gcc/ada/ * sem_ch8.adb (Find_Direct_Name.Undefined): Handle known unit names with 3 selectors.
2020-10-26[Ada] Fix SPARK expansion of iterated_component_assoc in delta aggregatePiotr Trojanek1-0/+1
gcc/ada/ * exp_spark.adb (Expand_SPARK_Delta_Or_Update): Add missing call to Enter_Name, just like it is called for iterated_component_association in Expand_SPARK_N_Aggregate.
2020-10-26[Ada] Cleanup SPARK expansion of aggregates with iterated_component_assocPiotr Trojanek1-7/+3
gcc/ada/ * exp_spark.adb (Expand_SPARK_Delta_Or_Update): Reuse local constant Expr and the Choice_List routine. (Expand_SPARK_N_Aggregate): Reuse local constant Expr.
2020-10-26[Ada] Fix typos in comments about parsing iterated_component_associationPiotr Trojanek1-8/+8
gcc/ada/ * par-ch4.adb (P_Iterated_Component_Association): Fix typos in comments.
2020-10-26[Ada] AI12-0395: Allow aspect_specifications on formal parametersArnaud Charlet3-4/+4
gcc/ada/ * par-ch6.adb (P_Formal_Part): Ada 2020 supports scanning aspects on formal parameters. * doc/gnat_rm/implementation_defined_aspects.rst (Aspect Unreferenced): Update documentation. * gnat_rm.texi: Regenerate.
2020-10-26[Ada] Crash on membership test in expression functionEd Schonberg1-1/+10
gcc/ada/ * freeze.adb (Freeze_Type_Refs): When an entity in an expression function is a type, freeze the entity and not just its type, which would be incomplete when the type is derived and/or tagged.
2020-10-26[Ada] Handle subtype_indication in 'Update for arraysPiotr Trojanek1-0/+3
gcc/ada/ * exp_attr.adb (Expand_Update_Attribute): Handle subtype_indication just like in Expand_Delta_Array_Aggregate.
2020-10-26Add overloaded debug_bb and debug_bb_n with dump flagsXionghu Luo3-2/+22
Add overloads that accept a flags argument so we can print debug_bb_n (5, TDF_DETAILS) in gdb, also the debug_bb_slim variant would then be just a forwarder. gcc/ChangeLog: 2020-10-26 Xionghu Luo <luoxhu@linux.ibm.com> * cfg.c (debug_bb): New overloaded function. (debug_bb_n): New overloaded function. * cfg.h (debug_bb): New declaration. (debug_bb_n): New declaration. * print-rtl.c (debug_bb_slim): Call debug_bb with flags.
2020-10-26Daily bump.GCC Administrator3-1/+28
2020-10-25Ada, Darwin, PowerPC : Fix bootstrap after 128 int changes.Iain Sandoe1-1/+12
The GNATRTL_128BIT_PAIRS/OBJS need to be added for 64bit multilibs on powerpc-darwin, and for powerpc64-darwin. gcc/ada/ChangeLog: * Makefile.rtl: Add GNATRTL_128BIT_PAIRS/OBJS for 64bit PowerPC Darwin cases.
2020-10-25Correct decls for functions which do not pass actual arguments.Thomas Koenig5-40/+155
A wrong decl for findloc caused segfaults at runtime on Darwin for ARM; however, this is only a symptom of a larger disease: The declarations for our library functions are often inconsistent. This patch solves that problem for the functions specifically for the functions for which we do not pass optional arguments, i.e. findloc and (min|max)loc. It works by saving the symbols of the specific functions in gfc_intrinsic_namespace and by generating the formal argument lists from the actual argument lists. Because symbols are re-used, so are the backend decls. gcc/fortran/ChangeLog: PR fortran/97454 * gfortran.h (gfc_symbol): Add pass_as_value flag. (gfc_copy_formal_args_intr): Add optional argument copy_type. (gfc_get_intrinsic_function_symbol): Add prototype. (gfc_find_intrinsic_symbol): Add prototype. * intrinsic.c (gfc_get_intrinsic_function_symbol): New function. (gfc_find_intrinsic_symbol): New function. * symbol.c (gfc_copy_formal_args_intr): Add argument. Handle case where the type needs to be copied from the actual argument. * trans-intrinsic.c (remove_empty_actual_arguments): New function. (specific_intrinsic_symbol): New function. (gfc_conv_intrinsic_funcall): Use it. (strip_kind_from_actual): Adjust so that the expression pointer is set to NULL. (gfc_conv_intrinsic_minmaxloc): Likewise. (gfc_conv_intrinsic_minmaxval): Adjust removal of dim. * trans-types.c (gfc_sym_type): If sym->pass_as_value is set, do not pass by reference.
2020-10-25Daily bump.GCC Administrator4-1/+53
2020-10-24Update check for working assembler --gdwarf-4 optionH.J. Lu5-13/+164
Rename HAVE_AS_WORKING_DWARF_4_FLAG to HAVE_AS_WORKING_DWARF_N_FLAG Don't set HAVE_AS_WORKING_DWARF_N_FLAG if --gdwarf-5/--gdwarf-4 generate an extra assembly input file in debug info from compiler generated .debug_line or fail with the APP marker: https://sourceware.org/bugzilla/show_bug.cgi?id=25878 https://sourceware.org/bugzilla/show_bug.cgi?id=26740 https://sourceware.org/bugzilla/show_bug.cgi?id=26778 Also replace success with dwarf4_success in the 32-bit --gdwarf-4 check. PR bootstrap/97451 * configure.ac (HAVE_AS_WORKING_DWARF_4_FLAG): Renamed to ... (HAVE_AS_WORKING_DWARF_N_FLAG): This. Don't define if there is an extra assembly input file in debug info. Replace success with dwarf4_success in the 32-bit --gdwarf-4 check. * dwarf2out.c (asm_outputs_debug_line_str): Check HAVE_AS_WORKING_DWARF_N_FLAG instead of HAVE_AS_WORKING_DWARF_4_FLAG. * gcc.c (ASM_DEBUG_SPEC): Likewise. (ASM_DEBUG_OPTION_SPEC): Likewise. * config.in: Regenerated. * configure: Likewise.
2020-10-24c++: Fix verify_ctor_sanity ICE [PR96241]Marek Polacek3-2/+74
The code added in r10-6437 caused us to create a CONSTRUCTOR when we're {}-initializing an aggregate. Then we pass this new CONSTRUCTOR down to cxx_eval_constant_expression which, if the CONSTRUCTOR isn't TREE_CONSTANT or reduced_constant_expression_p, calls cxx_eval_bare_aggregate. In this case the CONSTRUCTOR wasn't reduced_constant_expression_p because for r_c_e_p a CONST_DECL isn't good enough so it returns false. So we go to cxx_eval_bare_aggregate where we crash, because ctx->ctor wasn't set up properly. So my fix is to do so. Since we're value-initializing, I'm not setting CONSTRUCTOR_NO_CLEARING. To avoid keeping a garbage constructor around, I call free_constructor in case the evaluation did not use it. gcc/cp/ChangeLog: PR c++/96241 * constexpr.c (cxx_eval_array_reference): Set up ctx->ctor if we are initializing an aggregate. Call free_constructor on the new CONSTRUCTOR if it isn't returned from cxx_eval_constant_expression. gcc/testsuite/ChangeLog: PR c++/96241 * g++.dg/cpp0x/constexpr-96241.C: New test. * g++.dg/cpp1y/constexpr-96241.C: New test.
2020-10-24Handle undefined ranges in get_size_range.Aldy Hernandez2-6/+31
An undefined range was leaking through to the end of this function, which leads us to use an uninitialized wide_int. gcc/ChangeLog: PR tree-optimization/97538 * calls.c (get_size_range): Handle undefined ranges. gcc/testsuite/ChangeLog: * g++.dg/pr97538.C: New test.
2020-10-24cgraph: move former_thunk_p out of CHECKING_P macro.Martin Liska1-15/+15
This fixes the following failure: ld: cgraph.o: in function `cgraph_edge::verify_corresponds_to_fndecl(tree_node*)': gcc/cgraph.c:3067: undefined reference to `cgraph_node::former_thunk_p()' ld: cgraph.o: in function `clone_of_p': gcc/ChangeLog: * cgraph.c (cgraph_node::former_thunk_p): Move out of CHECKING_P macro.
2020-10-24[RS6000] altivec style lvx/stvx addresses vs power10Alan Modra1-4/+10
gcc.target/powerpc/fold-vec-st-pixel.c and other testcases fail on power10, generating addi 9,5,12 rldicr 9,9,0,59 stxv 34,0(9) rather than addi 5,5,12 stvx 2,0,5 for an altivec lvx/stvx style address. The problem starts with fwprop creating (insn 9 4 0 2 (set (mem:V8HI (and:DI (plus:DI (reg/v/f:DI 121 [ vpp ]) (const_int 12 [0xc])) (const_int -16 [0xfffffffffffffff0])) [0 MEM <vector(8) short int> [(void *)_4 & -16B]+0 S16 A128]) (reg/v:V8HI 120 [ vp1 ])) "pixel.c":6:10 1237 {vsx_movv8hi_64bit} which is finally thrown out as invalid by lra. lra of course does that by reloading the entire address. fwprop creates the invalid address due to rs6000_legitimate_address_p trimming off the outer AND of altivec style addresses before applying other predicates. address_is_prefixed then allows the inner address. Now at the time the AND stripping was added (git commit 850e8d3d56d), rs6000_legitimate_address looked a lot simpler. This patch allows through just those addresses that were legitimate in those simpler days. * config/rs6000/rs6000.c (rs6000_legitimate_address_p): Limit AND addressing to just lvx/stvx style addresses.
2020-10-24[RS6000] Power10 ICE running gcc.target/powerpc/ppc-ne0-1.cAlan Modra1-1/+1
* config/rs6000/rs6000.md (cstore<mode>4): Don't call rs6000_emit_int_cmove for power10 when -mno-isel.
2020-10-24Daily bump.GCC Administrator9-1/+686
2020-10-23net/http/cgi: merge upstream changes to default env varsNikhil Benesch1-1/+1
Incorporate upstream modifications to the cgi package's set of rules about which environment variables should be inherited by child processes by default on each platform. In particular this permits tests to pass on NetBSD by preserving the value of the LD_LIBRARY_PATH environment variable. This is a partial backport of the following upstream CLs: https://golang.org/cl/263802 https://golang.org/cl/263577 https://golang.org/cl/254740 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/264097
2020-10-23testsuite: Fix -Wsizeof-array-div tests.Marek Polacek2-4/+4
gcc/testsuite/ChangeLog: * c-c++-common/Wsizeof-array-div1.c: Expect certain warnings on lp64 targets only. * g++.dg/warn/Wsizeof-array-div2.C: Only run on lp64 targets.
2020-10-23Move thunks out of cgraph_nodeJan Hubicka33-761/+1045
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-23c, c++: Implement -Wsizeof-array-div [PR91741]Marek Polacek14-22/+226
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.