aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-10-07IPA: support -flto + -flive-patching=inline-cloneMartin Liska3-4/+13
There's no fundamental reason why -flive-patching=inline-clone can't coexist with -flto. Yes, one can theoretically have many more clone function that includes a live patch. It is pretty much the same as in-module inlining. gcc/ChangeLog: * opts.cc (finish_options): Print sorry message only for -flive-patching=inline-only-static. gcc/testsuite/ChangeLog: * gcc.dg/live-patching-2.c: Update scanned pattern. * gcc.dg/live-patching-5.c: New test.
2022-10-07c++ modules: static var in inline function [PR104433]Patrick Palka3-0/+20
The below testcase fails to link with the error undefined reference to `f()::y' ultimately because during stream out for the static VAR_DECL y we override DECL_EXTERNAL to true, which later during IPA confuses symbol_table::remove_unreachable_nodes into thinking it's safe to not emit the symbol. The streaming code here already avoids overriding DECL_EXTERNAL for inline vars and functions, so it seems natural to extend this to static vars from an inline function. PR c++/104433 gcc/cp/ChangeLog: * module.cc (trees_out::core_bools): Don't override DECL_EXTERNAL to true for static variables from an inline function. gcc/testsuite/ChangeLog: * g++.dg/modules/static-2_a.H: New test. * g++.dg/modules/static-2_b.C: New test.
2022-10-07gimplify: prevent some C++ temporary elisionJason Merrill2-7/+33
In this testcase, we were optimizing away the temporary for f(), but C++17 and above are clear that there is a temporary, and because its destructor has visible side-effects we can't optimize it away under the as-if rule. So disable this optimization for TREE_ADDRESSABLE type. I moved the declaration of volatile_p after the call to gimple_fold_indirect_ref_rhs to minimize indentation changes; I don't see any way the value of that flag could be affected by the call. gcc/ChangeLog: * gimplify.cc (gimplify_modify_expr_rhs): Don't optimize x = *(A*)&<expr> to x = <expr> for a TREE_ADDRESSABLE type. gcc/testsuite/ChangeLog: * g++.dg/init/elide9.C: New test.
2022-10-07tree-optimization/107153 - autopar SSA update issueRichard Biener3-2/+22
autopar performs insertion of stores, eventually requiring a virtual loop PHI and assorted LC PHI adjustments which we intend to do once after the pass finishes. But we also perform intermediate update_ssa after loop duplication which can lose this fact. The following forces renaming of the virtual operand before the final SSA update to fix that. It also removes the explicit update_ssa call from the gimple_duplicate_sese_tail utility as has been done for all other such utilities and instead performs the SSA update from autopar. PR tree-optimization/107153 * tree-cfg.cc (gimple_duplicate_sese_tail): Do not update SSA form here. * tree-parloops.cc (gen_parallel_loop): Update SSA form after to-exit-first transform, no PHI insertion is necessary. (pass_parallelize_loops::execute): Force re-write of the virtual operand SSA web. * gcc.dg/autopar/pr107153.c: New testcase.
2022-10-07libstdc++: Add --disable-libstdcxx-hosted as an alias for hosted-libstdcxxJonathan Wakely2-10/+49
Most libstdc++ configure args are of the form --enable-libstdcxx-xxx but the option to build freestanding is --disable-hosted-libstdcxx. If you accidentally type --disable-libstdcxx-hosted then it will be ignored. This adds --disable-libstdcxx-hosted as an alias for the existing arg, so it works whichever way you say it. If both args are used explicitly and their values do not agree, configure fails with an error. libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_ENABLE_HOSTED): Add libstdcxx-hosted enable arg as an alias for hosted-libstdcxx enable arg. * configure: Regenerate.
2022-10-07libstdc++: Shuffle header dependencies of <functional>Jonathan Wakely2-9/+8
The <new> header is needed by std::function to use placement new, so include it in <bits/std_function.h> instead of in <functional>. libstdc++-v3/ChangeLog: * include/bits/std_function.h: Include <new> but do not include <bits/stl_function.h>. * include/std/functional: Do not include <new>.
2022-10-07gcc: Fix comment typoJonathan Wakely1-1/+1
gcc/ChangeLog: * value-range.cc (irange::irange_contains_p): Fix comment typo.
2022-10-07libstdc++: Use bold style for DR titles in the manualJonathan Wakely2-397/+390
This matches how the issues are styled in the LWG issues list, and also allows us to use italics for "cv" (e.g. in issue 2487). libstdc++-v3/ChangeLog: * doc/xml/manual/intro.xml: Add role="bold" attribute to emphasis elements for issue titles. * doc/html/manual/bugs.html: Regenerate.
2022-10-07Reduce DF computation at -O0Eric Botcazou1-4/+9
Even at -O0 there may be a fair amount of DF computation performed when compiling large units and part of it appears to be useless. gcc/ * function.cc (thread_prologue_and_epilogue_insns): Update only entry and exit blocks when not optimizing. Remove dead statement.
2022-10-07Convert nonzero mask back to tree.Aldy Hernandez2-27/+77
Having nonzero masks always set had a performance penalty of 10% in VRP, so mask==NULL is a shortcut to all bits set. gcc/ChangeLog: * value-range.cc (irange::irange_set): Convert nonzero mask to tree. (irange::irange_set_anti_range): Same. (irange::set): Same. (irange::verify_range): Same. (irange::contains_p): Same. (irange::invert): Same. (irange::set_range_from_nonzero_bits): Same. (irange::set_nonzero_bits): Same. (mask_to_wi): Same. (irange::intersect_nonzero_bits): Same. (irange::union_nonzero_bits): Same. * value-range.h (irange::varying_compatible_p): Same. (gt_ggc_mx): Same. (gt_pch_nx): Same. (irange::set_undefined): Same. (irange::set_varying): Same.
2022-10-07contrib: remove extra fetch from git_update_versionMartin Liska1-1/+1
Remove extra fetch call that didn't help with the issue we had (missing object). contrib/ChangeLog: * gcc-changelog/git_update_version.py: Remove extra fetch.
2022-10-07libdecnumber: remove unused variableMartin Liska1-2/+1
Fixes: libdecnumber/dpd/decimal64.c:617:8: warning: variable 'n' set but not used [-Wunused-but-set-variable] libdecnumber/ChangeLog: * dpd/decimal64.c (decDigitsToDPD): Remove unused variable.
2022-10-07fix clang warningsMartin Liska4-20/+20
Fixes: gcc/c-family/name-hint.h:109:66: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call] gcc/config/i386/i386-expand.cc:1351:9: warning: argument 'operands' of type 'rtx[3]' (aka 'rtx_def *[3]') with mismatched bound [-Warray-parameter] gcc/config/i386/i386.cc:15635:8: warning: argument 'operands' of type 'rtx[2]' (aka 'rtx_def *[2]') with mismatched bound [-Warray-parameter] gcc/cp/module.cc:17482:51: warning: argument 'counts' of type 'unsigned int[8]' with mismatched bound [-Warray-parameter] gcc/cp/module.cc:17508:37: warning: argument 'counts' of type 'unsigned int[8]' with mismatched bound [-Warray-parameter] gcc/cp/name-lookup.cc:6385:16: warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call] gcc/c-family/ChangeLog: * name-hint.h: Use std::move. gcc/ChangeLog: * config/i386/i386-protos.h (ix86_binary_operator_ok): Add array size to function parameter. (ix86_unary_operator_ok): Likewise. gcc/cp/ChangeLog: * module.cc (enum module_state_counts): Use array size. * name-lookup.cc (class namespace_limit_reached): Likewise. (class module_state): Move up in the file.
2022-10-07remove dead variablesMartin Liska2-5/+3
Remove unused variables that are modified but not used. gcc/ChangeLog: * auto-profile.cc (get_inline_stack): Remove unused variable. gcc/objc/ChangeLog: * objc-gnu-runtime-abi-01.cc (generate_static_references): Remove unused variable.
2022-10-07Fix comment typosJakub Jelinek5-5/+5
When looking at tree-inline.cc I've noticed a comment typo and grepped for similar typos elsewhere. 2022-10-07 Jakub Jelinek <jakub@redhat.com> * ipa-prop.h (ipa_constant_data): Fix comment typo. * value-range.cc (irange::irange_contains_p): Likewise. * value-relation.cc (dom_oracle::set_one_relation): Likewise. * gimple-predicate-analysis.cc (predicate::simplify_4): Likewise. * tree-inline.cc (remap_ssa_name): Likewise.
2022-10-07c++: Improve handling of foreigner namespace attributesJakub Jelinek7-27/+123
In some cases we want to look up or remove both standard attributes and attributes from gnu namespace but not others. This patch arranges for ATTR_NS of "" to stand for ATTR_NS NULL or "gnu", so that we don't need 2 separate calls, and introduces is_attribute_namespace_p function which allows testing the namespace of an attribute similar way. The patch also uses the new lookup_attribute overload and extra tests to avoid emitting weird warnings on foreign namespace attributes which we should just ignore (perhaps with a warning), but shouldn't imply any meaning to them just because they have a name matching some standard or gnu attribute name. 2022-10-07 Jakub Jelinek <jakub@redhat.com> gcc/ * attribs.h (is_attribute_namespace_p): New inline function. (lookup_attribute): Document meaning of ATTR_NS equal to "". * attribs.cc (remove_attribute): Use is_attribute_namespace_p. (private_lookup_attribute): For ATTR_NS "" match either standard attribute or "gnu" namespace one. gcc/c-family/ * c-common.cc (attribute_fallthrough_p): Lookup fallthrough attribute only in gnu namespace or as standard attribute, treat fallthrough attributes in other namespaces like any other unknown attribute. gcc/cp/ * parser.cc (cp_parser_check_std_attribute): Only do checks if attribute is a standard attribute or in gnu namespace and only lookup other attributes in those namespaces. * cp-gimplify.cc (lookup_hotness_attribute): Adjust function comment. Only return true for standard attribute or gnu namespace attribute. (remove_hotness_attribute): Only remove hotness attributes when they are standard or in gnu namespace, implement it in a single loop rather than former 4 now 8 remove_attribute calls. gcc/testsuite/ * g++.dg/cpp1z/fallthrough2.C: New test. * g++.dg/cpp2a/attr-likely7.C: New test.
2022-10-07fixincludes: Deal also with the _Float128x cases [PR107059]Jakub Jelinek3-5/+75
On Wed, Sep 28, 2022 at 08:19:43PM +0200, Jakub Jelinek via Gcc-patches wrote: > Another case are the following 3 snippets: > # if !__GNUC_PREREQ (7, 0) || defined __cplusplus > # error "_Float128X supported but no constant suffix" > # else > # define __f128x(x) x##f128x > # endif > ... > # if !__GNUC_PREREQ (7, 0) || defined __cplusplus > # error "_Float128X supported but no complex type" > # else > # define __CFLOAT128X _Complex _Float128x > # endif > ... > # if !__GNUC_PREREQ (7, 0) || defined __cplusplus > # error "_Float128x supported but no type" > # endif > but as no target has _Float128x right now and don't see it > coming soon, it isn't a big deal (on the glibc side it is of > course ok to adjust those). This incremental patch deals handles the above 3 cases, so we fixinclude what glibc itself changed too. 2022-10-07 Jakub Jelinek <jakub@redhat.com> PR bootstrap/107059 * inclhack.def (glibc_cxx_floatn_5): New. * fixincl.x: Regenerated. * tests/base/bits/floatn.h: Regenerated.
2022-10-07fixincludes: Fix up powerpc floatn.h tweaks [PR107059]Jakub Jelinek3-9/+87
On Wed, Sep 28, 2022 at 12:23:31AM +0000, Joseph Myers wrote: > In general the changes match those made by fixincludes, though I think > the ones in sysdeps/powerpc/bits/floatn.h, where the header tests > __LDBL_MANT_DIG__ == 113 or uses #elif, wouldn't match the existing > fixincludes patterns. You're right, missed that. The header has: /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */ # if __HAVE_FLOAT128 # if __LDBL_MANT_DIG__ == 113 && defined __cplusplus typedef long double _Float128; # define __CFLOAT128 _Complex long double # elif !__GNUC_PREREQ (7, 0) || defined __cplusplus /* The type _Float128 exist for powerpc only since GCC 7.0. */ typedef __float128 _Float128; /* Add a typedef for older GCC and C++ compilers which don't natively support _Complex _Float128. */ typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__KC__))); # define __CFLOAT128 __cfloat128 # else # define __CFLOAT128 _Complex _Float128 # endif # endif and my current rules don't do anything about that. The following patch fixes that. I've run additionally MACRO_LIST=`pwd`/../gcc/macro_list TARGET_MACHINE=x86_64-pc-linux-gnu \ ../fixincludes/fixinc.sh /tmp/include-fixed \ `echo /usr/src/libc | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta` in the builddir/fixincludes directory where /usr/src/libc is latest glibc trunk checkout and seems the remaining defined __cplusplus cases in the floatn.h and floatn-common.h headers are ok or acceptable. The remaining cases are: #if __GNUC_PREREQ (7, 0) && !defined __cplusplus # define __HAVE_FLOATN_NOT_TYPEDEF 1 #else # define __HAVE_FLOATN_NOT_TYPEDEF 0 #endif which is IMHO ok because this is only used in tgmath.h or tgmath-like math.h stuff which is C only, as C++ doesn't have _Generic. Another case are the following 3 snippets: # if !__GNUC_PREREQ (7, 0) || defined __cplusplus # error "_Float128X supported but no constant suffix" # else # define __f128x(x) x##f128x # endif ... # if !__GNUC_PREREQ (7, 0) || defined __cplusplus # error "_Float128X supported but no complex type" # else # define __CFLOAT128X _Complex _Float128x # endif ... # if !__GNUC_PREREQ (7, 0) || defined __cplusplus # error "_Float128x supported but no type" # endif but as no target has _Float128x right now and don't see it coming soon, it isn't a big deal (on the glibc side it is of course ok to adjust those). OT, besides floatn.h and floatn-common.h headers, the only one remaining in /tmp/include-fixed is sysdeps/arm/unwind.h, perhaps -#if defined(linux) || defined(__NetBSD__) +#if defined(__linux__) || defined(__NetBSD__) should be done in that header (and libgcc/config/arm/unwind-arm.h too). 2022-10-07 Jakub Jelinek <jakub@redhat.com> PR bootstrap/107059 * inclhack.def (glibc_cxx_floatn_2): Handle #elif the same as #if. (glibc_cxx_floatn_4): New. * fixincl.x: Regenerated. * tests/base/bits/floatn.h: Regenerated.
2022-10-07Downgrade DWARF_VERSION_DEFAULT to 3 for VxWorks >= 7Olivier Hainque1-1/+1
Using 4 as the DWARF_VERSION_DEFAULT value for VxWorks observably still hangs recent system debuggers on tbreak for some contructs, and downgrading to 3 improves the situation. 2022-03-06 Olivier Hainque <hainque@adacore.com> gcc/ * config/vxworks.h (DWARF_VERSION_DEFAULT): Adjust from 4 to 3 for VxWorks >= 7.
2022-10-07Introduce DWARF_VERSION_DEFAULT and redefine for VxWorksOlivier Hainque6-13/+25
This change introduces a target overridable macro to replace the hardcoded value used to initialize dwarf_version from common.opt. The main advantage compared to special code in a target override_options hook is that redefinitions by target config files are visible by both the compiler proper and by the driver, which might refer to dwarf_version in ASM_DEBUG_SPECs and friends. This is useful at least on VxWorks, where we usually need to default to dwarf 4 or even 2 to accommodate non-gdb debuggers provided by the environment, including for assembly sources used in libgcc for some ports (witnessed with lse.S on aarch64). 2022-02-28 Olivier Hainque <hainque@adacore.com> gcc/ * defaults.h (DWARF_DEFAULT_VERSION): Define if not defined already. * common.opt (gdwarf-): Use it. * doc/tm.texi.in (DWARF_DEFAULT_VERSION): Document. * doc/tm.texi: Update accordingly. * config/vxworks.h (DWARF_DEFAULT_VERSION): Redefine. * config/vxworks.cc: Remove code setting dwarf_version, now handled by the DWARF_DEFAULT_VERSION redefinition.
2022-10-07undef offsetof before defining it in stddef.hOlivier Hainque1-0/+1
This prevents redefinition warnings by -Wsystem-headers on OSses where system headers happen to provide a definition of their own, such as VxWorks. 2022-02-15 Olivier Hainque <hainque@adacore.com> gcc/ * ginclude/stddef.h: #undef offsetof before #define.
2022-10-06compiler: better arg type checking for selected builtinsThan McIntosh2-2/+7
Tighten up the argument type checking for Builtin_call_expression to catch erroneous cases such as panic(panic("bad"))) where an argument void type is being passed to panic/alignof/sizeof. Fixes golang/go#56071. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/439815
2022-10-07Daily bump.GCC Administrator11-1/+517
2022-10-07libgcc, arc: Fix buildJakub Jelinek1-1/+1
Missed one spot in the r13-3108-g146e45914032 change (my sed script didn't expect nested []s). 2022-10-07 Jakub Jelinek <jakub@redhat.com> * config/arc/linux-unwind.h (arc_fallback_frame_state): Use fs->regs.how[X] instead of fs->regs.reg[X].how.
2022-10-06c++: fix broken conversion in coroutinesJason Merrill2-1/+5
You can't use CONVERT_EXPR to convert between two class types. VIEW_CONVERT_EXPR takes liberties with the C++ type system, but is probably safe in this context. Let's also only use it when the type isn't already what we want. gcc/cp/ChangeLog: * coroutines.cc (expand_one_await_expression): Change conversion to VIEW_CONVERT_EXPR. * cp-gimplify.cc (cp_genericize_r) [CONVERT_EXPR]: Add assert.
2022-10-06[PR107170] Avoid copying incompatible types in legacy VRP.Aldy Hernandez2-11/+21
Legacy VRP is calling ranger deep inside the bowels, and then trying to copy an incompatible type. My previous patch in this area assumed that the only possibility out of vr_values::get_value_range for an unsupported type was VARYING, but UNDEFINED can also be returned. PR tree-optimization/107170 gcc/ChangeLog: * vr-values.cc (vr_values::range_of_expr): Do not die on unsupported types. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr107170.c: New test.
2022-10-06analyzer: fix another ICE in PR 107158David Malcolm2-28/+114
I overreduced PR analyzer/107158 in r13-3096-gef878564140cbc, and there was another ICE in the original reproducer, which this patch fixes. gcc/analyzer/ChangeLog: PR analyzer/107158 * store.cc (store::replay_call_summary_cluster): Eliminate special-casing of RK_HEAP_ALLOCATED in favor of sharing code with RK_DECL, avoiding an ICE due to attempting to bind a compound_svalue into a binding_cluster when an svalue in the summary cluster converts to a compound_svalue in the caller. gcc/testsuite/ChangeLog: PR analyzer/107158 * gcc.dg/analyzer/call-summaries-pr107158-2.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-10-06analyzer: fixes to call_summary_replay::dump_to_ppDavid Malcolm1-2/+8
gcc/analyzer/ChangeLog: * call-summary.cc (call_summary_replay::dump_to_pp): Bulletproof against NULL caller regions/svalues. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-10-06openmp: Map holds clause to IFN_ASSUME for FortranTobias Burnus3-1/+132
Same as r13-3107-g847f5addc4d07a2f3b95f5daa50ab4a64dfd957d did for C/C++. Convert '!$omp assume holds(cond)' to IFN_ASSUME (cond). gcc/fortran/ * trans-openmp.cc (gfc_trans_omp_assume): New. (gfc_trans_omp_directive): Call it. gcc/testsuite/ * gfortran.dg/gomp/assume-3.f90: New test. * gfortran.dg/gomp/assume-4.f90: New test.
2022-10-06c: C2x typeofJoseph Myers13-23/+406
C2x adds typeof as a standard feature. In general this follows existing GNU C semantics very closely, but there are various ways in which the implementation involves more than simply enabling the keyword for C2x: * As well as typeof, there is a typeof_unqual variant, which removes all qualifiers and _Atomic from the resulting type (whereas typeof preserves qualifiers and _Atomic on qualified or atomic (lvalue or type name) operands). * The typeof keyword is disabled by -fno-asm, so enabling it for C2x needs to be implemented in a way that preserves the disabling by -fno-asm for older standard versions (which having -fno-asm having no effect on it in C2x mode). This is done via adding a new D_EXT11 mask (which is also where the C++ front-end change comes from, to handle D_EXT11 appropriately there for -fno-asm and -fno-gnu-keywords). * GNU typeof treats the noreturn property of a function (as specified in standard C with _Noreturn or [[noreturn]]) as being part of the type of a pointer to function, but it is not part of the type in standard terms. Thus a special case is needed in the typeof implementation, just like in the _Generic implementation, to avoid treating it as a type for standard typeof. It seems plausible this is being used when copying the type of one object to another using typeof, so the existing semantics are preserved for __typeof__, and for typeof in pre-C2x modes, while typeof for C2x or later has the standard semantics. * It turns out that, even after Martin Uecker's changes in this area, there were still cases where rvalues could wrongly have a qualified or atomic type in GCC. This applied to ++ and -- increment and decrement expressions, and also to calls to functions returning an atomic type. (For the latter, the working draft doesn't actually explicitly exclude the function call expression having an atomic type, but given all the changes that have gone into C17 and C2x to avoid rvalues ever having qualified types, and given that lvalue-to-rvalue conversion removes both qualifiers and _Atomic, it seems unlikely that this (or casts, where GCC already removes _Atomic) is actually intended as a route to allow an _Atomic-qualified rvalue; I've noted this to raise as an NB comment on the CD ballot.) Bootstrapped with no regressions for x86_64-pc-linux-gnu. OK to commit (C+ gcc/ * doc/invoke.texi (-fno-asm): Update description of effects on typeof keyword. gcc/c-family/ * c-common.cc (c_common_reswords): Mark typeof as D_EXT11. Add typeof_unqual. * c-common.h (enum rid): Add RID_TYPEOF_UNQUAL. (D_EXT11): New macro. Values of subsequent macros updated. gcc/c/ * c-parser.cc (c_parse_init): Add D_EXT11 to mask if flag_no_asm and not C2x. (c_keyword_starts_typename, c_token_starts_declspecs) (c_parser_declspecs, c_parser_objc_selector): Handle RID_TYPEOF_UNQUAL. (c_parser_typeof_specifier): Handle RID_TYPEOF_UNQUAL. Distinguish typeof for C2x from __typeof__ for all standard versions and typeof before C2x. * c-typeck.cc (build_function_call_vec): Use unqualified version of non-void return type. (build_unary_op): Use unqualified type for increment and decrement. gcc/cp/ * lex.cc (init_reswords): Handle D_EXT11. gcc/testsuite/ * gcc.dg/c11-typeof-1.c, gcc.dg/c2x-typeof-1.c, gcc.dg/c2x-typeof-2.c, gcc.dg/c2x-typeof-3.c, gcc.dg/gnu11-typeof-1.c, gcc.dg/gnu11-typeof-2.c, gcc.dg/gnu2x-typeof-1.c: New tests.
2022-10-06c++: remove optimize_specialization_lookup_pPatrick Palka4-118/+59
Roughly speaking, optimize_specialization_lookup_p returns true for a non-template member function of a class template, e.g. template<class T> struct A { int f(); }; The idea behind the optimization guarded by this predicate is that if we want to look up the specialization A<T>::f [with T=int], then we can just do a name lookup for f in A<int> and avoid having to add a spec_entry for f in the decl_specializations table. But the benefit of this optimization seems questionable because in order to do the name lookup we first need to look up A<T> [with T=int] in the type_specializations table, which is as expensive as the decl_specializations lookup we're avoiding. And according to some experiments (using stdc++.h, range-v3 and libstdc++ tests) the compiler is slightly (<1%) _faster_ if we disable this optimization. Additionally, this optimization means we won't record an explicit specialization in decl_specializations for such a template either, which is an unfortunate inconsistency that apparently breaks the below modules testcase. So since this optimization doesn't improve performance, and complicates the explicit specialization story which causes issues with modules, this patch proposes to remove it. gcc/cp/ChangeLog: * pt.cc (optimize_specialization_lookup_p): Remove. (retrieve_specialization): Assume the above returns false and simplify accordingly. (register_specialization): Likewise. gcc/testsuite/ChangeLog: * g++.dg/modules/indirect-3_b.C: Expect that the entity foo::TPL<0>::frob is tagged as a specialization instead of as a declaration. * g++.dg/modules/tpl-spec-8_a.H: New test. * g++.dg/modules/tpl-spec-8_b.C: New test.
2022-10-06Fix wrong code generated by unroll-and-jam passEric Botcazou2-2/+45
There is a loophole in the unroll-and-jam pass that can quickly result in wrong code generation. The code reads: if (!compute_data_dependences_for_loop (outer, true, &loop_nest, &datarefs, &dependences)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Cannot analyze data dependencies\n"); free_data_refs (datarefs); free_dependence_relations (dependences); continue; } but compute_data_dependences_for_loop may return true even if the analysis is reported as failing by compute_affine_dependence for a dependence pair: (compute_affine_dependence ref_a: data[_14], stmt_a: data[_14] = i_59; ref_b: data[_14], stmt_b: data[_14] = i_59; Data ref a: Data ref b: affine dependence test not usable: access function not affine or constant. ) -> dependence analysis failed Note that this is a self-dependence pair and the code for them reads: /* Nothing interesting for the self dependencies. */ if (dra == drb) continue; This means that the pass may reorder "complex" accesses to the same memory location in successive iterations, which is OK for reads but not for writes. gcc/ * gimple-loop-jam.cc (tree_loop_unroll_and_jam): Bail out for a self dependency that is a write-after-write if the access function is not affine or constant. gcc/testsuite/ * gcc.c-torture/execute/20221006-1.c: New test.
2022-10-06Minor cleanup in DF codeEric Botcazou1-10/+14
No functional changes. gcc/ * df-scan.cc (df_ref_create_structure): Minor cleanup.
2022-10-06middle-end/107115 - avoid bogus redundant store removal during RTL expansionRichard Biener2-1/+40
The following preserves the (premature) redundant store removal done in store_expr by appropriately guarding it with mems_same_for_tbaa_p. The testcase added needs scheduling disabled for now since there's a similar bug there still present. PR middle-end/107115 * expr.cc (store_expr): Check mems_same_for_tbaa_p before eliding a seemingly redundant store. * gcc.dg/torture/pr107115.c: New testcase.
2022-10-06aarch64: Remove redundant zero-extends with LDARKyrylo Tkachov2-0/+44
Like other loads in AArch64, the LDARB,LDARH,LDAR instructions clear out the top part of their destination register and we can thus avoid having to explicitly zero-extend it. We were missing a combine pattern that this patch adds. For one of the examples in the testcase we generated: load_uint8_t_ext_uint16_t: adrp x0, .LANCHOR0 add x0, x0, :lo12:.LANCHOR0 ldarb w0, [x0] and w0, w0, 255 ret but now generate: load_uint8_t_ext_uint16_t: adrp x0, .LANCHOR0 add x0, x0, :lo12:.LANCHOR0 ldarb w0, [x0] ret Bootstrapped and tested on aarch64-none-linux-gnu. gcc/ChangeLog: * config/aarch64/atomics.md (*atomic_load<ALLX:mode>_zext<SD_HSDI:mode>): New pattern. gcc/testsuite/ChangeLog: * gcc.target/aarch64/ldar_2.c: New test.
2022-10-06aarch64: Add test for LDAR generation from __atomic_load_nKyrylo Tkachov1-0/+66
I'd like a test to check the generation of LDAR for atomic_load_n. No new functionality added. gcc/testsuite/ChangeLog: * gcc.target/aarch64/ldar_1.c: New test.
2022-10-06aarch64: update Ampere-1 core definitionPhilipp Tomsich1-1/+1
This brings the extensions detected by -mcpu=native on Ampere-1 systems in sync with the defaults generated for -mcpu=ampere1. Note that some early kernel versions on Ampere1 may misreport the presence of PAUTH and PREDRES (i.e., -mcpu=native will add 'nopauth' and 'nopredres'). gcc/ChangeLog: * config/aarch64/aarch64-cores.def (AARCH64_CORE): Update Ampere-1 core entry. Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
2022-10-06aarch64: fix off-by-one in reading cpuinfoPhilipp Tomsich3-2/+25
Fixes: 341573406b39 Don't subtract one from the result of strnlen() when trying to point to the first character after the current string. This issue would cause individual characters (where the 128 byte buffers are stitched together) to be lost. gcc/ChangeLog: * config/aarch64/driver-aarch64.cc (readline): Fix off-by-one. gcc/testsuite/ChangeLog: * gcc.target/aarch64/cpunative/info_18: New test. * gcc.target/aarch64/cpunative/native_cpu_18.c: New test. Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
2022-10-06tree-optimization/107107 - tail-merging VN wrong-codeRichard Biener2-14/+28
The following fixes an unintended(?) side-effect of the special MODIFY_EXPR expression entries we add for tail-merging during VN. We shouldn't value-number the virtual operand differently here. PR tree-optimization/107107 * tree-ssa-sccvn.cc (visit_reference_op_store): Do not affect value-numbering when doing the tail merging MODIFY_EXPR lookup. * gcc.dg/pr107107.c: New testcase.
2022-10-06ada: Implementation of support for storage models in gigiEric Botcazou7-61/+605
It is based on a new LOAD_EXPR node in GENERIC that is later turned into a bona-fide temporary during gimplification. gcc/ada/ * gcc-interface/ada-tree.def (LOAD_EXPR): New expression code. * gcc-interface/gigi.h (build_storage_model_load): Declare. (build_storage_model_store): Likewise. (instantiate_load_in_expr): Likewise. (INSTANTIATE_LOAD_IN_EXPR): New macro. (instantiate_load_in_array_ref): Declare. * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Type>: Set a fake discriminant number on the fields of the template type. (gnat_to_gnu_field): Use integer for DECL_DISCRIMINANT_NUMBER. * gcc-interface/misc.cc (gnat_init_ts): Mark LOAD_EXPR as typed. * gcc-interface/trans.cc (fold_constant_decl_in_expr) <ARRAY_REF>: Also preserve the 4th operand. (Attribute_to_gnu): Deal with LOAD_EXPR of unconstrained array type. <Attr_Size>: Call INSTANTIATE_LOAD_IN_EXPR for a storage model. <Attr_Length>: Likewise. <Attr_Bit_Position>: Likewise. (get_storage_model): New function. (get_storage_model_access): Likewise. (storage_model_access_required_p): Likewise. (Call_to_gnu): Add GNAT_STORAGE_MODEL parameter and deal with it. Also deal with actual parameters that have a storage model. (gnat_to_gnu) <N_Object_Declaratio>: Adjust call to Call_to_gnu. <N_Explicit_Dereference>: Deal with a storage model access. <N_Indexed_Component>: Likewise. <N_Slice>: Likewise. <N_Selected_Component>: Likewise. <N_Assignment_Statement>: Adjust call to Call_to_gnu. Deal with a storage model access either on the LHS, on the RHS or on both. <N_Function_Cal>: Adjust call to Call_to_gnu. <N_Free_Statement>: Deal with a pool that is a storage model. Replace test for UNCONSTRAINED_ARRAY_REF with test on the type. (gnat_gimplify_expr) <CALL_EXPR>: Tidy up. <LOAD_EXPR>: New case. <UNCONSTRAINED_ARRAY_REF>: Move down. * gcc-interface/utils.cc (maybe_unconstrained_array): Deal with a LOAD_EXPR by recursing on its first operand. * gcc-interface/utils2.cc (build_allocator): Deal with a pool that is a storage model. (build_storage_model_copy): New function. (build_storage_model_load): Likewise. (build_storage_model_store): Likewise. (instantiate_load_in_expr): Likewise. (instantiate_load_in_array_ref): Likewise. (gnat_rewrite_reference) <ARRAY_REF>: Also preserve the 4th operand. (get_inner_constant_reference) <ARRAY_REF>: Remove useless test. (gnat_invariant_expr) <ARRAY_REF>: Rewrite test.
2022-10-06ada: Minor potential bug in sem_ch6.adbSteve Baird1-1/+1
In sem_ch6.adb, the procedure Analyze_Procedure_Call is preceded with a comment: -- WARNING: This routine manages Ghost regions. Return statements must be -- replaced by gotos that jump to the end of the routine and restore the -- Ghost mode. Correct a violation of this comment. This is a one-line change. gcc/ada/ * sem_ch6.adb (Analyze_Procedure_Call): Replace "return;" with "goto Leave;", as per comment preceding body of Analyze_Procedure_Call.
2022-10-06ada: Reject conditional goto in lock-free protected subprogramsPiotr Trojanek1-1/+1
In lock-free protected subprograms we don't allow goto statements; likewise, we now reject conditional goto statements. This fix only affects semantic checking mode with switch -gnatc. In ordinary compilation we already rejected conditional goto after it was expanded into ordinary goto. gcc/ada/ * sem_ch9.adb (Allows_Lock_Free_Implementation): Reject conditional goto statements.
2022-10-06ada: Cleanup related to lock-free protected subprogramsPiotr Trojanek3-11/+9
Cleanup code and documentation; semantics is unaffected. gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst (Lock_Free): Remove inconsistent periods that end item descriptions. * sem_ch9.adb (Allows_Lock_Free_Implementation): Remove unnecessary guard against an empty list of parameters; replace low-level entity kind membership test with a high-level query; refill error message. * gnat_rm.texi: Regenerate.
2022-10-06ada: hardened conditionals: exemplify codegen changesAlexandre Oliva2-4/+94
gcc/ada/ * doc/gnat_rm/security_hardening_features.rst: Add examples of codegen changes in hardened conditionals. * gnat_rm.texi: Regenerate.
2022-10-06ada: hardened booleans: exemplify codegen changesAlexandre Oliva2-7/+48
Show the sort of code that is to be expected from using hardened booleans in Ada code. Mention that C traps instead of raising exceptions. gcc/ada/ * doc/gnat_rm/security_hardening_features.rst: Add examples of codegen changes in hardened booleans. Mention that C traps where Ada raises exceptions. * gnat_rm.texi: Regenerate.
2022-10-06ada: stack scrubbing: exemplify codegen changesAlexandre Oliva2-2/+103
gcc/ada/ * doc/gnat_rm/security_hardening_features.rst: Add examples of codegen changes in stack scrubbing. * gnat_rm.texi: Regenerate.
2022-10-06ada: Fix inserting of validity checks in lock-free protected subprogramsPiotr Trojanek1-1/+1
Validity checks for statements in a lock-free implementation of protected subprogram were wrongly inserted in front of the original statements. This happened because the lock-free implementation was created as a shallow copy, where only the protected body statements were copied while its children still had the Parent pointing to the original statements. gcc/ada/ * exp_ch9.adb (Build_Lock_Free_Protected_Subprogram_Body): Replace shallow copy of protected statements with a deep copy.
2022-10-06ada: Add C declarations for Storage Model supportMarc Poulhiès2-0/+20
Add needed C declarations for Storage Model support in gigi. gcc/ada/ * fe.h (Has_Storage_Model_Type_Aspect) (Has_Designated_Storage_Model_Aspect, Storage_Model_Object) (Storage_Model_Copy_From, Storage_Model_Copy_To): Add declarations. * sem_util.ads: Add WARNING markers for functions for which a new C declaration has been added in fe.h
2022-10-06ada: Incorrect inferences drawn from if/elsif/while conditions with -gnatVoSteve Baird1-1/+16
Within the first (respectively, second) statement list of this if statement declare X : constant Integer := ... ; begin if X > 0 then ...; else ...; end if; end; we can safely assume that X is greater (respectively, not greater) than 0. Fix a bug that incorrectly computed the region in which such assumptions can be made to include the condition of the if-statement. This bug usually had no effect because semantic analysis/simplification of the condition was already complete before the code containing the bug was executed. Unfortunately, this is not true in some cases involving -gnatVo validity checking. In these cases, the bug could result in incorrect simplification of the condition at compile time. This, in turn, could lead to incorrect unconditional execution of one arm of the if-statement at run time. Similar errors appear to be possible for the conditions of an elsif or a while loop; the fix addresses these cases as well, although corresponding problems with these constructs have not been demonstrated. gcc/ada/ * exp_util.adb (Get_Current_Value_Condition): Treat references occurring within the condition of an if statement, an elsif, or a while loop in the same way as references that occur before the start of that enclosing construct.
2022-10-06ada: Accessibility error incorrectly flagged on call within Pre'Class expressionGary Dismukes1-1/+6
The compiler was wrongly reporting an error on a function call within a Pre'Class expression when a formal of the aspect's subprogram was passed to an aliased formal. This occurred due to the call appearing with the return statement of the wrapper function created for the precondition, but the accessibility error check should only be done for return statements that appear in the source program. gcc/ada/ * sem_ch4.adb (Analyze_Call): Add test of Comes_From_Source on the enclosing subprogram's Entity_Id for determining whether to perform the compile-time accessibility check on actuals passed to aliased formals in a function call occurring within a return statement. That test excludes cases where the call occurs within the return statement of a Pre'Class wrapper function.