Commit Graph

194050 Commits

Author SHA1 Message Date
GCC Administrator df724ec773 Daily bump. 2022-06-24 00:16:41 +00:00
Jason Merrill 6c72f1bfc3 c++: designated init cleanup [PR105925]
build_aggr_conv expects to run after reshape_init, which will usually have
filled out all the CONSTRUCTOR indexes; there's no reason to limit using
those to the case where the user gave an explicit designator.

	PR c++/105925

gcc/cp/ChangeLog:

	* call.cc (build_aggr_conv): Don't depend on
	CONSTRUCTOR_IS_DESIGNATED_INIT.
2022-06-23 17:16:42 -04:00
Jason Merrill d610ae121e c++: anon union designated init [PR105925]
This testcase was failing because CONSTRUCTOR_IS_DESIGNATED_INIT wasn't
getting set on the introduced CONSTRUCTOR for the anonymous union, and
build_aggr_conv uses that flag to decide whether to pay attention to the
indexes of the CONSTRUCTOR.  So set the flag when we see a designator rather
than relying on copying it from another CONSTRUCTOR.

This avoids some redundant errors on desig4.C because we stop setting
CONSTRUCTOR_IS_DESIGNATED_INIT on _Complex CONSTRUCTORs where it's
nonsense.

	PR c++/105925

gcc/cp/ChangeLog:

	* decl.cc (reshape_init_array_1): Set
	CONSTRUCTOR_IS_DESIGNATED_INIT here.
	(reshape_init_class): And here.
	(reshape_init): Not here.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/desig4.C: Remove extra errors.
	* g++.dg/cpp2a/desig26.C: New test.
2022-06-23 17:16:17 -04:00
Patrick Palka b00b95198e c++: constexpr folding in unevaluated context [PR105931]
Changing the type of N from int to unsigned in decltype82.C (from
r13-986-g0ecb6b906f215e) reveals another spot where we perform constexpr
evaluation in an unevaluated context for sake of warnings, this time
from the call to shorten_compare in cp_build_binary_op, which calls
fold_for_warn.

We could (and probably should) suppress the shorten_compare warnings
when in an unevaluated context, but there's probably other callers of
fold_for_warn that are similarly affected.  So this patch takes the
approach of directly suppressing fold_for_warn when in an unevaluated
context.

	PR c++/105931

gcc/cp/ChangeLog:

	* expr.cc (fold_for_warn): Don't fold when in an unevaluated
	context.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/decltype82a.C: New test.
2022-06-23 16:36:43 -04:00
Patrick Palka 01aff2ba18 c++: context completion in lookup_template_class [PR105982]
The below testcase demonstrates that completion of the substituted
context during lookup_template_class can end up registering the desired
specialization for us in more cases than r13-1045-gcb7fd1ea85feea
anticipated.  In particular this can happen for a non-dependent
specialization of a nested class as well.

For this testcase, during overload resolution with A's guides, we
substitute the deduced argument T=int into the TYPENAME_TYPE B::C,
during which we call lookup_template_class for A<T>::B with T=int,
which completes A<int> for the first time, which recursively registers
the desired specialization of B already.  The parent call to
lookup_template_class then tries to register the same specialization,
triggering an ICE.

This patch fixes this by making lookup_template_class determine more
directly whether we need to recheck the specializations table after
completion of the context -- when and only when the call to complete_type
had an effect.

	PR c++/105982

gcc/cp/ChangeLog:

	* pt.cc (lookup_template_class): After calling complete_type for
	the substituted context, check the table again iff the type was
	previously incomplete and complete_type made it complete.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/class-deduction111.C: New test.
2022-06-23 16:18:55 -04:00
zhangjian 5ee8e1d1b0 compiler: in Sort_bindings return false if comparing value to itself
Some versions of std::sort may pass elements at the same iterator location.

Fixes golang/go#53483

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413434
2022-06-23 12:44:43 -07:00
Ian Lance Taylor 038a7150ec compiler: unalias types for hash/equality functions
Test case is https://go.dev/cl/413694.

