Skip to content

[April 29th 2025] Merge changes from upstream #3723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10,000 commits into
base: master
Choose a base branch
from

Conversation

powerboat9
Copy link
Collaborator

This should improve our situation with respect to downstreaming. Any merge should be done with the github default merge method, rather than with a rebase-merge.

@powerboat9 powerboat9 requested a review from dkm April 9, 2025 21:50
@powerboat9
Copy link
Collaborator Author

powerboat9 commented Apr 9, 2025

GitHub appears to be having issues displaying the diff, considering the amount of commits or files involved I'd guess. I'm not sure how we'd fix that, so we might have to just work around it.

@powerboat9
Copy link
Collaborator Author

Looks like one of the tests is failing -- any ideas?

janhubicka and others added 27 commits April 19, 2025 18:52
as disucssed, I will proceed adding costs for common SSE operations which are
currently globbed into addss cost, so we do not need to set it incorrectly for
znver5.  Looking through the stats, there are quite few missing cases, so I am
starting with those that I think are more common. I plan to do it in smaller
steps so individual changes gets benchmarked by LNT and also can be bisected
to.

This patch adds costs for various SSE and AVX FP->FP conversions (extensions and
truncations). Looking through Agner Fog's tables, these are bit assymetric so I
added cost for CVTSS2SD which is also used for CVTSD2SS, CVTPS2PD and CVTPD2PS,
cost for 256bit VCVTPS2PS (also used for oposite direction) and cost for 512bit
one.

I plan to add int->int conversions next and then int->fp & fp->int which are
more tricky since they may bundle inter-unit move.

I also noticed that size tables are wrong for all SSE instructions so I updated
them.  With some love I think vectorization can work as size optimization, too,
but we need more work on that.

Those values I can find in Agner Fog tables are taken from there, other are guesses
(especially for yongfeng_cost and shijidadao_cost).

gcc/ChangeLog:

	* config/i386/i386.cc (vec_fp_conversion_cost): New function.
	(ix86_rtx_costs): Use it for SSE/AVX FP conversoins.
	(ix86_builtin_vectorization_cost): Fix indentation;
	and use vec_fp_conversion_cost in vec_promote_demote.
	(fp_conversion_stmt_cost): New function.
	(ix86_vector_costs::add_stmt_cost): Use it to cost NOP_EXPR
	and vec_promote_demote.
	* config/i386/i386.h (struct processor_costs):
	* config/i386/x86-tune-costs.h (struct processor_costs):
I'm posting this on behalf of Shreya Munnangi who is working as an intern with
me.  I've got her digging into prerequisites for removing mvconst_internal and
would prefer she focus on that rather than our patch process at this time.

--

We can use the orn, xnor, andn instructions on RISC-V to improve the code
generated logical operations when one operand is a constant C where
synthesizing ~C is cheaper than synthesizing C.

This is going to be an N -> N - 1 splitter rather than a define_insn_and_split.
A define_insn_and_split can obviously work, but has multiple undesirable
effects in general.

As a result of implementing as a simple define_split we're not supporting AND
at this time.  We need to clean up the mvconst_internal situation first after
which supporting AND is trivial.

This has been tested in Ventana's CI system as well as my tester. Obviously
we'll wait for the pre-commit tester to run before moving forward.

	PR target/118410
gcc/
	* config/riscv/bitmanip.md (logical with constant argument): New
	splitter for cases where synthesizing ~C is cheaper than synthesizing
	the original constant C.

gcc/testsuite/
	* gcc.target/riscv/pr118410-1.c: New test.
	* gcc.target/riscv/pr118410-2.c: Likewise.

	    Co-authored-by: Jeff Law  <[email protected]>
Kaiweng's patch to stop freeing riscv_arch_string was correct, but incomplete
as there's another path that was freeing that node, which is just plain wrong
for a node allocated by the GC system.

This patch removes that call to free() which fixes the test.  I've spun it in
my tester and will obviously wait for the pre-commit system to render a verdict
before moving forward.

	PR target/119865
gcc/
	* config/riscv/riscv.cc (parse_features_for_version): Do not
	explicitly free the architecture string.
..., using the standard idiom.  This '*.exp' file doesn't adhere to the
parallel testing protocol as defined in 'gcc/testsuite/lib/gcc-defs.exp'.

This also restores proper behavior for '*.exp' files executing after (!) this
one, which erroneously caused hundreds or even thousands of individual test
cases get duplicated vs. skipped, randomly, depending on the '-jN' level.

	PR testsuite/119508
	gcc/testsuite/
	* rust/compile/nr2/compile.exp: Disable parallel testing.
commit 546f28f
Author: Richard Sandiford <[email protected]>
Date:   Mon Apr 7 08:03:46 2025 +0100

    simplify-rtx: Fix shortcut for vector eq/ne

fixed

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117863

	PR target/117863
	* gcc.dg/rtl/i386/vector_eq-2.c: New test.
	* gcc.dg/rtl/i386/vector_eq-3.c: Likewise.

Signed-off-by: H.J. Lu <[email protected]>
When FMA is available, N-R step can be rewritten with

a / b = (a - (rcp(b) * a * b)) * rcp(b) + rcp(b) * a

which have 2 fma generated.

gcc/ChangeLog:

	* config/i386/i386-expand.cc (ix86_emit_swdivsf): Generate 2
	FMA instructions when TARGET_FMA.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/recip-vec-divf-fma.c: New test.
intrinsic.cc doesn't compile on Solaris:

/vol/gcc/src/hg/master/cobol/libgcobol/intrinsic.cc: In function ‘void
__gg__formatted_current_date(cblc_field_t*, cblc_field_t*, std::size_t,
std::size_t)’:
/vol/gcc/src/hg/master/cobol/libgcobol/intrinsic.cc:1480:6: error: ‘struct
std::tm’ has no member named ‘tm_zone’; did you mean ‘tm_mon’?
 1480 |   tm.tm_zone = "GMT";
      |      ^~~~~~~
      |      tm_mon

struct tm.tm_zone is new in POSIX.1-2024, thus cannot be assumed to be
present universally.

This patch checks for its presence and guards the use accordingly.

Bootstrapped without regressions on amd64-pc-solaris2.11,
sparcv9-sun-solaris2.11, and x86_64-pc-solaris2.11.

2025-04-08  Rainer Orth  <[email protected]>

	libgcobol:
	* configure.ac: Check for struct tm.tm_zone.
	* configure, config.h.in: Regenerate.
	* intrinsic.cc (__gg__formatted_current_date): Guard tm.tm_zone
	use with HAVE_STRUCT_TM_TM_ZONE.
So while debugging PR 118320, I found it was useful to have
an assert inside array_slice::begin/end that the array slice isvalid
rather than getting an segfault. This adds an assert that is only
enabled for checking.

OK? Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

	* vec.h (array_slice::begin): Assert that the
	slice is valid.
	(array_slice::end): Likewise.

Signed-off-by: Andrew Pinski <[email protected]>
…r comdat functions [PR119507]

This has been broken since GCC started to put the comdat functions' gcc_except_table into their
own section; r0-118218-g3e6011cfebedfb. What would happen is after a non-comdat function is processed,
the cached value would always be used even for comdat function. Instead we should create a new
section for comdat functions.

