Jonathan Wakely [Mon, 21 Nov 2022 14:12:52 +0000 (14:12 +0000)]
libstdc++: Improve Doxygen comments in <tuple>
libstdc++-v3/ChangeLog:
* include/std/tuple: Add better Doxygen comments.
Dimitar Dimitrov [Fri, 18 Nov 2022 19:59:42 +0000 (21:59 +0200)]
testsuite: Add filter for target socket support
The new analyzer tests for sockets are failing on embedded targets.
The newlib and avr-libc C libraries do not support sockets.
Testing done:
- No changes in gcc.sum for x86_64-pc-linux-gnu, with or without this
patch.
- Filtered cases are now UNSUPPORTED instead of failing on AVR and PRU
backends.
gcc/ChangeLog:
* doc/sourcebuild.texi (sockets): Document new check.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/fd-accept.c: Require sockets.
* gcc.dg/analyzer/fd-bind.c: Ditto.
* gcc.dg/analyzer/fd-connect.c: Ditto.
* gcc.dg/analyzer/fd-datagram-socket.c: Ditto.
* gcc.dg/analyzer/fd-glibc-byte-stream-connection-server.c:
Ditto.
* gcc.dg/analyzer/fd-glibc-byte-stream-socket.c: Ditto.
* gcc.dg/analyzer/fd-glibc-datagram-client.c: Ditto.
* gcc.dg/analyzer/fd-glibc-datagram-socket.c: Ditto.
* gcc.dg/analyzer/fd-listen.c: Ditto.
* gcc.dg/analyzer/fd-manpage-getaddrinfo-client.c: Ditto.
* gcc.dg/analyzer/fd-mappage-getaddrinfo-server.c: Ditto.
* gcc.dg/analyzer/fd-socket-meaning.c: Ditto.
* gcc.dg/analyzer/fd-socket-misuse.c: Ditto.
* gcc.dg/analyzer/fd-stream-socket-active-open.c: Ditto.
* gcc.dg/analyzer/fd-stream-socket-passive-open.c: Ditto.
* gcc.dg/analyzer/fd-stream-socket.c: Ditto.
* gcc.dg/analyzer/fd-symbolic-socket.c: Ditto.
* lib/target-supports.exp (check_effective_target_sockets): New
check.
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
Andrew Carlotti [Wed, 9 Nov 2022 15:59:21 +0000 (15:59 +0000)]
Expand comment for tree_niter_desc.max
This requirement is enforced by a gcc_checking_assert in
record_estimate.
gcc/ChangeLog:
* tree-ssa-loop.h (tree_niter_desc): Update comment.
Andrew Carlotti [Mon, 7 Nov 2022 14:35:08 +0000 (14:35 +0000)]
Modify test, to prevent the next patch breaking it
The upcoming c[lt]z idiom recognition patch eliminates the need for a
brute force computation of the iteration count of these loops. The test
is intended to verify that ivcanon can determine the loop count when the
condition is given by a chain of constant computations.
We replace the constant operations with a more complicated chain that should
resist future idiom recognition.
gcc/testsuite/ChangeLog:
* gcc.dg/pr77975.c: Make tests more robust.
Andrew Carlotti [Tue, 4 Oct 2022 17:21:57 +0000 (18:21 +0100)]
Refactor number_of_iterations_popcount
This includes various changes to improve clarity, and to enable the code
to be more similar to the clz and ctz idiom recognition added in
subsequent patches.
We create new number_of_iterations_bitcount function, which will be used
to call the other bit-counting recognition functions added in subsequent
patches, as well as a generic comment describing the loop structures
that are common to each idiom. Some of the variables in
number_of_iterations_popcount are given more descriptive names, and the
popcount expression builder is extracted into a separate function.
As part of the refactoring, we also fix a bug where the max loop count
for modes shorter than an integer would be incorrectly computed as if
the input mode were actually an integer.
We also ensure that niter->max takes into account the final value for
niter->niter (after any folding and simplifying), since if the latter is a
constant, then record_estimate mandates that the two values are equivalent.
gcc/ChangeLog:
* tree-ssa-loop-niter.cc
(number_of_iterations_exit_assumptions): Modify to call...
(number_of_iterations_bitcount): ...this new function.
(number_of_iterations_popcount): Now called by the above.
Refactor, and extract popcount expression builder to...
(build_popcount_expr): this new function.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/popcount-max.c: New test.
Andrew Carlotti [Tue, 4 Oct 2022 17:15:12 +0000 (18:15 +0100)]
Remove prototype for number_of_iterations_popcount
gcc/ChangeLog:
* tree-ssa-loop-niter.cc (ssa_defined_by_minus_one_stmt_p): Move
(number_of_iterations_popcount): Move, and remove separate prototype.
Andrew Carlotti [Thu, 6 Oct 2022 14:59:15 +0000 (15:59 +0100)]
Ensure at_stmt is defined before an early exit
This prevents a null dereference error when outputing debug information
following an early exit from number_of_iterations_exit_assumptions.
gcc/ChangeLog:
* tree-ssa-loop-niter.cc (number_of_iterations_exit_assumptions):
Move at_stmt assignment.
Torbjörn SVENSSON [Tue, 25 Oct 2022 15:04:07 +0000 (17:04 +0200)]
testsuite: Windows paths use \ and not /
Without this patch, the following error is reported on Windows:
In file included from t:\build\arm-none-eabi\include\c++\11.3.1\string:54,
from t:\build\arm-none-eabi\include\c++\11.3.1\bits\locale_classes.h:40,
from t:\build\arm-none-eabi\include\c++\11.3.1\bits\ios_base.h:41,
from t:\build\arm-none-eabi\include\c++\11.3.1\ios:42,
from t:\build\arm-none-eabi\include\c++\11.3.1\ostream:38,
from t:\build\arm-none-eabi\include\c++\11.3.1\iostream:39:
t:\build\arm-none-eabi\include\c++\11.3.1\bits\range_access.h:36:10: note: include 't:\build\arm-none-eabi\include\c++\11.3.1\initializer_list' translated to import
arm-none-eabi-g++.exe: warning: .../gcc/testsuite/g++.dg/modules/pr99023_b.X: linker input file unused because linking not done
FAIL: g++.dg/modules/pr99023_b.X -std=c++2a dg-regexp 6 not found: "[^\n]*: note: include '[^\n]*/initializer_list' translated to import\n"
gcc/testsuite/ChangeLog:
* g++.dg/modules/pr99023_b.X: Match Windows paths too.
Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Tobias Burnus [Mon, 21 Nov 2022 14:22:35 +0000 (15:22 +0100)]
libgomp/gcn: fix/improve struct output
output.printf_data.(value union) contains text[128], which has the size
of 128 bytes, sufficient for 16 uint64_t variables; hence value_u64[2]
could be extended to value_u64[6] - sufficient for all required arguments
to gomp_target_rev. Additionally, next_output.printf_data.(msg union)
contained msg_u64 which then is no longer needed and also caused 32bit
vs 64bit alignment issues.
libgomp/
* config/gcn/libgomp-gcn.h (struct output):
Remove 'msg_u64' from the union, change
value_u64[2] to value_u64[6].
* config/gcn/target.c (GOMP_target_ext): Update accordingly.
* plugin/plugin-gcn.c (process_reverse_offload, console_output):
Likewise.
Torbjörn SVENSSON [Thu, 20 Oct 2022 20:38:57 +0000 (22:38 +0200)]
libcpp/remap: Only override if string matched
For systems with HAVE_DOS_BASED_FILE_SYSTEM set, only override the
pointer if the backslash pattern matches.
Output without this patch:
.../gcc/testsuite/gcc.dg/cpp/pr71681-2.c:5:10: fatal error: a/t2.h: No such file or directory
With patch applied, no output and the test case succeeds.
libcpp/ChangeLog
* files.cc: Ensure pattern matches before use.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Christophe Lyon [Mon, 21 Nov 2022 11:12:14 +0000 (12:12 +0100)]
genmultilib: Fix sanity check
My previous patch to add a sanity check to genmultilib actually
checked the number of dirnames with the number of "sets of options"
rather than the number of options, thus breaking the build on some
targets.
To avoid duplicating once more the loop that constructs the sed
patterns, this patch checks that the current dirname/osdirname is not
empty in the existing loops.
Are there targets where:
if [ "$1" != "${opt}" ]; then
is "legally" executed with an empty $1? (and thus where this patch
would incorrectly trigger an error?)
Sorry for the breakage. Tested on aarch64 by adding an option to
t-aarch64 and no corresponding dirname, and on x86_64.
gcc/ChangeLog:
* genmultilib: Fix options and dirnames/osdirnames sanity check.
Philipp Tomsich [Mon, 21 Nov 2022 11:44:23 +0000 (12:44 +0100)]
RISC-V: Fix ICE in branch<ANYI:mode>_shiftedarith_equals_zero
With the recent improvements to the splitting of special cases of
branch patterns on RISC-V, a dependency on an unmerged/in-discussion
change for branch-equals-zero slipped in: this allowed a non-X mode to
be presented to branch-equals-zero (where only X mode is permissible).
This addresses the issue by wrapping the ANYI operand in a paradoxical
SUBREG:X (the high bits can be safely ignored, as we we perform an
and-immediate before the branch in the pattern).
Tested against the GCC testsuite and committed as obvious.
gcc/ChangeLog:
PR target/107786
* config/riscv/riscv.md
(*branch<ANYI:mode>_shiftedarith_equals_zero): Wrap ANYI
in a subreg, as our branch instructions only supports X.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/pr107786-2.c: New test.
* gcc.target/riscv/pr107786.c: New test.
Eric Botcazou [Wed, 16 Nov 2022 02:58:17 +0000 (03:58 +0100)]
ada: Adjust recent change for returns involving function calls
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Constant>: Revert
latest change.
* gcc-interface/trans.cc (gnat_to_gnu) <N_Object_Declaration>:
Tweak latest change.
Marc Poulhiès [Tue, 15 Nov 2022 15:47:59 +0000 (16:47 +0100)]
ada: Do not share Packed Array Type if sizes of types differ
If a subtype has a Size attribute value different than the size of its
ancestor, then the Packed Array Type can't be shared and a new one must
be created.
gcc/ada/
* exp_pakd.adb (Create_Packed_Array_Impl_Type): Do not share PAT
if sizes of types differ.
Ronan Desplanques [Thu, 17 Nov 2022 13:37:12 +0000 (14:37 +0100)]
ada: Order pragmas alphabetically in reference manual
gcc/ada/
* doc/gnat_rm/implementation_defined_pragmas.rst: Restore
alphabetical ordering.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.
Eric Botcazou [Thu, 17 Nov 2022 12:31:33 +0000 (13:31 +0100)]
ada: Minor tweak in assertion
For an array subtype, being definite is the same as being constrained.
gcc/ada/
* sem_util.adb (Needs_Secondary_Stack): Test Is_Constrained
directly instead of Is_Definite_Subtype for an array subtype.
Steve Baird [Wed, 16 Nov 2022 17:28:22 +0000 (09:28 -0800)]
ada: Internal compiler error for Sequential Partition_Elaboration_Policy
In some cases, compilation of a function with a limited class-wide result
type could fail with an internal error if a Sequential
Partition_Elaboration_Policy is specified. To prevent this, we want specifying
a Sequential Partition_Elaboration_Policy to have the side effect of
imposing a No_Task_Hierarchy restriction. But doing that in a straightforward
way leads to problems with incorrectly accepting violations of H.6(6). So
a new restriction, No_Task_Hierarchy_Implicit, is introduced.
gcc/ada/
* libgnat/s-rident.ads: Define a new restriction,
No_Task_Hierarchy_Implicit. This is like the No_Task_Hierarchy
restriction, but with the difference that setting this restriction
does not mean the H.6(6) post-compilation check is satisified.
* exp_ch6.adb (Add_Task_Actuals_To_Build_In_Place_Call): If it is
known that the function result cannot have tasks, then pass in a
null literal for the activation chain actual parameter. This
avoids generating a reference to an entity that
Build_Activation_Chain_Entity may have chosen not to generate a
declaration for.
* gnatbind.adb (List_Applicable_Restrictions): Do not list the
No_Task_Hierarchy_Implicit restriction.
* restrict.adb: Special treatment for the
No_Task_Hierarchy_Implicit restriction in functions
Get_Restriction_Id and Restriction_Active. The former is needed to
disallow the (unlikely) case that a user tries to explicitly
reference the No_Task_Hierarchy_Implicit restriction.
* sem_prag.adb (Analyze_Pragma): If a Sequential
Partition_Elaboration_Policy is specified (and the
No_Task_Hierarchy restriction is not already enabled), then enable
the No_Task_Hierarchy_Implicit restriction.
Eric Botcazou [Tue, 15 Nov 2022 07:53:46 +0000 (08:53 +0100)]
ada: Small cleanup in Expand_N_Object_Declaration
This reuses a local constant more consistently, removes a duplicate of this
local constant, renames local variables, alphabetizes declarations, makes a
few consistency tweaks and adjusts a couple of comments.
No functional changes.
gcc/ada/
* exp_ch3.adb (Expand_N_Object_Declaration): Use Typ local
constant throughout, remove Ret_Obj_Typ local constant, rename
Ref_Type into Acc_Typ in a couple of places, remove a useless call
to Set_Etype, use a consistent checks suppression scheme, adjust
comments for the sake of consistencty and alphabetize some local
declarations.
* exp_ch6.adb (Expand_Simple_Function_Return): Remove a couple of
redundant local constants.
Steve Baird [Fri, 11 Nov 2022 01:15:33 +0000 (17:15 -0800)]
ada: Ada 2022 Image attribute bugs
Two issues. First, the two procedures
Ada.Strings.Text_Buffers.Output_Mapping.[Wide_]Wide_Put each correctly
call Encode, but that call was missing from the corresponding Put procedure.
Second, if a record type contains an array-valued Data component as well as
both a Max_Length and Current_Length component, then the slice
Data (Current_Length + 1 .. Max_Length) should usually be treated like
uninitialized data. It should not participate in things like equality
comparisons. In particular, it should not participate in 'Image results.
To accomplish this, such a type usually ought to have a Put_Image aspect
specification. This Put_Image aspect specification was missing for the
three Super_String types declared in the
Ada.Strings.[Wide_[Wide_]]Superbounded packages.
gcc/ada/
* libgnat/a-sttebu.adb (Put): Add missing call to Encode.
* libgnat/a-strsup.ads: Declare new Put_Image procedure and add
Put_Image aspect specification for type Super_String.
* libgnat/a-strsup.adb (Put_Image): New procedure.
* libgnat/a-stwisu.ads: Declare new Put_Image procedure and add
Put_Image aspect specification for type Super_String.
* libgnat/a-stwisu.adb (Put_Image): New procedure.
* libgnat/a-stzsup.ads: Declare new Put_Image procedure and add
Put_Image aspect specification for type Super_String.
* libgnat/a-stzsup.adb (Put_Image): New procedure.
Ghjuvan Lacambre [Wed, 16 Nov 2022 14:53:17 +0000 (15:53 +0100)]
ada: Disable subprogram call validation in CodePeer mode
CodePeer builds with assertions enabled started failing when this
validation was introduced. We temporarily disable this validation for
CodePeer in order to buy time before fixing the underlying issue.
gcc/ada/
* frontend.adb (Frontend): Disable subprogram call validation.
Bob Duff [Tue, 15 Nov 2022 18:57:49 +0000 (13:57 -0500)]
ada: Move warnings switches
This patch moves warning switches from Opt into Warnsw, fixes some minor
discrepancies, and cleans up the code.
No change in behavior.
gcc/ada/
* warnsw.ads, warnsw.adb: Move warning flags here from package
Opt. Rename Warning_Record to be Warnings_State. Use an array
instead of a record; this simplifies the code. Add renamings of
all the array components for easy reference outside this package.
Pass the "Family" to Set_Warning_Switch. Use more table-driven
code. Misc cleanup and comment fixes.
* opt.ads: Move warning switches to Warnsw.
* gnat1drv.adb
(Adjust_Global_Switches): Expanded names needed.
* inline.ads: Rename Warning_Record to be Warnings_State.
* sem_ch12.adb: Likewise.
* sem_prag.adb: Use new Set_Warning_Switch.
* contracts.adb, errout.adb, exp_aggr.adb, exp_ch11.adb: Adjust
imports for move to Warnsw.
* exp_ch5.adb, exp_prag.adb, exp_util.adb, frontend.adb: Likewise.
* layout.adb, lib-xref.adb, restrict.adb, scn.adb, sem_aggr.adb:
Likewise.
* sem_attr.adb, sem_case.adb, sem_ch10.adb, sem_ch11.adb:
Likewise.
* sem_ch13.adb, sem_ch3.adb, sem_ch4.adb, sem_ch5.adb: Likewise.
* sem_ch6.adb, sem_ch7.adb, sem_ch8.adb, sem_elab.adb: Likewise.
* sem_eval.adb, sem_res.adb, sem_util.adb, sem_warn.adb: Likewise.
* switch-c.adb: Likewise.
Steve Baird [Wed, 9 Nov 2022 23:53:49 +0000 (15:53 -0800)]
ada: Improve documentation for -gnatw.h warnings
The -gnatw.h option enables warnings about "gaps" in record layout
specifications. In the case of a "partial" layout specification, where the
locations of some components are left unspecified, the resulting warnings
may be incomplete or incorrect. Document this implementation limitation.
gcc/ada/
* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Improve
the description of how the -gnatw.h switch interacts with
"partial" record layout specifications (i.e., specifications where
the locations of some components are left unspecified).
* gnat_ugn.texi: Regenerate.
Marc Poulhiès [Mon, 7 Nov 2022 13:34:54 +0000 (14:34 +0100)]
ada: Reject nonconfirming Size attribute value for aliased object
Only confirming Size must be supported for aliased object of elementary
type (see RM 13.1 in the "Implementation Advice").
-- size is 1-byte
type Y is range 0 .. 20;
type Ay is access all Y;
-- Var size is 8-bytes
Var : aliased Y := 5 with Size => 64;
-- JP.all is a 1-byte reference to an 8-bytes objects.
JP : Ay := Var'Access;
The above JP.all references the first byte of the 8-byte Var object,
which is, for example, not correct on little-endian systems.
This change rejects nonconfirming Size attribute on such objects
instead of miscompiling it.
gcc/ada/
* sem_ch13.adb (Check_One_Attr): produce error when Size attribute
used on aliased object of elementary types with nonconfirming
value.
Ronan Desplanques [Fri, 4 Nov 2022 15:54:35 +0000 (16:54 +0100)]
ada: Fix gnatmake's parsing of adc files
Before this patch, gnatmake's parser for adc files failed to ignore
semicolons located inside comments. This patch fixes that behavior.
gcc/ada/
* sfn_scan.adb (Scan_SFN_Pragmas): Improve handling of comments.
Ronan Desplanques [Wed, 9 Nov 2022 12:32:05 +0000 (13:32 +0100)]
ada: Tweak error messages on misplaced with keywords
Before this patch, with clauses placed in declarative sections were
interpreted by the compiler as incorrect aspect specifications, which
led to confusing error messages.
This patch makes it so more syntax errors involving the with keyword
are diagnosed as intended with clauses instead of aspect
specifications.
gcc/ada/
* par-ch3.adb (P_Declarative_Item): Tweak handling of with keyword.
Jakub Jelinek [Mon, 21 Nov 2022 09:28:27 +0000 (10:28 +0100)]
i386: Uglify some local identifiers in *intrin.h [PR107748]
While reporting PR107748 (where is a problem with non-uglified names,
but I've left it out because it needs fixing anyway), I've noticed
various spots where identifiers in *intrin.h headers weren't uglified.
The following patch fixed those that are related to unions (I've grepped
for [a-zA-Z]\.[a-zA-Z] spots).
The reason we need those to be uglified is the same as why the arguments
of the inlines are __ prefixed and most of automatic vars in the inlines
- say a, v or u aren't part of implementation namespace and so users could
#define u whatever->something
#include <x86intrin.h>
and it should still work, as long as u is not e.g. one of the names
of the functions/macros the header provides (_mm* etc.).
2022-11-21 Jakub Jelinek <jakub@redhat.com>
PR target/107748
* config/i386/avx512fp16intrin.h (_mm512_castph512_ph128,
_mm512_castph512_ph256, _mm512_castph128_ph512,
_mm512_castph256_ph512, _mm512_set1_pch): Uglify names of local
variables and union members.
* config/i386/avx512fp16vlintrin.h (_mm256_castph256_ph128,
_mm256_castph128_ph256, _mm256_set1_pch, _mm_set1_pch): Likewise.
* config/i386/smmintrin.h (_mm_extract_ps): Likewise.
Christophe Lyon [Thu, 27 Oct 2022 08:50:53 +0000 (08:50 +0000)]
genmultilib: Add sanity check
When a list of dirnames is provided to genmultilib, its length is
expected to match the number of options. If this is not the case, the
build fails later for reasons not obviously related to this mistake.
This patch adds a sanity check to help diagnose such cases.
Tested by adding an option to t-aarch64 and no corresponding dirname,
with both bash and dash.
v2: do not use arrays (bash feature).
OK for trunk?
gcc/ChangeLog:
* genmultilib: Add sanity check.
Martin Liska [Mon, 21 Nov 2022 08:17:29 +0000 (09:17 +0100)]
changelog: Fix extra space after tab.
Eric Botcazou [Mon, 21 Nov 2022 06:57:25 +0000 (07:57 +0100)]
Make ARMv8-M attribute cmse_nonsecure_call work in Ada
Unlike most other machine attributes, this one does not work in Ada because,
while it applies to pointer-to-function types, it is explicitly marked as
requiring declarations in the implementation.
Now, in Ada, machine attributes are specified like this:
type Non_Secure is access procedure;
pragma Machine_Attribute (Non_Secure, "cmse_nonsecure_call");
i.e. not attached to the declaration of Non_Secure.
The change extends the support to Ada by also accepting pointer-to-function
types in the handler.
gcc/
* config/arm/arm.cc (arm_attribute_table) <cmse_nonsecure_call>:
Change decl_required field to false.
(arm_handle_cmse_nonsecure_call): Deal with a TYPE node.
gcc/testsuite/
* gnat.dg/machine_attr2.ads, gnat.dg/machine_attr2.adb: New test.
Martin Liska [Mon, 21 Nov 2022 08:16:27 +0000 (09:16 +0100)]
Revert "gcc-changelog: temporarily disable check_line_start"
This reverts commit
0275ff207027954d16e873ccdbd92f9881a14e72.
Martin Liska [Mon, 21 Nov 2022 08:03:35 +0000 (09:03 +0100)]
build: re-configure 2 files
libcpp/ChangeLog:
* config.in: Re-configure.
libstdc++-v3/ChangeLog:
* src/experimental/Makefile.in: Re-configure.
Andrew Pinski [Sat, 19 Nov 2022 20:48:27 +0000 (12:48 -0800)]
Fix PR 106560: Another ICE after conflicting types of redeclaration
This another one of these ICE after error issues with the
gimplifier and a fallout from r12-3278-g823685221de986af.
The problem here is gimplify_modify_expr does not
check if either from or to was an error operand.
This adds the check and fixes the ICE.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
gcc/ChangeLog:
* gimplify.cc (gimplify_modify_expr): If
either *from_p or *to_p were error_operand
return early.
gcc/testsuite/ChangeLog:
* gcc.dg/redecl-23.c: New test.
* gcc.dg/redecl-24.c: New test.
* gcc.dg/redecl-25.c: New test.
liuhongt [Thu, 17 Nov 2022 08:19:31 +0000 (16:19 +0800)]
define builtins for "shared" avxneconvert-avx512bf16vl builtins.
This should fix incorrect error when call those builtin with
-mavxneconvert and w/o -mavx512bf16 -mavx512vl.
gcc/ChangeLog:
* config/i386/i386-builtins.cc (def_builtin): Handle "shared"
avx512bf16vl-avxneconvert builtins.
gcc/testsuite/ChangeLog:
* gcc.target/i386/avxneconvert-1.c: New test.
GCC Administrator [Mon, 21 Nov 2022 00:16:46 +0000 (00:16 +0000)]
Daily bump.
François Dumont [Sat, 19 Nov 2022 12:51:45 +0000 (13:51 +0100)]
libstdc++: Add std qualification on isxdigit calls
Those qualifications are needed in _GLIBCXX_INLINE_VERSION mode because in <cctype>
symbols are not put in versioned namespace.
libstdc++-v3/ChangeLog
* include/std/format: Add std qualification on isxdigit calls.
Patrick Palka [Sun, 20 Nov 2022 18:02:24 +0000 (13:02 -0500)]
c++: cache the normal form of a concept-id
We already cache the overall normal form of a declaration's constraints
(under the assumption that it can't change over the translation unit).
But if we have something like
template<class T> concept complicated = /* ... */;
template<class T> void f() requires complicated<T> && /* ... */;
template<class T> void g() requires complicated<T> && /* ... */;
then despite this high-level caching we'd still redundantly have to
expand the concept-id complicated<T> twice, once during normalization of
f's constraints and again during normalization of g's. Ideally, we'd
reuse the previously computed normal form of complicated<T> the second
time around.
To that end this patch introduces an intermediate layer of caching
during constraint normalization -- caching of the normal form of a
concept-id -- that sits between our high-level caching of the overall
normal form of a declaration's constraints and our low-level caching of
each individual atomic constraint.
It turns out this caching generalizes normalize_concept_check's caching
of the normal form of a concept definition (which is equivalent to the
normal form of the concept-id C<gtargs> where gtargs is C's generic
arguments) so this patch unifies the caching accordingly.
gcc/cp/ChangeLog:
* constraint.cc (struct norm_entry): Define.
(struct norm_hasher): Define.
(norm_cache): Define.
(normalize_concept_check): Add function comment. Cache the
the normal form of the substituted concept-id. Canonicalize
generic arguments as NULL_TREE. Don't coerce arguments unless
they were substituted.
(normalize_concept_definition): Simplify. Use norm_cache
instead of normalized_map.
Patrick Palka [Sun, 20 Nov 2022 18:00:00 +0000 (13:00 -0500)]
c++: remove coerce_innermost_template_parms
The only practical difference between coerce_innermost_template_parms
and the main function coerce_template_parms is that the former accepts
a potentially multi-level parameter list and returns an argument vector
of the same depth, whereas the latter accepts only a single level of
parameters and only returns only a single level of arguments. Both
functions accept a multi-level argument vector.
In light of this, it seems more natural to just overload the behavior of
the main function according to whether the given parameter list is
multi-level or not. And it turns out we can assume the given parms and
args have the same depth in the multi-level case, which simplifies the
overloading logic.
Besides the simplification benefit, another benefit of this unification
is that it avoids an extra copy of a multi-level args since now we can
return new_args directly from c_t_p. (And because of this, we need to
turn new_inner_args into a reference so that overwriting it also updates
new_args.)
gcc/cp/ChangeLog:
* pt.cc (coerce_template_parms): Salvage part of the function
comment from c_innermost_t_p. Handle parms being a full
template parameter list.
(coerce_innermost_template_parms): Remove.
(lookup_template_class): Use c_t_p instead of c_innermost_t_p.
(finish_template_variable): Likewise.
(tsubst_decl): Likewise.
(instantiate_alias_template): Likewise.
Jakub Jelinek [Sun, 20 Nov 2022 16:42:42 +0000 (17:42 +0100)]
reg-stack: Fix a -fcompare-debug bug in reg-stack [PR107183]
As the following testcase shows, the swap_rtx_condition function
in reg-stack can result in different code generation between -g and -g0.
The function is doing the changes as it goes, so does analysis and
changes together, which makes it harder to deal with DEBUG_INSNs,
where normally analysis phase ignores them and the later phase
doesn't.
swap_rtx_condition walks instructions two different ways, one is
using next_flags_user function which stops on non-call instructions
that mention the flags register, and the other is a loop on fnstsw
where it stops on instructions mentioning it and tries to find
sahf instruction that uses it (in both cases calls stop it and so
does end of basic block).
Now both of these currently stop on DEBUG_INSNs that mention
the flags register resp. the fnstsw result register.
On success the function recurses on next flags user instruction
if still live and if the recursion failed, reverts the changes
it did too and fails.
If it were just for the next_flags_user case, the fix could be
just not doing
INSN_CODE (insn) = -1;
if (recog_memoized (insn) == -1)
fail = 1;
on DEBUG_INSNs (assuming all changes to those are fine),
swap_rtx_condition_1 just changes one comparison to a different
one. But due to the possibility of fnstsw result being used
in theory before sahf in some DEBUG_INSNs, this patch takes
a different approach. swap_rtx_condition has now a new argument
and two modes. The first mode is when debug_seen is >= 0, in this
case both next_flags_user and the loop for fnstsw -> sahf will
ignore but note DEBUG_INSNs (that mention flags register or fnstsw
result). If no such DEBUG_INSN is found during the whole call
including recursive invocations (so e.g. for -g0 but probably most
often for -g as well), it behaves as before, if it returns true
all the changes are done and nothing further needs to be done later.
If any DEBUG_INSNs are seen along the way, even when returning success
all the changes are reverted, so it just reports that the function
would be successful if DEBUG_INSNs were ignored.
In this case, compare_for_stack_reg needs to call it again in
debug_seen = -1 mode, which tells the function to update everything
including DEBUG_INSNs. For the fnstsw -> sahf case which I hope
will be very rare I just reset the DEBUG_INSNs, I don't really
know how to express it easily otherwise. For the rest
swap_rtx_condition_1 is done even on the DEBUG_INSNs.
2022-11-20 Jakub Jelinek <jakub@redhat.com>
PR target/107183
* reg-stack.cc (next_flags_user): Add DEBUG_SEEN argument.
If >= 0 and a DEBUG_INSN would be otherwise returned, set
DEBUG_SEEN to 1 and ignore it.
(swap_rtx_condition): Add DEBUG_SEEN argument. In >= 0
mode only set DEBUG_SEEN to 1 if problematic DEBUG_ISNSs
were seen and revert all changes on success in that case.
Don't try to recog_memoized DEBUG_INSNs.
(compare_for_stack_reg): Adjust swap_rtx_condition caller.
If it returns true and debug_seen is 1, call swap_rtx_condition
again with debug_seen -1.
* gcc.dg/ubsan/pr107183.c: New test.
Martin Liska [Mon, 14 Nov 2022 02:26:17 +0000 (03:26 +0100)]
gcc-changelog: temporarily disable check_line_start
contrib/ChangeLog:
* gcc-changelog/git_commit.py: Temporarily disable
check_line.start.
Jeff Law [Sun, 20 Nov 2022 02:21:37 +0000 (19:21 -0700)]
[PR other/104044] Remove extraneous semicolons
gcc/
PR other/104044
* config/mn10300/mn10300.cc (mn10300_print_operand): Remove
extraneous semicolon.
* config/nvptx/nvptx.cc (nvptx_goacc_reduction_fini): Likewise.
gcc/jit/
PR other/104044
* jit-playback.cc (playback::lvale::mark_addressable): Remove
extraeous semicolon
Jeff Law [Sun, 20 Nov 2022 01:47:20 +0000 (20:47 -0500)]
Fix test to not depend on DECL_UIDs
The tester started tripping this on s390-linux-gnu:
Tests that now fail, but worked before (19 tests):
gcc.dg/pr96542.c scan-tree-dump-times evrp "254" 2
The problem is we search for "254" in the dump file. The dump file contains
UIDs for function declarations. So changes in the number of predefined DECL
nodes can make the test pass or file depending on whether or not a decl with
a UID containing "254" shows up. Like this:
;; Function foo (foo, funcdef_no=0, decl_uid=2542, cgraph_uid=1, symbol_order=0)
ISTM the test wants to look for a "return 254" rather than just "254".
I added a change for that to the tester. Naturally that fixed the test on
s390 and the dozen or so targets I tested didn't show any regressions.
gcc/testsuite
* gcc.dg/pr96542.c: Avoid falsely matching DECL_UIDs with
the number 254 in them.
Jonathan Wakely [Thu, 17 Nov 2022 10:21:54 +0000 (10:21 +0000)]
libstdc++: Add always_inline to trivial range access functions
This makes all the [iterator.range] functions always-inline, except the
ones that construct a std::reverse_iterator, as they do a little more
work. They could probably be made always_inline too though, and maybe
the std::reverse_iterator constructor too.
This means that even for -O0 these functions have no runtime overhead
compared with calling a member of the container, or performing pointer
arithmetic for arrays.
libstdc++-v3/ChangeLog:
* include/bits/range_access.h: Add always_inline attribute to
trivial functions.
Andrew Pinski [Fri, 18 Nov 2022 05:05:03 +0000 (05:05 +0000)]
constexprify some tree variables
Since we use C++11 by default now, we can
use constexpr for some const decls in tree-core.h.
This patch does that and it allows for better optimizations
of GCC code with checking enabled and without LTO.
For an example generic-match.cc compiling is speed up due
to the less number of basic blocks and less debugging info
produced. I did not check the speed of compiling the same source
but rather the speed of compiling the old vs new sources here
(but with the same compiler base).
The small slow down in the parsing of the arrays in each TU
is migrated by a speed up in how much code/debugging info
is produced in the end.
Note I looked at generic-match.cc since it is one of the
compiling sources which causes parallel building to stall and
I wanted to speed it up.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
gcc/ChangeLog:
PR middle-end/14840
* tree-core.h (tree_code_type): Constexprify
by including all-tree.def.
(tree_code_length): Likewise.
* tree.cc (tree_code_type): Remove.
(tree_code_length): Remove.
Jonathan Wakely [Fri, 18 Nov 2022 21:06:18 +0000 (21:06 +0000)]
libstdc++: Fix -Wsign-compare warnings in std::format
libstdc++-v3/ChangeLog:
* include/std/format: Fix -Wsign-compare warnings.
Jonathan Wakely [Thu, 17 Nov 2022 10:20:50 +0000 (10:20 +0000)]
libstdc++: Fix Doxygen warning
This fixes a Doxygen warning about a mismatched parameter name. The
standard uses 'r' here, like the Doxygen comment, so use '__r' instead
of '__e'.
libstdc++-v3/ChangeLog:
* include/bits/ptr_traits.h (pointer_traits::pointer_to): Rename
parameter.
Jonathan Wakely [Fri, 18 Nov 2022 21:17:51 +0000 (21:17 +0000)]
libstdc++: Fix one more malformed requires-clause [PR107649]
libstdc++-v3/ChangeLog:
PR libstdc++/107649
* include/std/complex (__complex_proj): Fix requires-clause.
Thomas Schwinge [Fri, 18 Nov 2022 22:57:52 +0000 (23:57 +0100)]
nvptx: In 'STARTFILE_SPEC', fix 'crt0.o' for '-mmainkernel'
A recent nvptx-tools change: commit
886a95faf66bf66a82fc0fe7d2a9fd9e9fec2820
"ld: Don't search for input files in '-L'directories" (of
<https://github.com/MentorEmbedded/nvptx-tools/pull/38>
"Match standard 'ld' "search" behavior") in GCC/nvptx target testing
generally causes linking to fail with:
error opening crt0.o
collect2: error: ld returned 1 exit status
compiler exited with status 1
Indeed per GCC '-v' output, there is an undecorated 'crt0.o' on the linker
('collect2') command line:
[...]/build-gcc/./gcc/collect2 -o [...] crt0.o [...]
This is due to:
gcc/config/nvptx/nvptx.h:#define STARTFILE_SPEC "%{mmainkernel:crt0.o}"
..., and the fix, as used by numerous other GCC targets, is to instead use
'crt0.o%s'; for '%s' means, per 'gcc/gcc.cc', "The Specs Language":
%s current argument is the name of a library or startup file of some sort.
Search for that file in a standard list of directories
and substitute the full name found.
With that, we get the expected path to 'crt0.o'.
gcc/
* config/nvptx/nvptx.h (STARTFILE_SPEC): Fix 'crt0.o' for
'-mmainkernel'.
Bernhard Reutner-Fischer [Thu, 17 Nov 2022 20:40:53 +0000 (21:40 +0100)]
libcpp: Add missing config for --enable-valgrind-annotations [PR107691]
r7-912 copied (parts of) the valgrind annotation checks from gcc
to libcpp. The above copies the missing pieces to libcpp to diagnose
when libcpp is configured with --enable-valgrind-annotations but
valgrind is not installed.
libcpp/ChangeLog:
PR preprocessor/107691
* configure.ac: Add valgrind header checks.
* configure: Regenerate.
Jonathan Wakely [Fri, 11 Nov 2022 12:48:29 +0000 (12:48 +0000)]
jit: Use std::mutex instead of pthread_mutex_t
This allows JIT to be built with a different thread model from posix
where pthread isn't available
By renaming the acquire_mutex () and release_mutex () member functions
to lock() and unlock() we make the playback::context type meet the C++
Lockable requirements. This allows it to be used with a scoped lock
(i.e. RAII) type as std::lock_guard. This automatically releases the
mutex when leaving the scope.
Co-authored-by: LIU Hao <lh_mouse@126.com>
gcc/jit/ChangeLog:
* jit-playback.cc (playback::context::scoped_lock): Define RAII
lock type.
(playback::context::compile): Use scoped_lock to acquire mutex
for the active playback context.
(jit_mutex): Change to std::mutex.
(playback::context::acquire_mutex): Rename to ...
(playback::context::lock): ... this.
(playback::context::release_mutex): Rename to ...
(playback::context::unlock): ... this.
* jit-playback.h (playback::context): Rename members and declare
scoped_lock.
* jit-recording.cc (INCLUDE_PTHREAD_H): Remove unused define.
* libgccjit.cc (version_mutex): Change to std::mutex.
(struct jit_version_info): Use std::lock_guard to acquire and
release mutex.
gcc/ChangeLog:
* system.h [INCLUDE_MUTEX]: Include header for std::mutex.
Tobias Burnus [Sat, 19 Nov 2022 09:36:27 +0000 (10:36 +0100)]
libgomp/gcn: Prepare for reverse-offload callback handling
libgomp/ChangeLog:
* config/gcn/libgomp-gcn.h: New file; contains
struct output, declared previously in plugin-gcn.c.
* config/gcn/target.c: Include it.
(GOMP_ADDITIONAL_ICVS): Declare as extern var.
(GOMP_target_ext): Handle reverse offload.
* plugin/plugin-gcn.c: Include libgomp-gcn.h.
(struct kernargs): Replace struct def by the one
from libgomp-gcn.h for output_data.
(process_reverse_offload): New.
(console_output): Call it.
Jakub Jelinek [Sat, 19 Nov 2022 09:17:01 +0000 (10:17 +0100)]
i386: Outline fast BF -> SF conversion and fix up sNaN handling in it [PR107628]
On Fri, Oct 21, 2022 at 10:23:14AM +0200, Uros Bizjak wrote:
> OK, but now we have two more copies of a function that effectively
> extends BF to SF. Can you please split this utility function out and
> use it here and in cbranchbf4/cstorebf4? I'm talking about this part:
>
> + op = gen_lowpart (HImode, op1);
> + if (CONST_INT_P (op))
> + op = simplify_const_unary_operation (FLOAT_EXTEND, SFmode,
> + op1, BFmode);
> + else
> + {
> + rtx t1 = gen_reg_rtx (SImode);
> + emit_insn (gen_zero_extendhisi2 (t1, op));
> + emit_insn (gen_ashlsi3 (t1, t1, GEN_INT (16)));
> + op = gen_lowpart (SFmode, t1);
> + }
>
> Taking this a bit further, it looks like a generic function to extend
> BF to SF, when extendbfsf2 named function is not defined.
>
> The above could be a follow-up patch, the proposed patch is OK.
Sorry for the delay, only got to this now.
And I'm fixing the sNaN handling in it too. If the argument is a BFmode sNaN
constant, we want in this case just a SFmode sNaN constant, but
simplify_const_unary_operation (FLOAT_EXTEND, ...)
in that case returns NULL (as normally conversions of a sNaN to some
other float type should raise an exception). In this case we want
to bypass that, as we know the sNaN will be used immediately in the SFmode
comparison a few instructions later. The patch fixes it by just
simplifying the lowpart to HImode and its zero extension to SImode, then
force into a pseudo and do the left shift and subreg to SFmode on the
pseudo. CSE or combine can handle it later.
2022-11-19 Jakub Jelinek <jakub@redhat.com>
PR target/107628
* config/i386/i386-protos.h (ix86_expand_fast_convert_bf_to_sf):
Declare.
* config/i386/i386-expand.cc (ix86_expand_fast_convert_bf_to_sf): New
function.
* config/i386/i386.md (cbranchbf4, cstorebf4): Use it.
* gcc.target/i386/pr107628.c: New test.
Jakub Jelinek [Sat, 19 Nov 2022 08:26:44 +0000 (09:26 +0100)]
c++: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions
The following patch implements this paper.
Per further discussions it is implemented for C++23 only, so isn't
treated as a DR, e.g. because the part of the standard the paper is
changing didn't even exist in C++20.
And we gave up on trying to implement it as a pedwarn rather than
error for C++20 and older, because of implicit constexpr lambdas or
-fimplicit-constexpr reasons.
For C++20 and older, the only change is that passing through
definitions of static or thread_local vars usable in constant expressions
is now accepted in statement expressions if they aren't inside of constexpr
or consteval functions.
2022-11-19 Jakub Jelinek <jakub@redhat.com>
gcc/c-family/
* c-cppbuiltin.cc (c_cpp_builtins): Bump __cpp_constexpr
value from 202207L to 202211L.
gcc/cp/
* constexpr.cc (cxx_eval_constant_expression): Implement C++23
P2647R1 - Permitting static constexpr variables in constexpr functions.
Allow DECL_EXPRs of decl_constant_var_p static or thread_local vars.
(potential_constant_expression_1): Similarly, except use
decl_maybe_constant_var_p instead of decl_constant_var_p if
processing_template_decl.
gcc/testsuite/
* g++.dg/cpp23/constexpr-nonlit17.C: New test.
* g++.dg/cpp23/constexpr-nonlit18.C: New test.
* g++.dg/cpp23/feat-cxx2b.C: Adjust expected __cpp_constexpr
value.
* g++.dg/ext/stmtexpr19.C: Don't expect an error.
* g++.dg/ext/stmtexpr25.C: New test.
Jeff Chapman II [Tue, 29 Jun 2021 20:52:56 +0000 (16:52 -0400)]
c++: implement P1492 contracts
Implement the P1492 versions of contracts, along with extensions that
support the emulation of N4820 and other proposals. This implementation
assigns a concrete semantic (one of: ignore, assume, enforce, or
observe) to each contract attribute depending on its labels and
configuration options.
Co-authored-by: Andrew Sutton <asutton@lock3software.com>
Co-authored-by: Andrew Marmaduke <amarmaduke@lock3software.com>
Co-authored-by: Michael Lopez <mlopez@lock3software.com>
Co-authored-by: Jason Merrill <jason@redhat.com>
gcc/ChangeLog:
* doc/invoke.texi: Document contracts flags.
gcc/c-family/ChangeLog:
* c.opt: Add contracts flags.
* c-cppbuiltin.cc (c_cpp_builtins): Add contracts feature-test
macros.
gcc/cp/ChangeLog:
* cp-tree.h (enum cp_tree_index): Add
CPTI_PSEUDO_CONTRACT_VIOLATION.
(pseudo_contract_violation_type): New macro.
(struct saved_scope): Add x_processing_contract_condition.
(processing_contract_condition): New macro.
(comparing_override_contracts): New variable decl.
(find_contract): New inline.
(set_decl_contracts): New inline.
(get_contract_semantic): New inline.
(set_contract_semantic): New inline.
* constexpr.cc (cxx_eval_assert): Split out from...
(cxx_eval_internal_function): ...here.
(cxx_eval_constant_expression): Use it for contracts.
(potential_constant_expression_1): Handle contracts.
* cp-gimplify.cc (cp_genericize_r): Handle contracts.
* cp-objcp-common.cc (cp_tree_size): Handle contracts.
(cp_common_init_ts): Handle contracts.
(cp_handle_option): Handle contracts.
* decl.cc (duplicate_decls): Handle contracts.
(check_tag_decl): Check for bogus contracts.
(start_decl): Check flag_contracts.
(grokfndecl): Call rebuild_postconditions.
(grokdeclarator): Handle contract attributes.
(start_preparsed_function): Call start_function_contracts.
(finish_function): Call finish_function_contracts.
* decl2.cc (cp_check_const_attributes): Skip contracts.
(comdat_linkage): Handle outlined contracts.
* error.cc (dump_type): Handle null TYPE_IDENTIFIER.
* g++spec.cc (EXPERIMENTAL): New macro.
(lang_specific_driver): Add -lstdc++exp if -fcontracts.
* mangle.cc (write_encoding): Handle outlined contracts.
* module.cc (trees_out::fn_parms_init): Handle outlined contracts.
(trees_in::fn_parms_init): Likewise.
(check_mergeable_decl): Likewise.
(module_state_config::get_dialect): Record -fcontracts.
* parser.h (struct cp_unparsed_functions_entry): Add contracts.
* parser.cc (unparsed_contracts): New macro.
(push_unparsed_function_queues): Adjust.
(contract_attribute_p): New.
(cp_parser_statement): Check contracts.
(cp_parser_decl_specifier_seq): Handle contracts.
(cp_parser_skip_to_closing_square_bracket): Split out...
(cp_parser_skip_up_to_closing_square_bracket): ...this fn.
(cp_parser_class_specifier): Do contract late parsing.
(cp_parser_class_head): Check contracts.
(cp_parser_contract_role): New.
(cp_parser_contract_mode_opt): New.
(find_error, contains_error_p): New.
(cp_parser_contract_attribute_spec): New.
(cp_parser_late_contract_condition): New.
(cp_parser_std_attribute_spec): Handle contracts.
(cp_parser_save_default_args): Also save contracts.
* pt.cc (register_parameter_specializations): No longer static.
(register_local_identity): New.
(check_explicit_specialization): Call remove_contract_attributes.
(tsubst_contract, tsubst_contract_attribute): New.
(tsubst_contract_attributes): New.
(tsubst_attribute): Add comment.
(tsubst_copy): Also allow parm when processing_contract_condition.
(tsubst_expr): Handle contracts.
(regenerate_decl_from_template): Handle contracts.
* search.cc (check_final_overrider): Compare contracts.
* semantics.cc (set_cleanup_locs): Skip POSTCONDITION_STMT.
(finish_non_static_data_member): Check contracts.
(finish_this_expr): Check contracts.
(process_outer_var_ref): Handle contracts.
(finish_id_expression_1): Handle contracts.
(apply_deduced_return_type): Adjust contracts.
* tree.cc (handle_contract_attribute): New.
(get_innermost_component, is_this_expression): New.
(comparing_this_references): New.
(equivalent_member_references): New.
(cp_tree_equal): Check it.
* typeck.cc (check_return_expr): Apply contracts.
* Make-lang.in: Add contracts.o.
* config-lang.in: Add contracts.cc.
* cp-tree.def (ASSERTION_STMT, PRECONDITION_STMT)
(POSTCONDITION_STMT): New.
* contracts.h: New file.
* contracts.cc: New file.
gcc/testsuite/ChangeLog:
* g++.dg/modules/modules.exp: Pass dg-options to link command.
* lib/g++.exp: Add -L for libstdc++exp.a.
* g++.dg/contracts/backtrace_handler/assert_fail.cpp: New test.
* g++.dg/contracts/backtrace_handler/handle_contract_violation.cpp: New test.
* g++.dg/contracts/contracts-access1.C: New test.
* g++.dg/contracts/contracts-assume1.C: New test.
* g++.dg/contracts/contracts-assume2.C: New test.
* g++.dg/contracts/contracts-assume3.C: New test.
* g++.dg/contracts/contracts-assume4.C: New test.
* g++.dg/contracts/contracts-assume5.C: New test.
* g++.dg/contracts/contracts-assume6.C: New test.
* g++.dg/contracts/contracts-comdat1.C: New test.
* g++.dg/contracts/contracts-config1.C: New test.
* g++.dg/contracts/contracts-constexpr1.C: New test.
* g++.dg/contracts/contracts-constexpr2.C: New test.
* g++.dg/contracts/contracts-constexpr3.C: New test.
* g++.dg/contracts/contracts-conversion1.C: New test.
* g++.dg/contracts/contracts-ctor-dtor1.C: New test.
* g++.dg/contracts/contracts-ctor-dtor2.C: New test.
* g++.dg/contracts/contracts-cv1.C: New test.
* g++.dg/contracts/contracts-deduced1.C: New test.
* g++.dg/contracts/contracts-deduced2.C: New test.
* g++.dg/contracts/contracts-friend1.C: New test.
* g++.dg/contracts/contracts-ft1.C: New test.
* g++.dg/contracts/contracts-ignore1.C: New test.
* g++.dg/contracts/contracts-ignore2.C: New test.
* g++.dg/contracts/contracts-large-return.C: New test.
* g++.dg/contracts/contracts-multiline1.C: New test.
* g++.dg/contracts/contracts-multiple-inheritance1.C: New test.
* g++.dg/contracts/contracts-multiple-inheritance2.C: New test.
* g++.dg/contracts/contracts-nested-class1.C: New test.
* g++.dg/contracts/contracts-nested-class2.C: New test.
* g++.dg/contracts/contracts-nocopy1.C: New test.
* g++.dg/contracts/contracts-override.C: New test.
* g++.dg/contracts/contracts-post1.C: New test.
* g++.dg/contracts/contracts-post2.C: New test.
* g++.dg/contracts/contracts-post3.C: New test.
* g++.dg/contracts/contracts-post4.C: New test.
* g++.dg/contracts/contracts-post5.C: New test.
* g++.dg/contracts/contracts-post6.C: New test.
* g++.dg/contracts/contracts-pre1.C: New test.
* g++.dg/contracts/contracts-pre10.C: New test.
* g++.dg/contracts/contracts-pre2.C: New test.
* g++.dg/contracts/contracts-pre2a1.C: New test.
* g++.dg/contracts/contracts-pre2a2.C: New test.
* g++.dg/contracts/contracts-pre3.C: New test.
* g++.dg/contracts/contracts-pre4.C: New test.
* g++.dg/contracts/contracts-pre5.C: New test.
* g++.dg/contracts/contracts-pre6.C: New test.
* g++.dg/contracts/contracts-pre7.C: New test.
* g++.dg/contracts/contracts-pre9.C: New test.
* g++.dg/contracts/contracts-redecl1.C: New test.
* g++.dg/contracts/contracts-redecl2.C: New test.
* g++.dg/contracts/contracts-redecl3.C: New test.
* g++.dg/contracts/contracts-redecl4.C: New test.
* g++.dg/contracts/contracts-redecl5.C: New test.
* g++.dg/contracts/contracts-redecl6.C: New test.
* g++.dg/contracts/contracts-redecl7.C: New test.
* g++.dg/contracts/contracts-redecl8.C: New test.
* g++.dg/contracts/contracts-tmpl-attr1.C: New test.
* g++.dg/contracts/contracts-tmpl-spec1.C: New test.
* g++.dg/contracts/contracts-tmpl-spec2.C: New test.
* g++.dg/contracts/contracts-tmpl-spec3.C: New test.
* g++.dg/contracts/contracts1.C: New test.
* g++.dg/contracts/contracts10.C: New test.
* g++.dg/contracts/contracts11.C: New test.
* g++.dg/contracts/contracts12.C: New test.
* g++.dg/contracts/contracts13.C: New test.
* g++.dg/contracts/contracts14.C: New test.
* g++.dg/contracts/contracts15.C: New test.
* g++.dg/contracts/contracts16.C: New test.
* g++.dg/contracts/contracts17.C: New test.
* g++.dg/contracts/contracts18.C: New test.
* g++.dg/contracts/contracts19.C: New test.
* g++.dg/contracts/contracts2.C: New test.
* g++.dg/contracts/contracts20.C: New test.
* g++.dg/contracts/contracts22.C: New test.
* g++.dg/contracts/contracts24.C: New test.
* g++.dg/contracts/contracts25.C: New test.
* g++.dg/contracts/contracts3.C: New test.
* g++.dg/contracts/contracts35.C: New test.
* g++.dg/contracts/contracts4.C: New test.
* g++.dg/contracts/contracts5.C: New test.
* g++.dg/contracts/contracts6.C: New test.
* g++.dg/contracts/contracts7.C: New test.
* g++.dg/contracts/contracts8.C: New test.
* g++.dg/contracts/contracts9.C: New test.
* g++.dg/modules/contracts-1_a.C: New test.
* g++.dg/modules/contracts-1_b.C: New test.
* g++.dg/modules/contracts-2_a.C: New test.
* g++.dg/modules/contracts-2_b.C: New test.
* g++.dg/modules/contracts-2_c.C: New test.
* g++.dg/modules/contracts-3_a.C: New test.
* g++.dg/modules/contracts-3_b.C: New test.
* g++.dg/modules/contracts-4_a.C: New test.
* g++.dg/modules/contracts-4_b.C: New test.
* g++.dg/modules/contracts-4_c.C: New test.
* g++.dg/modules/contracts-4_d.C: New test.
* g++.dg/modules/contracts-tpl-friend-1_a.C: New test.
* g++.dg/modules/contracts-tpl-friend-1_b.C: New test.
* g++.dg/contracts/backtrace_handler/Makefile: New test.
* g++.dg/contracts/backtrace_handler/README: New test.
* g++.dg/contracts/backtrace_handler/example_out.txt: New test.
* g++.dg/contracts/backtrace_handler/example_pretty.txt: New test.
* g++.dg/contracts/backtrace_handler/prettytrace.sh: New test.
* g++.dg/contracts/except_preload_handler/Makefile: New test.
* g++.dg/contracts/except_preload_handler/README: New test.
* g++.dg/contracts/except_preload_handler/assert_fail.cpp: New test.
* g++.dg/contracts/except_preload_handler/handle_contract_violation.cpp: New test.
* g++.dg/contracts/noexcept_preload_handler/Makefile: New test.
* g++.dg/contracts/noexcept_preload_handler/README: New test.
* g++.dg/contracts/noexcept_preload_handler/assert_fail.cpp: New test.
* g++.dg/contracts/noexcept_preload_handler/handle_contract_violation.cpp: New test.
* g++.dg/contracts/preload_handler/Makefile: New test.
* g++.dg/contracts/preload_handler/README: New test.
* g++.dg/contracts/preload_handler/assert_fail.cpp: New test.
* g++.dg/contracts/preload_handler/handle_contract_violation.cpp: New test.
* g++.dg/contracts/preload_nocontinue_handler/Makefile: New test.
* g++.dg/contracts/preload_nocontinue_handler/README: New test.
* g++.dg/contracts/preload_nocontinue_handler/assert_fail.cpp: New test.
* g++.dg/contracts/preload_nocontinue_handler/handle_contract_violation.cpp: New test.
* g++.dg/contracts/preload_nocontinue_handler/nocontinue.cpp: New test.
Jeff Chapman II [Thu, 3 Nov 2022 19:47:19 +0000 (15:47 -0400)]
libstdc++: add experimental Contracts support
This patch adds the library support for the experimental C++ Contracts
implementation. This now consists only of a default definition of the
violation handler, which users can override through defining their own
version. To avoid ABI stability problems with libstdc++.so this is added to
a separate -lstdc++exp static library, which the driver knows to add when it
sees -fcontracts.
Co-authored-by: Andrew Marmaduke <amarmaduke@lock3software.com>
Co-authored-by: Jason Merrill <jason@redhat.com>
libstdc++-v3/ChangeLog:
* acinclude.m4 (glibcxx_SUBDIRS): Add src/experimental.
* include/Makefile.am (experimental_headers): Add contract.
* include/Makefile.in: Regenerate.
* src/Makefile.am (SUBDIRS): Add experimental.
* src/Makefile.in: Regenerate.
* configure: Regenerate.
* src/experimental/contract.cc: New file.
* src/experimental/Makefile.am: New file.
* src/experimental/Makefile.in: New file.
* include/experimental/contract: New file.
David Malcolm [Sat, 19 Nov 2022 00:38:25 +0000 (19:38 -0500)]
analyzer: fix feasibility false +ve on jumps through function ptrs [PR107582]
PR analyzer/107582 reports a false +ve from
-Wanalyzer-use-of-uninitialized-value where
the analyzer's feasibility checker erroneously decides
that point (B) in the code below is reachable, with "x" being
uninitialized there:
pthread_cleanup_push(func, NULL);
while (ret != ETIMEDOUT)
ret = rand() % 1000;
/* (A): after the while loop */
if (ret != ETIMEDOUT)
x = &z;
pthread_cleanup_pop(1);
if (ret == ETIMEDOUT)
return 0;
/* (B): after not bailing out */
due to these contradictionary conditions somehow both holding:
* (ret == ETIMEDOUT), at (A) (skipping the initialization of x), and
* (ret != ETIMEDOUT), at (B)
The root cause is that after the while loop, state merger puts ret in
the exploded graph in an UNKNOWN state, and saves the diagnostic at (B).
Later, as we explore the feasibilty of reaching the enode for (B),
dynamic_call_info_t::update_model is called to push/pop the
frames for handling the call to "func" in pthread_cleanup_pop.
The "ret" at these nodes in the feasible_graph has a conjured_svalue for
"ret", and a constraint on it being either == *or* != ETIMEDOUT.
However dynamic_call_info_t::update_model blithely clobbers the
model with a copy from the exploded_graph, in which "ret" is UNKNOWN.
This patch fixes dynamic_call_info_t::update_model so that it
simulates pushing/popping a frame on the model we're working with,
preserving knowledge of the constraint on "ret", and enabling the
analyzer to "know" that the bail-out must happen.
Doing so fixes the false positive.
gcc/analyzer/ChangeLog:
PR analyzer/107582
* engine.cc (dynamic_call_info_t::update_model): Update the model
by pushing or pop a frame, rather than by clobbering it with the
model from the exploded_node's state.
gcc/testsuite/ChangeLog:
PR analyzer/107582
* gcc.dg/analyzer/feasibility-4.c: New test.
* gcc.dg/analyzer/feasibility-pr107582-1.c: New test.
* gcc.dg/analyzer/feasibility-pr107582-2.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Fri, 18 Nov 2022 21:59:12 +0000 (16:59 -0500)]
analyzer: move more impl_* to known_function
Fix a missing check that the argument to __analyzer_dump_capacity must
be a pointer type (which would otherwise lead to an ICE).
Do so by using the known_function_manager rather than by doing lots of
string matching. Do the same for many other functions.
Doing so moves the type-checking closer to the logic that makes use
of it, by putting them in the same class, rather than splitting them
up between two source files (and sometimes three, e.g. for "pipe").
I hope this reduces the number of missing checks.
gcc/analyzer/ChangeLog:
* analyzer.cc (is_pipe_call_p): Delete.
* analyzer.h (is_pipe_call_p): Delete.
* region-model-impl-calls.cc (call_details::get_location): New.
(class kf_analyzer_break): New, adapted from
region_model::on_stmt_pre.
(region_model::impl_call_analyzer_describe): Convert to...
(class kf_analyzer_describe): ...this.
(region_model::impl_call_analyzer_dump_capacity): Convert to...
(class kf_analyzer_dump_capacity): ...this.
(region_model::impl_call_analyzer_dump_escaped): Convert to...
(class kf_analyzer_dump_escaped): ...this.
(class kf_analyzer_dump_exploded_nodes): New.
(region_model::impl_call_analyzer_dump_named_constant): Convert
to...
(class kf_analyzer_dump_named_constant): ...this.
(class dump_path_diagnostic): Move here from region-model.cc.
(class kf_analyzer_dump_path) New, adapted from
region_model::on_stmt_pre.
(class kf_analyzer_dump_region_model): Likewise.
(region_model::impl_call_analyzer_eval): Convert to...
(class kf_analyzer_eval): ...this.
(region_model::impl_call_analyzer_get_unknown_ptr): Convert to...
(class kf_analyzer_get_unknown_ptr): ...this.
(class known_function_accept): Rename to...
(class kf_accept): ...this.
(class known_function_bind): Rename to...
(class kf_bind): ...this.
(class known_function_connect): Rename to...
(class kf_connect): ...this.
(region_model::impl_call_errno_location): Convert to...
(class kf_errno_location): ...this.
(class known_function_listen): Rename to...
(class kf_listen): ...this.
(region_model::impl_call_pipe): Convert to...
(class kf_pipe): ...this.
(region_model::impl_call_putenv): Convert to...
(class kf_putenv): ...this.
(region_model::impl_call_operator_new): Convert to...
(class kf_operator_new): ...this.
(region_model::impl_call_operator_delete): Convert to...
(class kf_operator_delete): ...this.
(class known_function_socket): Rename to...
(class kf_socket): ...this.
(register_known_functions): Rename param to KFM. Break out
existing known functions into a "POSIX" section, and add "pipe",
"pipe2", and "putenv". Add debugging functions
"__analyzer_break", "__analyzer_describe",
"__analyzer_dump_capacity", "__analyzer_dump_escaped",
"__analyzer_dump_exploded_nodes",
"__analyzer_dump_named_constant", "__analyzer_dump_path",
"__analyzer_dump_region_model", "__analyzer_eval",
"__analyzer_get_unknown_ptr". Add C++ support functions
"operator new", "operator new []", "operator delete", and
"operator delete []".
* region-model.cc (class dump_path_diagnostic): Move to
region-model-impl-calls.cc.
(region_model::on_stmt_pre): Eliminate special-casing of
"__analyzer_describe", "__analyzer_dump_capacity",
"__analyzer_dump_escaped", "__analyzer_dump_named_constant",
"__analyzer_dump_path", "__analyzer_dump_region_model",
"__analyzer_eval", "__analyzer_break",
"__analyzer_dump_exploded_nodes", "__analyzer_get_unknown_ptr",
"__errno_location", "pipe", "pipe2", "putenv", "operator new",
"operator new []", "operator delete", "operator delete []"
"pipe" and "pipe2", handling them instead via the known_functions
mechanism.
* region-model.h (call_details::get_location): New decl.
(region_model::impl_call_analyzer_describe): Delete decl.
(region_model::impl_call_analyzer_dump_capacity): Delete decl.
(region_model::impl_call_analyzer_dump_escaped): Delete decl.
(region_model::impl_call_analyzer_dump_named_constant): Delete decl.
(region_model::impl_call_analyzer_eval): Delete decl.
(region_model::impl_call_analyzer_get_unknown_ptr): Delete decl.
(region_model::impl_call_errno_location): Delete decl.
(region_model::impl_call_pipe): Delete decl.
(region_model::impl_call_putenv): Delete decl.
(region_model::impl_call_operator_new): Delete decl.
(region_model::impl_call_operator_delete): Delete decl.
* sm-fd.cc: Update comments.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/analyzer-debugging-fns-1.c: New test.
* gcc.dg/analyzer/attr-const-3.c: Increase the
"analyzer-max-svalue-depth" from 0 to 4 to ensure that
"__analyzer_eval" is recognized.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Philipp Tomsich [Sun, 16 Oct 2022 08:51:47 +0000 (10:51 +0200)]
RISC-V: No extensions for SImode min/max against safe constant
Optimize the common case of a SImode min/max against a constant
that is safe both for sign- and zero-extension.
E.g., consider the case
int f(unsigned int* a)
{
const int C = 1000;
return *a * 3 > C ? C : *a * 3;
}
where the constant C will yield the same result in DImode whether
sign- or zero-extended.
This should eventually go away once the lowering to RTL smartens up
and considers the precision/signedness and the value-ranges of the
operands to MIN_EXPR and MAX_EXPR.
gcc/ChangeLog:
* config/riscv/bitmanip.md (*minmax): Additional pattern for
min/max against constants that are extension-invariant.
* config/riscv/iterators.md (minmax_optab): Add an iterator
that has only min and max rtl.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zbb-min-max-02.c: New test.
Philipp Tomsich [Sun, 16 Oct 2022 10:48:26 +0000 (12:48 +0200)]
RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs
Use Zbs when generating a sequence for
"if ((a & twobits) == singlebit) ..."
that can be expressed as
bexti + bexti + andn.
gcc/ChangeLog:
* config/riscv/bitmanip.md
(*branch<X:mode>_mask_twobits_equals_singlebit):
Handle "if ((a & T) == C)" using Zbs, when T has 2 bits set and C
has one of these tow bits set.
* config/riscv/predicates.md (const_twobits_not_arith_operand):
New predicate.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zbs-if_then_else-01.c: New test.
Philipp Tomsich [Tue, 11 Oct 2022 21:42:48 +0000 (23:42 +0200)]
RISC-V: Use bseti/bclri/binvi to extend reach of ori/andi/xori
Sequences of the form "a | C" and "a ^ C" with C being the positive
half of a signed immediate's range with one extra bit set in addition
are mapped to ori/xori and one bseti/binvi to avoid using a temporary
(and a multi-insn sequence to load C into that temporary).
Something similar holds for "a & ~C" being representable as either
bclri + bclri or bclri + andi.
gcc/ChangeLog:
* config/riscv/bitmanip.md (*<or_optab>i<mode>_extrabit):
New pattern for binvi+binvi/xori and bseti+bseti/ori
(*andi<mode>_extrabit): New pattern for bclri+bclri/andi
* config/riscv/iterators.md (any_or): Match or and ior
* config/riscv/predicates.md (const_twobits_operand):
New predicate.
(uimm_extra_bit_operand): New predicate.
(uimm_extra_bit_or_twobits): New predicate.
(not_uimm_extra_bit_operand): New predicate.
(not_uimm_extra_bit_or_nottwobits): New predicate.
* config/riscv/riscv.h (UIMM_EXTRA_BIT_OPERAND):
Helper for the uimm_extra_bit_operand and
not_uimm_extra_bit_operand predicates.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zbs-bclri.c: Rename
* gcc.target/riscv/zbs-bclri-01.c: Renamed from above.
* gcc.target/riscv/zbs-bclri-02.c: New test.
* gcc.target/riscv/zbs-binvi.c: New test.
* gcc.target/riscv/zbs-bseti.c: New test.
Philipp Tomsich [Wed, 14 Sep 2022 12:16:27 +0000 (14:16 +0200)]
RISC-V: Optimize slli(.uw)? + addw + zext.w into sh[123]add + zext.w
gcc/ChangeLog:
* config/riscv/bitmanip.md: Handle corner-cases for combine
when chaining slli(.uw)? + addw
* config/riscv/riscv-protos.h (riscv_shamt_matches_mask_p):
Define prototype.
* config/riscv/riscv.cc (riscv_shamt_matches_mask_p):
Helper for evaluating the relationship between two operands.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zba-shNadd-04.c: New test.
Philipp Tomsich [Tue, 8 Nov 2022 19:45:51 +0000 (20:45 +0100)]
RISC-V: split to allow formation of sh[123]add before 32bit divw
When using strength-reduction, we will reduce a multiplication to a
sequence of shifts and adds. If this is performed with 32-bit types
and followed by a division, the lack of w-form sh[123]add will make
combination impossible and lead to a slli + addw being generated.
Split the sequence with the knowledge that a w-form div will perform
implicit sign-extensions.
gcc/ChangeLog:
* config/riscv/bitmanip.md: Add a define_split to optimize
slliw + addiw + divw into sh[123]add + divw.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zba-shNadd-05.c: New test.
Philipp Tomsich [Tue, 11 Oct 2022 13:50:11 +0000 (15:50 +0200)]
RISC-V: Optimize branches testing a bit-range or a shifted immediate
gcc/ChangeLog:
* config/riscv/predicates.md (shifted_const_arith_operand): New predicate.
(uimm_extra_bit_operand): New predicate.
* config/riscv/riscv.md (*branch<ANYI:mode>_shiftedarith_equals_zero):
New pattern.
(*branch<ANYI:mode>_shiftedmask_equals_zero): New pattern.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/branch-1.c: New test.
Philipp Tomsich [Mon, 10 Oct 2022 20:24:02 +0000 (22:24 +0200)]
RISC-V: allow bseti on SImode without sign-extension
As long as the SImode operand is not a partial subreg, we can use a
bseti without postprocessing to or in a bit, as the middle end is
smart enough to stay away from the signbit.
gcc/ChangeLog:
* config/riscv/bitmanip.md (*bsetidisi): New pattern.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zbs-bseti-02.c: New test.
Richard Purdie [Fri, 18 Nov 2022 20:13:50 +0000 (13:13 -0700)]
libcpp: Avoid remapping filenames within directives
Code such as:
#include __FILE__
can interact poorly with the *-prefix-map options when cross compiling. In
general you're after to remap filenames for use in target context but the
local paths should be used to find include files at compile time. Ingoring
filename remapping for directives allows avoiding such failures.
Fix this to improve such usage and then document this against file-prefix-map
(referenced by the other *-prefix-map options) to make the behaviour clear
and defined.
libcpp/ChangeLog:
* macro.cc (_cpp_builtin_macro_text): Don't remap filenames within
directives.
gcc/ChangeLog:
* doc/invoke.texi: Document prefix-maps don't affect directives.
Jakub Jelinek [Fri, 18 Nov 2022 18:21:17 +0000 (19:21 +0100)]
Manually add entries for r13-4128.
Aldo, replace some invalid tab + 2 spaces with just tab.
Harald Anlauf [Thu, 17 Nov 2022 20:36:49 +0000 (21:36 +0100)]
Fortran: reject NULL actual argument without explicit interface [PR107576]
gcc/fortran/ChangeLog:
PR fortran/107576
* interface.cc (gfc_procedure_use): Reject NULL as actual argument
when there is no explicit procedure interface.
gcc/testsuite/ChangeLog:
PR fortran/107576
* gfortran.dg/null_actual_3.f90: New test.
GCC Administrator [Fri, 18 Nov 2022 18:09:19 +0000 (18:09 +0000)]
Daily bump.
Jakub Jelinek [Fri, 18 Nov 2022 18:05:06 +0000 (19:05 +0100)]
Add another commit to ignore
We can't handle r13-4128-g1957bedf29a1b2cc231972aba680fe80199d5498
* gcc-changelog/git_update_version.py: Add
1957bedf29a1b2cc231972aba680fe80199d5498 to ignored commits.
Andrew Pinski [Thu, 17 Nov 2022 22:03:08 +0000 (22:03 +0000)]
Fix PR middle-end/107705: ICE after reclaration error
The problem here is after we created a call expression
in the C front-end, we replace the decl type with
an error mark node. We then end up calling
aggregate_value_p with the call expression
with the decl with the error mark as the type
and we ICE.
The fix is to check the function type
after we process the call expression inside
aggregate_value_p to get it.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
Thanks,
Andrew Pinski
gcc/ChangeLog:
PR middle-end/107705
* function.cc (aggregate_value_p): Return 0 if
the function type was an error operand.
gcc/testsuite/ChangeLog:
* gcc.dg/redecl-22.c: New test.
Andrew Pinski [Thu, 17 Nov 2022 22:08:07 +0000 (22:08 +0000)]
Fix PRs 106764, 106765, and 107307, all ICE after invalid re-declaration
The problem here is the gimplifier returns GS_ERROR but
in some cases we don't check that soon enough and try
to do other work which could crash.
So the fix in these two cases is to return GS_ERROR
early if the gimplify_* functions had return GS_ERROR.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
Thanks,
Andrew Pinski
gcc/ChangeLog:
PR c/106764
PR c/106765
PR c/107307
* gimplify.cc (gimplify_compound_lval): Return GS_ERROR
if gimplify_expr had return GS_ERROR.
(gimplify_call_expr): Likewise.
gcc/testsuite/ChangeLog:
PR c/106764
PR c/106765
PR c/107307
* gcc.dg/redecl-19.c: New test.
* gcc.dg/redecl-20.c: New test.
* gcc.dg/redecl-21.c: New test.
Yixuan Chen [Fri, 18 Nov 2022 15:47:11 +0000 (08:47 -0700)]
Fix testcase for architectures that use .srodata
gcc/testsuite:
* gcc.dg/pr25521.c: Fix testcase for architectures that use .srodata.
Kyrylo Tkachov [Fri, 18 Nov 2022 14:29:36 +0000 (14:29 +0000)]
aarch64: Fix LDAPURS assembly output
... And another follow-up once I realised that the sign-extending load, of course,
needs to have strictly an X-reg as a destination for DImode extensions and a W-reg
for SImode ones.
Tested on aarch64-none-linux.
gcc/ChangeLog:
* config/aarch64/atomics.md (*aarch64_atomic_load<ALLX:mode>_rcpc_sext):
Use <GPI:w> for destination format.
* config/aarch64/iterators.md (w_sz): Delete.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/ldapr-sext.c: Adjust expected output.
Torbjörn SVENSSON [Thu, 22 Sep 2022 20:14:24 +0000 (22:14 +0200)]
testsuite: Verify that module-mapper is available
For some test cases, it's required that the optional module mapper
"g++-mapper-server" is built. As the server is not required, the
test cases will fail if it can't be found.
gcc/testsuite/ChangeLog:
* lib/target-supports.exp (check_is_prog_name_available):
New.
* lib/target-supports-dg.exp
(dg-require-prog-name-available): New.
* g++.dg/modules/modules.exp: Verify avilability of module
mapper.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Kyrylo Tkachov [Fri, 18 Nov 2022 09:06:38 +0000 (09:06 +0000)]
aarch64: Fix up LDAPR codegen
Upon some further inspection I realised I had misunderstood some intricacies of the extending loads of the RCPC feature.
This patch fixes up the recent GCC support accordingly. In particular:
* The sign-extending forms are a form of LDAPURS* and are actually part of FEAT_RCPC2
that is enabled with Armv8.4-a rather than the base Armv8.3-a FEAT_RCPC.
The patch introduces a TARGET_RCPC2 macro and gates this combine pattern accordingly.
* The assembly output for the zero-extending LDAPR instruction should always use %w formatting for its destination register.
The testcase is split into zero-extending and sign-extending parts since they require different architecture pragmas.
It's also straightforward to add the rest of the FEAT_RCPC2 codegen
(with immediate offset addressing modes) but that can be done as a separate patch.
Apologies for not catching this sooner, but it hasn't been in trunk long, so no harm done.
Bootstrapped and tested on aarch64-none-linux-gnu.
gcc/ChangeLog:
* config/aarch64/aarch64.h (TARGET_RCPC2): Define.
* config/aarch64/atomics.md (*aarch64_atomic_load<ALLX:mode>_rcpc_zext):
Adjust output template.
(*aarch64_atomic_load<ALLX:mode>_rcpc_sex): Guard on TARGET_RCPC2.
Adjust output template.
* config/aarch64/iterators.md (w_sz): New mode attr.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/ldapr-ext.c: Rename to...
* gcc.target/aarch64/ldapr-zext.c: ... This. Fix expected assembly.
* gcc.target/aarch64/ldapr-sext.c: New test.
Jakub Jelinek [Fri, 18 Nov 2022 08:04:16 +0000 (09:04 +0100)]
c++: Implement CWG2635 - Constrained structured bindings
The following patch implements CWG2635.
2022-11-18 Jakub Jelinek <jakub@redhat.com>
* decl.cc (grokdeclarator): Implement
CWG2635 - Constrained structured bindings. Emit a pedwarn on
constrained auto type. Add auto_diagnostic_group for error_at
and inform for non-auto type on structured bindings declaration.
* g++.dg/cpp2a/decomp5.C: New test.
* g++.dg/cpp2a/decomp6.C: New test.
* g++.dg/cpp2a/decomp7.C: New test.
* g++.dg/cpp2a/concepts-placeholder7.C: Adjust expected diagnostics.
* g++.dg/cpp2a/concepts-placeholder8.C: Likewise.
* g++.dg/cpp2a/concepts-placeholder9.C: New test.
* g++.dg/cpp2a/concepts-placeholder10.C: New test.
Richard Biener [Thu, 17 Nov 2022 08:43:31 +0000 (09:43 +0100)]
tree-optimization/107647 - avoid FMA from SLP with -ffp-contract=off
Only with -ffp-contract=fast we can synthesize FMA operations like
vfmaddsub231ps, so properly guard the transform in SLP pattern
detection.
PR tree-optimization/107647
* tree-vect-slp-patterns.cc (addsub_pattern::recognize): Only
allow FMA generation with -ffp-contract=fast for FP types.
(complex_mul_pattern::matches): Likewise.
* gcc.target/i386/pr107647.c: New testcase.
Jinyang He [Thu, 17 Nov 2022 06:38:52 +0000 (14:38 +0800)]
LoongArch: Fix atomic_exchange expanding [PR107713]
We used to expand atomic_exchange_n(ptr, new, mem_order) for subword types
into something like:
{
__typeof__(*ptr) t = atomic_load_n(ptr, mem_order);
atomic_compare_exchange_n(ptr, &t, new, true, mem_order, mem_order);
return t;
}
It's incorrect because another thread may store a different value into *ptr
after atomic_load_n. Then atomic_compare_exchange_n will not store into
*ptr, but atomic_exchange_n should always perform the store.
gcc/ChangeLog:
PR target/107713
* config/loongarch/sync.md
(atomic_cas_value_exchange_7_<mode>): New define_insn.
(atomic_exchange): Use atomic_cas_value_exchange_7_si instead of
atomic_cas_value_cmp_and_7_si.
gcc/testsuite/ChangeLog:
PR target/107713
* gcc.target/loongarch/pr107713-1.c: New test.
* gcc.target/loongarch/pr107713-2.c: New test.
Marek Polacek [Thu, 17 Nov 2022 16:59:29 +0000 (11:59 -0500)]
c++: constinit on pointer to function [PR104066]
[dcl.constinit]: "The constinit specifier shall be applied only to
a declaration of a variable with static or thread storage duration."
Thus, this ought to be OK:
constinit void (*p)() = nullptr;
but the error message I introduced when implementing constinit was
not looking at funcdecl_p, so the code above was rejected.
Fixed thus. I'm checking constinit_p first because I think that's
far more likely to be false than funcdecl_p.
PR c++/104066
gcc/cp/ChangeLog:
* decl.cc (grokdeclarator): Check funcdecl_p before complaining
about constinit.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/constinit18.C: New test.
Bernhard Reutner-Fischer [Sat, 6 Nov 2021 05:48:00 +0000 (06:48 +0100)]
c: Set the locus of the function result decl
gcc/c/ChangeLog:
* c-decl.cc (start_function): Set the result decl source
location to the location of the typespec.
Bernhard Reutner-Fischer [Sun, 31 Oct 2021 12:57:46 +0000 (13:57 +0100)]
Fortran: Remove double spaces in open() warning [PR99884]
gcc/fortran/ChangeLog:
PR fortran/99884
* io.cc (check_open_constraints): Remove double spaces.
Andrew Pinski [Thu, 17 Nov 2022 17:48:00 +0000 (17:48 +0000)]
Fix PR 107734: valgrind errors with sbitmap in match.pd
sbitmap is a simple bitmap and the memory allocated is not cleared
on creation; you have to clear it or set it to all ones before using
it. This is unlike bitmap which is a sparse bitmap and the entries are
cleared as created.
The code added in r13-4044-gdc95e1e9702f2f missed that.
This patch fixes that mistake.
Committed as obvious after a bootstrap and test on x86_64-linux-gnu.
gcc/ChangeLog:
PR middle-end/107734
* match.pd (perm + vector op pattern): Clear the sbitmap before
use.
Aldy Hernandez [Thu, 17 Nov 2022 15:47:17 +0000 (16:47 +0100)]
[PR tree-optimization/107732] [range-ops] Handle attempt to abs() negatives.
The threader is creating a scenario where we are trying to solve:
[NEGATIVES] = abs(x)
While solving this we have an intermediate value of UNDEFINED because
we have no positive numbers. But then we try to union the negative
pair to the final result by querying the bounds. Since neither
UNDEFINED nor NAN have bounds, they need to be specially handled.
PR tree-optimization/107732
gcc/ChangeLog:
* range-op-float.cc (foperator_abs::op1_range): Early exit when
result is undefined.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr107732.c: New test.
David Malcolm [Thu, 17 Nov 2022 17:34:56 +0000 (12:34 -0500)]
c, analyzer: fix ICE with -fanalyzer and -Wunused-macros [PR107711]
PR analyzer/107711 reports an ICE since r13-4073-gd8aba860b34203 with
the combination of -fanalyzer and -Wunused-macros.
The issue is that in c_translation_unit::consider_macro's call to
cpp_create_reader I was passing "ident_hash" for use by the the new
reader, but that takes ownership of that hash_table, so that ident_hash
erroneously gets freed when c_translation_unit::consider_macro calls
cpp_destroy, leading to a use-after-free in -Wunused-macros, where:
(gdb) p pfile->hash_table->pfile == pfile
$23 = false
and it's instead pointing at the freed reader from consider_macro,
leading to a use-after-free ICE.
Fixed thusly.
gcc/c/ChangeLog:
PR analyzer/107711
* c-parser.cc (ana::c_translation_unit::consider_macro): Pass NULL
to cpp_create_reader, rather than ident_hash, so that the new
reader gets its own hash table.
gcc/testsuite/ChangeLog:
PR analyzer/107711
* gcc.dg/analyzer/named-constants-Wunused-macros.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Philipp Tomsich [Thu, 13 Oct 2022 08:55:41 +0000 (10:55 +0200)]
RISC-V: Optimize masking with two clear bits not a SMALL_OPERAND
Add a split for cases where we can use two bclri (or one bclri and an
andi) to clear two bits.
gcc/ChangeLog:
* config/riscv/bitmanip.md (*bclri<mode>_nottwobits): New pattern.
(*bclridisi_nottwobits): New pattern, handling the sign-bit.
* config/riscv/predicates.md (const_nottwobits_operand):
New predicate.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zbs-bclri.c: New test.
Philipp Tomsich [Tue, 9 Nov 2021 17:54:54 +0000 (18:54 +0100)]
RISC-V: bitmanip: add splitter to use bexti for "(a & (1 << BIT_NO)) ? 0 : -1"
Consider creating a polarity-reversed mask from a set-bit (i.e., if
the bit is set, produce all-ones; otherwise: all-zeros). Using Zbb,
this can be expressed as bexti, followed by an addi of minus-one. To
enable the combiner to discover this opportunity, we need to split the
canonical expression for "(a & (1 << BIT_NO)) ? 0 : -1" into a form
combinable into bexti.
Consider the function:
long f(long a)
{
return (a & (1 << BIT_NO)) ? 0 : -1;
}
This produces the following sequence prior to this change:
andi a0,a0,16
seqz a0,a0
neg a0,a0
ret
Following this change, it results in:
bexti a0,a0,4
addi a0,a0,-1
ret
gcc/ChangeLog:
* config/riscv/bitmanip.md: Add a splitter to generate
polarity-reversed masks from a set bit using bexti + addi.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zbs-bexti.c: New test.
mtsamis [Wed, 24 Aug 2022 13:22:58 +0000 (15:22 +0200)]
Enable shrink wrapping for the RISC-V target.
This commit implements the target macros (TARGET_SHRINK_WRAP_*) that
enable separate shrink wrapping for function prologues/epilogues in
RISC-V.
Tested against SPEC CPU 2017, this change always has a net-positive
effect on the dynamic instruction count. See the following table for
the breakdown on how this reduces the number of dynamic instructions
per workload on a like-for-like (i.e., same config file; suppressing
shrink-wrapping with -fno-shrink-wrap):
# dynamic instructions
w/o shrink-wrap w/ shrink-wrap reduction
500.perlbench_r
1265716786593 1262156218578 3560568015 0.28%
500.perlbench_r
779224795689 765337009025 13887786664 1.78%
500.perlbench_r
724087331471 711307152522 12780178949 1.77%
502.gcc_r
204259864844 194517006339 9742858505 4.77%
502.gcc_r
244047794302 231555834722 12491959580 5.12%
502.gcc_r
230896069400 221877703011 9018366389 3.91%
502.gcc_r
192130616624 183856450605 8274166019 4.31%
502.gcc_r
258875074079 247756203226 11118870853 4.30%
505.mcf_r
662653430325 660678680547 1974749778 0.30%
520.omnetpp_r
985114167068 934191310154 50922856914 5.17%
523.xalancbmk_r
927037633578 921688937650 5348695928 0.58%
525.x264_r
490953958454 490565583447 388375007 0.08%
525.x264_r
1994662294421 1993171932425 1490361996 0.07%
525.x264_r
1897617120450 1896062750609 1554369841 0.08%
531.deepsjeng_r
1695189878907 1669304130411 25885748496 1.53%
541.leela_r
1925941222222 1897900861198 28040361024 1.46%
548.exchange2_r
2073816227944 2073816226729 1215 0.00%
557.xz_r
379572090003 379057409041 514680962 0.14%
557.xz_r
953117469352 952680431430 437037922 0.05%
557.xz_r
536859579650 536456690164 402889486 0.08%
18421773405376 18223938521833 197834883543 1.07% totals
Signed-off-by: Manolis Tsamis <manolis.tsamis@vrull.eu>
gcc/ChangeLog:
* config/riscv/riscv.cc (struct machine_function): Add array to store
register wrapping information.
(riscv_for_each_saved_reg): Skip registers that are wrapped separetely.
(riscv_get_separate_components): New function.
(riscv_components_for_bb): Likewise.
(riscv_disqualify_components): Likewise.
(riscv_process_components): Likewise.
(riscv_emit_prologue_components): Likewise.
(riscv_emit_epilogue_components): Likewise.
(riscv_set_handled_components): Likewise.
(TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS): Define.
(TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB): Likewise.
(TARGET_SHRINK_WRAP_DISQUALIFY_COMPONENTS): Likewise.
(TARGET_SHRINK_WRAP_EMIT_PROLOGUE_COMPONENTS): Likewise.
(TARGET_SHRINK_WRAP_EMIT_EPILOGUE_COMPONENTS): Likewise.
(TARGET_SHRINK_WRAP_SET_HANDLED_COMPONENTS): Likewise.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/shrink-wrap-1.c: New test.
Kyrylo Tkachov [Thu, 17 Nov 2022 11:16:54 +0000 (11:16 +0000)]
aarch64: Add mode size check on LDAPR-extend patterns
Add an extra safety check as suggested by Richard.
Tested on aarch64-none-linux-gnu.
gcc/ChangeLog:
* config/aarch64/atomics.md (*aarch64_atomic_load<ALLX:mode>_rcpc_zext):
Add mode size check to condition.
(*aarch64_atomic_load<ALLX:mode>_rcpc_sext): Likewise.
Aldy Hernandez [Sat, 12 Nov 2022 10:58:07 +0000 (11:58 +0100)]
[PR68097] Try to avoid recursing for floats in gimple_stmt_nonnegative_warnv_p.
It irks me that a PR named "we should track ranges for floating-point
hasn't been closed in this release. This is an attempt to do just
that.
As mentioned in the PR, even though we track ranges for floats, it has
been suggested that avoiding recursing through SSA defs in
gimple_assign_nonnegative_warnv_p is also a goal. This patch uses a
global range query (no on-demand lookups, just global ranges and
minimal folding) to determine if the range of a statement is known to
be non-negative.
PR tree-optimization/68097
gcc/ChangeLog:
* gimple-fold.cc (gimple_stmt_nonnegative_warnv_p): Call
range_of_stmt for floats.
Lili Cui [Thu, 17 Nov 2022 07:50:46 +0000 (15:50 +0800)]
x86: Enable 256 move by pieces for ALDERLAKE machine.
gcc/ChangeLog:
* config/i386/x86-tune.def
(X86_TUNE_AVX256_MOVE_BY_PIECES): Add alderlake.
(X86_TUNE_AVX256_STORE_BY_PIECES): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pieces-memset-50.c: New test.
Tamar Christina [Thu, 17 Nov 2022 08:20:59 +0000 (08:20 +0000)]
middle-end: ensure that VEC_PERM operands get lowered to the same SSA_NAME. [PR107717]
At the moment when the VEC_PERMs generated by this match.pd rule is generated
it creates two different SSA_NAMEs for the folded operand. Because of this it
the permute switches from a single operand permute to a two operand permute and
the target may no longer support a permute for this.
This fixes it by ensuring we generate the same SSA_NAME for both operands.
gcc/ChangeLog:
PR tree-optimization/107717
* match.pd: Ensure same SSA_NAME.
gcc/testsuite/ChangeLog:
PR tree-optimization/107717
* gcc.target/aarch64/sve2/pr107717.c: New test.
Tamar Christina [Thu, 17 Nov 2022 08:14:44 +0000 (08:14 +0000)]
middle-end: replace GET_MODE_WIDER_MODE with GET_MODE_NEXT_MODE
After the fix to the addsub patch yesterday for bootstrap I had only regtested on x86.
While looking today it seemed the new tests were failing, this was caused
by a change in the behavior of the GET_MODE_WIDER_MODE macro on trunk.
gcc/ChangeLog:
* match.pd: Replace GET_MODE_WIDER_MODE with
custom code.
Aldy Hernandez [Mon, 14 Nov 2022 09:29:13 +0000 (10:29 +0100)]
[range-ops] Minor readability fix.
gcc/ChangeLog:
* range-op-float.cc (range_operator_float::fold_range): Make check
for maybe_isnan more readable.
Kewen Lin [Thu, 17 Nov 2022 05:08:23 +0000 (23:08 -0600)]
Fix typo in gimple_fold_partial_load_store_mem_ref
As Robin spotted, my recent commit r13-3716 caused an ICE
on s390 if vector access with length is enabled there (his
patch for the enablement hasn't been committed yet). The
failure is caused by one stupid typo, the bias on s390 is
-1, so the assertion should use tree_fits_shwi_p rather
than tree_fits_uhwi_p. Thanks for Robin's catching.
I just reproduced the ICE and verified the fix worked fine
with a cross build, the optimized dump against the test case
gcc.target/powerpc/pr107412.c looked expected.
gcc/ChangeLog:
* gimple-fold.cc (gimple_fold_partial_load_store_mem_ref): Use
tree_fits_shwi_p rather than tree_fits_uhwi_p as bias is signed.
Jia-Wei Chen [Thu, 17 Nov 2022 03:58:54 +0000 (22:58 -0500)]
RISC-V: Optimize RVV epilogue logic.
Sometimes "step1 -= scalable_frame" will cause adjust equal to
zero. And it will generate additional redundant instruction
"addi sp,sp,0". Add checking segement to skip that case.
This testcase mix exist spill-1.c and adding new fun to check if
there have redundant addi intructions. Idea provided by Jeff Law.
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_expand_epilogue):
Do not emit useless add sp, sp, 0 instrutions.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/base/spill-sp-adjust.c: New test.
Jeff Law [Thu, 17 Nov 2022 01:47:59 +0000 (18:47 -0700)]
Fix multiple recent sh3/sh3eb regressions
So my tester started showing even more regressions on the sh3/sh4 runs
recently (beyond the one recently reported in BZ triggered by some DCE
related changes). Bisection kept showing inconsistent results. I was
starting to think memory management error, but valgrind didn't flag anything.
After a bit of head-banging I was able to track it down to predicate
tests called from the SH specific combiner passes. And once I started
getting inside the actual code for the predicate function it became
pretty obvious. The predicate routines are supposed to return a bool,
fine and they dutifully set the low bit in %eax properly.
The *caller* was looking at the full register. Uh-oh. Naturally we
became dependent on what happened to be in the upper 31 bits of a register.
That's why the bug would come and go so willy-nilly. This was ultimately
chased down to an incorrect prototype in sh_treg_combine.cc for predicate
functions defined via define_predicate.
Removing the bogus prototypes and instead including the generated
tm-preds.h fixes this problem. I also checked the other ports for
similar problems (specifically looking for a extern int.*_operand, then
for each of the hits looking to see if the predicate was defined via
define_predicate). No other ports had similar braindamage.
This fixes the most recent regressions in my tester for sh3/sh3eb
and I strongly suspect sh4. It does not fix 107704, but I think
Richi and I both agree that's a visitation order issue and we were
just getting lucky before.
gcc/
* config/sh/sh_treg_combine.cc: Include tm-preds.h.
(t_reg_operand): Remove bogus prototype.
(negt_reg_operand): Likewise.
Jonathan Wakely [Wed, 16 Nov 2022 20:47:39 +0000 (20:47 +0000)]
libstdc++: Ensure std::to_chars overloads all declared in <format> [PR107720]
For powerpc64le we need to be able to format both of __ieee128 and
__ibm128, so we need the std::to_chars overloads for both types to be
visible at once. The __ieee128 overloads are always visible in C++23
mode, because they're used to implement the _Float128 overloads. The
__ibm128 overloads are only visible when long double is __ibm128.
libstdc++-v3/ChangeLog:
PR libstdc++/107720
* include/std/format [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT]:
Declare overloads of std::to_chars for the alternative long
double type.
GCC Administrator [Thu, 17 Nov 2022 00:16:52 +0000 (00:16 +0000)]
Daily bump.
David Malcolm [Wed, 16 Nov 2022 22:38:28 +0000 (17:38 -0500)]
analyzer: more test coverage for named constants
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/named-constants-via-command-line.c: New test.
* gcc.dg/analyzer/named-constants-via-macros-3.c: New test.
* gcc.dg/analyzer/named-constants-via-macros-4.c: New test.
* gcc.dg/analyzer/named-constants-via-macros-empty.c: New test.
* gcc.dg/analyzer/named-constants-via-macros-gc.c: New test.
* gcc.dg/analyzer/named-constants-via-macros-traditional.c: New test.
* gcc.dg/analyzer/named-constants-via-macros-undef.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Wed, 16 Nov 2022 22:38:24 +0000 (17:38 -0500)]
analyzer: log the stashing of named constants [PR107711]
PR analyzer/107711 seems to be a bug in how named constants are looked up
by the analyzer in the C frontend.
To help debug this, this patch extends -fdump-analyzer and
-fdump-analyzer-stderr so that they dump this part of the analyzer's
startup.
gcc/analyzer/ChangeLog:
PR analyzer/107711
* analyzer-language.cc: Include "diagnostic.h".
(maybe_stash_named_constant): Add logger param and use it to log
the name being looked up, and the result.
(stash_named_constants): New, splitting out from...
(on_finish_translation_unit): ...this function. Call
get_or_create_logfile and use the result to create a logger
instance, passing it to stash_named_constants.
* analyzer.h (get_or_create_any_logfile): New decl.
* engine.cc (dump_fout, owns_dump_fout): New globals, split out
from run_checkers.
(get_or_create_any_logfile): New function, split out from...
(run_checkers): ...here, so that the logfile can be opened by
on_finish_translation_unit. Clear the globals when closing the
dump file.
gcc/testsuite/ChangeLog:
PR analyzer/107711
* gcc.dg/analyzer/fdump-analyzer-1.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Steve Kargl [Wed, 16 Nov 2022 21:46:55 +0000 (22:46 +0100)]
Fortran: ICE on procedure arguments with non-integer length [PR107707]
gcc/fortran/ChangeLog:
PR fortran/107707
* interface.cc (gfc_compare_actual_formal): Check that we actually
have integer values before asking gmp_* to use them.
gcc/testsuite/ChangeLog:
PR fortran/107707
* gfortran.dg/pr107707.f90: New test.