Commit Graph

205417 Commits

Author SHA1 Message Date
Jakub Jelinek aaf0f12175 libsanitizer: Apply local patches
This patch just reapplies local patches (will be noted in LOCAL_PATCHES).
2023-11-15 12:46:56 +01:00
Jakub Jelinek 28219f7f99 libsanitizer: merge from upstream (c425db2eb558c263)
The following patch is result of libsanitizer/merge.sh
from c425db2eb558c263 (yesterday evening).

Bootstrapped/regtested on x86_64-linux and i686-linux (together with
the follow-up 3 patches I'm about to post).

BTW, seems upstream has added riscv64 support for I think lsan/tsan,
so if anyone is willing to try it there, it would be a matter of
copying e.g. the s390*-*-linux* libsanitizer/configure.tgt entry
to riscv64-*-linux* with the obvious s/s390x/riscv64/ change in it.
2023-11-15 12:45:58 +01:00
Xi Ruoyao 4d86dc51e3
LoongArch: Remove redundant barrier instructions before LL-SC loops
This is isomorphic to the LLVM changes [1-2].

On LoongArch, the LL and SC instructions has memory barrier semantics:

- LL: <memory-barrier> + <load-exclusive>
- SC: <store-conditional> + <memory-barrier>

But the compare and swap operation is allowed to fail, and if it fails
the SC instruction is not executed, thus the guarantee of acquiring
semantics cannot be ensured. Therefore, an acquire barrier needs to be
generated when failure_memorder includes an acquire operation.

On CPUs implementing LoongArch v1.10 or later, "dbar 0b10100" is an
acquire barrier; on CPUs implementing LoongArch v1.00, it is a full
barrier.  So it's always enough for acquire semantics.  OTOH if an
acquire semantic is not needed, we still needs the "dbar 0x700" as the
load-load barrier like all LL-SC loops.

[1]:https://github.com/llvm/llvm-project/pull/67391
[2]:https://github.com/llvm/llvm-project/pull/69339

gcc/ChangeLog:

	* config/loongarch/loongarch.cc
	(loongarch_memmodel_needs_release_fence): Remove.
	(loongarch_cas_failure_memorder_needs_acquire): New static
	function.
	(loongarch_print_operand): Redefine 'G' for the barrier on CAS
	failure.
	* config/loongarch/sync.md (atomic_cas_value_strong<mode>):
	Remove the redundant barrier before the LL instruction, and
	emit an acquire barrier on failure if needed by
	failure_memorder.
	(atomic_cas_value_cmp_and_7_<mode>): Likewise.
	(atomic_cas_value_add_7_<mode>): Remove the unnecessary barrier
	before the LL instruction.
	(atomic_cas_value_sub_7_<mode>): Likewise.
	(atomic_cas_value_and_7_<mode>): Likewise.
	(atomic_cas_value_xor_7_<mode>): Likewise.
	(atomic_cas_value_or_7_<mode>): Likewise.
	(atomic_cas_value_nand_7_<mode>): Likewise.
	(atomic_cas_value_exchange_7_<mode>): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/cas-acquire.c: New test.
2023-11-15 19:30:57 +08:00
Jonathan Wakely 452476db0c libstdc++: Fix std::deque::operator[] Xmethod [PR112491]
The Xmethod for std::deque::operator[] has the same bug that I recently
fixed for the std::deque::size() Xmethod. The first node might have
unused capacity at the start, which needs to be accounted for when
indexing into the deque.

libstdc++-v3/ChangeLog:

	PR libstdc++/112491
	* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.index):
	Correctly handle unused capacity at the start of the first node.
	* testsuite/libstdc++-xmethods/deque.cc: Check index operator
	when elements have been removed from the front.
2023-11-15 11:16:49 +00:00
Jonathan Wakely cbd0fe22a5 libstdc++: std::stacktrace tweaks
Fix a typo in a string literal and make the new hash.cc test gracefully
handle missing stacktrace data (see PR 112541).

libstdc++-v3/ChangeLog:

	* include/std/stacktrace (basic_stacktrace::at): Fix class name
	in exception message.
	* testsuite/19_diagnostics/stacktrace/hash.cc: Do not fail if
	current() returns a non-empty stacktrace.
2023-11-15 11:16:49 +00:00
Richard Earnshaw 7c16f7a154 arm: testsuite: fix test for armv6t2 hardware
My previous patch series added a new function to check for armv6t2
compatible hardware.  But the test was not correctly implemented and
also did not follow the standard naming convention for Arm hw
compatibility tests.  Fix both of these issues.

gcc/testsuite:

	* lib/target-supports.exp (check_effective_target_arm_arch_v6t2_hw_ok):
	Rename to...
	(check_effective_target_arm_arch_v6t2_hw): ... this.  Fix checks.
	* gcc.target/arm/acle/data-intrinsics-armv6.c: Update pre-check.
	* gcc.target/arm/acle/data-intrinsics-rbit.c: Likewise.
2023-11-15 10:46:31 +00:00
Juzhe-Zhong e9fc877f6d RISC-V: Support trailing vec_init optimization
Add optimization when trailing elements > leading elements.

Consider this following case:

#include <stdint.h>

typedef int64_t v16di __attribute__ ((vector_size (128)));

__attribute__ ((noipa)) void
f_v16di (int64_t a, int64_t b, int64_t c, int64_t d, int64_t *out)
{
  v16di v = {a, b, c, d, d, d, d, d, d, d, d, d, d, d, d, d};
  *(v16di *) out = v;
}

https://godbolt.org/z/vWTjbrWGf

Before this patch:

f_v16di:
        vsetivli        zero,16,e64,m8,ta,ma
        vmv.v.x v8,a0
        vslide1down.vx  v8,v8,a1
        vslide1down.vx  v8,v8,a2
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vslide1down.vx  v8,v8,a3
        vse64.v v8,0(a4)
        ret

After this patch:

f_v16di:
	vsetivli	zero,16,e64,m8,ta,ma
	vmv.v.x	v16,a3
	vslide1up.vx	v8,v16,a2
	vslide1up.vx	v16,v8,a1
	vslide1up.vx	v8,v16,a0
	vse64.v	v8,0(a4)
	ret

gcc/ChangeLog:

	* config/riscv/riscv-v.cc (expand_vector_init_trailing_same_elem): New function.
	(expand_vec_init): Add trailing optimization.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/vls/def.h: Add trailing tests.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/trailing-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/trailing-2.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/trailing_run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/trailing_run-2.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/trailing-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/trailing-2.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/trailing-3.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/trailing-4.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/trailing-5.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/trailing-6.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/trailing-7.c: New test.
2023-11-15 17:59:49 +08:00
Jakub Jelinek da36a438d8 testsuite: Adjust gcc.dg/cpp/if-2.c for 16-bit targets
Jeff reported this testcase newly FAILs on 16-bit targets, the following
patch adjusts the expected diagnostics for that case.

