platform/upstream/gcc.git
19 months agolibiberty: Remove a reference to the Glibc manual
Gerald Pfeifer [Thu, 30 Mar 2023 21:41:24 +0000 (23:41 +0200)]
libiberty: Remove a reference to the Glibc manual

longjmp is not specific to Glibc, and GCC supports lots of systems
that do not use Glibc. Plus this link has been broken in the web
version for ages without a good way to fix.

libiberty/ChangeLog:

* obstacks.texi (Preparing for Obstacks): Remove a (broken)
reference to the Glibc manual.

19 months agoc++: Fix up ICE in build_min_non_dep_op_overload [PR109319]
Jakub Jelinek [Thu, 30 Mar 2023 21:08:25 +0000 (23:08 +0200)]
c++: Fix up ICE in build_min_non_dep_op_overload [PR109319]

The following testcase ICEs, because grok_array_decl during
processing_template_decl handling of a non-dependent subscript
emits a -Wcomma-subscript pedwarn, we decide to pass to the
single index argument the index expressions as if it was wrapped
with () around it, but then when preparing it for later instantiation
we don't actually take that into account and ICE on a mismatch of
number of index arguments (the overload expects a single index,
testcase has two index expressions in this case).
For non-dependent subscript which are builtin subscripts we also
emit the same pedwarn and don't ICE, but emit the same pedwarn
again whenever we instantiate it, which is also IMHO undesirable,
it is enough to warn once during parsing the template.

The following patch fixes it by turning even the original index expressions
(those which didn't go through make_args_non_dependent) into a single
index using comma expression(s).

2023-03-30  Jakub Jelinek  <jakub@redhat.com>

PR c++/109319
* decl2.cc (grok_array_decl): After emitting a pedwarn for
-Wcomma-subscript, if processing_template_decl set orig_index_exp
to compound expr from orig_index_exp_list.

* g++.dg/cpp23/subscript14.C: New test.

19 months agoAdd recursive GORI recompuations with a depth limit.
Andrew MacLeod [Tue, 28 Mar 2023 16:16:34 +0000 (12:16 -0400)]
Add recursive GORI recompuations with a depth limit.

PR tree-optimization/109154
gcc/
* gimple-range-gori.cc (gori_compute::may_recompute_p): Add depth limit.
* gimple-range-gori.h (may_recompute_p): Add depth param.
* params.opt (ranger-recompute-depth): New param.

gcc/testsuite/
* gcc.dg/Walloca-13.c: Remove bogus warning that is now fixed.

19 months agoc++: lambda mangling alias issues [PR107897]
Jason Merrill [Mon, 6 Mar 2023 20:33:45 +0000 (15:33 -0500)]
c++: lambda mangling alias issues [PR107897]

In 107897, by the time we are looking at the mangling clash, the
alias has already been removed from the symbol table by analyze_functions,
so we can't look at n->cpp_implicit_alias.  So just assume that it's an
alias if it's internal.

In 108887 the problem is that removing the mangling alias from the symbol
table confuses analyze_functions, because it ended up as first_analyzed
somehow, so it becomes a dangling pointer.  So instead we call reset()
to neutralize the alias.  To make this work for variables, I needed to move
reset() from cgraph_node to symtab_node.

PR c++/107897
PR c++/108887

gcc/ChangeLog:

* cgraph.h: Move reset() from cgraph_node to symtab_node.
* cgraphunit.cc (symtab_node::reset): Adjust.  Also call
remove_from_same_comdat_group.

gcc/cp/ChangeLog:

* decl2.cc (record_mangling): Use symtab_node::reset.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-lambda3.C: Use -flto if supported.
* g++.dg/cpp0x/lambda/lambda-mangle7.C: New test.

19 months agotree-optimization/107561 - reduce -Wstringop-overflow false positives
Richard Biener [Wed, 29 Mar 2023 11:49:24 +0000 (13:49 +0200)]
tree-optimization/107561 - reduce -Wstringop-overflow false positives

The following tells pointer-query to prefer a zero size when we
are querying for the size range for a write into an object we've
determined is of zero size.  That avoids diagnostics about really
varying size arguments that just get a meaningful range for example
because they are multiplied by an element size.

I've adjusted only one call to get_size_range since that's what
I have a testcase for.

PR tree-optimization/107561
* gimple-ssa-warn-access.cc (get_size_range): Add flags
argument and pass it on.
(check_access): When querying for the size range pass
SR_ALLOW_ZERO when the known destination size is zero.

* g++.dg/pr71488.C: Remove XFAILed bogus diagnostic again.
* g++.dg/warn/Warray-bounds-16.C: Likewise.

19 months agotree-optimization/109342 - wrong code with edge equivalences in VN
Richard Biener [Thu, 30 Mar 2023 09:32:19 +0000 (11:32 +0200)]
tree-optimization/109342 - wrong code with edge equivalences in VN

The following testcase shows a problem in how we query valitity for
equivalences on edges when the edge is a backedge and thus refering
to a block thats later in the iteration order we use for VN.  That
causes the dominated_by_p_w_unex helper to look at edge executable
state that's not yet computed and thus still at optimistic not
executable state.

The following makes sure to use a plain dominance check in these cases.

PR tree-optimization/109342
* tree-ssa-sccvn.cc (vn_nary_op_get_predicated_value): New
overload for edge.  When that edge is a backedge use
dominated_by_p directly.

* g++.dg/torture/pr109342.C: New testcase.

19 months agoc++: Avoid informs without a warning [PR109278]
Jakub Jelinek [Thu, 30 Mar 2023 07:34:12 +0000 (09:34 +0200)]
c++: Avoid informs without a warning [PR109278]

On the following testcase we emit notes in
maybe_inform_about_fndecl_for_bogus_argument_init
despite no warning/error being printed before it.
This is for the extended floating point type conversions where pedwarn
is used, and complained is used there for 2 different purposes,
one is whether an unspecific error should be emitted if we haven't
complained otherwise, and one whether
maybe_inform_about_fndecl_for_bogus_argument_init should be called.
For the 2 pedwarns, currently it sets complained to true regardless of
whether pedwarn succeeded, which results in the undesirable notes printed
with -w.  If complained is initialized to result of pedwarn, we would
emit an error later on.

So, the following patch makes complained a tristate, the additional
error isn't printed if complained != 0, and
maybe_inform_about_fndecl_for_bogus_argument_init is called only if
complained == 1, so if pedwarn returns false, we can use complained = -1
to tell later code not to emit an error and not to call
maybe_inform_about_fndecl_for_bogus_argument_init.

2023-03-30  Jakub Jelinek  <jakub@redhat.com>

PR c++/109278
* call.cc (convert_like_internal): If pedwarn for extended float
type conversions doesn't report anything, avoid calling
maybe_inform_about_fndecl_for_bogus_argument_init.

* g++.dg/cpp23/ext-floating15.C: New test.

19 months agoFix fc-prototypes usage with C_INT64_T and non LP64 Targets.
Andrew Pinski [Wed, 29 Mar 2023 21:34:30 +0000 (21:34 +0000)]
Fix fc-prototypes usage with C_INT64_T and non LP64 Targets.

The problem here is we were outputing long_long instead of
"long long". This was just an oversight and a missing check.

Committed as obvious after a bootstrap/test on x86_64-linux-gnu.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (get_c_type_name): Fix "long_long"
type name to be "long long". Add a comment on why adding
2 to the name too.

19 months agoGenerate vpblendd instead of vpblendw for V4SI under AVX2.
liuhongt [Tue, 21 Mar 2023 05:37:59 +0000 (13:37 +0800)]
Generate vpblendd instead of vpblendw for V4SI under AVX2.

gcc/ChangeLog:

* config/i386/i386-expand.cc (expand_vec_perm_blend): Generate
vpblendd instead of vpblendw for V4SI under avx2.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr88828-0.c: Adjust testcase.

19 months agoDaily bump.
GCC Administrator [Thu, 30 Mar 2023 00:17:02 +0000 (00:17 +0000)]
Daily bump.

19 months agolibstdc++: Fix filename of new test [PR109242]
Jonathan Wakely [Wed, 29 Mar 2023 23:42:11 +0000 (00:42 +0100)]
libstdc++: Fix filename of new test [PR109242]

libstdc++-v3/ChangeLog:

PR libstdc++/109242
* testsuite/20_util/optional/monadic/pr109340.cc: Moved to...
* testsuite/20_util/optional/monadic/pr109242.cc: ...here.

19 months agolibstdc++: Fix constexpr functions in <experimental/internet>
Jonathan Wakely [Wed, 22 Mar 2023 17:00:11 +0000 (17:00 +0000)]
libstdc++: Fix constexpr functions in <experimental/internet>

Change ip::basic_endpoint to work in constant expressions, but only for
C++20 and later (due to the use of a union, which cannot change active
member in constexpr evaluation until C++20).

During constant evaluation we cannot inspect the common initial sequence
of basic_endpoint's union members to check whether sin_family == AF_INET
or AF_INET6.  This means we need to store an additional boolean member
that remembers whether we have a v4 or v6 address. The address type can
change behind our backs if a user copies an address to the data()
pointer and then calls resize(n), so we need to inspect the sa_family_t
member in the union after a resize and update the boolean. POSIX only
guarantees that the sa_family_t member of each protocol-specific address
structure is at the same offset and of the same type, not that there is
a common initial sequence. The check in resize is done using memcmp, so
that we avoid accessing an inactive member of the union if the
sockaddr_in and sockaddr_in6 structures do not have a common initial
sequence that includes the sa_family_t member.

libstdc++-v3/ChangeLog:

* include/experimental/internet (ip::make_address): Implement
missing overload.
(ip::address_v4::broadcast()): Avoid undefined shift.
(ip::basic_endpoint): Fix member functions for constexpr.
(ip::basic_endpoint::_M_is_v6): Replace member function with
data member, adjust member functions using it.
(ip::basic_endpoint::resize): Update _M_is_v6 based on sockaddr
content.
* testsuite/experimental/net/internet/address/v4/cons.cc: Fix
constexpr checks to work in C++14.
* testsuite/experimental/net/internet/address/v4/creation.cc:
Likewise.
* testsuite/experimental/net/internet/endpoint/cons.cc:
Likewise.
* testsuite/experimental/net/internet/network/v4/cons.cc:
Likewise.
* testsuite/experimental/net/internet/network/v4/members.cc:
Likewise.
* testsuite/experimental/net/internet/endpoint/extensible.cc: New test.

19 months agolibstdc++: Apply small fix from LWG 3843 to std::expected
Jonathan Wakely [Wed, 29 Mar 2023 21:43:16 +0000 (22:43 +0100)]
libstdc++: Apply small fix from LWG 3843 to std::expected

LWG 3843 adds some type requirements to std::expected::value to ensure
that it can correctly copy the error value if it needs to throw an
exception. We don't need to do anything to enforce that, because it will
already be ill-formed if the type can't be copied. The issue also makes
a small drive-by fix to ensure that a const E& is copied from the
non-const value()& overload, which this change implements.

libstdc++-v3/ChangeLog:

* include/std/expected (expected::value() &): Use const lvalue
for unex member passed to bad_expected_access constructor, as
per LWG 3843.

19 months agolibstdc++: Use std::remove_cv_t in std::optional::transform [PR109340]
Jonathan Wakely [Wed, 29 Mar 2023 21:16:55 +0000 (22:16 +0100)]
libstdc++: Use std::remove_cv_t in std::optional::transform [PR109340]

We need to strip cv-qualifiers from the result of the callable passed to
std::optional::transform.

For std::expected::transform and std::expected::transform_error I
noticed we were stripping cv-qualifiers but were also incorrectly
stripping references.

libstdc++-v3/ChangeLog:

PR libstdc++/109340
* include/std/expected (expected::transform): Use
std::remove_cv_t instead of std::remove_cvref_t.
(expected::transform_error): Likewise.
(expected<cv void, E>::transform): Likewise.
(expected<cv void, E>::transform_error): Likewise.
* include/std/optional (transform): Use std::remove_cv_t.
* testsuite/20_util/optional/monadic/pr109340.cc: New test.

19 months agolibstdc++: Enforce requirements on template argument of std::optional
Jonathan Wakely [Wed, 29 Mar 2023 21:02:19 +0000 (22:02 +0100)]
libstdc++: Enforce requirements on template argument of std::optional

The standard does not allow std::optional<T&>, std::optional<T[1]>,
std::optional<T()> etc. and although we do give errors, they come from
down inside the internals of std::optional. We could improve the static
assertions at the top of the class so that users get a more precise
diagnostic:

optional:721:21: error: static assertion failed
721 |       static_assert(is_object_v<_Tp> && !is_array_v<_Tp>);

libstdc++-v3/ChangeLog:

* include/std/optional (optional): Adjust static assertion to
reject arrays and functions as well as references.
* testsuite/20_util/optional/requirements_neg.cc: New test.

19 months agoCRIS: Make rtx-cost 0 for many CONST_INT "quick" operands
Hans-Peter Nilsson [Wed, 29 Mar 2023 22:56:13 +0000 (00:56 +0200)]
CRIS: Make rtx-cost 0 for many CONST_INT "quick" operands

Stepping through a gdb session inspecting costs that cause
gcc.dg/tree-ssa/slsr-13.c to fail, exposed that before this
patch, cris_rtx_costs told that a shift of 1 of a register
costs 5, while adding two registers costs 4.

Making the cost of a quick-immediate constant equal to using
a register (default 0) reflects actual performance and
size-cost better.  It also happens to make
gcc.dg/tree-ssa/slsr-13.c pass with what looks like better
code being generated, and improves coremark performance by
0.4%.

But, blindly doing this for *all* valid operands that fit
the "quick-immediate" addressing mode, trips interaction
with other factors*, with the end result mixed at best.  So,
do this only for MINUS and logical operations for the time
being, and only for modes that fit in one register.

*) Examples of "other factors":