OK? Bootstrapped and tested on x86_64-linux-gnu.

	PR middle-end/119507

gcc/ChangeLog:

	* except.cc (switch_to_exception_section): Don't use the cached section if
	the current function is in comdat.

gcc/testsuite/ChangeLog:

	* g++.dg/eh/pr119507.C: New test.

Signed-off-by: Andrew Pinski <[email protected]>
The optimisation to reduce the result to constant 28 still happens
but only much later in combine.

gcc/testsuite/
	* gcc.dg/tree-ssa/ssa-dom-cse-2.c: Do not check output for
	MIPS lp64 abi.
There are no platforms nor simulators for MSA and microMIPS R5 so
turning off this support for now.

gcc/ChangeLog:

	* config/mips/mips.cc (mips_option_override): Error out for
	-mmicromips -mmsa.
Accept jrc for clear cache intrinsic.

gcc/testsuite
	* gcc.target/mips/clear-cache-1.c: Also allow jrc.
From: Andrew Bennett <[email protected]>

Firstly, remove the MIPS specific bit of the test.
Secondly, create a MIPS specific version in the gcc.target/mips.
This will only execute for a MIPS ISA less than R6.

Cherry-picked c8b051cdbb1d5b166293513b0360d3d67cf31eb9
from https://github.com/MIPS/gcc

gcc/testsuite
	* gcc.dg/memcpy-4.c: Remove mips specific code.
	* gcc.target/mips/memcpy-2.c: New test.
In previous patch I miscomputed costs of cvtpd2pf instruction
which mistakely gets accounted as 2 (VEC_PACK_TRUNC_EXPR).
Vectorizer can produce both, but when producing VEC_PACK_TRUNC_EXPR
it use promote_demote patch.  This patch thus simplifies
handling of NOP_EXPR since in that case we should always be producing
only one instruction.

	PR target/119879
	* config/i386/i386.cc (fp_conversion_stmt_cost): Inline to ...
	(ix86_vector_costs::add_stmt_cost): ... here; fix handling of NOP_EXPR.
r11-7740 limited constexpr rejection of conversion from pointer to integer
to manifestly constant-evaluated contexts; it should instead check whether
we're in strict mode.

The comment for that commit noted that making this change regressed other
tests, which turned out to be because maybe_constant_init_1 was not being
properly strict for variables declared constexpr/constinit.

	PR c++/99456

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_constant_expression): Check strict
	instead of manifestly_const_eval.
	(maybe_constant_init_1): Be strict for static constexpr vars.
r15-7893 added a workaround for a case where we weren't registering (long)&a
as invalid in a constant-expression, because build_new_1 had folded away the
CONVERT_EXPR that we rely on to diagnose that problem.  In general we want
to defer most folding until cp_fold_function, so let's fold less here.  We
mainly want to expose constant size so we can treat it differently, and we
already did any constexpr evaluation when initializing cst_outer_nelts, so
fold_to_constant seems like the right choice.

	PR c++/118775

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_call_expression): Add assert.
	(fold_to_constant): Handle processing_template_decl.
	* init.cc (build_new_1): Use fold_to_constant.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/constexpr-new24.C: Adjust diagnostic.
My proposed change to stop setting TREE_STATIC on constexpr heap
pseudo-variables led to a diagnostic regression because we would get the
generic "not constant" diagnostic before the "allocated storage" diagnostic.
So let's move the generic verify_constant down a bit.

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_outermost_constant_expr): Move
	verify_constant later.
pr118182-2.c fails on gcc-14 because it lacks the late_combine passes,
particularly the one that runs after register allocation.

Even in the trunk, the predicate broadcast for the add reduction is
expanded and register-allocated as _zvfh, taking up an unneeded scalar
register to hold the constant to be vec_duplicated.

It is the late combine pass after register allocation that substitutes
this unneeded scalar register into the vec_duplicate, resolving to the
_zero or _imm insns.

It's easy enough and more efficient to expand pred_broadcast to the
insns that take the already-duplicated vector constant, when the
operands satisfy the predicates of the _zero or _imm insns.


for  gcc/ChangeLog

	PR target/118182
	* config/riscv/vector.md (@pred_broadcast<mode>): Expand to
	_zero and _imm variants without vec_duplicate.
gcc.target/powerpc/power11-3.c uses target_clones, that depends on
ifunc.  Require ifunc support.


for  gcc/testsuite/ChangeLog

	* gcc.target/powerpc/power11-3.c: Require ifunc support.
arm eabi emits the exception table using the handlerdata directive
and does not use a comdat section for comdat functions. So this
testcase should be skipped for arm eabi.

Pushed as obvious after a quick test.

gcc/testsuite/ChangeLog:

	* g++.dg/eh/pr119507.C: Skip for arm eabi.

Signed-off-by: Andrew Pinski <[email protected]>
…end classes [PR119863]

In r15-9029-geb26b667518c95, we started checking for conflicting
declarations with any reachable decl attached to the same originating
module.  This exposed the issue in the PR, where we would always create
a new type even if a matching type existed in the original module.

This patch reworks lookup_imported_hidden_friend to handle this case
better, by first checking for any reachable decl in the attached module
before looking in the mergeable decl slots.

	PR c++/119863

gcc/cp/ChangeLog:

	* name-lookup.cc (get_mergeable_namespace_binding): Remove
	no-longer-used function.
	(lookup_imported_hidden_friend): Also look for hidden imported
	decls in an attached decl's module.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/tpl-friend-18_a.C: New test.
	* g++.dg/modules/tpl-friend-18_b.C: New test.
	* g++.dg/modules/tpl-friend-18_c.C: New test.

Signed-off-by: Nathaniel Shead <[email protected]>
This call is not necessary, as we don't access the bodies of any classes
that we instantiate here.

gcc/cp/ChangeLog:

	* name-lookup.cc (lookup_imported_hidden_friend): Remove
	unnecessary lazy_load_pendings.

Signed-off-by: Nathaniel Shead <[email protected]>
The gcc.misc-tests/gcov-31.c test FAILs on Solaris and Darwin:

FAIL: gcc.misc-tests/gcov-31.c (test for excess errors)

Excess errors:
/vol/gcc/src/hg/master/local/gcc/testsuite/gcc.misc-tests/gcov-31.c:23:5:
error: implicit declaration of function '__sigsetjmp'; did you mean
'sigsetjmp'? [-Wimplicit-function-declaration]

__sigsetjmp is a Linux/glibc implementation detail.  Other tests just
use sigsetjmp directly, so this patch follows suit.

Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11,
x86_64-pc-linux-gnu, and x86_64-apple-darwin24.4.0.

2025-04-22  Rainer Orth  <[email protected]>

	gcc/testsuite:
	* gcc.misc-tests/gcov-31.c (run_pending_traps): Use sigsetjmp
	instead of __sigsetjmp.
Disallow adding new symbols to GLIBCXX_3.4.34 and CXXABI_1.3.16 versions.

	* testsuite/util/testsuite_abi.cc (check_version): Update latestp
	to use GLIBCXX_3.4.35 and CXXABI_1.3.17.