2023-11-15  Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/cpp/if-2.c: Adjust expected diagnostics for 16-bit targets.
2023-11-15 08:56:24 +01:00
Pan Li 319bbb3693 RISC-V: Refine the mask generation for vec_init case 2
Update in v2:
1. Add more test cases for fixed-vlmax.
2, Add test cases for vls mode.

Original log:

We take vec_init element int mode when generate the mask for
case 2. But actually we don't need as many bits as the element.
The extra bigger mode may introduce some unnecessary insns.
For example as below code:

typedef int64_t v16di __attribute__ ((vector_size (16 * 8)));

void __attribute__ ((noinline, noclone))
  foo (int64_t *out, int64_t x, int64_t y)
{
  v16di v = {y, x, y, x, y, x, y, x, y, x, y, x, y, x, y, x};
  *(v16di *) out = v;
}

We will have VDImode when generate the 0b0101010101010101 mask but
actually VHImode is good enough here. This patch would like to
refine the mask generation to avoid:
1. Unnecessary scalar to generate big constant mask.
2. Unnecessary vector insn to v0 mask.

Before this patch:
foo:
  li      a5,-1431654400
  li      a4,-1431654400               <== unnecessary insn
  addi    a5,a5,-1365                  <== unnecessary insn
  addi    a4,a4,-1366
  slli    a5,a5,32                     <== unnecessary insn
  add     a5,a5,a4                     <== unnecessary insn
  vsetivli        zero,16,e64,m8,ta,ma
  vmv.v.x v8,a2
  vmv.s.x v16,a5
  vmv1r.v v0,v16                       <== unnecessary insn
  vmerge.vxm      v8,v8,a1,v0
  vse64.v v8,0(a0)
  ret

After this patch:
foo:
  li      a5,-20480
  addiw   a5,a5,-1366
  vsetivli        zero,16,e64,m8,ta,ma
  vmv.s.x v0,a5
  vmv.v.x v8,a2
  vmerge.vxm      v8,v8,a1,v0
  vs8r.v  v8,0(a0)
  ret

gcc/ChangeLog:

	* config/riscv/riscv-v.cc (rvv_builder::get_merge_scalar_mask):
	Add inner_mode mask arg for mask int mode.
	(get_repeating_sequence_dup_machine_mode): Add mask_bit_mode arg
	to get the good enough vector int mode on precision.
	(expand_vector_init_merge_repeating_sequence): Pass required args
	to above func.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-10.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-11.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-12.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-13.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-14.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-15.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-6.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-7.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-8.c: New test.
	* gcc.target/riscv/rvv/autovec/vls-vlmax/init-repeat-sequence-9.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-0.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-2.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-3.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-4.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-5.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-6.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-7.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/init-repeat-sequence-8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2023-11-15 15:41:17 +08:00
Juzhe-Zhong d85161a73b RISC-V: Disallow RVV mode address for any load/store[PR112535]
This patch is quite obvious patch which disallow for load/store address register
with RVV mode.

	PR target/112535

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_legitimate_address_p): Disallow RVV modes base address.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/pr112535.c: New test.
2023-11-15 15:40:59 +08:00
Jakub Jelinek 5f580e2408 c++: Implement C++26 P2864R2 - Remove Deprecated Arithmetic Conversion on Enumerations From C++26
The following patch implements C++26 P2864R2 by emitting pedwarn enabled by
the same options as the C++20 and later warnings (i.e. -Wenum-compare,
-Wdeprecated-enum-enum-conversion and -Wdeprecated-enum-float-conversion
which are all enabled by default).  I think we still want to allow users
some option workaround, so am not using directly error.  Additionally, for
cxx_dialect >= cxx26 && (complain & tf_warning_or_error) == 0 it causes for
these newly ill-formed constructs error_mark_node to be silently returned.

2023-11-15  Jakub Jelinek  <jakub@redhat.com>

gcc/cp/
	* typeck.cc: Implement C++26 P2864R2 - Remove Deprecated Arithmetic
	Conversion on Enumerations From C++26.
	(do_warn_enum_conversions): Return bool rather than void, add COMPLAIN
	argument.  Use pedwarn rather than warning_at for C++26 and remove
	" is deprecated" part of the diagnostics in that case.  For SFINAE
	in C++26 return true on newly erroneous cases.
	(cp_build_binary_op): For C++26 call do_warn_enum_conversions
	unconditionally, pass complain argument to it and if it returns true,
	return error_mark_node.
	* call.cc (build_conditional_expr): Use pedwarn rather than warning_at
	for C++26 and remove " is deprecated" part of the diagnostics in that
	case and check for complain & tf_warning_or_error.  Use emit_diagnostic
	with cxx_dialect >= cxx26 ? DK_PEDWARN : DK_WARNING.  For SFINAE in
	C++26 return error_mark_node on newly erroneous cases.
	(build_new_op): Use emit_diagnostic with cxx_dialect >= cxx26
	? DK_PEDWARN : DK_WARNING and complain & tf_warning_or_error check
	for C++26.  For SFINAE in C++26 return error_mark_node on newly
	erroneous cases.
gcc/testsuite/
	* g++.dg/cpp26/enum-conv1.C: New test.
	* g++.dg/cpp2a/enum-conv1.C: Adjust expected diagnostics in C++26.
	* g++.dg/diagnostic/enum3.C: Likewise.
	* g++.dg/parse/attr3.C: Likewise.
	* g++.dg/cpp0x/linkage2.C: Likewise.
2023-11-15 08:27:07 +01:00
Alexandre Oliva 081fddbbcf Revert "libstdc++: bvector: undef always_inline macro"
This reverts commit a1ad62ee2f.
2023-11-15 01:45:58 -03:00
Alexandre Oliva f5d94999ee testsuite: tsan: add fallback overload for pthread_cond_clockwait
LTS GNU/Linux distros from 2018, still in use, don't have
pthread_cond_clockwait.  There's no trivial way to detect it so as to
make the test conditional, but there's an easy enough way to silence
the fail due to lack of the function in libc, and that has nothing to
do with the false positive that this is testing against.


for  gcc/testsuite/ChangeLog

	* g++.dg/tsan/pthread_cond_clockwait.C: Add fallback overload.
2023-11-14 22:24:28 -03:00
Alexandre Oliva a9a0daa3e5 testsuite: arg-pushing reqs -mno-accumulate-outgoing-args
gcc.target/i386/pr95126-m32-[34].c expect push instructions that are
only present with -mno-accumulate-outgoing-args, so make that option
explicit rather than dependent on tuning.


for  gcc/testsuite/ChangeLog

	* gcc.target/i386/pr95126-m32-3.c: Add
	-mno-accumulate-outgoing-args.
	* gcc.target/i386/pr95126-m32-4.c: Likewise.
2023-11-14 22:15:32 -03:00
Alexandre Oliva a1ad62ee2f libstdc++: bvector: undef always_inline macro
It's customary to undefine temporary internal macros at the end of the
header that defines them, even such widely-usable ones as
_GLIBCXX_ALWAYS_INLINE, so do so in the header where the define was
recently introduced.