- A bad default implementation of insn_cost or actually,
pattern_cost, that looks only at the set_src_cost and
furthermore sees such a cost of 0 as invalid.  (Compare to
the more sane set_rtx_cost.)  This naturally tripped up
combine and ifcvt, causing all sorts of changes, good and
bad.

- Having the same cost, to compare a register with 0 as with
-31..31, means a compare insn of an eliminable form no
longer looks preferable.

* config/cris/cris.cc (cris_rtx_costs) [CONST_INT]: Return 0
for many quick operands, for register-sized modes.

19 months agoPR modula2/109336 - The -fmod= and -fdef= options do not work
Gaius Mulley [Wed, 29 Mar 2023 16:38:22 +0000 (17:38 +0100)]
PR modula2/109336 - The -fmod= and -fdef= options do not work

The -fmod= and -fdef= options do not work.  After the linking
re-implementation and subsequent restructuring the -fmod= amd -fdef= are
now broken.  This patch adds -fmod= and -fdef= processing into gm2spec.cc.
It also reduces the complexity of extension handling within M2Search
by storing the preceeding "." in the extension.

gcc/m2/ChangeLog:

PR modula2/109336
PR modula2/109315
* gm2-compiler/M2FileName.mod (CalculateFileName): Simplified by
ensuring the extension contains the ".".
(CalculateStemName): Re-formatted.
(ExtractExtension): Re-formatted.
(ExtractModule): Re-formatted.
* gm2-compiler/M2Options.def (setdefextension): Add block comment.
(setmodextension): Add block comment.  Re-formatted.
* gm2-compiler/M2Options.mod (setdefextension): Add block comment.
(setmodextension): Add block comment.  Re-formatted.
* gm2-compiler/M2Search.mod (FindSourceDefFile): Use
DefaultDefExt.
(DefaultDefExt): New constant.
(DefaultModExt): New constant.
(FindSourceModFile): Use DefaultModExt.
* gm2-gcc/m2decl.cc (m2decl_DeclareKnownVariable): Correct
spelling.
* gm2spec.cc (M2SOURCE): New constant.
(LANGSPEC): New value.
(MATHLIB): New value.
(WITHLIBC): New value.
(SKIPOPT): New value.
(lang_specific_driver): Replace seen_module_extension bool with
module_extension char *.  Detect -fmod= and remember extension.
Use the extension to detect modula-2 source and mark it as such.

gcc/testsuite/ChangeLog:

PR modula2/109336
* gm2/link/nondefaultext/pass/hello.md: New test.
* gm2/link/nondefaultext/pass/liba.dm: New test.
* gm2/link/nondefaultext/pass/liba.md: New test.
* gm2/link/nondefaultext/pass/link-nondefaultext-pass.exp: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
19 months agoRISC-V: Add Z*inx imcompatible check in gcc
Jiawei [Tue, 28 Mar 2023 16:55:15 +0000 (00:55 +0800)]
RISC-V: Add Z*inx imcompatible check in gcc

Z*inx is conflict with float extensions, add incompatible check when
z*inx and f extension both enabled.

Since all float extension imply f extension and all z*inx extension
imply zfinx extension, so we just need to check f with zfinx extension
as the base case.

Co-Authored by: Kito Cheng <kito.cheng@gmail.com>

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc (riscv_subset_list::parse):
New check.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-19.c: New test.

19 months agoconfigure: deprecate --enable-link-mutex option
Martin Liska [Wed, 29 Mar 2023 12:52:42 +0000 (14:52 +0200)]
configure: deprecate --enable-link-mutex option

PR bootstrap/109310

gcc/ChangeLog:

* configure.ac: Emit a warning for deprecated option
--enable-link-mutex.
* configure: Regenerate.

19 months agotree-optimization/109331 - make sure to clean up the CFG after forwprop
Richard Biener [Wed, 29 Mar 2023 09:59:16 +0000 (11:59 +0200)]
tree-optimization/109331 - make sure to clean up the CFG after forwprop

When forwprop discovers unreachable code or makes decisions based
on unreachable edges make sure to cleanup the CFG since otherwise
SSA form can become invalid.

PR tree-optimization/109331
* tree-ssa-forwprop.cc (pass_forwprop::execute): When we
discover a taken edge make sure to cleanup the CFG.

* gcc.dg/torture/pr109331.c: New testcase.

19 months agoscan generic vector tests before lowering
Richard Biener [Wed, 29 Mar 2023 08:45:14 +0000 (10:45 +0200)]
scan generic vector tests before lowering

The g++.dg/pr94920.C testcase looks for a specific number of
ABS_EXPRs but the vector example is prone to vector lowering so
the following instead of scanning the optimized dump scans the
forwprop1 dump which is before vector lowering and the point the
transforms should have happened.

* g++.dg/pr94920.C: Scan forwprop1 instead of optimized.

19 months agotree-optimization/109327 - forwprop stmt removal issue
Richard Biener [Wed, 29 Mar 2023 07:51:58 +0000 (09:51 +0200)]
tree-optimization/109327 - forwprop stmt removal issue

There's interfering between the to_removed queue and other mechanisms
removing stmts, in this case remove_prop_source_from_use.  The following
makes the to_remove queue draining more permissive.

PR tree-optimization/109327
* tree-ssa-forwprop.cc (pass_forwprop::execute): Deal with
already removed stmts when draining to_remove.

* gcc.dg/pr109327.c: New testcase.

19 months agoipa/106124 - ICE with -fkeep-inline-functions and OpenMP
Richard Biener [Mon, 27 Mar 2023 14:40:15 +0000 (16:40 +0200)]
ipa/106124 - ICE with -fkeep-inline-functions and OpenMP

The testcases in this bug reveal cases where an early generated
type is collected because it was unused but gets attempted to
be recreated later when a late DIE for a function (an OpenMP
reduction) is created.  That's unexpected and possibly the fault
of OpenMP but the following allows the re-creation of the context
type to succeed.

PR ipa/106124
* dwarf2out.cc (lookup_type_die): Reset TREE_ASM_WRITTEN
so we can re-create the DIE for the type if required.

* g++.dg/gomp/pr106124.C: New testcase.

19 months agotree-ssa-math-opts: Move PROP_gimple_opt_math from sincos pass to powcabs [PR109301]
Jakub Jelinek [Wed, 29 Mar 2023 06:33:30 +0000 (08:33 +0200)]
tree-ssa-math-opts: Move PROP_gimple_opt_math from sincos pass to powcabs [PR109301]

