]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
22 months agolibstdc++: check for openat
Alexandre Oliva [Fri, 24 Jun 2022 02:20:53 +0000 (23:20 -0300)] 
libstdc++: check for openat

rtems6.0 has fdopendir, and fcntl.h defines AT_FDCWD and declares
openat, but there's no openat in libc.  Adjust dir-common.h to not
assume ::openat just because of AT_FDCWD.

for  libstdc++-v3/ChangeLog

* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for
openat.
* configure, config.h.in: Rebuilt.
* src/filesystem/dir-common.h (openat): Use ::openat if
_GLIBCXX_HAVE_OPENAT.
* src/filesystem/dir.cc (dir_and_pathname): Use dirfd if
_GLIBCXX_HAVE_OPENAT.

(cherry picked from commit 93070671eae44f24ba822383e17571a39257c637)

22 months agolibstdc++: Fix directory iterator build for newlib
Jonathan Wakely [Tue, 8 Feb 2022 21:05:30 +0000 (21:05 +0000)] 
libstdc++: Fix directory iterator build for newlib

When building for newlib HAVE_OPENAT and HAVE_UNLINKAT are (sometimes?)
defined, but <fcntl.h> is only included when HAVE_DIRENT_H is defined.
Since directory iterators are completely useless without <dirent.h>,
just override the HAVE_OPENAT and HAVE_UNLINKAT detection when we don't
have <dirent.h>.

libstdc++-v3/ChangeLog:

* src/filesystem/dir-common.h (_GLIBCXX_HAVE_DIRFD): Undefine
when <dirent.h> is not available.
(_GLIBCXX_HAVE_UNLINKAT):  Likewise.

(cherry picked from commit 3d5f4f76e6db0895181ebca538748379bfe6058f)

22 months agolibstdc++: Simplify resource management in directory iterators
Jonathan Wakely [Tue, 8 Feb 2022 15:57:58 +0000 (15:57 +0000)] 
libstdc++: Simplify resource management in directory iterators

This replaces the _Dir constructor that takes ownership of an existing
DIR* resource with one that takes a _Dir_base rvalue instead. This means
a raw DIR* is never passed around, but is always owned by a _Dir_base
object.

libstdc++-v3/ChangeLog:

* src/c++17/fs_dir.cc (_Dir(DIR*, const path&)): Change first
parameter to _Dir_base&&.
* src/filesystem/dir-common.h (_Dir_base(DIR*)): Remove.
* src/filesystem/dir.cc (_Dir(DIR*, const path&)): Change first
parameter to _Dir_base&&.

(cherry picked from commit 1ef6085f09b50e0aa3e5a5d15ebf8752e8aa8a72)

22 months agolibstdc++: Fix filesystem::remove_all for Windows [PR104161]
Jonathan Wakely [Mon, 7 Feb 2022 23:36:47 +0000 (23:36 +0000)] 
libstdc++: Fix filesystem::remove_all for Windows [PR104161]