davidmalcolm and others added 28 commits April 28, 2025 18:21
gcc/analyzer/ChangeLog:
	* engine.cc (class plugin_analyzer_init_impl): Convert
	"m_checkers" to use std::vector of std::unique_ptr.  Convert
	"m_known_fn_mgr" to a reference.
	(impl_run_checkers): Convert "checkers" to use std::vector of
	std::unique_ptr and move it into the extrinsic_state.
	* program-state.cc (extrinsic_state::dump_to_pp): Update for
	changes to m_checkers.
	(extrinsic_state::to_json): Likewise.
	(extrinsic_state::get_sm_idx_by_name): Likewise.
	(selftest::test_sm_state_map): Update to use std::unique_ptr
	for state machines.
	(selftest::test_program_state_1): Likewise.
	(selftest::test_program_state_2): Likewise.
	(selftest::test_program_state_merging): Likewise.
	(selftest::test_program_state_merging_2): Likewise.
	* program-state.h (class extrinsic_state): Convert "m_checkers" to
	use std::vector of std::unique_ptr and to be owned by this object,
	rather than a reference.  Add ctor for use in selftests.
	* sm-fd.cc (make_fd_state_machine): Update to use std::unique_ptr.
	* sm-file.cc (make_fileptr_state_machine): Likewise.
	* sm-malloc.cc (make_malloc_state_machine): Likewise.
	* sm-pattern-test.cc (make_pattern_test_state_machine): Likewise.
	* sm-sensitive.cc (make_sensitive_state_machine): Likewise.
	* sm-signal.cc (make_signal_state_machine): Likewise.
	* sm-taint.cc (make_taint_state_machine): Likewise.
	* sm.cc: Define INCLUDE_LIST.
	(make_checkers): Return the vector directly, rather than pass it
	in by reference.  Update to use std::unique_ptr throughout.  Use
	an intermediate list, and use that to filter with
	flag_analyzer_checker, fixing memory leak for this case.
	* sm.h: (make_checkers): Return the vector directly, rather than
	pass it in by reference, and use std::vector of std::unique_ptr.
	(make_malloc_state_machine): Convert return type to use std::unique_ptr.
	(make_fileptr_state_machine): Likewise.
	(make_taint_state_machine): Likewise.
	(make_sensitive_state_machine): Likewise.
	(make_signal_state_machine): Likewise.
	(make_pattern_test_state_machine): Likewise.
	(make_va_list_state_machine): Likewise.
	(make_fd_state_machine): Likewise.
	* varargs.cc (make_va_list_state_machine): Update to use
	std::unique_ptr.

Signed-off-by: David Malcolm <[email protected]>
C++11 does not provide a std::make_unique so in
r13-3627-g00d7c8ff16e683 I added a make-unique.h
declaring a ::make_unique.

As of r15-4719-ga9ec1bc06bd3cc we can use C++14, so make-unique.h is no
longer needed: we can use simply use std::make_unique instead.

This patch removes make-unique.h and updates every place using it
to use std::make_unique.

No functional change intended.

gcc/analyzer/ChangeLog:
	* access-diagram.cc: Replace uses of ::make_unique with
	std::make_unique.
	* analyzer.cc: Likewise.
	* bounds-checking.cc: Likewise.
	* call-details.cc: Likewise.
	* call-info.cc: Likewise.
	* call-string.cc: Likewise.
	* checker-path.cc: Likewise.
	* common.h: Drop include of "make-unique.h".
	* constraint-manager.cc: Replace uses of ::make_unique with
	std::make_unique.
	* diagnostic-manager.cc: Likewise.
	* engine.cc: Likewise.
	* infinite-loop.cc: Likewise.
	* infinite-recursion.cc: Likewise.
	* kf-analyzer.cc: Likewise.
	* kf-lang-cp.cc: Likewise.
	* kf.cc: Likewise.
	* pending-diagnostic.cc: Likewise.
	* program-point.cc: Likewise; drop #include.
	* program-state.cc: Likewise.
	* ranges.cc: Likewise.
	* region-model.cc: Likewise.
	* region.cc: Likewise; drop #include.
	* sm-fd.cc: Likewise.
	* sm-file.cc: Likewise.
	* sm-malloc.cc: Likewise.
	* sm-pattern-test.cc: Likewise.
	* sm-sensitive.cc: Likewise.
	* sm-signal.cc: Likewise.
	* sm-taint.cc: Likewise.
	* sm.cc: Likewise.
	* store.cc: Likewise.
	* supergraph.cc: Likewise.
	* svalue.cc: Likewise; drop #include.
	* varargs.cc: Likewise.

gcc/c-family/ChangeLog:
	* c-pretty-print.cc: Drop include of "make-unique.h".
	Replace uses of ::make_unique with std::make_unique.

gcc/c/ChangeLog:
	* c-decl.cc: Drop include of "make-unique.h".
	Replace uses of ::make_unique with std::make_unique.
	* c-objc-common.cc: Likewise.
	* c-parser.cc: Likewise.

gcc/cp/ChangeLog:
	* cxx-pretty-print.cc: Drop include of "make-unique.h".
	Replace uses of ::make_unique with std::make_unique.
	* error.cc: Likewise.
	* name-lookup.cc: Likewise.
	* parser.cc: Likewise.

gcc/ChangeLog:
	* diagnostic-format-json.cc: Drop include of "make-unique.h".
	Replace uses of ::make_unique with std::make_unique.
	* diagnostic-format-sarif.cc: Likewise.
	* diagnostic-format-text.cc: Likewise.
	* diagnostic.cc: Likewise.
	* dumpfile.cc: Likewise.
	* gcc-attribute-urlifier.cc: Likewise.
	* gcc-urlifier.cc: Likewise.
	* json-parsing.cc: Likewise.
	* json.cc: Likewise.
	* lazy-diagnostic-path.cc: Likewise.
	* libgdiagnostics.cc: Likewise.
	* libsarifreplay.cc: Likewise.
	* lto-wrapper.cc: Likewise.
	* make-unique.h: Delete.
	* opts-diagnostic.cc: Drop include of "make-unique.h".
	Replace uses of ::make_unique with std::make_unique.
	* pretty-print.cc: Likewise.
	* text-art/style.cc: Likewise.
	* text-art/styled-string.cc: Likewise.
	* text-art/table.cc: Likewise.
	* text-art/tree-widget.cc: Likewise.
	* text-art/widget.cc: Likewise.
	* timevar.cc: Likewise.
	* toplev.cc: Likewise.
	* tree-diagnostic-client-data-hooks.cc: Likewise.

gcc/jit/ChangeLog:
	* dummy-frontend.cc: Drop include of "make-unique.h".
	Replace uses of ::make_unique with std::make_unique.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/analyzer_cpython_plugin.cc: Drop include of
	"make-unique.h".  Replace uses of ::make_unique with
	std::make_unique.
	* gcc.dg/plugin/analyzer_gil_plugin.cc: Likewise.
	* gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise.
	* gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise.
	* gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise.
	* gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc: Likewise.

Signed-off-by: David Malcolm <[email protected]>
… for C++

Implement ana::translation_unit for the C++ frontend with a
no-op placeholder implementation, for now.

No functional change intended; a follow-up may implement
things further.