for  libstdc++-v3/ChangeLog

	* include/bits/stl_bvector.h (_GLIBCXX_ALWAYS_INLINE): Undef.
2023-11-14 22:15:29 -03:00
David Malcolm 2220263f0e json.cc: use SELFTEST_LOCATION in selftests
gcc/ChangeLog:
	* json.cc (selftest::assert_print_eq): Add "loc" param and use
	ASSERT_STREQ_AT.
	(ASSERT_PRINT_EQ): New macro.
	(selftest::test_writing_objects): Use ASSERT_PRINT_EQ to capture
	source location of assertion.
	(selftest::test_writing_arrays): Likewise.
	(selftest::test_writing_float_numbers): Likewise.
	(selftest::test_writing_integer_numbers): Likewise.
	(selftest::test_writing_strings): Likewise.
	(selftest::test_writing_literals): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-11-14 19:48:48 -05:00
GCC Administrator eaedb56a0f Daily bump. 2023-11-15 00:16:41 +00:00
Lewis Hyatt 9938645fcf c-family: Let libcpp know when the compilation is for a PCH [PR9471]
libcpp will generate diagnostics when it encounters things in the main file
that only belong in a header file, such as `#pragma once' or `#pragma GCC
system_header'. But sometimes the main file is a header file that is just
being compiled separately, e.g. to produce a C++ module or a PCH, in which
case such diagnostics should be suppressed. libcpp already has an interface
to request that, so make use of it in the C frontends to prevent libcpp from
issuing unwanted diagnostics when compiling a PCH.

gcc/c-family/ChangeLog:

	PR pch/9471
	PR pch/47857
	* c-opts.cc (c_common_post_options): Set cpp_opts->main_search
	so libcpp knows it is compiling a header file separately.

gcc/testsuite/ChangeLog:

	PR pch/9471
	PR pch/47857
	* g++.dg/pch/main-file-warnings.C: New test.
	* g++.dg/pch/main-file-warnings.Hs: New test.
	* gcc.dg/pch/main-file-warnings.c: New test.
	* gcc.dg/pch/main-file-warnings.hs: New test.
2023-11-14 17:50:42 -05:00
Cassio Neri f71352c71d libstdc++: Improve operator-(weekday x, weekday y)
The current implementation calls __detail::__modulo which is relatively
expensive.

A better implementation is possible if we assume that x.ok() && y.ok() == true,
so that n = x.c_encoding() - y.c_encoding() is in [-6, 6]. In this case, it
suffices to return n >= 0 ? n : n + 7.

The above is allowed by [time.cal.wd.nonmembers]/5: the returned value is
unspecified when x.ok() || y.ok() == false.

The assembly emitted for x86-64 and ARM can be seen in:
https://godbolt.org/z/nMdc5vv9n.

libstdc++-v3/ChangeLog:

	* include/std/chrono (operator-(const weekday&, const weekday&)):
	Optimize.
2023-11-14 22:32:09 +00:00
Cassio Neri f6ce081d0f libstdc++: Fix UB in weekday::weekday(sys_days) and add test
The following has undefined behaviour (signed overflow) [1]:
    weekday max{sys_days{days{numeric_limits<days::rep>::max()}}};

The issue is in this line when __n is very large and __n + 4 overflows:
    return weekday(__n >= -4 ? (__n + 4) % 7 : (__n + 5) % 7 + 6);

In addition to fixing this bug, the new implementation makes the compiler emit
shorter and branchless code for x86-64 and ARM [2].

[1] https://godbolt.org/z/1s5bv7KfT
[2] https://godbolt.org/z/zKsabzrhs

libstdc++-v3/ChangeLog:

	* include/std/chrono (weekday::_S_from_days): Fix UB.
	* testsuite/std/time/weekday/1.cc: Add test for overflow.
2023-11-14 22:32:08 +00:00
Cassio Neri 86a0df1a6c libstdc++: Simplify year::is_leap()
The current implementation returns
    (_M_y & (__is_multiple_of_100 ? 15 : 3)) == 0;
where __is_multiple_of_100 is calculated using an obfuscated algorithm which
saves one ror instruction when compared to _M_y % 100 == 0 [1].

In leap years calculation, it's correct to replace the divisibility check by
100 with the one by 25. It turns out that _M_y % 25 == 0 also saves the ror
instruction [2]. Therefore, the obfuscation is not required.

[1] https://godbolt.org/z/5PaEv6a6b
[2] https://godbolt.org/z/55G8rn77e

libstdc++-v3/ChangeLog:

	* include/std/chrono (year::is_leap): Clear code.
2023-11-14 22:32:08 +00:00
Cassio Neri b011535456 libstdc++: Remove unnecessary "& 1" from year_month_day_last::day()
When year_month_day_last::day() was implemented, Dr. Matthias Kretz realised
that the operation "& 1" wasn't necessary but we did not patch it at that
time. This patch removes the unnecessary operation.

libstdc++-v3/ChangeLog:

	* include/std/chrono (year_month_day_last::day): Remove &1.
2023-11-14 22:32:08 +00:00
Jonathan Wakely 1c15303375 libstdc++: Fix <charconv> uses of signed types with <bit> functions
In <charconv> we pass the int __base parameter to our internal versions
of <bit> functions, __bit_width and __countr_zero. Those functions are
only defined for unsigned types, so we need to convert the base to
unsigned. The base must be in the range [2,36] so we can mask off the
low bits and then convert that to unsigned, so that we don't need to
care about negative values becoming large unsigned values.

libstdc++-v3/ChangeLog:

	* include/std/charconv (__from_chars_pow2_base): Convert base to
	unsigned for call to __countr_zero.
	(__from_chars_alnum): Likewise for call to __bit_width.
2023-11-14 22:32:08 +00:00
Jonathan Wakely 6f2fc42d9e libstdc++: Fix std::hash<std::stacktrace> [PR112348]
libstdc++-v3/ChangeLog:

	PR libstdc++/112348
	* include/std/stacktrace (hash<basic_stacktrace<Alloc>>): Fix
	type of hash functio nfor entries.
	* testsuite/19_diagnostics/stacktrace/hash.cc: New test.
2023-11-14 22:32:08 +00:00
David Malcolm cfaaa8b11b analyzer: enable taint state machine by default [PR103533]
gcc/analyzer/ChangeLog:
	PR analyzer/103533
	* sm-taint.cc: Remove "experimental" from comment.
	* sm.cc (make_checkers): Always add taint state machine.

gcc/ChangeLog:
	PR analyzer/103533
	* doc/invoke.texi (Static Analyzer Options): Add the six
	-Wanalyzer-tainted-* warnings.  Update documentation of each
	warning to reflect removed requirement to use
	-fanalyzer-checker=taint.  Remove discussion of
	-fanalyzer-checker=taint.

