aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-11-08ada: Improve handling of declare expressions in deferred-freezing contextsSteve Baird1-0/+20
In some cases where a declare expression occurs in a deferred-freezing context (e.g., within the default value for a discriminant or for a formal parameter, or within the expression of an expression function), the compiler generates a bugbox. gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Do not perform expansion actions if In_Spec_Expression is true.
2022-11-08ada: Minor consistency tweaks in Sem_Ch4Eric Botcazou1-15/+24
This ensures that, during the analysis of the qualified expressions, type conversions and unchecked type conversions, the determination of the type of the node and the analysis of its expression are done in the same order. No functional changes. gcc/ada/ * sem_ch4.adb (Analyze_Qualified_Expression): Analyze the expression only after setting the type. (Analyze_Unchecked_Type_Conversion): Likewise. (Analyze_Short_Circuit): Likewise for the operands. (Analyze_Type_Conversion): Minor tweaks. (Analyze_Unchecked_Expression): Likewise.
2022-11-08ada: Remove redundant line in Analyze_Qualified_ExpressionEric Botcazou1-2/+0
The same statement is present a few lines above. gcc/ada/ * sem_ch4.adb (Analyze_Qualified_Expression): Remove redundant line.
2022-11-08ada: Preanalyze classwide contracts as spec expressionsRonan Desplanques1-2/+2
Classwide contracts are "spec expressions" as defined in the documentation in sem.ads. Before this patch, the instances of classwide contracts that are destined to class conditions merging were not preanalyzed as spec expressions. That caused preanalysis to emit spurious errors in some cases. gcc/ada/ * contracts.adb (Preanalyze_Condition): Use Preanalyze_Spec_Expression.
2022-11-08ada: Fix expansion of 'Wide_Image and 'Wide_Wide_Image on composite typesPiotr Trojanek4-7/+51
Attributes Wide_Image and Wide_Wide_Image applied to composite types are now expanded just like attribute Image. gcc/ada/ * exp_imgv.adb (Expand_Wide_Image_Attribute): Handle just like attribute Image. (Expand_Wide_Wide_Image_Attribute): Likewise. * exp_put_image.adb (Build_Image_Call): Adapt to also work for Wide and Wide_Wide attributes. * exp_put_image.ads (Build_Image_Call): Update comment. * rtsfind.ads (RE_Id): Support wide variants of Get. (RE_Unit_Table): Likewise.
2022-11-08ada: Fix inconsistent whitespace in Ada.Numerics.Generic_Complex_ArraysPiotr Trojanek2-4/+4
Cleanup only. gcc/ada/ * libgnat/a-ngcoar.ads, libgnat/a-ngcoar.adb: Remove extra spaces.
2022-11-08ada: Remove unneeded code in handling formal type defaultsPiotr Trojanek1-4/+2
Unneeded code found while experimenting with improved detection of unreferenced objects. gcc/ada/ * sem_ch12.adb (Validate_Formal_Type_Default): Remove call to Collect_Interfaces, which had no effect apart from populating a list that was not used; fix style.
2022-11-08ada: Cleanup local variable that is only set as an out parameterPiotr Trojanek2-10/+10
Minor improvements; found experimenting with improved detection of unreferenced objects. gcc/ada/ * exp_spark.adb (SPARK_Freeze_Type): Refine type of a local object. * sem_ch3.adb (Derive_Subprograms): Remove initial value for New_Subp, which is in only written as an out parameter and never read.
2022-11-08ada: Remove obsolete code in Resolve_If_ExpressionEric Botcazou1-12/+1
gcc/ada/ * sem_res.adb (Resolve_If_Expression): Remove obsolete special case.
2022-11-08ada: Reject limited objects in array and record delta aggregatesPiotr Trojanek1-0/+17
For array delta aggregates the base expression cannot be limited; for record delta aggregates the base expression can only be limited if it is a newly constructed object. gcc/ada/ * sem_aggr.adb (Resolve_Delta_Aggregate): Implement rules related to limited objects appearing as the base expression.
2022-11-08ada: Allow initialization of limited objects with delta aggregatesPiotr Trojanek1-0/+1
Objects of a limited type can be initialized with "aggregates", which is a collective term for ordinary aggregates (i.e. record aggregates and array aggregates), extension aggregates and finally for delta aggregates (introduced by Ada 2022). gcc/ada/ * sem_ch3.adb (OK_For_Limited_Init_In_05): Handle delta aggregates just like other aggregates.
2022-11-08ada: Reject record delta aggregates with limited expressionsPiotr Trojanek1-0/+10
Implement a missing check related to record delta aggregates. gcc/ada/ * sem_aggr.adb (Resolve_Delta_Record_Aggregate): Reject expressions of a limited types.
2022-11-08ada: Missing master of task causing assertion failureJavier Miranda1-1/+36
gcc/ada/ * exp_ch9.adb (Build_Master_Entity): Handle missing case: when the context of the master is a BIP function whose result type has tasks.
2022-11-08ada: Raise Tag_Error when Ada.Tags operations are called with No_TagPiotr Trojanek1-7/+15
Implement missing behavior of RM 13.9 (25.1/3): Tag_Error is raised by a call of Interface_Ancestor_Tags and Is_Descendant_At_Same_Level, if any tag passed is No_Tag. This change also fixes Descendant_Tag, which relies on Is_Descendant_At_Same_Level. The remaining operations already worked properly. gcc/ada/ * libgnat/a-tags.adb (Interface_Ancestor_Tags): Raise Tag_Error on No_Tag. (Is_Descendant_At_Same_Level): Likewise.
2022-11-08ada: Add new -gnatw_q switch to usage messageBob Duff1-0/+4
...along with -gnatw_Q. gcc/ada/ * usage.adb: Add -gnatw_q and -gnatw_Q.
2022-11-08libstdc++: Update my author blurb in the manualJonathan Wakely1-1/+4
libstdc++-v3/ChangeLog: * doc/xml/authors.xml: Update the blurb listing my doc contributions.
2022-11-08libstdc++: Remove empty <author> elements in manualJonathan Wakely3-15/+5
This fixes a spurious comma before the list of authors in the PDF version of the libstdc++ manual. Also fix the commented-out examples which should show <personblurb> not <authorblurb>. libstdc++-v3/ChangeLog: * doc/xml/authors.xml: Remove empty author element. * doc/xml/manual/spine.xml: Likewise. * doc/html/manual/index.html: Regenerate.
2022-11-08Revert "i386: Prefer remote atomic insn for atomic_fetch{add, and, or, xor}"konglin14-62/+4
This reverts commit 48fa4131e419942efc9dd762694fdc7e819de392.
2022-11-08Add m_CORE_ATOM for atom coresHaochen Jiang2-31/+41
gcc/ChangeLog: * config/i386/i386-options.cc (m_CORE_ATOM): New. * config/i386/x86-tune.def (X86_TUNE_SCHEDULE): Initial tune for CORE_ATOM. (X86_TUNE_PARTIAL_REG_DEPENDENCY): Ditto. (X86_TUNE_SSE_PARTIAL_REG_DEPENDENCY): Ditto. (X86_TUNE_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY): Ditto. (X86_TUNE_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY): Ditto. (X86_TUNE_DEST_FALSE_DEP_FOR_GLC): Ditto. (X86_TUNE_MEMORY_MISMATCH_STALL): Ditto. (X86_TUNE_USE_LEAVE): Ditto. (X86_TUNE_PUSH_MEMORY): Ditto. (X86_TUNE_USE_INCDEC): Ditto. (X86_TUNE_INTEGER_DFMODE_MOVES): Ditto. (X86_TUNE_PREFER_KNOWN_REP_MOVSB_STOSB): Ditto. (X86_TUNE_MISALIGNED_MOVE_STRING_PRO_EPILOGUES): Ditto. (X86_TUNE_USE_SAHF): Ditto. (X86_TUNE_USE_BT): Ditto. (X86_TUNE_AVOID_FALSE_DEP_FOR_BMI): Ditto. (X86_TUNE_ONE_IF_CONV_INSN): Ditto. (X86_TUNE_AVOID_MFENCE): Ditto. (X86_TUNE_USE_SIMODE_FIOP): Ditto. (X86_TUNE_EXT_80387_CONSTANTS): Ditto. (X86_TUNE_SSE_UNALIGNED_LOAD_OPTIMAL): Ditto. (X86_TUNE_SSE_UNALIGNED_STORE_OPTIMAL): Ditto. (X86_TUNE_SSE_TYPELESS_STORES): Ditto. (X86_TUNE_SSE_LOAD0_BY_PXOR): Ditto. (X86_TUNE_AVOID_4BYTE_PREFIXES): Ditto. (X86_TUNE_USE_GATHER_2PARTS): Ditto. (X86_TUNE_USE_GATHER_4PARTS): Ditto. (X86_TUNE_USE_GATHER): Ditto.
2022-11-07analyzer: start adding support for errnoDavid Malcolm10-2/+167
gcc/analyzer/ChangeLog: * region-model-impl-calls.cc (region_model::impl_call_errno_location): New. * region-model-manager.cc (region_model_manager::region_model_manager): Initialize m_thread_local_region and m_errno_region. * region-model-manager.h (region_model_manager::get_errno_region): New accessor. (region_model_manager::m_thread_local_region): New. (region_model_manager::m_errno_region): New. * region-model.cc (region_model::on_call_pre): Special-case "__errno_location". (region_model::set_errno): New. * region-model.h (impl_call_errno_location): New decl. (region_model::set_errno): New decl. * region.cc (thread_local_region::dump_to_pp): New. (errno_region::dump_to_pp): New. * region.h (enum memory_space): Add MEMSPACE_THREAD_LOCAL. (enum region_kind): Add RK_THREAD_LOCAL and RK_ERRNO. (class thread_local_region): New. (is_a_helper <const thread_local_region *>::test): New. (class errno_region): New. (is_a_helper <const errno_region *>::test): New. * store.cc (binding_cluster::escaped_p): New. (store::escaped_p): Treat errno as always having escaped. (store::replay_call_summary_cluster): Handle RK_THREAD_LOCAL and RK_ERRNO. * store.h (binding_cluster::escaped_p): Remove definition. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/errno-1.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-07analyzer: introduce succeed_or_fail_call_infoDavid Malcolm2-23/+32
This makes some followup code much cleaner. gcc/analyzer/ChangeLog: * call-info.cc (success_call_info::get_desc): Delete. (failed_call_info::get_desc): Likewise. (succeed_or_fail_call_info::get_desc): New. * call-info.h (class succeed_or_fail_call_info): New. (class success_call_info): Convert to a subclass of succeed_or_fail_call_info. (class failed_call_info): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-07analyzer: fix "when 'strchr' returns non-NULL" messageDavid Malcolm3-10/+21
Tweak analyzer handling of strchr, so that we show the when 'strchr' returns non-NULL message for that execution path. gcc/analyzer/ChangeLog: * region-model-impl-calls.cc (region_model::impl_call_strchr): Move to on_call_post. Handle both outcomes using bifurcation, rather than just the "not found" case. * region-model.cc (region_model::on_call_pre): Move BUILT_IN_STRCHR and "strchr" to... (region_model::on_call_post): ...here. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/strchr-1.c (test_literal): Detect writing to a string literal. Verify that we emit the "when '__builtin_strchr' returns non-NULL" message. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-08libstdc++: Fix syntax error in old-glibc case in floating_from_chars.cc ↵Joseph Myers1-1/+1
[PR107562] PR libstdc++/107562 * src/c++17/floating_from_chars.cc (from_chars_impl): Fix syntax error.
2022-11-07c++: implement P2468R2, the equality operator you are looking forJason Merrill12-20/+389
This paper is resolving the problem of well-formed C++17 code becoming ambiguous in C++20 due to asymmetrical operator== being compared with itself in reverse. I had previously implemented a tiebreaker such that if the two candidates were functions with the same parameter types, we would prefer the non-reversed candidate. But the committee went with a different approach: if there's an operator!= with the same parameter types as the operator==, don't consider the reversed form of the ==. So this patch implements that, and changes my old tiebreaker to give a pedwarn if it is used. I also noticed that we were giving duplicate errors for some testcases, and fixed the tourney logic to avoid that. As a result, a lot of tests of the form struct A { bool operator==(const A&); }; need to be fixed to add a const function-cv-qualifier, e.g. struct A { bool operator==(const A&) const; }; The committee thought such code ought to be fixed, so breaking it was fine. 18_support/comparisons/algorithms/fallback.cc also breaks with this patch, because of the similarly asymmetrical bool operator==(const S&, S&) { return true; } As a result, some of the asserts need to be reversed. The H test in spaceship-eq15.C is specified in the standard to be well-formed because the op!= in the inline namespace is not found by the search, but that seems wrong to me. I've implemented that behavior, but disabled it for now; if we decide that is the way we want to go, we can just remove the "0 &&" in add_candidates to enable it. Co-authored-by: Jakub Jelinek <jakub@redhat.com> gcc/cp/ChangeLog: * cp-tree.h (fns_correspond): Declare. * decl.cc (fns_correspond): New. * call.cc (add_candidates): Look for op!= matching op==. (joust): Complain about non-standard reversed tiebreaker. (tourney): Fix champ_compared_to_predecessor logic. (build_new_op): Don't complain about error_mark_node not having 'bool' type. * pt.cc (tsubst_copy_and_build): Don't try to be permissive when seen_error(). gcc/testsuite/ChangeLog: * g++.dg/cpp2a/spaceship-eq15.C: New test. * g++.dg/cpp0x/defaulted3.C: Add const. * g++.dg/cpp2a/bit-cast7.C: Add const. * g++.dg/cpp2a/spaceship-rewrite1.C: Expect error. * g++.dg/cpp2a/spaceship-rewrite5.C: Expect error. * g++.old-deja/g++.jason/byval2.C: Expect error. * g++.old-deja/g++.other/overload13.C: Add const. libstdc++-v3/ChangeLog: * testsuite/18_support/comparisons/algorithms/fallback.cc: Adjust asserts.
2022-11-07Add transitive inferred range processing.Andrew MacLeod8-14/+112
Rewalk statements at the end of a block to see if any inferred ranges affect earlier calculations and register those as inferred ranges. gcc/ PR tree-optimization/104530 * gimple-range-cache.cc (ranger_cache::register_inferred_value): New. Split from: (ranger_cache::apply_inferred_ranges): Move setting cache to separate function. * gimple-range-cache.h (register_inferred_value): New prototype. * gimple-range-infer.cc (infer_range_manager::has_range_p): New. * gimple-range-infer.h (has_range_p): New prototype. * gimple-range.cc (register_transitive_inferred_ranges): New. * gimple-range.h (register_transitive_inferred_ranges): New proto. * tree-vrp.cc (rvrp_folder::fold_stmt): Check for transitive inferred ranges at the end of the block before folding final stmt. gcc/testsuite/ * gcc.dg/pr104530.c: New.
2022-11-08Daily bump.GCC Administrator6-1/+588
2022-11-08libstdc++: Fix up libstdc++ build against glibc 2.25 or older [PR107562]Jakub Jelinek2-2/+4
On Mon, Nov 07, 2022 at 05:48:42PM +0000, Jonathan Wakely wrote: > On Mon, 7 Nov 2022 at 16:11, Joseph Myers <joseph@codesourcery.com> wrote: > > > > On Wed, 2 Nov 2022, Jakub Jelinek via Gcc-patches wrote: > > > > > APIs. So that one can build gcc against older glibc and then compile > > > user programs on newer glibc, the patch uses weak references unless > > > gcc is compiled against glibc 2.26+. strfromf128 unfortunately can't > > > > This support for older glibc doesn't actually seem to be working, on an > > older system with glibc 2.19 I'm seeing > > > > /scratch/jmyers/fsf/gcc-mainline/libstdc++-v3/src/c++17/floating_to_chars.cc:52:3: error: expected initializer before '__asm' > > 52 | __asm ("strfromf128"); > > | ^~~~~ > > > > and a series of subsequent errors. > > This seems to "fix" it (not sure if it's right though): > > #ifndef _GLIBCXX_HAVE_FLOAT128_MATH > extern "C" _Float128 __strtof128(const char*, char**) > __attribute__((__weak__)); > #endif > extern "C" _Float128 __strtof128(const char*, char**) > __asm ("strtof128"); It is, but floating_from_chars.cc has the same problem, and I think we can avoid the duplication, like this: 2022-11-08 Jakub Jelinek <jakub@redhat.com> PR libstdc++/107562 * src/c++17/floating_from_chars.cc (__strtof128): Put __asm before __attribute__. * src/c++17/floating_to_chars.cc (__strfromf128): Likewise.
2022-11-07bpf: cleanup missed refactorDavid Faust1-23/+1
Commit 068baae1864 "bpf: add preserve_field_info builtin" factored out some repeated code to a new function maybe_make_core_relo (), but missed using it in one place. Clean that up. gcc/ * config/bpf/bpf.cc (handle_attr_preserve): Use maybe_make_core_relo().
2022-11-07Improve multiplication by powers of 2 in range-ops.Aldy Hernandez2-2/+33
For unsigned numbers, multiplication by X, where X is a power of 2 is [0,0][X,+INF]. This patch causes a regression to g++.dg/pr71488.C where -Wstringop-overflow gets the same IL as before, but better ranges cause it to issue a bogus warning. I will create a PR with some notes. No discernible changes in performance. Tested on x86-64 Linux. PR tree-optimization/55157 gcc/ChangeLog: * range-op.cc (operator_mult::wi_fold): Optimize multiplications by powers of 2. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr55157.c: New test.
2022-11-07Extend optimization for integer bit test on __atomic_fetch_[or|and]_*H.J. Lu2-15/+91
Extend optimization for _1 = __atomic_fetch_or_4 (ptr_6, 0x80000000, _3); _5 = (signed int) _1; _4 = _5 >= 0; to _1 = __atomic_fetch_or_4 (ptr_6, 0x80000000, _3); _5 = (signed int) _1; if (_5 >= 0) gcc/ PR middle-end/102566 * tree-ssa-ccp.cc (optimize_atomic_bit_test_and): Also handle if (_5 < 0) and if (_5 >= 0). gcc/testsuite/ PR middle-end/102566 * g++.target/i386/pr102566-7.C
2022-11-07libstdc++: Implement ranges::as_rvalue_view from P2446R2Patrick Palka2-0/+137
libstdc++-v3/ChangeLog: * include/std/ranges (as_rvalue_view): Define. (enable_borrowed_range<as_rvalue_view>): Define. (views::__detail::__can_as_rvalue_view): Define. (views::_AsRvalue, views::as_rvalue): Define. * testsuite/std/ranges/adaptors/as_rvalue/1.cc: New test.
2022-11-07libstdc++: Implement ranges::cartesian_product_view from P2374R4Patrick Palka2-0/+699
This also implements the proposed resolutions of the tentatively ready LWG issues 3760, 3761 and 3801 for cartesian_product_view. I'm not sure how/if we should implement the recommended practice of: iterator::difference_type should be the smallest signed-integer-like type that is sufficiently wide to store the product of the maximum sizes of all underlying ranges if such a type exists because for e.g. extern std::vector<int> x, y; auto v = views::cartesian_product(x, y); IIUC it'd mean difference_type should be __int128 (on 64-bit systems), which seems quite wasteful: in practice the size of any cartesian product probably won't exceed the precision of say ptrdiff_t, and using anything larger will just incur unnecessary space/time overhead. It's also probably not worth the complexity to use less precision than ptrdiff_t (when possible) either. So this patch defines difference_type as common_type_t<ptrdiff_t, range_difference_t<_First>, range_difference_t<_Vs>...> which should mean it's least as large as the difference_type of each underlying range, and at least as large as ptrdiff_t. This patch also adds assertions to catch any overflow that occurs due to this choice of difference_type. libstdc++-v3/ChangeLog: * include/std/ranges (__maybe_const_t): New alias for __detail::__maybe_const_t. (__detail::__cartesian_product_is_random_access): Define. (__detail::__cartesian_product_common_arg): Define. (__detail::__cartesian_product_is_bidirectional): Define. (__detail::__cartesian_product_is_common): Define. (__detail::__cartesian_product_is_sized): Define. (__detail::__cartesian_is_sized_sentinel): Define. (__detail::__cartesian_common_arg_end): Define. (cartesian_product_view): Define. (cartesian_product_view::_Iterator): Define. (views::__detail::__can_cartesian_product_view): Define. (views::_CartesianProduct, views::cartesian_product): Define. * testsuite/std/ranges/cartesian_product/1.cc: New test.
2022-11-07C++: Template lambda mangling testcasesNathan Sidwell4-0/+28
I found some additional cases when working on the demangler. May as well check their mangling. gcc/testsuite/ * g++.dg/abi/lambda-tpl1.h: Add more cases. * g++.dg/abi/lambda-tpl1-17.C: Add checks. * g++.dg/abi/lambda-tpl1-18.C: Likewise. * g++.dg/abi/lambda-tpl1-18vs17.C: Likewise.
2022-11-07Fix NULL filename handlingRichard Purdie1-1/+1
The previous commit introduced a regression as some Ada tests end up passing NULL as the filename to remap_filename. Handle this as before to fix them. gcc/ * file-prefix-map.cc (remap_filename): Handle NULL filenames.
2022-11-07libstdc++: Update from latest fast_float [PR107468]Jakub Jelinek5-99/+211
The following patch updates from fast_float trunk. That way it grabs two of the 4 LOCAL_PATCHES, some smaller tweaks, to_extended cleanups and most importantly fix for the incorrect rounding case, PR107468 aka https://github.com/fastfloat/fast_float/issues/149 Using std::fegetround showed in benchmarks too slow, so instead of doing that the patch limits the fast path where it uses floating point multiplication rather than integral to cases where we can prove there will be no rounding (the multiplication will be exact, not just that the two multiplication or division operation arguments are exactly representable). 2022-11-07 Jakub Jelinek <jakub@redhat.com> PR libstdc++/107468 * src/c++17/fast_float/MERGE: Adjust for merge from upstream. * src/c++17/fast_float/LOCAL_PATCHES: Remove commits that were upstreamed. * src/c++17/fast_float/README.md: Merge from fast_float 662497742fea7055f0e0ee27e5a7ddc382c2c38e commit. * src/c++17/fast_float/fast_float.h: Likewise. * testsuite/20_util/from_chars/pr107468.cc: New test.
2022-11-07libstdc++: Add _Float128 to_chars/from_chars support for x86, ia64 and ↵Jakub Jelinek5-9/+259
ppc64le with glibc The following patch adds std::{to,from}_chars support for std::float128_t on glibc 2.26+ for {i?86,x86_64,ia64,powerpc64le}-linux. When long double is already IEEE quad, previous changes already handle it by using long double overloads in _Float128 overloads. The powerpc64le case (with explicit or implicit -mabi=ibmlongdouble) is handled by using the __float128/__ieee128 entrypoints which are already in the library and used for -mabi=ieeelongdouble. For i?86, x86_64 and ia64 this patch adds new library entrypoints, mostly by enabling the code that was already there for powerpc64le-linux. Those use __float128 or __ieee128, the patch uses _Float128 for the exported overloads and internally as template parameter. While powerpc64le-linux uses __sprintfieee128 and __strtoieee128, for _Float128 the patch uses the glibc 2.26 strfromf128 and strtof128 APIs. So that one can build gcc against older glibc and then compile user programs on newer glibc, the patch uses weak references unless gcc is compiled against glibc 2.26+. strfromf128 unfortunately can't handle %.0Lf and %.*Le, %.*Lf, %.*Lg format strings sprintf/__sprintfieee128 use, we need to remove the L from those and replace * with actually directly printing the precision into the format string (i.e. it can handle %.0f and %.27f (floating point type is implied from the function name)). Unlike the std::{,b}float16_t support, this one actually exports APIs with std::float128_t aka _Float128 in the mangled name, because no standard format is superset of it. On the other side, e.g. on i?86/x86_64 it doesn't have restrictions like for _Float16/__bf16 which ISAs need to be enabled in order to use it. The denorm_min case in the testcase is temporarily commented out because of the ERANGE subnormal issue Patrick posted patch for. 2022-11-07 Jakub Jelinek <jakub@redhat.com> * include/std/charconv (from_chars, to_chars): Add _Float128 overfloads if _GLIBCXX_HAVE_FLOAT128_MATH is defined. * config/abi/pre/gnu.ver (GLIBCXX_3.4.31): Export _ZSt8to_charsPcS_DF128_, _ZSt8to_charsPcS_DF128_St12chars_format, _ZSt8to_charsPcS_DF128_St12chars_formati and _ZSt10from_charsPKcS0_RDF128_St12chars_format. * src/c++17/floating_from_chars.cc (USE_STRTOF128_FOR_FROM_CHARS): Define if needed. (__strtof128): Declare. (from_chars_impl): Handle _Float128. (from_chars): New _Float128 overload if USE_STRTOF128_FOR_FROM_CHARS is define. * src/c++17/floating_to_chars.cc (__strfromf128): Declare. (FLOAT128_TO_CHARS): Define even when _Float128 is supported and wider than long double. (F128_type): Use _Float128 for that case. (floating_type_traits): Specialize for F128_type rather than __float128. (sprintf_ld): Add length argument. Handle _Float128. (__floating_to_chars_shortest, __floating_to_chars_precision): Pass length to sprintf_ld. (to_chars): Add _Float128 overloads for the F128_type being _Float128 cases. * testsuite/20_util/to_chars/float128_c++23.cc: New test.
2022-11-07tree-ssa-sink: do not touch calls that return twiceAlexander Monakov2-2/+29
Avoid moving pure/const calls that may return twice in tree-ssa-sink: properly redirecting the associated abnormal edge is non-trivial. gcc/ChangeLog: PR tree-optimization/107505 * tree-ssa-sink.cc (statement_sink_location): Additionally reject ECF_RETURNS_TWICE calls. gcc/testsuite/ChangeLog: PR tree-optimization/107505 * gcc.dg/pr107505.c: New test.
2022-11-07[range-op] Restrict division by power of 2 optimization to positive numbers.Aldy Hernandez2-1/+19
The problem here is that we are transforming a division by a power of 2 into a right shift, and using this to shift the maybe nonzero bits. This gives the wrong result when the number being divided is negative. In the testcase we are dividing this by 8: [irange] int [-256, -255] NONZERO 0xffffff01 and coming up with: [irange] int [-32, -31] NONZERO 0xffffffe0 The maybe nonzero bits are wrong as -31 has the LSB set (0xffffffe1) whereas the bitmask says the lower 4 bits are off. PR tree-optimization/107541 gcc/ChangeLog: * range-op.cc (operator_div::fold_range): Restrict power of 2 optimization to positive numbers. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr107541.c: New test.
2022-11-07Fortran: Fix reallocation on assignment for kind=4 strings [PR107508]Tobias Burnus3-54/+60
The check whether reallocation on assignment was required did not handle kind=4 characters correctly such that there was always a reallocation, implying issues with pointer addresses and lower bounds. Additionally, with all deferred strings, the old memory was not freed on reallocation. And, finally, inside the block which was only executed if string lengths or bounds or dynamic types changed, was a subcheck of the same, which was effectively a no op but still confusing and at least added with -O0 extra instructions to the binary. PR fortran/107508 gcc/fortran/ChangeLog: * trans-array.cc (gfc_alloc_allocatable_for_assignment): Fix string-length check, plug memory leak, and avoid generation of effectively no-op code. * trans-expr.cc (alloc_scalar_allocatable_for_assignment): Extend comment; minor cleanup. gcc/testsuite/ChangeLog: * gfortran.dg/widechar_11.f90: New test.
2022-11-07i386: Fix typo in sse-22.c pragmakonglin11-1/+1
gcc/testsuite/ChangeLog: * gcc.target/i386/sse-22.c: Fix typo in pragma GCC target.
2022-11-07unswitch most profitable condition firstRichard Biener1-12/+54
When doing the loop unswitching re-org we promised to followup with improvements on the cost modeling. The following makes sure we try to unswitch on the most profitable condition first. As most profitable we pick the condition leading to the edge with the highest profile count. Note the profile is only applied when picking the first unswitching opportunity since the profile counts are not updated with earlier unswitchings in mind. Further opportunities are picked in DFS order. * tree-ssa-loop-unswitch.cc (unswitch_predicate::count): New. (unswitch_predicate::unswitch_predicate): Initialize count. (init_loop_unswitch_info): First collect candidates and determine the outermost loop to unswitch. (tree_ssa_unswitch_loops): First perform all guard hoisting, then perform unswitching on innermost loop predicates. (find_unswitching_predicates_for_bb): Keep track of the most profitable predicate to unswitch on. (tree_unswitch_single_loop): Unswitch given predicate if not NULL.
2022-11-07docs: update: document sanitizers can trigger warningsMartin Liska1-3/+4
gcc/ChangeLog: * doc/invoke.texi: Improve wording. Co-Authored-By: Gerald Pfeifer <gerald@pfeifer.com>
2022-11-07Mitigate clang warnings:Martin Liska1-6/+8
gcc/range-op.cc:1752:16: warning: 'wi_fold' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/range-op.cc:1757:16: warning: 'wi_op_overflows' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/range-op.cc:1759:16: warning: 'op1_range' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/range-op.cc:1763:16: warning: 'op2_range' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/range-op.cc:1928:16: warning: 'wi_fold' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/range-op.cc:1933:16: warning: 'wi_op_overflows' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] gcc/ChangeLog: * range-op.cc: Add final override keywords.
2022-11-07ada: Document that gprof won't work on windows with PIE.Cedric Landet2-4/+11
Document that gprof won't work on windows with PIE and -no-pie must be used. gcc/ada/ * doc/gnat_ugn/gnat_and_program_execution.rst: Mention the needed -no-pie for windows to use gprof. * gnat_ugn.texi: Regenerate.
2022-11-07ada: Tune hash function for cross-reference entriesPiotr Trojanek1-2/+2
Tune the hash function that combines entity identifiers with source locations of where those entities are referenced. Previously the source location was multiplied by 2 ** 7 (i.e. shifted left by 7 bits), then added to the entity identifier, and finally divided modulo 2 ** 16 (i.e. masked to only use the lowest 16 bits). This hash routine caused collisions that could make some tests up to twice slower. With a large entity number the source location was only contributing few bits to the hash value. This large entity number might correspond to entity like Ada.Characters.Latin_1.NUL that occurs thousands of times in generated code. gcc/ada/ * lib-xref.adb (Hash): Tune hash function.
2022-11-07ada: Fix performance regression related to references in Refined_StatePiotr Trojanek1-27/+29
Recently added call to In_Pragma_Expression caused a performance regression. It might require climbing syntax trees of arbitrarily deep expressions, while previously references within pragmas were detected in bounded time. This patch restores the previous efficiency. However, while the original code only detected references directly within pragma argument associations, now we also detect references inside aggregates, e.g. like those in pragma Refined_State. gcc/ada/ * sem_prag.adb (Non_Significant_Pragma_Reference): Detect references with aggregates; only assign local variables Id and C when necessary.
2022-11-07ada: Use named notation in calls to Expand_Composite_EqualityBob Duff1-12/+18
Use named notation in calls to Expand_Composite_Equality. gcc/ada/ * exp_ch4.adb (Component_Equality, Expand_Array_Equality) (Expand_Record_Equality): Use named notation.
2022-11-07ada: New warning about noncomposing user-defined "="Bob Duff10-34/+145
Print warning for a user-defined "=" that does not compose as might be expected (i.e. is ignored for predefined "=" of a containing record or array type). This warning is enabled by -gnatw_q; we don't enable it by default because it generates too many false positives. We also don't enable it via -gnatwa. gcc/ada/ * exp_ch4.adb (Expand_Array_Equality): Do not test Ltyp = Rtyp here, because that is necessarily true. Move assertion thereof to more general place. (Expand_Composite_Equality): Pass in Outer_Type, for use in warnings. Rename Typ to be Comp_Type, to more clearly distinguish it from Outer_Type. Print warning when appropriate. * exp_ch4.ads: Minor comment fix. * errout.ads: There is no such pragma as Warning_As_Pragma -- Warning_As_Error must have been intended. Improve comment for ?x?. * exp_ch3.adb (Build_Untagged_Equality): Update comment to be accurate for more recent versions of Ada. * sem_case.adb (Choice_Analysis): Declare user-defined "=" functions as abstract. * sem_util.ads (Is_Bounded_String): Give RM reference in comment. * warnsw.ads, warnsw.adb (Warn_On_Ignored_Equality): Implement new warning switch -gnatw_q. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Document new warning switch. * gnat_ugn.texi: Regenerate.
2022-11-07ada: Inline composite node kind AST queriesPiotr Trojanek2-2/+3
Queries that ultimately examine the same field of an AST node (e.g. Nkind) are visibly more efficient when inlined. In particular, routines Is_Body_Or_Package_Declaration and Is_Body can apparently be inlined into a single Nkind membership test. This patch fixes some of the performance lost with the recent changes, which increased the number of calls to Is_Body_Or_Package_Declaration (as it is typically used to prevent AST search from climbing too far). However, it should be generally beneficial to inline routines like this. gcc/ada/ * sem_aux.ads (Is_Body): Annotate with Inline. * sem_util.ads (Is_Body_Or_Package_Declaration): Likewise.
2022-11-07ada: Fix inherited postconditions in inlined subprogramsBob Duff1-5/+10
Protect the building of postcondition pragmas in case the postcondition is not present due to inlining. gcc/ada/ * freeze.adb (Build_Inherited_Condition_Pragmas): Do nothing if A_Post is empty.