gcc/cp/ChangeLog:
	* parser.cc: Include "analyzer/analyzer-language.h".
	(ana::cp_translation_unit): New class.
	(cp_parser_translation_unit): Add call to
	ana::on_finish_translation_unit.

Signed-off-by: David Malcolm <[email protected]>
This patch adds initial support for exception-handling to -fanalyzer,
handling eh_dispatch for regions of type ERT_TRY and
ERT_ALLOWED_EXCEPTIONS.   I haven't managed yet seen eh_dispatch for
regions of type ERT_CLEANUP and ERT_MUST_NOT_THROW in the analyzer; with
this patch it will ICE if it sees those.

Additionally, this patch only checks for exact matches of exception
types, rather than supporting subclasses and references.  I'm deferring
fixing this for now whilst figuring out how best to interact with the C++
type system; I'm tracking it as PR analyzer/119697.

The patch adds event classes for throwing and catching exceptions, and
seems to generate readable warnings for the kinds of leak that might
occur due to trying to manage resources manually and forgetting about
exceptions; for example:

exception-leak-1.C: In function ‘int test()’:
exception-leak-1.C:7:9: warning: leak of ‘ptr’ [CWE-401] [-Wanalyzer-malloc-leak]
    7 |   throw 42;
      |         ^~
  ‘int test()’: events 1-3
    5 |   void *ptr = __builtin_malloc (1024);
      |               ~~~~~~~~~~~~~~~~~^~~~~~
      |                                |
      |                                (1) allocated here
    6 |
    7 |   throw 42;
      |         ~~
      |         |
      |         (2) throwing exception of type ‘int’ here...
      |         (3) ⚠️  ‘ptr’ leaks here; was allocated at (1)

Although dynamic exception specifications are only available in C++14
and earlier, the need to support them meant it seemed relatively easy to
add a warning to check them, hence the patch adds a new warning
for code paths that throw an exception that doesn't match a dynamic
exception specification:  -Wanalyzer-throw-of-unexpected-type.

gcc/analyzer/ChangeLog:
	PR analyzer/97111
	* analyzer.cc (is_cxa_throw_p): New.
	(is_cxa_rethrow_p): New.
	* analyzer.opt (Wanalyzer-throw-of-unexpected-type): New.
	* analyzer.opt.urls: Regenerate.
	* call-info.cc (custom_edge_info::create_enode): New.
	* call-info.h (call_info::print): Drop "final".
	(call_info::add_events_to_path): Likewise.
	* checker-event.cc (event_kind_to_string): Add cases for
	event_kind::catch_, event_kind::throw_, and event_kind::unwind.
	(explicit_throw_event::print_desc): New.
	(throw_from_call_to_external_fn_event::print_desc): New.
	(unwind_event::print_desc): New.
	* checker-event.h (enum class event_kind): Add catch_, throw_,
	and unwind.
	(class catch_cfg_edge_event): New.
	(class throw_event): New.
	(class explicit_throw_event): New.
	(class throw_from_call_to_external_fn_event): New.
	(class unwind_event): New.
	* common.h (class eh_dispatch_cfg_superedge): New forward decl.
	(class eh_dispatch_try_cfg_superedge): New forward decl.
	(class eh_dispatch_allowed_cfg_superedge): New forward decl.
	(custom_edge_info::create_enode): New vfunc decl.
	(is_cxa_throw_p): New decl.
	(is_cxa_rethrow_p): New decl.
	* diagnostic-manager.cc
	(diagnostic_manager::add_events_for_superedge): Special-case edges
	for eh_dispach_try.
	(diagnostic_manager::prune_path): Call consolidate_unwind_events.
	(diagnostic_manager::prune_for_sm_diagnostic): Don't filter the new
	event_kinds.
	(diagnostic_manager::consolidate_unwind_events): New.
	* diagnostic-manager.h
	(diagnostic_manager::consolidate_unwind_events): New decl.
	* engine.cc (exploded_node::on_stmt_pre): Handle "__cxa_throw",
	"__cxa_rethrow", and resx statements.
	(class throw_custom_edge): New.
	(class unwind_custom_edge): New.
	(get_eh_outedge): New.
	(exploded_graph::unwind_from_exception): New.
	(exploded_node::on_throw): New.
	(exploded_node::on_resx): New.
	(exploded_graph::get_or_create_node): Add "add_to_worklist" param
	and use it.
	(exploded_graph::process_node): Use edge_info's create_enode vfunc
	to create enodes, rather than calling get_or_create_node directly.
	Ignore CFG edges in the sgraph flagged with EH whilst we're
	exploring the egraph.
	(exploded_graph_annotator::print_enode): Handle case
	exploded_node::status::special.
	* exploded-graph.h (exploded_node::status): Add value "special".
	(exploded_node::on_throw): New decl.
	(exploded_node::on_resx): New decl.
	(exploded_graph::get_or_create_node): Add optional
	"add_to_worklist" param.
	(exploded_graph::unwind_from_exception): New decl.
	* kf-lang-cp.cc (class kf_cxa_allocate_exception): New.
	(class kf_cxa_begin_catch): New.
	(class kf_cxa_end_catch): New.
	(class throw_of_unexpected_type): New.
	(class kf_cxa_call_unexpected): New.
	(register_known_functions_lang_cp): Register known functions
	"__cxa_allocate_exception", "__cxa_begin_catch",
	"__cxa_end_catch", and "__cxa_call_unexpected".
	* kf.cc (class kf_eh_pointer): New.
	(register_known_functions): Register it for BUILT_IN_EH_POINTER.
	* region-model.cc: Include "analyzer/function-set.h".
	(exception_node::operator==): New.
	(exception_node::dump_to_pp): New.
	(exception_node::dump): New.
	(exception_node::to_json): New.
	(exception_node::make_dump_widget): New.
	(exception_node::maybe_get_type): New.
	(exception_node::add_to_reachable_regions): New.
	(region_model::region_model): Initialize
	m_thrown_exceptions_stack and m_caught_exceptions_stack.
	(region_model::operator=): Likewise.
	(region_model::operator==): Compare them.
	(region_model::dump_to_pp): Dump exception stacks.
	(region_model::to_json): Add exception stacks.
	(region_model::make_dump_widget): Likewise.
	(class exception_thrown_from_unrecognized_call): New.
	(get_fns_assumed_not_to_throw): New.
	(can_throw_p): New.
	(region_model::check_for_throw_inside_call): New.
	(region_model::on_call_pre): Call check_for_throw_inside_call
	on unknown fns or those we don't have a body for.
	(region_model::maybe_update_for_edge): Handle eh_dispatch_stmt
	statements.  Drop old code that called
	apply_constraints_for_exception on EDGE_EH edges.
	(class rejected_eh_dispatch): New.
	(exception_matches_type_p): New.
	(matches_any_exception_type_p): New.
	(region_model::apply_constraints_for_eh_dispatch): New.
	(region_model::apply_constraints_for_eh_dispatch_try): New.
	(region_model::apply_constraints_for_eh_dispatch_allowed): New.
	(region_model::apply_constraints_for_exception): Delete.
	(region_model::can_merge_with_p): Don't merge models with
	non-equal exception stacks.
	(region_model::get_referenced_base_regions): Add regions from
	exception stacks.
	* region-model.h (struct exception_node): New.
	(region_model::push_thrown_exception): New.
	(region_model::get_current_thrown_exception): New.
	(region_model::pop_thrown_exception): New.
	(region_model::push_caught_exception): New.
	(region_model::get_current_caught_exception): New.
	(region_model::pop_caught_exception): New.
	(region_model::apply_constraints_for_eh_dispatch_try): New decl.
	(region_model::apply_constraints_for_eh_dispatch_allowed) New decl.
	(region_model::apply_constraints_for_exception): Delete.
	(region_model::apply_constraints_for_eh_dispatch): New decl.
	(region_model::check_for_throw_inside_call): New decl.
	(region_model::m_thrown_exceptions_stack): New field.
	(region_model::m_caught_exceptions_stack): New field.
	* supergraph.cc: Include "except.h" and "analyzer/region-model.h".
	(supergraph::add_cfg_edge): Special-case eh_dispatch edges.
	(superedge::get_description): Use default_tree_printer.
	(get_catch): New.
	(eh_dispatch_cfg_superedge::make): New.
	(eh_dispatch_cfg_superedge::eh_dispatch_cfg_superedge): New.
	(eh_dispatch_cfg_superedge::get_eh_status): New.
	(eh_dispatch_try_cfg_superedge::dump_label_to_pp): New.
	(eh_dispatch_try_cfg_superedge::apply_constraints): New.
	(eh_dispatch_allowed_cfg_superedge::eh_dispatch_allowed_cfg_superedge):
	New.
	(eh_dispatch_allowed_cfg_superedge::dump_label_to_pp): New.
	(eh_dispatch_allowed_cfg_superedge::apply_constraints): New.
	* supergraph.h: Include "except.h".
	(superedge::dyn_cast_eh_dispatch_cfg_superedge): New vfunc.
	(superedge::dyn_cast_eh_dispatch_try_cfg_superedge): New vfunc.
	(superedge::dyn_cast_eh_dispatch_allowed_cfg_superedge): New
	vfunc.
	(class eh_dispatch_cfg_superedge): New.
	(is_a_helper <const eh_dispatch_cfg_superedge *>::test): New.
	(class eh_dispatch_try_cfg_superedge): New.
	(is_a_helper <const eh_dispatch_try_cfg_superedge *>::test): New.
	(class eh_dispatch_allowed_cfg_superedge): New.
	(is_a_helper <const eh_dispatch_allowed_cfg_superedge *>::test):
	New.
	* svalue.cc (svalue::maybe_get_type_from_typeinfo): New.
	* svalue.h (svalue::maybe_get_type_from_typeinfo): New decl.