gcc/testsuite/ChangeLog:
	PR analyzer/103533
	* c-c++-common/analyzer/attr-tainted_args-1.c: Remove use of
	-fanalyzer-checker=taint.
	* c-c++-common/analyzer/fread-1.c: Likewise.
	* c-c++-common/analyzer/pr104029.c: Likewise.
	* gcc.dg/analyzer/pr93032-mztools-signed-char.c: Add params to
	work around state explosion.
	* gcc.dg/analyzer/pr93032-mztools-unsigned-char.c: Likewise.
	* gcc.dg/analyzer/pr93382.c: Remove use of
	-fanalyzer-checker=taint.
	* gcc.dg/analyzer/switch-enum-taint-1.c: Likewise.
	* gcc.dg/analyzer/taint-CVE-2011-2210-1.c: Likewise.
	* gcc.dg/analyzer/taint-CVE-2020-13143-1.c: Likewise.
	* gcc.dg/analyzer/taint-CVE-2020-13143-2.c: Likewise.
	* gcc.dg/analyzer/taint-CVE-2020-13143.h: Likewise.
	* gcc.dg/analyzer/taint-alloc-1.c: Likewise.
	* gcc.dg/analyzer/taint-alloc-2.c: Likewise.
	* gcc.dg/analyzer/taint-alloc-3.c: Likewise.
	* gcc.dg/analyzer/taint-alloc-4.c: Likewise.
	* gcc.dg/analyzer/taint-alloc-5.c: Likewise.
	* gcc.dg/analyzer/taint-assert-BUG_ON.c: Likewise.
	* gcc.dg/analyzer/taint-assert-macro-expansion.c: Likewise.
	* gcc.dg/analyzer/taint-assert-system-header.c: Likewise.
	* gcc.dg/analyzer/taint-assert.c: Likewise.
	* gcc.dg/analyzer/taint-divisor-1.c: Likewise.
	* gcc.dg/analyzer/taint-divisor-2.c: Likewise.
	* gcc.dg/analyzer/taint-merger.c: Likewise.
	* gcc.dg/analyzer/taint-ops.c: Delete this test: it was a
	duplicate of material in operations.c and data-model-1.c, with
	-fanalyzer-checker=taint added.
	* gcc.dg/analyzer/taint-read-index-1.c: Remove use of
	-fanalyzer-checker=taint.
	* gcc.dg/analyzer/taint-read-offset-1.c: Likewise.
	* gcc.dg/analyzer/taint-realloc.c: Likewise.  Add missing
	dg-warning for leak now that the malloc state machine is also
	active.
	* gcc.dg/analyzer/taint-size-1.c: Remove use of
	-fanalyzer-checker=taint.
	* gcc.dg/analyzer/taint-size-access-attr-1.c: Likewise.
	* gcc.dg/analyzer/taint-write-index-1.c: Likewise.
	* gcc.dg/analyzer/taint-write-offset-1.c: Likewise.
	* gcc.dg/analyzer/torture/taint-read-index-2.c: Likewise.
	* gcc.dg/analyzer/torture/taint-read-index-3.c: Likewise.
	* gcc.dg/plugin/taint-CVE-2011-0521-1-fixed.c: Likewise.  Add
	-Wno-pedantic.
	* gcc.dg/plugin/taint-CVE-2011-0521-1.c: Likewise.
	* gcc.dg/plugin/taint-CVE-2011-0521-2-fixed.c: Likewise.
	* gcc.dg/plugin/taint-CVE-2011-0521-2.c: Likewise.
	* gcc.dg/plugin/taint-CVE-2011-0521-3-fixed.c: Likewise.
	* gcc.dg/plugin/taint-CVE-2011-0521-3.c: Likewise.  Fix C++-style
	comment.
	* gcc.dg/plugin/taint-CVE-2011-0521-4.c: Remove use of
	-fanalyzer-checker=taint and add -Wno-pedantic. Remove xfail and
	add missing dg-warning.
	* gcc.dg/plugin/taint-CVE-2011-0521-5-fixed.c: Remove use of
	-fanalyzer-checker=taint and add -Wno-pedantic.
	* gcc.dg/plugin/taint-CVE-2011-0521-5.c: Likewise.
	* gcc.dg/plugin/taint-CVE-2011-0521-6.c: Likewise.
	* gcc.dg/plugin/taint-antipatterns-1.c: : Remove use of
	-fanalyzer-checker=taint.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-11-14 15:51:52 -05:00
Jakub Jelinek c6560525ca Manually add ChangeLog entry for r14-5312-g040e5b0edbca861196d9e2ea2af5e805769c8d5d commit.
This commit got ignored because ChangeLog update can't parse its log message.
2023-11-14 21:41:45 +01:00
Dimitar Dimitrov 3d8d443c4e testsuite: Ignore warning for unsupported option
The -w option was used in gcc.dg/20020206-1.c to ignore warnings if the
'-fprefetch-loop-arrays' option is not supported by target.

When commit r14-5380-g5c432b0efab54e removed the -w option, some targets
(arm-none-eabi, pru and possibly others) started failing the test:

  cc1: warning: '-fprefetch-loop-arrays' not supported for this target
  FAIL: gcc.dg/20020206-1.c (test for excess errors)

Fix by instructing DejaGnu to prune the '-fprefetch-loop-arrays'
warning.

gcc/testsuite/ChangeLog:

	* gcc.dg/20020206-1.c: Prune warning that
	-fprefetch-loop-arrays is not supported.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2023-11-14 21:55:38 +02:00
Nathaniel Shead 14979dd31c c++: Stream virtual dtor vtable indices
Virtual cloned functions have distinct vtable indices, stream them
explicitly.

As such, this patch ensures that DECL_VINDEX is properly passed on for
cloned functions as well to prevent this from causing issues.

	PR c++/103499

gcc/cp/ChangeLog:

	* module.cc (trees_out::decl_node): Write DECL_VINDEX for
	virtual clones.
	(trees_in::tree_node): Read DECL_VINDEX for virtual clones.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/pr103499_a.C: New test.
	* g++.dg/modules/pr103499_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Signed-off-by: Nathan Sidwell <nathan@acm.org>
2023-11-14 14:43:20 -05:00
Nathaniel Shead 5b9ecce87e c++: Fix exported using decls of templates
We need to look at DECL_TEMPLATE_RESULT to get the module attachment.

	PR c++/106849

gcc/cp/ChangeLog:

	* name-lookup.cc (do_nonmember_using_decl): Handle
	TEMPLATE_DECLs when checking module attachment.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/using-9.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Signed-off-by: Nathan Sidwell <nathan@acm.org>
2023-11-14 14:43:19 -05:00
David Malcolm 353f146ceb diagnostics: make option-handling callbacks private
No functional change intended.

gcc/c-family/ChangeLog:
	* c-warn.cc (conversion_warning): Update call to
	global_dc->m_option_enabled to use option_enabled_p.

gcc/cp/ChangeLog:
	* decl.cc (finish_function): Update call to
	global_dc->m_option_enabled to use option_enabled_p.

