Commit Graph

186809 Commits

Author SHA1 Message Date
Richard Biener
df0d7486ec tree-optimization/101467 - fix make_temp_ssa_name usage
My previous change to vect_gen_while introduced paths which call
make_temp_ssa_name with a NULL name which isn't supported.  The
following fixes that.

2021-07-16  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/101467
	* tree-vect-stmts.c (vect_gen_while): Properly guard
	make_temp_ssa_name usage.
2021-07-16 12:01:46 +02:00
Jonathan Wright
fc58c49ed9 testsuite: aarch64: Fix failing SVE tests on big endian
A recent change "gcc: Add vec_select -> subreg RTL simplification"
updated the expected test results for SVE extraction tests. The new
result should only have been changed for little endian. This patch
restores the old expected result for big endian.

gcc/testsuite/ChangeLog:

2021-07-15  Jonathan Wright  <jonathan.wright@arm.com>

	* gcc.target/aarch64/sve/extract_1.c: Split expected results
	by big/little endian targets, restoring the old expected
	result for big endian.
	* gcc.target/aarch64/sve/extract_2.c: Likewise.
	* gcc.target/aarch64/sve/extract_3.c: Likewise.
	* gcc.target/aarch64/sve/extract_4.c: Likewise.
2021-07-16 10:54:05 +01:00
Cooper Qu
2f11ca2a3a C-SKY: Use the common way to define MULTILIB_DIRNAMES.
C-SKY previously used a forked print-sysroot-suffix.sh and define
CSKY_MULTILIB_DIRNAMES to specify OS multilib directories. This
patch delete the forked print-sysroot-suffix.sh and define
MULTILIB_DIRNAMES to generate same directories.

gcc/
	* config.gcc: Don't use forked print-sysroot-suffix.sh and
	t-sysroot-suffix for C-SKY.
	* config/csky/print-sysroot-suffix.sh: Delete.
	* config/csky/t-csky-linux: Delete.
	* config/csky/t-sysroot-suffix: Define MULTILIB_DIRNAMES
	instead of CSKY_MULTILIB_DIRNAMES.
2021-07-16 16:48:06 +08:00
Richard Biener
d6aa28bb93 tree-optimization/101462 - fix signedness of reused reduction vector
This fixes the partial reduction of the reused reduction vector to
carried out in the correct sign and the correctly signed vector
recorded for the skip edge use.

2021-07-16  Richard Biener  <rguenther@suse.de>

	* tree-vect-loop.c (vect_transform_cycle_phi): Correct sign
	conversion issues with the partial reduction of the reused
	vector accumulator.
2021-07-16 09:41:23 +02:00
Richard Biener
a314d50336 Disable --param vect-partial-vector-usage by default on x86
The following defaults --param vect-partial-vector-usage to zero
for x86_64 matching existing behavior where support for this
is not present.

2021-07-15  Richard Biener  <rguenther@suse.de>

	* config/i386/i386-options.c (ix86_option_override_internal): Set
	param_vect_partial_vector_usage to zero if not set.