Fixes golang/go#52846

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413660
2022-06-23 12:22:05 -07:00
David Malcolm 0b14f590e3 diagnostics: add ability to associate diagnostics with rules from coding standards
gcc/ChangeLog:
	* common.opt (fdiagnostics-show-rules): New option.
	* diagnostic-format-json.cc (diagnostic_output_format_init_json):
	Fix up context->show_rules.
	* diagnostic-format-sarif.cc
	(diagnostic_output_format_init_sarif): Likewise.
	* diagnostic-metadata.h (diagnostic_metadata::rule): New class.
	(diagnostic_metadata::precanned_rule): New class.
	(diagnostic_metadata::add_rule): New.
	(diagnostic_metadata::get_num_rules): New.
	(diagnostic_metadata::get_rule): New.
	(diagnostic_metadata::m_rules): New field.
	* diagnostic.cc (diagnostic_initialize): Initialize show_rules.
	(print_any_rules): New.
	(diagnostic_report_diagnostic): Call it.
	* diagnostic.h (diagnostic_context::show_rules): New field.
	* doc/invoke.texi (-fno-diagnostics-show-rules): New option.
	* opts.cc (common_handle_option): Handle
	OPT_fdiagnostics_show_rules.
	* toplev.cc (general_init): Set up global_dc->show_rules.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/diagnostic-test-metadata.c: Expect " [STR34-C]" to
	be emitted at the "gets" call.
	* gcc.dg/plugin/diagnostic_plugin_test_metadata.c
	(pass_test_metadata::execute): Associate the "gets" diagnostic
	with a rule named "STR34-C".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-06-23 14:59:24 -04:00
Jonathan Wakely 7c1c7e120c libstdc++: Properly remove temporary directories in filesystem tests
Although these tests use filesystem::remove_all to clean up, that fails
because it uses recursive_directory_iterator which is intentionally
bodged by the custom readdir defined in the test.

Just use POSIX rmdir to clean up. We don't need to use _rmdir or _wrmdir
for Windows, because we'll never reach test02() on targets where the
custom readdir doesn't interpose the one from libc.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/iterators/error_reporting.cc: Use
	rmdir to remove directories.
	* testsuite/experimental/filesystem/iterators/error_reporting.cc:
	Likewise.
2022-06-23 17:19:38 +01:00
Jason Merrill 124a9e08b7 c++: -Waddress and if constexpr [PR94554]
Like we avoid various warnings for seemingly tautological expressions when
substituting a template, we should avoid warning for the implicit conversion
to bool in an if statement.  I considered also doing this for the conditions
in loop expressions, but that seems unnecessary, as a loop condition is
unlikely to be a constant.

The change to finish_if_stmt_cond isn't necessary since dependent_operand_p
looks through IMPLICIT_CONV_EXPR, but makes it more constent with
e.g. build_x_binary_op that determines the type of an expression and then
builds it using the original operands.

	PR c++/94554

gcc/cp/ChangeLog:

	* pt.cc (dependent_operand_p): Split out from...
	(tsubst_copy_and_build): ...here.
	(tsubst_expr) [IF_STMT]: Use it.
	* semantics.cc (finish_if_stmt_cond): Keep the pre-conversion
	condition in the template tree.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/constexpr-if38.C: New test.
2022-06-23 11:07:21 -04:00
Jason Merrill 6e4d5300c1 c++: -Waddress and value-dependent expr [PR105885]
We already suppress various warnings for code that would be tautological if
written directly, but not when it's the result of template substitution.  It
seems we need to do this for -Waddress as well.

	PR c++/105885

gcc/cp/ChangeLog:

	* pt.cc (tsubst_copy_and_build): Also suppress -Waddress for
	comparison of dependent operands.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/constexpr-if37.C: New test.
2022-06-23 11:06:25 -04:00
Martin Liska 8a15cd3396 c++: properly initialize UBSAN built-ins
PR c++/106062

gcc/ChangeLog:

	* ubsan.cc (sanitize_unreachable_fn): Change order of calls
	in order to initialize UBSAN built-ins.

gcc/testsuite/ChangeLog:

	* gfortran.dg/ubsan/pr106062.f90: New test.
2022-06-23 15:28:27 +02:00
Nathan Sidwell c01fe6729e c++: Prune unneeded macro locations
This implements garbage collection on locations within macro
expansions, when streaming out a CMI.  When doing the reachability
walks, we now note which macro locations we need and then only write
those locations.  The complication here is that every macro expansion
location has an independently calculated offset.  This complicates
writing, but reading remains the same -- the macro locations of a CMI
continue to form a contiguous block.