The recursive_directory_iterator::__erase member was failing for
Windows, because the entry._M_type value is always file_type::none
(because _Dir_base::advance doesn't populate it for Windows) and
top.unlink uses fs::remove which sets an error using the
system_category. That meant that ec.value() was a Windows error code and
not an errno value, so the comparisons to EPERM and EISDIR failed.
Instead of depending on a specific Windows error code for attempting to
remove a directory, just use directory_entry::refresh() to query the
type first. This doesn't avoid the TOCTTOU races with directory
symlinks, but we can't avoid them on Windows without openat and
unlinkat, and creating symlinks requires admin privs on Windows anyway.

This also fixes the fs::remove_all(const path&) overload, which was
supposed to use the same logic as the other overload, but I forgot to
change it before my previous commit.

libstdc++-v3/ChangeLog:

PR libstdc++/104161
* src/c++17/fs_dir.cc (fs::recursive_directory_iterator::__erase):
[i_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Refresh entry._M_type member,
instead of checking for errno values indicating a directory.
* src/c++17/fs_ops.cc (fs::remove_all(const path&)): Use similar
logic to non-throwing overload.
(fs::remove_all(const path&, error_code&)): Add comments.
* src/filesystem/ops-common.h: Likewise.

(cherry picked from commit 5750952bec1e632d1f804f4a1bed2f74c0f3b189)

22 months agolibstdc++: Fix std::filesystem build failure for Windows
Jonathan Wakely [Fri, 4 Feb 2022 23:54:17 +0000 (23:54 +0000)] 
libstdc++: Fix std::filesystem build failure for Windows

The std::filesystem code needs to use posix::DIR not ::DIR, as that is
an alias for _WDIR on Windows.

libstdc++-v3/ChangeLog:

* src/filesystem/dir-common.h (_Dir_base::openat): Change return
type to use portable posix::DIR alias.

(cherry picked from commit 6e3419529d4e3284172f9965b4993b9f184f34d2)

22 months agolibstdc++: Fix filesystem::remove_all races [PR104161]
Jonathan Wakely [Tue, 1 Feb 2022 22:04:46 +0000 (22:04 +0000)] 
libstdc++: Fix filesystem::remove_all races [PR104161]

This fixes the remaining filesystem::remove_all race condition by using
POSIX openat to recurse into sub-directories and using POSIX unlinkat to
remove files. This avoids the remaining race where the directory being
removed is replaced with a symlink after the directory has been opened,
so that the filesystem::remove("subdir/file") resolves to "target/file"
instead, because "subdir" has been removed and replaced with a symlink.
The previous patch only fixed the case where the directory was replaced
with a symlink before we tried to open it, but it still used the full
(potentially compromised) path as an argument to filesystem::remove.

The first part of the fix is to use openat when recursing into a
sub-directory with recursive_directory_iterator. This means that opening
"dir/subdir" uses the file descriptor for "dir", and so is sure to open
"dir/subdir" and not "symlink/subdir". (The previous patch to use
O_NOFOLLOW already ensured we won't open "dir/symlink/" here.)

The second part of the fix is to use unlinkat for the remove_all
operation. Previously we used a directory_iterator to get the name of
each file in a directory and then used filesystem::remove(iter->path())
on that name. This meant that any checks (e.g. O_NOFOLLOW) done by the
iterator could be invalidated before the remove operation on that
pathname. The directory iterator contains an open DIR stream, which we
can use to obtain a file descriptor to pass to unlinkat. This ensures
that the file being deleted really is contained within the directory
we're iterating over, rather than using a pathname that could resolve to
some other file.

The filesystem::remove_all function previously used a (non-recursive)
filesystem::directory_iterator for each directory, and called itself
recursively for sub-directories. The new implementation uses a single
filesystem::recursive_directory_iterator object, and calls a new __erase
member function on that iterator. That new __erase member function does
the actual work of removing a file (or a directory after its contents
have been iterated over and removed) using unlinkat. That means we don't
need to expose the DIR stream or its file descriptor to the remove_all
function, it's still encapuslated by the iterator class.

It would be possible to add a __rewind member to directory iterators
too, to call rewinddir after each modification to the directory. That
would make it more likely for filesystem::remove_all to successfully
remove everything even if files are being written to the directory tree
while removing it. It's unclear if that is actually prefereable, or if
it's better to fail and report an error at the first opportunity.

The necessary APIs (openat, unlinkat, fdopendir, dirfd) are defined in
POSIX.1-2008, and in Glibc since 2.10. But if the target doesn't provide
them, the original code (with race conditions) is still used.

This also reduces the number of small memory allocations needed for
std::filesystem::remove_all, because we do not store the full path to
every directory entry that is iterated over. The new filename_only
option means we only store the filename in the directory entry, as that
is all we need in order to use openat or unlinkat.

Finally, rather than duplicating everything for the Filesystem TS, the
std::experimental::filesystem::remove_all implementation now just calls
std::filesystem::remove_all to do the work.

libstdc++-v3/ChangeLog:

PR libstdc++/104161
* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for dirfd
and unlinkat.
* config.h.in: Regenerate.
* configure: Regenerate.
* include/bits/fs_dir.h (recursive_directory_iterator): Declare
remove_all overloads as friends.
(recursive_directory_iterator::__erase): Declare new member
function.
* include/bits/fs_fwd.h (remove, remove_all): Declare.
* src/c++17/fs_dir.cc (_Dir): Add filename_only parameter to
constructor. Pass file descriptor argument to base constructor.
(_Dir::dir_and_pathname, _Dir::open_subdir, _Dir::do_unlink)
(_Dir::unlink, _Dir::rmdir): Define new member functions.
(directory_iterator): Pass filename_only argument to _Dir
constructor.
(recursive_directory_iterator::_Dir_stack): Adjust constructor
parameters to take a _Dir rvalue instead of creating one.
(_Dir_stack::orig): Add data member for storing original path.
(_Dir_stack::report_error): Define new member function.
(__directory_iterator_nofollow): Move here from dir-common.h and
fix value to be a power of two.
(__directory_iterator_filename_only): Define new constant.
(recursive_directory_iterator): Construct _Dir object and move
into _M_dirs stack. Pass skip_permission_denied argument to first
advance call.
(recursive_directory_iterator::increment): Use _Dir::open_subdir.
(recursive_directory_iterator::__erase): Define new member
function.
* src/c++17/fs_ops.cc (ErrorReporter, do_remove_all): Remove.
(fs::remove_all): Use new recursive_directory_iterator::__erase
member function.
* src/filesystem/dir-common.h (_Dir_base): Add int parameter to
constructor and use openat to implement nofollow semantics.
(_Dir_base::fdcwd, _Dir_base::set_close_on_exec, _Dir_base::openat):
Define new member functions.
(__directory_iterator_nofollow): Move to fs_dir.cc.
* src/filesystem/dir.cc (_Dir): Pass file descriptor argument to
base constructor.
(_Dir::dir_and_pathname, _Dir::open_subdir): Define new member
functions.
(recursive_directory_iterator::_Dir_stack): Adjust constructor
parameters to take a _Dir rvalue instead of creating one.
(recursive_directory_iterator): Check for new nofollow option.
Construct _Dir object and move into _M_dirs stack. Pass
skip_permission_denied argument to first advance call.
(recursive_directory_iterator::increment): Use _Dir::open_subdir.
* src/filesystem/ops.cc (fs::remove_all): Use C++17 remove_all.

(cherry picked from commit ebf6175464768983a2d8c82c2d47771ee89192b8)

22 months agolibstdc++: Avoid symlink race in filesystem::remove_all [PR104161]
Jonathan Wakely [Sun, 23 Jan 2022 21:45:16 +0000 (21:45 +0000)] 
libstdc++: Avoid symlink race in filesystem::remove_all [PR104161]

This adds a new internal flag to the filesystem::directory_iterator
constructor that makes it fail if the path is a symlink that resolves to
a directory. This prevents filesystem::remove_all from following a
symlink to a directory, rather than deleting the symlink itself.

We can also use that new flag in recursive_directory_iterator to ensure
that we don't follow symlinks if the follow_directory_symlink option is
not set.

This also moves an error check in filesystem::remove_all after the while
loop, so that errors from the directory_iterator constructor are
reproted, instead of continuing to the filesystem::remove call below.

libstdc++-v3/ChangeLog:

PR libstdc++/104161
* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for
fdopendir.
* config.h.in: Regenerate.
* configure: Regenerate.
* src/c++17/fs_dir.cc (_Dir): Add nofollow flag to constructor
and pass it to base class constructor.
(directory_iterator): Pass nofollow flag to _Dir constructor.
(fs::recursive_directory_iterator::increment): Likewise.
* src/c++17/fs_ops.cc (do_remove_all): Use nofollow option for
directory_iterator constructor. Move error check outside loop.
* src/filesystem/dir-common.h (_Dir_base): Add nofollow flag to
constructor and when it's set use ::open with O_NOFOLLOW and
O_DIRECTORY.
* src/filesystem/dir.cc (_Dir): Add nofollow flag to constructor
and pass it to base class constructor.
(directory_iterator): Pass nofollow flag to _Dir constructor.
(fs::recursive_directory_iterator::increment): Likewise.
* src/filesystem/ops.cc (remove_all): Use nofollow option for
directory_iterator constructor. Move error check outside loop.

(cherry picked from commit c8bd4dc8212e43b2f9af08b80df97f90cdb0df4f)

22 months agolibstdc++: Fix typos in std::filesystem code
Jonathan Wakely [Sat, 2 Oct 2021 20:18:19 +0000 (21:18 +0100)] 
libstdc++: Fix typos in std::filesystem code

There were a couple of typos in r12-4070 and r12-4071 which don't show
up when building for POSIX targets.

libstdc++-v3/ChangeLog:

* src/c++17/fs_ops.cc (create_directory): Fix typo in enum name.
* src/filesystem/ops-common.h (__last_system_error): Add
explicit cast to avoid narrowing conversion.
(do_space): Fix type in function name.

(cherry picked from commit b7848a2068b2579092e0b1bbe02bdb743eb7db26)

22 months agolibstdc++: Avoid unconditional use of errc::not_supported [PR 99327]
Jonathan Wakely [Tue, 11 May 2021 17:47:18 +0000 (18:47 +0100)] 
libstdc++: Avoid unconditional use of errc::not_supported [PR 99327]

The errc::not_supported constant is only defined if ENOTSUP is defined,
which is not true for all targets. Many uses of errc::not_supported in
the filesystem library do not actually match the intended meaning of
ENOTSUP described by POSIX. They should be using ENOSYS instead
(i.e. errc::function_not_supported).

This change ensures that appropriate error codes are used by the
filesystem library. The remaining uses of errc::not_supported are
replaced with a call to a new helper function so that an alternative
value will be used on targets that don't support errc::not_supported.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/99327
* src/filesystem/ops-common.h (__unsupported): New function to
return a suitable error code for missing functionality.
(posix::off_t): New typedef.
(posix::*): Set errno to ENOSYS instead of ENOTSUP for no-op
fallback implementations.
(do_copy_file): Replace uses of errc::not_supported.
* src/c++17/fs_ops.cc (fs::copy, fs::copy_file, create_dir)
(fs::create_directory, fs::create_directory_symlink)
(fs::create_hard_link, fs::create_symlink, fs::current_path)
(fs::equivalent, do_stat, fs::file_size, fs::hard_link_count)
(fs::last_write_time, fs::permissions, fs::read_symlink):
Replace uses of errc::not_supported.
(fs::resize_file): Qualify off_t.
* src/filesystem/ops.cc (fs::copy, fs::copy_file, create_dir)
(fs::create_directory, fs::create_directory_symlink)
(fs::create_hard_link, fs::create_symlink, fs::current_path)
(fs::equivalent, do_stat, fs::file_size, fs::last_write_time)
(fs::permissions, fs::read_symlink, fs::system_complete):
Replace uses of errc::not_supported.
(fs::resize_file): Qualify off_t and enable unconditionally.
* testsuite/19_diagnostics/system_error/cons-1.cc: Likewise.

(cherry picked from commit 59ffa3e3dba5a7805585c61dd4387c5644249d52)

22 months agolibstdc++: Add utility for creating std::error_code from OS errors
Jonathan Wakely [Wed, 10 Feb 2021 18:00:00 +0000 (18:00 +0000)] 
libstdc++: Add utility for creating std::error_code from OS errors

This adds a helper function to encapsulate obtaining an error code for
errors from OS calls. For Windows we want to use GetLastError() and the
system error category, but otherwise just use errno and the generic
error category.

This should not be used to replace existing uses of
ec.assign(errno, generic_category()) because in those cases we really do
want to get the value of errno, not a system-specific error. Only the
cases that currently use GetLastError() are replace by this new
function.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* src/filesystem/ops-common.h (last_error): New helper function.
(filesystem::do_space): Use last_error().
* src/c++17/fs_ops.cc (fs::absolute, fs::create_hard_link)
(fs::equivalent, fs::remove, fs::temp_directory_path): Use
last_error().
* src/filesystem/ops.cc (fs::create_hard_link)
(fs::remove, fs::temp_directory_path): Likewise.

(cherry picked from commit d71476c9df931f3ca674941f1942b03eabea010d)

22 months agoRevert "libstdc++: Horrible macro hacks to allow building on avr"
Jonathan Wakely [Tue, 3 Oct 2023 15:08:41 +0000 (16:08 +0100)] 
Revert "libstdc++: Horrible macro hacks to allow building on avr"

This reverts commit 061700c9f6f0f9f4219ddeb236d55764b42869b6.

This hack will be unnecessary, as I'm backporting the __unsupported()
utility from the later branches.

libstdc++-v3/ChangeLog:

* src/c++17/fs_ops.cc (not_supported):
* src/filesystem/ops-common.h (ENOTSUP):

22 months agoDaily bump.
GCC Administrator [Wed, 4 Oct 2023 00:19:22 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Tue, 3 Oct 2023 00:18:42 +0000 (00:18 +0000)] 
Daily bump.

22 months agoDisable generation of scalar modulo instructions.
Pat Haugen [Tue, 19 Sep 2023 18:19:59 +0000 (13:19 -0500)] 
Disable generation of scalar modulo instructions.

It was recently discovered that the scalar modulo instructions can suffer
noticeable performance issues for certain input values. This patch disables
their generation since the equivalent div/mul/sub sequence does not suffer
the same problem.

gcc/
* config/rs6000/rs6000.c (rs6000_rtx_costs): Check whether the
modulo instruction is disabled.
* config/rs6000/rs6000.h (RS6000_DISABLE_SCALAR_MODULO): New.
* config/rs6000/rs6000.md (mod<mode>3, *mod<mode>3): Check it.
(define_expand umod<mode>3): New.
(define_insn umod<mode>3): Rename to *umod<mode>3 and check if the modulo
instruction is disabled.
(umodti3, modti3): Check if the modulo instruction is disabled.

gcc/testsuite/
* gcc.target/powerpc/clone1.c: Add xfails.
* gcc.target/powerpc/clone3.c: Likewise.
* gcc.target/powerpc/mod-1.c: Update scan strings and add xfails.
* gcc.target/powerpc/mod-2.c: Likewise.
* gcc.target/powerpc/p10-vdivq-vmodq.c: Add xfails.

(cherry picked from commit 58ab38213b979811d314f68e3f455c28a1d44140)

22 months agolibstdc++: Force _Hash_node_value_base methods inline to fix abi (PR111050)
Tim Song [Wed, 6 Sep 2023 17:31:55 +0000 (19:31 +0200)] 
libstdc++: Force _Hash_node_value_base methods inline to fix abi (PR111050)

https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=1b6f0476837205932613ddb2b3429a55c26c409d
changed _Hash_node_value_base to no longer derive from _Hash_node_base, which means
that its member functions expect _M_storage to be at a different offset. So explosions
result if an out-of-line definition is emitted for any of the member functions (say,
in a non-optimized build) and the resulting object file is then linked with code built
using older version of GCC/libstdc++.

libstdc++-v3/ChangeLog:

PR libstdc++/111050
* include/bits/hashtable_policy.h
(_Hash_node_value_base<>::_M_valptr(), _Hash_node_value_base<>::_M_v())
Add [[__gnu__::__always_inline__]].

(cherry picked from commit 2c1e3544a94c5d7354fad031e1f9731c3ce3af25)

22 months agoDaily bump.
GCC Administrator [Mon, 2 Oct 2023 00:18:58 +0000 (00:18 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sun, 1 Oct 2023 00:20:04 +0000 (00:20 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sat, 30 Sep 2023 00:19:15 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Fri, 29 Sep 2023 00:19:11 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Thu, 28 Sep 2023 09:51:40 +0000 (09:51 +0000)] 
Daily bump.

22 months agolibstdc++: Fix constexpr functions to conform to older standards
Jonathan Wakely [Wed, 9 Aug 2023 10:11:31 +0000 (11:11 +0100)] 
libstdc++: Fix constexpr functions to conform to older standards

Some constexpr functions were inadvertently relying on relaxed constexpr
rules from later standards.

libstdc++-v3/ChangeLog:

* include/experimental/bits/fs_path.h (path::string): Use
_GLIBCXX17_CONSTEXPR not _GLIBCXX_CONSTEXPR for 'if constexpr'.
* include/std/charconv (__to_chars_8): Initialize variable for
C++17 constexpr rules.

(cherry picked from commit b3a2b307b9deea719fb725a86df43b82176fe459)

22 months agolibstdc++: Prevent unwanted ADL in std::to_array [PR111512]
Jonathan Wakely [Thu, 21 Sep 2023 08:14:57 +0000 (09:14 +0100)] 
libstdc++: Prevent unwanted ADL in std::to_array [PR111512]

Qualify the calls to the __to_array helper to prevent ADL, so we don't
try to complete associated classes.

libstdc++-v3/ChangeLog:

PR libstdc++/111511
PR c++/111512
* include/std/array (to_array): Qualify calls to __to_array.
* testsuite/23_containers/array/creation/111512.cc: New test.

(cherry picked from commit 77cf3773021b0a20d89623e09d620747a05588ec)

22 months agoDaily bump.
GCC Administrator [Tue, 26 Sep 2023 00:19:46 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Mon, 25 Sep 2023 00:18:59 +0000 (00:18 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sun, 24 Sep 2023 00:18:57 +0000 (00:18 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sat, 23 Sep 2023 00:20:11 +0000 (00:20 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Fri, 22 Sep 2023 00:19:03 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Thu, 21 Sep 2023 00:19:45 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Wed, 20 Sep 2023 00:19:33 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Tue, 19 Sep 2023 00:19:06 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Mon, 18 Sep 2023 00:18:50 +0000 (00:18 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sun, 17 Sep 2023 00:20:08 +0000 (00:20 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sat, 16 Sep 2023 00:19:39 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Fri, 15 Sep 2023 00:19:43 +0000 (00:19 +0000)] 
Daily bump.

22 months agolibstdc++: Add workaround for std::make_integer_sequence bug [PR111357]
Jonathan Wakely [Thu, 14 Sep 2023 08:18:34 +0000 (09:18 +0100)] 
libstdc++: Add workaround for std::make_integer_sequence bug [PR111357]

The compiler bug has been fixed on trunk, but we need this workaround on
the branches.

libstdc++-v3/ChangeLog:

PR c++/111357
* include/std/utility (make_integer_sequence): Add cast.
* testsuite/20_util/integer_sequence/pr111357.cc: New test.

(cherry picked from commit 7b0abd4a8ee9d2057febe443de67009dcdfe7574)

22 months agoDaily bump.
GCC Administrator [Thu, 14 Sep 2023 00:19:28 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Wed, 13 Sep 2023 00:19:31 +0000 (00:19 +0000)] 
Daily bump.

22 months agoi386: Handle CONST_WIDE_INT in output_pic_addr_const [PR111340]
Uros Bizjak [Mon, 11 Sep 2023 18:56:42 +0000 (20:56 +0200)] 
i386: Handle CONST_WIDE_INT in output_pic_addr_const [PR111340]

PR target/111340

gcc/ChangeLog:

* config/i386/i386.c (output_pic_addr_const): Handle CONST_WIDE_INT.
Call output_addr_const for CASE_CONST_SCALAR_INT.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 048927ed8561ca994ad853fe85ccf8c2ca07a8fe)

22 months agoaarch64: Make stack smash canary protect saved registers
Richard Sandiford [Tue, 12 Sep 2023 15:19:52 +0000 (16:19 +0100)] 
aarch64: Make stack smash canary protect saved registers

AArch64 normally puts the saved registers near the bottom of the frame,
immediately above any dynamic allocations.  But this means that a
stack-smash attack on those dynamic allocations could overwrite the
saved registers without needing to reach as far as the stack smash
canary.

The same thing could also happen for variable-sized arguments that are
passed by value, since those are allocated before a call and popped on
return.

This patch avoids that by putting the locals (and thus the canary) below
the saved registers when stack smash protection is active.

The patch fixes CVE-2023-4039.

gcc/
* config/aarch64/aarch64.c (aarch64_save_regs_above_locals_p):
New function.
(aarch64_layout_frame): Use it to decide whether locals should
go above or below the saved registers.
(aarch64_expand_prologue): Update stack layout comment.
Emit a stack tie after the final adjustment.

gcc/testsuite/
* gcc.target/aarch64/stack-protector-8.c: New test.
* gcc.target/aarch64/stack-protector-9.c: Likewise.

22 months agoaarch64: Remove below_hard_fp_saved_regs_size
Richard Sandiford [Tue, 12 Sep 2023 15:19:52 +0000 (16:19 +0100)] 
aarch64: Remove below_hard_fp_saved_regs_size

After previous patches, it's no longer necessary to store
saved_regs_size and below_hard_fp_saved_regs_size in the frame info.
All measurements instead use the top or bottom of the frame as
reference points.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::saved_regs_size)
(aarch64_frame::below_hard_fp_saved_regs_size): Delete.
* config/aarch64/aarch64.c (aarch64_layout_frame): Update accordingly.

22 months agoaarch64: Explicitly record probe registers in frame info
Richard Sandiford [Tue, 12 Sep 2023 15:19:52 +0000 (16:19 +0100)] 
aarch64: Explicitly record probe registers in frame info

The stack frame is currently divided into three areas:

A: the area above the hard frame pointer
B: the SVE saves below the hard frame pointer
C: the outgoing arguments

If the stack frame is allocated in one chunk, the allocation needs a
probe if the frame size is >= guard_size - 1KiB.  In addition, if the
function is not a leaf function, it must probe an address no more than
1KiB above the outgoing SP.  We ensured the second condition by

(1) using single-chunk allocations for non-leaf functions only if
    the link register save slot is within 512 bytes of the bottom
    of the frame; and

(2) using the link register save as a probe (meaning, for instance,
    that it can't be individually shrink wrapped)

If instead the stack is allocated in multiple chunks, then:

* an allocation involving only the outgoing arguments (C above) requires
  a probe if the allocation size is > 1KiB

* any other allocation requires a probe if the allocation size
  is >= guard_size - 1KiB

* second and subsequent allocations require the previous allocation
  to probe at the bottom of the allocated area, regardless of the size
  of that previous allocation

The final point means that, unlike for single allocations,
it can be necessary to have both a non-SVE register probe and
an SVE register probe.  For example:

* allocate A, probe using a non-SVE register save
* allocate B, probe using an SVE register save
* allocate C

The non-SVE register used in this case was again the link register.
It was previously used even if the link register save slot was some
bytes above the bottom of the non-SVE register saves, but an earlier
patch avoided that by putting the link register save slot first.

As a belt-and-braces fix, this patch explicitly records which
probe registers we're using and allows the non-SVE probe to be
whichever register comes first (as for SVE).

The patch also avoids unnecessary probes in sve/pcs/stack_clash_3.c.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::sve_save_and_probe)
(aarch64_frame::hard_fp_save_and_probe): New fields.
* config/aarch64/aarch64.c (aarch64_layout_frame): Initialize them.
Rather than asserting that a leaf function saves LR, instead assert
that a leaf function saves something.
(aarch64_get_separate_components): Prevent the chosen probe
registers from being individually shrink-wrapped.
(aarch64_allocate_and_probe_stack_space): Remove workaround for
probe registers that aren't at the bottom of the previous allocation.

gcc/testsuite/
* gcc.target/aarch64/sve/pcs/stack_clash_3.c: Avoid redundant probes.

22 months agoaarch64: Simplify probe of final frame allocation
Richard Sandiford [Tue, 12 Sep 2023 15:19:51 +0000 (16:19 +0100)] 
aarch64: Simplify probe of final frame allocation

Previous patches ensured that the final frame allocation only needs
a probe when the size is strictly greater than 1KiB.  It's therefore
safe to use the normal 1024 probe offset in all cases.

The main motivation for doing this is to simplify the code and
remove the number of special cases.

gcc/
* config/aarch64/aarch64.c (aarch64_allocate_and_probe_stack_space):
Always probe the residual allocation at offset 1024, asserting
that that is in range.

gcc/testsuite/
* gcc.target/aarch64/stack-check-prologue-17.c: Expect the probe
to be at offset 1024 rather than offset 0.
* gcc.target/aarch64/stack-check-prologue-18.c: Likewise.

22 months agoaarch64: Put LR save probe in first 16 bytes
Richard Sandiford [Tue, 12 Sep 2023 15:19:49 +0000 (16:19 +0100)] 
aarch64: Put LR save probe in first 16 bytes

-fstack-clash-protection uses the save of LR as a probe for the next
allocation.  The next allocation could be:

* another part of the static frame, e.g. when allocating SVE save slots
  or outgoing arguments

* an alloca in the same function

* an allocation made by a callee function

However, when -fomit-frame-pointer is used, the LR save slot is placed
above the other GPR save slots.  It could therefore be up to 80 bytes
above the base of the GPR save area (which is also the hard fp address).

aarch64_allocate_and_probe_stack_space took this into account when
deciding how much subsequent space could be allocated without needing
a probe.  However, it interacted badly with:

      /* If doing a small final adjustment, we always probe at offset 0.
 This is done to avoid issues when LR is not at position 0 or when
 the final adjustment is smaller than the probing offset.  */
      else if (final_adjustment_p && rounded_size == 0)
residual_probe_offset = 0;

which forces any allocation that is smaller than the guard page size
to be probed at offset 0 rather than the usual offset 1024.  It was
therefore possible to construct cases in which we had:

* a probe using LR at SP + 80 bytes (or some other value >= 16)
* an allocation of the guard page size - 16 bytes
* a probe at SP + 0

which allocates guard page size + 64 consecutive unprobed bytes.

This patch requires the LR probe to be in the first 16 bytes of the
save area when stack clash protection is active.  Doing it
unconditionally would cause code-quality regressions, but a later
patch deals with that.

The new comment doesn't say that the probe register is required
to be LR, since a later patch removes that restriction.

gcc/
* config/aarch64/aarch64.c (aarch64_layout_frame): Ensure that
the LR save slot is in the first 16 bytes of the register save area.
(aarch64_allocate_and_probe_stack_space): Remove workaround for
when LR was not in the first 16 bytes.

gcc/testsuite/
* gcc.target/aarch64/stack-check-prologue-18.c: New test.

22 months agoaarch64: Tweak stack clash boundary condition
Richard Sandiford [Tue, 12 Sep 2023 15:19:49 +0000 (16:19 +0100)] 
aarch64: Tweak stack clash boundary condition

The AArch64 ABI says that, when stack clash protection is used,
there can be a maximum of 1KiB of unprobed space at sp on entry
to a function.  Therefore, we need to probe when allocating
>= guard_size - 1KiB of data (>= rather than >).  This is what
GCC does.

If an allocation is exactly guard_size bytes, it is enough to allocate
those bytes and probe once at offset 1024.  It isn't possible to use a
single probe at any other offset: higher would conmplicate later code,
by leaving more unprobed space than usual, while lower would risk
leaving an entire page unprobed.  For simplicity, the code probes all
allocations at offset 1024.

Some register saves also act as probes.  If we need to allocate
more space below the last such register save probe, we need to
probe the allocation if it is > 1KiB.  Again, this allocation is
then sometimes (but not always) probed at offset 1024.  This sort of
allocation is currently only used for outgoing arguments, which are
rarely this big.

However, the code also probed if this final outgoing-arguments
allocation was == 1KiB, rather than just > 1KiB.  This isn't
necessary, since the register save then probes at offset 1024
as required.  Continuing to probe allocations of exactly 1KiB
would complicate later patches.

gcc/
* config/aarch64/aarch64.c (aarch64_allocate_and_probe_stack_space):
Don't probe final allocations that are exactly 1KiB in size (after
unprobed space above the final allocation has been deducted).

gcc/testsuite/
* gcc.target/aarch64/stack-check-prologue-17.c: New test.

22 months agoaarch64: Minor initial adjustment tweak
Richard Sandiford [Tue, 12 Sep 2023 15:19:49 +0000 (16:19 +0100)] 
aarch64: Minor initial adjustment tweak

This patch just changes a calculation of initial_adjust
to one that makes it slightly more obvious that the total
adjustment is frame.frame_size.

gcc/
* config/aarch64/aarch64.c (aarch64_layout_frame): Tweak
calculation of initial_adjust for frames in which all saves
are SVE saves.

22 months agoaarch64: Simplify top of frame allocation
Richard Sandiford [Tue, 12 Sep 2023 15:19:48 +0000 (16:19 +0100)] 
aarch64: Simplify top of frame allocation

After previous patches, it no longer really makes sense to allocate
the top of the frame in terms of varargs_and_saved_regs_size and
saved_regs_and_above.

gcc/
* config/aarch64/aarch64.c (aarch64_layout_frame): Simplify
the allocation of the top of the frame.

22 months agoaarch64: Measure reg_offset from the bottom of the frame
Richard Sandiford [Tue, 12 Sep 2023 15:19:48 +0000 (16:19 +0100)] 
aarch64: Measure reg_offset from the bottom of the frame

reg_offset was measured from the bottom of the saved register area.
This made perfect sense with the original layout, since the bottom
of the saved register area was also the hard frame pointer address.
It became slightly less obvious with SVE, since we save SVE
registers below the hard frame pointer, but it still made sense.

However, if we want to allow different frame layouts, it's more
convenient and obvious to measure reg_offset from the bottom of
the frame.  After previous patches, it's also a slight simplification
in its own right.

gcc/
* config/aarch64/aarch64.h (aarch64_frame): Add comment above
reg_offset.
* config/aarch64/aarch64.c (aarch64_layout_frame): Walk offsets
from the bottom of the frame, rather than the bottom of the saved
register area.  Measure reg_offset from the bottom of the frame
rather than the bottom of the saved register area.
(aarch64_save_callee_saves): Update accordingly.
(aarch64_restore_callee_saves): Likewise.
(aarch64_get_separate_components): Likewise.
(aarch64_process_components): Likewise.

22 months agoaarch64: Tweak frame_size comment
Richard Sandiford [Tue, 12 Sep 2023 15:19:47 +0000 (16:19 +0100)] 
aarch64: Tweak frame_size comment

This patch fixes another case in which a value was described with
an “upside-down” view.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::frame_size): Tweak comment.

22 months agoaarch64: Rename hard_fp_offset to bytes_above_hard_fp
Richard Sandiford [Tue, 12 Sep 2023 15:19:47 +0000 (16:19 +0100)] 
aarch64: Rename hard_fp_offset to bytes_above_hard_fp

Similarly to the previous locals_offset patch, hard_fp_offset
was described as:

  /* Offset from the base of the frame (incomming SP) to the
     hard_frame_pointer.  This value is always a multiple of
     STACK_BOUNDARY.  */
  poly_int64 hard_fp_offset;

which again took an “upside-down” view: higher offsets meant lower
addresses.  This patch renames the field to bytes_above_hard_fp instead.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::hard_fp_offset): Rename
to...
(aarch64_frame::bytes_above_hard_fp): ...this.
* config/aarch64/aarch64.c (aarch64_layout_frame)
(aarch64_expand_prologue): Update accordingly.
(aarch64_initial_elimination_offset): Likewise.

22 months agoaarch64: Rename locals_offset to bytes_above_locals
Richard Sandiford [Tue, 12 Sep 2023 15:19:46 +0000 (16:19 +0100)] 
aarch64: Rename locals_offset to bytes_above_locals

locals_offset was described as:

  /* Offset from the base of the frame (incomming SP) to the
     top of the locals area.  This value is always a multiple of
     STACK_BOUNDARY.  */

This is implicitly an “upside down” view of the frame: the incoming
SP is at offset 0, and anything N bytes below the incoming SP is at
offset N (rather than -N).

However, reg_offset instead uses a “right way up” view; that is,
it views offsets in address terms.  Something above X is at a
positive offset from X and something below X is at a negative
offset from X.

Also, even on FRAME_GROWS_DOWNWARD targets like AArch64,
target-independent code views offsets in address terms too:
locals are allocated at negative offsets to virtual_stack_vars.

It seems confusing to have *_offset fields of the same structure
using different polarities like this.  This patch tries to avoid
that by renaming locals_offset to bytes_above_locals.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::locals_offset): Rename to...
(aarch64_frame::bytes_above_locals): ...this.
* config/aarch64/aarch64.c (aarch64_layout_frame)
(aarch64_initial_elimination_offset): Update accordingly.

22 months agoaarch64: Only calculate chain_offset if there is a chain
Richard Sandiford [Tue, 12 Sep 2023 15:19:46 +0000 (16:19 +0100)] 
aarch64: Only calculate chain_offset if there is a chain

After previous patches, it is no longer necessary to calculate
a chain_offset in cases where there is no chain record.

gcc/
* config/aarch64/aarch64.c (aarch64_expand_prologue): Move the
calculation of chain_offset into the emit_frame_chain block.

22 months agoaarch64: Tweak aarch64_save/restore_callee_saves
Richard Sandiford [Tue, 12 Sep 2023 15:19:46 +0000 (16:19 +0100)] 
aarch64: Tweak aarch64_save/restore_callee_saves

aarch64_save_callee_saves and aarch64_restore_callee_saves took
a parameter called start_offset that gives the offset of the
bottom of the saved register area from the current stack pointer.
However, it's more convenient for later patches if we use the
bottom of the entire frame as the reference point, rather than
the bottom of the saved registers.

Doing that removes the need for the callee_offset field.
Other than that, this is not a win on its own.  It only really
makes sense in combination with the follow-on patches.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::callee_offset): Delete.
* config/aarch64/aarch64.c (aarch64_layout_frame): Remove
callee_offset handling.
(aarch64_save_callee_saves): Replace the start_offset parameter
with a bytes_below_sp parameter.
(aarch64_restore_callee_saves): Likewise.
(aarch64_expand_prologue): Update accordingly.
(aarch64_expand_epilogue): Likewise.

22 months agoaarch64: Add bytes_below_hard_fp to frame info
Richard Sandiford [Tue, 12 Sep 2023 15:19:45 +0000 (16:19 +0100)] 
aarch64: Add bytes_below_hard_fp to frame info

Following on from the previous bytes_below_saved_regs patch, this one
records the number of bytes that are below the hard frame pointer.
This eventually replaces below_hard_fp_saved_regs_size.

If a frame pointer is not needed, the epilogue adds final_adjust
to the stack pointer before restoring registers:

     aarch64_add_sp (tmp1_rtx, tmp0_rtx, final_adjust, true);

Therefore, if the epilogue needs to restore the stack pointer from
the hard frame pointer, the directly corresponding offset is:

     -bytes_below_hard_fp + final_adjust

i.e. go from the hard frame pointer to the bottom of the frame,
then add the same amount as if we were using the stack pointer
from the outset.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::bytes_below_hard_fp): New
field.
* config/aarch64/aarch64.c (aarch64_layout_frame): Initialize it.
(aarch64_expand_epilogue): Use it instead of
below_hard_fp_saved_regs_size.

22 months agoaarch64: Add bytes_below_saved_regs to frame info
Richard Sandiford [Tue, 12 Sep 2023 15:19:45 +0000 (16:19 +0100)] 
aarch64: Add bytes_below_saved_regs to frame info

The frame layout code currently hard-codes the assumption that
the number of bytes below the saved registers is equal to the
size of the outgoing arguments.  This patch abstracts that
value into a new field of aarch64_frame.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::bytes_below_saved_regs): New
field.
* config/aarch64/aarch64.c (aarch64_layout_frame): Initialize it,
and use it instead of crtl->outgoing_args_size.
(aarch64_get_separate_components): Use bytes_below_saved_regs instead
of outgoing_args_size.
(aarch64_process_components): Likewise.

22 months agoaarch64: Explicitly handle frames with no saved registers
Richard Sandiford [Tue, 12 Sep 2023 15:19:44 +0000 (16:19 +0100)] 
aarch64: Explicitly handle frames with no saved registers

If a frame has no saved registers, it can be allocated in one go.
There is no need to treat the areas below and above the saved
registers as separate.

And if we allocate the frame in one go, it should be allocated
as the initial_adjust rather than the final_adjust.  This allows the
frame size to grow to guard_size - guard_used_by_caller before a stack
probe is needed.  (A frame with no register saves is necessarily a
leaf frame.)

This is a no-op as thing stand, since a leaf function will have
no outgoing arguments, and so all the frame will be above where
the saved registers normally go.

gcc/
* config/aarch64/aarch64.c (aarch64_layout_frame): Explicitly
allocate the frame in one go if there are no saved registers.

22 months agoaarch64: Avoid a use of callee_offset
Richard Sandiford [Tue, 12 Sep 2023 15:19:44 +0000 (16:19 +0100)] 
aarch64: Avoid a use of callee_offset

When we emit the frame chain, i.e. when we reach Here in this statement
of aarch64_expand_prologue:

  if (emit_frame_chain)
    {
      // Here
      ...
    }

the stack is in one of two states:

- We've allocated up to the frame chain, but no more.

- We've allocated the whole frame, and the frame chain is within easy
  reach of the new SP.

The offset of the frame chain from the current SP is available
in aarch64_frame as callee_offset.  It is also available as the
chain_offset local variable, where the latter is calculated from other
data.  (However, chain_offset is not always equal to callee_offset when
!emit_frame_chain, so chain_offset isn't redundant.)

In c600df9a4060da3c6121ff4d0b93f179eafd69d1 I switched to using
chain_offset for the initialisation of the hard frame pointer:

       aarch64_add_offset (Pmode, hard_frame_pointer_rtx,
-                         stack_pointer_rtx, callee_offset,
+                         stack_pointer_rtx, chain_offset,
                          tmp1_rtx, tmp0_rtx, frame_pointer_needed);

But the later REG_CFA_ADJUST_CFA handling still used callee_offset.

I think the difference is harmless, but it's more logical for the
CFA note to be in sync, and it's more convenient for later patches
if it uses chain_offset.

gcc/
* config/aarch64/aarch64.c (aarch64_expand_prologue): Use
chain_offset rather than callee_offset.

22 months agoaarch64: Use local frame vars in shrink-wrapping code
Richard Sandiford [Tue, 12 Sep 2023 15:19:43 +0000 (16:19 +0100)] 
aarch64: Use local frame vars in shrink-wrapping code

aarch64_layout_frame uses a shorthand for referring to
cfun->machine->frame:

  aarch64_frame &frame = cfun->machine->frame;

This patch does the same for some other heavy users of the structure.
No functional change intended.

gcc/
* config/aarch64/aarch64.c (aarch64_save_callee_saves): Use
a local shorthand for cfun->machine->frame.
(aarch64_restore_callee_saves, aarch64_get_separate_components):
(aarch64_process_components): Likewise.
(aarch64_allocate_and_probe_stack_space): Likewise.
(aarch64_expand_prologue, aarch64_expand_epilogue): Likewise.
(aarch64_layout_frame): Use existing shorthand for one more case.

22 months agors6000: call vector load/store with length only on 64-bit Power10
Haochen Gui [Tue, 12 Sep 2023 01:58:08 +0000 (09:58 +0800)] 
rs6000: call vector load/store with length only on 64-bit Power10

gcc/
PR target/96762
* config/rs6000/rs6000-string.c (expand_block_move): Call vector
load/store with length only on 64-bit Power10.

gcc/testsuite/
PR target/96762
* gcc.target/powerpc/pr96762.c: New.

(cherry picked from commit 946b8967b905257ac9f140225db744c9a6ab91be)

22 months agoDaily bump.
GCC Administrator [Tue, 12 Sep 2023 00:19:02 +0000 (00:19 +0000)] 
Daily bump.

22 months agoc++: member vs global template [PR106310]
Jason Merrill [Wed, 26 Jul 2023 14:39:34 +0000 (10:39 -0400)] 
c++: member vs global template [PR106310]

For backward compatibility we still want to allow patterns like
this->A<T>::foo, but the template keyword in a qualified name is
specifically to specify that a dependent name is a template, so don't look
in the enclosing scope at all.

Also fix handling of dependent bases: if member lookup in the current
instantiation fails and we have dependent bases, the lookup is dependent.
We were already handling that for the case where lookup in the enclosing
scope also fails, but we also want it to affect that lookup itself.

PR c++/106310

gcc/cp/ChangeLog:

* parser.c (cp_parser_template_name): Skip non-member
lookup after the template keyword.
(cp_parser_lookup_name): Pass down template_keyword_p.

gcc/testsuite/ChangeLog:

* g++.dg/template/template-keyword4.C: New test.

22 months agoc++: array DMI and member fn [PR109666]
Jason Merrill [Mon, 1 May 2023 14:57:20 +0000 (10:57 -0400)] 
c++: array DMI and member fn [PR109666]

Here it turns out I also needed to adjust cfun when stepping out of the
member function to instantiate the DMI.  But instead of adding that tweak,
let's unify with instantiate_body and just push_to_top_level instead of
trying to do the minimum subset of it.  There was no measurable change in
compile time on stdc++.h.

This should also resolve 109506 without yet another tweak.

PR c++/106890
PR c++/109666

gcc/cp/ChangeLog:

* name-lookup.c (maybe_push_to_top_level)
(maybe_pop_from_top_level): Split out...
* pt.c (instantiate_body): ...from here.
* init.c (maybe_instantiate_nsdmi_init): Use them.
* name-lookup.h: Declare them..

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/nsdmi-array2.C: New test.
* g++.dg/cpp0x/nsdmi-template25.C: New test.

22 months agoDaily bump.
GCC Administrator [Mon, 11 Sep 2023 00:18:05 +0000 (00:18 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sun, 10 Sep 2023 00:18:15 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sat, 9 Sep 2023 00:18:10 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Fri, 8 Sep 2023 09:42:55 +0000 (09:42 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Thu, 7 Sep 2023 00:18:36 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Wed, 6 Sep 2023 00:18:39 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Tue, 5 Sep 2023 13:35:22 +0000 (13:35 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Mon, 4 Sep 2023 00:18:21 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sun, 3 Sep 2023 00:18:09 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sat, 2 Sep 2023 00:19:03 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Fri, 1 Sep 2023 00:18:38 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Thu, 31 Aug 2023 00:21:11 +0000 (00:21 +0000)] 
Daily bump.

23 months agotree-ssa-strlen: Fix up handling of conditionally zero memcpy [PR110914]
Jakub Jelinek [Wed, 30 Aug 2023 09:21:45 +0000 (11:21 +0200)] 
tree-ssa-strlen: Fix up handling of conditionally zero memcpy [PR110914]

The following testcase is miscompiled since r279392 aka r10-5451-gef29b12cfbb4979
The strlen pass has adjust_last_stmt function, which performs mainly strcat
or strcat-like optimizations (say strcpy (x, "abcd"); strcat (x, p);
or equivalent memcpy (x, "abcd", strlen ("abcd") + 1); char *q = strchr (x, 0);
memcpy (x, p, strlen (p)); etc. where the first stmt stores '\0' character
at the end but next immediately overwrites it and so the first memcpy can be
adjusted to store 1 fewer bytes.  handle_builtin_memcpy called this function
in two spots, the first one guarded like:
  if (olddsi != NULL
      && tree_fits_uhwi_p (len)
      && !integer_zerop (len))
    adjust_last_stmt (olddsi, stmt, false);
i.e. only for constant non-zero length.  The other spot can call it even
for non-constant length but in that case we punt before that if that length
isn't length of some string + 1, so again non-zero.
The r279392 change I assume wanted to add some warning stuff and changed it
like
   if (olddsi != NULL
-      && tree_fits_uhwi_p (len)
       && !integer_zerop (len))
-    adjust_last_stmt (olddsi, stmt, false);
+    {
+      maybe_warn_overflow (stmt, len, rvals, olddsi, false, true);
+      adjust_last_stmt (olddsi, stmt, false);
+    }
While maybe_warn_overflow possibly handles non-constant length fine,
adjust_last_stmt really relies on length to be non-zero, which
!integer_zerop (len) alone doesn't guarantee.  While we could for
len being SSA_NAME ask the ranger or tree_expr_nonzero_p, I think
adjust_last_stmt will not benefit from it much, so the following patch
just restores the above condition/previous behavior for the adjust_last_stmt
call only.

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

PR tree-optimization/110914
* tree-ssa-strlen.c (strlen_pass::handle_builtin_memcpy): Don't call
adjust_last_stmt unless len is known constant.

* gcc.c-torture/execute/pr110914.c: New test.

(cherry picked from commit 398842e7038ea0f34054f0f694014d0ecd656846)

23 months agostore-merging: Fix up >= 64 bit insertion [PR111015]
Jakub Jelinek [Wed, 30 Aug 2023 08:47:21 +0000 (10:47 +0200)] 
store-merging: Fix up >= 64 bit insertion [PR111015]

The following testcase shows that we mishandle bit insertion for
info->bitsize >= 64.  The problem is in using unsigned HOST_WIDE_INT
shift + subtraction + build_int_cst to compute mask, the shift invokes
UB at compile time for info->bitsize 64 and larger and e.g. on the testcase
with info->bitsize happens to compute mask of 0x3f rather than
0x3f'ffffffff'ffffffff.

The patch fixes that by using wide_int wi::mask + wide_int_to_tree, so it
handles masks in any precision (up to WIDE_INT_MAX_PRECISION ;) ).

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

PR tree-optimization/111015
* gimple-ssa-store-merging.c
(imm_store_chain_info::output_merged_store): Use wi::mask and
wide_int_to_tree instead of unsigned HOST_WIDE_INT shift and
build_int_cst to build BIT_AND_EXPR mask.

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

(cherry picked from commit 49a3b35c4068091900b657cd36e5cffd41ef0c47)

23 months agoDaily bump.
GCC Administrator [Wed, 30 Aug 2023 00:19:43 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Tue, 29 Aug 2023 00:19:49 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Mon, 28 Aug 2023 00:20:12 +0000 (00:20 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sun, 27 Aug 2023 00:18:38 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sat, 26 Aug 2023 00:20:10 +0000 (00:20 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Fri, 25 Aug 2023 00:20:00 +0000 (00:20 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Thu, 24 Aug 2023 00:19:28 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Wed, 23 Aug 2023 00:19:57 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Tue, 22 Aug 2023 00:20:04 +0000 (00:20 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Mon, 21 Aug 2023 00:19:10 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sun, 20 Aug 2023 00:19:02 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sat, 19 Aug 2023 00:18:10 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Fri, 18 Aug 2023 00:18:16 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Thu, 17 Aug 2023 00:18:48 +0000 (00:18 +0000)] 
Daily bump.

23 months agoSupport -m[no-]gather to enable/disable vectorization for all gather instructions
liuhongt [Wed, 16 Aug 2023 02:07:15 +0000 (10:07 +0800)] 
Support -m[no-]gather to enable/disable vectorization for all gather instructions

gcc/ChangeLog:

* config/i386/i386.opt: Add new option mgather.

23 months agoSoftware mitigation: Disable gather generation in vectorization for GDS affected...
liuhongt [Thu, 10 Aug 2023 03:41:39 +0000 (11:41 +0800)] 
Software mitigation: Disable gather generation in vectorization for GDS affected Intel Processors.

For more details of GDS (Gather Data Sampling), refer to
https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/advisory-guidance/gather-data-sampling.html

After microcode update, there's performance regression. To avoid that,
the patch disables gather generation in autovectorization but uses
gather scalar emulation instead.

gcc/ChangeLog:

* config/i386/i386-options.c (m_GDS): New macro.
* config/i386/x86-tune.def (X86_TUNE_USE_GATHER): Don't enable
for m_GDS.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx2-gather-2.c: Adjust options to keep
gather vectorization.
* gcc.target/i386/avx2-gather-6.c: Ditto.
* gcc.target/i386/avx512f-pr88464-1.c: Ditto.
* gcc.target/i386/avx512f-pr88464-5.c: Ditto.
* gcc.target/i386/avx512vl-pr88464-1.c: Ditto.
* gcc.target/i386/avx512vl-pr88464-11.c: Ditto.
* gcc.target/i386/avx512vl-pr88464-3.c: Ditto.
* gcc.target/i386/avx512vl-pr88464-9.c: Ditto.

(cherry picked from commit 3064d1f5c48cb6ce1b4133570dd08ecca8abb52d)

23 months agoDaily bump.
GCC Administrator [Wed, 16 Aug 2023 00:18:17 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Tue, 15 Aug 2023 00:19:19 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Mon, 14 Aug 2023 00:18:07 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sun, 13 Aug 2023 00:18:37 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sat, 12 Aug 2023 00:18:39 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Fri, 11 Aug 2023 00:18:21 +0000 (00:18 +0000)] 
Daily bump.

2 years agoDaily bump.
GCC Administrator [Thu, 10 Aug 2023 00:19:04 +0000 (00:19 +0000)] 
Daily bump.

2 years agoc++: noexcept-spec from nested class confusion [PR109761]
Patrick Palka [Tue, 9 May 2023 19:06:34 +0000 (15:06 -0400)] 
c++: noexcept-spec from nested class confusion [PR109761]

When late processing a noexcept-spec from a nested class after completion
of the outer class (since it's a complete-class context), we pass the wrong
class context to noexcept_override_late_checks -- the outer class type
instead of the nested class type -- which leads to bogus errors in the
below test.

This patch fixes this by making noexcept_override_late_checks obtain the
class context directly via DECL_CONTEXT instead of via an additional
parameter.

PR c++/109761

gcc/cp/ChangeLog:

* parser.c (cp_parser_class_specifier): Don't pass a class
context to noexcept_override_late_checks.
(noexcept_override_late_checks): Remove 'type' parameter
and use DECL_CONTEXT of 'fndecl' instead.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/noexcept78.C: New test.

(cherry picked from commit c13906f258fb34b3e0c90ddc8d9191dd72f3da0e)

2 years agoWorkaround possible CPUID bug in Sandy Bridge.
liuhongt [Fri, 4 Aug 2023 01:27:39 +0000 (09:27 +0800)] 
Workaround possible CPUID bug in Sandy Bridge.

Don't access leaf 7 subleaf 1 unless subleaf 0 says it is
supported via EAX.

Intel documentation says invalid subleaves return 0. We had been
relying on that behavior instead of checking the max sublef number.

It appears that some Sandy Bridge CPUs return at least the subleaf 0
EDX value for subleaf 1. Best guess is that this is a bug in a
microcode patch since all of the bits we're seeing set in EDX were
introduced after Sandy Bridge was originally released.

This is causing avxvnniint16 to be incorrectly enabled with
-march=native on these CPUs.

gcc/ChangeLog:

* common/config/i386/cpuinfo.h (get_available_features): Check
max_subleaf_level for valid subleaf before use CPUID.