gcc/ChangeLog:
	PR analyzer/97111
	* doc/invoke.texi: Add -Wanalyzer-throw-of-unexpected-type.
	* gimple.h (gimple_call_nothrow_p): Make arg const.

gcc/testsuite/ChangeLog:
	PR analyzer/97111
	* c-c++-common/analyzer/analyzer-verbosity-2a.c: Add
	-fno-exceptions.
	* c-c++-common/analyzer/analyzer-verbosity-3a.c: Likewise.
	* c-c++-common/analyzer/attr-const-2.c: Add
	__attribute__((nothrow)).
	* c-c++-common/analyzer/attr-malloc-4.c: Likewise.
	* c-c++-common/analyzer/attr-malloc-5.c: Likewise.
	* c-c++-common/analyzer/attr-malloc-6.c: Add -fno-exceptions.
	* c-c++-common/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c:
	Likewise.
	* c-c++-common/analyzer/attr-malloc-exception.c: New test.
	* c-c++-common/analyzer/call-summaries-pr107158-2.c: Add
	-fno-exceptions.
	* c-c++-common/analyzer/call-summaries-pr107158.c: Likewise.
	* c-c++-common/analyzer/capacity-2.c: Likewise.
	* c-c++-common/analyzer/coreutils-sum-pr108666.c: Likewise.
	* c-c++-common/analyzer/data-model-22.c: Likewise.
	* c-c++-common/analyzer/data-model-5d.c: Likewise.
	* c-c++-common/analyzer/deref-before-check-pr108455-git-pack-revindex.c:
	Likewise.
	* c-c++-common/analyzer/deref-before-check-pr108475-haproxy-tcpcheck.c:
	Likewise.
	* c-c++-common/analyzer/edges-2.c: Likewise.
	* c-c++-common/analyzer/fd-2.c: Likewise.
	* c-c++-common/analyzer/fd-3.c: Likewise.
	* c-c++-common/analyzer/fd-meaning.c: Likewise.
	* c-c++-common/analyzer/file-1.c: Likewise.
	* c-c++-common/analyzer/file-3.c: Likewise.
	* c-c++-common/analyzer/file-meaning-1.c: Likewise.
	* c-c++-common/analyzer/infinite-recursion.c: Likewise.
	* c-c++-common/analyzer/leak-3.c: Likewise.
	* c-c++-common/analyzer/malloc-dedupe-1.c: Likewise.
	* c-c++-common/analyzer/malloc-in-loop.c: Likewise.
	* c-c++-common/analyzer/malloc-many-paths-3.c: Likewise.
	* c-c++-common/analyzer/malloc-paths-5.c: Likewise.
	* c-c++-common/analyzer/malloc-paths-7.c: Likewise.
	* c-c++-common/analyzer/malloc-paths-8.c: Likewise.
	* c-c++-common/analyzer/malloc-vs-local-1a.c: Likewise.
	* c-c++-common/analyzer/malloc-vs-local-2.c: Likewise.
	* c-c++-common/analyzer/malloc-vs-local-3.c: Likewise.
	* c-c++-common/analyzer/paths-7.c: Likewise.
	* c-c++-common/analyzer/pr110830.c: Likewise.
	* c-c++-common/analyzer/pr93032-mztools-simplified.c: Likewise.
	* c-c++-common/analyzer/pr93355-localealias-feasibility-3.c:
	Likewise.
	* c-c++-common/analyzer/pr93355-localealias-simplified.c:
	Likewise.
	* c-c++-common/analyzer/pr96650-1-trans.c: Likewise.
	* c-c++-common/analyzer/pr97072.c: Add __attribute__((nothrow)).
	* c-c++-common/analyzer/pr98575-1.c: Likewise.
	* c-c++-common/analyzer/pr99716-1.c: Add -fno-exceptions.
	* c-c++-common/analyzer/pr99716-2.c: Likewise.
	* c-c++-common/analyzer/pr99716-3.c: Likewise.
	* c-c++-common/analyzer/pragma-2.c: Likewise.
	* c-c++-common/analyzer/rhbz1878600.c: Likewise.
	* c-c++-common/analyzer/strndup-1.c: Likewise.
	* c-c++-common/analyzer/write-to-string-literal-4-disabled.c:
	Likewise.
	* c-c++-common/analyzer/write-to-string-literal-4.c: Likewise.
	* c-c++-common/analyzer/write-to-string-literal-5.c: Likewise.
	* c-c++-common/analyzer/zlib-5.c: Likewise.
	* g++.dg/analyzer/exception-could-throw-1.C: New test.
	* g++.dg/analyzer/exception-could-throw-2.C: New test.
	* g++.dg/analyzer/exception-dynamic-spec.C: New test.
	* g++.dg/analyzer/exception-leak-1.C: New test.
	* g++.dg/analyzer/exception-leak-2.C: New test.
	* g++.dg/analyzer/exception-leak-3.C: New test.
	* g++.dg/analyzer/exception-leak-4.C: New test.
	* g++.dg/analyzer/exception-leak-5.C: New test.
	* g++.dg/analyzer/exception-leak-6.C: New test.
	* g++.dg/analyzer/exception-nothrow.C: New test.
	* g++.dg/analyzer/exception-path-1.C: New test.
	* g++.dg/analyzer/exception-path-catch-all-1.C: New test.
	* g++.dg/analyzer/exception-path-catch-all-2.C: New test.
	* g++.dg/analyzer/exception-path-unwind-multiple-2.C: New test.
	* g++.dg/analyzer/exception-path-unwind-multiple.C: New test.
	* g++.dg/analyzer/exception-path-unwind-single.C: New test.
	* g++.dg/analyzer/exception-path-with-cleanups.C: New test.
	* g++.dg/analyzer/exception-rethrow-1.C: New test.
	* g++.dg/analyzer/exception-rethrow-2.C: New test.
	* g++.dg/analyzer/exception-stack-1.C: New test.
	* g++.dg/analyzer/exception-stack-2.C: New test.
	* g++.dg/analyzer/exception-subclass-1.C: New test.
	* g++.dg/analyzer/exception-subclass-2.C: New test.
	* g++.dg/analyzer/exception-value-1.C: New test.
	* g++.dg/analyzer/exception-value-2.C: New test.
	* g++.dg/analyzer/fno-exception.C: New test.
	* g++.dg/analyzer/pr94028.C: Drop xfail.
	* g++.dg/analyzer/std-unexpected.C: New test.
	* g++.dg/coroutines/pr105287.C: Drop dg-excess-errors.

