This function is no longer used since r12-6691 and can be removed.
libstdc++-v3/ChangeLog:
* include/bits/stl_pair.h (_PCC::_DeprConsPair): Remove unused
function.
This fixes an on AIX.
The lock function currently just spins, which should be changed to use
back-off, and maybe then _M_val.wait(__current) when supported.
libstdc++-v3/ChangeLog:
PR libstdc++/104101
* include/bits/shared_ptr_atomic.h (_Sp_atomic::_Atomic_count::lock):
Only use __thread_relax if __cpp_lib_atomic_wait is defined.
It was pointed out to me by Jakub, that the comment in front of
the new code which handles warning/error attribute was not really
understandable. This fixes the comment to be understandable; I
don't know why I wrote the original comment that way even.
Committed as obvious after a quick build.
gcc/ChangeLog:
* ipa-split.cc (visit_bb): Fix comment before the
warning/error attribute checking code.
The following testcase is miscompiled. We see the constructor is immediate,
in build_over_call we trigger:
if (obj_arg && is_dummy_object (obj_arg))
{
call = build_cplus_new (DECL_CONTEXT (fndecl), call, complain);
obj_arg = NULL_TREE;
}
which makes call a TARGET_EXPR with the dtor in TARGET_EXPR_CLEANUP,
but then call cxx_constant_value on it. In cxx_eval_outermost_constant_expr
it triggers the:
else if (TREE_CODE (t) != CONSTRUCTOR)
{
r = get_target_expr_sfinae (r, tf_warning_or_error | tf_no_cleanup);
TREE_CONSTANT (r) = true;
}
which wraps the CONSTRUCTOR r into a new TARGET_EXPR, but one without
dtors (I think we need e.g. the TREE_CONSTANT for the callers),
and finally build_over_call uses that.
The following patch fixes that by using get_target_expr instead
of get_target_expr_sfinae + TREE_CONSTANT (r) = true if t is
a TARGET_EXPR with non-NULL TARGET_EXPR_CLEANUP.
2022-01-19 Jakub Jelinek <jakub@redhat.com>
PR c++/104055
* constexpr.cc (cxx_eval_outermost_constant_expr): If t is a
TARGET_EXPR with TARGET_EXPR_CLEANUP, use get_target_expr rather
than get_target_expr_sfinae with tf_no_cleanup, and don't set
TREE_CONSTANT.
* g++.dg/cpp2a/consteval27.C: New test.
Debug information was getting confused because input_location was different
depending on whether we had looked ahead to see if the next tokens look like
a template argument list.
I tried resetting input_location in cp_lexer_rollback_tokens itself, but
that caused regressions, so let's just do it here for now.
PR c++/104025
gcc/cp/ChangeLog:
* parser.cc (saved_token_sentinel::rollback): Call
cp_lexer_set_source_position.
(~saved_token_sentinel): Call rollback.
gcc/testsuite/ChangeLog:
* g++.dg/warn/pr104025.C: New test.
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
BPF CO-RE relocations contain offsets to strings buffered in the BTF
string table. These BTF-specific strings are stored in memory in the
CTF auxilliary strtab, which at output time is concatenated onto the end
of the standard strtab.
Previously, these string offsets were computed at the time the
relocations were created. But strings could be added to the standard
strtab after this point, causing the offsets to no longer be correct.
Compute the offsets just before output instead, when they are sure to no
longer change.
gcc/ChangeLog:
* config/bpf/coreout.cc (bpf_core_reloc_add): Do not account
for base strtab offset yet as it may change.
(output_asm_btfext_core_reloc): Do so here instead.
(output_btfext_core_sections): Likewise.
The CO-RE relocation record size should be written only once in the
.BTF.ext section, not once for each section with relocations.
gcc/ChangeLog:
* config/bpf/coreout.cc (output_btfext_header): Account for
4-byte record size in core_relo_len.
(output_btfext_core_sections): Only write record size once.
* config/bpf/coreout.h (btf_ext_section_header): Delete unused
member.
gcc/testsuite/ChangeLog:
* gcc.target/bpf/core-section-1.c: Adjust expected record size
occurrences.
gcc/analyzer/ChangeLog:
PR analyzer/104089
* region-model-manager.cc
(region_model_manager::get_or_create_constant_svalue): Assert that
we have a CONSTANT_CLASS_P.
(region_model_manager::maybe_fold_unaryop): Only fold a constant
when fold_unary's result is a constant or a cast of a constant.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/pr104089.c: New test.
PR analyzer/104089
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/ChangeLog:
PR analyzer/104062
* region-model-manager.cc
(region_model_manager::maybe_fold_sub_svalue): Avoid casting to
NULL type when folding access to repeated svalue.
gcc/testsuite/ChangeLog:
PR analyzer/104062
* gcc.dg/analyzer/pr104062.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
The new deleted constructors added by P2166R1 are a breaking change,
making previously valid code ill-formed in C++23. As a result, they
should only be defined for C++23 and not for C++11 and up.
libstdc++-v3/ChangeLog:
PR libstdc++/104099
* include/bits/basic_string.h (basic_string(nullptr_t)): Only
define for C++23.
(operator=(nullptr_t)): Likewise.
* include/bits/cow_string.h: Likewise.
* include/std/string_view (basic_string_view(nullptr_t)):
Likewise.
* testsuite/21_strings/basic_string/cons/char/nullptr.cc: Adjust
expected error. Add examples that become ill-formed in C++23.
* testsuite/21_strings/basic_string_view/cons/char/nonnull.cc:
Adjust expected errors.
* testsuite/21_strings/basic_string_view/cons/wchar_t/nonnull.cc:
Likewise.
We're incorrectly rejecting the below testcase during template argument
coercion because invalid_nontype_parm_type_p returns true for
DEPENDENT_OPERATOR_TYPE in C++17 mode.
This patch fixes this by partially rewriting invalid_nontype_parm_type_p
in terms of WILDCARD_TYPE_P, for which DEPENDENT_OPERATOR_TYPE is true,
so that the predicate handles wildcard types consistently.
PR c++/104074
gcc/cp/ChangeLog:
* pt.cc (invalid_nontype_parm_type_p): Use WILDCARD_TYPE_P so
that we return false for DEPENDENT_OPERATOR_TYPE too.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/nontype-auto20.C: New test.
Avoid undefined arithmetic involving a pointer to a heap allocation that
has been freed and move a problematic calculation ahead of the following
call to `free' in `riscv_subset_list::parse_multiletter_ext', removing a
compilation error:
.../gcc/common/config/riscv/riscv-common.cc: In member function 'const char* riscv_subset_list::parse_multiletter_ext(const char*, const char*, const char*)':
.../gcc/common/config/riscv/riscv-common.cc:905:27: error: pointer 'subset' used after 'void free(void*)' [-Werror=use-after-free]
905 | p += end_of_version - subset;
| ~~~~~~~~~~~~~~~^~~~~~~~
.../gcc/common/config/riscv/riscv-common.cc:904:12: note: call to 'void free(void*)' here
904 | free (subset);
| ~~~~~^~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:2428: riscv-common.o] Error 1
and a build regression from commit 671a283636 ("Add -Wuse-after-free
[PR80532].").
gcc/
* common/config/riscv/riscv-common.cc
(riscv_subset_list::parse_multiletter_ext): Move pointer
arithmetic ahead of `free'.
For this testcase, the cleanup that is supposed to happen if initialization
throws was wrongly being run on the normal control path as well. This turns
out to be because the EH-only handling in gimple_push_cleanup didn't apply
to conditional cleanups such as we have for nothrow new, since we check
whether the result is non-null before proceeding with the initialization.
PR c++/104007
gcc/ChangeLog:
* gimplify.cc (gimple_push_cleanup): Handle eh_only in conditional
context.
gcc/testsuite/ChangeLog:
* g++.dg/eh/new2.C: New test.
stack_limit_rtx was being initialized before init_reg_modes_target (),
resulting in the REG expression being created incorrectly and an ICE
later in compilation.
2022-01-18 Sandra Loosemore <sandra@codesourcery.com>
PR middle-end/103163
gcc/
* emit-rtl.cc (init_emit_regs): Initialize stack_limit_rtx here...
(init_emit_once): ...not here.
We should not assume that std::iter_value_t etc. are defined
unconditionally for C++20 mode.
libstdc++-v3/ChangeLog:
PR libstdc++/104098
* include/bits/stl_iterator.h (reverse_iterator): Check
__cpp_lib_concepts instead of __cplusplus.
The deprecated non-standard std::pair constructors that allow
constructing std::pair<move-only-type, pointer-type> from an rvalue and
a literal zero where not sufficiently constrained. They were viable when
constructing std::pair<copyable-type, pointer-type>, and that case
should work fine using the standard constructors.
Replace the constraints on the non-standard constructors so they are
only viable in cases that should actually be ill-formed according to the
standard.
Also rename __null_ptr_constant to __zero_as_null_pointer_constant so it
matches the name of the -Wzero-as-null-pointer-constant warning. Also
make the text of the deprecated warning describe the problem in more
detail.
libstdc++-v3/ChangeLog:
PR libstdc++/101124
* include/bits/stl_pair.h (pair): Adjust constraints on
deprecated constructors accepting literal zero as null pointer
constant. Improve wording of deprecated attribute.
* testsuite/20_util/pair/cons/99957.cc: Check that deprecated
constructors do not cause ambiguities for copyable types.
This patch completes implementation of the C++20 proposal P0482R6 [1] by
adding declarations of std::c8rtomb() and std::mbrtoc8() in <cuchar> if
provided by the C library in <uchar.h>.
This patch addresses feedback provided in response to a previous patch
submission [2].
Autoconf changes determine if the C library declares c8rtomb and mbrtoc8
at global scope when uchar.h is included and compiled with either
-fchar8_t or -std=c++20. New _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_FCHAR8_T
and _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20 configuration macros
reflect the probe results. The <cuchar> header declares these functions
in the std namespace only if available and the _GLIBCXX_USE_CHAR8_T
configuration macro is defined (by default it is defined if the C++20
__cpp_char8_t feature test macro is defined)
Patches to glibc to implement c8rtomb and mbrtoc8 have been submitted [3].
New tests validate the presence of these declarations. The tests pass
trivially if the C library does not provide these functions. Otherwise
they ensure that the functions are declared when <cuchar> is included
and either -fchar8_t or -std=c++20 is enabled.
1]: WG21 P0482R6
"char8_t: A type for UTF-8 characters and strings (Revision 6)"
https://wg21.link/p0482r6
[2]: [PATCH] C++ P0482R6 char8_t: declare std::c8rtomb and std::mbrtoc8
if provided by the C library
https://gcc.gnu.org/pipermail/libstdc++/2021-June/052685.html
[3]: "C++20 P0482R6 and C2X N2653"
[Patch 0/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135061.html
[Patch 1/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135062.html
[Patch 2/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135063.html
[Patch 3/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135064.html
libstdc++-v3/ChangeLog:
* acinclude.m4: Define config macros if uchar.h provides
c8rtomb() and mbrtoc8().
* config.h.in: Regenerate.
* configure: Regenerate.
* include/c_compatibility/uchar.h (c8rtomb, mbrtoc8): Define.
* include/c_global/cuchar (c8rtomb, mbrtoc8): Likewise.
* include/c_std/cuchar (c8rtomb, mbrtoc8): Likewise.
* testsuite/21_strings/headers/cuchar/functions_std_cxx20.cc:
New test.
* testsuite/21_strings/headers/cuchar/functions_std_fchar8_t.cc:
New test.
This adds the C++23 <stdatomic.h> header, as proposed by P0943R6, for
compatibility with C code.
There are still some ABI differences between atomic_xxx in C and C++
std::atomic_xxx in C++, so this only provides source compatibility, not
binary compatibility.
libstdc++-v3/ChangeLog:
* include/Makefile.am: Install new header.
* include/Makefile.in: Regenerate.
* include/c_compatibility/stdatomic.h: New file.
* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc: New test.
gcc/ChangeLog:
* tree-vect-loop.cc (vect_estimate_min_profitable_iters): Pass new
argument suggested_unroll_factor.
(vect_analyze_loop_costing): Likewise.
(_loop_vec_info::_loop_vec_info): Initialize new member
suggested_unroll_factor.
(vect_determine_partial_vectors_and_peeling): Make epilogue of unrolled
main loop use partial vectors.
(vect_analyze_loop_2): Pass and use new argument
suggested_unroll_factor.
(vect_analyze_loop_1): Change to intialize local
suggested_unroll_factor and use it.
(vectorizable_reduction): Don't use single_defuse_cycle when unrolling.
* tree-vectorizer.h (_loop_vec_info::_loop_vec_info): Add new member
suggested_unroll_factor.
(vector_costs::vector_costs): Add new member m_suggested_unroll_factor.
(vector_costs::suggested_unroll_factor): New getter function.
(finish_cost): Set return argument suggested_unroll_factor.
In pathological cases, the number of transitive relations being added is
potentially quadratic. Lookups for relations in a block is linear in
nature, so simply limit the number of relations to some reasonable number.
PR tree-optimization/104038
* doc/invoke.texi (relation-block-limit): New.
* params.opt (relation-block-limit): New.
* value-relation.cc (dom_oracle::register_relation): Check for NULL
record before invoking transitive registery.
(dom_oracle::set_one_relation): Check limit before creating record.
(dom_oracle::register_transitives): Stop when no record created.
* value-relation.h (relation_chain_head::m_num_relations): New.
The following change avoids doing IPA inlining of small functions
into functions compiled with -Og - those functions will see almost no
followup scalar cleanups so that the benefit anticipated by the
inliner will not be realized and instead the late diagnostic code
will be confused by dead code that is left around.
2022-01-18 Richard Biener <rguenther@suse.de>
PR ipa/103989
* ipa-inline.cc (inline_small_functions): Do not enqueue call
edges originating in functions compiled with -Og.
* g++.dg/opt/pr103989.C: New testcase.
With -Og we are not prepared to do cleanup after IPA optimizations
and dead code exposed by those confuses late diagnostic passes.
This is a first patch removing unwanted IPA optimizations, namely
both late modref and pure-const analysis.
2022-01-18 Richard Biener <rguenther@suse.de>
PR ipa/103989
* passes.def (pass_all_optimizations_g): Remove pass_modref
and pass_local_pure_const.
This adds a missing guard for a pointer to the DSE modref query,
otherwise we can end up invoking APIs desired to only work on
pointers on non-pointers when there are mismatches between declared
and actual arguments of functions in the program.
2022-01-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/103987
* tree-ssa-dse.cc (dse_optimize_call): Properly guard modref
query with a pointer check.
* gcc.dg/torture/pr103987.c: New testcase.
In g:526e1639aa76b0a8496b0dc3a3ff2c450229544e I'd added support
for finding more consecutive MEMs. However, the check was too
eager, in that it matched MEM_REFs with the same base address
even if that base address was an arbitrary SSA name. This can
give wrong results if a MEM_REF from one loop iteration is
compared with a MEM_REF from another (e.g. after rtl unrolling).
In principle, we could still accept MEM_REFs based on the same
incoming SSA name, but there seems to be no out-of-the-box API
for doing that. Adding a new one at this stage in GCC 12 doesn't
feel like a good risk/reward trade-off.
This patch therefore restricts the MEM_EXPR comparison to base decls
only, excluding all MEM_REFs. It means we lose all the new STPs in
the PR testcase but keep the ones in the original stp_1.c testcase.
gcc/
PR target/104005
* config/aarch64/aarch64.cc (aarch64_check_consecutive_mems):
When using MEM_EXPR, require the base to be a decl.
gcc/testsuite/
PR target/104005
* gcc.target/aarch64/pr104005.c: New test.
As pointed out by pahole.
2022-01-18 Richard Biener <rguenther@suse.de>
* cgraph.h (struct cgraph_simd_clone_arg): Re-arrange fields to
avoid padding.
* function.h (struct function): Likewise.
The Linux kernel started to fail compile when the jump threader was improved
(r12-2591-g2e96b5f14e4025691). This failure was due to the IPA splitting code
decided now to split off the basic block which contained two functions,
one of those functions included the error attribute on them. This patch fixes
the problem by disallowing basic blocks from being split which contain functions
that have either the error or warning attribute on them.
The two new testcases are to make sure we still split the function for other
places if we reject the one case.
Committed as approved after Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR tree-optimization/101941
gcc/ChangeLog:
* ipa-split.cc (visit_bb): Disallow function calls where
the function has either error or warning attribute.
gcc/testsuite/ChangeLog:
* gcc.c-torture/compile/pr101941-1.c: New test.
* gcc.dg/tree-ssa/pr101941-1.c: New test.
Instead of hardcoded preprocessor conditionals with explicit target
checks, just rely on the fact that __BYTE_ORDER__ is always defined by
GCC.
libstdc++-v3/ChangeLog:
PR libstdc++/104080
* src/c++17/fast_float/LOCAL_PATCHES: Update.
* src/c++17/fast_float/fast_float.h (FASTFLOAT_IS_BIG_ENDIAN):
Define in terms of __BYTE_ORDER__.
gcc/testsuite/ChangeLog:
* gcc.src/maintainers.exp: Use
check_effective_target_python3_module for checking of unicode
module.
* lib/target-supports.exp: Add
check_effective_target_python3_module.
Since we order DRs after DR_INIT we know the difference will be
positive and thus can avoid signed overflow issues by using
unsigned arithmetic to produce the known unsigned result.
2022-01-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/104064
* tree-vect-data-refs.cc (vect_analyze_data_ref_accesses): Check
DR_INIT fits in a signed HWI, represent the difference from the
first DR in unsigned.