gcc/ChangeLog:
	* diagnostic-format-json.cc
	(json_output_format::on_end_diagnostic): Update calls to m_context
	callbacks to use member functions; tighten up scopes.
	* diagnostic-format-sarif.cc (sarif_builder::make_result_object):
	Likewise.
	(sarif_builder::make_reporting_descriptor_object_for_warning):
	Likewise.
	* diagnostic.cc (diagnostic_context::initialize): Update for
	callbacks being moved into m_option_callbacks and being renamed.
	(diagnostic_context::set_option_hooks): New.
	(diagnostic_option_classifier::classify_diagnostic): Update call
	to global_dc->m_option_enabled to use option_enabled_p.
	(diagnostic_context::print_option_information): Update calls to
	m_context callbacks to use member functions; tighten up scopes.
	(diagnostic_context::diagnostic_enabled): Likewise.
	* diagnostic.h (diagnostic_option_enabled_cb): New typedef.
	(diagnostic_make_option_name_cb): New typedef.
	(diagnostic_make_option_url_cb): New typedef.
	(diagnostic_context::option_enabled_p): New.
	(diagnostic_context::make_option_name): New.
	(diagnostic_context::make_option_url): New.
	(diagnostic_context::set_option_hooks): New decl.
	(diagnostic_context::m_option_enabled): Rename to
	m_option_enabled_cb and move within m_option_callbacks, using
	typedef.
	(diagnostic_context::m_option_state): Move within
	m_option_callbacks.
	(diagnostic_context::m_option_name): Rename to
	m_make_option_name_cb and move within m_option_callbacks, using
	typedef.
	(diagnostic_context::m_get_option_url): Likewise, renaming to
	m_make_option_url_cb.
	* lto-wrapper.cc (print_lto_docs_link): Update call to m_context
	callback to use member function.
	(main): Use diagnostic_context::set_option_hooks.
	* opts-diagnostic.h (option_name): Make context param const.
	(get_option_url): Likewise.
	* opts.cc (option_name): Likewise.
	(get_option_url): Likewise.
	* toplev.cc (general_init): Use
	diagnostic_context::set_option_hooks.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-11-14 14:02:10 -05:00
David Malcolm 07e568d77f diagnostics: make m_text_callbacks private
No functional change intended.

gcc/ChangeLog:
	* diagnostic-show-locus.cc (diagnostic_context::show_locus):
	Update for renaming of text callbacks fields.
	* diagnostic.cc (diagnostic_context::initialize): Likewise.
	* diagnostic.h (class diagnostic_context): Add "friend" for
	accessors to m_text_callbacks.
	(diagnostic_context::m_text_callbacks): Make private, and add an
	"m_" prefix to field names.
	(diagnostic_starter): Convert from macro to inline function.
	(diagnostic_start_span): New.
	(diagnostic_finalizer): Convert from macro to inline function.

gcc/fortran/ChangeLog:
	* error.cc (gfc_diagnostics_init): Use diagnostic_start_span.

gcc/ChangeLog:
	* selftest-diagnostic.cc
	(test_diagnostic_context::test_diagnostic_context): Use
	diagnostic_start_span.
	* tree-diagnostic-path.cc (struct event_range): Likewise.

gcc/testsuite:
	* gcc.dg/plugin/diagnostic_group_plugin.c: Use
	diagnostic_start_span.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-11-14 14:01:55 -05:00
David Malcolm d0bfd6ba3b diagnostics: convert diagnostic_ready_p to an inline function
No functional change intended.

gcc/ChangeLog:
	* diagnostic.h (diagnostic_ready_p): Convert from macro to inline
	function.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-11-14 14:01:36 -05:00
Uros Bizjak b42a09b258 i386: Generate strict_low_part QImode insn with high input register
Following testcase:

struct S1
{
  unsigned char val;
  unsigned char pad1;
  unsigned short pad2;
};

struct S2
{
  unsigned char pad1;
  unsigned char val;
  unsigned short pad2;
};

struct S1 test_and (struct S1 a, struct S2 b)
{
  a.val &= b.val;

  return a;
}

compiles with -O2 to:

	movl    %esi, %edx
	movl    %edi, %eax
	movzbl  %dh, %esi
	andb    %sil, %al

ANDB could use high register %dh instead of %sil:

	movl    %edi, %eax
	movl    %esi, %edx
	andb    %dh, %al

Patch introduces strict_low_part QImode insn patterns with one of
its input arguments extracted from high register.

	PR target/78904

gcc/ChangeLog:

	* config/i386/i386.md (*addqi_ext<mode>_1_slp):
	New define_insn_and_split pattern.
	(*subqi_ext<mode>_1_slp): Ditto.
	(*<any_logic:code>qi_ext<mode>_1_slp): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr78904-7.c: New test.
	* gcc.target/i386/pr78904-7a.c: New test.
	* gcc.target/i386/pr78904-7b.c: New test.
2023-11-14 18:36:02 +01:00
Jakub Jelinek d64b7c82da libcpp, contrib: Update to Unicode 15.1
The following patch (in plaintext just a pseudo-patch where I've left out
the too big parts of either wget downloaded or regenerated files out with
..., full patch attached compressed) updates to Unicode 15.1 from 15.0
we had last year.  Apparently Unicode forgot to add a new range to 4-8 Table
we are using, but from the other files it is clear what should have been
added; I've filed a bugreport against Unicode.

2023-11-14  Jakub Jelinek  <jakub@redhat.com>

contrib/
	* unicode/README: Adjust glibc git commit hash, number of Unicode
	data files to be updated and latest Unicode version.
	* unicode/from_glibc/utf8_gen.py: Update from glibc.
	* unicode/UnicodeData.txt: Update from Unicode 15.1.
	* unicode/EastAsianWidth.txt: Likewise.
	* unicode/DerivedNormalizationProps.txt: Likewise.
	* unicode/NameAliases.txt: Likewise.
	* unicode/DerivedCoreProperties.txt: Likewise.
	* unicode/PropList.txt: Likewise.
libcpp/
	* makeucnid.cc (write_copyright): Update copyright year.
	* makeuname2c.cc (write_copyright): Likewise.
	(struct generated): Update latest Unicode version.
	(generated_ranges): Add 2ebf0-2ee5d CJK UNIFIED IDEOGRAPH
	range which was forgotten to be added to 4-8 table, but
	clearly is expected to be there from the 15.1 additions.
	* ucnid.h: Regenerated.
	* uname2c.h: Regenerated.
	* generated_cpp_wcwidth.h: Regenerated.
2023-11-14 18:32:37 +01:00
Jakub Jelinek 194825f206 c++: Implement C++26 P1854R4 - Making non-encodable string literals ill-formed [PR110341]
This paper voted in as DR makes some multi-character literals ill-formed.
'abcd' stays valid, but e.g. 'á' is newly invalid in UTF-8 exec charset
while valid e.g. in ISO-8859-1, because it is a single character which needs
2 bytes to be encoded.

The following patch does that by checking (only pedantically, especially
because it is a DR) if we'd emit a -Wmultichar warning because character
constant has more than one byte in it whether the number of source characters
is equal to the number of bytes in the multichar string.
If it is, it is normal multi-character literal constant
and is diagnosed normally with -Wmultichar, otherwise at least one of the
c-chars in the sequence was encoded as 2+ bytes.