Signed-off-by: David Malcolm <[email protected]>
gcc/analyzer/ChangeLog:
	PR analyzer/109366
	* region-model-manager.cc
	(region_model_manager::maybe_fold_sub_svalue): Sub-values of zero
	constants are zero.

gcc/testsuite/ChangeLog:
	PR analyzer/109366
	* g++.dg/analyzer/unique_ptr-1.C: New test.
	* g++.dg/analyzer/unique_ptr-2.C: New test.

Signed-off-by: David Malcolm <[email protected]>
The analyzer was issuing false warnings about uninitialized variables
in C++ in places where NRVO was marking DECL_RESULT with
DECL_BY_REFERENCE.

Fixed thusly.

gcc/analyzer/ChangeLog:
	PR analyzer/111536
	* engine.cc (maybe_update_for_edge): Update for new call_stmt
	param to region_model::push_frame.
	* program-state.cc (program_state::push_frame): Likewise.
	* region-model.cc (region_model::update_for_gcall): Likewise.
	(region_model::push_frame): Add "call_stmt" param.
	Handle DECL_RESULT with DECL_BY_REFERENCE set on it by stashing
	the region of the lhs of the call_stmt in the caller frame,
	and writing a reference to it within the "result" in the callee
	frame.
	(region_model::pop_frame): Don't write back to the LHS for
	DECL_BY_REFERENCE results.
	(selftest::test_stack_frames): Update for new call_stmt param to
	region_model::push_frame.
	(selftest::test_get_representative_path_var): Likewise.
	(selftest::test_state_merging): Likewise.
	(selftest::test_alloca): Likewise.
	* region-model.h (region_model::push_frame): Add "call_stmt"
	param.
	* region.cc: Include "tree-ssa.h".
	(region::can_have_initial_svalue_p): Use ssa_defined_default_def_p
	for ssa names, rather than special-casing it for just parameters.
	This should now also cover DECL_RESULT with DECL_BY_REFERENCE and
	hard registers.
	* sm-signal.cc (update_model_for_signal_handler): Update for new
	call_stmt param to region_model::push_frame.
	* state-purge.cc (state_purge_per_decl::process_worklists):
	Likewise.

gcc/testsuite/ChangeLog:
	PR analyzer/111536
	* c-c++-common/analyzer/hard-reg-1.c: New test.
	* g++.dg/analyzer/nrvo-1.C: New test.
	* g++.dg/analyzer/nrvo-2.C: New test.
	* g++.dg/analyzer/nrvo-pr111536-1.C: New test.
	* g++.dg/analyzer/nrvo-pr111536-1b.C: New test.
	* g++.dg/analyzer/nrvo-pr111536-2.C: New test.
	* g++.dg/analyzer/nrvo-pr111536-2b.C: New test.

Signed-off-by: David Malcolm <[email protected]>
…ersions

Since the conversions are under the same constraints, centralize the
test in one file instead of two, testing both smart pointer classes, to
ease future maintenance. This is used right away: more tests are added.
Amends r15-8048-gdf0e6509bf7442.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/shared_ptr/requirements/1.cc: Test both
	shared_ptr and weak_ptr.
	Add more tests.
	* testsuite/20_util/weak_ptr/requirements/1.cc: Removed as
	superseded by the other test.

Signed-off-by: Giuseppe D'Angelo <[email protected]>
Since the tune if only for GLC(sapphirerapids and alderlake-P).

gcc/ChangeLog:

	* config/i386/x86-tune.def (X86_TUNE_DEST_FALSE_DEP_FOR_GLC):
	Remove other processor except for GLC since this one is only
	for GLC.
When passing 0xff as an unsigned char function argument with the C frontend
promotion, expand_normal used to get

<integer_cst 0x7fffe6aa23a8 type <integer_type 0x7fffe98225e8 int> constant 255>

and returned the rtx value using the sign-extended representation:

(const_int 255 [0xff])

But after

commit a670ebd
Author: H.J. Lu <[email protected]>
Date:   Thu Nov 21 07:54:35 2024 +0800

    Drop targetm.promote_prototypes from C, C++ and Ada frontends

expand_normal now gets

<integer_cst 0x7fffe9824018 type <integer_type 0x7fffe9822348 unsigned char > constant 255>

and returns

     (const_int -1 [0xffffffffffffffff])

which doesn't work with the predicates nor the instruction templates which
expect the unsigned expanded value.  Extract the unsigned char and short
integer constants to return

(const_int 255 [0xff])

so that the expanded value is always unsigned, without the C frontend
promotion.

	PR target/117547
	* config/i386/i386-expand.cc (ix86_expand_unsigned_small_int_cst_argument):
	New function.
	(ix86_expand_args_builtin): Call
	ix86_expand_unsigned_small_int_cst_argument to expand the argument
	before calling fixup_modeless_constant.
	(ix86_expand_round_builtin): Likewise.
	(ix86_expand_special_args_builtin): Likewise.
	(ix86_expand_builtin): Likewise.

Signed-off-by: H.J. Lu <[email protected]>
For all different modes of all 0s/1s vectors, we can use the single widest
all 0s/1s vector register for all 0s/1s vector uses in the whole function.
Add a pass to generate a single widest all 0s/1s vector set instruction at
entry of the nearest common dominator for basic blocks with all 0s/1s
vector uses.  On Linux/x86-64, in cc1plus, this patch reduces the number
of vector xor instructions from 4803 to 4714 and pcmpeq instructions from
144 to 142.