For std headers this reduced the number of macro maps by 40% and the
number of locations by 16%.  For a GMF including iostream, it reduced
it by 80% and 60% respectively.

Ordinary locations are still transformed en-mass.  They are somewhat
more complicated to apply a similar optimization to.

	gcc/cp/
	* module.cc (struct macro_info): New.
	(struct macro_traits): New.
	(macro_remap, macro_table): New globals.
	(depset:#️⃣:find_dependencies): Note namespace location.
	(module_for_macro_loc): Adjust.
	(module_state::note_location): New.
	(module_state::Write_location): Note location when not
	streaming. Adjust macro location streaming.
	(module_state::read_location): Adjust macro location
	streaming.
	(module_state::write_init_maps): New.
	(module_state::write_prepare_maps): Reimplement macro map
	preparation.
	(module_state::write_macro_maps): Reimplement.
	(module_state::read_macro_maps): Likewise.
	(module_state::write_begin): Adjust.
	gcc/testsuite/
	* g++.dg/modules/loc-prune-1.C: New.
	* g++.dg/modules/loc-prune-2.C: New.
	* g++.dg/modules/loc-prune-3.C: New.
	* g++.dg/modules/pr98718_a.C: Adjust.
	* g++.dg/modules/pr98718_b.C: Adjust.
2022-06-23 05:16:24 -07:00
Richard Sandiford 509cdb4416 testsuite: Compile slsr-39.c without vectorisation
The fix for PR106019 regressed slsr-39.c for -m32 -march=cascadelake
because we are now able to vectorise the code.  (Whether the code model
should be allowing that is a different question -- the vectorised code
looked worse to me.)

The test runs at -O2 and predates vectorisation being enabled at -O2,
so this patch just adds -fno-tree-vectorize.

gcc/testsuite/
	* gcc.dg/tree-ssa/slsr-39.c: Force vectorization off.
2022-06-23 12:54:10 +01:00
Jonathan Wakely 78fd15fd4a libstdc++: Simplify test by not using std::log2
This test uses std::log2 without including <cmath>, but it doesn't need
to use it at all. Just get the number of digits from numeric_limits
instead.

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/random/random_device/entropy.cc: Use
	numeric_limits<unsigned>::digits.
2022-06-23 12:00:01 +01:00
Martin Liska 31ce821a79 ipa-icf: skip variables with body_removed
Similarly to cgraph_nodes, it may happen that body_removed is set
during merging of symbols.

	PR ipa/105600

gcc/ChangeLog:

	* ipa-icf.cc (sem_item_optimizer::filter_removed_items):
	Skip variables with body_removed.
2022-06-23 06:07:22 +02:00
liuhongt 7f52df186d Replace REGNO with reg_or_subregno in pre_reload splitter.
gcc/ChangeLog:

	* config/i386/sse.md:(sse4_2_pcmpestr): Replace REGNO with
	reg_or_subregno.
	(sse4_2_pcmpistr): Ditto.
2022-06-23 11:34:37 +08:00
Jason Merrill 27e9bd9116 c++: tweak deduction with auto template parms
While looking at PR105964 I noticed that we were unnecessarily repeating
the deduction loop because of seeing a non-type parameter with type 'auto'.
It is indeed dependent, but not on any other deductions.

gcc/cp/ChangeLog:

	* pt.cc (type_unification_real): An auto tparm can't
	be affected by other deductions.
2022-06-22 23:23:01 -04:00
Jason Merrill d29f61a329 c++: dependence of baselink [PR105964]
helper<token>::c isn't dependent just because we haven't deduced its return
type yet.  type_dependent_expression_p already knows how to deal with that
for bare FUNCTION_DECL, but needs to learn to look through a BASELINK.

	PR c++/105964

gcc/cp/ChangeLog:

	* pt.cc (type_dependent_expression_p): Look through BASELINK.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/nontype-auto21.C: New test.
2022-06-22 23:23:01 -04:00
Xionghu Luo 3104a9fa7e Fix typo
Fix typo and commit as obvious.

Signed-off-by: Xionghu Luo <xionghuluo@tencent.com>

gcc/ChangeLog:

	* cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee): Fix
	typo.
	* tree-ssa-loop-ivopts.cc (struct iv_cand): Likewise.
	* tree-switch-conversion.h: Likewise.
