Martin Liska [Tue, 14 Dec 2021 14:43:16 +0000 (15:43 +0100)]
testsuite: fix ASAN errors
The tests failed on my machine as they contain out-of-bounds
access.
gcc/testsuite/ChangeLog:
* gcc.target/i386/avx2-psraq-1.c: Use ARRAY_SIZE.
* gcc.target/i386/m128-check.h: Move it to the top-level
context.
* gcc.target/i386/sse2-psraq-1.c: Use ARRAY_SIZE.
* gcc.target/i386/sse4_2-check.h: Include the header with
ARRAY_SIZE definition.
Jonathan Wakely [Mon, 13 Dec 2021 13:36:33 +0000 (13:36 +0000)]
libstdc++: Fix non-reserved name in <regex> header
libstdc++-v3/ChangeLog:
* include/bits/regex_compiler.tcc (_Compiler::_M_match_token):
Use reserved name for parameter.
* testsuite/17_intro/names.cc: Check "token".
Patrick Palka [Tue, 14 Dec 2021 13:15:52 +0000 (08:15 -0500)]
c++: processing_template_decl vs template depth [PR103408]
We use processing_template_decl in two slightly different ways: as a
flag to signal that we're dealing with templated trees, and as a measure
of the current syntactic template nesting depth. This overloaded
meaning of p_t_d is conceptually confusing and leads to bugs that we end
up working around in an ad-hoc fashion.
This patch replaces all uses of processing_template_decl that care about
its magnitude to instead look at the depth of current_template_parms
via a new macro current_template_depth. This allows us to eliminate 3
workarounds in the concepts code: two about non-templated
requires-expressions (in constraint.cc) and one about lambdas inside
constraints (in cp_parser_requires_clause_expression etc). This also
fixes the testcase in PR103408 about auto(x) used inside a non-templated
requires-expression.
The replacement was mostly mechanical, aside from two issues:
* In synthesize_implicit_template_parm, when introducing a new template
parameter list for an abbreviated function template, we need to add
the new level of current_template_parms sooner, before calling
process_template_parm, since this latter function now looks at
current_template_depth to determine the level of the new parameter.
* In instantiate_class_template_1 after substituting a template
friend declaration, we currently increment processing_template_decl
around the call to make_friend_class so that the friend_depth
computation within this subroutine yields a nonzero value. We could
just replace this with an equivalent manipulation of
current_template_depth, but this patch instead rewrites the
friend_depth calculation within make_friend_class to not depend on
p_t_d / c_t_d at all when called from instantiate_class_template_1.
PR c++/103408
gcc/cp/ChangeLog:
* constraint.cc (type_deducible_p): Remove workaround for
non-templated requires-expressions.
(normalize_placeholder_type_constraints): Likewise.
* cp-tree.h (current_template_depth): Define.
(PROCESSING_REAL_TEMPLATE_DECL): Inspect current_template_depth
instead of the magnitude of processing_template_decl.
* decl.c (start_decl): Likewise.
(grokfndecl): Likewise.
(grokvardecl): Likewise.
(grokdeclarator): Likewise.
* friend.c (make_friend_class): Likewise. Calculate
friend_depth differently when called at instantiation time
instead of parse time.
(do_friend): Likewise.
* parser.c (cp_parser_requires_clause_expression): Remove
workaround for lambdas inside constraints.
(cp_parser_constraint_expression): Likewise.
(cp_parser_requires_expression): Likewise.
(synthesize_implicit_template_parm): Add to current_template_parms
before calling process_template_parm.
* pt.c (inline_needs_template_parms): Inspect
current_template_depth instead of the magnitude of
processing_template_decl.
(push_inline_template_parms_recursive): Likewise.
(maybe_begin_member_template_processing): Likewise.
(begin_template_parm_list): Likewise.
(process_template_parm): Likewise.
(end_template_parm_list): Likewise.
(push_template_decl): Likewise.
(add_inherited_template_parms): Likewise.
(instantiate_class_template_1): Don't adjust
processing_template_decl around the call to make_friend_class.
adjust_processing_template_decl to adjust_template_depth. Set
current_template_parms instead of processing_template_decl when
adjust_template_depth.
(make_auto_1): Inspect current_template_depth instead of the
magnitude of processing_template_decl.
(splice_late_return_type): Likewise.
* semantics.c (fixup_template_type): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/concepts/diagnostic18.C: Expect a "constraints on a
non-templated function" error.
* g++.dg/cpp23/auto-fncast11.C: New test.
Olivier Hainque [Sun, 15 Nov 2020 09:56:51 +0000 (09:56 +0000)]
Remove fpic multilib on x86_64-vxworks
The addition of fPIC for shared libraries is performed
independently from multilibs and fpic multilibs have
no other particular purpose for VxWorks at this stage.
They incur extra build time, complexify the install tree
and are a bit tricky because -fpic is not supported for kernel
mode.
2021-12-14 Olivier Hainque <hainque@adacore.com>
gcc/
* config/i386/t-vxworks: Drop the fPIC multilibs.
Patrick Palka [Tue, 14 Dec 2021 12:48:54 +0000 (07:48 -0500)]
c++: don't leak 'arglist' in build_new_op
gcc/cp/ChangeLog:
* call.c (build_new_op): Use releasing_vec for arglist. Declare
conv in the scope it's used.
Patrick Palka [Tue, 14 Dec 2021 12:48:05 +0000 (07:48 -0500)]
c++: remove COMPOUND_EXPR_OVERLOADED flag
This flag is never set because non-dependent COMPOUND_EXPRs that resolve
to an overload are expressed as a CALL_EXPR at template definition time
(in build_x_compound_expr) ever since r6-5772.
gcc/cp/ChangeLog:
* cp-tree.h (COMPOUND_EXPR_OVERLOADED): Remove.
* pt.c (build_non_dependent_expr): Don't inspect the flag.
* tree.c (build_min_non_dep): Don't set the flag.
Frederic Konrad [Thu, 12 Nov 2020 11:39:25 +0000 (12:39 +0100)]
Drop the fpic multilib for powerpc*-vxworks*
The addition of fPIC for shared libraries is performed
independently from multilibs and the fpic multilibs have
no other particular purpose. They incur extra build time,
complexify the install tree and are a bit tricky because
-fpic is not supported for kernel mode.
2020-11-06 Fred Konrad <konrad@adacore.com>
gcc/
* config/rs6000/t-vxworks: Drop the fPIC multilib.
Jakub Jelinek [Tue, 14 Dec 2021 11:02:55 +0000 (12:02 +0100)]
c: Fix ICE on deferred pragma in unknown attribute arguments [PR103587]
We ICE on the following testcase, because c_parser_balanced_token_sequence
when encountering a deferred pragma will just use c_parser_consume_token
which the FE doesn't allow for CPP_PRAGMA tokens (and if that wasn't
the case, it could ICE on CPP_PRAGMA_EOL similarly).
We don't know in what exact context the pragma appears when we don't
know what those arguments semantically mean, so I think we should just
skip over them, like e.g. the C++ FE does. And, I think (/[/{ vs. )/]/}
from outside of the pragma shouldn't be paired with those inside of
the pragma and it doesn't seem to be necessary to check that inside of
the pragma line itself all the paren kinds are balanced.
2021-12-14 Jakub Jelinek <jakub@redhat.com>
PR c/103587
* c-parser.c (c_parser_balanced_token_sequence): For CPP_PRAGMA,
consume the pragma and silently skip to the pragma eol.
* gcc.dg/pr103587.c: New test.
Thomas Schwinge [Tue, 14 Dec 2021 06:03:52 +0000 (07:03 +0100)]
Adjust 'gfortran.dg/goacc/privatization-1-*' [PR103576, PR103697]
... for the recent commit
494ebfa7c9aacaeb6ec1fccc47a0e49f31eb2bb8
"Fortran: Handle compare in OpenMP atomic", which changes the GIMPLE IR
such that a temporary is no longer used; 'original' dump:
x = *a;
- {
- integer(kind=4) D.4237;
-
- D.4237 = *a;
#pragma omp atomic relaxed
- &y = D.4237;
- }
+ &y = *a;
}
(I'm not familiar to comment whether that's correct; but it appears that the
difference again disappears in later compiler passes.)
These OpenACC test cases verify behavior re OpenACC privatization levels, and
have to be adjusted accordingly.
gcc/testsuite/
PR fortran/103576
PR testsuite/103697
* gfortran.dg/goacc/privatization-1-compute-loop.f90: Adjust.
* gfortran.dg/goacc/privatization-1-compute.f90: Likewise.
* gfortran.dg/goacc/privatization-1-routine_gang-loop.f90:
Likewise.
* gfortran.dg/goacc/privatization-1-routine_gang.f90: Likewise.
GCC Administrator [Tue, 14 Dec 2021 00:16:25 +0000 (00:16 +0000)]
Daily bump.
Vladimir N. Makarov [Mon, 13 Dec 2021 18:48:12 +0000 (13:48 -0500)]
[PR99531] Modify pseudo class cost calculation when processing move involving the pseudo and a hard register
Pseudo class calculated on the 1st iteration should not have a
special treatment in cost calculation when processing move involving
the pseudo and a hard register.
gcc/ChangeLog:
PR target/99531
* ira-costs.c (record_operand_costs): Do not take pseudo class
calculated on the 1st iteration into account when processing move
involving the pseudo and a hard register.
gcc/testsuite/ChangeLog:
PR target/99531
* gcc.target/i386/pr99531.c: New test.
Roger Sayle [Mon, 13 Dec 2021 18:48:22 +0000 (18:48 +0000)]
x86: Avoid generating orb $0, %ah
I'll post my proposed fix for PR target/103611 shortly, but this patch
fixes another missed optimization opportunity revealed by that PR.
Occasionally, reload materializes integer constants during register
allocation sometimes resulting in unnecessary instructions such as:
(insn 23 31 24 2 (parallel [
(set (reg:SI 0 ax [99])
(ior:SI (reg:SI 0 ax [99])
(const_int 0 [0])))
(clobber (reg:CC 17 flags))
]) "pr103611.c":18:73 550 {*iorsi_1}
(nil))
These then get "optimized" during the split2 pass, which realizes that
no bits outside of 0xff00 are set, so this operation can be implemented
by operating on just the highpart of a QIreg_operand, i.e. %ah, %bh, %ch
etc., which leads to the useless "orb $0, %ah" seen in the reported PR.
This fix catches the case of const0_rtx in relevant splitter, either
eliminating the instruction or turning it into a simple move.
2021-12-13 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/i386/i386.md (define_split any_or:SWI248 -> orb %?h):
Optimize the case where the integer constant operand is zero.
gcc/testsuite/ChangeLog
* gcc.target/i386/pr103611-1.c: New test case.
Douglas B Rupp [Thu, 8 Apr 2021 18:03:19 +0000 (11:03 -0700)]
Rework VXWORKS_LINK_SPEC for shared objects support
Split LINK_SPEC as BASE_LINK_SPEC + EXTRA_LINK_SPEC,
with an overridable LINK_OS component that cpu ports may
redefine.
Leverage the latter on powerpc for VxWorks 7, where we incorporate
our specific bits in the linux os configuration as the system compiler
is now very close to a standard linux one.
The split allows supporting shared objects (shared libs and
non-static rtps) on recent versions of VxWorks while retaining
compatibility with older VxWorks targets which could link with
shared libraries but not build them.
2021-12-07 Doug Rupp <rupp@adacore.com>
Olivier Hainque <hainque@adacore.com>
gcc/
* config/vxworks.h (VXWORKS_LINK_OS_SPEC): New spec.
(VXWORKS_BASE_LINK_SPEC): New spec, using the former.
(VXWORKS_EXTRA_LINK_SPEC): New spec for old and new VxWorks.
(VXWORKS_LINK_SPEC): Combo of BASE and EXTRA specs.
* config/rs6000/vxworks.h (VXWORKS_LINK_OS_SPEC): Empty.
(LINK_OS_EXTRA_SPEC32): Use VXWORKS_LINK_SPEC.
(LINK_OS_EXTRA_SPEC64): Likewise.
Olivier Hainque [Thu, 9 Dec 2021 15:37:37 +0000 (15:37 +0000)]
Remove ppc*-vxworks7* inadequate libgcc Makefile fragments
t-linux assigns .so version numbers to a set of
symbols, some of which aren't included the VxWorks libgcc
on powerpc (from ibm-ldouble.c, in particular).
t-slibgcc-libgcc yields a kind of .so file that the default
loader can't handle. This sort of extension to tmake_file for
shared libs will be better handled in a grouped fashion for
all targets anyway.
2021-12-13 Olivier Hainque <hainque@adacore.com>
* config.host (powerpc*-*-vxworks7*): Remove
rs6000/t-linux and t-slibgcc-libgcc from tmake_file.
Olivier Hainque [Tue, 7 Dec 2021 16:46:02 +0000 (16:46 +0000)]
Remove special case for arm-vxworks on the use of vxcrtstuff
Not needed any more after the recent cleanups issued for the
support of shared libraries.
2021-12-13 Olivier Hainque <hainque@adacore.com>
libgcc/
* config.host (*vxworks*): Remove special case for
arm on the use of vxcrtstuff.
Frederic Konrad [Thu, 5 Nov 2020 10:34:57 +0000 (11:34 +0100)]
Tigthen libc_internal and crtstuff for VxWorks shared objects
This change tightens and documents the use of libc_internal, then
strengthens the VxWorks crtstuff objects for the support of shared
libraries. In particular:
- Define __dso_handle, which libstdc++.so requires,
- Provide _init and _fini functions to run through the init/fini arrays
for shared libs in configurations which HAVE_INITFINI_ARRAY_SUPPORT.
The init/fini functions are provided by libc_internal.a for static links
but with slightly different names and we don't want to risk dragging other
libc_internal contents in the closure accidentally so make sure we don't
link with it.
As for the !vxworks crtstuff, the new shared libs specific bits are
conditioned by a CRTSTUFFS_O macro, for which we provide new Makefile
fragment.
The bits to actually use the fragment and the shared objects will
be added by a forthcoming change, as part of a more general configury
update for shared libs.
The change also adds guards the eh table registration code
in vxcrtstuff so the objects can be used for either init/fini
or eh tables independently.
2021-12-07 Fred Konrad <konrad@adacore.com>
Olivier Hainque <hainque@adacore.com>
gcc/
* config/vxworks.h (VXWORKS_BASE_LIBS_RTP): Guard -lc_internal
on !shared+!non-static and document.
(VXWORKS_LIB_SPEC): Remove the bits intended to drag the
init/fini functions from libc_internal in the shared lib case.
(VX_CRTBEGIN_SPEC/VX_CRTEND_SPEC): Use vxcrtstuff objects also in
configurations with shared lib and INITFINI_ARRAY support.
libgcc/
* config/t-vxcrtstuffS: New Makefile fragment.
* config/vxcrtstuff.c: Provide __dso_handle. Provide _init/_fini
functions for INITFINI_ARRAY support in shared libs and guard
the definition of eh table registration functions on conditions
indicating they are needed.
Frederic Konrad [Fri, 6 Nov 2020 18:42:27 +0000 (19:42 +0100)]
VxWorks config fixes for shared objects
This strengthens the VxWorks configuration files for the support
of shared objects, which encompasses a VxWorks specific "non-static"
mode for RTPs (in addition to -static and -shared).
2020-11-06 Fred Konrad <konrad@adacore.com>
Olivier Hainque <hainque@adacore.com>
gcc/
* config/vx-common.h: Define REAL_LIBGCC_SPEC since the
'-non-static' option is not standard.
* config/vxworks.h (VXWORKS_LIBGCC_SPEC): Implement the LIBGCC_SPEC
since REAL_LIBGCC_SPEC is used now.
(STARTFILE_PREFIX_SPEC): Use the PIC VSB when building shared libraries
or non-static binaries.
Olivier Hainque [Tue, 7 Dec 2021 13:26:30 +0000 (13:26 +0000)]
Preserve cpu specific CRTSTUFF_T_CFLAGS on powerpc-vxworks7
The unconditional assignment performed in t-vxworks to handle
include flags currently overrides what specific cpu ports had
for the regular (!vxworks) crtstuff objects.
This was not done on purpose and the proposed change adjusts the
configuration bits to apply the vxworks specific flags on top of
the cpu ones instead.
2021-12-07 Olivier Hainque <hainque@adacore.com>
* config.host (powerpc*-wrs-vxworks7*): Place t-crtstuff
ahead of the other files in tmake_files.
* config/t-vxworks: Add to CRTSTUFF_T_CFLAGS instead of
overriding it.
Jan Hubicka [Mon, 13 Dec 2021 16:29:26 +0000 (17:29 +0100)]
Add -fipa-strict-aliasing
gcc/ChangeLog:
2021-12-13 Jan Hubicka <hubicka@ucw.cz>
* common.opt: Add -fipa-strict-aliasing.
* doc/invoke.texi: Document -fipa-strict-aliasing.
* ipa-modref.c (modref_access_analysis::record_access): Honor
-fipa-strict-aliasing.
(modref_access_analysis::record_access_lto): Likewise.
Kyrylo Tkachov [Mon, 13 Dec 2021 14:15:16 +0000 (14:15 +0000)]
aarch64: Add command-line support for Armv8.8-a
This final patch in the series is much simpler and adds command-line support for -march=armv8.8-a,
making use of the +mops features added in the previous patches.
Bootstrapped and tested on aarch64-none-linux-gnu.
gcc/ChangeLog:
* config/aarch64/aarch64-arches.def (armv8.8-a): Define.
* config/aarch64/aarch64.h (AARCH64_FL_V8_8): Define.
(AARCH64_FL_FOR_ARCH8_8): Define.
* doc/invoke.texi: Document -march=armv8.8-a.
Kyrylo Tkachov [Mon, 13 Dec 2021 14:14:21 +0000 (14:14 +0000)]
aarch64: Use +mops to inline memset operations
This 3rd patch in the series adds an inline sequence for the memset operation.
The aarch64-mops-memset-size-threshold param is added to control the size threshold for the sequence.
Its default setting is 256, which may seem a bit high, but it is consistent with the current
SIMD memset inline sequence limit, and future CPU tunings can override it easily as needed.
Bootstrapped and tested on aarch64-none-linux-gnu.
gcc/ChangeLog:
* config/aarch64/aarch64.c (aarch64_expand_setmem_mops): Define.
(aarch64_expand_setmem): Adjust for TARGET_MOPS.
* config/aarch64/aarch64.h (CLEAR_RATIO): Adjust for TARGET_MOPS.
(SET_RATIO): Likewise.
* config/aarch64/aarch64.md ("unspec"): Add UNSPEC_SETMEM.
(aarch64_setmemdi): Define.
(setmemdi): Adjust for TARGET_MOPS.
* config/aarch64/aarch64.opt (aarch64-mops-memset-size-threshold):
New param.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/mops_3.c: New test.
Kyrylo Tkachov [Mon, 13 Dec 2021 14:13:21 +0000 (14:13 +0000)]
aarch64: Add memmove expansion for +mops
This second patch in the series adds an inline movmem expansion for TARGET_MOPS
that emits the recommended sequence.
A new param aarch64-mops-memmove-size-threshold is added to control the memmove size threshold
for this expansion. Its default value is zero to be consistent with the current behaviour where
we always emit a libcall, as we don't currently have a movmem inline expansion
(we should add a compatible-everywhere inline expansion, but that's for the future), so we should
always prefer to emit the MOPS sequence when available in lieu of a libcall.
Bootstrapped and tested on aarch64-none-linux-gnu.
gcc/ChangeLog:
* config/aarch64/aarch64.md (aarch64_movmemdi): Define.
(movmemdi): Define.
(unspec): Add UNSPEC_MOVMEM.
* config/aarch64/aarch64.opt (aarch64-mops-memmove-size-threshold):
New param.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/mops_2.c: New test.
Kyrylo Tkachov [Mon, 13 Dec 2021 14:11:59 +0000 (14:11 +0000)]
aarch64: Add support for Armv8.8-a memory operations and memcpy expansion
This patch adds the +mops architecture extension flag from the 2021 Arm Architecture extensions, Armv8.8-a.
The +mops extensions introduce instructions to accelerate the memcpy, memset, memmove standard functions.
The first patch here uses the instructions in the inline memcpy expansion.
Further patches in the series will use similar instructions to inline memmove and memset.
A new param, aarch64-mops-memcpy-size-threshold, is introduced to control the size threshold above which to
emit the new sequence. Its default setting is 256 bytes, which is the same as the current threshold above
which we'd emit a libcall.
Bootstrapped and tested on aarch64-none-linux-gnu.
gcc/ChangeLog:
* config/aarch64/aarch64-option-extensions.def (mops): Define.
* config/aarch64/aarch64.c (aarch64_expand_cpymem_mops): Define.
(aarch64_expand_cpymem): Define.
* config/aarch64/aarch64.h (AARCH64_FL_MOPS): Define.
(AARCH64_ISA_MOPS): Define.
(TARGET_MOPS): Define.
(MOVE_RATIO): Adjust for TARGET_MOPS.
* config/aarch64/aarch64.md ("unspec"): Add UNSPEC_CPYMEM.
(aarch64_cpymemdi): New pattern.
(cpymemdi): Adjust for TARGET_MOPS.
* config/aarch64/aarch64.opt (aarch64-mops-memcpy-size-threshol):
New param.
* doc/invoke.texi (AArch64 Options): Document +mops.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/mops_1.c: New test.
Martin Liska [Fri, 10 Dec 2021 10:40:54 +0000 (11:40 +0100)]
inline: fix ICE with -fprofile-generate
PR ipa/103636
gcc/ChangeLog:
* ipa-inline.c (can_inline_edge_p): Move logic checking
no_profile_instrument_function logic to ...
(can_early_inline_edge_p): ... here.
Olivier Hainque [Mon, 13 Dec 2021 08:06:46 +0000 (08:06 +0000)]
Include yvals.h for VxWorks < 7 RTPs as well
For -mrtp on VxWorks 6.9, at least inttypes.h ends up #including
system headers checking that _BITS_BYTES is 8, which the system yvals.h
defines. We do pre-include _yvals.h ahead of inttypes.h for this kind of
purpose, but it currently assumes that only VxWorks >= 7 provides yvals.h.
This results in unexpected configure checks failures, complaining about
_BITS_BYTES not being 8, spotted while inspecting libstdc++ config.log for
unrelated reasons.
This change relaxes the guard in _yvals.h to include yvals.h for
__RTP__ in addition to version >= 7.
2021-12-13 Olivier Hainque <hainque@adacore.com>
* config/vxworks/_yvals.h: #include yvals.h also if
defined(__RTP__).
Olivier Hainque [Sat, 11 Dec 2021 08:46:08 +0000 (08:46 +0000)]
Ensure VxWorks headers expose C99 features for C++
C++ relies on C99 features since C++11 and libstdc++ down to c++98
checks for C99 features at configure time. Simpler is to request C99
features from system headers unconditionally.
2021-12-11 Olivier Hainque <hainque@adacore.com>
* config/vxworks.h (VXWORKS_OS_CPP_BUILTINS): Define
_C99 for C++.
Olivier Hainque [Fri, 26 Nov 2021 21:37:46 +0000 (21:37 +0000)]
Leverage sysroot for VxWorks
The build of a VxWorks toolchain relies a lot on system headers
and VxWorks has a few very specific features that require special
processing. For example, different sets of headers for the kernel
vs the rtp modes, which the compiler knows about by way of -mrtp
on the command line.
If we manage to avoid the need for fixincludes on recent versions
of VxWorks (>= 7), we still need to handle at least VxWorks 6.9 at
this stage.
We sort of get away with locating the correct headers at
run-time thanks to environment variables and various tests for
-mrtp in cpp specs, but getting fixincludes to work for old
configurations has always been tricky and getting a toolchain
to build with c++/libstdc++ support gets trickier with every
move to a more recent release.
sysroot_headers_suffix_spec is a pretty powerful device to help
address such issues, and this patch introduces changes that let
us get advantage of it.
The general idea is to leverage the assumption that compilations
occur with --sysroot=$VSB_DIR on vx7 or --sysroot=$WIND_BASE/target
prior to that.
For the toolchains we build, this is achieved with a few
configure options like:
--with-sysroot
--with-build-sysroot=${WIND_BASE}/target
--with-specs=%{!sysroot=*:--sysroot=%:getenv(WIND_BASE /target)}
This also allows simplifying the libgcc compilation flags control
and we take the opportunity to merge t-vxworks7 into t-vxworks as
the two files were differing only on the libgcc2 flags part.
2021-12-09 Olivier Hainque <hainque@adacore.com>
gcc/
* config/t-vxworks: Clear NATIVE_SYSTEM_HEADER_DIR.
* config/vxworks.h (SYSROOT_HEADERS_SUFFIX_SPEC): Define, for
VxWorks 7 and earlier.
(VXWORKS_ADDITIONAL_CPP_SPEC): Simplify accordingly.
(STARTFILE_PREFIX_SPEC): Adjust accordingly.
* config/rs6000/vxworks.h (STARTFILE_PREFIX_SPEC): Adjust.
libgcc/
* config/t-vxworks (LIBGCC2_INCLUDES): Simplify and handle
both VxWorks7 and earlier.
* config/t-vxworks7: Remove.
* config.host: Remove special case for vxworks7.
Jonathan Wakely [Mon, 13 Dec 2021 13:09:57 +0000 (13:09 +0000)]
libstdc++: Add support for '?' in linker script globs
The scripts/make_exports.pl script used for darwin only replaces '*'
wildcards in globs, it doesn't handle '?'. This means the recent changes
to std::__timepunct exports broke darwin.
Rather than use mangled names in the linker script, this adds support
for '?' to the perl script.
This also removes some unnecessary escaping of the replacement strings
in s// substitutions.
libstdc++-v3/ChangeLog:
* scripts/make_exports.pl: Replace '?' with '.' when turning
a glob into a regex.
Tobias Burnus [Mon, 13 Dec 2021 11:37:40 +0000 (12:37 +0100)]
Fortran: Handle compare in OpenMP atomic
gcc/fortran/ChangeLog:
PR fortran/103576
* openmp.c (is_scalar_intrinsic_expr): Fix condition.
(resolve_omp_atomic): Fix/update checks, accept compare.
* trans-openmp.c (gfc_trans_omp_atomic): Handle compare.
libgomp/ChangeLog:
* libgomp.texi (OpenMP 5.1): Set Fortran support for atomic to 'Y'.
* testsuite/libgomp.fortran/atomic-19.f90: New test.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/atomic-25.f90: Remove sorry, fix + add checks.
* gfortran.dg/gomp/atomic-26.f90: Likewise.
* gfortran.dg/gomp/atomic-21.f90: New test.
Jonathan Wakely [Sun, 12 Dec 2021 21:16:25 +0000 (21:16 +0000)]
libstdc++: Make ranges::size and ranges::empty check for unbounded arrays
Passing IncompleteType(&)[] to ranges::begin produces an error outside
the immediate context, which is fine for ranges::begin, but it means
that we fail to enforce the SFINAE-able constraints for ranges::size and
ranges::size. They should not be callable for any array of unknown
bound, whether the type is complete or not. Because we don't enforce
that in their constraints, we get a hard error when they try to use
ranges::begin.
This simply adds explicit checks for arrays of unknown bound to the
constraints for ranges::size and ranges::empty. We only need to check it
for the __sentinel_size and __eq_iter_empty concepts, because those are
the ones that are relevant to arrays, and which try to use
ranges::begin.
libstdc++-v3/ChangeLog:
* include/bits/ranges_base.h (ranges::size, ranges::empty): Add
explicit check for unbounded arrays before using ranges::begin.
* testsuite/std/ranges/access/empty.cc: Check handling of unbounded
arrays.
* testsuite/std/ranges/access/size.cc: Likewise.
Jonathan Wakely [Sun, 12 Dec 2021 21:15:17 +0000 (21:15 +0000)]
libstdc++: Fix std::regex_replace for strings with embedded null [PR103664]
The overload of std::regex_replace that takes a std::basic_string as the
fmt argument (for the replacement string) is implemented in terms of the
one taking a const C*, which uses std::char_traits to find the length.
That means it stops at a null character, even though the basic_string
might have additional characters beyond that.
Rather than duplicate the implementation of the const C* one for the
std::basic_string case, this moves that implementation to a new
__regex_replace function which takes a const C* and a length. Then both
the std::basic_string and const C* overloads can call that (with the
latter using char_traits to find the length to pass to the new
function).
libstdc++-v3/ChangeLog:
PR libstdc++/103664
* include/bits/regex.h (__regex_replace): Declare.
(regex_replace): Use it.
* include/bits/regex.tcc (__regex_replace): Replace regex_replace
definition with __regex_replace.
* testsuite/28_regex/algorithms/regex_replace/char/103664.cc: New test.
Martin Liska [Mon, 13 Dec 2021 10:56:24 +0000 (11:56 +0100)]
docs: add missing @item for the first item
gcc/ChangeLog:
* doc/extend.texi: Use @item for the first @itemx entry.
Jakub Jelinek [Mon, 13 Dec 2021 08:51:17 +0000 (09:51 +0100)]
pch: Small cleanup
> Fixed thusly, compile tested on x86_64-linux, committed to trunk.
Here is a small cleanup. IMHO we should use gt_pointer_operator instead of
specifying manually void (*) (void *, void *) or
void (*) (void *, void *, void *) so that next time we want to change it,
we don't have to trace all the spots. I was afraid it wouldn't work due to
header dependencies, but it works well. gengtype generated files also
use gt_pointer_operator.
2021-12-13 Jakub Jelinek <jakub@redhat.com>
* machmode.h (gt_pch_nx): Use gt_pointer_operator as type of second
argument instead of equivalent void (*) (void *, void *, void *).
* poly-int.h (gt_pch_nx): Likewise.
* wide-int.h (gt_pch_nx): Likewise.
* config/aarch64/aarch64-sve-builtins.cc (gt_pch_nx): Likewise.
Jan Hubicka [Mon, 13 Dec 2021 08:38:53 +0000 (09:38 +0100)]
Do not ICE on ternary expressions when calculating value ranges
gcc/ChangeLog:
2021-12-12 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103513
* ipa-fnsummary.c (evaluate_conditions_for_known_args): Do not ICE
on ternary expression.
gcc/testsuite/ChangeLog:
2021-12-12 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103513
* gcc.c-torture/compile/pr103513.c: New test.
Kewen Lin [Mon, 13 Dec 2021 05:27:51 +0000 (23:27 -0600)]
pragma: Update target option node when optimization changes [PR103515]
For a function with optimize pragma, it's possible that the target
options change as optimization options change. Now we create one
optimization option node when optimize pragma parsing, but don't
create target option node for possible target option changes. It
makes later processing not detect the target options can actually
change and further doesn't update the target options accordingly.
This patch is to check whether target options have changed when
creating one optimization option node for pragma optimize, and
make one target option node if needed. The associated test case
shows the difference. Without this patch, the function foo1 will
perform unrolling which is unexpected. The reason is that flag
unroll_only_small_loops isn't correctly set for it. The value
is updated after parsing function foo2, but doesn't get restored
later since both decls don't have DECL_FUNCTION_SPECIFIC_TARGET
set and the hook thinks we don't need to switch. With this patch,
there is no unrolling for foo1, which is also consistent with the
behavior by replacing pragma by attribute whether w/ and w/o this
patch.
As Martin noted, this change does the similar thing like what his
previous commit r12-1039 did.
gcc/ChangeLog:
PR target/103515
* attribs.c (decl_attributes): Check if target options change and
create one node if so.
gcc/testsuite/ChangeLog:
PR target/103515
* gcc.target/powerpc/pr103515.c: New test.
GCC Administrator [Mon, 13 Dec 2021 00:16:28 +0000 (00:16 +0000)]
Daily bump.
Jonathan Wakely [Tue, 9 Nov 2021 12:56:43 +0000 (12:56 +0000)]
Replace gnu::unique_ptr with std::unique_ptr
Now that GCC is compiled as C++11 there is no need to keep the C++03
implementation of gnu::unique_ptr.
This removes the unique-ptr.h header and replaces it with <memory> in
system.h, and changes the INCLUDE_UNIQUE_PTR macro to INCLUDE_MEMORY.
Uses of gnu::unique_ptr and gnu::move can be replaced with
std::unique_ptr and std::move. There are no uses of unique_xmalloc_ptr
or xmalloc_deleter in GCC.
gcc/analyzer/ChangeLog:
* engine.cc: Define INCLUDE_MEMORY instead of INCLUDE_UNIQUE_PTR.
gcc/c-family/ChangeLog:
* known-headers.cc: Define INCLUDE_MEMORY instead of
INCLUDE_UNIQUE_PTR.
* name-hint.h: Likewise.
(class name_hint): Use std::unique_ptr instead of gnu::unique_ptr.
gcc/c/ChangeLog:
* c-decl.c: Define INCLUDE_MEMORY instead of INCLUDE_UNIQUE_PTR.
* c-parser.c: Likewise.
gcc/cp/ChangeLog:
* error.c: Define INCLUDE_MEMORY instead of
INCLUDE_UNIQUE_PTR.
* lex.c: Likewise.
* name-lookup.c: Likewise.
(class namespace_limit_reached): Use std::unique_ptr instead of
gnu::unique_ptr.
(suggest_alternatives_for): Use std::move instead of gnu::move.
(suggest_alternatives_in_other_namespaces): Likewise.
* parser.c: Define INCLUDE_MEMORY instead of INCLUDE_UNIQUE_PTR.
gcc/ChangeLog:
* Makefile.in: Remove unique-ptr-tests.o.
* selftest-run-tests.c (selftest::run_tests): Remove
unique_ptr_tests_cc_tests.
* selftest.h (unique_ptr_tests_cc_tests): Remove.
* system.h: Check INCLUDE_MEMORY instead of INCLUDE_UNIQUE_PTR
and include <memory> instead of "unique-ptr.h".
* unique-ptr-tests.cc: Removed.
include/ChangeLog:
* unique-ptr.h: Removed.
Antoni Boucher [Sun, 12 Dec 2021 21:16:21 +0000 (16:16 -0500)]
libgccjit: Add support for setting the link section of global variables [PR100688]
2021-12-12 Antoni Boucher <bouanto@zoho.com>
gcc/jit/
PR target/100688
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_18): New ABI
tag.
* docs/topics/expressions.rst: Add documentation for the
function gcc_jit_lvalue_set_link_section.
* jit-playback.h: New function (set_link_section).
* jit-recording.c: New function (set_link_section) and
support for setting the link section.
* jit-recording.h: New function (set_link_section) and new
field m_link_section.
* libgccjit.c: New function (gcc_jit_lvalue_set_link_section).
* libgccjit.h: New function (gcc_jit_lvalue_set_link_section).
* libgccjit.map (LIBGCCJIT_ABI_18): New ABI tag.
gcc/testsuite/
PR target/100688
* jit.dg/all-non-failing-tests.h: Mention new test
link-section-assembler.
* jit.dg/test-link-section-assembler.c: New test.
* jit.dg/jit.exp: New helper function to test that the
assembly contains a pattern.
Roger Sayle [Thu, 9 Dec 2021 09:45:28 +0000 (10:45 +0100)]
nvptx: Add (experimental) support for HFmode with -misa=sm_53
The recent flurry of activity around HFmode on gcc-patches intrigued me
to investigate adding HFmode support to the nvptx backend. NVidia GPUs
with an SM ISA above 5.3 support IEEE 16-bit floating point instructions.
Hence, this patch adds support for -misa=sm_53, and implements some
backend patterns/insns sufficient for a proof-of-concept prototype.
The following has been tested on nvptx-none, hosted on x86_64-pc-linux-gnu
with a "make" and "make -k check" with no new failures.
gcc/ChangeLog:
* config/nvptx/nvptx-opts.h (ptx_isa): Add PTX_ISA_SM53 ISA level
to enumeration.
* config/nvptx/nvptx.opt: Add sm_53 to -misa.
* config/nvptx/nvptx-modes.def: Add support for HFmode.
* config/nvptx/nvptx.h (TARGET_SM53):
New helper macro to conditionalize functionality on target ISA.
* config/nvptx/nvptx-c.c (nvptx_cpu_cpp_builtins): Add __PTX_SM__
support for the new ISA levels.
* config/nvptx/nvptx.c (nvtx_ptx_type_from_mode): Support new HFmode
with the ".f16" suffix/qualifier.
(nvptx_file_start): Add support for TARGET_SM53.
(nvptx_omp_device_kind_arch_isa): Add support for TARGET_SM53
and tweak TARGET_SM35.
(nvptx_scalar_mode_supported_p): Target hook with conditional
HFmode support on TARGET_SM53 and higher.
(nvptx_libgcc_floating_mode_supported_p): Likewise.
(TARGET_SCALAR_MODE_SUPPORTED_P): Use nvptx_scalar_mode_supported_p.
(TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P): Likewise, use new hook.
* config/nvptx/nvptx.md (*movhf_insn): New define_insn.
(movhf): New define_expand for HFmode moves.
(addhf3, subhf3, mulhf, extendhf<mode>2, trunc<mode>hf2): New
instructions conditional on TARGET_SM53 (i.e. -misa=sm_53).
gcc/testsuite/ChangeLog:
* gcc.target/nvptx/float16-1.c: New test case.
Jan Hubicka [Sun, 12 Dec 2021 10:38:13 +0000 (11:38 +0100)]
Terminate BB analysis on NULL memory access in ipa-pure-const and ipa-modref
As discussed in the PR, we miss some optimization becuase
gimple-ssa-isolate-paths turns NULL memory accesses to volatile and adds
__builtin_trap after them. This is seen as a side-effect by IPA analysis
and additionally the (fully unreachable) builtin_trap is believed to load
all global memory.
I think we should think of less intrusive gimple representation of this, but
it is also easy enough to special case that in IPA analysers as done in
this patch. This is a win even if we improve the representation since
gimple-ssa-isolate-paths is run late and this way we improve optimization
early.
This affects 1623 functions during cc1plus link.
Bootstrapped/regtested x86_64-linux, comitted.
gcc/ChangeLog:
2021-12-12 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103665
* ipa-modref.c (modref_access_analysis::analyze): Terminate BB
analysis on NULL memory access.
* ipa-pure-const.c (analyze_function): Likewise.
GCC Administrator [Sun, 12 Dec 2021 00:16:45 +0000 (00:16 +0000)]
Daily bump.
Antoni Boucher [Sun, 12 Dec 2021 00:01:15 +0000 (19:01 -0500)]
libgccjit: Add support for TLS variable [PR95415]
2021-12-11 Antoni Boucher <bouanto@zoho.com>
gcc/jit/
PR target/95415
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_17): New ABI
tag.
* docs/topics/expressions.rst: Add document for the function
gcc_jit_lvalue_set_tls_model.
* jit-playback.h: New function (set_tls_model).
* jit-recording.c: New function (set_tls_model), new
variables (tls_models and tls_model_enum_strings) and support
for setting the tls model.
* jit-recording.h: New function (set_tls_model) and new
field m_tls_model.
* libgccjit.c: New function (gcc_jit_lvalue_set_tls_model).
* libgccjit.h: New function (gcc_jit_lvalue_set_tls_model)
and new enum (gcc_jit_tls_model).
* libgccjit.map (LIBGCCJIT_ABI_17): New ABI tag.
gcc/testsuite/
PR target/95415
* jit.dg/all-non-failing-tests.h: Add test-tls.c.
* jit.dg/test-tls.c: New test.
Antoni Boucher [Sat, 11 Dec 2021 21:42:54 +0000 (16:42 -0500)]
libgccjit: Add support for types used by atomic builtins [PR96066] [PR96067]
2021-12-11 Antoni Boucher <bouanto@zoho.com>
gcc/jit/
PR target/96066
PR target/96067
* jit-builtins.c: Implement missing types for builtins.
* jit-recording.c:: Allow sending a volatile const void * as
argument.
* jit-recording.h: New functions (is_volatile, is_const) and
allow comparing qualified types.
gcc/testsuite/
PR target/96066
PR target/96067
* jit.dg/all-non-failing-tests.h: Add test-builtin-types.c.
* jit.dg/test-builtin-types.c
* jit.dg/test-error-bad-assignment.c
* jit.dg/test-fuzzer.c: Add fuzzing for type qualifiers.
Signed-off-by: Antoni Boucher <bouanto@zoho.com>
Harald Anlauf [Fri, 10 Dec 2021 21:41:24 +0000 (22:41 +0100)]
Fortran: fix checking of elemental functions of type CLASS
gcc/fortran/ChangeLog:
PR fortran/103606
* resolve.c (resolve_fl_procedure): Do not access CLASS components
before class container has been built.
gcc/testsuite/ChangeLog:
PR fortran/103606
* gfortran.dg/pr103606.f90: New test.
Jan Hubicka [Sat, 11 Dec 2021 19:45:02 +0000 (20:45 +0100)]
Avoid updating hot bb threshold in call speculation code
This patch removes apparently forgotten debugging hack (which got in during
the speculative call patchset) which reduces hot bb threshold. This does not
make sense since it is set and reset randomly as the summaries are processed.
One problem is that we set the BB threshold to make certain BBs hot and hten
unrolling or vectorization may reduce it to some fraction of the count that
makes it cold. We may want to add some buffer and divide the value by,
say 32, but that shoulid be done independently of speculative calls.
gcc/ChangeLog:
2021-12-11 Jan Hubicka <hubicka@ucw.cz>
* ipa-profile.c (ipa_profile): Do not update hot bb threshold.
Jan Hubicka [Sat, 11 Dec 2021 19:37:18 +0000 (20:37 +0100)]
Fix handling of thunks in ipa-modref
Thunks are not transparent for ipa-modref summary since it cares about offsets
from pointer parameters and also for virtual thunk about the read from memory
in there. We however use function_or_virtual_thunk_symbol to get the summary
that may lead to wrong code (and does in two testsuite testcases with patch
I am working on). This is a first aid fix that is bacportable to gcc 11.
We could easily produce summary for thunk on demand. I will look into it
incrementally. It is not very important since we usually inline the thunk when
we devirutalize...
Bootstrapped/regtested x86_64-linux, will commit it shortly.
gcc/ChangeLog:
2021-12-11 Jan Hubicka <hubicka@ucw.cz>
* ipa-modref.c (get_modref_function_summary): Use ultimate_alias_target.
(ignore_edge): Likewise.
(compute_parm_map): Likewise.
(modref_propagate_in_scc): Likewise.
(modref_propagate_flags_in_scc): Likewise.
Rasmus Villemoes [Wed, 27 Oct 2021 10:21:49 +0000 (12:21 +0200)]
libgcc: vxcrtstuff.c: make ctor/dtor functions static
When the translation unit itself creates pointers to the ctors/dtors
in a specific section handled by the linker (whether .init_array or
.ctors.*), there's no reason for the functions to have external
linkage. That ends up polluting the symbol table in the running
kernel.
This makes vxcrtstuff.c on par with the generic crtstuff.c which also
defines e.g. frame_dummy and __do_global_dtors_aux static.
libgcc/
* config/vxcrtstuff.c: Make constructor and destructor
functions static when possible.
Rasmus Villemoes [Thu, 28 Oct 2021 11:50:22 +0000 (13:50 +0200)]
libgcc: vxcrtstuff.c: remove ctor/dtor declarations
These declarations prevent the priority given in the
constructor/destructor attributes from taking effect, thus emitting
the function pointers in the ordinary (lowest-priority)
.init_array/.fini_array sections.
libgcc/
* config/vxcrtstuff.c: Remove constructor/destructor
declarations.
Jason Merrill [Fri, 10 Dec 2021 16:21:50 +0000 (11:21 -0500)]
libstdc++: check length in string append [PR103534]
In the testcase for 103534 we get a warning about append leading to memcpy
of a very large number of bytes overflowing the buffer. This turns out to
be because we weren't calling _M_check_length for string append. Rather
than do that directly, let's go through the public pointer append that calls
it.
PR c++/103534
libstdc++-v3/ChangeLog:
* include/bits/basic_string.h (append (basic_string)): Call pointer
append instead of _M_append directly.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wstringop-overflow-8.C: New test.
GCC Administrator [Sat, 11 Dec 2021 00:16:30 +0000 (00:16 +0000)]
Daily bump.
Iain Sandoe [Fri, 10 Dec 2021 21:20:38 +0000 (21:20 +0000)]
libgcc, Darwin: Update darwin10 unwinder shim dependencies.
We include libgcc_tm.h to provide a prototype for this shim
so add that to the make dependencies.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libgcc/ChangeLog:
* config/t-darwin: Add libgcc_tm.h to the dependencies
for darwin10-unwind-find-enc-func.
David Malcolm [Fri, 10 Dec 2021 14:28:48 +0000 (09:28 -0500)]
jit: set DECL_CONTEXT of RESULT_DECL [PR103562]
libgccjit was failing to set the DECL_CONTEXT of function RESULT_DECLs,
leading to them failing to be properly handled by the inlining machinery.
Fixed thusly.
gcc/jit/ChangeLog:
PR jit/103562
* jit-playback.c (gcc::jit::playback::context::new_function): Set
DECL_CONTEXT of the result_decl.
gcc/testsuite/ChangeLog:
PR jit/103562
* jit.dg/all-non-failing-tests.h: Add comment about...
* jit.dg/test-pr103562.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Jason Merrill [Fri, 10 Dec 2021 10:45:01 +0000 (05:45 -0500)]
symtab: fix comment typo
gcc/ChangeLog:
* symtab.c (symtab_node::equal_address_to): Fix comment typo.
Marek Polacek [Fri, 10 Dec 2021 18:07:19 +0000 (13:07 -0500)]
c++: Add test for C++23 auto(x)
I was curious if our auto(x) works in contexts like bit-field width
and similar. It appears that it does. Might be worth adding a test
for it.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/auto-fncast10.C: New test.
Harald Anlauf [Thu, 9 Dec 2021 21:57:13 +0000 (22:57 +0100)]
Fortran: fix check for pointer dummy arguments with INTENT(IN)
gcc/fortran/ChangeLog:
PR fortran/103418
* check.c (variable_check): Replace previous check of procedure
dummy arguments with INTENT(IN) attribute when passed to intrinsic
procedures by gfc_check_vardef_context.
* expr.c (gfc_check_vardef_context): Correct check of INTENT(IN)
dummy arguments for the case of sub-components of a CLASS pointer.
gcc/testsuite/ChangeLog:
PR fortran/103418
* gfortran.dg/move_alloc_8.f90: Adjust error messages.
* gfortran.dg/pointer_intent_9.f90: New test.
Jakub Jelinek [Fri, 10 Dec 2021 16:05:04 +0000 (17:05 +0100)]
libstdc++: Add std::time_get %r support [PR71367]
This incremental patch adds std::time_get %r support (%p was added already
in the previous patch). The _M_am_fm_format method previously in the header
unfortunately had wrong arguments and so was useless, so the largest
complication in this patch is exporting a new symbol in the right symbol
version.
2021-12-10 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/71367
* config/locale/dragonfly/time_members.cc (_M_initialize_timepunct):
Initialize "C" _M_am_pm_format to %I:%M:%S %p rather than empty
string.
* config/locale/gnu/time_members.cc (_M_initialize_timepunct):
Likewise.
* config/locale/generic/time_members.cc (_M_initialize_timepunct):
Likewise.
* include/bits/locale_facets_nonio.h (_M_am_pm_format): New method.
* include/bits/locale_facets_nonio.tcc (_M_extract_via_format): Handle
%r.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.30): Export _M_am_pm_format
with const _CharT** argument, ensure it isn't exported in GLIBCXX_3.4.
* testsuite/22_locale/time_get/get/char/71367.cc: New test.
* testsuite/22_locale/time_get/get/wchar_t/71367.cc: New test.
Jakub Jelinek [Fri, 10 Dec 2021 16:01:28 +0000 (17:01 +0100)]
libstdc++: Some time_get fixes [PR78714]
The following patch is an attempt to fix various time_get related issues.
Sorry, it is long...
One of them is PR78714. It seems _M_extract_via_format has been written
with how strftime behaves in mind rather than how strptime behaves.
There is a significant difference between the two, for strftime %a and %A
behave differently etc., one emits an abbreviated name, the other full name.
For strptime both should behave the same and accept both the full or
abbreviated names. This needed large changes in _M_extract_name, which
was assuming the names are unique and names aren't prefixes of other names.
The _M_extract_name changes allow to deal with those cases. As can be
seen in the new testcase, e.g. for %b and english locales we need to
accept both Apr and April. If we see Apr in the input, the code looks
at whether there is end right after those 3 chars or if the next
character doesn't match characters in the longer names; in that case
it accepts the abbreviated name. Otherwise, if the input has Apri, it
commits to a longer name and fails if it isn't April. This behavior is
different from strptime, which for %bix and Aprix accepts it, but for
an input iterator I'm afraid we can't do better, we can't go back (peek
more than the current character).
Another case is that %d and %e in strptime should work the same, while
previously the code was hardcoding that %d would be 01 to 31 and %e
1 to 31 (with leading 0 replaced by space).
strptime POSIX 2009 documentation seems to suggest for numbers it should
accept up to the specified number of digits rather than exactly that number
of digits:
The pattern "[x,y]" indicates that the value shall fall within the range
given (both bounds being inclusive), and the maximum number of characters scanned
shall be the maximum required to represent any value in the range without leading
zeros.
so by my reading "1:" is valid for "%H:".
The glibc strptime implementation actually skips any amount of whitespace
in all the cases where a number is read, my current patch skips a single
space at the start of %d/%e but not the others, but doesn't subtract the
space length from the len characters.
One option would be to do the leading whitespace skipping in _M_extract_num
but take it into account how many digits can be read.
This matters for " 12:" and "%H:", but not for " 12:" and " %H:"
as in the latter case the space in the format string results in all the
whitespace at the start to be consumed.
Note, the allowing of a single digit rather than 2 changes a behavior in
other ways, e.g. when seeing 40 in a number for range [1, 31] we reject
it as before, but previously we'd keep *ret == '4' because it was assuming
it has to be 2 digits and 40 isn't valid, so we know error already on the
4, but now we accept the 4 as value and fail iff the next format string
doesn't match the 0.
Also, previously it wasn't really checking the number was in the right
range, it would accept 00 for [1, 31] numbers, or would accept 39.
Another thing is that %I was parsing 12 as tm_hour 12 rather than as tm_hour 0
like e.g. glibc does.
Another thing is that %t was matching a single tab and %n a single newline,
while strptime docs say it skips over whitespace (again, zero or more).
Another thing is that %p wasn't handled at all, I think this was the main
cause of
FAIL: 22_locale/time_get/get_time/char/2.cc execution test
FAIL: 22_locale/time_get/get_time/char/wrapped_env.cc execution test
FAIL: 22_locale/time_get/get_time/char/wrapped_locale.cc execution test
FAIL: 22_locale/time_get/get_time/wchar_t/2.cc execution test
FAIL: 22_locale/time_get/get_time/wchar_t/wrapped_env.cc execution test
FAIL: 22_locale/time_get/get_time/wchar_t/wrapped_locale.cc execution test
before this patch, because en_HK* locales do use %I and %p in it.
The patch handles %p only if it follows %I (i.e. when the hour is parsed
first), which is the more usual case (in glibc):
grep '%I' localedata/locales/* | grep '%I.*%p' | wc -l
282
grep '%I' localedata/locales/* | grep -v '%I.*%p' | wc -l
44
grep '%I' localedata/locales/* | grep -v '%p' | wc -l
17
The last case use %P instead of %p in t_fmt_ampm, not sure if that one
is never used by strptime because %P isn't handled by strptime.
Anyway, the right thing to handle even %p%I would be to pass some state
around through all the _M_extract_via_format calls like glibc passes
struct __strptime_state
{
unsigned int have_I : 1;
unsigned int have_wday : 1;
unsigned int have_yday : 1;
unsigned int have_mon : 1;
unsigned int have_mday : 1;
unsigned int have_uweek : 1;
unsigned int have_wweek : 1;
unsigned int is_pm : 1;
unsigned int want_century : 1;
unsigned int want_era : 1;
unsigned int want_xday : 1;
enum ptime_locale_status decided : 2;
signed char week_no;
signed char century;
int era_cnt;
} s;
around. That is for the %p case used like:
if (s.have_I && s.is_pm)
tm->tm_hour += 12;
during finalization, but handles tons of other cases which it is unclear
if libstdc++ needs or doesn't need to handle, e.g. strptime if one
specifies year and yday computes wday/mon/day from it, etc. basically for
the redundant fields computes them from other fields if those have been
parsed and are sufficient to determine it.
To do this we'd need to change ABI for the _M_extract_via_format,
though sure, we could add a wrapper around the new one with the old
arguments that would just use a dummy state. And we'd need a new
_M_whatever finalizer that would do those post parsing tweaks.
Also, %% wasn't handled.
For a whitespace in the strings there was inconsistent behavior,
_M_extract_via_format would require exactly that whitespace char (say
matching space, or matching tab), while the caller follows what
https://eel.is/c++draft/locale.time.get#members-8.5 says, that
when encountering whitespace it skips whitespace in the format and
then whitespace in the input if any. I've changed _M_extract_via_format
to skip whitespace in the input (looping over format isn't IMHO necessary,
because next iteration of the loop will handle that too).
Tested on x86_64-linux by make check-target-libstdc++-v3, ok for trunk
if it passes full bootstrap/regtest?
For the new 3.cc testcases, I have included hopefully correctly
corresponding C testcase using strptime in an attachment, and to the
extent where it can be compared (e.g. strptime on failure just
returns NULL, doesn't tell where it exactly stopped) I think the
only difference is that
str = "Novembur";
format = "%bembur";
ret = strptime (str, format, &time);
case where strptime accepts it but there is no way to do it with input
operator.
I admit I don't have libc++ or other STL libraries around to be able to
check how much the new 3.cc matches or disagrees with other implementations.
Now, the things not handled by this patch but which should be fixed (I
probably need to go back to compiler work) or at least looked at:
1) seems %j, %r, %U, %w and %W aren't handled (not sure if all of them
are already in POSIX 2009 or some are later)
2) I haven't touched the %y/%Y/%C and year handling stuff, that is
definitely not matching what POSIX 2009 says:
C All but the last two digits of the year {2}; leading zeros shall be permitted but shall not be required. A leading '+' or '−' character shall be permitted before
any leading zeros but shall not be required.
y The last two digits of the year. When format contains neither a C conversion specifier nor a Y conversion specifier, values in the range [69,99] shall refer to
years 1969 to 1999 inclusive and values in the range [00,68] shall refer to years 2000 to 2068 inclusive; leading zeros shall be permitted but shall not be re‐
quired. A leading '+' or '−' character shall be permitted before any leading zeros but shall not be required.
Note: It is expected that in a future version of this standard the default century inferred from a 2-digit year will change. (This would apply to all commands
accepting a 2-digit year as input.)
Y The full year {4}; leading zeros shall be permitted but shall not be required. A leading '+' or '−' character shall be permitted before any leading zeros but
shall not be required.
I've tried to avoid making changes to _M_extract_num for these as well
to keep current status quo (the __len == 4 cases). One thing is what
to do for things with %C %y and/or %Y in the formats, another thing
is what to do in the methods that directly perform _M_extract_num
for year
3) the above question what to do for leading whitespace of any numbers
being parsed
4) the %p%I issue mentioned above and generally what to do if we
pass state and have finalizers at the end of parsing
5) _M_extract_via_format is also inconsistent with its callers on handling
the non-whitespace characters in between format specifiers, the caller
follows https://eel.is/c++draft/locale.time.get#members-8.6 and does
case insensitive comparison:
// TODO real case-insensitive comparison
else if (__ctype.tolower(*__s) == __ctype.tolower(*__fmt) ||
__ctype.toupper(*__s) == __ctype.toupper(*__fmt))
while _M_extract_via_format only compares exact characters:
// Verify format and input match, extract and discard.
if (__format[__i] == *__beg)
++__beg;
(another question is if there is a better way how to do real
case-insensitive comparison of 2 characters and whether we e.g. need
to handle the Turkish i/İ and ı/I which have different number of bytes
in UTF-8)
6) _M_extract_name does something weird for case-sensitivity,
// NB: Some of the locale data is in the form of all lowercase
// names, and some is in the form of initially-capitalized
// names. Look for both.
if (__beg != __end)
and
if (__c == __names[__i1][0]
|| __c == __ctype.toupper(__names[__i1][0]))
for the first letter while just
__name[__pos] == *__beg
on all the following letters. strptime says:
In case a text string (such as the name of a day of the week or a month
name) is to be matched, the comparison is case insensitive.
so supposedly all the _M_extract_name comparisons should be case
insensitive.
2021-12-10 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/78714
* include/bits/locale_facets_nonio.tcc (_M_extract_via_format):
Mention in function comment it interprets strptime format string
rather than strftime. Handle %a and %A the same by accepting both
full and abbreviated names. Similarly handle %h, %b and %B the same.
Handle %d and %e the same by accepting possibly optional single space
and 1 or 2 digits. For %I store tm_hour 0 instead of tm_hour 12. For
%t and %n skip any whitespace. Handle %p and %%. For whitespace in
the string skip any whitespace.
(_M_extract_num): For __len == 2 accept 1 or 2 digits rather than
always 2. Don't punt early if __value * __mult is larget than __max
or smaller than __min - __mult, instead punt if __value > __max.
At the end verify __value is in between __min and __max and punt
otherwise.
(_M_extract_name): Allow non-unique names or names which are prefixes
of other names. Don't recompute lengths of names for every character.
* testsuite/22_locale/time_get/get/char/3.cc: New test.
* testsuite/22_locale/time_get/get/wchar_t/3.cc: New test.
* testsuite/22_locale/time_get/get_date/char/12791.cc (test01): Use
62 instead 60 and expect 6 to be accepted and thus *ret01 == '2'.
* testsuite/22_locale/time_get/get_date/wchar_t/12791.cc (test01):
Similarly.
* testsuite/22_locale/time_get/get_time/char/2.cc (test02): Add " PM"
to the string.
* testsuite/22_locale/time_get/get_time/char/5.cc (test01): Expect
tm_hour 1 rather than 0.
* testsuite/22_locale/time_get/get_time/wchar_t/2.cc (test02): Add
" PM" to the string.
* testsuite/22_locale/time_get/get_time/wchar_t/5.cc (test01): Expect
tm_hour 1 rather than 0.
Douglas B Rupp [Thu, 8 Apr 2021 17:41:11 +0000 (10:41 -0700)]
Fix inaccuracies in VxWorks LINK_SPEC
-v needs to generate a -V not -v, as most/all other ports do.
The latter causes collect2 to output exec'd collect-ld with same
switches, which in turn causes a configure test which accumulates
linker switches to contain duplicates, leading to a libstdc++ configure
failure in some configurations.
-V is typically used in such contexts to output the available
emulations.
The change also removes reference to %(link_target), long obsolete.
2021-12-07 Doug Rupp <rupp@adacore.com>
* config/vxworks.h (LINK_SPEC): Remove %(link_target).
Change %{v:-v} to %{v:-V}.
Olivier Hainque [Fri, 26 Nov 2021 17:06:45 +0000 (17:06 +0000)]
Remove assignment to STMP_FIXINC from t-vxworks
Just redundant with the default Makefile setting.
2021-12-07 Olivier Hainque <hainque@adacore.com>
* config/t-vxworks: Remove assignment to STMP_FIXINC.
Jonathan Wakely [Fri, 10 Dec 2021 11:44:29 +0000 (11:44 +0000)]
libstdc++: Guard mutex and condvar with gthreads macro [PR103638]
A mutex and condition variable is used for timed waits on atomics if
there is no "platform wait" (e.g. futex) supported. But the use of those
types wasn't guarded by the _GLIBCXX_HAS_GTHREADS macro, causing errors
for --disable-threads builds. This fix allows <atomic> to work on
targets with futexes but no gthreads.
libstdc++-v3/ChangeLog:
PR libstdc++/103638
* include/bits/atomic_timed_wait.h: Check _GLIBCXX_HAS_GTHREADS
before using std::mutex and std::__condvar.
Jonathan Wakely [Fri, 10 Dec 2021 11:39:26 +0000 (11:39 +0000)]
libstdc++: Fix definition of _GLIBCXX_NO_SLEEP config macro
If no OS function to sleep (e.g. nanosleep, usleep, Win32 Sleep etc.) is
available then configure defines the macro NO_SLEEP. But this will not
get prefixed with "_GLIBCXX_" because include/Makefile.am only does that
for macros beginning with "HAVE_". The configure script should define
_GLIBCXX_NO_SLEEP instead (which is what the code actually checks for).
libstdc++-v3/ChangeLog:
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Add _GLIBCXX_
prefix to NO_SLEEP macro.
* config.h.in: Regenerate.
* configure: Regenerate.
Rasmus Villemoes [Tue, 7 Dec 2021 12:09:38 +0000 (12:09 +0000)]
Replace t-ppccomm by t-vxworks in libgcc/config/rs6000
This removes ibm-ldouble.c and a few eabi crt files from the build
closure, which were producing objects we don't use anyway.
2021-12-07 Rasmus Villemoes <rv@rasmusvillemoes.dk>
libgcc/
* config/rs6000/t-vxworks: New file.
* config.host (powerpc*-*-vxworks*): Use it instead of
t-ppccomm.
Martin Liska [Fri, 10 Dec 2021 12:31:21 +0000 (13:31 +0100)]
param: Add missing . in description.
Fixes:
FAIL: compiler driver --help=param option(s): "^ +-.*[^:.]$" absent from output: "
--param=max-inline-functions-called-once-loop-depth= Maximum loop depth of a call which is considered for inlining functions called once"
FAIL: compiler driver --help=params option(s): "[^.]$" absent from output: "e"
gcc/ChangeLog:
* params.opt: Add missing dot.
Roger Sayle [Fri, 10 Dec 2021 12:02:04 +0000 (12:02 +0000)]
PR ipa/103601: ICE compiling CSiBE in ipa-modref's insert_kill.
This patch fixes PR ipa/103061 which is P1 regression that shows up as
an ICE in ipa-modref-tree.c's insert_kill when compiling the CSiBE
benchmark. I believe the underlying cause is that the new kill tracking
functionality wasn't anticipating memory accesses that are zero bits
wide!?. The failing source code (test case) contains the unusual lines:
typedef struct { } spinlock_t;
and
q->lock = (spinlock_t) { };
Making spinlock_t larger, or removing the assignment work around the issue.
The one line patch below to useful_for_kill_p teaches IPA that a memory
write is only useful as a "kill" if it is more than zero bits wide.
In theory, the existing known_size_p (size) test is now redundant, as
poly_int64 currently uses the value -1 for unknown size values,
but the proposed change makes the semantics clear, and defends against
possible future changes in representation.
2021-12-10 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR ipa/103601
* ipa-modref-tree.h (useful_for_kill_p): Zero width accesses aren't
useful for kill tracking.
gcc/testsuite/ChangeLog
PR ipa/103601
* gcc.dg/ipa/pr103601.c: New test case.
Andrew Stubbs [Tue, 16 Nov 2021 10:32:35 +0000 (10:32 +0000)]
amdgcn: Change offload variable table discovery
Up to now the libgomp GCN plugin has been finding the offload variables
by using a symbol lookup, but the AMD runtime requires that the symbols are
global for that to work. This was ensured by mkoffload as a post-procssing
step, but the LLVM 13 assembler no longer accepts this in the case where the
variable was previously declared differently.
This patch switches to locating the symbols directly from the
offload_var_table, which means that only one symbol needs to be forced
global.
This changes breaks the libgomp image compatibility so GOMP_VERSION_GCN has
also been bumped.
gcc/ChangeLog:
* config/gcn/mkoffload.c (process_asm): Process the variable table
completely differently.
(process_obj): Encode the varaible data differently.
include/ChangeLog:
* gomp-constants.h (GOMP_VERSION_GCN): Bump.
libgomp/ChangeLog:
* plugin/plugin-gcn.c (struct gcn_image_desc): Remove global_variables.
(GOMP_OFFLOAD_load_image): Locate the offload variables via the
table, not individual symbols.
Joel Hutton [Fri, 10 Dec 2021 10:26:42 +0000 (10:26 +0000)]
pr103523: Check for PLUS/MINUS support
Check for PLUS_EXPR/MINUS_EXPR support in vectorizable_induction.
PR103523 is an ICE on valid code:
void d(float *a, float b, int c) {
float e;
for (; c; c--, e += b)
a[c] = e;
}
This is due to not checking for PLUS_EXPR support, which is missing in
VNx2sf mode. This causes an ICE at expand time. This patch adds a check
for support in vectorizable_induction.
gcc/ChangeLog:
PR tree-optimization/103523
* tree-vect-loop.c (vectorizable_induction): Check for
PLUS_EXPR/MINUS_EXPR support.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/pr103523.c: New test.
Jonathan Wakely [Fri, 10 Dec 2021 09:06:37 +0000 (09:06 +0000)]
libstdc++: Fix diagnostic pragma push that should be pop
libstdc++-v3/ChangeLog:
* include/bits/char_traits.h: Change pragma push to pop.
Iain Buclaw [Fri, 10 Dec 2021 02:14:20 +0000 (03:14 +0100)]
d: Merge upstream dmd
3982604c5, druntime
bc58b1e9, phobos
12329adb6.
D front-end changes:
- Import dmd mainline development.
- Split off enum EXP from enum TOK.
- Integer promotions now follow C integral promotions by default.
- Implements __traits(initSymbol).
- Lowering of array construction has been moved to the dmd
front-end.
- Fix segfault in dmd.lexer from unaligned read (PR103529).
Druntime changes:
- Import druntime mainline development.
- Define SIG_BLOCK for Solaris (PR103528).
Phobos changes:
- Import phobos mainline development.
gcc/d/ChangeLog:
PR d/103529
* dmd/MERGE: Merge upstream dmd
3982604c5.
* Make-lang.in (D_FRONTEND_OBJS): Add d/root-optional.o.
* d-attribs.cc (build_attributes): Update for new front-end interface.
* d-codegen.cc (d_build_call): Likewise.
* d-compiler.cc (Compiler::paintAsType): Likewise.
* d-lang.cc (d_handle_option): Remove OPT_fpreview_intpromote, add
handling of OPT_frevert_intpromote.
* d-port.cc (Port::valcpy): Assert buffer is aligned.
* d-target.cc (Target::isVectorOpSupported): Update for new front-end
interface.
* decl.cc (layout_class_initializer): Likewise.
* expr.cc (lvalue_p): Likewise.
(binop_assignment): Likewise.
(ExprVisitor::visit): Likewise.
(ExprVisitor::visit (AssignExp *)): Remove generation of _d_arrayctor
and _d_arraysetctor library helpers.
(ExprVisitor::visit (VarExp *)): Support __traits(initSymbol).
* intrinsics.cc (expand_intrinsic_rotate): Update for new front-end
interface.
* lang.opt (fpreview=intpromote): Remove.
(frevert=intpromote): New.
* runtime.def (ARRAYCTOR): Remove.
(ARRAYSETCTOR): Remove.
* toir.cc (IRVisitor::visit): Update for new front-end interface.
* types.cc (layout_aggregate_members): Likewise.
* dmd/root/optional.d: New file.
* dmd/root/optional.h: New file.
libphobos/ChangeLog:
PR d/103528
* libdruntime/MERGE: Merge upstream druntime
bc58b1e9.
* libdruntime/Makefile.am (DRUNTIME_DSOURCES_LINUX): Remove
core/sys/linux/syscalls.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos
12329adb6.
* testsuite/libphobos.config/config.exp: Add test22523.
* libdruntime/core/sys/linux/syscalls.d: Removed.
* testsuite/libphobos.config/test22523.d: New test.
Thomas Rodgers [Thu, 9 Dec 2021 23:35:25 +0000 (15:35 -0800)]
libstdc++: Make atomic<T*>::wait() const [PR102994]
This was an oversight in the original commit adding wait/notify
to atomic<T>.
libstdc++-v3/ChangeLog:
PR libstdc++/102994
* include/bits/atomic_base.h (__atomic_base<_PTp*>::wait()):
Add const qualifier.
* include/std/atomic (atomic<_Tp*>::wait(), atomic_wait()):
Likewise.
* testsuite/29_atomics/atomic/wait_notify/102994.cc:
New test.
Cui,Lili [Fri, 26 Nov 2021 03:16:43 +0000 (11:16 +0800)]
x86: Update -mtune=tremont
Silvermont has a special handle in add_stmt_cost function, because it has in
order SIMD pipeline. But for Tremont, its SIMD pipeline is out of order,
remove Tremont from this special handle.
gcc/ChangeLog
* config/i386/i386.c (ix86_vector_costs::add_stmt_cost): Remove Tremont.
Iain Buclaw [Fri, 10 Dec 2021 00:30:19 +0000 (01:30 +0100)]
d: Align methods to MINIMUM_METHOD_BOUNDARY.
Aligns all D defined methods to MINIMUM_METHOD_BOUNDARY, improving
interoperability with C++ methods.
gcc/d/ChangeLog:
* decl.cc (get_symbol_decl): Align methods to MINIMUM_METHOD_BOUNDARY.
GCC Administrator [Fri, 10 Dec 2021 00:16:29 +0000 (00:16 +0000)]
Daily bump.
Jonathan Wakely [Thu, 9 Dec 2021 22:22:42 +0000 (22:22 +0000)]
libstdc++: Fix ambiguous comparisons for iterators in C++20
Since r11-1571 (c++: Refinements to "more constrained") was changed in
the front end, the following comment from stl_iterator.h stopped being
true:
// These extra overloads are not needed in C++20, because the ones above
// are constrained with a requires-clause and so overload resolution will
// prefer them to greedy unconstrained function templates.
The requires-clause is no longer considered when comparing unrelated
function templates. That means that the constrained operator== specified
in the standard is no longer more constrained than the pathological
comparison operators defined in the testsuite_greedy_ops.h header. This
was causing several tests to FAIL in C++20 mode:
FAIL: 23_containers/deque/types/1.cc (test for excess errors)
FAIL: 23_containers/vector/types/1.cc (test for excess errors)
FAIL: 24_iterators/move_iterator/greedy_ops.cc (test for excess errors)
FAIL: 24_iterators/normal_iterator/greedy_ops.cc (test for excess errors)
FAIL: 24_iterators/reverse_iterator/greedy_ops.cc (test for excess errors)
The solution is to restore some of the non-standard comparison operators
that are more specialized than the greedy operators in the testsuite.
libstdc++-v3/ChangeLog:
* include/bits/stl_iterator.h (operator==, operator<=>): Define
overloads for homogeneous specializations of reverse_iterator,
__normal_iterator and move_iterator.
Jonathan Wakely [Thu, 9 Dec 2021 22:14:57 +0000 (22:14 +0000)]
libstdc++: Remove bogus dg-error for effective-target c++20
This test no longer has additional errors for C++20 mode, so remove the
dg-error that is now failing, and the unnecessary dg-prune-output.
libstdc++-v3/ChangeLog:
* testsuite/20_util/scoped_allocator/69293_neg.cc: Remove
dg-error for c++20.
Jonathan Wakely [Thu, 9 Dec 2021 18:37:38 +0000 (18:37 +0000)]
libstdc++: Make std::make_exception_ptr work with -fno-exceptions [PR85813]
This allows std::make_exception_ptr to be used in a translation unit
compiled with -fno-exceptions. This works because the new implementation
added for PR 68297 doesn't need to throw or catch anything. The catch is
there to handle exceptions from the constructor of the exception object,
which we can assume won't happen in a -fno-exceptions TU and so use the
__catch macro instead. If the constructor does throw (because it's
defined in a different TU which was compiled with exceptions enabled)
then that exception will propagate to the make_exception_ptr caller.
That seems acceptable for a program that is trying to mix & match TUs
compiled with and without exceptions, and using types that throw when
constructed. That should be rare, and can't reasonably be expected to
have sensible behaviour.
This also enables the new implementation for targets that use a
non-standard calling convention for the exceptionDestructor callback
(specifically, mingw, which uses __thiscall). All we need to do is mark
the __dest_thunk function template with the right calling convention.
Finally, the useless no-op definition of make_exception_ptr (which is
only used if both RTTI and exceptions are disabled) is marked
always_inline, to ensure that the linker won't keep that definition and
discard the functional ones when both definitions of the function are
present in the link. An alternative would be to add the abi_tag
attribute to the useless definition, but making it always_inline should
work, and it's small enough to always be inlined reliably.
libstdc++-v3/ChangeLog:
PR libstdc++/85813
* libsupc++/exception_ptr.h (__dest_thunk): Add macro for
destructor calling convention.
(make_exception_ptr): Enable non-throwing implementation for
-fno-exceptions and for non-standard calling conventions. Use
always_inline attribute on the useless no-rtti no-exceptions
definition.
* testsuite/18_support/exception_ptr/64241.cc: Add -fno-rtti so
the no-op implementation is still used.
Jonathan Wakely [Thu, 9 Dec 2021 13:54:39 +0000 (13:54 +0000)]
libstdc++: Fix std::exception_ptr regressions [PR103630]
This restores support for std::make_exception_ptr<E&> and for using
std::exception_ptr in C++98.
Because the new non-throwing implementation needs to use std::decay to
handle references the original throwing implementation is used for
C++98.
We also need to change the typeid expression so it doesn't yield the
dynamic type when the function parameter is a reference to a polymorphic
type. Otherwise the new exception object could be caught by any handler
matching the dynamic type, even though the actual exception object is
only a copy of the base class, sliced to the static type.
libstdc++-v3/ChangeLog:
PR libstdc++/103630
* libsupc++/exception_ptr.h (exception_ptr): Fix exception
specifications on inline definitions.
(make_exception_ptr): Decay the template parameter. Use typeid
of the static type.
* testsuite/18_support/exception_ptr/103630.cc: New test.
Jonathan Wakely [Wed, 8 Dec 2021 20:58:11 +0000 (20:58 +0000)]
libstdc++: Implement std::ios_base::noreplace for C++23 [PR59769]
This implements my P2467R0 proposal to support opening an fstream in
exclusive mode. The new constant is also supported pre-C++23 as
std::ios_base::__noreplace.
This proposal hasn't been approved for C++23 yet, but I am confident it
will be, as this is restoring a feture found in pre-ISO C++ iostreams
implementations (and still present in the MSVC library as _Noreplace).
If the proposal fails for C++23 we can remove the ios::noreplace
name and just keep ios::__noreplace as an extension.
libstdc++-v3/ChangeLog:
PR libstdc++/59769
* config/io/basic_file_stdio.cc (fopen_mode): Add support for
exclusive mode.
* include/bits/ios_base.h (_S_noreplace): Define new enumerator.
(ios_base::__noreplace): Define.
(ios_base::noreplace): Define for C++23.
* include/std/version (__cpp_lib_ios_noreplace): Define.
* testsuite/27_io/basic_ofstream/open/char/noreplace.cc: New test.
* testsuite/27_io/basic_ofstream/open/wchar_t/noreplace.cc: New test.
Jonathan Wakely [Tue, 7 Dec 2021 15:11:15 +0000 (15:11 +0000)]
libstdc++: Allow std::condition_variable waits to be cancelled [PR103382]
std::condition_variable::wait(unique_lock<mutex>&) is incorrectly marked
noexcept, which means that the __forced_unwind exception used by NPTL
cancellation will terminate the process. It should allow exceptions to
pass through, so that a thread can be cleanly cancelled when waiting on
a condition variable.
The new behaviour is exported as a new version of the symbol, to avoid
an ABI break for existing code linked to the non-throwing definition of
the function. Code linked against older releases will have a reference
to the @GLIBCXX_3.4.11 version, andcode compiled against the new
libstdc++ will get a reference to the @@GLIBCXX_3.4.30 version.
libstdc++-v3/ChangeLog:
PR libstdc++/103382
* config/abi/pre/gnu.ver (GLIBCXX_3.4.11): Do not export old
symbol if .symver renaming is supported.
(GLIBCXX_3.4.30): Export new symbol if .symver renaming is
supported.
* doc/xml/manual/evolution.xml: Document change.
* doc/html/manual/api.html: Regenerate.
* include/bits/std_mutex.h (__condvar::wait, __condvar::wait_until):
Remove noexcept.
* include/std/condition_variable (condition_variable::wait):
Likewise.
* src/c++11/condition_variable.cc (condition_variable::wait):
Likewise.
* src/c++11/compatibility-condvar.cc (__nothrow_wait_cv::wait):
Define nothrow wrapper around std::condition_variable::wait and
export the old symbol as an alias to it.
* testsuite/30_threads/condition_variable/members/103382.cc: New test.
Jonathan Wakely [Fri, 3 Dec 2021 14:33:13 +0000 (14:33 +0000)]
libstdc++: Avoid unnecessary allocations in std::map insertions [PR92300]
Inserting a pair<Key, Value> into a map<Key, Value> will allocate a new
node and construct a pair<const Key, Value> in the node, then check if
the Key is already present in the map. That is because pair<Key, Value>
is not the same type as the map's value_type. But it only differs in the
const-qualification on the Key, and so we should be able to do the
lookup directly, without allocating a new node. This avoids allocating
and then deallocating a node for the case where the key is already found
and nothing gets inserted.
We can take this optimization further and lookup the key directly for a
pair<Key, X>, pair<const Key, X>, pair<Key&, X> etc. for any X. A strict
reading of the standard says we can only do this when we know the
allocator won't do anything funky with the value when constructing a
pair<const Key, Value> from a slightly different type. Inserting that
type only requires the value_type to be Cpp17EmplaceInsertable into the
container, and that doesn't have any requirement that the value is
unchanged (unlike Cpp17CopyInsertable and Cpp17MoveInsertable). For that
reason, the optimization is only done for maps using std::allocator.
A similar optimization can be done for map.emplace(key, value) where the
first argument is similar to the key_type and so can be looked up
without allocating a new node and constructing a key_type.
Finally, both of the insert and emplace cases can use the same
optimization when key_type is a scalar type and some other scalar is
being passed as the insert/emplace argument. Converting from one scalar
type to another won't have surprising value-altering behaviour, and has
no side effects (unlike e.g. constructing a std::string from a const
char* argument, which might allocate).
We don't need to do this for std::multimap, because we always insert the
new node even if the key is already present. So there's no benefit to
doing the lookup before allocating the new node.
libstdc++-v3/ChangeLog:
PR libstdc++/92300
* include/bits/stl_map.h (insert(Pair&&), emplace(Args&&...)):
Check whether the arguments can be looked up directly without
constructing a temporary node first.
* include/bits/stl_pair.h (__is_pair): Move to here, from ...
* include/bits/uses_allocator_args.h (__is_pair): ... here.
* testsuite/23_containers/map/modifiers/emplace/92300.cc: New test.
* testsuite/23_containers/map/modifiers/insert/92300.cc: New test.
Jonathan Wakely [Thu, 2 Dec 2021 15:50:17 +0000 (15:50 +0000)]
libstdc++: Do not leak empty COW strings
When non-const references, pointers or iterators are obtained to the
contents of a COW std::basic_string, the implementation has to assume it
could result in a write to the contents. If the string was previously
shared, it does the "copy-on-write" step of creating a new copy of the
data that is not shared by another object. It also marks the string as
"leaked", so that no future copies of it will share ownership either.
However, if the string is empty then the only character in the sequence
is the terminating null, and modifying that is undefined behaviour. This
means that non-const references/pointers/iterators to an empty string
are effectively const. Since no direct modification is possible, there
is no need to "leak" the string, it can be safely shared with other
objects. This avoids unnecessary allocations to create new copies of
empty strings that can't be modified anyway.
We already did this optimization for strings that share ownership of the
static _S_empty_rep() object, but not for strings that have non-zero
capacity, and not for fully-dynamic-strings (where the _S_empty_rep()
object is never used).
With this change we avoid two allocations in the return statement:
std::string s;
s.reserve(1); // allocate
std::string s2 = s;
std::string s3 = s;
return s[0] + s2[0] + s3[0]; // leak+allocate twice
libstdc++-v3/ChangeLog:
* include/bits/cow_string.h (basic_string::_M_leak_hard): Do not
reallocate an empty string.
Jonathan Wakely [Thu, 2 Dec 2021 13:19:41 +0000 (13:19 +0000)]
libstdc++: Disable over-zealous warnings about std::string copies [PR103332]
These warnings are triggered by perfectly valid code using std::string.
They're particularly bad when --enable-fully-dynamic-string is used,
because even std::string().begin() will give a warning.
Use pragmas to stop the troublesome warnings for copies done by
std::char_traits.
libstdc++-v3/ChangeLog:
PR libstdc++/103332
PR libstdc++/102958
PR libstdc++/103483
* include/bits/char_traits.h: Suppress stringop and array-bounds
warnings.
Jonathan Wakely [Wed, 1 Dec 2021 17:56:23 +0000 (17:56 +0000)]
libstdc++: Fix non-reserved name in std::allocator base class [PR64135]
The possible base classes of std::allocator are new_allocator and
malloc_allocator, which both cause a non-reserved name to be declared in
every program that includes the definition of std::allocator. This is
non-conforming.
This change replaces __gnu_cxx::new_allocator with std::__new_allocator
which is identical except for using a reserved name. The non-standard
extension __gnu_cxx::new_allocator is preserved as a thin wrapper over
std::__new_allocator. There is no problem with the extension using a
non-reserved name now that it's not included by default in other
headers.
The same change could be done to __gnu_cxx::malloc_allocator but as it's
not the default configuration it can wait.
libstdc++-v3/ChangeLog:
PR libstdc++/64135
* config/allocator/new_allocator_base.h: Include
<bits/new_allocator.h> instead of <ext/new_allocator.h>.
(__allocator_base): Use std::__new_allocator instead of
__gnu_cxx::new_allocator.
* doc/xml/manual/allocator.xml: Document new default base class
for std::allocator.
* doc/xml/manual/evolution.xml: Likewise.
* doc/html/*: Regenerate.
* include/Makefile.am: Add bits/new_allocator.h.
* include/Makefile.in: Regenerate.
* include/experimental/memory_resource (new_delete_resource):
Use std::__new_allocator instead of __gnu_cxx::new_allocator.
* include/ext/new_allocator.h (new_allocator): Derive from
std::__new_allocator. Move implementation to ...
* include/bits/new_allocator.h: New file.
* testsuite/20_util/allocator/64135.cc: New test.
Jan Hubicka [Thu, 9 Dec 2021 20:02:17 +0000 (21:02 +0100)]
Limit inlining functions called once
as dicussed in PR ipa/103454 there are several benchmarks that regresses
for -finline-functions-called once. Runtmes:
- tramp3d with -Ofast. 31%
- exchange2 with -Ofast 11-21%
- roms O2 9%-10%
- tonto 2.5-3.5% with LTO
Build times:
- specfp2006 41% (mostly wrf that builds 71% faster)
- specint2006 1.5-3%
- specfp2017 64% (again mostly wrf)
- specint2017 2.5-3.5%
This patch adds two params to tweak the behaviour:
1) max-inline-functions-called-once-loop-depth limiting the loop depth
(this is useful primarily for exchange where the inlined function is in
loop depth 9)
2) max-inline-functions-called-once-insns
We already have large-function-insns/growth parameters, but these are
limiting also inlining small functions, so reducing them will regress
very large functions that are hot.
Because inlining functions called once is meant just as a cleanup pass
I think it makes sense to have separate limit for it.
gcc/ChangeLog:
2021-12-09 Jan Hubicka <hubicka@ucw.cz>
* doc/invoke.texi (max-inline-functions-called-once-loop-depth,
max-inline-functions-called-once-insns): New parameters.
* ipa-inline.c (check_callers): Handle
param_inline_functions_called_once_loop_depth and
param_inline_functions_called_once_insns.
(edge_badness): Fix linebreaks.
* params.opt (param=max-inline-functions-called-once-loop-depth,
param=max-inline-functions-called-once-insn): New params.
Martin Sebor [Thu, 9 Dec 2021 19:49:28 +0000 (12:49 -0700)]
Extend the offset and size of merged object references [PR103215].
Resolves:
PR tree-optimization/103215 - bogus -Warray-bounds with two pointers with different offsets each
gcc/ChangeLog:
PR tree-optimization/103215
* pointer-query.cc (access_ref::merge_ref): Extend the offset and
size of the merged object instead of using the larger.
gcc/testsuite/ChangeLog:
PR tree-optimization/103215
* gcc.dg/Wstringop-overflow-58.c: Adjust and xfail expected warnings.
* gcc.dg/Wstringop-overflow-59.c: Same.
* gcc.dg/warn-strnlen-no-nul.c: Same.
* gcc.dg/Warray-bounds-91.c: New test.
* gcc.dg/Warray-bounds-92.c: New test.
* gcc.dg/Wstringop-overflow-85.c: New test.
* gcc.dg/Wstringop-overflow-87.c: New test.
Martin Sebor [Thu, 9 Dec 2021 18:24:14 +0000 (11:24 -0700)]
Avoid expecting nonzero size for access none void* arguments [PR101751].
Resolves:
PR middle-end/101751 - attribute access none with void pointer expects nonzero size
gcc/ChangeLog:
PR middle-end/101751
* doc/extend.texi (attribute access): Adjust.
* gimple-ssa-warn-access.cc (pass_waccess::maybe_check_access_sizes):
Treat access mode none on a void* argument as expecting as few as
zero bytes.
gcc/testsuite/ChangeLog:
PR middle-end/101751
* gcc.dg/Wstringop-overflow-86.c: New test.
Frederic Konrad [Thu, 14 Jan 2021 08:08:40 +0000 (09:08 +0100)]
Fix path to t-ppc64-fp for ppc*-vxworks7* libgcc tmake_file
This fixes a basic mistake in the relative path used to reference
a rs6000 specific Makefile fragment in the libgcc configuration bits
for powerpc*-vxworks7.
2021-01-14 Fred Konrad <konrad@adacore.com>
libgcc/
* config.host (powerpc*-wrs-vxworks7*): Fix path to
rs6000/t-ppc64-fp, relative to config/ not libgcc/.
Jakub Jelinek [Thu, 9 Dec 2021 16:55:28 +0000 (17:55 +0100)]
pch: Fix aarch64 build [PR71934]
On Thu, Dec 09, 2021 at 05:42:10PM +0100, Christophe Lyon wrote:
> This also broke aarch64 I think:
> In file included from
> /tmp/6140018_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64-sve-builtins.cc:3920:0:
> ./gt-aarch64-sve-builtins.h: In function 'void
> gt_pch_p_19registered_function(void*, void*, gt_pointer_operator, void*)':
> ./gt-aarch64-sve-builtins.h:86:44: error: no matching function for call to
> 'gt_pch_nx(aarch64_sve::function_instance*, void (*&)(void*, void*, void*),
> void*&)'
> gt_pch_nx (&((*x).instance), op, cookie);
Fixed thusly.
2021-12-09 Jakub Jelinek <jakub@redhat.com>
PR pch/71934
* config/aarch64/aarch64-sve-builtins.cc (gt_pch_nx): Change type of
second argument from function with 2 pointer arguments to function
with 3 pointer arguments.
Olivier Hainque [Fri, 9 Apr 2021 15:46:42 +0000 (15:46 +0000)]
Leverage VX_CPU_PREFIX in aarch64-vxworks.h
This change tightens the CPU macro definitions issued
for VxWorks system headers on aarch64 to incorporate
the common VX_CPU_PREFIX facility, as the powerpc port
does.
The net effect for current configurations is the addition
of an actual "_VX_" prefix to the references to architecture
representative values. The absence of this prefix is most
often compensated for in system headers, but not always (when
going through particular #include paths), and this caused
a couple of spurious test failures.
2021-12-09 Olivier Hainque <hainque@adacore.com>
gcc/
* config/aarch64/aarch64-vxworks.h (TARGET_OS_CPP_BUILTINS):
Use VX_CPU_PREFIX in CPU definitions.
Martin Sebor [Mon, 6 Dec 2021 16:52:32 +0000 (09:52 -0700)]
Add a new dump function.
gcc/ChangeLog:
* pointer-query.cc (access_ref::dump): Define new function
(pointer_query::dump): Call it.
* pointer-query.h (access_ref::dump): Declare new function.
Martin Sebor [Mon, 6 Dec 2021 16:33:32 +0000 (09:33 -0700)]
Refactor compute_objsize_r into helpers.
gcc/ChangeLog:
* pointer-query.cc (compute_objsize_r): Add an argument.
(gimple_call_return_array): Pass a new argument to compute_objsize_r.
(access_ref::merge_ref): Same.
(access_ref::inform_access): Add an argument and use it.
(access_data::access_data): Initialize new member.
(handle_min_max_size): Pass a new argument to compute_objsize_r.
(handle_decl): New function.
(handle_array_ref): Pass a new argument to compute_objsize_r.
Avoid incrementing deref.
(set_component_ref_size): New function.
(handle_component_ref): New function.
(handle_mem_ref): Pass a new argument to compute_objsize_r.
Only increment deref after successfully computing object size.
(handle_ssa_name): New function.
(compute_objsize_r): Move code into helpers and call them.
(compute_objsize): Pass a new argument to compute_objsize_r.
* pointer-query.h (access_ref::inform_access): Add an argument.
(access_data::ostype): New member.
Martin Sebor [Mon, 6 Dec 2021 16:23:22 +0000 (09:23 -0700)]
Introduce access_ref::merge_ref.
gcc/ChangeLog:
* pointer-query.cc (access_ref::merge_ref): Define new function.
(access_ref::get_ref): Move code into merge_ref and call it.
* pointer-query.h (access_ref::merge_ref): Declare new function.
Martin Sebor [Sat, 4 Dec 2021 23:57:48 +0000 (16:57 -0700)]
Pass GIMPLE statement to compute_objsize.
gcc/ChangeLog:
* gimple-ssa-warn-restrict.c (builtin_access::builtin_access): Pass
GIMPLE statement to compute_objsize.
* pointer-query.cc (compute_objsize): Add a statement argument.
* pointer-query.h (compute_objsize): Define a new overload.
Martin Sebor [Sat, 4 Dec 2021 23:46:17 +0000 (16:46 -0700)]
Move bndrng from access_ref to access_data.
gcc/ChangeLog:
* gimple-ssa-warn-access.cc (check_access): Adjust to member name
change.
(pass_waccess::check_strncmp): Same.
* pointer-query.cc (access_ref::access_ref): Remove arguments.
Simpilfy.
(access_data::access_data): Define new ctors.
(access_data::set_bound): Define new member function.
(compute_objsize_r): Remove unnecessary code.
* pointer-query.h (struct access_ref): Remove ctor arguments.
(struct access_data): Declare ctor overloads.
(access_data::dst_bndrng): New member.
(access_data::src_bndrng): New member.
Martin Sebor [Sat, 4 Dec 2021 23:22:07 +0000 (16:22 -0700)]
Use the recursive form of compute_objsize [PR 103143].
gcc/ChangeLog:
PR middle-end/103143
* pointer-query.cc (gimple_call_return_array): Call compute_objsize_r.
gcc/testsuite/ChangeLog:
PR middle-end/103143
* gcc.dg/Wstringop-overflow-83.c: New test.
Marek Polacek [Thu, 25 Nov 2021 14:08:03 +0000 (09:08 -0500)]
c++: Handle auto(x) in parameter-declaration-clause [PR103401]
In C++23, auto(x) is valid, so decltype(auto(x)) should also be valid,
so
void f(decltype(auto(0)));
should be just as
void f(int);
but currently, everytime we see 'auto' in a parameter-declaration-clause,
we try to synthesize_implicit_template_parm for it, creating a new template
parameter list. The code above actually has us calling s_i_t_p twice;
once from cp_parser_decltype_expr -> cp_parser_postfix_expression which
fails and then again from cp_parser_decltype_expr -> cp_parser_expression.
So it looks like we have f<auto, auto> and we accept ill-formed code.
This shows that we need to be more careful about synthesizing the
implicit template parameter. [dcl.spec.auto.general] says that "A
placeholder-type-specifier of the form type-constraintopt auto can be
used as a decl-specifier of the decl-specifier-seq of a
parameter-declaration of a function declaration or lambda-expression..."
so this patch turns off auto_is_... after we've parsed the decl-specifier-seq.
That doesn't quite cut it yet though, because we also need to handle an
auto nested in the decl-specifier:
void f(decltype(new auto{0}));
therefore the cp_parser_decltype change.
To accept "sizeof(auto{10})", the cp_parser_type_id_1 hunk only gives a
hard error when we're not parsing tentatively.
The cp_parser_parameter_declaration hunk broke lambda-generic-85713-2.C but
I think the error we issue with this patch is in fact correct, and clang++
agrees.
The r11-1913 change is OK: we need to make sure that we see '(auto)' after
decltype to go ahead with 'decltype(auto)'.
PR c++/103401
gcc/cp/ChangeLog:
* parser.c (cp_parser_decltype): Clear
auto_is_implicit_function_template_parm_p.
(cp_parser_type_id_1): Give errors only when !cp_parser_simulate_error.
(cp_parser_parameter_declaration): Clear
auto_is_implicit_function_template_parm_p after parsing the
decl-specifier-seq.
(cp_parser_sizeof_operand): Clear
auto_is_implicit_function_template_parm_p.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-85713-2.C: Add dg-error.
* g++.dg/cpp1y/pr60054.C: Adjust dg-error.
* g++.dg/cpp1y/pr60332.C: Likewise.
* g++.dg/cpp2a/concepts-pr84979-2.C: Likewise.
* g++.dg/cpp2a/concepts-pr84979-3.C: Likewise.
* g++.dg/cpp2a/concepts-pr84979.C: Likewise.
* g++.dg/cpp23/auto-fncast7.C: New test.
* g++.dg/cpp23/auto-fncast8.C: New test.
* g++.dg/cpp23/auto-fncast9.C: New test.
Chung-Lin Tang [Thu, 9 Dec 2021 16:38:20 +0000 (00:38 +0800)]
openmp: Fix libgomp.c++ testsuite errors for non-offload configs
Some testcases for libgomp.c++ only works for non-shared address space offloading,
because it exercises the zero-length array section behavior for offloaded
address space, testing for NULL/non-NULL cases.
libgomp/ChangeLog:
* testsuite/libgomp.c++/target-lambda-1.C: Only run under
"target offload_device_nonshared_as"
* testsuite/libgomp.c++/target-this-3.C: Likewise.
* testsuite/libgomp.c++/target-this-4.C: Likewise.
Olivier Hainque [Sun, 28 Nov 2021 15:21:25 +0000 (15:21 +0000)]
Provide vxworks alternate stdint.h during the build
This change arranges to provide the vxworks alternate stdint.h
at build time instead of at install time, so it is used instead
of the system one while building the libraries.
This is a lot more consistent and helps the build on configurations
where the system does not come with stdint.h at all.
The change uses a similar mechanism as the one previsouly introduced
for glimits.h and takes the opportunity to simplify the glimits.h
command to use an automatic variable.
This introduces an indirect dependency on the VxWorks version.h
for vxcrtstuff objects, for which we then need to apply the same
tricks as for libgcc2 regarding include paths (to select the system
header instead of the gcc one).
2021-02-12 Olivier Hainque <hainque@adacore.com>
Rasmus Villemoes <rv@rasmusvillemoes.dk>
gcc/
* Makefile.in (T_STDINT_GCC_H): New variable, path to
stdint-gcc.h that a target configuration may override when
use_gcc_stdint is "provide".
(stmp-int-hdrs): Depend on it and copy that for
USE_GCC_INT=provide.
* config.gcc (vxworks): Revert to use_gcc_stdint=provide.
* config/t-vxworks (T_STDINT_GCC_H): Define, as vxw-stdint-gcc.h.
(vxw-stdint-gcc.h): New target, produced from the original
stdint-gcc.h.
(vxw-glimits.h): Use an automatic variable to designate the
first and only prerequisite.
* config/vxworks/stdint.h: Remove.
libgcc/
* config/t-vxworks: Set CRTSTUFF_T_CFLAGS to
$(LIBGCC2_INCLUDES).
* config/t-vxworks7: Likewise.
Iain Sandoe [Mon, 6 Dec 2021 07:50:08 +0000 (07:50 +0000)]
Darwin, PCH: Rework hooks for relocatable implementation [PR71934].
Now we have a relocatable PCH implementation we can revise the
hooks that find and use the mmapped memory. Specifically, this
removes the extra checking and diagnostic output for cases that
were likely to fail in a non-relocatable scenario.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:
PR pch/71934
* config/host-darwin.c (SAFE_ALLOC_SIZE): Remove.
(darwin_gt_pch_get_address): Rework for relocatable PCH.
(darwin_gt_pch_use_address): Likewise.
Jakub Jelinek [Thu, 9 Dec 2021 14:54:33 +0000 (15:54 +0100)]
pch: Fix up Darwin and HPUX pch_use_address hooks [PR71934]
In the last change, I've changed the arguments from void * to void *&,
but missed the fact that these hooks will in that case update the value
the caller will see in an undesirable way.
2021-12-09 Jakub Jelinek <jakub@redhat.com>
PR pch/71934
* config/host-darwin.c (darwin_gt_pch_use_address): When reading
manually the file into mapped area, update mapped_addr as
an automatic variable rather than addr which is a reference parameter.
* config/host-hpux.c (hpux_gt_pch_use_address): When reading
manually the file into mapped area, update addr as
an automatic variable rather than base which is a reference parameter.
Jakub Jelinek [Thu, 9 Dec 2021 14:40:15 +0000 (15:40 +0100)]
pch: Add support for relocation of the PCH data [PR71934]
The following patch adds support for relocation of the PCH blob on PCH
restore if we don't manage to get the preferred map slot for it.
The GTY stuff knows where all the pointers are, after all it relocates
it once during PCH save from the addresses where it was initially allocated
to addresses in the preferred map slot.
But, if we were to do it solely using GTY info upon PCH restore, we'd need
another set of GTY functions, which I think would make it less maintainable
and I think it would also be more costly at PCH restore time. Those
functions would need to call something to add bias to pointers that haven't
been marked yet and make sure not to add bias to any pointer twice.
So, this patch instead builds a relocation table (sorted list of addresses
in the blob which needs relocation) at PCH save time, stores it in a very
compact form into the gch file and upon restore, adjusts pointers in GTY
roots (that is right away in the root structures) and the addresses in the
relocation table.
The cost on stdc++.gch/O2g.gch (previously 85MB large) is about 3% file size
growth, there are 2.5 million pointers that need relocation in the gch blob
and the relocation table uses uleb128 for address deltas and needs ~1.01 bytes
for one address that needs relocation, and about 20% compile time during
PCH save (I think it is mainly because of the need to qsort those 2.5
million pointers). On PCH restore, if it doesn't need relocation (the usual
case), it is just an extra fread of sizeof (size_t) data and fseek
(in my tests real time on vanilla tree for #include <bits/stdc++.h> CU
was ~0.175s and with the patch but no relocation ~0.173s), while if it needs
relocation it took ~0.193s, i.e. 11.5% slower.
Without PCH that
#include <bits/stdc++.h>
int i;
testcase compiles with -O2 -g in ~1.199s, i.e. 6.2 times slower than PCH with
relocation and 6.9 times than PCH without relocation.
The discovery of the pointers in the blob that need relocation is done
in the relocate_ptrs hook which does the pointer relocation during PCH save.
Unfortunately, I had to make one change to the gengtype stuff due to the
nested_ptr feature of GTY, which some libcpp headers and stringpool.c use.
The relocate_ptrs hook had 2 arguments, pointer to the pointer and a cookie.
When relocate_ptrs is done, in most cases it is called solely on the
subfields of the current object, so e.g.
if ((void *)(x) == this_obj)
op (&((*x).u.fld[0].rt_rtx), cookie);
so relocate_ptrs can assert that ptr_p is within the
state->ptrs[state->ptrs_i]->obj ..
state->ptrs[state->ptrs_i]->obj+state->ptrs[state->ptrs_i]->size-sizeof(void*)
range and compute from that the address in the blob which will need
relocation (state->ptrs[state->ptrs_i]->new_addr is the new address
given to it and ptr_p-state->ptrs[state->ptrs_i]->obj is the relative
offset. Unfortunately, for nested_ptr gengtype emits something like:
{
union tree_node * x0 =
((*x).val.node.node) ? HT_IDENT_TO_GCC_IDENT (HT_NODE (((*x).val.node.node))) : NULL;
if ((void *)(x) == this_obj)
op (&(x0), cookie);
(*x).val.node.node = (x0) ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT ((x0))) : NULL;
}
so relocate_ptrs is called with an address of some temporary variable and
so doesn't know where the pointer will finally be.
So, I've added another argument to relocate_ptrs (and to
gt_pointer_operator). For the most common case I pass NULL as the new middle
argument to that function, first one remains pointer to the pointer that
needs adjustment and last the cookie. The NULL seems to be cheap to compute
and short in the gt*.[ch] files and stands for ptr_p is an address within
the this_obj's range, remember its address. For the nested_ptr case, the
new middle argument contains actual address of the pointer that might need
to be relocated, so instead of the above
op (&(x0), &((*x).val.node.node), cookie);
in there. And finally, e.g. for the reorder case I need a way to tell
restore_ptrs to ignore a particular address for the relocation purposes
and only treat it the old way. I've used for that the case when
the first and second arguments are equal.
In order to enable support for mapping PCH as fallback at different
addresses than the preferred ones, a small change is needed to the
host pch_use_address hooks. One change I've done to all of them is
the change of the type of the first argument from void * to void *&,
such that the actual address can be told to the callers (or shall I
instead use void **?), but another change that still needs to be done
in them if they want the relocation is actually not fail if they couldn't
get a preferred address, but instead modify what the first argument
refers to. I've done that only for host-linux.c and Iain is testing
similar change for host-darwin.c. Didn't change hpux, netbsd, openbsd,
solaris, mingw32 or the fallbacks because I can't test those.
Tested also with the:
--- gcc/config/host-linux.c.jj 2021-12-06 22:22:42.
007777367 +0100
+++ gcc/config/host-linux.c 2021-12-07 00:21:53.
052674040 +0100
@@ -191,6 +191,8 @@ linux_gt_pch_use_address (void *&base, s
if (size == 0)
return -1;
+base = (char *) base + ((size + 8191) & (size_t) -4096);
+
/* Try to map the file with MAP_PRIVATE. */
addr = mmap (base, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, offset);
hack which forces all PCH restores to be relocated. An earlier version of the
patch has been also regrest with base = (char *) base + 16384; in that spot,
so both relocation to a non-overlapping spot and to an overlapping spot have
been tested.
2021-12-09 Jakub Jelinek <jakub@redhat.com>
PR pch/71934
* coretypes.h (gt_pointer_operator): Use 3 pointer arguments instead
of two.
* gengtype.c (struct walk_type_data): Add in_nested_ptr argument.
(walk_type): Temporarily set d->in_nested_ptr around nested_ptr
handling.
(write_types_local_user_process_field): Pass a new middle pointer
to gt_pointer_operator op calls, if d->in_nested_ptr pass there
address of d->prev_val[2], otherwise NULL.
(write_types_local_process_field): Likewise.
* ggc-common.c (relocate_ptrs): Add real_ptr_p argument. If equal
to ptr_p, do nothing, otherwise if NULL remember ptr_p's
or if non-NULL real_ptr_p's corresponding new address in
reloc_addrs_vec.
(reloc_addrs_vec): New variable.
(compare_ptr, read_uleb128, write_uleb128): New functions.
(gt_pch_save): When iterating over objects through relocate_ptrs,
save current i into state.ptrs_i. Sort reloc_addrs_vec and emit
it as uleb128 of differences between pointer addresses into the
PCH file.
(gt_pch_restore): Allow restoring of PCH to a different address
than the preferred one, in that case adjust global pointers by bias
and also adjust by bias addresses read from the relocation table
as uleb128 differences. Otherwise fseek over it. Perform
gt_pch_restore_stringpool only after adjusting callbacks and for
callback adjustments also take into account the bias.
(default_gt_pch_use_address): Change type of first argument from
void * to void *&.
(mmap_gt_pch_use_address): Likewise.
* ggc-tests.c (gt_pch_nx): Pass NULL as new middle argument to op.
* hash-map.h (hash_map::pch_nx_helper): Likewise.
(gt_pch_nx): Likewise.
* hash-set.h (gt_pch_nx): Likewise.
* hash-table.h (gt_pch_nx): Likewise.
* hash-traits.h (ggc_remove::pch_nx): Likewise.
* hosthooks-def.h (default_gt_pch_use_address): Change type of first
argument from void * to void *&.
(mmap_gt_pch_use_address): Likewise.
* hosthooks.h (struct host_hooks): Change type of first argument of
gt_pch_use_address hook from void * to void *&.
* machmode.h (gt_pch_nx): Expect a callback with 3 pointers instead of
two in the middle argument.
* poly-int.h (gt_pch_nx): Likewise.
* stringpool.c (gt_pch_nx): Pass NULL as new middle argument to op.
* tree-cfg.c (gt_pch_nx): Likewise, except for LOCATION_BLOCK pass
the same &(block) twice.
* value-range.h (gt_pch_nx): Pass NULL as new middle argument to op.
* vec.h (gt_pch_nx): Likewise.
* wide-int.h (gt_pch_nx): Likewise.
* config/host-darwin.c (darwin_gt_pch_use_address): Change type of
first argument from void * to void *&.
* config/host-darwin.h (darwin_gt_pch_use_address): Likewise.
* config/host-hpux.c (hpux_gt_pch_use_address): Likewise.
* config/host-linux.c (linux_gt_pch_use_address): Likewise. If
it couldn't succeed to mmap at the preferred location, set base
to the actual one. Update addr in the manual reading loop instead of
base.
* config/host-netbsd.c (netbsd_gt_pch_use_address): Change type of
first argument from void * to void *&.
* config/host-openbsd.c (openbsd_gt_pch_use_address): Likewise.
* config/host-solaris.c (sol_gt_pch_use_address): Likewise.
* config/i386/host-mingw32.c (mingw32_gt_pch_use_address): Likewise.
* config/rs6000/rs6000-gen-builtins.c (write_init_file): Pass NULL
as new middle argument to op in the generated code.
* doc/gty.texi: Adjust samples for the addition of middle pointer
to gt_pointer_operator callback.
gcc/ada/
* gcc-interface/decl.c (gt_pch_nx): Pass NULL as new middle argument
to op.
gcc/c-family/
* c-pch.c (c_common_no_more_pch): Pass a temporary void * var
with NULL value instead of NULL to host_hooks.gt_pch_use_address.
gcc/c/
* c-decl.c (resort_field_decl_cmp): Pass the same pointer twice
to resort_data.new_value.
gcc/cp/
* module.cc (nop): Add another void * argument.
* name-lookup.c (resort_member_name_cmp): Pass the same pointer twice
to resort_data.new_value.