NB: PR target/92080 and PR target/117839 aren't same.  PR target/117839
is for vectors of all 0s and all 1s with different sizes and different
components.  PR target/92080 is for broadcast of the same component to
different vector sizes.  This patch covers only all 0s and all 1s cases
of PR target/92080.

gcc/

	PR target/92080
	PR target/117839
	* config/i386/i386-features.cc (ix86_place_single_vector_set):
	New function.
	(remove_partial_avx_dependency): Use it.
	(ix86_get_vector_load_mode): New function.
	(replace_vector_const): Likewise.
	(remove_redundant_vector_load): Likewise.
	(pass_data_remove_redundant_vector_load): Likewise.
	(pass_remove_redundant_vector_load): Likewise.
	(make_pass_remove_redundant_vector_load): Likewise.
	* config/i386/i386-passes.def: Add
	pass_remove_redundant_vector_load after
	pass_remove_partial_avx_dependency.
	* config/i386/i386-protos.h
	(make_pass_remove_redundant_vector_load): New.
	* config/i386/i386.cc (ix86_modes_tieable_p): Return true for
	narrower non-scalar-integer modes in SSE registers.

gcc/testsuite/

	PR target/92080
	PR target/117839
	* gcc.target/i386/pr117839-1a.c: New test.
	* gcc.target/i386/pr117839-1b.c: Likewise.
	* gcc.target/i386/pr117839-2.c: Likewise.
	* gcc.target/i386/pr92080-1.c: Likewise.
	* gcc.target/i386/pr92080-2.c: Likewise.
	* gcc.target/i386/pr92080-3.c: Likewise.

Signed-off-by: H.J. Lu <[email protected]>
Skip sub-RTXes of the memory operand if stack access register is
not mentioned in the operand.

gcc/ChangeLog:

	* config/i386/i386.cc (ix86_update_stack_alignment): Skip sub-RTXes
	of the memory operand if stack access register is not mentioned in
	the operand.
The following rewords the documentation for -Og which over-promises
the ability to debug the generated code.  While -Og enables
var-tracking and thus improves debugging in some areas the experience
is usually worse than -O0 for standard C code.

	PR debug/78685
	* doc/invoke.texi (-Og): Reword.
…gle_succ.

For an empty BB with all debug_stmt, it will be ignored by
afdo_set_bb_count, but it can be set with count of single successors
PHIs which edge from the BB.

gcc/ChangeLog:

	PR gcov-profile/118581
	* auto-profile.cc (autofdo_source_profile::get_count_info):
	Overload the function with parameter gimple location instead
	of stmt.
	(afdo_set_bb_count): For !has_annotated BB, Check single
	successors PHIs corresponding to the block and use those
	count.
Since TARGET_PROMOTE_FUNCTION_RETURN is no longer used, remove its
reference from target.def.

	PR target/119985
	* target.def: Remove TARGET_PROMOTE_FUNCTION_RETURN reference.
	* doc/tm.texi: Regenerated.

Signed-off-by: H.J. Lu <[email protected]>
…657]

MOVS instructions allow segment override of their source operand, e.g.:

	rep movsq %gs:(%rsi), (%rdi)

where %rsi is the address of the source location (with %gs segment override)
and %rdi is the address of the destination location.

The testcase improves from (-O2 -mno-sse -mtune=generic):

	xorl	%eax, %eax
.L2:
	movl	%eax, %edx
	addl	$8, %eax
	movq	%gs:m(%rdx), %rcx
	movq	%rcx, (%rdi,%rdx)
	cmpl	$240, %eax
	jb	.L2
	ret

to:
	movl	$m, %esi
	movl	$30, %ecx
	rep movsq %gs:(%rsi), (%rdi)
	ret

	PR target/111657

gcc/ChangeLog:

	* config/i386/i386-expand.cc (alg_usable_p): Remove have_as bool
	argument and add dst_as and src_as address space arguments.  Reject
	libcall algorithm with dst_as and src_as in the non-default address
	spaces.  Reject rep_prefix_{1,4,8}_byte algorithms with dst_as in
	the non-default address space.
	(decide_alg): Remove have_as bool argument and add dst_as and src_as
	address space arguments.  Update calls to alg_usable_p.
	(ix86_expand_set_or_cpymem): Update call to decide_alg.
	* config/i386/i386.md (strmov): Do not fail if operand[3] (source)
	is in the non-default address space.  Expand with gen_strmov_singleop
	only when operand[1] (destination) is in the default address space.
	(*strmovdi_rex_1): Determine memory operands from insn pattern.
	Allow only when destination is in the default address space.
	Rewrite asm template to use explicit operands.
	(*strmovsi_1): Ditto.
	(*strmovhi_1): DItto.
	(*strmovqi_1): Ditto.
	(*rep_movdi_rex64): Ditto.
	(*rep_movsi): Ditto.
	(*rep_movqi): Ditto.
	(*strsetdi_rex_1): Determine memory operands from insn pattern.
	Allow only when destination is in the default address space.
	(*strsetsi_1): Ditto.
	(*strsethi_1): Ditto.
	(*strsetqi_1): Ditto.
	(*rep_stosdi_rex64): Ditto.
	(*rep_stossi): Ditto.
	(*rep_stosqi): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr111657-1.c: New test.
…nation

I made a last-minute change to Nina's r10-200-gf4e678ef74b272
implementation of P1165R1 (consistent allocator propagation for
operator+ on strings), so that the rvalue+rvalue case assumes that COW
strings do not support stateful allocators. I don't think that was true
when the change went in, and isn't true now. COW strings don't support
allocator propagation on assignment and swap, but they do support
non-equal stateful allocators, which are correctly propagated on move
construction.

This removes the preprocessor conditional in the rvalue+rvalue overload
so that COW strings are handled equivalently. Also use constexpr-if
unconditionally, disabling diagnostics with pragmas.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (operator+(string&&, string&&)):
	Do not assume that COW strings have equal allocators. Use
	constexpr-if unconditionally.
	* testsuite/21_strings/basic_string/allocator/char/operator_plus.cc:
	Remove cxx11_abi effective-target check.
	* testsuite/21_strings/basic_string/allocator/wchar_t/operator_plus.cc:
	Likewise.

Reviewed-by: Tomasz Kamiński <[email protected]>
Simplify std::vector's use of std::__relocate_a by using 'if constexpr'
even in C++11 and C++14, with diagnostic pragmas to disable warnings.
This allows us to call std::__relocate_a directly, instead of via
_S_relocate and tag distpatching.

Preserve _S_relocate so that explicit instantiations still get it, but
make it a no-op when _S_use_relocate() is false, so that we don't
instantiate __relocate_a if it isn't needed.

libstdc++-v3/ChangeLog:

	* include/bits/stl_vector.h (_S_do_relocate): Remove.
	(_S_relocate): Remove tag dispatching path.
	* include/bits/vector.tcc (reserve, _M_realloc_insert)
	(_M_realloc_append, _M_default_append): Add diagnostic pragmas
	and use 'if constexpr' in C++11 and C++14. Call
	std::__relocate_a directly instead of _S_relocate.