2023-11-14  Jakub Jelinek  <jakub@redhat.com>

	PR c++/110341
libcpp/
	* charset.cc: Implement C++26 P1854R4 - Making non-encodable string
	literals ill-formed.
	(one_count_chars, convert_count_chars, count_source_chars): New
	functions.
	(narrow_str_to_charconst): Change last arg type from cpp_ttype to
	const cpp_token *.  For C++ if pedantic and i > 1 in CPP_CHAR
	interpret token also as CPP_STRING32 and if number of characters
	in the CPP_STRING32 is larger than number of bytes in CPP_CHAR,
	pedwarn on it.  Make the diagnostics more detailed.
	(wide_str_to_charconst): Change last arg type from cpp_ttype to
	const cpp_token *.  Make the diagnostics more detailed.
	(cpp_interpret_charconst): Adjust narrow_str_to_charconst and
	wide_str_to_charconst callers.
gcc/testsuite/
	* g++.dg/cpp26/literals1.C: New test.
	* g++.dg/cpp26/literals2.C: New test.
	* g++.dg/cpp23/wchar-multi1.C: Adjust expected diagnostic wordings.
	* g++.dg/cpp23/wchar-multi2.C: Likewise.
	* gcc.dg/c23-utf8char-3.c: Likewise.
	* gcc.dg/cpp/charconst-4.c: Likewise.
	* gcc.dg/cpp/charconst.c: Likewise.
	* gcc.dg/cpp/if-2.c: Likewise.
	* gcc.dg/utf16-4.c: Likewise.
	* gcc.dg/utf32-4.c: Likewise.
	* g++.dg/cpp1z/utf8-neg.C: Likewise.
	* g++.dg/cpp2a/ucn2.C: Likewise.
	* g++.dg/ext/utf16-4.C: Likewise.
	* g++.dg/ext/utf32-4.C: Likewise.
2023-11-14 18:28:34 +01:00
Andrew Stubbs 948b8b6e0e Fix ICE generating uniform vector masks
Most targets have an "and" instructions for their vector mask size, but RISC-V
only has DImode "and".  Fixed by allowing wider instruction modes.

gcc/ChangeLog:

	PR target/112481
	* expr.cc (store_constructor): Use OPTAB_WIDEN for mask adjustment.
2023-11-14 16:46:39 +00:00
David Malcolm 1bdd665a02 input.h: eliminate implicit users of global_dc's file_cache
This patch eliminates the following functions that implicitly used
global_dc's file cache:

  extern char_span location_get_source_line (const char *file_path, int line);
  extern char_span get_source_file_content (const char *file_path);
  extern bool location_missing_trailing_newline (const char *file_path);

in favor of explicitly using a specific file_cache throughout, and only
using global_dc's file_cache in gcc-specific code.

Rather than creating global_dc's file_cache the first time its needed,
this patch simply creates one when a diagnostic_context is initialized,
and eliminates diagnostic_file_cache_init.

No functional change intended.

gcc/c-family/ChangeLog:
	* c-common.cc (c_get_substring_location): Use global_dc's
	file_cache.
	* c-format.cc (get_corrected_substring): Likewise.
	* c-indentation.cc (get_visual_column): Add file_cache param.
	(get_first_nws_vis_column): Likewise.
	(detect_intervening_unindent): Likewise.
	(should_warn_for_misleading_indentation): Use global_dc's
	file_cache.
	(assert_get_visual_column_succeeds): Add file_cache param.
	(ASSERT_GET_VISUAL_COLUMN_SUCCEEDS): Likewise.
	(assert_get_visual_column_fails): Likewise.
	(define ASSERT_GET_VISUAL_COLUMN_FAILS): Likewise.
	(selftest::test_get_visual_column): Create and use a temporary
	file_cache.

gcc/cp/ChangeLog:
	* contracts.cc (build_comment): Use global_dc's file_cache.