2022-06-23 11:00:02 +08:00
GCC Administrator 5d0cf15822 Daily bump. 2022-06-23 00:16:40 +00:00
Jason Merrill 349a39f061 c++: class scope function lookup [PR105908]
In r12-1273 for PR91706, I removed the code in get_class_binding that
stripped BASELINK.  This testcase demonstrates that we still need to strip
it in outer_binding before putting the overload set in IDENTIFIER_BINDING,
for compatibility with bindings added directly for declarations.

	PR c++/105908

gcc/cp/ChangeLog:

	* name-lookup.cc (outer_binding): Strip BASELINK.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/trailing16.C: New test.
2022-06-22 18:01:27 -04:00
Iain Buclaw 445d8deffb d: Merge upstream dmd 6203135dc, druntime e150cca1, phobos a4a18d21c.
D front-end changes:

    - Input parameters can now be applied on extern(C++) functions to
      bind to `const &' when the `-fpreview=in' flag is in effect.

D runtime changes:

    - Run-time flag `--DRT-oncycle=deprecate' has been removed.

Phobos changes:

    - Removed std.experimental.logger's capability to set the minimal
      LogLevel at compile time.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 6203135dc.
	* typeinfo.cc (TypeInfoVisitor::visit (TypeInfoStructDeclaration *)):
	Update for new front-end interface.
	(SpeculativeTypeVisitor::visit (TypeStruct *)): Likewise.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime e150cca1.
	* src/MERGE: Merge upstream phobos a4a18d21c.
	* testsuite/libphobos.cycles/cycles.exp (cycle_test_list): Update
	expected result of deprecate test.
2022-06-22 17:57:56 +02:00
Nathan Sidwell d844478ab4 c++: Remove ifdefed code
The only reason I chose to use DECL_UID on this hash table was to make
it stable against ASLR and perturbations due to other allocations.
It's not required for correctness, as the comment mentions the
equality fn uses pointer identity.

	gcc/cp/
	* module.cc (struct duplicate_hash): Remove.
	(duplicate_hash_map): Adjust.
2022-06-22 08:21:03 -07:00
Jason Merrill d68d366425 ubsan: default to trap on unreachable at -O0 and -Og [PR104642]
When not optimizing, we can't do anything useful with unreachability in
terms of code performance, so we might as well improve debugging by turning
__builtin_unreachable into a trap.  I think it also makes sense to do this
when we're explicitly optimizing for the debugging experience.

In the PR richi suggested introducing an -funreachable-traps flag for this.
This functionality is already implemented as -fsanitize=unreachable
-fsanitize-trap=unreachable, and we want to share the implementation, but it
does seem useful to have a separate flag that isn't affected by the various
sanitization controls.  -fsanitize=unreachable takes priority over
-funreachable-traps if both are enabled.

Jakub observed that this would slow down -O0 by default from running the
sanopt pass, so this revision avoids the need for sanopt by rewriting calls
introduced by the compiler immediately, and calls written by the user at
fold time.  Many of the calls introduced by the compiler are also rewritten
immediately to ubsan calls when not trapping, which fixes ubsan-8b.C;
previously the call to f() was optimized away before sanopt.  But this early
rewriting isn't practical for uses of __builtin_unreachable in
devirtualization and such, so sanopt rewriting is still done for
non-trapping sanitize.

	PR c++/104642

gcc/ChangeLog:

	* common.opt: Add -funreachable-traps.
	* doc/invoke.texi (-funreachable-traps): Document it.
	* opts.cc (finish_options): Enable at -O0 or -Og.
	* tree.cc (build_common_builtin_nodes): Add __builtin_trap.
	(builtin_decl_unreachable, build_builtin_unreachable): New.
	* tree.h: Declare them.
	* ubsan.cc (sanitize_unreachable_fn): Factor out.
	(ubsan_instrument_unreachable): Use
	gimple_build_builtin_unreachable.
	* ubsan.h (sanitize_unreachable_fn): Declare.
	* gimple.cc (gimple_build_builtin_unreachable): New.
	* gimple.h: Declare it.
	* builtins.cc (expand_builtin_unreachable): Add assert.
	(fold_builtin_0): Call build_builtin_unreachable.
	* sanopt.cc: Don't run for just SANITIZE_RETURN
	or SANITIZE_UNREACHABLE when trapping.
	* cgraphunit.cc (walk_polymorphic_call_targets): Use new
	unreachable functions.
	* gimple-fold.cc (gimple_fold_call)
	(gimple_get_virt_method_for_vtable)
	* ipa-fnsummary.cc (redirect_to_unreachable)
	* ipa-prop.cc (ipa_make_edge_direct_to_target)
	(ipa_impossible_devirt_target)
	* ipa.cc (walk_polymorphic_call_targets)
	* tree-cfg.cc (pass_warn_function_return::execute)
	(execute_fixup_cfg)
	* tree-ssa-loop-ivcanon.cc (remove_exits_and_undefined_stmts)
	(unloop_loops)
	* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_stmt):
	Likewise.

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_builtin_function_call): Handle
	unreachable/trap earlier.
	* cp-gimplify.cc (cp_maybe_instrument_return): Use
	build_builtin_unreachable.

gcc/testsuite/ChangeLog:

	* g++.dg/ubsan/return-8a.C: New test.
	* g++.dg/ubsan/return-8b.C: New test.
	* g++.dg/ubsan/return-8d.C: New test.
	* g++.dg/ubsan/return-8e.C: New test.
2022-06-22 09:01:29 -04:00
Richard Sandiford 038b077689 data-ref: Improve non-loop disambiguation [PR106019]
When dr_may_alias_p is called without a loop context, it tries
to use the tree-affine interface to calculate the difference
between the two addresses and use that difference to check whether
the gap between the accesses is known at compile time.  However, as the
example in the PR shows, this doesn't expand SSA_NAMEs and so can easily
be defeated by things like reassociation.

One fix would have been to use aff_combination_expand to expand the
SSA_NAMEs, but we'd then need some way of maintaining the associated
cache.  This patch instead reuses the innermost_loop_behavior fields
(which exist even when no loop context is provided).

It might still be useful to do the aff_combination_expand thing too,
if an example turns out to need it.

gcc/
	PR tree-optimization/106019
	* tree-data-ref.cc (dr_may_alias_p): Try using the
	innermost_loop_behavior to disambiguate non-loop queries.

gcc/testsuite/
	PR tree-optimization/106019
	* gcc.dg/vect/bb-slp-pr106019.c: New test.
2022-06-22 11:27:15 +01:00
Palmer Dabbelt 98b6e62cf5
RISC-V: Add -mtune=thead-c906 to the invoke docs
gcc/ChangeLog

	* doc/invoke.texi (RISC-V): Document -mtune=thead-c906.
2022-06-21 19:29:27 -07:00
Alexandre Oliva a33dda016e libstdc++: eh_globals: gthreads: reset _S_init before deleting key
Clear __eh_globals_init's _S_init in the dtor before deleting the
gthread key.

This ensures that, in case any code involved in deleting the key
interacts with eh_globals, the key that is being deleted won't be
used, and the non-thread-specific eh_globals fallback will.


for  libstdc++-v3/ChangeLog

	* libsupc++/eh_globals.cc [!_GLIBCXX_HAVE_TLS]
	(__eh_globals_init::~__eh_globals_init): Clear _S_init first.
2022-06-21 23:11:02 -03:00
Alexandre Oliva f129628e8f libstdc++: testsuite: call sched_yield for nonpreemptive targets
As in the gcc testsuite, systems without preemptive multi-threading
require sched_yield calls to be placed at points in which a context
switch might be needed to enable the test to complete.


for  libstdc++-v3/ChangeLog

	* testsuite/30_threads/this_thread/60421.cc (test02): Call
	sched_yield.
2022-06-21 23:11:01 -03:00
Alexandre Oliva 540ae3601e libstdc++: testsuite: require cmath for nexttowardl
nexttowardl is only expected to be available with C99 math, but
20_util/to_chars/long_double.cc uses it unconditionally.

State the cmath requirement in the test.


for  libstdc++-v3/ChangeLog

	* testsuite/20_util/to_chars/long_double.cc: Require cmath.
2022-06-21 23:11:00 -03:00
Alexandre Oliva 345d69a7de libstdc++: testsuite: work around bitset namespace pollution
rtems6 declares a global struct bitset in a header file included
indirectly by sys/types.h, that ambiguates the unqualified references
to bitset after "using namespace std" in the testsuite.

Work around the namespace pollution with using declarations of
std::bitset.


for  libstdc++-v3/ChangeLog

	* testsuite/23_containers/bitset/cons/dr1325-2.cc: Work around
	global struct bitset.
	* testsuite/23_containers/bitset/ext/15361.cc: Likewise.
	* testsuite/23_containers/bitset/input/1.cc: Likewise.
	* testsuite/23_containers/bitset/to_string/1.cc: Likewise.
	* testsuite/23_containers/bitset/to_string/dr396.cc: Likewise.
2022-06-21 23:11:00 -03:00
Alexandre Oliva 7a1790ac6b testsuite: outputs.exp: cleanup before running tests
Use the just-added dry-run infrastructure to clean up files that may
have been left over by interrupted runs of outputs.exp, which used to
lead to spurious non-repeatable (self-fixing) failures.


for  gcc/testsuite/ChangeLog

	* gcc.misc-tests/outputs.exp: Clean up left-overs first.
2022-06-21 23:10:59 -03:00
Alexandre Oliva 870f6866c9 testsuite: outputs.exp: test for skip_atsave more thoroughly
The presence of -I or -L flags in link command lines changes the
driver's, and thus the linker's behavior, WRT naming files with
command-line options.  With such flags, the driver creates .args.0 and
.args.1 files, whereas without them it's the linker (collect2, really)
that creates .ld1_args.

I've hit some fails on a target system that doesn't have -I or -L
flags in the board config file, but it does add some of them
implicitly with configured-in driver self specs.  Alas, the test in
outputs.exp doesn't catch that, so we proceed to run rather than
skip_atsave tests.

I've reworked the outest procedure to allow dry runs and to return
would-have-been pass/fail results as lists, so we can now test whether
certain files are created and use that to configure the actual test
runs.


for  gcc/testsuite/ChangeLog

	* gcc.misc-tests/outputs.exp (outest): Introduce quiet mode,
	create and return lists of passes and fails.  Use it to catch
	skip_atsave cases where -L flags are implicitly added by
	driver self specs.
2022-06-21 23:10:58 -03:00
Alexandre Oliva 614db2317e c++: testsuite: require lto_incremental in pr90990_0.C
Other LTO tests that use -r require the lto_incremental effective
target.  I suppose pr90990_0.C is missing it due to an oversight.
This patch arranges for this test to also be skipped on
non-lto_incremental targets.


for  gcc/testsuite/ChangeLog

	* g++.dg/lto/pr90990_0.C: Require lto_incremental target.
2022-06-21 23:10:58 -03:00
Haochen Jiang 5e377d21f1 i386: Add syscall to enable AMX for latest kernels
gcc/testsuite/ChangeLog:

	* gcc.target/i386/amx-check.h (request_perm_xtile_data):
	New function to check if AMX is usable and enable AMX.
	(main): Run test if AMX is usable.
2022-06-22 09:31:26 +08:00
Takayuki 'January June' Suwa ec532b47f1 xtensa: Fix buffer overflow
Fortify buffer overflow message reported.
(see https://github.com/earlephilhower/esp-quick-toolchain/issues/36)

gcc/ChangeLog:

	* config/xtensa/xtensa.md (bswapsi2_internal):
	Enlarge the buffer that is obviously smaller than the template
	string given to sprintf().
2022-06-21 17:52:24 -07:00
GCC Administrator de89b078e3 Daily bump. 2022-06-22 00:16:25 +00:00
Roger Sayle 4306339798 PR target/105991: Recognize PLUS and XOR forms of rldimi in rs6000.md.
This patch addresses PR target/105991 where a change to prefer representing
shifts and adds at the tree-level as multiplications, causes problems for
the rldimi patterns in the powerpc backend.  The issue is that rs6000.md
models this pattern using IOR, and some variants that have the equivalent
PLUS or XOR in the RTL fail to match some *rotl<mode>4_insert patterns.
This is fixed in this patch by adding a define_insn_and_split to locally
canonicalize the PLUS and XOR forms to the backend's preferred IOR form.

An alternative fix might be for the RTL optimizers to define a canonical
form for these plus_xor_ior equivalent expressions, but the logical
choice might be plus (which may appear in an addressing mode), and such
a change may require a number of tweaks to update various backends
(i.e.  a more intrusive change than the one proposed here).

Many thanks for Marek Polacek for bootstrapping and regression testing
this change without problems.

2022-06-22  Roger Sayle  <roger@nextmovesoftware.com>
	    Marek Polacek  <polacek@redhat.com>
	    Segher Boessenkool  <segher@kernel.crashing.org>
	    Kewen Lin  <linkw@linux.ibm.com>

gcc/ChangeLog
	PR target/105991
	* config/rs6000/rs6000.md (rotl<mode>3_insert_3): Check that
	exact_log2 doesn't return -1 (or zero).
	(plus_xor): New code iterator.
	(*rotl<mode>3_insert_3_<code>): New define_insn_and_split.

gcc/testsuite/ChangeLog
	PR target/105991
	* gcc.target/powerpc/pr105991.c: New test case.
2022-06-22 00:08:56 +01:00
Jakub Jelinek 85d613da34 libgomp: Fix up target-31.c test [PR106045]
The i variable is used inside of the parallel in:
      #pragma omp simd safelen(32) private (v)
      for (i = 0; i < 64; i++)
        {
          v = 3 * i;
          ll[i] = u1 + v * u2[0] + u2[1] + x + y[0] + y[1] + v + h[0] + u3[i];
        }
where i is predetermined linear (so while inside of the body
it is safe, private per SIMD lane var) the final value is written to
the shared variable, and in:
      for (i = 0; i < 64; i++)
        if (ll[i] != u1 + 3 * i * u2[0] + u2[1] + x + y[0] + y[1] + 3 * i + 13 + 14 + i)
          #pragma omp atomic write
            err = 1;
which is a normal loop and so it isn't in any way privatized there.
So we have a data race, fixed by adding private (i) clause to the
parallel.

2022-06-21  Jakub Jelinek  <jakub@redhat.com>
	    Paul Iannetta  <piannetta@kalrayinc.com>

	PR libgomp/106045
	* testsuite/libgomp.c/target-31.c: Add private (i) clause.
2022-06-21 17:51:08 +02:00
Ian Lance Taylor 7905a9ac26 libgo: #include <sys/types.h> when checking for loff_t
PR go/106033

Fixes golang/go#53469

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413214
2022-06-21 08:03:17 -07:00
Nathan Sidwell f1fcd6e3ad doc: Document module language-linkage supported
I missed we documented this as unimplemented, when I implemented it.

	gcc/
	* doc/invoke.texi (C++ Modules): Remove language-linkage
	as missing feature.
2022-06-21 06:25:03 -07:00
Arjun Shankar ab981aab92 match.pd: Remove "+ 0x80000000" in int comparisons [PR94899]
Expressions of the form "X + CST < Y + CST" where:

* CST is an unsigned integer constant with only the MSB set, and
* X and Y's types have integer conversion ranks <= CST's

can be simplified to "(signed) X < (signed) Y".

This is because, assuming a 32-bit signed numbers,
(unsigned) INT_MIN + 0x80000000 is 0, and
(unsigned) INT_MAX + 0x80000000 is UINT_MAX.

i.e. the result increases monotonically with signed input.

This means:
((signed) X < (signed) Y) iff (X + 0x80000000 < Y + 0x80000000)

gcc/
	PR tree-optimization/94899
	* match.pd (X + C < Y + C -> (signed) X < (signed) Y, if C is
	0x80000000): New simplification.
gcc/testsuite/
	* gcc.dg/pr94899.c: New test.
2022-06-21 12:13:52 +02:00
Jakub Jelinek a0c30fe3b8 ifcvt: Don't introduce trapping or faulting reads in noce_try_sign_mask [PR106032]
noce_try_sign_mask as documented will optimize
  if (c < 0)
    x = t;
  else
    x = 0;
into x = (c >> bitsm1) & t;
The optimization is done if either t is unconditional
(e.g. for
  x = t;
  if (c >= 0)
    x = 0;
) or if it is cheap.  We already check that t doesn't have side-effects,
but if t is conditional, we need to punt also if it may trap or fault,
as we make it unconditional.

I've briefly skimmed other noce_try* optimizations and didn't find one that
would suffer from the same problem.

2022-06-21  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/106032
	* ifcvt.cc (noce_try_sign_mask): Punt if !t_unconditional, and
	t may_trap_or_fault_p, even if it is cheap.

	* gcc.c-torture/execute/pr106032.c: New test.
2022-06-21 11:40:16 +02:00
Jakub Jelinek 2df1df945f expand: Fix up expand_cond_expr_using_cmove [PR106030]
If expand_cond_expr_using_cmove can't find a cmove optab for a particular
mode, it tries to promote the mode and perform the cmove in the promoted
mode.

The testcase in the patch ICEs on arm because in that case we pass temp which
has the promoted mode (SImode) as target to expand_operands where the
operands have the non-promoted mode (QImode).
Later on the function uses paradoxical subregs:
  if (GET_MODE (op1) != mode)
    op1 = gen_lowpart (mode, op1);

  if (GET_MODE (op2) != mode)
    op2 = gen_lowpart (mode, op2);
to change the operand modes.

The following patch fixes it by passing NULL_RTX as target if it has
promoted mode.

2022-06-21  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/106030
	* expr.cc (expand_cond_expr_using_cmove): Pass NULL_RTX instead of
	temp to expand_operands if mode has been promoted.

	* gcc.c-torture/compile/pr106030.c: New test.
2022-06-21 11:38:59 +02:00
Xionghu Luo 57424087e8 if-to-switch: Don't skip the first condition bb when find_conditions in if-to-switch [PR105740]
The if condition is at last of first bb, so side effect statement in first BB
doesn't matter, then the first if condition could also be folded to switch
table.

gcc/ChangeLog:

	PR target/105740
	* gimple-if-to-switch.cc (find_conditions): Don't skip the first
	condition bb.

gcc/testsuite/ChangeLog:

	PR target/105740
	* gcc.dg/tree-ssa/if-to-switch-11.c: New test.

Signed-off-by: Xionghu Luo <xionghuluo@tencent.com>
2022-06-21 17:26:45 +08:00
Siddhesh Poyarekar 70454c50b4 tree-object-size: Don't let error_mark_node escape for ADDR_EXPR [PR105736]
The addr_expr computation does not check for error_mark_node before
returning the size expression.  This used to work in the constant case
because the conversion to uhwi would end up causing it to return
size_unknown, but that won't work for the dynamic case.

Modify the control flow to explicitly return size_unknown if the offset
computation returns an error_mark_node.

gcc/ChangeLog:

	PR tree-optimization/105736
	* tree-object-size.cc (addr_object_size): Return size_unknown
	when object offset computation returns an error.

gcc/testsuite/ChangeLog:

	PR tree-optimization/105736
	* gcc.dg/builtin-dynamic-object-size-0.c (TV4): New struct.
	(val3): New variable.
	(test_pr105736): New test.
	(main): Call it.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2022-06-21 12:15:07 +05:30
GCC Administrator d6ba321135 Daily bump. 2022-06-21 00:16:27 +00:00
Iain Sandoe 607118dfa4 testsuite, asan: Avoid color in asan test output.
The presence of the color markers in the some of the asan tests
appears to confuse the dg-output matching (possibly a platform
TCL or termios bug) on some Darwin platforms.

Since the color is not being tested, switch it off (makes the log
files easier to read too).  This fixes a large number of spurious
test fails on AVX512 Darwin19.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/testsuite/ChangeLog:

	* lib/asan-dg.exp: Do not apply color to asan output when
	under test.
2022-06-20 16:33:10 +01:00
H.J. Lu fe9765c0b9 i386: Disallow sibcall for calling ifunc functions with PIC register
Disallow siball when calling ifunc functions with PIC register so that
PIC register can be restored.

gcc/

	PR target/105960
	* config/i386/i386.cc (ix86_function_ok_for_sibcall): Return
	false if PIC register is used when calling ifunc functions.

gcc/testsuite/

	PR target/105960
	* gcc.target/i386/pr105960.c: New test.
2022-06-20 08:26:47 -07:00
Iain Sandoe 1b23812484 testsuite, Darwin: Skip an unsupported test.
Darwin does not support patchable function entries, skip the test
there.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/pr105169_a.C: Skip the test on Darwin.
	* g++.dg/modules/pr105169_b.C: Likewise.
2022-06-20 16:23:49 +01:00