Reviewed-by: Tomasz Kamiński <[email protected]>
This allows removing the _Target_handler class template, because it's no
longer needed to prevent instantiating invalid specializations of
_Function_handler.

libstdc++-v3/ChangeLog:

	* include/bits/std_function.h (_Target_handler): Remove.
	(function::target): Use constexpr-if for C++11 and
	C++14, with diagnostic pragmas to suppress warnings.

Reviewed-by: Tomasz Kamiński <[email protected]>
Replace remaining uses of _GLIBCXX17_CONSTEXPR for constexpr-if, so that
we always use constexpr-if in C++11 and C++14. Diagnostic pragmas are
used to suppress diagnostics.

libstdc++-v3/ChangeLog:

	* include/bits/char_traits.h (char_traits::assign): Use
	constexpr-if unconditionally for C++11 and C++14.
	* include/bits/locale_conv.h (__do_str_codecvt): Likewise.
	* include/bits/ostream.h (basic_ostream::_S_cast_flt): Likewise.
	* include/bits/random.tcc (shuffle_order_engine::operator())
	(seed_seq::seed_seq(Iter, Iter)): Likewise.
	* include/bits/shared_ptr_base.h (_Sp_counted_base::_M_release):
	Likewise.
	* include/bits/stl_tree.h (_Rb_tree::_M_move_data): Likewise.
	* include/bits/uniform_int_dist.h
	(uniform_int_distribution::operator()): Likewise.
	* include/bits/valarray_array.h (__valarray_default_construct)
	(__valarray_fill_construct, __valarray_copy_construct)
	(__valarray_copy_construct, __valarray_destroy_elements):
	Likewise.
	* include/experimental/numeric (lcm): Likewise.
	* include/std/bit (__rotl, __rotr, __countl_zero, __countr_zero)
	(__popcount, __bit_ceil) Likewise.:
	* include/std/bitset (operator>>): Likewise.
	* include/std/charconv (__to_chars_8, __to_chars_i)
	(__from_chars_alnum_to_val, from_chars): Likewise.
	* include/tr2/dynamic_bitset (__dynamic_bitset_base): Likewise.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line number.

Reviewed-by: Tomasz Kamiński <[email protected]>
The following makes PRE handle &ptr->field the same as VN by
treating it as a POINTER_PLUS_EXPR when possible and thus as
'nary'.  To facilitate this the patch splits out vn_pp_nary_for_addr
and adds const overloads for vec::last.  The patch also avoids
handling an effective zero offset as POINTER_PLUS_EXPR.

	PR tree-optimization/119997
	* vec.h (vec<T, A, vl_embed>::last): Provide const overload.
	(vec<T, va_heap, vl_ptr>::last): Likewise.
	* tree-ssa-sccvn.h (vn_pp_nary_for_addr): Declare.
	* tree-ssa-sccvn.cc (vn_pp_nary_for_addr): Split out from ...
	(vn_reference_lookup): ... here.
	(vn_reference_insert): ... and duplicate here.  Do not handle
	zero offset as POINTER_PLUS_EXPR.
	* tree-ssa-pre.cc (compute_avail): Implement
	ADDR_EXPR-as-POINTER_PLUS_EXPR special casing.

	* gcc.dg/tree-ssa/ssa-pre-35.c: New testcase.
These std::erase_if overloads were wrongly implemented as hidden
friends, visible only via ADL, so erase_if(x) would work but not
std::erase_if(x).

	PR libstdc++/119427

libstdc++-v3/ChangeLog:

	* include/std/flat_map (_Flat_map_impl::erase_if): Replace
	this hidden friend with ...
	(_Flat_map_impl::_M_erase_if): ... this member function.
	(flat_map): Export _Flat_map_impl::_M_erase_if.
	(erase_if(flat_map)): Define.
	(flat_multimap): Export _Flat_map_impl::_M_erase_if.
	(erase_if(flat_multimap)): Define.
	* include/std/flat_set (_Flat_set_impl::erase_if): Replace
	with ...
	(_Flat_set_impl::_M_erase_if): ... this member function.
	(flat_set): Export _Flat_set_impl::_M_erase_if.
	(erase_if(flat_set)): Define.
	(flat_multiset): Export _Flat_set_impl::_M_erase_if.
	(erase_if(flat_multiset)): Define.
	* testsuite/23_containers/flat_map/1.cc (test07): New test.
	* testsuite/23_containers/flat_multimap/1.cc (test07): New test.
	* testsuite/23_containers/flat_multiset/1.cc (test09): New test.
	* testsuite/23_containers/flat_set/1.cc (test09): New test.

Reviewed-by: Jonathan Wakely <[email protected]>
SIBCALL_REGS/JALR_REGS are also subset of GR_REGS and need to
be taken into acount in riscv_register_move_cost, otherwise it
will get a incorrect cost.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_register_move_cost): Use
	reg_class_subset_p to check the reg class.
Previously, calling erase(key) on both std::map and std::set
would execute that same code that std::multi{map,set} would.
However, doing that is unnecessary because std::{map,set}
guarantee that all elements are unique.

It is reasonable to expect that erase(key) is equivalent
or better than:

  auto it = m.find(key);
  if (it != m.end())
    m.erase(it);

However, this was not the case. Fix that by adding a new
function _Rb_tree<>::_M_erase_unique() that is essentially
equivalent to the above snippet, and use this from both
std::map and std::set.

libstdc++-v3/ChangeLog:

	PR libstdc++/112934
	* include/bits/stl_map.h (map::erase): Use _M_erase_unique.
	* include/bits/stl_set.h (set::erase): Likewise.
	* include/bits/stl_tree.h (_Rb_tree::_M_erase_unique): Add.
…[PR111657]

0x67 prefix is applied before segment register. That is in

	rep movsq %gs:(%esi), (%edi)

the address is %gs + %esi. In case Pmode != word_mode (x32 with a default
-maddress-mode=short) instructions should not allow segment override prefixes.

Also, remove explicit addr32 prefix from asm templates because address
mode can be determined from explicit instruction operands. Also note that
Pmode != word_mode only with TARGET_64BIT, so the check in ix86_print_operand
is not needed.

	PR target/111657

gcc/ChangeLog:

	* config/i386/i386-expand.cc (alg_usable_p): For Pmode != word_mode
	reject rep_prefix_{1,4,8}_byte algorithms with src_as in the
	non-default address space.
	* config/i386/i386-protos.h (ix86_check_movs): New prototype.
	* config/i386/i386.cc (ix86_check_movs): New function.
	(ix86_print_operand) [case '^']: Remove excess check for TARGET_64BIT.
	* config/i386/i386.md (strmov): For Pmode != word_mode expand with
	gen_strmov_single only when operands[3] (source) is in the default
	address space.
	(*strmovdi_rex_1) Use ix86_check_movs.  Remove %^ from asm template.
	(*strmovsi_1): Ditto.
	(*strmovhi_1): DItto.
	(*strmovqi_1): Ditto.
	(*rep_movdi_rex64): Ditto.
	(*rep_movsi): Ditto.
	(*rep_movqi): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr111657-1.c: Check that segment override is not
	generated for "rep movsq" for x32 target.
@powerboat9 powerboat9 changed the title [April 24th 2025] Merge changes from upstream [April 29th 2025] Merge changes from upstream Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.