gcc/ChangeLog:
	* diagnostic-format-sarif.cc (sarif_builder::get_sarif_column):
	Use m_context's file_cache.
	(sarif_builder::maybe_make_artifact_content_object): Likewise.
	(sarif_builder::get_source_lines): Likewise.
	* diagnostic-show-locus.cc
	(exploc_with_display_col::exploc_with_display_col): Add file_cache
	param.
	(layout::m_file_cache): New field.
	(make_range): Add file_cache param.
	(selftest::test_layout_range_for_single_point): Create and use a
	temporary file_cache.
	(selftest::test_layout_range_for_single_line): Likewise.
	(selftest::test_layout_range_for_multiple_lines): Likewise.
	(layout::layout): Initialize m_file_cache from the context and use it.
	(layout::maybe_add_location_range): Use m_file_cache.
	(layout::calculate_x_offset_display): Likewise.
	(get_affected_range): Add file_cache param.
	(get_printed_columns): Likewise.
	(line_corrections::line_corrections): Likewwise.
	(line_corrections::m_file_cache): New field.
	(source_line::source_line): Add file_cache param.
	(line_corrections::add_hint): Use m_file_cache.
	(layout::print_trailing_fixits): Likewise.
	(layout::print_line): Likewise.
	(selftest::test_layout_x_offset_display_utf8): Create and use a
	temporary file_cache.
	(selftest::test_layout_x_offset_display_tab): Likewise.
	(selftest::test_diagnostic_show_locus_one_liner_utf8): Likewise.
	(selftest::test_add_location_if_nearby): Pass global_dc's
	file_cache to temp_source_file ctor.
	(selftest::test_overlapped_fixit_printing): Create and use a
	temporary file_cache.
	(selftest::test_overlapped_fixit_printing_utf8): Likewise.
	(selftest::test_overlapped_fixit_printing_2): Use dc's file_cache.
	* diagnostic.cc (diagnostic_context::initialize): Always create a
	file_cache.
	(diagnostic_context::initialize_input_context): Assume
	m_file_cache has already been created.
	(diagnostic_context::create_edit_context): Pass m_file_cache to
	edit_context.
	(convert_column_unit): Add file_cache param.
	(diagnostic_context::converted_column): Use context's file_cache.
	(print_parseable_fixits): Add file_cache param.
	(diagnostic_context::report_diagnostic): Use context's file_cache.
	(selftest::test_print_parseable_fixits_none): Create and use a
	temporary file_cache.
	(selftest::test_print_parseable_fixits_insert): Likewise.
	(selftest::test_print_parseable_fixits_remove): Likewise.
	(selftest::test_print_parseable_fixits_replace): Likewise.
	(selftest::test_print_parseable_fixits_bytes_vs_display_columns):
	Likewise.
	* diagnostic.h (diagnostic_context::file_cache_init): Delete.
	(diagnostic_context::get_file_cache): Convert return type from
	pointer to reference.
	* edit-context.cc (edited_file::get_file_cache): New.
	(edited_file::m_edit_context): New.
	(edit_context::edit_context): Add file_cache param.
	(edit_context::get_or_insert_file): Pass this to edited_file's
	ctor.
	(edited_file::edited_file): Add edit_context param.
	(edited_file::print_content): Use get_file_cache.
	(edited_file::print_diff_hunk): Likewise.
	(edited_file::print_run_of_changed_lines): Likewise.
	(edited_file::get_or_insert_line): Likewise.
	(edited_file::get_num_lines): Likewise.
	(edited_line::edited_line): Pass in file_cache and use it.
	(selftest::test_get_content): Create and use a
	temporary file_cache.
	(selftest::test_applying_fixits_insert_before): Likewise.
	(selftest::test_applying_fixits_insert_after): Likewise.
	(selftest::test_applying_fixits_insert_after_at_line_end):
	Likewise.
	(selftest::test_applying_fixits_insert_after_failure): Likewise.
	(selftest::test_applying_fixits_insert_containing_newline):
	Likewise.
	(selftest::test_applying_fixits_growing_replace): Likewise.
	(selftest::test_applying_fixits_shrinking_replace): Likewise.
	(selftest::test_applying_fixits_replace_containing_newline):
	Likewise.
	(selftest::test_applying_fixits_remove): Likewise.
	(selftest::test_applying_fixits_multiple): Likewise.
	(selftest::test_applying_fixits_multiple_lines): Likewise.
	(selftest::test_applying_fixits_modernize_named_init): Likewise.
	(selftest::test_applying_fixits_modernize_named_init): Likewise.
	(selftest::test_applying_fixits_unreadable_file): Likewise.
	(selftest::test_applying_fixits_line_out_of_range): Likewise.
	(selftest::test_applying_fixits_column_validation): Likewise.
	(selftest::test_applying_fixits_column_validation): Likewise.
	(selftest::test_applying_fixits_column_validation): Likewise.
	(selftest::test_applying_fixits_column_validation): Likewise.
	* edit-context.h (edit_context::edit_context): Add file_cache
	param.
	(edit_context::get_file_cache): New.
	(edit_context::m_file_cache): New.
	* final.cc: Include "diagnostic.h".
	(asm_show_source): Use global_dc's file_cache.
	* gcc-rich-location.cc (blank_line_before_p): Add file_cache
	param.
	(use_new_line): Likewise.
	(gcc_rich_location::add_fixit_insert_formatted): Use global dc's
	file_cache.
	* input.cc (diagnostic_file_cache_init): Delete.
	(diagnostic_context::file_cache_init): Delete.
	(diagnostics_file_cache_forcibly_evict_file): Delete.
	(file_cache::missing_trailing_newline_p): New.
	(file_cache::evicted_cache_tab_entry): Don't call
	diagnostic_file_cache_init.
	(location_get_source_line): Delete.
	(get_source_text_between): Add file_cache param.
	(get_source_file_content): Delete.
	(location_missing_trailing_newline): Delete.
	(location_compute_display_column): Add file_cache param.
	(dump_location_info): Create and use temporary file_cache.
	(get_substring_ranges_for_loc): Add file_cache param.
	(get_location_within_string): Likewise.
	(get_source_range_for_char): Likewise.
	(get_num_source_ranges_for_substring): Likewise.
	(selftest::test_reading_source_line): Create and use temporary
	file_cache.
	(selftest::lexer_test::m_file_cache): New field.
	(selftest::assert_char_at_range): Use test.m_file_cache.
	(selftest::assert_num_substring_ranges): Likewise.
	(selftest::assert_has_no_substring_ranges): Likewise.
	(selftest::test_lexer_string_locations_concatenation_2): Likewise.
	* input.h (class file_cache): New forward decl.
	(location_compute_display_column): Add file_cache param.
	(location_get_source_line): Delete.
	(get_source_text_between): Add file_cache param.
	(get_source_file_content): Delete.
	(location_missing_trailing_newline): Delete.
	(file_cache::missing_trailing_newline_p): New decl.
	(diagnostics_file_cache_forcibly_evict_file): Delete.
	* selftest.cc (named_temp_file::named_temp_file): Add file_cache
	param.
	(named_temp_file::~named_temp_file): Optionally evict the file
	from the given file_cache.
	(temp_source_file::temp_source_file): Add file_cache param.
	* selftest.h (class file_cache): New forward decl.
	(named_temp_file::named_temp_file): Add file_cache param.
	(named_temp_file::m_file_cache): New field.
	(temp_source_file::temp_source_file): Add file_cache param.
	* substring-locations.h (get_location_within_string): Add
	file_cache param.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Use
	global_dc's file cache.
	* gcc.dg/plugin/expensive_selftests_plugin.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-11-14 11:01:40 -05:00
David Malcolm 070944fdd6 json: reduce use of naked new in json-building code
No functional change intended.

gcc/ChangeLog:
	* diagnostic-format-json.cc: Use type-specific "set_*" functions
	of json::object to avoid naked new of json value subclasses.
	* diagnostic-format-sarif.cc: Likewise.
	* gcov.cc: Likewise.
	* json.cc (object::set_string): New.
	(object::set_integer): New.
	(object::set_float): New.
	(object::set_bool): New.
	(selftest::test_writing_objects): Use object::set_string.
	* json.h (object::set_string): New decl.
	(object::set_integer): New decl.
	(object::set_float): New decl.
	(object::set_bool): New decl.
	* optinfo-emit-json.cc: Use type-specific "set_*" functions of
	json::object to avoid naked new of json value subclasses.
	* timevar.cc: Likewise.
	* tree-diagnostic-path.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-11-14 11:01:39 -05:00
Jonathan Wakely 4db8209280 libstdc++: Fix std::deque::size() Xmethod [PR112491]
The Xmethod for std::deque::size() assumed that the first element would
be at the start of the first node. That's only true if elements are only
added at the back. If an element is inserted at the front, or removed
from the front (or anywhere before the middle) then the first node will
not be completely populated, and the Xmethod will give the wrong result.

libstdc++-v3/ChangeLog:

	PR libstdc++/112491
	* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.size): Fix
	calculation to use _M_start._M_cur.
	* testsuite/libstdc++-xmethods/deque.cc: Check failing cases.
2023-11-14 15:55:03 +00:00
Andrew MacLeod 8f331be429 Use case label type to create case range.
Create a range from the label type, and cast it to the required type.

	PR tree-optimization/112509
	gcc/
	* tree-vrp.cc (find_case_label_range): Create range from case labels.

	gcc/testsuite/
	* gcc.dg/pr112509.c: New.
2023-11-14 10:33:29 -05:00
Stefan Schulze Frielinghaus 2c2fcd6d2a s390: Fix vec_scatter_element for vectors of floats
The offset for vec_scatter_element of floats should be a vector of type
UV4SI instead of V4SF.  Note, this is an incompatibility change.

gcc/ChangeLog:

	* config/s390/s390-builtin-types.def: Add/remove types.
	* config/s390/s390-builtins.def (s390_vec_scatter_element_flt):
	The type for the offset should be UV4SI instead of V4SF.
