1. 24 Jan, 2018 19 commits
    • compiler: rationalize external symbol names · 4880b994
          
          Encode all external symbol names using only ASCII alphanumeric
          characters, underscore, and dot.  Use a scheme that can be reliably
          demangled to a somewhat readable version as described in the long
          comment in names.cc.
          
          A minor cleanup discovered during this was that we were treating
          function types as different if one had a NULL parameters_ field and
          another has a non-NULL parameters_ field that has no parameters.  This
          worked because we mangled them slightly differently.  We now mangle
          them the same, so we treat them as equal, as we should anyhow.
          
          Reviewed-on: https://go-review.googlesource.com/89555
      
      	* go.go-torture/execute/names-1.go: New test.
      
      From-SVN: r257033
      Ian Lance Taylor committed
    • Fix m68k-linux-gnu libgcc build for ColdFire (PR target/68467). · d3719ee2
      PR target/68467 is libgcc failing to build for m68k-linux-gnu
      configured for ColdFire.
      
      Jeff has an analysis in the PR identifying the problem as resulting
      from the callers of libcalls with 1-byte or 2-byte arguments wanting
      to push just 1 or 2 bytes on the stack, while the libcall
      implementations have the normal C ABI and expect 4-byte arguments.
      For normal C functions, I believe the TARGET_PROMOTE_PROTOTYPES
      definition would ensure such arguments get passed as 4-byte, but that
      does not apply for libcalls.
      
      This patch fixes the issue by defining TARGET_PROMOTE_FUNCTION_MODE
      for m68k.  The definition is conservative, only applying promotions in
      the case of arguments to libcalls; otherwise it returns the unpromoted
      type, which I believe matches what the default implementation of the
      hook would have done on m68k.
      
      I have tested that this fixes the libgcc build for ColdFire, and, in
      conjunction with one glibc patch, this enables glibc to build cleanly
      for ColdFire and to pass the compilation parts of the glibc testsuite
      except for one test unrelated to this patch (while glibc and the
      compilation parts of the testsuite continue to build OK for
      non-ColdFire m68k, as expected).  I have *not* run any GCC tests for
      this patch, or any execution tests for m68k.
      
      	PR target/68467
      	* config/m68k/m68k.c (m68k_promote_function_mode): New function.
      	(TARGET_PROMOTE_FUNCTION_MODE): New macro.
      
      From-SVN: r257032
      Joseph Myers committed
    • re PR target/83994 (%ebx is clobbered by stack-clash probing for regparm-3 function in PIC mode) · 5e77d9b1
      	PR target/83994
      	* i386.c (get_probe_interval): Move to earlier point.
      	(ix86_compute_frame_layout): If -fstack-clash-protection and
      	the frame is larger than the probe interval, then use pushes
      	to save registers rather than reg->mem moves.
      	(ix86_expand_prologue): Remove conditional for int_registers_saved
      	assertion.
      
      	PR target/83994
      	* gcc.target/i386/pr83994.c: New test.
      
      From-SVN: r257031
      Jeff Law committed
    • re PR target/84014 (ICE in setup_min_max_allocno_live_range_point, at ira-build.c:2762) · ffd464df
      2018-01-24  Vladimir Makarov  <vmakarov@redhat.com>
      
      	PR target/84014
      	* ira-build.c (setup_min_max_allocno_live_range_point): Set up
      	min/max for never referenced object.
      
      2018-01-24  Vladimir Makarov  <vmakarov@redhat.com>
      
      	PR target/84014
      	* gcc.target/powerpc/pr84014.c: New.
      
      From-SVN: r257029
      Vladimir Makarov committed
    • re PR middle-end/83977 (ICE in simd_clone_clauses_extract, at omp-simd-clone.c:184) · f1542d9a
      	PR middle-end/83977
      	* tree.c (free_lang_data_in_decl): Don't clear DECL_ABSTRACT_ORIGIN
      	here.
      	* omp-low.c (create_omp_child_function): Remove "omp declare simd"
      	attributes from DECL_ATTRIBUTES (decl) without affecting
      	DECL_ATTRIBUTES (current_function_decl).
      	* omp-simd-clone.c (expand_simd_clones): Ignore DECL_ARTIFICIAL
      	functions with non-NULL DECL_ABSTRACT_ORIGIN.
      
      	* c-c++-common/gomp/pr83977-1.c: New test.
      	* c-c++-common/gomp/pr83977-2.c: New test.
      	* c-c++-common/gomp/pr83977-3.c: New test.
      	* gfortran.dg/gomp/pr83977.f90: New test.
      
      From-SVN: r257023
      Jakub Jelinek committed
    • Remove explicit dg-do runs from gcc.dg/vect (PR 83889) · 556d3a24
      The failures in this PR were from forcing { dg-do run } even when
      vect.exp chooses options that are incompatible with the runtime.
      The default vect.exp behaviour is to execute when possible, so there's
      no need for a dg-do at all.
      
      The patch removes other unconditional { dg-do run }s too.  Many of them
      were already failing in the same way.
      
      Also, the dg-do run condition in vect-reduc-or* seems unnecessary:
      the test should run correctly whatever happens, and the scan tests
      are already guarded properly.
      
      2018-01-24  Richard Sandiford  <richard.sandiford@linaro.org>
      
      gcc/testsuite/
      	PR testsuite/83889
      	* gcc.dg/vect/pr79920.c: Remove explicit dg-do run.
      	* gcc.dg/vect/pr80631-1.c: Likewise.
      	* gcc.dg/vect/pr80631-2.c: Likewise.
      	* gcc.dg/vect/pr81410.c: Likewise.
      	* gcc.dg/vect/pr81633.c: Likewise.
      	* gcc.dg/vect/pr81815.c: Likewise.
      	* gcc.dg/vect/pr82108.c: Likewise.
      	* gcc.dg/vect/pr83857.c: Likewise.
      	* gcc.dg/vect/vect-alias-check-8.c: Likewise.
      	* gcc.dg/vect/vect-alias-check-9.c: Likewise.
      	* gcc.dg/vect/vect-alias-check-10.c: Likewise.
      	* gcc.dg/vect/vect-alias-check-11.c: Likewise.
      	* gcc.dg/vect/vect-alias-check-12.c: Likewise.
      	* gcc.dg/vect/vect-reduc-11.c: Likewise.
      	* gcc.dg/vect/vect-tail-nomask-1.c: Likewise.
      	* gcc.dg/vect/vect-reduc-in-order-1.c: Remove dg-do run and use
      	dg-xfail-run-if instead.
      	* gcc.dg/vect/vect-reduc-in-order-2.c: Likewise.
      	* gcc.dg/vect/vect-reduc-in-order-3.c: Likewise.
      	* gcc.dg/vect/vect-reduc-in-order-4.c: Likewise.
      	* gcc.dg/vect/vect-reduc-or_1.c: Remove conditional dg-do run.
      	* gcc.dg/vect/vect-reduc-or_2.c: Likewise.
      
      From-SVN: r257022
      Richard Sandiford committed
    • Fix use of boolean_true/false_node (PR 83979) · 885a33e1
      r255913 changed some constant_boolean_node calls to boolean_true_node
      and boolean_false_node, which meant that the returned tree didn't
      always have the right type.
      
      2018-01-24  Richard Sandiford  <richard.sandiford@linaro.org>
      
      gcc/
      	PR tree-optimization/83979
      	* fold-const.c (fold_comparison): Use constant_boolean_node
      	instead of boolean_{true,false}_node.
      
      gcc/testsuite/
      	PR tree-optimization/83979
      	* g++.dg/pr83979.c: New test.
      
      From-SVN: r257021
      Richard Sandiford committed
    • ipa-profile.c (ipa_propagate_frequency_1): Fix logic skipping calls with zero counts. · 35d93d1d
      
      	* ipa-profile.c (ipa_propagate_frequency_1): Fix logic skipping calls
      	with zero counts.
      
      From-SVN: r257020
      Jan Hubicka committed
    • rs6000.md (*call_indirect_nonlocal_sysv<mode>): Simplify the clause that sets the length attribute. · 0976f13b
      2018-01-24  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
      
      	* config/rs6000/rs6000.md (*call_indirect_nonlocal_sysv<mode>):
      	Simplify the clause that sets the length attribute.
      	(*call_value_indirect_nonlocal_sysv<mode>): Likewise.
      	(*sibcall_nonlocal_sysv<mode>): Clean up code block; simplify the
      	clause that sets the length attribute.
      	(*sibcall_value_nonlocal_sysv<mode>): Likewise.
      
      From-SVN: r257019
      Bill Schmidt committed
    • PR c++/82249 - wrong mismatched pack length error. · 018e9cb5
      	* pt.c (extract_fnparm_pack, tsubst_pack_expansion): Handle
      	unsubstituted function parameter pack.
      
      From-SVN: r257018
      Jason Merrill committed
    • [testsuite] Fix arm options in gcc.dg/lto/20110201-1_0.c · a84aff58
      This test fails on arm hardfloat targets because it sets an explicit -mfloat-abi=softfp.
      The usual approach to setting the NEON options is to use dg-add-options arm_neon.
      But in the lto tests we don't have that framework, we can only set them explicitly with dg-lto-options.
      
      The solution is to remove the explicit -mfloat-abi=softfp and instead add an effective target check
      for arm_neon_ok_no_float_abi that makes sure we only run this test if -mfpu=neon is enough to get NEON
      without any -mfloat-abi options. In fact, this is what the comment above check_effective_target_arm_neon_ok_no_float_abi_nocache
      recommends for lto tests.
      
      That way on my hardfloat toolchain the test doesn't try to link the softfp binary against a hard-float runtime/test glue
      and all is good. I've tested that the test is appropriately skipped when testing a --with-float=soft toolchain.
      
      
           * gcc.dg/lto/20110201-1_0.c: Remove explicit -mfloat-abi=softfp
           option.  Add arm_neon_ok_no_float_abi check.
      
      From-SVN: r257017
      Kyrylo Tkachov committed
    • [nvptx, PR83589] Workaround for branch-around-nothing JIT bug · 3dede32b
      2018-01-24  Tom de Vries  <tom@codesourcery.com>
      
      	PR target/83589
      	* config/nvptx/nvptx.c (WORKAROUND_PTXJIT_BUG_2): Define to 1.
      	(nvptx_pc_set, nvptx_condjump_label): New function. Copy from jump.c.
      	Add strict parameter.
      	(prevent_branch_around_nothing): Insert dummy insn between branch to
      	label and label with no ptx insn inbetween.
      	* config/nvptx/nvptx.md (define_insn "fake_nop"): New insn.
      
      	* testsuite/libgomp.oacc-c-c++-common/pr83589.c: New test.
      
      From-SVN: r257016
      Tom de Vries committed
    • [nvptx, PR81352] Add exit insn after noreturn call for neutered threads in warp · be606483
      2018-01-24  Tom de Vries  <tom@codesourcery.com>
      
      	PR target/81352
      	* config/nvptx/nvptx.c (nvptx_single): Add exit insn after noreturn call
      	for neutered threads in warp.
      	* config/nvptx/nvptx.md (define_insn "exit"): New insn.
      
      	* testsuite/libgomp.oacc-fortran/pr81352.f90: New test.
      
      From-SVN: r257014
      Tom de Vries committed
    • re PR tree-optimization/83176 ([graphite] ICE in set_codegen_error, at… · 6acfd18c
      re PR tree-optimization/83176 ([graphite] ICE in set_codegen_error, at graphite-isl-ast-to-gimple.c:206)
      
      2018-01-24  Richard Biener  <rguenther@suse.de>
      
      	PR tree-optimization/83176
      	* tree-chrec.c (chrec_fold_plus_1): Handle (signed T){(T) .. }
      	operands.
      
      	* gcc.dg/graphite/pr83176.c: New testcase.
      
      From-SVN: r257013
      Richard Biener committed
    • re PR tree-optimization/82819 ([graphite] ICE in set_codegen_error, at… · da37a70f
      re PR tree-optimization/82819 ([graphite] ICE in set_codegen_error, at graphite-isl-ast-to-gimple.c:206)
      
      2018-01-24  Richard Biener  <rguenther@suse.de>
      
      	PR tree-optimization/82819
      	* graphite-isl-ast-to-gimple.c (binary_op_to_tree): Avoid
      	code generating pluses that are no-ops in the target precision.
      
      	* gcc.dg/graphite/pr82819.c: New testcase.
      
      From-SVN: r257012
      Richard Biener committed
    • re PR fortran/84000 (ICE in replace_loop_annotate, at tree-cfg.c:352) · df9e39b1
      2018-01-24  Richard Biener  <rguenther@suse.de>
      
      	PR middle-end/84000
      	* tree-cfg.c (replace_loop_annotate): Handle annot_expr_parallel_kind.
      
      From-SVN: r257011
      Richard Biener committed
    • cfgcleanup.c (try_crossjump_to_edge): Use combine_with_count to merge probabilities. · 97c07987
      
      	* cfgcleanup.c (try_crossjump_to_edge): Use combine_with_count
      	to merge probabilities.
      	* predict.c (probably_never_executed): Also mark as cold functions
      	with global 0 profile and guessed local profile.
      	* profile-count.c (profile_probability::combine_with_count): New
      	member function.
      	* profile-count.h (profile_probability::operator*,
      	profile_probability::operator*=, profile_probability::operator/,
      	profile_probability::operator/=): Reduce precision to adjusted
      	and set value to guessed on contradictory divisions.
      	(profile_probability::combine_with_freq): Remove.
      	(profile_probability::combine_wiht_count): Declare.
      	(profile_count::force_nonzero):: Set to adjusted.
      	(profile_count::probability_in):: Set quality to adjusted.
      	* tree-ssa-tail-merge.c (replace_block_by): Use
      	combine_with_count.
      
      From-SVN: r257010
      Jan Hubicka committed
    • re PR c++/83921 (GCC rejects constexpr initialization of empty aggregate.) · 3885527d
      /cp
      2018-01-23  Paolo Carlini  <paolo.carlini@oracle.com>
      
      	PR c++/83921
      	* decl.c (check_for_uninitialized_const_var): Not static; add
      	bool and tsubst_flags_t parameters; adjust to be used both in
      	constexpr context and not.
      	* constexpr.c (potential_constant_expression_1): Use the above.
      	* cp-tree.h (check_for_uninitialized_const_var): Declare.
      
      /testsuite
      2018-01-23  Paolo Carlini  <paolo.carlini@oracle.com>
      
      	PR c++/83921
      	* g++.dg/cpp1y/constexpr-83921-1.C: New.
      	* g++.dg/cpp1y/constexpr-83921-2.C: Likewise.
      	* g++.dg/cpp1y/constexpr-83921-3.C: Likewise.
      	* g++.dg/ext/stmtexpr20.C: Likewise.
      	* g++.dg/ext/stmtexpr21.C: Likewise.
      
      From-SVN: r257009
      Paolo Carlini committed
    • Daily bump. · 7a007e44
      From-SVN: r257008
      GCC Administrator committed
  2. 23 Jan, 2018 21 commits
    • RISC-V: Add -mpreferred-stack-boundary option. · 0ce42fe1
      	2018-01-23  Andrew Waterman  <andrew@sifive.com>
      	gcc/
      	* config/riscv/riscv.c (riscv_stack_boundary): New.
      	(riscv_option_override): Set riscv_stack_boundary.  Handle
      	riscv_preferred_stack_boundary_arg.
      	* config/riscv/riscv.h (MIN_STACK_BOUNDARY, ABI_STACK_BOUNDARY): New.
      	(BIGGEST_ALIGNMENT): Set to STACK_BOUNDARY.
      	(STACK_BOUNDARY): Set to riscv_stack_boundary.
      	(RISCV_STACK_ALIGN): Use STACK_BOUNDARY.
      	* config/riscv/riscv.opt (mpreferred-stack-boundary): New.
      	* doc/invoke.tex (RISC-V Options): Add -mpreferred-stack-boundary.
      
      Co-Authored-By: Jim Wilson <jimw@sifive.com>
      
      From-SVN: r257005
      Andrew Waterman committed
    • libgcc: xtensa: fix NaN return from add/sub/mul/div helpers · 0889f168
      libgcc/
      2018-01-23  Max Filippov  <jcmvbkbc@gmail.com>
      
      	* config/xtensa/ieee754-df.S (__addsf3, __subsf3, __mulsf3)
      	(__divsf3): Make NaN return value quiet.
      	* config/xtensa/ieee754-sf.S (__adddf3, __subdf3, __muldf3)
      	(__divdf3): Make NaN return value quiet.
      
      From-SVN: r257002
      Max Filippov committed
    • PR c++/83947 - ICE with auto declarations. · d78201d3
      	* pt.c (do_auto_deduction): Don't deduce from an auto decl.
      	* decl.c (undeduced_auto_decl): Limit to vars and fns.
      
      From-SVN: r257000
      Jason Merrill committed
    • C++: Fix ICE in fold_for_warn on CAST_EXPR (PR c++/83974) · 7c719d08
      gcc/cp/ChangeLog:
      	PR c++/83974
      	* pt.c (tsubst_copy_and_build) <CONSTRUCTOR>: Remove early bailout
      	for pointer to member function types.
      
      gcc/testsuite/ChangeLog:
      	PR c++/83974
      	* g++.dg/warn/pr83974.C: New test case.
      
      From-SVN: r256999
      David Malcolm committed
    • re PR sanitizer/83987 (ICE with OpenMP, sanitizer and virtual bases) · 508d0c3d
      	PR sanitizer/83987
      	* tree.c (cp_free_lang_data): Change DECL_VALUE_EXPR of
      	DECL_OMP_PRIVATIZED_MEMBER vars to error_mark_node.
      
      	* g++.dg/ubsan/pr83987.C: New test.
      
      From-SVN: r256997
      Jakub Jelinek committed
    • i386: Use const reference of struct ix86_frame to avoid copy · 56dbd05b
      We can use const reference of struct ix86_frame to avoid making a local
      copy of ix86_frame.  ix86_expand_epilogue makes a local copy of struct
      ix86_frame and uses the reg_save_offset field as a local variable.  This
      patch uses a separate local variable for reg_save_offset.
      
      Tested on x86-64 with ada.
      
      	PR target/83905
      	* config/i386/i386.c (ix86_expand_prologue): Use cost reference
      	of struct ix86_frame.
      	(ix86_expand_epilogue): Likewise.  Add a local variable for
      	the reg_save_offset field in struct ix86_frame.
      
      From-SVN: r256996
      H.J. Lu committed
    • re PR fortran/83866 (ICE in gfc_release_symbol, at fortran/symbol.c:3087) · f59986b2
      2018-23-01  Paul Thomas  <pault@gcc.gnu.org>
      
      	PR fortran/83866
      	* decl.c (gfc_match_derived_decl): If eos not matched, recover
      	and emit error about garbage after declaration.
      
      2018-23-01  Paul Thomas  <pault@gcc.gnu.org>
      
      	PR fortran/83866
      	* gfortran.dg/pdt_29.f03 : New test.
      
      From-SVN: r256995
      Paul Thomas committed
    • re PR fortran/83898 (ICE in gfc_conv_expr_descriptor, at fortran/trans-array.c:7181) · 84ee745e
      2018-23-01  Paul Thomas  <pault@gcc.gnu.org>
      
      	PR fortran/83898
      	* trans-stmt.c (trans_associate_var): Do not set cst_array_ctor
      	for characters.
      
      2018-23-01  Paul Thomas  <pault@gcc.gnu.org>
      
      	PR fortran/83898
      	* gfortran.dg/associate_33.f03 : New test.
      
      From-SVN: r256994
      Paul Thomas committed
    • re PR tree-optimization/82604 (SPEC CPU2006 410.bwaves ~50% performance… · 5955438a
      re PR tree-optimization/82604 (SPEC CPU2006 410.bwaves ~50% performance regression with trunk@253679 when ftree-parallelize-loops is used)
      
      	PR tree-optimization/82604
      	* tree-loop-distribution.c (enum partition_kind): New enum item
      	PKIND_PARTIAL_MEMSET.
      	(partition_builtin_p): Support above new enum item.
      	(generate_code_for_partition): Ditto.
      	(compute_access_range): Differentiate cases that equality can be
      	proven at all loops, the innermost loops or no loops.
      	(classify_builtin_st, classify_builtin_ldst): Adjust call to above
      	function.  Set PKIND_PARTIAL_MEMSET for partition appropriately.
      	(finalize_partitions, distribute_loop): Don't fuse partition of
      	PKIND_PARTIAL_MEMSET kind when distributing 3-level loop nest.
      	(prepare_perfect_loop_nest): Distribute 3-level loop nest only if
      	parloop is enabled.
      
      From-SVN: r256990
      Bin Cheng committed
    • Handle trailing arrays in ODR warning (PR lto/81440). · cde9b2f8
      2018-01-23  Martin Liska  <mliska@suse.cz>
      
      	PR lto/81440
      	* lto-symtab.c (lto_symtab_merge): Handle and do not warn about
      	trailing arrays at the end of a struct.
      2018-01-23  Martin Liska  <mliska@suse.cz>
      
      	PR lto/81440
      	* gcc.dg/lto/pr81440.h: New test.
      	* gcc.dg/lto/pr81440_0.c: New test.
      	* gcc.dg/lto/pr81440_1.c: New test.
      
      From-SVN: r256989
      Martin Liska committed
    • Remove predictors that are unrealiable. · 813d6db9
      2018-01-23  Martin Liska  <mliska@suse.cz>
      
      	* predict.def (PRED_INDIR_CALL): Set probability to PROB_EVEN in
      	order to ignore the predictor.
      	(PRED_POLYMORPHIC_CALL): Likewise.
      	(PRED_RECURSIVE_CALL): Likewise.
      
      From-SVN: r256988
      Martin Liska committed
    • [PR c++/839888] Baselink tsubst ICE · 66ce8ff7
      https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01954.html
      	PR c++/83988
      	* pt.c (tsubst_baselink): Remove optype assert.
      	* ptree.c (cxx_print_xnode): <case BASELINK> Print BASELINK_OPTYPE.
      
      	PR c++/83988
      	* g++.dg/template/pr83988.C: New.
      
      From-SVN: r256986
      Nathan Sidwell committed
    • re PR c++/82882 (ICE Segmentation fault) · 55a46cb5
      	PR c++/82882
      	PR c++/83978
      	* g++.dg/cpp0x/pr82882.C: New test.
      	* g++.dg/cpp0x/pr83978.C: New test.
      
      From-SVN: r256985
      Jakub Jelinek committed
    • re PR c++/83958 (ICE: Segmentation fault (in find_decomp_class_base)) · 941ae8b4
      	PR c++/83958
      	* decl.c (cp_finish_decomp): Diagnose if reference structure binding
      	refers to incomplete type.
      
      	* g++.dg/cpp1z/decomp35.C: New test.
      
      From-SVN: r256984
      Jakub Jelinek committed
    • Clean-up IPA profile dump output. · a53d4f20
      2018-01-23  Martin Liska  <mliska@suse.cz>
      
      	* tree-profile.c (tree_profiling): Print function header to
      	aware reader which function we are working on.
      	* value-prof.c (gimple_find_values_to_profile): Do not print
      	not interesting value histograms.
      
      From-SVN: r256983
      Martin Liska committed
    • Fix profile_quality sanity check. · 17594687
      2018-01-22  Martin Liska  <mliska@suse.cz>
      
      	* profile-count.h (enum profile_quality): Add
      	profile_uninitialized as the first value. Do not number values
      	as they are zero based.
      	(profile_count::verify): Update sanity check.
      	(profile_probability::verify): Likewise.
      
      From-SVN: r256982
      Martin Liska committed
    • [C++ PATCH] Deprecate ARM-era for scopes · d55d1e4f
      https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01940.html
      	gcc/cp/
      	Deprecate ARM-era for scope handling
      	* decl.c (poplevel): Flag_new_for_scope is a boolean-like.
      	(cxx_init_decl_processing): Deprecate flag_new_for_scope being
      	cleared.
      	* name-lookup.c (check_for_out_of_scope_variable): Deprecate and
      	cleanup handling.
      	* semantics.c (begin_for_scope): Flag_new_for_scope is
      	boolean-like.
      	(finish_for_stmt, begin_range_for_stmt): Likewise.
      
      	gcc/
      	* doc/invoke.texi (ffor-scope): Deprecate.
      
      	gcc/cp/
      	* g++.dg/cpp0x/range-for10.C: Adjust.
      	* g++.dg/ext/forscope1.C: Adjust.
      	* g++.dg/ext/forscope2.C: Adjust.
      	* g++.dg/template/for1.C: Adjust.
      
      From-SVN: r256981
      Nathan Sidwell committed
    • -Warray-bounds: Fix false positive in some "switch" stmts (PR tree-optimization/83510) · 9972bbbc
      PR tree-optimization/83510 reports that r255649 (for
      PR tree-optimization/83312) introduced a false positive for
      -Warray-bounds for array accesses within certain switch statements:
      those for which value-ranges allow more than one case to be reachable,
      but for which one or more of the VR-unreachable cases contain
      out-of-range array accesses.
      
      In the reproducer, after the switch in f is inlined into g, we have 3 cases
      for the switch (case 9, case 10-19, and default), within a loop that
      ranges from 0..9.
      
      With both the old and new code, vr_values::simplify_switch_using_ranges clears
      the EDGE_EXECUTABLE flag on the edge to the "case 10-19" block.  This
      happens during the dom walk within the substitute_and_fold_engine.
      
      With the old code, the clearing of that EDGE_EXECUTABLE flag led to the
            /* Skip blocks that were found to be unreachable.  */
      code in the old implementation of vrp_prop::check_all_array_refs skipping
      the "case 10-19" block.
      
      With the new code, we have a second dom walk, and that dom_walker's ctor
      sets all edges to be EDGE_EXECUTABLE, losing that information.
      
      Then, dom_walker::before_dom_children (here, the subclass'
      check_array_bounds_dom_walker::before_dom_children) can return one edge, if
      there's a unique successor edge, and dom_walker::walk filters the dom walk
      to just that edge.
      
      Here we have two VR-valid edges (case 9 and default), and an VR-invalid
      successor edge (case 10-19).  There's no *unique* valid successor edge,
      and hence taken_edge is NULL, and the filtering in dom_walker::walk
      doesn't fire.
      
      Hence we've lost the filtering of the "case 10-19" BB, hence the false
      positive.
      
      The issue is that we have two dom walks: first within vr_values'
      substitute_and_fold_dom_walker (which has skip_unreachable_blocks == false),
      then another within vrp_prop::check_all_array_refs (with
      skip_unreachable_blocks == true).
      
      Each has different "knowledge" about ruling out edges due to value-ranges,
      but we aren't combining that information.  The former "knows" about
      out-edges at a particular control construct (e.g. at a switch), the latter
      "knows" about dominance, but only about unique successors (hence the
      problem when two out of three switch cases are valid).
      
      This patch combines the information by preserving the EDGE_EXECUTABLE
      flags from the first dom walk, and using it in the second dom walk,
      potentially rejecting additional edges.
      
      Doing so fixes the false positive.
      
      I attempted an alternative fix, merging the two dom walks into one, but
      that led to crashes in identify_jump_threads, so I went with this, as
      a less invasive fix.
      
      gcc/ChangeLog:
      	PR tree-optimization/83510
      	* domwalk.c (set_all_edges_as_executable): New function.
      	(dom_walker::dom_walker): Convert bool param
      	"skip_unreachable_blocks" to enum reachability.  Move setup of
      	edge flags to set_all_edges_as_executable and only do it when
      	reachability is REACHABLE_BLOCKS.
      	* domwalk.h (enum dom_walker::reachability): New enum.
      	(dom_walker::dom_walker): Convert bool param
      	"skip_unreachable_blocks" to enum reachability.
      	(set_all_edges_as_executable): New decl.
      	* graphite-scop-detection.c  (gather_bbs::gather_bbs): Convert
      	from false for "skip_unreachable_blocks" to ALL_BLOCKS for
      	"reachability".
      	* tree-ssa-dom.c (dom_opt_dom_walker::dom_opt_dom_walker): Likewise,
      	but converting true to REACHABLE_BLOCKS.
      	* tree-ssa-sccvn.c (sccvn_dom_walker::sccvn_dom_walker): Likewise.
      	* tree-vrp.c
      	(check_array_bounds_dom_walker::check_array_bounds_dom_walker):
      	Likewise, but converting it to REACHABLE_BLOCKS_PRESERVING_FLAGS.
      	(vrp_dom_walker::vrp_dom_walker): Likewise, but converting it to
      	REACHABLE_BLOCKS.
      	(vrp_prop::vrp_finalize): Call set_all_edges_as_executable
      	if check_all_array_refs will be called.
      
      gcc/testsuite/ChangeLog:
      	PR tree-optimization/83510
      	* gcc.c-torture/compile/pr83510.c: New test case.
      
      From-SVN: r256980
      David Malcolm committed
    • Add more test coverage to selftest::test_location_wrappers · 02851c8c
      gcc/ChangeLog:
      	* tree.c (selftest::test_location_wrappers): Add more test
      	coverage.
      
      From-SVN: r256979
      David Malcolm committed
    • Fix memory leaks in sbitmap.c selftests · 485cf854
      "make selftest-valgrind" shows a few leaks in sbitmap.c's selftests;
      this patch fixes them.
      
      gcc/ChangeLog:
      	* sbitmap.c (selftest::test_set_range): Fix memory leaks.
      	(selftest::test_bit_in_range): Likewise.
      
      From-SVN: r256978
      David Malcolm committed