2021-07-16 09:41:23 +02:00
Jonathan Wakely
adc03d72c3 libstdc++: Adjust doxygen markup for unique_ptr grouping
This reorders the @{ and @relates tags, and moves the definition of the
__cpp_lib_make_unique macro out of the group, as it seems to confuse
doxygen.

libstdc++-v3/ChangeLog:

	* include/bits/unique_ptr.h: Adjust doxygen markup.
2021-07-16 08:40:44 +01:00
Jonathan Wakely
da89dfc2a0 libstdc++: Adjust doxygen markup for variable templates group [PR101307]
libstdc++-v3/ChangeLog:

	PR libstdc++/101307
	* include/std/type_traits: Adjust doxygen markup.
2021-07-16 08:40:43 +01:00
Jonathan Wakely
c1676651b6 libstdc++: Suppress pedantic warnings about __int128
With -std=c++NN -pedantic -Wsystem-headers there are warnings about the
use of __int128, which can be suppressed using diagnostic pragmas.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/cpp_type_traits.h: Add diagnostic pragmas around
	uses of non-standard integer types.
	* include/bits/functional_hash.h: Likewise.
	* include/bits/iterator_concepts.h: Likewise.
	* include/bits/max_size_type.h: Likewise.
	* include/bits/std_abs.h: Likewise.
	* include/bits/stl_algobase.h: Likewise.
	* include/bits/uniform_int_dist.h: Likewise.
	* include/ext/numeric_traits.h: Likewise.
	* include/std/type_traits: Likewise.
2021-07-16 08:40:43 +01:00
GCC Administrator
d97d71a198 Daily bump. 2021-07-16 00:16:25 +00:00
David Malcolm
c031ea2782 analyzer: fix const-correctness of various is_a_helper
gcc/analyzer/ChangeLog:
	* svalue.h (is_a_helper <placeholder_svalue *>::test): Make
	param and template param const.
	(is_a_helper <widening_svalue *>::test): Likewise.
	(is_a_helper <compound_svalue *>::test): Likewise.
	(is_a_helper <conjured_svalue *>::test): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2021-07-15 19:33:07 -04:00
Uros Bizjak
f364cdffa4 i386: Fix ix86_hard_regno_mode_ok for TDmode on 32bit targets [PR101346]
General regs on 32bit targets do not support 128bit modes,
including TDmode.

gcc/

2021-07-15  Uroš Bizjak  <ubizjak@gmail.com>

	PR target/101346
	* config/i386/i386.h (VALID_SSE_REG_MODE): Add TDmode.
	(VALID_INT_MODE_P): Add SDmode and DDmode.
	Add TDmode for TARGET_64BIT.
	(VALID_DFP_MODE_P): Remove.
	* config/i386/i386.c (ix86_hard_regno_mode_ok):
	Do not use VALID_DFP_MODE_P.

gcc/testsuite/

2021-07-15  Uroš Bizjak  <ubizjak@gmail.com>

	PR target/101346
	* gcc.target/i386/pr101346.c: New test.
2021-07-15 22:40:30 +02:00
Andrew MacLeod
478cc962ad Add gimple_range_type for statements.
The existing mechanisms for picking up the type of a statement are
inconsistent with the needs of ranger. Encapsulate all the bits
required to pick up the return type of a statement in one place, and check
whether the type is supported.

	* gimple-range-fold.cc (adjust_pointer_diff_expr): Use
	gimple_range_type.
	(fold_using_range::fold_stmt): Ditto.
	(fold_using_range::range_of_range_op): Ditto.
	(fold_using_range::range_of_phi): Ditto.
	(fold_using_range::range_of_call): Ditto.
	(fold_using_range::range_of_builtin_ubsan_call): Ditto.
	(fold_using_range::range_of_builtin_call): Ditto.
	(fold_using_range::range_of_cond_expr): Ditto.
	* gimple-range-fold.h (gimple_range_type): New.
2021-07-15 15:58:11 -04:00
Martin Sebor
f0500db369 Detect buffer overflow by aggregate and vector stores [PR97027].
Resolves:
PR middle-end/97027 - missing warning on buffer overflow storing a larger scalar into a smaller array

gcc/ChangeLog:

	PR middle-end/97027
	* tree-ssa-strlen.c (handle_assign): New function.
	(maybe_warn_overflow): Add argument.
	(nonzero_bytes_for_type): New function.
	(count_nonzero_bytes): Handle more tree types.  Call
	nonzero_bytes_for_tye.
	(count_nonzero_bytes): Handle types.
	(handle_store): Handle stores from function calls.
	(strlen_check_and_optimize_call): Move code to handle_assign.  Call
	it for assignments from function calls.

gcc/testsuite/ChangeLog:

	PR middle-end/97027
	* gcc.dg/Wstringop-overflow-15.c: Remove an xfail.
	* gcc.dg/Wstringop-overflow-47.c: Adjust xfails.
	* gcc.dg/torture/pr69170.c: Avoid valid warnings.
	* gcc.dg/torture/pr70025.c: Prune out a false positive.
	* gcc.dg/vect/pr97769.c: Initialize a loop control variable.
	* gcc.target/i386/pr92658-avx512bw-trunc.c: Increase buffer size
	to avoid overflow.
	* gcc.target/i386/pr92658-avx512f.c: Same.
	* gcc.dg/Wstringop-overflow-68.c: New test.
	* gcc.dg/Wstringop-overflow-69.c: New test.
	* gcc.dg/Wstringop-overflow-70.c: New test.
	* gcc.dg/Wstringop-overflow-71.c: New test.
	* gcc.dg/strlenopt-95.c: New test.
2021-07-15 13:15:31 -06:00
David Malcolm
33255ad3ac analyzer: reimplement -Wanalyzer-use-of-uninitialized-value [PR95006 et al]
The initial gcc 10 era commit of the analyzer (in
757bf1dff5) had an implementation of
-Wanalyzer-use-of-uninitialized-value, but was sufficiently buggy
that I removed it in 78b9783774 before
the release of gcc 10.1

This patch reintroduces the warning, heavily rewritten, with (I hope)
a less buggy implementation this time, for GCC 12.

gcc/analyzer/ChangeLog:
	PR analyzer/95006
	PR analyzer/94713
	PR analyzer/94714
	* analyzer.cc (maybe_reconstruct_from_def_stmt): Split out
	GIMPLE_ASSIGN case into...
	(get_diagnostic_tree_for_gassign_1): New.
	(get_diagnostic_tree_for_gassign): New.
	* analyzer.h (get_diagnostic_tree_for_gassign): New decl.
	* analyzer.opt (Wanalyzer-write-to-string-literal): New.
	* constraint-manager.cc (class svalue_purger): New.
	(constraint_manager::purge_state_involving): New.
	* constraint-manager.h
	(constraint_manager::purge_state_involving): New.
	* diagnostic-manager.cc (saved_diagnostic::supercedes_p): New.
	(dedupe_winners::handle_interactions): New.
	(diagnostic_manager::emit_saved_diagnostics): Call it.
	* diagnostic-manager.h (saved_diagnostic::supercedes_p): New decl.
	* engine.cc (impl_region_model_context::warn): Convert return type
	to bool.  Return false if the diagnostic isn't saved.
	(impl_region_model_context::purge_state_involving): New.
	(impl_sm_context::get_state): Use NULL ctxt when querying old
	rvalue.
	(impl_sm_context::set_next_state): Use new sval when querying old
	state.
	(class dump_path_diagnostic): Move to region-model.cc
	(exploded_node::on_stmt): Move to on_stmt_pre and on_stmt_post.
	Remove call to purge_state_involving.
	(exploded_node::on_stmt_pre): New, based on the above.  Move most
	of it to region_model::on_stmt_pre.
	(exploded_node::on_stmt_post): Likewise, moving to
	region_model::on_stmt_post.
	(class stale_jmp_buf): Fix parent class to use curiously recurring
	template pattern.
	(feasibility_state::maybe_update_for_edge): Call on_call_pre and
	on_call_post on gcalls.
	* exploded-graph.h (impl_region_model_context::warn): Return bool.
	(impl_region_model_context::purge_state_involving): New decl.
	(exploded_node::on_stmt_pre): New decl.
	(exploded_node::on_stmt_post): New decl.
	* pending-diagnostic.h (pending_diagnostic::use_of_uninit_p): New.
	(pending_diagnostic::supercedes_p): New.
	* program-state.cc (sm_state_map::get_state): Inherit state for
	conjured_svalue as well as initial_svalue.
	(sm_state_map::purge_state_involving): Also support SK_CONJURED.
	* region-model-impl-calls.cc (call_details::get_uncertainty):
	Handle m_ctxt being NULL.
	(call_details::get_or_create_conjured_svalue): New.
	(region_model::impl_call_fgets): New.
	(region_model::impl_call_fread): New.
	* region-model-manager.cc
	(region_model_manager::get_or_create_initial_value): Return an
	uninitialized poisoned value for regions that can't have initial
	values.
	* region-model-reachability.cc
	(reachable_regions::mark_escaped_clusters): Handle ctxt being
	NULL.
	* region-model.cc (region_to_value_map::purge_state_involving): New.
	(poisoned_value_diagnostic::use_of_uninit_p): New.
	(poisoned_value_diagnostic::emit): Handle POISON_KIND_UNINIT.
	(poisoned_value_diagnostic::describe_final_event): Likewise.
	(region_model::check_for_poison): New.
	(region_model::on_assignment): Call it.
	(class dump_path_diagnostic): Move here from engine.cc.
	(region_model::on_stmt_pre): New, based on exploded_node::on_stmt.
	(region_model::on_call_pre): Move the setting of the LHS to a
	conjured svalue to before the checks for specific functions.
	Handle "fgets", "fgets_unlocked", and "fread".
	(region_model::purge_state_involving): New.
	(region_model::handle_unrecognized_call): Handle ctxt being NULL.
	(region_model::get_rvalue): Call check_for_poison.
	(selftest::test_stack_frames): Use NULL for context when getting
	uninitialized rvalue.
	(selftest::test_alloca): Likewise.
	* region-model.h (region_to_value_map::purge_state_involving): New
	decl.
	(call_details::get_or_create_conjured_svalue): New decl.
	(region_model::on_stmt_pre): New decl.
	(region_model::purge_state_involving): New decl.
	(region_model::impl_call_fgets): New decl.
	(region_model::impl_call_fread): New decl.
	(region_model::check_for_poison): New decl.
	(region_model_context::warn): Return bool.
	(region_model_context::purge_state_involving): New.
	(noop_region_model_context::warn): Return bool.
	(noop_region_model_context::purge_state_involving): New.
	(test_region_model_context:: warn): Return bool.
	* region.cc (region::get_memory_space): New.
	(region::can_have_initial_svalue_p): New.
	(region::involves_p): New.
	* region.h (enum memory_space): New.
	(region::get_memory_space): New decl.
	(region::can_have_initial_svalue_p): New decl.
	(region::involves_p): New decl.
	* sm-malloc.cc (use_after_free::supercedes_p): New.
	* store.cc (binding_cluster::purge_state_involving): New.
	(store::purge_state_involving): New.
	* store.h (class symbolic_binding): New forward decl.
	(binding_key::dyn_cast_symbolic_binding): New.
	(symbolic_binding::dyn_cast_symbolic_binding): New.
	(binding_cluster::purge_state_involving): New.
	(store::purge_state_involving): New.
	* svalue.cc (svalue::can_merge_p): Reject attempts to merge
	poisoned svalues with other svalues, so that we identify
	paths in which a variable is conditionally uninitialized.
	(involvement_visitor::visit_conjured_svalue): New.
	(svalue::involves_p): Also handle SK_CONJURED.
	(poison_kind_to_str): Handle POISON_KIND_UNINIT.
	(poisoned_svalue::maybe_fold_bits_within): New.
	* svalue.h (enum poison_kind): Add POISON_KIND_UNINIT.
	(poisoned_svalue::maybe_fold_bits_within): New decl.

gcc/ChangeLog:
	PR analyzer/95006
	PR analyzer/94713
	PR analyzer/94714
	* doc/invoke.texi: Add -Wanalyzer-use-of-uninitialized-value.

gcc/testsuite/ChangeLog:
	PR analyzer/95006
	PR analyzer/94713
	PR analyzer/94714
	* g++.dg/analyzer/pr93212.C: Update location of warning.
	* g++.dg/analyzer/pr94011.C: Add
	-Wno-analyzer-use-of-uninitialized-value.
	* g++.dg/analyzer/pr94503.C: Likewise.
	* gcc.dg/analyzer/clobbers-1.c: Convert "f" from a local to a
	param to avoid uninitialized warning.
	* gcc.dg/analyzer/data-model-1.c (test_12): Add test for
	uninitialized value on result of alloca.
	(test_12a): Add expected warning.
	(test_12c): Likewise.
	(test_19): Likewise.
	(test_29b): Likewise.
	(test_29c): Likewise.
	(test_37): Remove xfail.
	(test_37a): Likewise.
	* gcc.dg/analyzer/data-model-20.c: Add warning about leak.
	* gcc.dg/analyzer/explode-2.c: Remove params; add
	-Wno-analyzer-too-complex, -Wno-analyzer-malloc-leak, and xfails.
	Initialize the locals.
	* gcc.dg/analyzer/explode-2a.c: Initialize the locals.  Add
	expected leak.
	* gcc.dg/analyzer/fgets-1.c: New test.
	* gcc.dg/analyzer/fread-1.c: New test.
	* gcc.dg/analyzer/malloc-1.c (test_16): Add expected warning.
	(test_40): Likewise.
	* gcc.dg/analyzer/memset-CVE-2017-18549-1.c: Check for
	uninitialized padding.
	* gcc.dg/analyzer/pr93355-localealias-feasibility.c (fread): New
	decl.
	(read_alias_file): Call it.
	* gcc.dg/analyzer/pr94047.c: Add expected warnings.
	* gcc.dg/analyzer/pr94851-2.c: Likewise.
	* gcc.dg/analyzer/pr96841.c: Convert local to a param.
	* gcc.dg/analyzer/pr98628.c: Likewise.
	* gcc.dg/analyzer/pr99042.c: Updated expected location of leak
	diagnostics.
	* gcc.dg/analyzer/symbolic-1.c: Add expected warnings.
	* gcc.dg/analyzer/symbolic-7.c: Likewise.
	* gcc.dg/analyzer/torture/pr93649.c: Add expected warning.  Skip
	with -fno-fat-lto-objects.
	* gcc.dg/analyzer/uninit-1.c: New test.
	* gcc.dg/analyzer/uninit-2.c: New test.
	* gcc.dg/analyzer/uninit-3.c: New test.
	* gcc.dg/analyzer/uninit-4.c: New test.
	* gcc.dg/analyzer/uninit-pr94713.c: New test.
	* gcc.dg/analyzer/uninit-pr94714.c: New test.
	* gcc.dg/analyzer/use-after-free-2.c: New test.
	* gcc.dg/analyzer/use-after-free-3.c: New test.
	* gcc.dg/analyzer/zlib-3.c: Add expected warning.
	* gcc.dg/analyzer/zlib-6.c: Convert locals to params to avoid
	uninitialized warnings.  Remove xfail.
	* gcc.dg/analyzer/zlib-6a.c: New test, based on the old version
	of the above.
	* gfortran.dg/analyzer/pr97668.f: Add
	-Wno-analyzer-use-of-uninitialized-value and
	-Wno-analyzer-too-complex.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2021-07-15 15:07:07 -04:00
David Malcolm
98cd4d123a analyzer: add -fdump-analyzer-exploded-paths
gcc/analyzer/ChangeLog:
	* analyzer.opt (fdump-analyzer-exploded-paths): New.
	* diagnostic-manager.cc
	(diagnostic_manager::emit_saved_diagnostic): Implement it.
	* engine.cc (exploded_path::dump_to_pp): Add ext_state param and
	use it to dump states if non-NULL.
	(exploded_path::dump): Likewise.
	(exploded_path::dump_to_file): New.
	* exploded-graph.h (exploded_path::dump_to_pp): Add ext_state
	param.
	(exploded_path::dump): Likewise.
	(exploded_path::dump): Likewise.
	(exploded_path::dump_to_file): New.

gcc/ChangeLog:
	* doc/invoke.texi (-fdump-analyzer-exploded-paths): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2021-07-15 15:04:07 -04:00
David Malcolm
e9711fe482 analyzer: use DECL_DEBUG_EXPR on SSA names for artificial vars
gcc/analyzer/ChangeLog:
	* analyzer.cc (fixup_tree_for_diagnostic_1): Use DECL_DEBUG_EXPR
	if it's available.
	* engine.cc (readability): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2021-07-15 15:02:42 -04:00
David Malcolm
a9241df96e analyzer: handle self-referential phis
gcc/analyzer/ChangeLog:
	* state-purge.cc (self_referential_phi_p): New.
	(state_purge_per_ssa_name::process_point): Don't purge an SSA name
	at its def-stmt if the def-stmt is self-referential.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/phi-1.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2021-07-15 15:01:57 -04:00
Christophe Lyon
797358f42f testsuite: [arm] Remove arm_v8_2a_imm8_neon_ok_nocache
This patch removes this recently-introduced effective-target, as it
looks like a typo and duplicate for arm_v8_2a_i8mm_ok (imm8 vs i8mm),
and it is not used.

2021-07-15  Christophe Lyon  <christophe.lyon@foss.st.com>

	gcc/testsuite/
	* lib/target-supports.exp (arm_v8_2a_imm8_neon_ok_nocache):
	Delete.
2021-07-15 18:56:09 +00:00
Christophe Lyon
7a9c9a3265 testsuite: [arm] Add missing effective-target to vusdot-autovec.c
This test fails when forcing an -mcpu option incompatible with
-march=armv8.2-a+i8mm.

This patch adds the missing arm_v8_2a_i8mm_ok effective-target, as
well as the associated dg-add-options arm_v8_2a_i8mm.

2021-07-15  Christophe Lyon  <christophe.lyon@foss.st.com>

	gcc/testsuite/
	* gcc.target/arm/simd/vusdot-autovec.c: Use arm_v8_2a_i8mm_ok
	effective-target.
2021-07-15 18:55:39 +00:00
Jakub Jelinek
7094a69bd6 c++: Optimize away NULLPTR_TYPE comparisons [PR101443]
Comparisons of NULLPTR_TYPE operands cause all kinds of problems in the
middle-end and in fold-const.c, various optimizations assume that if they
see e.g. a non-equality comparison with one of the operands being
INTEGER_CST and it is not INTEGRAL_TYPE_P (which has TYPE_{MIN,MAX}_VALUE),
they can build_int_cst (type, 1) to find a successor.

The following patch fixes it by making sure they don't appear in the IL,
optimize them away at cp_fold time as all can be folded.

Though, I've just noticed that clang++ rejects the non-equality comparisons
instead, foo () > 0 with
invalid operands to binary expression ('decltype(nullptr)' (aka 'nullptr_t') and 'int')
and foo () > nullptr with
invalid operands to binary expression ('decltype(nullptr)' (aka 'nullptr_t') and 'nullptr_t')

Shall we reject those too, in addition or instead of parts of this patch?
If so, wouldn't this patch be still useful for backports, I bet we don't
want to start reject it on the release branches when we used to accept it.

2021-07-15  Jakub Jelinek  <jakub@redhat.com>

	PR c++/101443
	* cp-gimplify.c (cp_fold): For comparisons with NULLPTR_TYPE
	operands, fold them right away to true or false.

	* g++.dg/cpp0x/nullptr46.C: New test.
2021-07-15 18:53:20 +02:00
Tamar Christina
b25edf6e6f testsuite: Fix testisms in scalar tests PR101457
These testcases accidentally contain the wrong signs for the expected values
for the scalar code.  The vector code however is correct.

Committed as a trivial fix.

gcc/testsuite/ChangeLog:

	PR middle-end/101457
	* gcc.dg/vect/vect-reduc-dot-17.c: Fix signs of scalar code.
	* gcc.dg/vect/vect-reduc-dot-18.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-22.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-9.c: Likewise.
2021-07-15 17:42:10 +01:00
Martin Sebor
98f1f9f38c Avoid -Wvla-parameter for nontrivial bounds [PR97548].
Resolves:
PR c/101289 - bogus -Wvla-paramater warning when using const for vla param
PR c/97548 -  bogus -Wvla-parameter on a bound expression involving a parameter

gcc/c-family/ChangeLog:

	PR c/101289
	PR c/97548
	* c-warn.c (warn_parm_array_mismatch): Use OEP_DECL_NAME.

gcc/c/ChangeLog:

	PR c/101289
	PR c/97548
	* c-decl.c (get_parm_array_spec): Strip nops.

gcc/ChangeLog:

	PR c/101289
	PR c/97548
	* fold-const.c (operand_compare::operand_equal_p): Handle OEP_DECL_NAME.
	(operand_compare::verify_hash_value): Same.
	* tree-core.h (OEP_DECL_NAME): New.

gcc/testsuite/ChangeLog:

	* gcc.dg/Wvla-parameter-12.c: New test.
2021-07-15 10:22:06 -06:00
Martin Jambor
07bd270304
Change the type of return value of profile_count::value to uint64_t
The field in which profile_count holds the count has 61 bits but the
getter method only returns it as a 32 bit number.  The getter is (and
should be) only used for dumping but even dumps are better when they
do not lie.

gcc/ChangeLog:

2021-07-13  Martin Jambor  <mjambor@suse.cz>

	* profile-count.h (profile_count::value): Change the return type to
	uint64_t.
	* gimple-pretty-print.c (dump_gimple_bb_header): Adjust print
	statement.
	* tree-cfg.c (dump_function_to_file): Likewise.
2021-07-15 17:27:17 +02:00
Jonathan Wakely
17855eed7f libstdc++: Fix std::get<T> for std::tuple [PR101427]
The std::get<T> functions relied on deduction failing if more than one
base class existed for the type T.  However the implementation of Core
DR 2303 (in r11-4693) made deduction succeed (and select the
more-derived base class).

This rewrites the implementation of std::get<T> to explicitly check for
more than one occurrence of T in the tuple elements, making it
ill-formed again. Additionally, the large wall of overload resolution
errors described in PR c++/101460 is avoided by making std::get<T> use
__get_helper<I> directly instead of calling std::get<I>, and by adding a
deleted overload of __get_helper<N> for out-of-range N.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101427
	* include/std/tuple (tuple_element): Improve static_assert text.
	(__get_helper): Add deleted overload.
	(get<i>(tuple<T...>&&), get<i>(const tuple<T...>&&)): Use
	__get_helper directly.
	(__get_helper2): Remove.
	(__find_uniq_type_in_pack): New constexpr helper function.
	(get<T>): Use __find_uniq_type_in_pack and __get_helper instead
	of __get_helper2.
	* testsuite/20_util/tuple/element_access/get_neg.cc: Adjust
	expected errors.
	* testsuite/20_util/tuple/element_access/101427.cc: New test.
2021-07-15 16:25:42 +01:00
Jonathan Wakely
1f7182d68c libstdc++: Add noexcept to __replacement_assert [PR101429]
This results in slightly smaller code when assertions are enabled when
either using Clang (because it adds code to call std::terminate when
potentially-throwing functions are called in a noexcept function) or a
freestanding or non-verbose build (because it doesn't use printf).

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101429
	* include/bits/c++config (__replacement_assert): Add noexcept.
	[!_GLIBCXX_VERBOSE] (__glibcxx_assert_impl): Use __builtin_trap
	instead of __replacement_assert.
2021-07-15 16:25:42 +01:00
Bill Schmidt
ad5f8ac1d2 rs6000: Don't let swaps pass break multiply low-part (PR101129)
2021-07-15  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	PR target/101129
	* config/rs6000/rs6000-p8swap.c (has_part_mult): New.
	(rs6000_analyze_swaps): Insns containing a subreg of a mult are
	not swappable.

gcc/testsuite/
	PR target/101129
	* gcc.target/powerpc/pr101129.c: New.
2021-07-15 10:16:17 -05:00
Richard Biener
92acae5047 Streamline vect_gen_while
This adjusts the vect_gen_while API to match that of
vect_gen_while_not allowing further patches to generate more
than one stmt for the while case.

2021-07-15  Richard Biener  <rguenther@suse.de>

	* tree-vectorizer.h (vect_gen_while): Match up with
	vect_gen_while_not.
	* tree-vect-stmts.c (vect_gen_while): Adjust API to that
	of vect_gen_while_not.
	(vect_gen_while_not): Adjust.
	* tree-vect-loop-manip.c (vect_set_loop_controls_directly): Likewise.
2021-07-15 14:55:28 +02:00
Aldy Hernandez
79f71ec6fc Abstract out non_null adjustments in ranger.
There are 4 exact copies of the non-null range adjusting code in the
ranger.  This patch abstracts the functionality into a separate method.

As a follow-up I would like to remove the varying_p check, since I have
seen incoming ranges such as [0, 0xff....ef] which are not varying, but
are not-null.  Removing the varying restriction catches those.

gcc/ChangeLog:

	* gimple-range-cache.cc (non_null_ref::adjust_range): New.
	(ranger_cache::range_of_def): Call adjust_range.
	(ranger_cache::entry_range): Same.
	* gimple-range-cache.h (non_null_ref::adjust_range): New.
	* gimple-range.cc (gimple_ranger::range_of_expr): Call
	adjust_range.
	(gimple_ranger::range_on_entry): Same.
2021-07-15 14:23:55 +02:00
Tamar Christina
8e321f2a63 Revert "AArch32: Correct sdot RTL on aarch32"
This reverts commit c9165e2d58.
2021-07-15 13:16:15 +01:00
Tamar Christina
5402023f05 Revert "AArch64: Correct dot-product auto-vect optab RTL"
This reverts commit 6d1cdb2782.
2021-07-15 13:16:00 +01:00
Jakub Jelinek
f6dde32b9d gimplify: Fix endless recursion on volatile empty type reads/writes [PR101437]
Andrew's recent change to optimize away during gimplification not just
assignments of zero sized types, but also assignments of empty types,
caused infinite recursion in the gimplifier.
If such assignment is optimized away, we gimplify separately the to_p
and from_p operands and throw away the result.  When gimplifying the
operand that is volatile, we run into the gimplifier code below, which has
different handling for types with non-BLKmode mode, tries to gimplify
those as vol.N = expr, and for BLKmode just throws those away.
Zero sized types will always have BLKmode and so are fine, but for the
non-BLKmode ones like struct S in the testcase, the vol.N = expr
gimplification will reach again the gimplify_modify_expr code, see it is
assignment of empty type and will gimplify again vol.N separately
(non-volatile, so ok) and expr, on which it will recurse again.

The following patch breaks that infinite recursion by ignoring bare
volatile loads from empty types.
If a volatile load or store for aggregates are supposed to be member-wise
loads or stores, then there are no non-padding members in the empty types that
should be copied and so it is probably ok.

2021-07-15  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/101437
	* gimplify.c (gimplify_expr): Throw away volatile reads from empty
	types even if they have non-BLKmode TYPE_MODE.

	* gcc.c-torture/compile/pr101437.c: New test.
2021-07-15 10:17:06 +02:00
Alan Modra
cd6ca96f5d [POWER10] __morestack calls from pcrel code
Compiling gcc/testsuite/gcc.dg/split-*.c and others with -mcpu=power10
and linking with a non-pcrel libgcc results in crashes due to the
power10 pcrel code not having r2 set for the generic-morestack.c
functions called from __morestack.  There is also a problem when
non-pcrel code calls a pcrel libgcc.  See the patch comments.

A similar situation theoretically occurs with ELFv1 multi-toc
executables, when __morestack might be located in a different toc
group to its caller.  This patch makes no attempt to fix that, since
the gold linker does not support multi-toc (gold is needed for proper
support of -fsplit-stack code) nor does gcc emit __morestack calls
that support multi-toc.

	* config/rs6000/morestack.S (R2_SAVE): Define.
	(__morestack): Save and restore r2.  Set up r2 for called
	functions.
2021-07-15 15:27:09 +09:30
Richard Biener
4f3b383cf8 driver/101383 - handle -gtoggle in driver
The driver amends assembler options with for example --gdwarf-5
when debugging is enabled but the check for that does not consider
the effect of -gtoggle which is not handled in the common option
machinery.  The following alters debug_info_level according to
-gtoggle mimicing what process_options later does in the compiler.

This in particular avoids changing of the cc1-checksum with every
bootstrap (debug) cycle as we compute that from stage2 where we
use -g -gtoggle but with --gdwarf-5 and no debug info from the
compiler the assembler will fill the line table with the temporary
assembler file names.

2021-07-09  Richard Biener  <rguenther@suse.de>

	PR driver/101383
	* gcc.c (process_command): Process -gtoggle like process_options
	would after parsing options.
2021-07-15 07:56:08 +02:00
Trevor Saunders
ef3bb641e9 add myself to DCO section
ChangeLog:

	* MAINTAINERS: Add myself to DCO section.

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
2021-07-15 01:16:51 -04:00
Trevor Saunders
8d76ff9922 pass location to md_asm_adjust
So the hook can use it as the location of diagnostics.

gcc/ChangeLog:

	* cfgexpand.c (expand_asm_loc): Adjust.
	(expand_asm_stmt): Likewise.
	* config/arm/aarch-common-protos.h (arm_md_asm_adjust): Likewise.
	* config/arm/aarch-common.c (arm_md_asm_adjust): Likewise.
	* config/arm/arm.c (thumb1_md_asm_adjust): Likewise.
	* config/avr/avr.c (avr_md_asm_adjust): Likewise.
	* config/cris/cris.c (cris_md_asm_adjust): Likewise.
	* config/i386/i386.c (ix86_md_asm_adjust): Likewise.
	* config/mn10300/mn10300.c (mn10300_md_asm_adjust): Likewise.
	* config/nds32/nds32.c (nds32_md_asm_adjust): Likewise.
	* config/pdp11/pdp11.c (pdp11_md_asm_adjust): Likewise.
	* config/rs6000/rs6000.c (rs6000_md_asm_adjust): Likewise.
	* config/s390/s390.c (s390_md_asm_adjust): Likewise.
	* config/vax/vax.c (vax_md_asm_adjust): Likewise.
	* config/visium/visium.c (visium_md_asm_adjust): Likewise.
	* doc/tm.texi: Regenerate.
	* target.def: Add location argument to md_asm_adjust.

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
2021-07-15 01:10:47 -04:00
Trevor Saunders
329769b720 use diagnostic location in diagnostic_report_current_function
It appears that input_location was used here before the diagnostic's location
was available, and never updated, when the other part of the header was added
that uses it, so this makes it consistent.

gcc/ChangeLog:

	* tree-diagnostic.c (diagnostic_report_current_function): Use the
	diagnostic's location, not input_location.

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
2021-07-15 01:10:34 -04:00
Trevor Saunders
28ca844641 use error_at and warning_at in cfgexpand.c
gcc/ChangeLog:

	* cfgexpand.c (tree_conflicts_with_clobbers_p): Pass location to
	diagnostics.
	(expand_asm_stmt): Likewise.

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
2021-07-15 01:10:19 -04:00
Jason Merrill
0b7a11874d c++: fix tree_contains_struct for C++ types [PR101095]
Many of the types from cp-tree.def were only marked as having tree_common,
when actually most of them have type_non_common.  This broke
g++.dg/modules/xtreme-header-2, as the modules code relies on
tree_contains_struct to know what bits it needs to stream.

We don't seem to use type_non_common for TYPE_ARGUMENT_PACK, so I bumped it
down to TS_TYPE_COMMON.  I tried doing the same in cp_tree_size, but that
breaks without more extensive changes to tree_node_structure.

Why do we need the init_ts function anyway?  It seems redundant with
tree_node_structure.

	PR c++/101095

gcc/cp/ChangeLog:

	* cp-objcp-common.c (cp_common_init_ts): Mark types as types.
	(cp_tree_size): Remove redundant entries.
2021-07-14 23:18:14 -04:00
GCC Administrator
c4fee1c646 Daily bump. 2021-07-15 00:16:54 +00:00
Peter Bergner
69feb7601e rs6000: Generate an lxvp instead of two adjacent lxv instructions
The MMA build built-ins currently use individual lxv instructions to
load up the registers of a __vector_pair or __vector_quad.  If the
memory addresses of the built-in operands are to adjacent locations,
then we can use an lxvp in some cases to load up two registers at once.
The patch below adds support for checking whether memory addresses are
adjacent and emitting an lxvp instead of two lxv instructions.

2021-07-14  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	* config/rs6000/rs6000.c (adjacent_mem_locations): Return the lower
	addressed memory rtx, if any.
	(rs6000_split_multireg_move): Fix code formatting.
	Handle MMA build built-ins with operands in adjacent memory locations.

gcc/testsuite/
	* gcc.target/powerpc/mma-builtin-9.c: New test.
2021-07-14 18:27:02 -05:00
Peter Bergner
7d914777fc rs6000: Move rs6000_split_multireg_move to later in file
An upcoming change to rs6000_split_multireg_move requires it to be
moved later in the file to fix a declaration issue.

2021-07-14  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	* config/rs6000/rs6000.c (rs6000_split_multireg_move): Move to later
	in the file.
2021-07-14 18:23:31 -05:00
Patrick Palka
bebd8e9da8 c++: CTAD and forwarding references [PR88252]
Here during CTAD we're incorrectly treating T&& as a forwarding
reference even though T is a template parameter of the class template.

This happens because the template parameter T in the out-of-line
definition of the constructor doesn't have the flag
TEMPLATE_TYPE_PARM_FOR_CLASS set, and during duplicate_decls the
the redeclaration (which is in terms of this unflagged T) prevails.
To fix this, we could perhaps be more consistent about setting the flag,
but it appears we don't really need this flag to make the determination.

Since the template parameters of an synthesized guide consist of the
template parameters of the class template followed by those of the
constructor (if any), it should suffice to look at the index of the
template parameter to determine whether it comes from the class
template or the constructor (template).  This patch replaces the
TEMPLATE_TYPE_PARM_FOR_CLASS flag with this approach.

	PR c++/88252

gcc/cp/ChangeLog:

	* cp-tree.h (TEMPLATE_TYPE_PARM_FOR_CLASS): Remove.
	* pt.c (push_template_decl): Remove TEMPLATE_TYPE_PARM_FOR_CLASS
	handling.
	(redeclare_class_template): Likewise.
	(forwarding_reference_p): Define.
	(maybe_adjust_types_for_deduction): Use it instead.  Add 'tparms'
	parameter.
	(unify_one_argument): Pass tparms to
	maybe_adjust_types_for_deduction.
	(try_one_overload): Likewise.
	(unify): Likewise.
	(rewrite_template_parm): Remove TEMPLATE_TYPE_PARM_FOR_CLASS
	handling.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/class-deduction96.C: New test.
2021-07-14 15:37:30 -04:00
Jason Merrill
91bb571d20 vec: use auto_vec in a few more places
The uses of vec<T> in get_all_loop_exits and process_conditional were memory
leaks, as .release() was never called for them.  The other changes are some
cases that did have proper release handling, but it's simpler to leave
releasing to the auto_vec destructor.

gcc/ChangeLog:

	* sel-sched-ir.h (get_all_loop_exits): Use auto_vec.

gcc/cp/ChangeLog:

	* class.c (struct find_final_overrider_data): Use auto_vec.
	(find_final_overrider): Remove explicit release.
	* coroutines.cc (process_conditional): Use auto_vec.
	* cp-gimplify.c (struct cp_genericize_data): Use auto_vec.
	(cp_genericize_tree): Remove explicit release.
	* parser.c (cp_parser_objc_at_property_declaration): Use
	auto_delete_vec.
	* semantics.c (omp_reduction_lookup): Use auto_vec.
2021-07-14 15:01:27 -04:00
Jason Merrill
b15e301748 c++: enable -fdelete-dead-exceptions by default
As I was discussing with richi, I don't think it makes sense to protect
calls to pure/const functions from DCE just because they aren't explicitly
declared noexcept.  PR100382 indicates that there are different
considerations for Go, which has non-call exceptions.  But still turn the
flag off for that specific testcase.

gcc/c-family/ChangeLog:

	* c-opts.c (c_common_post_options): Set -fdelete-dead-exceptions.

gcc/ChangeLog:

	* doc/invoke.texi: -fdelete-dead-exceptions is on by default for
	C++.

gcc/testsuite/ChangeLog:

	* g++.dg/torture/pr100382.C: Pass -fno-delete-dead-exceptions.
2021-07-14 14:59:56 -04:00
Tamar Christina
4940166a15 Vect: correct rebase issue
The lines being removed have been updated and merged into a new
condition.  But when resolving some conflicts I accidentally
reintroduced them causing some test failes.

This removes them.

Committed as the changes were previously approved in
https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574977.html
but the hunk was misapplied during a rebase.

gcc/ChangeLog:

	* tree-vect-patterns.c (vect_recog_dot_prod_pattern):
	Remove erroneous line.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/vect-reduc-dot-11.c: Expect pass.
	* gcc.dg/vect/vect-reduc-dot-15.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-19.c: Likewise.
	* gcc.dg/vect/vect-reduc-dot-21.c: Likewise.
2021-07-14 19:00:59 +01:00
Andrew MacLeod
398572c154 Turn hybrid mode off, default to ranger-only mode for EVRP.
Change the default EVRP mode to ranger-only.

	gcc/
	* params.opt (param_evrp_mode): Change default.

	gcc/testsuite/
	* gcc.dg/pr80776-1.c: Remove xfail.
2021-07-14 12:47:10 -04:00
Marek Polacek
a42f812044 c++: constexpr array reference and value-initialization [PR101371]
This PR gave me a hard time: I saw multiple issues starting with
different revisions.  But ultimately the root cause seems to be
the following, and the attached patch fixes all issues I've found
here.

In cxx_eval_array_reference we create a new constexpr context for the
CP_AGGREGATE_TYPE_P case, but we also have to create it for the
non-aggregate case.  In this test, we are evaluating

  ((B *)this)->a = rhs->a

which means that we set ctx.object to ((B *)this)->a.  Then we proceed
to evaluate the initializer, rhs->a.  For *rhs, we eval rhs, a PARM_DECL,
for which we have (const B &) &c.arr[0] in the hash table.  Then
cxx_fold_indirect_ref gives us c.arr[0].  c is evaluated to {.arr={}} so
c.arr is {}.  Now we want c.arr[0], so we end up in cxx_eval_array_reference
and since we're initializing from {}, we call build_value_init which
gives us an AGGR_INIT_EXPR that calls 'constexpr B::B()'.  Then we
evaluate this AGGR_INIT_EXPR and since its first argument is dummy,
we take ctx.object instead.  But that is the wrong object, we're not
initializing ((B *)this)->a here.  And so we wound up with an
initializer for A, and then crash in cxx_eval_component_reference:

  gcc_assert (DECL_CONTEXT (part) == TYPE_MAIN_VARIANT (TREE_TYPE (whole)));

where DECL_CONTEXT (part) is B (as it should be) but the type of whole
was A.

So create a new object, if there already was one, and the element type
is not a scalar.

	PR c++/101371

gcc/cp/ChangeLog:

	* constexpr.c (cxx_eval_array_reference): Create a new .object
	and .ctor for the non-aggregate non-scalar case too when
	value-initializing.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/constexpr-101371-2.C: New test.
	* g++.dg/cpp1y/constexpr-101371.C: New test.
2021-07-14 11:54:07 -04:00
Harald Anlauf
269ca408e2 Fortran - ICE in gfc_conv_expr_present initializing non-dummy class variable
gcc/fortran/ChangeLog:

	PR fortran/100949
	* trans-expr.c (gfc_trans_class_init_assign): Call
	gfc_conv_expr_present only for dummy variables.

gcc/testsuite/ChangeLog:

	PR fortran/100949
	* gfortran.dg/pr100949.f90: New test.
2021-07-14 17:25:29 +02:00
Tamar Christina
6d1cdb2782 AArch64: Correct dot-product auto-vect optab RTL
The current RTL for the vectorizer patterns for dot-product are incorrect.
Operand3 isn't an output parameter so we can't write to it.

This fixes this issue and reduces the number of RTL.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (udot, sdot): Rename to...
	(sdot_prod, udot_prod): ...These.
	* config/aarch64/aarch64-simd.md (<sur>dot_prod<vsi2qi>): Remove.
	(aarch64_<sur>dot<vsi2qi>): Rename to...
	(<sur>dot_prod<vsi2qi>): ...This.
	* config/aarch64/arm_neon.h (vdot_u32, vdotq_u32, vdot_s32, vdotq_s32):
	Update builtins.
2021-07-14 15:41:31 +01:00
Tamar Christina
c9165e2d58 AArch32: Correct sdot RTL on aarch32
The RTL Generated from <sup>dot_prod<vsi2qi> is invalid as operand3 cannot be
written to, it's a normal input.  For the expand it's just another operand
but the caller does not expect it to be written to.

gcc/ChangeLog:

	* config/arm/neon.md (<sup>dot_prod<vsi2qi>): Drop statements.
2021-07-14 15:22:37 +01:00