2023-11-14 16:15:51 +01:00
Saurabh Jha ddb479e796 Add a REG_P check for inc and dec for Arm MVE
This patch tightens mve_vector_mem_operand to reject non-register operands inside {PRE,POST}_{INC,DEC} addresses by introducing a REG_P check.

This patch fixes this ICE:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112337

gcc/ChangeLog:

	PR target/112337
	* config/arm/arm.cc (mve_vector_mem_operand): Add a REG_P check for INC
	and DEC operations.

gcc/testsuite/ChangeLog:

	PR target/112337
	* gcc.target/arm/mve/pr112337.c: Test for REG_P check for INC and DEC
	operations.
2023-11-14 14:49:46 +00:00
Richard Biener 2066c29bf8 tree-optimization/111233 - loop splitting miscompile
The change in r14-2852-gf5fb9ff2396fd4 failed to update patch_loop_exit
to compensate for rewriting of a NE/EQ_EXPR to a new code.  Fixed
with the following.

	PR tree-optimization/111233
	PR tree-optimization/111652
	PR tree-optimization/111727
	PR tree-optimization/111838
	PR tree-optimization/112113
	* tree-ssa-loop-split.cc (patch_loop_exit): Get the new
	guard code instead of the old guard stmt.
	(split_loop): Adjust.

	* gcc.dg/torture/pr111233.c: New testcase.
	* gcc.dg/torture/pr111652.c: Likewise.
	* gcc.dg/torture/pr111727.c: Likewise.
	* gcc.dg/torture/pr111838.c: Likewise.
	* gcc.dg/torture/pr112113.c: Likewise.
2023-11-14 15:10:16 +01:00
Richard Biener bc390ae72f Loop distribution fix for SCC detection
The following adjusts data_dep_in_cycle_p to properly consider the
whole loop nest when looking for data dep cycles and exempting
zero-distance DDRs instead of just the outermost loop.

	* tree-loop-distribution.cc (loop_distribution::data_dep_in_cycle_p):
	Consider all loops in the nest when looking for
	lambda_vector_zerop.
2023-11-14 13:44:56 +01:00
Richard Biener 5ea2965b49 tree-optimization/112281 - loop distribution and zero dependence distances
We currently distribute

  for (c = 2; c; c--)
    for (e = 0; e < 2; e++) {
      d[c] = b = d[c + 1];
      d[c + 1].a = 0;
    }

in a wrong way where the inner loop zero dependence distance should
make us preserve stmt execution order.  We fail to do so since we
only look for a fully zero distance vector rather than looking at
the innermost loop distance.  This is somewhat similar to PR87022
where we instead looked at the outermost loop distance and changed
this to what we do now.  The following switches us to look at the
innermost loop distance.

	PR tree-optimization/112281
	* tree-loop-distribution.cc (pg_add_dependence_edges):
	Preserve stmt order when the innermost loop has exact
	overlap.

	* gcc.dg/torture/pr112281.c: New testcase.
2023-11-14 13:44:56 +01:00
GCC Administrator b9fd8399ec Daily bump. 2023-11-14 12:23:39 +00:00
Jakub Jelinek aad65285a1 i386: Fix up <insn><dwi>3_doubleword_lowpart [PR112523]
On Sun, Nov 12, 2023 at 09:03:42PM -0000, Roger Sayle wrote:
> This patch improves register pressure during reload, inspired by PR 97756.
> Normally, a double-word right-shift by a constant produces a double-word
> result, the highpart of which is dead when followed by a truncation.
> The dead code calculating the high part gets cleaned up post-reload, so
> the issue isn't normally visible, except for the increased register
> pressure during reload, sometimes leading to odd register assignments.
> Providing a post-reload splitter, which clobbers a single wordmode
> result register instead of a doubleword result register, helps (a bit).

Unfortunately this broke bootstrap on i686-linux, broke all ACATS tests
on x86_64-linux as well as miscompiled e.g. __floattisf in libgcc there
as well.

The bug is that shrd{l,q} instruction expects the low part of the input
to be the same register as the output, rather than the high part as the
patch implemented.
  split_double_mode (<DWI>mode, &operands[1], 1, &operands[1], &operands[3]);
sets operands[1] to the lo_half and operands[3] to the hi_half, so if
operands[0] is not the same register as operands[1] (rather than [3]) after
RA, we should during splitting move operands[1] into operands[0].

Your testcase:
> #define MASK60 ((1ul << 60) - 1)
> unsigned long foo (__uint128_t n)
> {
>   unsigned long a = n & MASK60;
>   unsigned long b = (n >> 60);
>   b = b & MASK60;
>   unsigned long c = (n >> 120);
>   return a+b+c;
> }

still has the same number of instructions.

Bootstrapped/regtested on x86_64-linux (where it e.g. turns
                === acats Summary ===
-# of unexpected failures       2328
+# of expected passes           2328
+# of unexpected failures       0
and fixes gcc.dg/torture/fp-int-convert-*timode.c FAILs as well)
and i686-linux (where it previously didn't bootstrap, but compared to
Friday evening's bootstrap the testresults are ok).

2023-11-14  Jakub Jelinek  <jakub@redhat.com>

	PR target/112523
	PR ada/112514
	* config/i386/i386.md (<insn><dwi>3_doubleword_lowpart): Move
	operands[1] aka low part of input rather than operands[3] aka high
	part of input to output if not the same register.
2023-11-14 13:19:48 +01:00
Jakub Jelinek 0a1dd8b551 contrib: Ignore the r14-5312-g040e5b0edbca861196d9e2ea2af5e805769c8d5d bogus commit
The r14-5312-g040e5b0edbca861196d9e2ea2af5e805769c8d5d commit log contains
a line from git revert with correct hash, but unfortunately hand ammended
with explanation, so it got through the pre-commit hook but failed during
update_version_git generation.  Please don't do this.

2023-11-14  Jakub Jelinek  <jakub@redhat.com>

contrib/ChangeLog:
	* gcc-changelog/git_update_version.py: Add
	040e5b0edb to ignored commits.
2023-11-14 13:16:36 +01:00
Georg-Johann Lay 3232e73c44 LibF7: sinh: Fix loss of precision due to cancellation for small values.
libgcc/config/avr/libf7/
	* libf7-const.def [F7MOD_sinh_]: Add MiniMax polynomial.
	* libf7.c (f7_sinh): Use it instead of (exp(x) - exp(-x)) / 2
	when |x| < 0.5 to avoid loss of precision due to cancellation.
2023-11-14 12:10:08 +01:00
Lehua Ding e47e836f31 x86: Make testcase apx-spill_to_egprs-1.c more robust
Hi,

This little patch adjust the assert in apx-spill_to_egprs-1.c testcase.
The -mapxf compilation option allows more registers to be used, which in
turn eliminates the need for local variables to be stored in stack memory.
Therefore, the assertion is changed to detects no memory loaded through the
%rsp register.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/apx-spill_to_egprs-1.c: Make sure that no local
	variables are stored on the stack.
2023-11-14 18:55:17 +08:00