The following testcase ICEs since the sincos and vect pass order has
been swapped.  It is not valid to replace vector sqrt (sqrt (x)) with
pow (x, 0.25) because build_real on vector type is invalid (could be
handled by using build_uniform_cst and adjusting type passed to
build_real) but more importantly because nothing checks if we can
actually do vector pow.
While we have pow_optab, apparently no target defines it, so it doesn't
seem to be worth bothering with for now and the patch just punts on
non-scalar sqrts.
I think the other simplifications next to it are fine, as they mostly
use CBRT which doesn't even have internal function (so is a builtin
only and therefore always scalar), or have already pow in the IL (which
doesn't have optab and shouldn't be thus vector either).
It is true that with <bits/math-vector.h> we do vectorize some calls to
pow or cbrt (but don't handle others strangely), but those aren't using
internal functions but simd clones and so match.pd doesn't know anything
about those (at least for now).

The following patch fixes it by mostly restoring the state before
r13-1763 where canonicalize_math_p () was true only until the end of the
pass which transformed pow or pow-like calls before vectorization (formerly
sincos pass, now it is powcabs pass).
powcabs is a pass in the spot sincos was happening before, so the
only change was defer the sin+cos simplification into cexpi to a later
new pass (except for the name moving with it) and none of the
canonicalize_math_p () guarded simplification in match.pd seem to rely
on those sin+cos -> cexpi simplifications and canonicalize_math_p is
the only user of this property.

2023-03-29  Jakub Jelinek  <jakub@redhat.com>
    Richard Biener  <rguenther@suse.de>

PR tree-optimization/109301
* tree-ssa-math-opts.cc (pass_data_cse_sincos): Change
properties_provided from PROP_gimple_opt_math to 0.
(pass_data_expand_powcabs): Change properties_provided from 0 to
PROP_gimple_opt_math.

* gcc.dg/pr109301.c: New test.

19 months agotree-optimization/109154 - improve if-conversion for vectorization
Richard Biener [Tue, 28 Mar 2023 13:20:22 +0000 (15:20 +0200)]
tree-optimization/109154 - improve if-conversion for vectorization

With multi-argument PHIs and now doing VN on the if-converted blocks
the optimization of CSEing condition and negated condition doesn't
work well anymore.  The following restores this a little bit for
the case of a single inverted condition into a COND_EXPR where
we can instead swap the COND_EXPR arms.  The same optimization
is already done for the case of two-argument PHIs.

This avoids one comparison/mask for the testcase at hand.

PR tree-optimization/109154
* tree-if-conv.cc (gen_phi_arg_condition): Handle single
inverted condition specially by inverting at the caller.
(gen_phi_arg_condition): Swap COND_EXPR arms if requested.

19 months agoc++: alias ctad refinements [PR109321]
Jason Merrill [Tue, 28 Mar 2023 21:42:23 +0000 (17:42 -0400)]
c++: alias ctad refinements [PR109321]

The two hunks fix missing handling demonstrated by the two testcases: first,
if we omit one alias template parm but include another, we need to rewrite
the deduced template args to reflect the new position of the included parm.
Second, if we can't deduce any template args for a parameter pack, it is
deduced to an empty pack.

PR c++/109321
PR c++/109320

gcc/cp/ChangeLog:

* pt.cc (alias_ctad_tweaks): Rewrite deduced args.
(type_targs_deducible_from): Handle null pack deduction.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias16.C: New test.
* g++.dg/cpp2a/class-deduction-alias17.C: New test.

19 months agocompiler: mark Call_expression multiple results as a result struct
Ian Lance Taylor [Tue, 28 Mar 2023 20:01:28 +0000 (13:01 -0700)]
compiler: mark Call_expression multiple results as a result struct

In https://go.dev/cl/343873 we stopped padding zero-sized trailing
fields in functions that return multiple results where the last result
is zero-sized. This CL makes the corresponding change on the caller side.

The test case is https://go.dev/cl/479898.

Fixes golang/go#55242

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/479955

19 months agoDaily bump.
GCC Administrator [Wed, 29 Mar 2023 00:17:01 +0000 (00:17 +0000)]
Daily bump.

19 months agoUpdate gcc de.po
Joseph Myers [Tue, 28 Mar 2023 23:46:40 +0000 (23:46 +0000)]
Update gcc de.po

* de.po: Update.

19 months agolibstdc++: Do not use facets cached in ios for ATL128 build [PR103387]
Jonathan Wakely [Tue, 28 Mar 2023 20:07:21 +0000 (21:07 +0100)]
libstdc++: Do not use facets cached in ios for ATL128 build [PR103387]

For the powerpc64le build with two different long double
representations, we cannot use the ios_base::_M_num_put and
ios_base::_M_num_get pointers, because they might have been initialized
in a translation unit using the other long double type. With the changes
to add __try_use_facet to GCC 13 the cache isn't really needed now, we
can just access the right facet in the locale directly, without needing
RTTI checks.

libstdc++-v3/ChangeLog:

PR libstdc++/103387
* include/bits/istream.tcc (istream::_M_extract(ValueT&)): Use
std::use_facet instead of cached _M_num_get facet.
(istream::operator>>(short&)): Likewise.
(istream::operator>>(int&)): Likewise.
* include/bits/ostream.tcc (ostream::_M_insert(ValueT)): Use
std::use_facet instead of cached _M_num_put facet.

19 months agoEnable 'gfortran.dg/weak-2.f90' for nvptx target
Thomas Schwinge [Tue, 28 Mar 2023 20:26:30 +0000 (22:26 +0200)]
Enable 'gfortran.dg/weak-2.f90' for nvptx target

Follow-up to commit bcbeebc498126c50d73809ec8a4bd0bff27ee97b
"Fortran: Add support for WEAK attribute for variables".

gcc/testsuite/
* gfortran.dg/weak-2.f90: Enable for nvptx target.

19 months agolibstdc++: More fixes for null pointers used with std::char_traits
Jonathan Wakely [Tue, 28 Mar 2023 10:12:58 +0000 (11:12 +0100)]
libstdc++: More fixes for null pointers used with std::char_traits

The std::char_traits member functions require that [p,p+n) is a valid
range, which is true for p==nullptr iff n==0. But we must not call
memcpy, memset etc, in that case, as they require non-null pointers even
when n==0.

This std::char_traits<char> and std::char_traits<wchar_t> explicit
specializations are already correct, but the primary template has some
bugs.

libstdc++-v3/ChangeLog:

* include/bits/char_traits.h (char_traits::copy): Return without
using memcpy if n==0.
(char_traits::assign): Likewise for memset.

19 months agolibstdc++: Tell GCC what basic_string::_M_is_local() means [PR109299]
Jonathan Wakely [Tue, 28 Mar 2023 09:50:40 +0000 (10:50 +0100)]
libstdc++: Tell GCC what basic_string::_M_is_local() means [PR109299]

This avoids a bogus warning about overflowing a buffer, because GCC
can't tell that we don't copy into the buffer unless it fits. By adding
a __builtin_unreachable() hint we inform the compiler about the
invariant that the buffer is only used when it's big enough.

This can also improve codegen, by eliminating dead code that GCC
couldn't tell was unreachable.

libstdc++-v3/ChangeLog:

PR libstdc++/109299
* include/bits/basic_string.h (basic_string::_M_is_local()): Add
hint for compiler that local strings fit in the local buffer.

19 months agolibstdc++: Update tzdata to 2023a [PR109288]
Jonathan Wakely [Mon, 27 Mar 2023 12:51:25 +0000 (13:51 +0100)]
libstdc++: Update tzdata to 2023a [PR109288]

Import the new 2023a tzdata.zi file and update the expiry dates of the
hardcoded lists of leapseconds to 2023-12-28.

With the new data, Africa/Egypt no longer has a single unbroken sys_info
from 2014-09-25 to chrono::year::max(). Only check up to 2014-09-01 so
that the test isn't sensitive to differences between 2022g and 2023a
data.

libstdc++-v3/ChangeLog:

PR libstdc++/109288
* include/std/chrono (__detail::__get_leap_second_info): Update
expiry date of hardcoded leapseconds list.
* src/c++20/tzdb.cc (tzdb_list::_Node::_S_read_leap_seconds()):
Likewise.
* src/c++20/tzdata.zi: Import new file from 2023a release.
* testsuite/std/time/time_zone/get_info_local.cc: Only check
transitions for Egypt up to 2014.

19 months agolibbacktrace: minor fixes for zstd decompression
Ian Lance Taylor [Tue, 28 Mar 2023 20:08:42 +0000 (13:08 -0700)]
libbacktrace: minor fixes for zstd decompression

* elf.c (elf_zstd_read_fse): Call elf_fetch_bits after reading
bits, not before.  Add unlikely for error case.
(elf_zstd_offset_table): Regenerate.
(elf_zstd_read_huff): Clear 13 entries in weight_mark, not 12.
(elf_zstd_read_literals): For a single stream adjust by
total_streams_size, not compressed_size.

19 months agoDon't emit -Wxor-used-as-pow on macro expansions [PR107002]
David Malcolm [Tue, 28 Mar 2023 18:34:49 +0000 (14:34 -0400)]
Don't emit -Wxor-used-as-pow on macro expansions [PR107002]

PR c/107002 reports an assertion failure from deep inside the
diagnostic_shows_locus when attempting to print fix-it hints relating
to -Wxor-used-as-pow.  The case involves macro expansions with
-ftrack-macro-expansion=0.

It doesn't seem to make much sense to emit this warning for macro
expansions, so this patch updates the warning not to (which seems
to also be clang's behavior).  The patch also adds some bulletproofing
to diagnostic-show-locus.cc to be more robust against such invalid
fix-it hints.

Doing so fixes the ICE.

gcc/c-family/ChangeLog:
PR c/107002
* c-common.h (check_for_xor_used_as_pow): Add "rhs_loc" param.
* c-warn.cc (check_for_xor_used_as_pow): Add "rhs_loc" param.
Reject cases where involving macro expansions.

gcc/c/ChangeLog:
PR c/107002
* c-typeck.cc (parser_build_binary_op): Update for new param of
check_for_xor_used_as_pow.

gcc/cp/ChangeLog:
PR c/107002
* parser.cc (cp_parser_binary_expression): Update for new param of
check_for_xor_used_as_pow.

gcc/ChangeLog:
PR c/107002
* diagnostic-show-locus.cc (column_range::column_range): Factor
out assertion conditional into...
(column_range::valid_p): ...this new function.
(line_corrections::add_hint): Don't attempt to consolidate hints
if it would lead to invalid column_range instances.

gcc/testsuite/ChangeLog:
PR c/107002
* c-c++-common/Wxor-used-as-pow-1.c: Add macro test.
* c-c++-common/Wxor-used-as-pow-pr107002-0.c: New test.
* c-c++-common/Wxor-used-as-pow-pr107002-1.c: New test.
* c-c++-common/Wxor-used-as-pow-pr107002-2.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
19 months agoc++: Allow translations of check_postcondition_result messages [PR109309]
Jakub Jelinek [Tue, 28 Mar 2023 15:49:23 +0000 (17:49 +0200)]
c++: Allow translations of check_postcondition_result messages [PR109309]

As mentioned in the PR, constructing a message from two parts by
concatenating them prevents translations, unless one of the parts
is a keyword which should be never translated.

The following patch fixes that.

2023-03-28  Jakub Jelinek  <jakub@redhat.com>

PR c++/109309
* contracts.cc: Include intl.h.
(check_postcondition_result): Don't form diagnostics from two halves
of an English message to allow translations.

19 months agoc-family: -Wsequence-point and COMPONENT_REF [PR107163]
Jason Merrill [Thu, 23 Mar 2023 19:57:39 +0000 (15:57 -0400)]
c-family: -Wsequence-point and COMPONENT_REF [PR107163]

The patch for PR91415 fixed -Wsequence-point to treat shifts and ARRAY_REF
as sequenced in C++17, and COMPONENT_REF as well.  But this is unnecessary
for COMPONENT_REF, since the RHS is just a FIELD_DECL with no actual
evaluation, and in this testcase handling COMPONENT_REF as sequenced blows
up fast in a deep inheritance tree.  Instead, look through it.

PR c++/107163

gcc/c-family/ChangeLog:

* c-common.cc (verify_tree): Don't use sequenced handling
for COMPONENT_REF.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wsequence-point-5.C: New test.

19 months agoRISC-V: Define __riscv_v_intrinsic [PR109312]
Kito Cheng [Tue, 28 Mar 2023 14:21:50 +0000 (22:21 +0800)]
RISC-V: Define __riscv_v_intrinsic [PR109312]

RVV intrinsic has defined a macro to identity the version of RVV
intrinsic spec, we missed that before, thanksful we are catch this
before release.

gcc/ChangeLog:

PR target/109312
* config/riscv/riscv-c.cc (riscv_ext_version_value): New.
(riscv_cpu_cpp_builtins): Define __riscv_v_intrinsic and
minor refactor.

gcc/testsuite/ChangeLog:

PR target/109312
* gcc.target/riscv/predef-__riscv_v_intrinsic.c: New test.

19 months agolibstdc++: Add missing trait is_simd_flag_type
Matthias Kretz [Wed, 22 Mar 2023 07:12:08 +0000 (08:12 +0100)]
libstdc++: Add missing trait is_simd_flag_type

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd.h (is_simd_flag_type): New.
(_IsSimdFlagType): New.
(copy_from, copy_to, load ctors): Constrain _Flags using
_IsSimdFlagType.

19 months agohaifa-sched: fix autopref_rank_for_schedule comparator [PR109187]
Alexander Monakov [Tue, 28 Mar 2023 13:00:37 +0000 (16:00 +0300)]
haifa-sched: fix autopref_rank_for_schedule comparator [PR109187]

Do not attempt to use a plain subtraction for generating a three-way
comparison result in autopref_rank_for_schedule qsort comparator, as
offsets are not restricted and subtraction may overflow.  Open-code
a safe three-way comparison instead.

gcc/ChangeLog:

PR rtl-optimization/109187
* haifa-sched.cc (autopref_rank_for_schedule): Avoid use of overflowing
subtraction in three-way comparison.

gcc/testsuite/ChangeLog:

PR rtl-optimization/109187
* gcc.dg/pr109187.c: New test.

19 months agoFix compute_operand when op1 == op2 symbolically.
Andrew MacLeod [Fri, 24 Mar 2023 15:21:20 +0000 (11:21 -0400)]
Fix compute_operand when op1 == op2 symbolically.

First, class value_relation should not sanitize records. just create
what is asked.

Second., if there is not a relation record, compute_operand was
creating one for op1 == op2 if op1 and op2 were the same symbol.   This
is not the correct way to communicate the information, as that record
will continue to be passed along the GORI unwind chain.

Instead, simply pass that information locally to the opX_range routine
for only the current statement.

PR tree-optimization/109265
PR tree-optimization/109274
gcc/
* gimple-range-gori.cc (gori_compute::compute_operand_range): Do
not create a relation record is op1 and op2 are the same symbol.
(gori_compute::compute_operand1_range): Pass op1 == op2 to the
handler for this stmt, but create a new record only if this statement
generates a relation based on the ranges.
(gori_compute::compute_operand2_range): Ditto.
* value-relation.h (value_relation::set_relation): Always create the
record that is requested.

gcc/testsuite/
* gcc.dg/pr109274.c: New.
* gfortran.dg/pr109265.f90: New.

19 months agotree-optimization/107087 - missed CCP after forwprop
Richard Biener [Mon, 27 Mar 2023 13:18:41 +0000 (15:18 +0200)]
tree-optimization/107087 - missed CCP after forwprop

When forwprop simplifies the CFG the 2nd order opportunities by
exposed degenerate PHIs are not realized.  The following improves
this by properly tracking executable edges and thus handling this
for non-cyclic CFGs at least.

This avoids the bogus diagnostic reported for the testcase in this PR.

PR tree-optimization/107087
* tree-ssa-forwprop.cc (pass_forwprop::execute): Track
executable regions to avoid useless work and to better
propagate degenerate PHIs.

* g++.dg/pr107087.C: New testcase.

19 months agomingw: Fix comments in x-mingw32-utf8
Costas Argyris [Tue, 28 Mar 2023 10:29:06 +0000 (11:29 +0100)]
mingw: Fix comments in x-mingw32-utf8

This is a comment-only change that I should have
done with the previous commit (304c7d44a) but
forgot to do so.

gcc/ChangeLog:

* config/i386/x-mingw32-utf8: update comments.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
19 months agoaarch64: Restore vectorisation of vld1 inputs [PR109072]
Richard Sandiford [Tue, 28 Mar 2023 11:34:51 +0000 (12:34 +0100)]
aarch64: Restore vectorisation of vld1 inputs [PR109072]

Before GCC 12, we would vectorize:

  int32_t arr[] = { x, x, x, x };

at -O3.  Vectorizing the store on its own is often a loss, particularly
for integers, so g:4963079769c99c4073adfd799885410ad484cbbe suppressed it.
This was necessary to fix regressions from enabling vectorisation at -O2,

However, the vectorisation is important if the code subsequently loads
from the array using vld1:

  return vld1q_s32 (arr);

This approach of initialising an array and loading from it is the
recommend endian-agnostic way of constructing an ACLE vector.

As discussed in the PR notes, the general fix would be to fold the
store and load-back to a constructor (preferably before vectorisation).
But that's clearly not stage 4 material.

This patch instead delays folding vld1 until after inlining and
records which decls a vld1 loads from.  It then treats vector
stores to those decls as free, on the optimistic assumption that
they will be removed later.  The patch also brute-forces
vectorization of plain constructor+store sequences, since some
of the CPU costs make that (dubiously) expensive even when the
store is discounted.

Delaying folding showed that we were failing to update the vops.
The patch fixes that too.

Thanks to Tamar for discussion & help with testing.

gcc/
PR target/109072
* config/aarch64/aarch64-protos.h (aarch64_vector_load_decl): Declare.
* config/aarch64/aarch64.h (machine_function::vector_load_decls): New
variable.
* config/aarch64/aarch64-builtins.cc (aarch64_record_vector_load_arg):
New function.
(aarch64_general_gimple_fold_builtin): Delay folding of vld1 until
after inlining.  Record which decls are loaded from.  Fix handling
of vops for loads and stores.
* config/aarch64/aarch64.cc (aarch64_vector_load_decl): New function.
(aarch64_accesses_vector_load_decl_p): Likewise.
(aarch64_vector_costs::m_stores_to_vector_load_decl): New member
variable.
(aarch64_vector_costs::add_stmt_cost): If the function has a vld1
that loads from a decl, treat vector stores to those decls as
zero cost.
(aarch64_vector_costs::finish_cost): ...and in that case,
if the vector code does nothing more than a store, give the
prologue a zero cost as well.

gcc/testsuite/
PR target/109072
* gcc.target/aarch64/pr109072_1.c: New test.
* gcc.target/aarch64/pr109072_2.c: Likewise.

19 months agobootstrap/84402 - improve (match ...) code generation
Richard Biener [Tue, 28 Mar 2023 10:42:14 +0000 (12:42 +0200)]
bootstrap/84402 - improve (match ...) code generation

The following avoids duplicating matching code for (match ...)
in match.pd when possible.  That's more easily possible for
(match ...) than simplify because we do not need to handle
common matches (those would be diagnosed only during compiling)
nor is the result able to inspect the active operator.

Specifically this reduces the size of the generated matches for
the atomic ops as noted in PR108129.

gimple-match.cc shrinks from 245k lines to 209k lines with this patch.

PR bootstrap/84402
PR tree-optimization/108129
* genmatch.cc (lower_for): For (match ...) delay
substituting into the match operator if possible.
(dt_operand::gen_gimple_expr): For user_id look at the
first substitute for determining how to access operands.
(dt_operand::gen_generic_expr): Likewise.
(dt_node::gen_kids): Properly sort user_ids according
to their substitutes.
(dt_node::gen_kids_1): Code-generate user_id matching.

19 months agolibstdc++: Fix operator% implementation for Clang
Matthias Kretz [Wed, 22 Mar 2023 07:12:08 +0000 (08:12 +0100)]
libstdc++: Fix operator% implementation for Clang

This resolves a regression of my previous fix where Clang would ICE on
_S_divides.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd_x86.h (_SimdImplX86): Use
_Base::_S_divides if the optimized _S_divides function is hidden
via the preprocessor.

19 months agogcov-tool: Use subcommand rather than sub-command in function comments
Jakub Jelinek [Tue, 28 Mar 2023 09:53:59 +0000 (11:53 +0200)]
gcov-tool: Use subcommand rather than sub-command in function comments

Follow-up to the recently committed fix of fixing the "subcomand" typos
in diagnostics.

2023-03-28  Jakub Jelinek  <jakub@redhat.com>
    Jonathan Wakely  <jwakely@redhat.com>

* gcov-tool.cc (do_merge, do_merge_stream, do_rewrite, do_overlap):
Use subcommand rather than sub-command in function comments.

19 months agoopenmp: Fix typo in diagnostics [PR109314]
Jakub Jelinek [Tue, 28 Mar 2023 09:39:46 +0000 (11:39 +0200)]
openmp: Fix typo in diagnostics [PR109314]

Trivial typo fix.

2023-03-28  Jakub Jelinek  <jakub@redhat.com>

PR fortran/109314
* openmp.cc (gfc_omp_absent_contains_clause): Fix typo in diagnostics
- composit -> composite.

19 months agorange-op-float: Only flush_denormals_to_zero for +-*/ [PR109154]
Jakub Jelinek [Tue, 28 Mar 2023 09:00:32 +0000 (11:00 +0200)]
range-op-float: Only flush_denormals_to_zero for +-*/ [PR109154]

As discussed in the PR, flushing denormals to zero on every frange::set
might be harmful for e.g. x < 0.0 comparisons, because we then on both
sides use ranges that include zero [-Inf, -0.0] on the true side, and
[-0.0, +Inf] NAN on the false side, rather than [-Inf, nextafter (-0.0, -Inf)]
on the true side.

The following patch does it only in range_operator_float::fold_range
which is right now used for +-*/ (both normal and reverse ops of those).

Though, I don't see any difference on the testcase in the PR, but not sure
what I should be looking at and the reduced testcase there has undefined
behavior.

2023-03-28  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/109154
* value-range.h (frange::flush_denormals_to_zero): Make it public
rather than private.
* value-range.cc (frange::set): Don't call flush_denormals_to_zero
here.
* range-op-float.cc (range_operator_float::fold_range): Call
flush_denormals_to_zero.

19 months agosanopt: Return TODO_cleanup_cfg if any .{UB,HWA,A}SAN_* calls were lowered [PR106190]
Jakub Jelinek [Tue, 28 Mar 2023 08:56:44 +0000 (10:56 +0200)]
sanopt: Return TODO_cleanup_cfg if any .{UB,HWA,A}SAN_* calls were lowered [PR106190]

The following testcase ICEs, because without optimization eh lowering
decides not to duplicate finally block of try/finally and so we end up
with variable guarded cleanup.  The sanopt pass creates a cfg that ought
to be cleaned up (some IFN_UBSAN_* functions are lowered in this case with
constant conditions in gcond and when not allowing recovery some bbs which
end with noreturn calls actually have successor edges), but the cfg cleanup
is actually (it is -O0) done only during the optimized pass.  We notice
there that the d[1][a] = 0; statement which has an EH edge is unreachable
(because ubsan would always abort on the out of bounds d[1] access), remove
the EH landing pad and block, but because that block just sets a variable
and jumps to another one which tests that variable and that one is reachable
from normal control flow, the __builtin_eh_pointer (1) later in there is
kept in the IL and we ICE during expansion of that statement because the
EH region has been removed.

The following patch fixes it by doing the cfg cleanup already during
sanopt pass if we create something that might need it, while the EH
landing pad is then removed already during sanopt pass, there is ehcleanup
later and we don't ICE anymore.

2023-03-28  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/106190
* sanopt.cc (pass_sanopt::execute): Return TODO_cleanup_cfg if any
of the IFN_{UB,HWA,A}SAN_* internal fns are lowered.

* gcc.dg/asan/pr106190.c: New test.

19 months agorange-op-float: Use get_nan_state in float_widen_lhs_range
Jakub Jelinek [Tue, 28 Mar 2023 08:55:31 +0000 (10:55 +0200)]
range-op-float: Use get_nan_state in float_widen_lhs_range

On Wed, Mar 22, 2023 at 07:32:44AM +0100, Aldy Hernandez wrote:
>       * value-range.cc (frange::set): Add nan_state argument.
>       * value-range.h (class nan_state): New.
>       (frange::get_nan_state): New.

The following patch makes use of those changes in float_widen_lhs_range.

2023-03-28  Jakub Jelinek  <jakub@redhat.com>

* range-op-float.cc (float_widen_lhs_range): Use pass get_nan_state
as 4th argument to set to avoid clear_nan and union_ calls.

19 months agoFix line ending
Eric Botcazou [Tue, 28 Mar 2023 08:44:06 +0000 (10:44 +0200)]
Fix line ending

gcc/testsuite/
* gcc.target/sparc/20230328-1.c: New test.
* gcc.target/sparc/20230328-2.c: Likewise.
* gcc.target/sparc/20230328-3.c: Likewise.
* gcc.target/sparc/20230328-4.c: Likewise.

19 months agoi386: Require just 32-bit alignment for SLOT_FLOATxFDI_387 -m32 -mpreferred-stack...
Jakub Jelinek [Tue, 28 Mar 2023 08:43:08 +0000 (10:43 +0200)]
i386: Require just 32-bit alignment for SLOT_FLOATxFDI_387 -m32 -mpreferred-stack-boundary=2 DImode temporaries [PR109276]

The following testcase ICEs since r11-2259 because assign_386_stack_local
-> assign_stack_local -> ix86_local_alignment now uses 64-bit alignment
for DImode temporaries rather than 32-bit as before.
Most of the spots in the backend which ask for DImode temporaries are during
expansion and those apparently are handled fine with -m32
-mpreferred-stack-boundary=2, we dynamically realign the stack in that case
(most of the spots actually don't need that alignment but at least one
does), then 2 spots are in STV which I assume also work correctly.
But during splitting we can create a DImode slot which doesn't need to be
64-bit alignment (it is nicer for performance though), when we apparently
aren't able to detect it for dynamic stack realignment purposes.

The following patch just makes the slot 32-bit aligned in that rare case.

2023-03-28  Jakub Jelinek  <jakub@redhat.com>

PR target/109276
* config/i386/i386.cc (assign_386_stack_local): For DImode
with SLOT_FLOATxFDI_387 and -m32 -mpreferred-stack-boundary=2 pass
align 32 rather than 0 to assign_stack_local.

* gcc.target/i386/pr109276.c: New test.

19 months agoFix PR target/109140
Eric Botcazou [Tue, 28 Mar 2023 08:13:24 +0000 (10:13 +0200)]
Fix PR target/109140

This is a regression present on the mainline and 12 branch at -O2, but the
issue is related to vectorization so was present at -O3 in earlier versions.

The vcondu expander that was added for VIS 3 more than a decade ago does not
fully work, because it does not filter out the unsigned condition codes (the
instruction is an UNSPEC that accepts only signed condition codes).

While I was at it, I also added the missing vcond and vcondu expanders for
the new comparison instructions that were added in VIS 4.

gcc/
PR target/109140
* config/sparc/sparc.cc (sparc_expand_vcond): Call signed_condition
on operand #3 to get the final condition code.  Use std::swap.
* config/sparc/sparc.md (vcondv8qiv8qi): New VIS 4 expander.
(fucmp<gcond:code>8<P:mode>_vis): Move around.
(fpcmpu<gcond:code><GCM:gcm_name><P:mode>_vis): Likewise.
(vcondu<GCM:mode><GCM:mode>): New VIS 4 expander.

gcc/testsuite/
* gcc.target/sparc/20230328-1.c: New test.
* gcc.target/sparc/20230328-2.c: Likewise.
* gcc.target/sparc/20230328-3.c: Likewise.
* gcc.target/sparc/20230328-4.c: Likewise.

19 months agoModula-2: fix documentation layout again
Eric Botcazou [Mon, 27 Mar 2023 16:27:17 +0000 (18:27 +0200)]
Modula-2: fix documentation layout again

Nothing really serious this time.

gcc/
* doc/gm2.texi: Add missing Next, Previous and Top fields to most
top-level sections.

19 months agotestsuite: Fix weak_undefined handling on Darwin
Rainer Orth [Tue, 28 Mar 2023 08:40:05 +0000 (10:40 +0200)]
testsuite: Fix weak_undefined handling on Darwin

The patch that introduced the weak_undefined effective-target keyword
and corresponding dg-add-options support

commit 378ec7b87a5265dbe2d489c245fac98ef37fa638
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu Mar 23 00:45:05 2023 -0300

    [testsuite] test for weak_undefined support and add options

badly broke the affected tests on macOS like so:

ERROR: gcc.dg/addr_equal-1.c: unknown dg option: 89 for " dg-add-options 5 weak_undefined "
ERROR: gcc.dg/addr_equal-1.c: unknown dg option: 89 for " dg-add-options 5 weak_undefined "

add_options_for_weak_undefined tries to call an non-existant proc "89".
Even after fixing this by escaping the brackets, two tests still failed to
link since they lacked the corresponding calls do dg-add-options
weak_undefined.

Tested on x86_64-apple-darwin20.6.0 and i386-pc-solaris2.11.

2023-03-27  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* lib/target-supports.exp (add_options_for_weak_undefined): Escape
brackets.
* gcc.dg/visibility-22.c: Add weak_undefined options.

libgomp:
* testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c: Add
weak_undefined options.

19 months agoExtend UTF-8 support to the 32-bit mingw host.
Costas Argyris [Sun, 26 Mar 2023 10:32:13 +0000 (11:32 +0100)]
Extend UTF-8 support to the 32-bit mingw host.

Prevent any name mangling in HOST_EXTRA_OBJS_SYMBOL
such that the linker always finds it by that name.

Also add the .manifest file as an explicit
dependency in the make rule such that the
object gets re-built if it changes.

gcc/ChangeLog:

* config.host: Pull in i386/x-mingw32-utf8 Makefile
fragment and reference utf8rc-mingw32.o explicitly
for mingw hosts.
* config/i386/sym-mingw32.cc: prevent name mangling of
stub symbol.
* config/i386/x-mingw32-utf8: Make utf8rc-mingw32.o
depend on manifest file explicitly.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
19 months agoRevert "rtl-optimization/109237 - speedup bb_is_just_return"
Richard Biener [Tue, 28 Mar 2023 07:31:36 +0000 (09:31 +0200)]
Revert "rtl-optimization/109237 - speedup bb_is_just_return"

This reverts commit 776a5bb5894315ab144dc74222fc580fde8fdd87.

PR rtl-optimization/109311
* cfgcleanup.cc (bb_is_just_return): Revert previous change.

19 months agofixincludes: Declare memmem if it's not declared in system headers [PR109293]
Xi Ruoyao [Mon, 27 Mar 2023 17:48:02 +0000 (01:48 +0800)]
fixincludes: Declare memmem if it's not declared in system headers [PR109293]

memmem is not POSIX so the system may lack it.  Then libiberty will
provide an implementation, but it's a "supplemental function" and not
declared in libiberty.h.  We need to declare the prototype to use it
then.

See libiberty doc at
https://gcc.gnu.org/onlinedocs/libiberty/Supplemental-Functions.html.

Tested by bootstrapping GCC in the following container environments on
x86_64-linux-gnu:

1. "Vanilla" system with memmem in Glibc.
2. memmem removed from string.h.
3. memmem removed from both string.h and libc.so.

For 3, also verified that memmem from libiberty is linked into fixincl
executable.

Ok for trunk?

fixincludes/ChangeLog:

PR other/109293
* configure.ac (AC_CHECK_DECLS): Add memmem.
* configure: Regenerate.
* config.h.in: Regenerate.
* system.h (memmem): Declare if HAVE_DECL_MEMMEM is zero.

19 months agoRemove Negative(gwarf-) from gdwarf
Richard Biener [Fri, 24 Mar 2023 09:19:55 +0000 (10:19 +0100)]
Remove Negative(gwarf-) from gdwarf

Prior to the removal of STABS support the gdwarf, gstabs, ... options
formed a cycle with their Negative(..) option attribute.  But that
didn't actually have any effect since most of the options also
are Joined or JoinedOrMissing for which there's no pruning of options
and so once ran into the set_debug_level diagnostics reporting
conflicting debug formats.

The following removes the remains of that cycle, which is a
Negative option from gdwarf to gdwarf-.  With RejectNegative
added the expected effect of -gdwarf-4 -gdwarf would be to
enable DWARF5 support (but this doesn't happen for some reason).
I think the more sensible behavior is that seen and implemented
in opts.cc, the more specific -gdwarf-4 determines the DWARF level
and a later or earlier -gdwarf becomes a no-op.  So the
Negative(..) annotation on gdwarf is just confusing.

* common.opt (gdwarf): Remove Negative(gdwarf-).

19 months agoDisallow -gno-dwarf, gno-dwarf-N, -gno-gdb and -gno-vms
Richard Biener [Fri, 24 Mar 2023 08:57:33 +0000 (09:57 +0100)]
Disallow -gno-dwarf, gno-dwarf-N, -gno-gdb and -gno-vms

The following adds RejectNegative to the gdwarf, gdwarf-, ggdb and gvms
options since the current behavior is to treat the negative variant
the same as the positive variant.  In particular -ggdb -gno-gdb
do not cancel, and plain -gno-dwarf will enable (dwarf!) debug output.

Rejecting the negative forms avoids interpreting sensible behavior
to combinations of options like -gdwarf-5 -gno-dwarf-3 and sticks to
the behavior that later -g options simply override earlier ones and
the only negative form is -g0.

* common.opt (gdwarf): Add RejectNegative.
(gdwarf-): Likewise.
(ggdb): Likewise.
(gvms): Likewise.

19 months agoCRIS: Correct "T" to define_memory_constraint, not define_constraint
Hans-Peter Nilsson [Tue, 28 Mar 2023 01:23:33 +0000 (03:23 +0200)]
CRIS: Correct "T" to define_memory_constraint, not define_constraint

This patch has no effect on builds using reload of libgcc, newlib libc, my
own at-a-glance-testsuite and coremark.  That somewhat surprisingly
also goes for LRA builds, even with all CRIS reload_in_progress
augmented to include lra_in_progress.  I just noticed it when checking
because another port had a similar fix, where it mattered for LRA.

* config/cris/constraints.md ("T"): Correct to
define_memory_constraint.

19 months agoCRIS: Add peephole2 to handle gcc.target/cris/rld-legit1.c for LRA
Hans-Peter Nilsson [Tue, 28 Mar 2023 01:21:13 +0000 (03:21 +0200)]
CRIS: Add peephole2 to handle gcc.target/cris/rld-legit1.c for LRA

The test-case gcc.target/cris/rld-legit1.c is a reduced
test-case that required defining LEGITIMIZE_RELOAD_ADDRESS
to stop the address from being decomposed into several insns
by reload.  Valid but suboptimal code was generated.

(Before implementing that hook for CRIS, the same test-case
also exposed a bug in reload, and a fix was committed to
avoid an ICE; see e.g. git r0-71992-gff0d9879ab0f30 and
related commits.  But, post-cc0, reload no longer handles
this test-case without LEGITIMIZE_RELOAD_ADDRESS helping and
there'd again an be ICE for CRIS (again: only if
LEGITIMIZE_RELOAD_ADDRESS is disabled).  There's a patch to
reload to fix that, at
https://gcc.gnu.org/pipermail/gcc-patches/2023-February/612039.html)

But, LRA also does not handle that test-case gracefully, and
like reload without LEGITIMIZE_RELOAD_ADDRESS for CRIS,
decomposes the address into a suboptimal (but valid)
sequence, about as messy as that from reload, and
gcc.target/cris/rld-legit1.c would regress for LRA.  There's
nothing equivalent to LEGITIMIZE_RELOAD_ADDRESS for LRA.
(Stepping through LRA, I can't find an obvious place where
to put such a hook.  Granted, I haven't seen this kind of
messy decomposition in other code, so I'm not insisting a
LEGITIMIZE_RELOAD_ADDRESS-like hook is a good idea.)

These new peephole2's are required to not regress
gcc.target/cris/rld-legit1.c with LRA enabled for CRIS.
They don't appear to otherwise make a difference for neither
libgcc, newlib libc, my own at-a-glance tests nor coremark,
for neither LRA nor reload.

* config/cris/cris.md (BW2): New mode-iterator.
(lra_szext_decomposed, lra_szext_decomposed_indirect_with_offset): New
peephole2s.

19 months agoCRIS: Improve bailing for eliminable compares for "addi" vs. "add"
Hans-Peter Nilsson [Tue, 28 Mar 2023 01:20:05 +0000 (03:20 +0200)]
CRIS: Improve bailing for eliminable compares for "addi" vs. "add"

This patch affects a post-reload define_split for CRIS that transforms
a condition-code-clobbering addition into a non-clobbering addition.
(A "two-operand" addition between registers is the only insn that has
both a condition-code-clobbering and a non-clobbering variant for
CRIS.)  Many more "add.d":s are replaced by non-condition-code-
clobbering "addi":s after this patch, but most of the transformations
don't matter.

CRIS with LRA generated code that exposed a flaw with the original
patch: it bailed too easily, on *any* insn using the result of the
addition.  To wit, more effort than simply applying reg_mentioned_p is
needed to inspect the user, in the code to avoid munging an insn
sequence that cmpelim is supposed to handle.

With this patch coremark score for CRIS (*with reload*) improves by
less than 0.01% (a single "nop" is eliminated in
core_state_transition, in an execution path that affects ~1/20 of all
of the 10240 calls).  However, the original cause for this patch is to
not regress gcc.target/cris/pr93372-44.c for LRA, where otherwise a
needless "cmpq" is emitted.  For CRIS with LRA, the performance effect
on coremark isn't even measurable, except by reducing the size of the
executable due to affecting non-called library code.

* config/cris/cris.md ("*add<mode>3_addi"): Improve to bail only
for possible eliminable compares.

19 months agoCRIS: Remove unused constraint "R".
Hans-Peter Nilsson [Tue, 28 Mar 2023 01:18:31 +0000 (03:18 +0200)]
CRIS: Remove unused constraint "R".

* config/cris/constraints.md ("R"): Remove unused constraint.

19 months agoDaily bump.
GCC Administrator [Tue, 28 Mar 2023 00:17:14 +0000 (00:17 +0000)]
Daily bump.

19 months agogcov: Fix "subcomand" typos [PR109297]
Jonathan Wakely [Mon, 27 Mar 2023 12:46:46 +0000 (13:46 +0100)]
gcov: Fix "subcomand" typos [PR109297]

gcc/ChangeLog:

PR gcov-profile/109297
* gcov-tool.cc (merge_usage): Fix "subcomand" typo.
(merge_stream_usage): Likewise.
(overlap_usage): Likewise.

19 months agotree-optimization/54498 - testcase for the bug
Richard Biener [Mon, 27 Mar 2023 12:30:47 +0000 (14:30 +0200)]
tree-optimization/54498 - testcase for the bug

I realized I never added a testcase for the fix of this bug.  Now done
after verifying it still fails when reverting the fix.

PR tree-optimization/54498
* g++.dg/torture/pr54498.C: New testcase.

19 months agotree-optimization/108357 - add testcase
Richard Biener [Mon, 27 Mar 2023 12:22:56 +0000 (14:22 +0200)]
tree-optimization/108357 - add testcase

The following adds the testcase for the bug which was recently
fixed.

PR tree-optimization/108357
* gcc.dg/tree-ssa/pr108357.c: New testcase.

19 months agotarget/109296 - riscv: Add missing mode specifiers for XTheadMemPair
Christoph Müllner [Mon, 27 Mar 2023 10:51:51 +0000 (12:51 +0200)]
target/109296 - riscv: Add missing mode specifiers for XTheadMemPair

This patch adds missing mode specifiers for XTheadMemPair INSNs.

gcc/ChangeLog:
PR target/109296
* config/riscv/thead.md: Add missing mode specifiers.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
19 months agolibstdc++: Fix up experimental/net/timer/waitable/dest.cc testcase
Jakub Jelinek [Mon, 27 Mar 2023 10:02:06 +0000 (12:02 +0200)]
libstdc++: Fix up experimental/net/timer/waitable/dest.cc testcase

In Fedora package build I've noticed a failure
/builddir/build/BUILD/gcc-13.0.1-20230324/libstdc++-v3/testsuite/experimental/net/timer/waitable/dest.cc: In function 'void test01()':
/builddir/build/BUILD/gcc-13.0.1-20230324/libstdc++-v3/testsuite/experimental/net/timer/waitable/dest.cc:41: warning: format '%lu' expects argument of type 'long unsigned int', but a
rgument 2 has type 'unsigned int' [-Wformat=]
FAIL: experimental/net/timer/waitable/dest.cc (test for excess errors)
Excess errors:
/builddir/build/BUILD/gcc-13.0.1-20230324/libstdc++-v3/testsuite/experimental/net/timer/waitable/dest.cc:41: warning: format '%lu' expects argument of type 'long unsigned int', but
+argument 2 has type 'unsigned int' [-Wformat=]
because we build with -Wformat.

The test uses %lu for size_t argument, which can be anything from unsigned
int to unsigned long long.  As for printf I'm not sure we can use %zu
portably and given the n == 1 assertion, I think the options are to kill
the printf, or cast to long.

2023-03-27  Jakub Jelinek  <jakub@redhat.com>

* testsuite/experimental/net/timer/waitable/dest.cc: Avoid -Wformat
warning if size_t is not unsigned long.

19 months agoaarch64: update ampere1 vectorization cost
Philipp Tomsich [Mon, 27 Mar 2023 07:16:22 +0000 (09:16 +0200)]
aarch64: update ampere1 vectorization cost

The original submission of AmpereOne (-mcpu=ampere1) costs occurred
prior to exhaustive testing of vectorizable workloads against
hardware.

Adjust the vector costs to achieve the best results and more closely
match the underlying hardware.

gcc/ChangeLog:

* config/aarch64/aarch64.cc: Update vector costs for ampere1.

Co-Authored-By: Jiangning Liu <jiangning.liu@amperecomputing.com>
Co-Authored-By: Manolis Tsamis <manolis.tsamis@vrull.eu>
19 months agofix: pytest error
Martin Liska [Mon, 27 Mar 2023 08:03:26 +0000 (10:03 +0200)]
fix: pytest error

Fixes:
gcc/testsuite/lib/verify-sarif-file.py:10:27: Q000 Double quotes found but single quotes preferred

gcc/testsuite/ChangeLog:

* lib/verify-sarif-file.py: Use apostrophes instead
of double quotes.

19 months agortl-optimization/109237 - speedup bb_is_just_return
Richard Biener [Wed, 22 Mar 2023 09:05:19 +0000 (10:05 +0100)]
rtl-optimization/109237 - speedup bb_is_just_return

For the testcase bb_is_just_return is on top of the profile, changing
it to walk BB insns backwards puts it off the profile.  That's because
in the forward walk you have to process possibly many debug insns
but in a backward walk you very likely run into control insns first.

PR rtl-optimization/109237
* cfgcleanup.cc (bb_is_just_return): Walk insns backwards.

19 months agolto/109263 - lto-wrapper and -g0 -ggdb
Richard Biener [Thu, 23 Mar 2023 15:56:53 +0000 (16:56 +0100)]
lto/109263 - lto-wrapper and -g0 -ggdb

The following makes lto-wrapper deal with non-combined debug
disabling / enabling option combinations properly.  Interestingly
-gno-dwarf also enables debug.

PR lto/109263
* lto-wrapper.cc (run_gcc): Parse alternate debug options
as well, they always enable debug.

19 months agors6000: Make _mm_slli_si128 and _mm_bslli_si128 consistent [PR109167]
Kewen Lin [Mon, 27 Mar 2023 02:43:39 +0000 (21:43 -0500)]
rs6000: Make _mm_slli_si128 and _mm_bslli_si128 consistent [PR109167]

As PR109167 shows, it's unexpected to have two different
implementation ways for _mm_slli_si128 and _mm_bslli_si128,
as gcc/config/i386/emmintrin.h they should be the same.  So
this patch is to fix it accordingly.

PR target/109167

gcc/ChangeLog:

* config/rs6000/emmintrin.h (_mm_bslli_si128): Move the implementation
from ...
(_mm_slli_si128): ... here.  Change to call _mm_bslli_si128 directly.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr109167.c: New test.

19 months agors6000: Ensure vec_sld shift count in allowable range [PR109082]
Kewen Lin [Mon, 27 Mar 2023 02:42:23 +0000 (21:42 -0500)]
rs6000: Ensure vec_sld shift count in allowable range [PR109082]

As PR109082 shows, some uses of vec_sld in emmintrin.h don't
strictly guarantee the given shift count is in the range
0-15 (inclusive).  This patch is to make the argument
range constraint honored for those uses.

PR target/109082

gcc/ChangeLog:

* config/rs6000/emmintrin.h (_mm_bslli_si128): Check __N is not less
than zero when calling vec_sld.
(_mm_bsrli_si128): Return __A if __N is zero, check __N is bigger than
zero when calling vec_sld.
(_mm_slli_si128): Return __A if _imm5 is zero, check _imm5 is bigger
than zero when calling vec_sld.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr109082.c: New test.

19 months agoDocs, OpenMP: Correct internal documentation of OMP_FOR.
Sandra Loosemore [Tue, 21 Mar 2023 22:15:33 +0000 (22:15 +0000)]
Docs, OpenMP: Correct internal documentation of OMP_FOR.

gcc/ChangeLog:

* doc/generic.texi (OpenMP): Document OMP_SIMD, OMP_DISTRIBUTE,
OMP_TASKLOOP, and OMP_LOOP with OMP_FOR.  Document how collapsed
loops are represented and which fields are vectors.  Add
documentation for OMP_FOR_PRE_BODY field.  Document internal
form of non-rectangular loops and OMP_FOR_NON_RECTANGULAR.

* tree.def (OMP_FOR): Make documentation consistent with the
Texinfo manual, to fill some gaps and correct errors.

19 months agoDaily bump.
GCC Administrator [Mon, 27 Mar 2023 00:16:43 +0000 (00:16 +0000)]
Daily bump.

19 months agom68k: handle TLS access with offset
Andreas Schwab [Sun, 17 Jul 2022 21:35:05 +0000 (23:35 +0200)]
m68k: handle TLS access with offset

This reinstates FINAL_PRESCAN_INSN, and the calls in handle_move_double,
so that access to TLS variables with offset are properly handled.

gcc:
PR target/106282
* config/m68k/m68k.h (FINAL_PRESCAN_INSN): Define.
* config/m68k/m68k.cc (m68k_final_prescan_insn): Define.
(handle_move_double): Call it before handle_movsi.
* config/m68k/m68k-protos.h: Declare it.

gcc/testsuite:
PR target/106282
* gcc.target/m68k/tls-gd-off.c: New.
* gcc.target/m68k/tls-ie-off.c: New.
* gcc.target/m68k/tls-ld-off.c: New.
* gcc.target/m68k/tls-ld-xtls-off.c: New.
* gcc.target/m68k/tls-le-off.c: New.
* gcc.target/m68k/tls-le-xtls-off.c: New.
* gcc.target/m68k/tls-ld.c: Make pattern less strict.
* gcc.target/m68k/tls-le.c: Likewise.

19 months agomatch.pd: Fix up fneg/fadd simplification [PR109230]
Jakub Jelinek [Sun, 26 Mar 2023 18:17:00 +0000 (20:17 +0200)]
match.pd: Fix up fneg/fadd simplification [PR109230]

The following testcase is miscompiled on aarch64-linux.  match.pd
has a simplification for addsub, where it negates one of the vectors
in twice as large floating point element vector (effectively negating every
other element) and then doing addition.
But a requirement for that is that the permutation picks the right elements,
in particular 0, nelts+1, 2, nelts+3, 4, nelts+5, ...
The pattern tests this with sel.series_p (0, 2, 0, 2) check, which as
documented verifies that the even elements of the permutation mask are
identity, but doesn't say anything about the others.
The following patch fixes it by also checking that the odd elements
start at nelts + 1 with the same step of 2.

2023-03-26  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/109230
* match.pd (fneg/fadd simplify): Verify also odd permutation indexes.

* gcc.dg/pr109230.c: New test.

19 months agopredict: Don't emit -Wsuggest-attribute=cold warning for functions which already...
Jakub Jelinek [Sun, 26 Mar 2023 18:15:05 +0000 (20:15 +0200)]
predict: Don't emit -Wsuggest-attribute=cold warning for functions which already have that attribute [PR105685]

In the following testcase, we predict baz to have cold
entry regardless of the user supplied attribute (as it call
unconditionally a cold function), but still issue
a -Wsuggest-attribute=cold warning despite it having that attribute
already.

The following patch avoids that.

2023-03-26  Jakub Jelinek  <jakub@redhat.com>

PR ipa/105685
* predict.cc (compute_function_frequency): Don't call
warn_function_cold if function already has cold attribute.

* c-c++-common/cold-2.c: New test.

19 months agodoc: Remove anachronistic note related to languages built
Gerald Pfeifer [Sun, 26 Mar 2023 10:21:31 +0000 (12:21 +0200)]
doc: Remove anachronistic note related to languages built

This is another instance of what ce51e8439a49 (and originally
05432288d4e5) addressed in a different part. We stopped shipping
granular tarballs years ago.

gcc/ChangeLog:

* doc/install.texi: Remove anachronistic note
related to languages built and separate source tarballs.

19 months agoDaily bump.
GCC Administrator [Sun, 26 Mar 2023 00:16:45 +0000 (00:16 +0000)]
Daily bump.

19 months agoFortran: remove dead code [PR104321]
Harald Anlauf [Sat, 25 Mar 2023 18:59:45 +0000 (19:59 +0100)]
Fortran: remove dead code [PR104321]

gcc/fortran/ChangeLog:

PR fortran/104321
* trans-decl.cc (gfc_conv_cfi_to_gfc): Remove dead code.

19 months agodiagnostics: ensure that .sarif files are UTF-8 encoded [PR109098]
David Malcolm [Sat, 25 Mar 2023 00:52:34 +0000 (20:52 -0400)]
diagnostics: ensure that .sarif files are UTF-8 encoded [PR109098]

PR analyzer/109098 notes that the SARIF spec mandates that .sarif
files are UTF-8 encoded, but -fdiagnostics-format=sarif-file naively
assumes that the source files are UTF-8 encoded when quoting source
artefacts in the .sarif output, which can lead to us writing out
.sarif files with non-UTF-8 bytes in them (which break my reporting
scripts).

The root cause is that sarif_builder::maybe_make_artifact_content_object
was using maybe_read_file to load the file content as bytes, and
assuming they were UTF-8 encoded.

This patch reworks both overloads of this function (one used for the
whole file, the other for snippets of quoted lines) so that they go
through input.cc's file cache, which attempts to decode the input files
according to the input charset, and then encode as UTF-8.  They also
check that the result actually is UTF-8, for cases where the input
charset is missing, or incorrectly specified, and omit the quoted
source for such awkward cases.

Doing so fixes all of the cases I've encountered.

The patch adds a new:
  { dg-final { verify-sarif-file } }
directive to all SARIF test cases in the test suite, which verifies
that the output is UTF-8 encoded, and is valid JSON.  In particular
it verifies that when we complain about encoding problems, the .sarif
report we emit is itself correctly encoded.

gcc/ChangeLog:
PR analyzer/109098
* diagnostic-format-sarif.cc (read_until_eof): Delete.
(maybe_read_file): Delete.
(sarif_builder::maybe_make_artifact_content_object): Use
get_source_file_content rather than maybe_read_file.
Reject it if it's not valid UTF-8.
* input.cc (file_cache_slot::get_full_file_content): New.
(get_source_file_content): New.
(selftest::check_cpp_valid_utf8_p): New.
(selftest::test_cpp_valid_utf8_p): New.
(selftest::input_cc_tests): Call selftest::test_cpp_valid_utf8_p.
* input.h (get_source_file_content): New prototype.

gcc/testsuite/ChangeLog:
PR analyzer/109098
* c-c++-common/diagnostic-format-sarif-file-1.c: Add
verify-sarif-file directive.
* c-c++-common/diagnostic-format-sarif-file-2.c: Likewise.
* c-c++-common/diagnostic-format-sarif-file-3.c: Likewise.
* c-c++-common/diagnostic-format-sarif-file-4.c: Likewise.
* c-c++-common/diagnostic-format-sarif-file-Wbidi-chars.c: New
test case, adapted from Wbidi-chars-1.c.
* c-c++-common/diagnostic-format-sarif-file-bad-utf8-pr109098-1.c:
New test case.
* c-c++-common/diagnostic-format-sarif-file-bad-utf8-pr109098-2.c:
New test case.
* c-c++-common/diagnostic-format-sarif-file-bad-utf8-pr109098-3.c:
New test case, adapted from cpp/Winvalid-utf8-1.c.
* c-c++-common/diagnostic-format-sarif-file-valid-CP850.c: New
test case, adapted from gcc.dg/diagnostic-input-charset-1.c.
* gcc.dg/plugin/crash-test-ice-sarif.c: Add verify-sarif-file
directive.
* gcc.dg/plugin/crash-test-write-though-null-sarif.c: Likewise.
* gcc.dg/plugin/diagnostic-test-paths-5.c: Likewise.
* lib/scansarif.exp (verify-sarif-file): New procedure.
* lib/verify-sarif-file.py: New support script.

libcpp/ChangeLog:
PR analyzer/109098
* charset.cc (cpp_valid_utf8_p): New function.
* include/cpplib.h (cpp_valid_utf8_p): New prototype.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
19 months agoDaily bump.
GCC Administrator [Sat, 25 Mar 2023 00:16:51 +0000 (00:16 +0000)]
Daily bump.

19 months agodocs, analyzer: improvements to "Debugging the Analyzer"
David Malcolm [Fri, 24 Mar 2023 23:52:08 +0000 (19:52 -0400)]
docs, analyzer: improvements to "Debugging the Analyzer"

gcc/ChangeLog:
* doc/analyzer.texi (Debugging the Analyzer): Add notes on useful
debugging options.
(Special Functions for Debugging the Analyzer): Convert to a
table, and rewrite in places.
(Other Debugging Techniques): Add notes on how to compare two
different exploded graphs.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
19 months agogo: Fix up go.test/test/fixedbugs/bug207.go failure [PR109258]
Jakub Jelinek [Fri, 24 Mar 2023 22:02:08 +0000 (23:02 +0100)]
go: Fix up go.test/test/fixedbugs/bug207.go failure [PR109258]

The PR109086 r13-6690 inline_string_cmp change to
      if (diff != result)
        emit_move_insn (result, diff);
regressed
FAIL: go.test/test/fixedbugs/bug207.go,  -O2 -g  (internal compiler error: in emit_move_insn, at expr.cc:4224)
The problem is the Go FE doesn't mark __builtin_memcmp as pure as other FEs,
so we ended up with
  __builtin_memcmp (whatever, whateverelse, somesize);
in the IL before expansion and the expansion ICEd on it.
As the builtin calls a library function which is pure or is inline expanded
as such, not marking it pure is an unnecessary pessimization from the FE
side, keeping such dead calls in the IL if they aren't needed will not help
anything.

The following patch fixes that.  Initially I've added just DECL_PURE_P to
it, but that unfortunately broke bootstrap, for __builtin_memcmp there is
also __builtin_memcmp_eq registered by the middle-end code if not registered
earlier and that one is registered with the usual flags (pure, nothrow,
leaf), so if __builtin_memcmp from FE was just pure, it would appear in the
IL as that it can raise exceptions and when folded into __builtin_memcmp_eq
all of sudden it couldn't and we'd ICE in verification.

I think tons of functions should have builtin_nothrow as well, but changing
that wasn't necessary for this fix.

2023-03-24  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/109258
* go-gcc.cc (Gcc_backend): Add new static data members builtin_pure
and builtin_nothrow.
(Gcc_backend::Gcc_backend): Pass builtin_pure | builtin_nothrow for
BUILT_IN_MEMCMP.
(Gcc_backend::define_builtin): Handle builtin_pure and builtin_nothrow
in flags.

19 months agoFortran: fix FE memleak with BOZ expressions.
Harald Anlauf [Fri, 24 Mar 2023 21:07:37 +0000 (22:07 +0100)]
Fortran: fix FE memleak with BOZ expressions.

gcc/fortran/ChangeLog:

* expr.cc (free_expr0): Free also BOZ strings as part of an expression.

19 months agoc++: outer 'this' leaking into local class [PR106969]
Patrick Palka [Fri, 24 Mar 2023 18:51:24 +0000 (14:51 -0400)]
c++: outer 'this' leaking into local class [PR106969]

Here when resolving the implicit object for '&wrapped' within the
local class Foo, we expect to obtain a dummy object of type Foo& since
there's no 'this' available in this context.  And yet at this point
current_class_ref still corresponds to the outer class Context (and is
const), which confuses maybe_dummy_object into propagating the cv-quals
of current_class_ref and returning an object of type const Foo&.  Thus
decltype(&wrapped) wrongly yields const int* instead of int*.

The problem ultimately seems to be that the 'this' from the enclosing
class appears available for use when parsing the local class, but 'this'
shouldn't persist across classes like that.  This patch fixes this by
clearing current_class_ptr/ref before parsing a class definition.

After this change, for the test name-clash11.C in C++98 mode we would
now complain about an invalid use of 'this' in e.g.

  ASSERT (sizeof (this->A) == 16);

due to the way the test defines the ASSERT macro via a local class.
This patch redefines the macro using a local typedef instead.

PR c++/106969

gcc/cp/ChangeLog:

* parser.cc (cp_parser_class_specifier): Clear current_class_ptr
and current_class_ref sooner, before parsing a class definition.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/name-clash11.C: Fix ASSERT macro definition in
C++98 mode.
* g++.dg/lookup/this2.C: New test.

19 months agolibatomic: Fix SEQ_CST 128-bit atomic load [PR108891]
Wilco Dijkstra [Fri, 10 Feb 2023 17:41:05 +0000 (17:41 +0000)]
libatomic: Fix SEQ_CST 128-bit atomic load [PR108891]

The LSE2 ifunc for 16-byte atomic load requires a barrier before the LDP -
without it, it effectively has Load-AcquirePC semantics similar to LDAPR,
which is less restrictive than what __ATOMIC_SEQ_CST requires.  This patch
fixes this and adds comments to make it easier to see which sequence is
used for each case.  Use a load/store exclusive loop for store to simplify
testing memory ordering is correct (it is slightly faster too).

libatomic/
PR libgcc/108891
* config/linux/aarch64/atomic_16.S: Fix libat_load_16_i1.
Add comments describing the memory order.

19 months agolibgomp.texi: Fix wording in GCN offload specifics
Tobias Burnus [Fri, 24 Mar 2023 16:32:59 +0000 (17:32 +0100)]
libgomp.texi: Fix wording in GCN offload specifics

libgomp/
* libgomp.texi (Offload-Target Specifics): Grammar fix.

19 months agoc++: default template arg, partial ordering [PR105481]
Jason Merrill [Thu, 23 Mar 2023 22:20:52 +0000 (18:20 -0400)]
c++: default template arg, partial ordering [PR105481]

The default argument code in type_unification_real was assuming that all
targs we've deduced by that point are non-dependent, but that's not the case
for partial ordering.

PR c++/105481

gcc/cp/ChangeLog:

* pt.cc (type_unification_real): Adjust for partial ordering.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/fntmpdefarg-partial1.C: New test.

19 months agoAdd caveat/safeguard to OpenMP: Handle descriptors in target's firstprivate [PR104949]
Thomas Schwinge [Thu, 23 Mar 2023 11:32:35 +0000 (12:32 +0100)]
Add caveat/safeguard to OpenMP: Handle descriptors in target's firstprivate [PR104949]

Follow-up to commit 49d1a2f91325fa8cc011149e27e5093a988b3a49
"OpenMP: Handle descriptors in target's firstprivate [PR104949]".

PR fortran/104949
libgomp/
* target.c (gomp_map_vars_internal) <GOMP_MAP_FIRSTPRIVATE>: Add
caveat/safeguard.

19 months agojson: preserve key-insertion order [PR109163]
David Malcolm [Fri, 24 Mar 2023 15:38:14 +0000 (11:38 -0400)]
json: preserve key-insertion order [PR109163]

PR other/109163 notes that when we write out JSON files, we traverse
the keys within each object via hash_map iteration, and thus the
ordering is non-deterministic - it can arbitrarily vary from run to
run and from different machines, making it harder for users to compare
results and determine if anything has "really" changed.

I'm running into this issue with SARIF output, but there are several
places where we're currently emitting JSON:

  * -fsave-optimization-record emits SRCFILE.opt-record.json.gz
"This option is experimental and the format of the data within
the compressed JSON file is subject to change."; see
optinfo-emit-json.{h,cc}, dumpfile.cc, etc
  * -fdiagnostics-format= with the various "sarif" and "json" options
  * -fdump-analyzer-json is a developer option in the analyzer
  * gcov has:
     "-j, --json-format: Output JSON intermediate format into
     .gcov.json.gz file"

This patch adds an auto_vec to class json::object to preserve
key-insertion order, and use it when writing out objects.  Potentially
this slightly slows down JSON output, but I believe that this isn't
normally a bottleneck, and that the benefits to the user of
deterministic output are worth it.

I had first attempted to use ordered_hash_map.h for this, but ran into
impenetrable template errors, so this patch uses a simpler approach of
just adding an auto_vec to json::object.

Testing showed a failure of diagnostic-format-json-5.c, which was using
a convoluted set of regexps to consume the output; I believe that this
was brittle, and was intermittently failing for some of the random
orderings of output.  I rewrote these regexps to work with the expected
output order.  The other such tests seem to pass with the
now-deterministic orderings.

gcc/ChangeLog:
PR other/109163
* json.cc: Update comments to indicate that we now preserve
insertion order of keys within objects.
(object::print): Traverse keys in insertion order.
(object::set): Preserve insertion order of keys.
(selftest::test_writing_objects): Add an additional key to verify
that we preserve insertion order.
* json.h (object::m_keys): New field.

gcc/testsuite/ChangeLog:
PR other/109163
* c-c++-common/diagnostic-format-json-1.c: Update comment.
* c-c++-common/diagnostic-format-json-2.c: Likewise.
* c-c++-common/diagnostic-format-json-3.c: Likewise.
* c-c++-common/diagnostic-format-json-4.c: Likewise.
* c-c++-common/diagnostic-format-json-5.c: Rewrite regexps.
* c-c++-common/diagnostic-format-json-stderr-1.c: Update comment.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
19 months agoRanger cache dominator queries should ignore backedges.
Andrew MacLeod [Thu, 23 Mar 2023 14:28:34 +0000 (10:28 -0400)]
Ranger cache dominator queries should ignore backedges.

When querying dominators for cache values, ignore back edges in
read-only mode.

PR tree-optimization/109238
gcc/
* gimple-range-cache.cc (ranger_cache::resolve_dom): Ignore
predecessors which this block dominates.

gcc/testsuite/
* gcc.dg/pr109238.c: New.

19 months agotree-optimization/106912 - clear const attribute from fntype
Richard Biener [Thu, 16 Mar 2023 12:51:19 +0000 (13:51 +0100)]
tree-optimization/106912 - clear const attribute from fntype

The following makes sure that after clearing pure/const from
instrumented function declarations we are adjusting call statements
fntype as well to handle indirect calls and because gimple_call_flags
looks at both decl and fntype.

Like the pure/const flag clearing on decls we refrain from touching
calls to known functions that do not have a body in the current TU.

PR tree-optimization/106912
* tree-profile.cc (tree_profiling): Update stmts only when
profiling or testing coverage.  Make sure to update calls
fntype, stripping 'const' there.

* gcc.dg/profile-generate-4.c: New testcase.

19 months agomodula2: Enable iso-extended-opaque-run-pass.exp to build library tests
Gaius Mulley [Fri, 24 Mar 2023 12:16:44 +0000 (12:16 +0000)]
modula2: Enable iso-extended-opaque-run-pass.exp to build library tests

This patch fixes the tcl test script iso-extended-opaque-run-pass.exp so
that the test library modules are built and included with the link command.

gcc/testsuite/ChangeLog:

* gm2/projects/iso/small/run/pass/iso-extended-opaque-run-pass.exp:
Compile object for stressset.mod and testlib.mod.  Add test so
that we only link these objects with test application objects.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>