diff options
author | Martin Liska <mliska@suse.cz> | 2021-06-30 06:49:12 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2021-06-30 06:49:12 +0200 |
commit | 7445abec5d383d37a2f827657dafa12053179c6e (patch) | |
tree | e838ed44a39c986af901507cdf2390d4310619d9 | |
parent | 490d1e1be15b62b51a2de248e6d7f76356402bc9 (diff) | |
parent | 35da8a98026849bd20d16bbf9210ac1d0b44ea6a (diff) | |
download | gcc-7445abec5d383d37a2f827657dafa12053179c6e.zip gcc-7445abec5d383d37a2f827657dafa12053179c6e.tar.gz gcc-7445abec5d383d37a2f827657dafa12053179c6e.tar.bz2 |
Merge branch 'master' into devel/sphinx
126 files changed, 2187 insertions, 825 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index aac08e6..468d83f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -666,6 +666,7 @@ Przemyslaw Wirkus <przemyslaw.wirkus@arm.com> Carlo Wood <carlo@alinoe.com> Jackson Woodruff <jackson.woodruff@arm.com> Jonathan Wright <jonathan.wright@arm.com> +Ruoyao Xi <xry111@mengyan1223.wang> Mingjie Xing <mingjie.xing@gmail.com> Chenghua Xu <paul.hua.gm@gmail.com> Canqun Yang <canqun@nudt.edu.cn> diff --git a/fixincludes/fixfixes.c b/fixincludes/fixfixes.c index 5b23a8b..404b420 100644 --- a/fixincludes/fixfixes.c +++ b/fixincludes/fixfixes.c @@ -477,6 +477,39 @@ FIX_PROC_HEAD( char_macro_def_fix ) fputs (text, stdout); } +/* Check if the pattern at pos is actually in a "__has_include(...)" + directive. Return the pointer to the ')' of this + "__has_include(...)" if it is, NULL otherwise. */ +static const char * +check_has_inc (const char *begin, const char *pos, const char *end) +{ + static const char has_inc[] = "__has_include"; + const size_t has_inc_len = sizeof (has_inc) - 1; + const char *p; + + for (p = memmem (begin, pos - begin, has_inc, has_inc_len); + p != NULL; + p = memmem (p, pos - p, has_inc, has_inc_len)) + { + p += has_inc_len; + while (p < end && ISSPACE (*p)) + p++; + + /* "__has_include" may appear as "defined(__has_include)", + search for the next appearance then. */ + if (*p != '(') + continue; + + /* To avoid too much complexity, just hope there is never a + ')' in a header name. */ + p = memchr (p, ')', end - p); + if (p == NULL || p > pos) + return p; + } + + return NULL; +} + /* Fix for machine name #ifdefs that are not in the namespace reserved by the C standard. They won't be defined if compiling with -ansi, and the headers will break. We go to some trouble to only change @@ -524,7 +557,7 @@ FIX_PROC_HEAD( machine_name_fix ) /* If the 'name_pat' matches in between base and limit, we have a bogon. It is not worth the hassle of excluding comments because comments on #if/#ifdef lines are rare, and strings on - such lines are illegal. + such lines are only legal in a "__has_include" directive. REG_NOTBOL means 'base' is not at the beginning of a line, which shouldn't matter since the name_re has no ^ anchor, but let's @@ -544,8 +577,16 @@ FIX_PROC_HEAD( machine_name_fix ) break; p = base + match[0].rm_so; - base += match[0].rm_eo; + /* Check if the match is in __has_include(...) (PR 91085). */ + q = check_has_inc (base, p, limit); + if (q) + { + base = q + 1; + goto again; + } + + base += match[0].rm_eo; /* One more test: if on the same line we have the same string with the appropriate underscores, then leave it alone. We want exactly two leading and trailing underscores. */ diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def index 3a4cfe0..4db3117 100644 --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -3151,7 +3151,8 @@ fix = { c_fix = machine_name; test_text = "/* MACH_DIFF: */\n" - "#if defined( i386 ) || defined( sparc ) || defined( vax )" + "#if defined( i386 ) || defined( sparc ) || defined( vax ) || " + "defined( linux ) || __has_include ( <linux.h> )" "\n/* no uniform test, so be careful :-) */"; }; diff --git a/fixincludes/tests/base/testing.h b/fixincludes/tests/base/testing.h index cf95321..8b3acca 100644 --- a/fixincludes/tests/base/testing.h +++ b/fixincludes/tests/base/testing.h @@ -64,7 +64,7 @@ BSD43__IOWR('T', 1) /* Some are multi-line */ #if defined( MACHINE_NAME_CHECK ) /* MACH_DIFF: */ -#if defined( i386 ) || defined( sparc ) || defined( vax ) +#if defined( i386 ) || defined( sparc ) || defined( vax ) || defined( linux ) || __has_include ( <linux.h> ) /* no uniform test, so be careful :-) */ #endif /* MACHINE_NAME_CHECK */ diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f8e3401..52d2397 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,142 @@ +2021-06-29 Sergei Trofimovich <siarheit@google.com> + + * doc/generic.texi: Fix s/net yet/not yet/ typo. + +2021-06-29 Andrew MacLeod <amacleod@redhat.com> + + PR tree-optimization/101254 + * range-op.cc (operator_minus::op1_op2_relation_effect): Check for + wrapping/non-wrapping when setting the result range. + +2021-06-29 Andrew MacLeod <amacleod@redhat.com> + + * value-query.cc (gimple_range_global): Allow phis. + +2021-06-29 Andrew MacLeod <amacleod@redhat.com> + + * vr-values.c (vr_values::vrp_stmt_computes_nonzero): Use stmt. + (simplify_using_ranges::op_with_boolean_value_range_p): Add a + statement for location context. + (check_for_binary_op_overflow): Ditto. + (simplify_using_ranges::get_vr_for_comparison): Ditto. + (simplify_using_ranges::compare_name_with_value): Ditto. + (simplify_using_ranges::compare_names): Ditto. + (vrp_evaluate_conditional_warnv_with_ops_using_ranges): Ditto. + (simplify_using_ranges::simplify_truth_ops_using_ranges): Ditto. + (simplify_using_ranges::simplify_min_or_max_using_ranges): Ditto. + (simplify_using_ranges::simplify_internal_call_using_ranges): Ditto. + (simplify_using_ranges::two_valued_val_range_p): Ditto. + (simplify_using_ranges::simplify): Ditto. + * vr-values.h: Adjust prototypes. + +2021-06-29 Uroš Bizjak <ubizjak@gmail.com> + + PR target/95046 + * config/i386/mmx.md (vec_addsubv2sf3): New insn pattern. + +2021-06-29 Julian Brown <julian@codesourcery.com> + + * config/gcn/gcn.c (gcn_init_libfuncs): New function. + (TARGET_INIT_LIBFUNCS): Define target hook using above function. + * config/gcn/gcn.h (UNITS_PER_WORD): Define to 8 for IN_LIBGCC2, 4 + otherwise. + (LIBGCC2_UNITS_PER_WORD, BITS_PER_WORD): Remove definitions. + (MAX_FIXED_MODE_SIZE): Change to 128. + +2021-06-29 Julian Brown <julian@codesourcery.com> + + * config/gcn/gcn.md (UNSPEC_FLBIT_INT): New unspec constant. + (s_mnemonic): Add clrsb. + (gcn_flbit<mode>_int): Add insn pattern for SImode/DImode. + (clrsb<mode>2): Add expander for SImode/DImode. + +2021-06-29 Julian Brown <julian@codesourcery.com> + + * config/gcn/gcn.md (<su>mulsidi3, <su>mulsidi3_reg, <su>mulsidi3_imm, + muldi3): Add patterns. + +2021-06-29 Julian Brown <julian@codesourcery.com> + + * config/gcn/gcn.md (<su>mulsi3_highpart): Change to expander. + (<su>mulsi3_highpart_reg, <su>mulsi3_highpart_imm): New patterns. + +2021-06-29 Julian Brown <julian@codesourcery.com> + + * config/gcn/gcn.md (mulsi3): Make s_mulk_i32 variant clobber SCC. + +2021-06-29 Joseph Myers <joseph@codesourcery.com> + + * btfout.c, ctfout.c: Include "memmodel.h". + +2021-06-29 Tobias Burnus <tobias@codesourcery.com> + + * gcc.c (check_offload_target_name): Cast len argument to + %q.*s to 'int'; avoid -Wstringop-truncation warning. + +2021-06-29 Richard Biener <rguenther@suse.de> + + * tree-vect-slp.c (vect_optimize_slp): Forward propagate + to "any" permute nodes and relax "any" permute proapgation + during iterative backward propagation. + +2021-06-29 Tobias Burnus <tobias@codesourcery.com> + + PR other/67300 + * common.opt (-foffload=): Update description. + (-foffload-options=): New. + * doc/invoke.texi (C Language Options): Document + -foffload and -foffload-options. + * gcc.c (check_offload_target_name): New, split off from + handle_foffload_option. + (check_foffload_target_names): New. + (handle_foffload_option): Handle -foffload=default. + (driver_handle_option): Update for -foffload-options. + * lto-opts.c (lto_write_options): Use -foffload-options + instead of -foffload. + * lto-wrapper.c (merge_and_complain, append_offload_options): + Likewise. + * opts.c (common_handle_option): Likewise. + +2021-06-29 Tobias Burnus <tobias@codesourcery.com> + + * doc/invoke.texi (C Language Options): Sort options + alphabetically in optlist and also the description itself. + Remove leftover -fallow-single-precision from and add missing + -fgnu-tm to the optlist. + +2021-06-29 Richard Biener <rguenther@suse.de> + + * tree-vect-slp.c (slpg_vertex::visited): Remove. + (vect_slp_perms_eq): Handle -1 permutes. + (vect_optimize_slp): Rewrite permute propagation. + +2021-06-29 Jakub Jelinek <jakub@redhat.com> + + PR c++/101210 + * match.pd ((intptr_t)x eq/ne CST to x eq/ne (typeof x) CST): Don't + perform the optimization in GENERIC when sanitizing and x has a + reference type. + +2021-06-29 Richard Biener <rguenther@suse.de> + + PR tree-optimization/101242 + * tree-vect-slp.c (vect_slp_build_vertices): Force-add + PHIs with not represented initial values as leafs. + +2021-06-29 Jan-Benedict Glaw <jbglaw@getslash.de> + + * config/pdp11/pdp11.h (ASM_OUTPUT_SKIP): Fix signedness warning. + * config/pdp11/pdp11.c (pdp11_asm_print_operand_punct_valid_p): Remove + "register" keyword. + (pdp11_initial_elimination_offset) Remove unused variable. + (pdp11_cmp_length) Ditto. + (pdp11_insn_cost): Ditto, and fix signedness warning. + +2021-06-29 David Edelsohn <dje.gcc@gmail.com> + + * btfout.c: Include tm_p.h. + * ctfout.c: Same. + 2021-06-28 Indu Bhagat <indu.bhagat@oracle.com> * config/bpf/bpf.c (bpf_expand_prologue): Do not mark insns as diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index f814e09..80bc3a6 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20210629 +20210630 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0841a93..f07cc96 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,244 @@ +2021-06-29 Richard Kenner <kenner@adacore.com> + + * sem_util.adb (Visit_Node): Add handling for N_Block_Statement + with declarations. + +2021-06-29 Piotr Trojanek <trojanek@adacore.com> + + * einfo-utils.adb + (Unknown_Alignment): Simply negate the Known_ counterpart. + (Unknown_Component_Bit_Offset): Likewise. + (Unknown_Esize): Likewise. + (Unknown_Normalized_First_Bit): Likewise. + (Unknown_Normalized_Position): Likewise. + (Unknown_Normalized_Position_Max): Likewise. + (Unknown_RM_Size): Likewise. + +2021-06-29 Boris Yakobowski <yakobowski@adacore.com> + + * exp_ch4.adb (Expand_N_Op_Mod): Remove special case for mod -1 + in CodePeer_Mode. + +2021-06-29 Aleksandra Pasek <pasek@adacore.com> + + * libgnat/s-objrea.adb (EM_AARCH64): New Constant. + (Initialize): Handle EM_AARCH64 case. + (Read_Address): Handle AARCH64 case. + * libgnat/s-objrea.ads (Object_Arch): Add AARCH64 record + component. + +2021-06-29 Bob Duff <duff@adacore.com> + + * sem_ch13.adb (Analyze_Record_Representation_Clause): Call + Set_Entity_With_Checks instead of Set_Entity, so we perform the + check for correct casing. + * style.adb (Check_Identifier): Minor comment improvement. + Cleanup overly complicated code. + +2021-06-29 Ed Schonberg <schonberg@adacore.com> + + * exp_aggr.adb (Convert_Aggr_In_Object_Decl): After expansion of + the aggregate, the expression can be removed from the + declaration, except if the object is class-wide, in which case + the aggregate provides the actual type. In other cases the + presence of the expression may lead to spurious freezing issue. + * exp_ch3.adb (Expand_N_Object_Declaration): If the expression + in the declaration is an aggregate with delayed expansion (as is + the case for objects of a limited type, or a subsequent address + specification) the aggregate must be resolved at this point. + This resolution must not include expansion, because the + expansion of the enclosing declaration will construct the + necessary aggregate expansion. + +2021-06-29 Piotr Trojanek <trojanek@adacore.com> + + * errout.ads (Adjust_Name_Case): Remove obsolete and now unused + variant. + * errout.adb (Adjust_Name_Case): Likewise; fix variant that uses + a custom buffer to also use it for names in Standard_Location. + +2021-06-29 Eric Botcazou <ebotcazou@adacore.com> + + * sem_ch12.adb (Freeze_Subprogram_Body): Add missing "freeze". + (Install_Body): Likewise. + +2021-06-29 Piotr Trojanek <trojanek@adacore.com> + + * adaint.c (__gnat_portable_spawn): Revert change that + introduced setting of __gnat_in_child_after_fork. + +2021-06-29 Patrick Bernardi <bernardi@adacore.com> + + * libgnarl/s-tasdeb.ads (Known_Tasks): Add Atomic_Components + aspect. + +2021-06-29 Doug Rupp <rupp@adacore.com> + + * Makefile.rtl (x86_64-vx7r2) [EXTRA_GNATRTL_TASKING_OBJS]: Move + i-vxinco.o out of RTP runtime. + +2021-06-29 Claire Dross <dross@adacore.com> + + * libgnat/a-cfdlli.ads: Use pragma Assertion_Policy to disable + pre and postconditions. + * libgnat/a-cfhama.ads: Likewise. + * libgnat/a-cfhase.ads: Likewise. + * libgnat/a-cfinve.ads: Likewise. + * libgnat/a-cforma.ads: Likewise. + * libgnat/a-cforse.ads: Likewise. + * libgnat/a-cofove.ads: Likewise. + +2021-06-29 Piotr Trojanek <trojanek@adacore.com> + + * sem_util.ads (Get_Fullest_View): Refill comment; remove extra + extra after period. + * sem_util.adb (Get_Fullest_View): Fix style. + +2021-06-29 Piotr Trojanek <trojanek@adacore.com> + + * sem_ch3.adb (Analyze_Declarations): Remove explicit check for + missing, because a subsequent call to Is_Empty_List will detect + them anyway. + +2021-06-29 Piotr Trojanek <trojanek@adacore.com> + + * freeze.adb (Freeze_All): Simplify by reusing + Is_Subprogram_Or_Entry. + * sem_ch11.adb (Analyze_Handled_Statement): Likewise. + +2021-06-29 Piotr Trojanek <trojanek@adacore.com> + + * sem_warn.adb (Warn_On_Overlapping_Actuals): Prevent cascaded + errors once for the subprogram call, not for every pair of + actual parameters. + +2021-06-29 Piotr Trojanek <trojanek@adacore.com> + + * sem_ch3.adb (Is_Local_Type): Simplify by reusing Scope_Within. + +2021-06-29 Gary Dismukes <dismukes@adacore.com> + + * sem_ch6.ads (Can_Override_Operator): Function declaration + moved from package body to package spec. + * sem_ch6.adb (Check_Overriding_Indicator): Now use test of + whether the subprogram's Chars is an operator name, to handle + cases of function instances whose entity is + N_Defining_Identifier rather than N_Defining_Operator_Symbol. + (Can_Override_Operator): Function declaration moved to package + spec. Now use test of whether the subprogram's Chars is an + operator name, to handle cases of function instances whose + entity is N_Defining_Identifier rather than + N_Defining_Operator_Symbol. + * sem_ch8.adb (Analyze_Renamed_Subprogram): Check for + possibility of an overridden predefined operator, and suppress + the "not overriding" message in that case. + +2021-06-29 Doug Rupp <rupp@adacore.com> + + * Makefile.rtl: Add a new ifeq for vx7r2 shared gnatlib. + +2021-06-29 Piotr Trojanek <trojanek@adacore.com> + + * exp_attr.adb (Build_Array_VS_Func): Restore uses of + Validated_View. + (Build_Record_VS_Func): Likewise. + (Expand_N_Attribute_Reference): Likewise. + * sem_util.adb (Validated_View): Behave as an identity function + for arrays and scalars. + +2021-06-29 Bob Duff <duff@adacore.com> + + * atree.adb, atree.ads (Parent, Set_Parent): Assert node is + Present. + (Copy_Parent, Parent_Kind): New helper routines. + * gen_il-gen.adb: Add with clause. + * nlists.adb (Parent): Assert Parent of list is Present. + * aspects.adb, checks.adb, exp_aggr.adb, exp_ch6.adb, + exp_util.adb, lib-xref-spark_specific.adb, osint.ads, + sem_ch12.adb, sem_ch13.adb, sem_ch3.adb, sem_ch6.adb, + sem_dim.adb, sem_prag.adb, sem_res.adb, sem_util.adb, + treepr.adb: Do not call Parent and Set_Parent on the Empty node. + * libgnat/a-stwiun__shared.adb, libgnat/a-stzunb__shared.adb: + Minor: Fix typos in comments. + * einfo.ads: Minor comment update. + * sinfo-utils.ads, sinfo-utils.adb (Parent_Kind, Copy_Parent): + New functions. + +2021-06-29 Eric Botcazou <ebotcazou@adacore.com> + + * repinfo-input.adb (Read_JSON_Stream): Fix typo. + +2021-06-29 Eric Botcazou <ebotcazou@adacore.com> + + * rtsfind.ads (RE_Id): Change RE_Valid_Enumeration_Value_NN into + RE_Valid_Value_Enumeration_NN. + (RE_Unit_Table): Adjust to above renaming. + * exp_imgv.adb (Expand_Valid_Value_Attribute): Likewise. + * libgnat/s-valuen.ads (Invalid): Remove. + (Value_Enumeration_Pos): Move to... + * libgnat/s-valuen.adb (Value_Enumeration_Pos): ...here. + Return -1 instead of Invalid. + (Value_Enumeration): Compare against 0 instead of Invalid. + (Valid_Enumeration_Value): Likewise. Rename to... + (Valid_Value_Enumeration): ...this. + * libgnat/s-vaenu8.ads (Valid_Enumeration_Value_8): Rename into... + (Valid_Value_Enumeration_8): ...this. + * libgnat/s-vaen16.ads (Valid_Enumeration_Value_16): Rename into... + (Valid_Value_Enumeration_16): ...this. + * libgnat/s-vaen32.ads (Valid_Enumeration_Value_32): Rename into... + (Valid_Value_Enumeration_32): ...this. + +2021-06-29 Bob Duff <duff@adacore.com> + + * einfo.ads (Component_Bit_Offset, Component_Size): Update + documentation: Repinfo is the package where these negative + values are documented. + * einfo-utils.adb (Known_Component_Size, + Known_Static_Component_Size, Unknown_Component_Size): Remove + calls to Implementation_Base_Type, because Component_Size is an + Impl_Base_Type_Only field (see Gen_Entities). + * sem_ch13.ads, sem_ch13.adb (Check_Size): Do not set Esize and + RM_Size. This is unnecessary in the case of Size. For + Component_Size, it is wrong, because we would be setting the + Esize and RM_Size of the component type. + +2021-06-29 Pascal Obry <obry@adacore.com> + + * s-oscons-tmplt.c: Add some OS constants. + +2021-06-29 Piotr Trojanek <trojanek@adacore.com> + + * sem_util.ads (Validated_View): Fix style in comment. + * sem_util.adb (Validated_View): Rewrite in recursive style. + +2021-06-29 Eric Botcazou <ebotcazou@adacore.com> + + * Make-generated.in (ada/stamp-gen_il): Ignore errors from + running gen_il-main. + +2021-06-29 Richard Kenner <kenner@adacore.com> + + * gen_il-gen-gen_entities.adb (Record_Field_Kind, + Allocatable_Kind): Add new abstract kinds. + (Constant_Or_Variable_Kind): Likewise. + (E_Constant, E_Variable, E_Loop_Parameter): Use them. + (E_Discriminant, E_Component): Likewise. + * gen_il-types.ads (type Opt_Type_Enum): Add them. + +2021-06-29 Bob Duff <duff@adacore.com> + + * gen_il-gen.adb (Put_C_Type_And_Subtypes): Put the correct + numbers. + * gen_il-internals.ads, gen_il-internals.adb: (Pos): Remove this + function. It was assuming that the order of the enumeration + literals in Type_Enum is the same as the order of the generated + types Node_Kind and Entity_Kind, which is not true. + +2021-06-29 Piotr Trojanek <trojanek@adacore.com> + + * exp_attr.adb (Expand_N_Attribute_Reference): Explicitly use + Validated_View for record objects. + 2021-06-28 Martin Sebor <msebor@redhat.com> * gcc-interface/trans.c (Handled_Sequence_Of_Statements_to_gnu): diff --git a/gcc/ada/Make-generated.in b/gcc/ada/Make-generated.in index 129909b..7d452b8 100644 --- a/gcc/ada/Make-generated.in +++ b/gcc/ada/Make-generated.in @@ -18,7 +18,9 @@ GEN_IL_FLAGS = -gnata -gnat2012 -gnatw.g -gnatyg -gnatU $(GEN_IL_INCLUDES) ada/seinfo_tables.ads ada/seinfo_tables.adb ada/sinfo.h ada/einfo.h ada/nmake.ads ada/nmake.adb ada/seinfo.ads ada/sinfo-nodes.ads ada/sinfo-nodes.adb ada/einfo-entities.ads ada/einfo-entities.adb: ada/stamp-gen_il ; @true ada/stamp-gen_il: $(fsrcdir)/ada/gen_il* $(MKDIR) ada/gen_il - cd ada/gen_il ; gnatmake -q -g $(GEN_IL_FLAGS) gen_il-main ; ./gen_il-main + cd ada/gen_il; gnatmake -q -g $(GEN_IL_FLAGS) gen_il-main + # Ignore errors to work around finalization issues in older compilers + - cd ada/gen_il; ./gen_il-main $(fsrcdir)/../move-if-change ada/gen_il/seinfo_tables.ads ada/seinfo_tables.ads $(fsrcdir)/../move-if-change ada/gen_il/seinfo_tables.adb ada/seinfo_tables.adb $(fsrcdir)/../move-if-change ada/gen_il/sinfo.h ada/sinfo.h diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index f626c5d..ff46200 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1200,13 +1200,6 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworks vxworksspe vxworks7% vxworks7spe GCC_SPEC_FILES+=vxworks-cert-$(ARCH_STR)-link.spec GCC_SPEC_FILES+=vxworks-smp-$(ARCH_STR)-link.spec endif - - ifeq ($(strip $(filter-out vxworks7r2 powerpc64 rtp rtp-smp, $(target_os) $(target_cpu) $(THREAD_KIND))),) - # Shared libraries are only supported on PowerPC64, VxWorks7r2 - # ATM. Also this is disabled for kernel runtimes. - GNATLIB_SHARED = gnatlib-shared-dual - LIBRARY_VERSION := $(LIB_VERSION) - endif endif # PowerPC and e500v2 VxWorks 653 @@ -1464,12 +1457,12 @@ ifeq ($(strip $(filter-out %86 x86_64 wrs vxworks vxworks7%,$(target_cpu) $(targ endif endif - EXTRA_GNATRTL_NONTASKING_OBJS += i-vxwork.o i-vxwoio.o + EXTRA_GNATRTL_NONTASKING_OBJS += i-vxinco.o i-vxwork.o i-vxwoio.o endif endif EXTRA_GNATRTL_NONTASKING_OBJS += s-stchop.o - EXTRA_GNATRTL_TASKING_OBJS += i-vxinco.o s-vxwork.o s-vxwext.o + EXTRA_GNATRTL_TASKING_OBJS += s-vxwork.o s-vxwext.o EXTRA_LIBGNAT_OBJS+=vx_stack_info.o @@ -2973,6 +2966,13 @@ ifeq ($(strip $(filter-out linux%,$(target_os))),) g-sercom.adb<libgnat/g-sercom__linux.adb endif +# Turn on shared gnatlib for specific vx7r2 targets for RTP runtimes. Once +# all targets are ported the target_cpu selector can be removed. +ifeq ($(strip $(filter-out vxworks7r2 powerpc64 x86_64 rtp rtp-smp, $(target_os) $(target_cpu) $(THREAD_KIND))),) + GNATLIB_SHARED = gnatlib-shared-dual + LIBRARY_VERSION := $(LIB_VERSION) +endif + LIBGNAT_TARGET_PAIRS += \ interfac.ads<libgnat/interfac__2020.ads diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 7770300..b2d4de6 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -2423,7 +2423,6 @@ __gnat_portable_spawn (char *args[] ATTRIBUTE_UNUSED) if (pid == 0) { /* The child. */ - __gnat_in_child_after_fork = 1; if (execv (args[0], MAYBE_TO_PTR32 (args)) != 0) _exit (1); } diff --git a/gcc/ada/aspects.adb b/gcc/ada/aspects.adb index 22ae9c4..a6e4f28 100644 --- a/gcc/ada/aspects.adb +++ b/gcc/ada/aspects.adb @@ -241,6 +241,10 @@ package body Aspects is -- find the declaration node where the aspects reside. This is usually -- the parent or the parent of the parent. + if No (Parent (Owner)) then + return Empty; + end if; + Decl := Parent (Owner); if not Permits_Aspect_Specifications (Decl) then Decl := Parent (Decl); @@ -488,6 +492,7 @@ package body Aspects is function Permits_Aspect_Specifications (N : Node_Id) return Boolean is begin + pragma Assert (Present (N)); return Has_Aspect_Specifications_Flag (Nkind (N)); end Permits_Aspect_Specifications; diff --git a/gcc/ada/atree.adb b/gcc/ada/atree.adb index be03c97..33cde5a 100644 --- a/gcc/ada/atree.adb +++ b/gcc/ada/atree.adb @@ -1232,7 +1232,9 @@ package body Atree is if Field in Node_Range then New_N := Union_Id (Copy_Separate_Tree (Node_Id (Field))); - if Parent (Node_Id (Field)) = Source then + if Present (Node_Id (Field)) + and then Parent (Node_Id (Field)) = Source + then Set_Parent (Node_Id (New_N), New_Id); end if; @@ -1801,16 +1803,14 @@ package body Atree is end if; end Paren_Count; - ------------ - -- Parent -- - ------------ - - function Parent (N : Node_Id) return Node_Id is + function Parent (N : Node_Or_Entity_Id) return Node_Or_Entity_Id is begin + pragma Assert (Atree.Present (N)); + if Is_List_Member (N) then return Parent (List_Containing (N)); else - return Node_Id (Link (N)); + return Node_Or_Entity_Id (Link (N)); end if; end Parent; @@ -2126,9 +2126,9 @@ package body Atree is -- Set_Parent -- ---------------- - procedure Set_Parent (N : Node_Id; Val : Node_Id) is + procedure Set_Parent (N : Node_Or_Entity_Id; Val : Node_Or_Entity_Id) is begin - pragma Assert (not Locked); + pragma Assert (Atree.Present (N)); pragma Assert (not In_List (N)); Set_Link (N, Union_Id (Val)); end Set_Parent; diff --git a/gcc/ada/atree.ads b/gcc/ada/atree.ads index 3522753..0995b94 100644 --- a/gcc/ada/atree.ads +++ b/gcc/ada/atree.ads @@ -414,34 +414,34 @@ package Atree is -- The following functions return the contents of the indicated field of -- the node referenced by the argument, which is a Node_Id. - function No (N : Node_Id) return Boolean; + function No (N : Node_Id) return Boolean; pragma Inline (No); -- Tests given Id for equality with the Empty node. This allows notations -- like "if No (Variant_Part)" as opposed to "if Variant_Part = Empty". - function Parent (N : Node_Id) return Node_Id; + function Parent (N : Node_Or_Entity_Id) return Node_Or_Entity_Id; pragma Inline (Parent); -- Returns the parent of a node if the node is not a list member, or else -- the parent of the list containing the node if the node is a list member. - function Paren_Count (N : Node_Id) return Nat; + function Paren_Count (N : Node_Id) return Nat; pragma Inline (Paren_Count); -- Number of parentheses that surround an expression - function Present (N : Node_Id) return Boolean; + function Present (N : Node_Id) return Boolean; pragma Inline (Present); -- Tests given Id for inequality with the Empty node. This allows notations -- like "if Present (Statement)" as opposed to "if Statement /= Empty". - procedure Set_Original_Node (N : Node_Id; Val : Node_Id); + procedure Set_Original_Node (N : Node_Id; Val : Node_Id); pragma Inline (Set_Original_Node); -- Note that this routine is used only in very peculiar cases. In normal -- cases, the Original_Node link is set by calls to Rewrite. - procedure Set_Parent (N : Node_Id; Val : Node_Id); + procedure Set_Parent (N : Node_Or_Entity_Id; Val : Node_Or_Entity_Id); pragma Inline (Set_Parent); - procedure Set_Paren_Count (N : Node_Id; Val : Nat); + procedure Set_Paren_Count (N : Node_Id; Val : Nat); pragma Inline (Set_Paren_Count); --------------------------- diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 907641f..1a39a82 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -2713,6 +2713,10 @@ package body Checks is Subp_Spec := Parent (Subp); + if No (Subp_Spec) then + return; + end if; + if Nkind (Subp_Spec) = N_Defining_Program_Unit_Name then Subp_Spec := Parent (Subp_Spec); end if; diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 0641862..6e8a772 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -515,8 +515,8 @@ package body Einfo.Utils is function Known_Component_Size (E : Entity_Id) return B is begin - return Component_Size (Implementation_Base_Type (E)) /= Uint_0 - and then Component_Size (Implementation_Base_Type (E)) /= No_Uint; + return Component_Size (E) /= Uint_0 + and then Component_Size (E) /= No_Uint; end Known_Component_Size; function Known_Esize (E : Entity_Id) return B is @@ -556,7 +556,7 @@ package body Einfo.Utils is function Known_Static_Component_Size (E : Entity_Id) return B is begin - return Component_Size (Implementation_Base_Type (E)) > Uint_0; + return Component_Size (E) > Uint_0; end Known_Static_Component_Size; function Known_Static_Esize (E : Entity_Id) return B is @@ -593,50 +593,42 @@ package body Einfo.Utils is function Unknown_Alignment (E : Entity_Id) return B is begin - return Alignment (E) = Uint_0 - or else Alignment (E) = No_Uint; + return not Known_Alignment (E); end Unknown_Alignment; function Unknown_Component_Bit_Offset (E : Entity_Id) return B is begin - return Component_Bit_Offset (E) = No_Uint; + return not Known_Component_Bit_Offset (E); end Unknown_Component_Bit_Offset; function Unknown_Component_Size (E : Entity_Id) return B is begin - return Component_Size (Implementation_Base_Type (E)) = Uint_0 - or else - Component_Size (Implementation_Base_Type (E)) = No_Uint; + return not Known_Component_Size (E); end Unknown_Component_Size; function Unknown_Esize (E : Entity_Id) return B is begin - return Esize (E) = No_Uint - or else - Esize (E) = Uint_0; + return not Known_Esize (E); end Unknown_Esize; function Unknown_Normalized_First_Bit (E : Entity_Id) return B is begin - return Normalized_First_Bit (E) = No_Uint; + return not Known_Normalized_First_Bit (E); end Unknown_Normalized_First_Bit; function Unknown_Normalized_Position (E : Entity_Id) return B is begin - return Normalized_Position (E) = No_Uint; + return not Known_Normalized_Position (E); end Unknown_Normalized_Position; function Unknown_Normalized_Position_Max (E : Entity_Id) return B is begin - return Normalized_Position_Max (E) = No_Uint; + return not Known_Normalized_Position_Max (E); end Unknown_Normalized_Position_Max; function Unknown_RM_Size (E : Entity_Id) return B is begin - return (RM_Size (E) = Uint_0 - and then not Is_Discrete_Type (E) - and then not Is_Fixed_Point_Type (E)) - or else RM_Size (E) = No_Uint; + return not Known_RM_Size (E); end Unknown_RM_Size; -------------------- diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 4c5a2da..70b93b3 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -669,7 +669,7 @@ package Einfo is -- this field is always set. A negative value is used to represent -- a value which is not known at compile time, and must be computed -- at run-time (this happens if fields of a record have variable --- lengths). See package Layout for details of these values. +-- lengths). See package Repinfo for details of these values. -- -- Note: Component_Bit_Offset is redundant with respect to the fields -- Normalized_First_Bit and Normalized_Position, and could in principle @@ -691,8 +691,9 @@ package Einfo is -- by the front end in package Layout, or by the backend. A negative -- value is used to represent a value which is not known at compile -- time, and must be computed at run-time (this happens if the type --- of the component has a variable length size). See package Layout --- for details of these values. +-- of the component has a variable length size). See package Repinfo +-- for details of these values. Component_Size can also be negative in +-- an illegal program that says e.g. "for T'Component_Size use -8;". -- Component_Type [implementation base type only] -- Defined in array types and string types. References component type. @@ -5087,9 +5088,9 @@ package Einfo is -- Applicable attributes by entity kind -- ------------------------------------------ - -- In the conversion to variable-sized nodes and entities, which is an - -- ongoing project, a number of discrepancies were noticed. They are - -- documented in comments, and marked with "$$$". + -- In the conversion to variable-sized nodes and entities, a number of + -- discrepancies were noticed. They are documented in comments, and marked + -- with "$$$". -- E_Abstract_State -- Refinement_Constituents diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index f643c8d..8fd2076 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -3402,7 +3402,7 @@ package body Errout is -- For standard locations, always use mixed case if Loc <= No_Location then - Set_Casing (Mixed_Case); + Set_Casing (Buf, Mixed_Case); else -- Determine if the reference we are dealing with corresponds to @@ -3440,11 +3440,6 @@ package body Errout is end; end Adjust_Name_Case; - procedure Adjust_Name_Case (Loc : Source_Ptr) is - begin - Adjust_Name_Case (Global_Name_Buffer, Loc); - end Adjust_Name_Case; - --------------------------- -- Set_Identifier_Casing -- --------------------------- diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads index 904c87d..b0cbd82 100644 --- a/gcc/ada/errout.ads +++ b/gcc/ada/errout.ads @@ -985,10 +985,6 @@ package Errout is -- the name at that source location, we copy the casing from the source, -- otherwise we set appropriate default casing. - procedure Adjust_Name_Case (Loc : Source_Ptr); - -- Uses Buf => Global_Name_Buffer. There are no calls to this in the - -- compiler, but it is called in SPARK 2014. - procedure Set_Identifier_Casing (Identifier_Name : System.Address; File_Name : System.Address); diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 2e772ed..56ec1be 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -1920,7 +1920,7 @@ package body Exp_Aggr is function Gen_Loop (L, H : Node_Id; Expr : Node_Id) return List_Id is Is_Iterated_Component : constant Boolean := - Nkind (Parent (Expr)) = N_Iterated_Component_Association; + Parent_Kind (Expr) = N_Iterated_Component_Association; L_J : Node_Id; @@ -2436,7 +2436,7 @@ package body Exp_Aggr is Expr := Get_Assoc_Expr (Others_Assoc); Dup_Expr := New_Copy_Tree (Expr); - Set_Parent (Dup_Expr, Parent (Expr)); + Copy_Parent (To => Dup_Expr, From => Expr); Set_Loop_Actions (Others_Assoc, New_List); Append_List @@ -4437,6 +4437,15 @@ package body Exp_Aggr is end; Set_No_Initialization (N); + + -- After expansion the expression can be removed from the declaration + -- except if the object is class-wide, in which case the aggregate + -- provides the actual type. + + if not Is_Class_Wide_Type (Etype (Obj)) then + Set_Expression (N, Empty); + end if; + Initialize_Discriminants (N, Typ); end Convert_Aggr_In_Object_Decl; diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 400398d..2e1cb85 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -248,7 +248,7 @@ package body Exp_Attr is is Loc : constant Source_Ptr := Sloc (Attr); Comp_Typ : constant Entity_Id := - Get_Fullest_View (Component_Type (Array_Typ)); + Validated_View (Component_Type (Array_Typ)); function Validate_Component (Obj_Id : Entity_Id; @@ -535,7 +535,7 @@ package body Exp_Attr is is Field_Id : constant Entity_Id := Defining_Entity (Field); Field_Nam : constant Name_Id := Chars (Field_Id); - Field_Typ : constant Entity_Id := Get_Fullest_View (Etype (Field_Id)); + Field_Typ : constant Entity_Id := Validated_View (Etype (Field_Id)); Attr_Nam : Name_Id; begin @@ -7396,7 +7396,7 @@ package body Exp_Attr is ------------------- when Attribute_Valid_Scalars => Valid_Scalars : declare - Val_Typ : constant Entity_Id := Get_Fullest_View (Ptyp); + Val_Typ : constant Entity_Id := Validated_View (Ptyp); Expr : Node_Id; begin diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 6a8b330..4dbaadd 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -30,6 +30,7 @@ with Einfo; use Einfo; with Einfo.Entities; use Einfo.Entities; with Einfo.Utils; use Einfo.Utils; with Errout; use Errout; +with Expander; use Expander; with Exp_Aggr; use Exp_Aggr; with Exp_Atag; use Exp_Atag; with Exp_Ch4; use Exp_Ch4; @@ -6985,12 +6986,16 @@ package body Exp_Ch3 is -- happen when the aggregate is limited and the declared object -- has a following address clause; it happens also when generating -- C code for an aggregate that has an alignment or address clause - -- (see Analyze_Object_Declaration). + -- (see Analyze_Object_Declaration). Resolution is done without + -- expansion because it will take place when the declaration + -- itself is expanded. if (Is_Limited_Type (Typ) or else Modify_Tree_For_C) and then not Analyzed (Expr) then + Expander_Mode_Save_And_Set (False); Resolve (Expr, Typ); + Expander_Mode_Restore; end if; Convert_Aggr_In_Object_Decl (N); diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 9c585e7..a9fc2705 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -9626,6 +9626,7 @@ package body Exp_Ch4 is if ((not ROK) or else (Rlo <= (-1) and then (-1) <= Rhi)) and then ((not LOK) or else (Llo = LLB)) + and then not CodePeer_Mode then Rewrite (N, Make_If_Expression (Loc, diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index cd972e1..b81216f 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -3589,7 +3589,9 @@ package body Exp_Ch6 is Ren_Root := Alias (Ren_Root); end if; - if Present (Original_Node (Parent (Parent (Ren_Root)))) then + if Present (Parent (Ren_Root)) + and then Present (Original_Node (Parent (Parent (Ren_Root)))) + then Ren_Decl := Original_Node (Parent (Parent (Ren_Root))); if Nkind (Ren_Decl) = N_Subprogram_Renaming_Declaration then diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb index 38ee11e..6e17a5c 100644 --- a/gcc/ada/exp_imgv.adb +++ b/gcc/ada/exp_imgv.adb @@ -1439,17 +1439,17 @@ package body Exp_Imgv is begin -- Generate: - -- Valid_Enumeration_Value _NN + -- Valid_Value_Enumeration_NN -- (typS, typN'Address, typH'Unrestricted_Access, Num, X) Ttyp := Component_Type (Etype (Lit_Indexes (Rtyp))); if Ttyp = Standard_Integer_8 then - Func := RE_Valid_Enumeration_Value_8; + Func := RE_Valid_Value_Enumeration_8; elsif Ttyp = Standard_Integer_16 then - Func := RE_Valid_Enumeration_Value_16; + Func := RE_Valid_Value_Enumeration_16; else - Func := RE_Valid_Enumeration_Value_32; + Func := RE_Valid_Value_Enumeration_32; end if; Prepend_To (Args, diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index d02e587..270242d 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -12277,7 +12277,9 @@ package body Exp_Util is -- Local variables - Context : constant Node_Id := Parent (Ref); + Context : constant Node_Id := + (if No (Ref) then Empty else Parent (Ref)); + Loc : constant Source_Ptr := Sloc (Ref); Ref_Id : Entity_Id; Result : Traverse_Result; @@ -13493,7 +13495,7 @@ package body Exp_Util is -- modification of that variable within the loop may incorrectly -- affect the execution of the loop. - elsif Nkind (Parent (Parent (N))) = N_Loop_Parameter_Specification + elsif Parent_Kind (Parent (N)) = N_Loop_Parameter_Specification and then Within_In_Parameter (Prefix (N)) and then Variable_Ref then diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 3ea4a99..81e0e87 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -2179,7 +2179,7 @@ package body Freeze is elsif Is_Concurrent_Type (E) then Item := First_Entity (E); while Present (Item) loop - if (Is_Entry (Item) or else Is_Subprogram (Item)) + if Is_Subprogram_Or_Entry (Item) and then not Default_Expressions_Processed (Item) then Process_Default_Expressions (Item, After); diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb index 9fe9012..f5040b2 100644 --- a/gcc/ada/gen_il-gen-gen_entities.adb +++ b/gcc/ada/gen_il-gen-gen_entities.adb @@ -242,8 +242,8 @@ begin -- Gen_IL.Gen.Gen_Entities -- The initial Ekind value for a newly created entity. Also used as the -- Ekind for Standard_Void_Type, a type entity in Standard used as a -- dummy type for the return type of a procedure (the reason we create - -- this type is to share the circuits for performing overload resolution - -- on calls). + -- this type is to share the circuits for performing overload + -- resolution on calls). (Sm (Alignment, Uint), Sm (Contract, Node_Id), Sm (Is_Elaboration_Warnings_OK_Id, Flag), @@ -254,7 +254,9 @@ begin -- Gen_IL.Gen.Gen_Entities Sm (Current_Value, Node_Id), -- setter only Sm (Has_Predicates, Flag), -- setter only Sm (Initialization_Statements, Node_Id), -- setter only - Sm (Is_Param_Block_Component_Type, Flag, Base_Type_Only), -- setter only + Sm (Is_Param_Block_Component_Type, Flag, Base_Type_Only), + -- setter only + Sm (Package_Instantiation, Node_Id), -- setter only Sm (Related_Expression, Node_Id), -- setter only @@ -302,17 +304,10 @@ begin -- Gen_IL.Gen.Gen_Entities (Sm (Current_Value, Node_Id), Sm (Renamed_Or_Alias, Node_Id))); - Cc (E_Component, Object_Kind, - -- Components of a record declaration, private declarations of - -- protected objects. + Ab (Record_Field_Kind, Object_Kind, (Sm (Component_Bit_Offset, Uint), Sm (Component_Clause, Node_Id), Sm (Corresponding_Record_Component, Node_Id), - Sm (Discriminant_Checking_Func, Node_Id), - Sm (DT_Entry_Count, Uint, - Pre => "Is_Tag (N)"), - Sm (DT_Offset_To_Top_Func, Node_Id, - Pre => "Is_Tag (N)"), Sm (Entry_Formal, Node_Id), Sm (Esize, Uint), Sm (Interface_Name, Node_Id), @@ -320,114 +315,80 @@ begin -- Gen_IL.Gen.Gen_Entities Sm (Normalized_First_Bit, Uint), Sm (Normalized_Position, Uint), Sm (Normalized_Position_Max, Uint), - Sm (Original_Record_Component, Node_Id), + Sm (Original_Record_Component, Node_Id))); + + Cc (E_Component, Record_Field_Kind, + -- Components of a record declaration, private declarations of + -- protected objects. + (Sm (Discriminant_Checking_Func, Node_Id), + Sm (DT_Entry_Count, Uint, + Pre => "Is_Tag (N)"), + Sm (DT_Offset_To_Top_Func, Node_Id, + Pre => "Is_Tag (N)"), Sm (Prival, Node_Id, Pre => "Is_Protected_Component (N)"), Sm (Related_Type, Node_Id))); - Cc (E_Constant, Object_Kind, - -- Constants created by an object declaration with a constant keyword + Ab (Allocatable_Kind, Object_Kind, (Sm (Activation_Record_Component, Node_Id), - Sm (Actual_Subtype, Node_Id), Sm (Alignment, Uint), + Sm (Esize, Uint), + Sm (Interface_Name, Node_Id), + Sm (Is_Finalized_Transient, Flag), + Sm (Is_Ignored_Transient, Flag), + Sm (Linker_Section_Pragma, Node_Id), + Sm (Related_Expression, Node_Id), + Sm (Status_Flag_Or_Transient_Decl, Node_Id))); + + Ab (Constant_Or_Variable_Kind, Allocatable_Kind, + (Sm (Actual_Subtype, Node_Id), Sm (BIP_Initialization_Call, Node_Id), Sm (Contract, Node_Id), Sm (Discriminal_Link, Node_Id), Sm (Encapsulating_State, Node_Id), - Sm (Esize, Uint), Sm (Extra_Accessibility, Node_Id), - Sm (Full_View, Node_Id), Sm (Initialization_Statements, Node_Id), - Sm (Interface_Name, Node_Id), Sm (Is_Elaboration_Checks_OK_Id, Flag), Sm (Is_Elaboration_Warnings_OK_Id, Flag), - Sm (Is_Finalized_Transient, Flag), - Sm (Is_Ignored_Transient, Flag), Sm (Last_Aggregate_Assignment, Node_Id), - Sm (Linker_Section_Pragma, Node_Id), Sm (Optimize_Alignment_Space, Flag), Sm (Optimize_Alignment_Time, Flag), Sm (Prival_Link, Node_Id), - Sm (Related_Expression, Node_Id), Sm (Related_Type, Node_Id), Sm (Return_Statement, Node_Id), Sm (Size_Check_Code, Node_Id), Sm (SPARK_Pragma, Node_Id), - Sm (SPARK_Pragma_Inherited, Flag), - Sm (Status_Flag_Or_Transient_Decl, Node_Id))); + Sm (SPARK_Pragma_Inherited, Flag))); + + Cc (E_Constant, Constant_Or_Variable_Kind, + -- Constants created by an object declaration with a constant keyword + (Sm (Full_View, Node_Id))); - Cc (E_Discriminant, Object_Kind, + Cc (E_Discriminant, Record_Field_Kind, -- A discriminant, created by the use of a discriminant in a type -- declaration. - (Sm (Component_Bit_Offset, Uint), - Sm (Component_Clause, Node_Id), - Sm (Corresponding_Discriminant, Node_Id), - Sm (Corresponding_Record_Component, Node_Id), + (Sm (Corresponding_Discriminant, Node_Id), Sm (CR_Discriminant, Node_Id), Sm (Discriminal, Node_Id), Sm (Discriminant_Default_Value, Node_Id), Sm (Discriminant_Number, Uint), - Sm (Entry_Formal, Node_Id), - Sm (Esize, Uint), - Sm (Interface_Name, Node_Id), - Sm (Is_Completely_Hidden, Flag), - Sm (Linker_Section_Pragma, Node_Id), - Sm (Normalized_First_Bit, Uint), - Sm (Normalized_Position, Uint), - Sm (Normalized_Position_Max, Uint), - Sm (Original_Record_Component, Node_Id))); + Sm (Is_Completely_Hidden, Flag))); - Cc (E_Loop_Parameter, Object_Kind, - -- A loop parameter created by a for loop - (Sm (Activation_Record_Component, Node_Id), - Sm (Alignment, Uint), - Sm (Esize, Uint), - Sm (Interface_Name, Node_Id), - Sm (Is_Finalized_Transient, Flag), - Sm (Is_Ignored_Transient, Flag), - Sm (Linker_Section_Pragma, Node_Id), - Sm (Related_Expression, Node_Id), - Sm (Status_Flag_Or_Transient_Decl, Node_Id))); + Cc (E_Loop_Parameter, Allocatable_Kind); + -- A loop parameter created by a for loop - Cc (E_Variable, Object_Kind, + Cc (E_Variable, Constant_Or_Variable_Kind, -- Variables created by an object declaration with no constant keyword - (Sm (Activation_Record_Component, Node_Id), - Sm (Actual_Subtype, Node_Id), - Sm (Alignment, Uint), - Sm (Anonymous_Designated_Type, Node_Id), - Sm (BIP_Initialization_Call, Node_Id), - Sm (Contract, Node_Id), + (Sm (Anonymous_Designated_Type, Node_Id), Sm (Debug_Renaming_Link, Node_Id), - Sm (Discriminal_Link, Node_Id), - Sm (Encapsulating_State, Node_Id), - Sm (Esize, Uint), - Sm (Extra_Accessibility, Node_Id), Sm (Extra_Constrained, Node_Id), Sm (Has_Initial_Value, Flag), Sm (Hiding_Loop_Variable, Node_Id), - Sm (Initialization_Statements, Node_Id), - Sm (Interface_Name, Node_Id), - Sm (Is_Elaboration_Checks_OK_Id, Flag), - Sm (Is_Elaboration_Warnings_OK_Id, Flag), - Sm (Is_Finalized_Transient, Flag), - Sm (Is_Ignored_Transient, Flag), - Sm (Last_Aggregate_Assignment, Node_Id), Sm (Last_Assignment, Node_Id), - Sm (Linker_Section_Pragma, Node_Id), Sm (OK_To_Rename, Flag), - Sm (Optimize_Alignment_Space, Flag), - Sm (Optimize_Alignment_Time, Flag), Sm (Part_Of_Constituents, Elist_Id), Sm (Part_Of_References, Elist_Id), - Sm (Prival_Link, Node_Id), - Sm (Related_Expression, Node_Id), - Sm (Related_Type, Node_Id), - Sm (Return_Statement, Node_Id), Sm (Shared_Var_Procs_Instance, Node_Id), - Sm (Size_Check_Code, Node_Id), - Sm (SPARK_Pragma, Node_Id), - Sm (SPARK_Pragma_Inherited, Flag), - Sm (Status_Flag_Or_Transient_Decl, Node_Id), Sm (Suppress_Initialization, Flag), Sm (Unset_Reference, Node_Id), Sm (Validated_Object, Node_Id))); diff --git a/gcc/ada/gen_il-gen.adb b/gcc/ada/gen_il-gen.adb index 6b48e8e..0f3698e 100644 --- a/gcc/ada/gen_il-gen.adb +++ b/gcc/ada/gen_il-gen.adb @@ -2329,6 +2329,7 @@ package body Gen_IL.Gen is Put (B, "with Nlists; use Nlists;" & LF); Put (B, "pragma Warnings (Off);" & LF); Put (B, "with Einfo.Utils; use Einfo.Utils;" & LF); + Put (B, "with Sinfo.Utils; use Sinfo.Utils;" & LF); Put (B, "pragma Warnings (On);" & LF); Put (B, LF & "package body Sinfo.Nodes is" & LF & LF); @@ -2930,9 +2931,15 @@ package body Gen_IL.Gen is procedure Put_C_Type_And_Subtypes (S : in out Sink; Root : Root_Type) is + Cur_Pos : Root_Nat := 0; + -- Current Node_Kind'Pos or Entity_Kind'Pos to be printed + procedure Put_Enum_Lit (T : Node_Or_Entity_Type); -- Print out the #define corresponding to the Ada enumeration literal -- for T in Node_Kind and Entity_Kind (i.e. concrete types). + -- This looks like "#define Some_Kind <pos>", where Some_Kind + -- is the Node_Kind or Entity_Kind enumeration literal, and + -- <pos> is Node_Kind'Pos or Entity_Kind'Pos of that literal. procedure Put_Kind_Subtype (T : Node_Or_Entity_Type); -- Print out the SUBTYPE macro call corresponding to an abstract @@ -2941,7 +2948,8 @@ package body Gen_IL.Gen is procedure Put_Enum_Lit (T : Node_Or_Entity_Type) is begin if T in Concrete_Type then - Put (S, "#define " & Image (T) & " " & Image (Pos (T)) & "" & LF); + Put (S, "#define " & Image (T) & " " & Image (Cur_Pos) & LF); + Cur_Pos := Cur_Pos + 1; end if; end Put_Enum_Lit; @@ -2961,7 +2969,7 @@ package body Gen_IL.Gen is Iterate_Types (Root, Pre => Put_Enum_Lit'Access); Put (S, "#define Number_" & Node_Or_Entity (Root) & "_Kinds " & - Image (Pos (Last_Concrete (Root)) + 1) & "" & LF & LF); + Image (Cur_Pos) & "" & LF & LF); Iterate_Types (Root, Pre => Put_Kind_Subtype'Access); diff --git a/gcc/ada/gen_il-internals.adb b/gcc/ada/gen_il-internals.adb index 59a142d..d77fe7a 100644 --- a/gcc/ada/gen_il-internals.adb +++ b/gcc/ada/gen_il-internals.adb @@ -477,16 +477,4 @@ package body Gen_IL.Internals is Put (S, "-- End type hierarchy for " & N_Or_E & LF & LF); end Put_Type_Hierarchy; - --------- - -- Pos -- - --------- - - function Pos (T : Concrete_Type) return Root_Nat is - First : constant Concrete_Type := - (if T in Concrete_Node then Concrete_Node'First - else Concrete_Entity'First); - begin - return Type_Enum'Pos (T) - Type_Enum'Pos (First); - end Pos; - end Gen_IL.Internals; diff --git a/gcc/ada/gen_il-internals.ads b/gcc/ada/gen_il-internals.ads index 8d13e80..9c5779b 100644 --- a/gcc/ada/gen_il-internals.ads +++ b/gcc/ada/gen_il-internals.ads @@ -202,7 +202,10 @@ package Gen_IL.Internals is Nil'Access); -- Iterate top-down on the type hierarchy. Call Pre and Post before and -- after walking child types. Note that this ignores union types, because - -- they are nonhierarchical. + -- they are nonhierarchical. The order in which concrete types are visited + -- matches the order of the generated enumeration types Node_Kind and + -- Entity_Kind, which is not the same as the order of the Type_Enum + -- type in Gen_IL.Types. function Is_Descendant (Ancestor, Descendant : Node_Or_Entity_Type) return Boolean; @@ -212,9 +215,6 @@ package Gen_IL.Internals is procedure Put_Type_Hierarchy (S : in out Sink; Root : Root_Type); - function Pos (T : Concrete_Type) return Root_Nat; - -- Return Node_Kind'Pos (T) or Entity_Kind'Pos (T) - ---------------- type Field_Desc is record diff --git a/gcc/ada/gen_il-types.ads b/gcc/ada/gen_il-types.ads index 482d01d..6850411 100644 --- a/gcc/ada/gen_il-types.ads +++ b/gcc/ada/gen_il-types.ads @@ -124,6 +124,7 @@ package Gen_IL.Types is Access_Subprogram_Kind, Access_Protected_Kind, Aggregate_Kind, + Allocatable_Kind, Anonymous_Access_Kind, Array_Kind, Assignable_Kind, @@ -131,6 +132,7 @@ package Gen_IL.Types is Composite_Kind, Concurrent_Kind, Concurrent_Body_Kind, + Constant_Or_Variable_Kind, Decimal_Fixed_Point_Kind, Digits_Kind, Discrete_Kind, @@ -158,6 +160,7 @@ package Gen_IL.Types is Protected_Kind, Real_Kind, Record_Kind, + Record_Field_Kind, Scalar_Kind, Subprogram_Kind, Signed_Integer_Kind, diff --git a/gcc/ada/lib-xref-spark_specific.adb b/gcc/ada/lib-xref-spark_specific.adb index 723b7a8..1905f23 100644 --- a/gcc/ada/lib-xref-spark_specific.adb +++ b/gcc/ada/lib-xref-spark_specific.adb @@ -187,6 +187,10 @@ package body SPARK_Specific is | Generic_Subprogram_Kind | Subprogram_Kind then + if No (Unit_Declaration_Node (N)) then + return Empty; + end if; + Context := Parent (Unit_Declaration_Node (N)); -- If this was a library-level subprogram then replace Context with diff --git a/gcc/ada/libgnarl/s-tasdeb.ads b/gcc/ada/libgnarl/s-tasdeb.ads index 3e8a8d8..eebb2a9 100644 --- a/gcc/ada/libgnarl/s-tasdeb.ads +++ b/gcc/ada/libgnarl/s-tasdeb.ads @@ -65,9 +65,11 @@ package System.Tasking.Debug is -- General GDB support -- ------------------------- - Known_Tasks : array (0 .. 999) of Task_Id := (others => null); + Known_Tasks : array (0 .. 999) of Task_Id := (others => null) + with Atomic_Components; -- Global array of tasks read by gdb, and updated by Create_Task and - -- Finalize_TCB + -- Finalize_TCB. Ensure access to its components is atomic to allow + -- lock-free concurrent access. Debug_Event_Activating : constant := 1; Debug_Event_Run : constant := 2; diff --git a/gcc/ada/libgnat/a-cfdlli.ads b/gcc/ada/libgnat/a-cfdlli.ads index d3bc3ba..e3a2de6 100644 --- a/gcc/ada/libgnat/a-cfdlli.ads +++ b/gcc/ada/libgnat/a-cfdlli.ads @@ -39,6 +39,11 @@ generic package Ada.Containers.Formal_Doubly_Linked_Lists with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); type List (Capacity : Count_Type) is private with diff --git a/gcc/ada/libgnat/a-cfhama.ads b/gcc/ada/libgnat/a-cfhama.ads index 9ccd9c2..e9b0268 100644 --- a/gcc/ada/libgnat/a-cfhama.ads +++ b/gcc/ada/libgnat/a-cfhama.ads @@ -64,6 +64,11 @@ generic package Ada.Containers.Formal_Hashed_Maps with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); type Map (Capacity : Count_Type; Modulus : Hash_Type) is private with diff --git a/gcc/ada/libgnat/a-cfhase.ads b/gcc/ada/libgnat/a-cfhase.ads index 47aaf0d..5d57863 100644 --- a/gcc/ada/libgnat/a-cfhase.ads +++ b/gcc/ada/libgnat/a-cfhase.ads @@ -62,6 +62,11 @@ generic package Ada.Containers.Formal_Hashed_Sets with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); type Set (Capacity : Count_Type; Modulus : Hash_Type) is private with diff --git a/gcc/ada/libgnat/a-cfinve.ads b/gcc/ada/libgnat/a-cfinve.ads index a8aeaa2..37dde92 100644 --- a/gcc/ada/libgnat/a-cfinve.ads +++ b/gcc/ada/libgnat/a-cfinve.ads @@ -55,6 +55,11 @@ generic package Ada.Containers.Formal_Indefinite_Vectors with SPARK_Mode => On is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); subtype Extended_Index is Index_Type'Base diff --git a/gcc/ada/libgnat/a-cforma.ads b/gcc/ada/libgnat/a-cforma.ads index 4e17978..d32727e 100644 --- a/gcc/ada/libgnat/a-cforma.ads +++ b/gcc/ada/libgnat/a-cforma.ads @@ -63,6 +63,11 @@ generic package Ada.Containers.Formal_Ordered_Maps with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); function Equivalent_Keys (Left, Right : Key_Type) return Boolean with diff --git a/gcc/ada/libgnat/a-cforse.ads b/gcc/ada/libgnat/a-cforse.ads index 61a93a3..12d2d3c 100644 --- a/gcc/ada/libgnat/a-cforse.ads +++ b/gcc/ada/libgnat/a-cforse.ads @@ -59,6 +59,11 @@ generic package Ada.Containers.Formal_Ordered_Sets with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); function Equivalent_Elements (Left, Right : Element_Type) return Boolean diff --git a/gcc/ada/libgnat/a-cofove.ads b/gcc/ada/libgnat/a-cofove.ads index 217032f..61115dd 100644 --- a/gcc/ada/libgnat/a-cofove.ads +++ b/gcc/ada/libgnat/a-cofove.ads @@ -45,6 +45,11 @@ generic package Ada.Containers.Formal_Vectors with SPARK_Mode is + -- Contracts in this unit are meant for analysis only, not for run-time + -- checking. + + pragma Assertion_Policy (Pre => Ignore); + pragma Assertion_Policy (Post => Ignore); pragma Annotate (CodePeer, Skip_Analysis); subtype Extended_Index is Index_Type'Base diff --git a/gcc/ada/libgnat/a-stwiun__shared.adb b/gcc/ada/libgnat/a-stwiun__shared.adb index f293684..1d0521c 100644 --- a/gcc/ada/libgnat/a-stwiun__shared.adb +++ b/gcc/ada/libgnat/a-stwiun__shared.adb @@ -76,7 +76,7 @@ package body Ada.Strings.Wide_Unbounded is Reference (Empty_Shared_Wide_String'Access); DR := Empty_Shared_Wide_String'Access; - -- Left string is empty, return Rigth string + -- Left string is empty, return Right string elsif LR.Last = 0 then Reference (RR); diff --git a/gcc/ada/libgnat/a-stzunb__shared.adb b/gcc/ada/libgnat/a-stzunb__shared.adb index 17d27d6..99a545e 100644 --- a/gcc/ada/libgnat/a-stzunb__shared.adb +++ b/gcc/ada/libgnat/a-stzunb__shared.adb @@ -76,7 +76,7 @@ package body Ada.Strings.Wide_Wide_Unbounded is Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; - -- Left string is empty, return Rigth string + -- Left string is empty, return Right string elsif LR.Last = 0 then Reference (RR); diff --git a/gcc/ada/libgnat/s-objrea.adb b/gcc/ada/libgnat/s-objrea.adb index b5ca32f..9dd8c1f 100644 --- a/gcc/ada/libgnat/s-objrea.adb +++ b/gcc/ada/libgnat/s-objrea.adb @@ -78,6 +78,7 @@ package body System.Object_Reader is EM_SPARCV9 : constant := 43; -- SPARC v9 64-bit EM_IA_64 : constant := 50; -- Intel Merced EM_X86_64 : constant := 62; -- AMD x86-64 architecture + EM_AARCH64 : constant := 183; -- Aarch64 EN_NIDENT : constant := 16; @@ -648,6 +649,9 @@ package body System.Object_Reader is when EM_ARM => Res.Arch := ARM; + when EM_AARCH64 => + Res.Arch := AARCH64; + when others => raise Format_Error with "unrecognized architecture"; end case; @@ -2038,7 +2042,8 @@ package body System.Object_Reader is Address_32 := Read (S); return uint64 (Address_32); - when IA64 + when AARCH64 + | IA64 | PPC64 | SPARC64 | x86_64 diff --git a/gcc/ada/libgnat/s-objrea.ads b/gcc/ada/libgnat/s-objrea.ads index 28dabf5..a83ca53 100644 --- a/gcc/ada/libgnat/s-objrea.ads +++ b/gcc/ada/libgnat/s-objrea.ads @@ -120,9 +120,12 @@ package System.Object_Reader is PPC64, -- 64-bit PowerPC - ARM); + ARM, -- 32-bit ARM + AARCH64); + -- 64-bit ARM + ------------------ -- Target types -- ------------------ diff --git a/gcc/ada/libgnat/s-vaen16.ads b/gcc/ada/libgnat/s-vaen16.ads index 86cdaa1..6ea6071 100644 --- a/gcc/ada/libgnat/s-vaen16.ads +++ b/gcc/ada/libgnat/s-vaen16.ads @@ -49,13 +49,13 @@ package System.Val_Enum_16 is return Natural renames Impl.Value_Enumeration; - function Valid_Enumeration_Value_16 + function Valid_Value_Enumeration_16 (Names : String; Indexes : System.Address; Hash : Impl.Hash_Function_Ptr; Num : Natural; Str : String) return Boolean - renames Impl.Valid_Enumeration_Value; + renames Impl.Valid_Value_Enumeration; end System.Val_Enum_16; diff --git a/gcc/ada/libgnat/s-vaen32.ads b/gcc/ada/libgnat/s-vaen32.ads index 0dead07..e1a7644 100644 --- a/gcc/ada/libgnat/s-vaen32.ads +++ b/gcc/ada/libgnat/s-vaen32.ads @@ -49,13 +49,13 @@ package System.Val_Enum_32 is return Natural renames Impl.Value_Enumeration; - function Valid_Enumeration_Value_32 + function Valid_Value_Enumeration_32 (Names : String; Indexes : System.Address; Hash : Impl.Hash_Function_Ptr; Num : Natural; Str : String) return Boolean - renames Impl.Valid_Enumeration_Value; + renames Impl.Valid_Value_Enumeration; end System.Val_Enum_32; diff --git a/gcc/ada/libgnat/s-vaenu8.ads b/gcc/ada/libgnat/s-vaenu8.ads index db0b360..395a969 100644 --- a/gcc/ada/libgnat/s-vaenu8.ads +++ b/gcc/ada/libgnat/s-vaenu8.ads @@ -49,13 +49,13 @@ package System.Val_Enum_8 is return Natural renames Impl.Value_Enumeration; - function Valid_Enumeration_Value_8 + function Valid_Value_Enumeration_8 (Names : String; Indexes : System.Address; Hash : Impl.Hash_Function_Ptr; Num : Natural; Str : String) return Boolean - renames Impl.Valid_Enumeration_Value; + renames Impl.Valid_Value_Enumeration; end System.Val_Enum_8; diff --git a/gcc/ada/libgnat/s-valuen.adb b/gcc/ada/libgnat/s-valuen.adb index 7b72bc6..ef613a2 100644 --- a/gcc/ada/libgnat/s-valuen.adb +++ b/gcc/ada/libgnat/s-valuen.adb @@ -35,6 +35,16 @@ with System.Val_Util; use System.Val_Util; package body System.Value_N is + function Value_Enumeration_Pos + (Names : String; + Indexes : System.Address; + Hash : Hash_Function_Ptr; + Num : Natural; + Str : String) + return Integer with Pure_Function; + -- Same as Value_Enumeration, except returns negative if Value_Enumeration + -- would raise Constraint_Error. + --------------------------- -- Value_Enumeration_Pos -- --------------------------- @@ -98,9 +108,25 @@ package body System.Value_N is end if; end; - return Invalid; + return -1; end Value_Enumeration_Pos; + ----------------------------- + -- Valid_Value_Enumeration -- + ----------------------------- + + function Valid_Value_Enumeration + (Names : String; + Indexes : System.Address; + Hash : Hash_Function_Ptr; + Num : Natural; + Str : String) + return Boolean + is + begin + return Value_Enumeration_Pos (Names, Indexes, Hash, Num, Str) >= 0; + end Valid_Value_Enumeration; + ----------------------- -- Value_Enumeration -- ----------------------- @@ -115,28 +141,15 @@ package body System.Value_N is is Result : constant Integer := Value_Enumeration_Pos (Names, Indexes, Hash, Num, Str); + begin - if Result = Invalid then + -- The comparison eliminates the need for a range check on return + + if Result < 0 then Bad_Value (Str); else return Result; end if; end Value_Enumeration; - ----------------------------- - -- Valid_Enumeration_Value -- - ----------------------------- - - function Valid_Enumeration_Value - (Names : String; - Indexes : System.Address; - Hash : Hash_Function_Ptr; - Num : Natural; - Str : String) - return Boolean - is - begin - return Value_Enumeration_Pos (Names, Indexes, Hash, Num, Str) /= Invalid; - end Valid_Enumeration_Value; - end System.Value_N; diff --git a/gcc/ada/libgnat/s-valuen.ads b/gcc/ada/libgnat/s-valuen.ads index 7ef0539..db8ad1d 100644 --- a/gcc/ada/libgnat/s-valuen.ads +++ b/gcc/ada/libgnat/s-valuen.ads @@ -67,7 +67,7 @@ package System.Value_N is -- If the image is found in Names, then the corresponding Pos value is -- returned. If not, Constraint_Error is raised. - function Valid_Enumeration_Value + function Valid_Value_Enumeration (Names : String; Indexes : System.Address; Hash : Hash_Function_Ptr; @@ -79,16 +79,4 @@ package System.Value_N is -- raise Constraint_Error. The parameters have the same meaning as for -- Value_Enumeration. - Invalid : constant Integer := -1; - - function Value_Enumeration_Pos - (Names : String; - Indexes : System.Address; - Hash : Hash_Function_Ptr; - Num : Natural; - Str : String) - return Integer with Pure_Function; - -- Same as Value_Enumeration, except returns Invalid if Value_Enumeration - -- would raise Constraint_Error. - end System.Value_N; diff --git a/gcc/ada/nlists.adb b/gcc/ada/nlists.adb index 821c0ab..7339c17 100644 --- a/gcc/ada/nlists.adb +++ b/gcc/ada/nlists.adb @@ -27,11 +27,11 @@ -- file must be properly reflected in the corresponding C header a-nlists.h with Alloc; -with Atree; use Atree; -with Debug; use Debug; -with Output; use Output; -with Sinfo; use Sinfo; -with Sinfo.Nodes; use Sinfo.Nodes; +with Atree; use Atree; +with Debug; use Debug; +with Output; use Output; +with Sinfo; use Sinfo; +with Sinfo.Nodes; use Sinfo.Nodes; with Table; package body Nlists is @@ -1015,6 +1015,7 @@ package body Nlists is function Parent (List : List_Id) return Node_Or_Entity_Id is begin + pragma Assert (Present (List)); pragma Assert (List <= Lists.Last); return Lists.Table (List).Parent; end Parent; diff --git a/gcc/ada/osint.ads b/gcc/ada/osint.ads index f481812..f1a9f84 100644 --- a/gcc/ada/osint.ads +++ b/gcc/ada/osint.ads @@ -716,9 +716,9 @@ private File_Names : File_Name_Array_Ptr := new File_Name_Array (1 .. Int (Argument_Count) + 2); -- As arguments are scanned, file names are stored in this array. The - -- strings do not have terminating NUL files. The array is extensible, - -- because when using project files, there may be more files than - -- arguments on the command line. + -- strings do not have terminating NULs. The array is extensible, because + -- when using project files, there may be more files than arguments on the + -- command line. type File_Index_Array is array (Int range <>) of Int; type File_Index_Array_Ptr is access File_Index_Array; diff --git a/gcc/ada/repinfo-input.adb b/gcc/ada/repinfo-input.adb index 6463563..106c43c 100644 --- a/gcc/ada/repinfo-input.adb +++ b/gcc/ada/repinfo-input.adb @@ -215,7 +215,7 @@ package body Repinfo.Input is J_COMMA, J_COLON, J_EOF); - -- JSON Token kind. Note that in ECMA 404 there is no notion of integer. + -- JSON token kind. Note that in ECMA 404 there is no notion of integer. -- Only numbers are supported. In our implementation we return J_INTEGER -- if there is no decimal part in the number. The semantic is that this -- is a J_NUMBER token that might be represented as an integer. Special diff --git a/gcc/ada/rtsfind.ads b/gcc/ada/rtsfind.ads index df51477..ad84e9e 100644 --- a/gcc/ada/rtsfind.ads +++ b/gcc/ada/rtsfind.ads @@ -2040,9 +2040,9 @@ package Rtsfind is RE_Value_Enumeration_16, -- System.Val_Enum_16 RE_Value_Enumeration_32, -- System.Val_Enum_32 - RE_Valid_Enumeration_Value_8, -- System.Val_Enum_8 - RE_Valid_Enumeration_Value_16, -- System.Val_Enum_16 - RE_Valid_Enumeration_Value_32, -- System.Val_Enum_32 + RE_Valid_Value_Enumeration_8, -- System.Val_Enum_8 + RE_Valid_Value_Enumeration_16, -- System.Val_Enum_16 + RE_Valid_Value_Enumeration_32, -- System.Val_Enum_32 RE_Value_Fixed32, -- System_Val_Fixed_32 @@ -3731,11 +3731,11 @@ package Rtsfind is RE_Value_Enumeration_32 => System_Val_Enum_32, - RE_Valid_Enumeration_Value_8 => System_Val_Enum_8, + RE_Valid_Value_Enumeration_8 => System_Val_Enum_8, - RE_Valid_Enumeration_Value_16 => System_Val_Enum_16, + RE_Valid_Value_Enumeration_16 => System_Val_Enum_16, - RE_Valid_Enumeration_Value_32 => System_Val_Enum_32, + RE_Valid_Value_Enumeration_32 => System_Val_Enum_32, RE_Value_Fixed32 => System_Val_Fixed_32, diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c index 25a4df0..d42e663 100644 --- a/gcc/ada/s-oscons-tmplt.c +++ b/gcc/ada/s-oscons-tmplt.c @@ -1501,6 +1501,21 @@ CNS(MSG_Forced_Flags, "") #endif CND(TCP_NODELAY, "Do not coalesce packets") +#ifndef TCP_KEEPCNT +# define TCP_KEEPCNT -1 +#endif +CND(TCP_KEEPCNT, "Maximum number of keepalive probes") + +#ifndef TCP_KEEPIDLE +# define TCP_KEEPIDLE -1 +#endif +CND(TCP_KEEPIDLE, "Idle time before TCP starts sending keepalive probes") + +#ifndef TCP_KEEPINTVL +# define TCP_KEEPINTVL -1 +#endif +CND(TCP_KEEPINTVL, "Time between individual keepalive probes") + #ifndef SO_REUSEADDR # define SO_REUSEADDR -1 #endif diff --git a/gcc/ada/sem_ch11.adb b/gcc/ada/sem_ch11.adb index 5a2c6a6..2af65ae 100644 --- a/gcc/ada/sem_ch11.adb +++ b/gcc/ada/sem_ch11.adb @@ -435,7 +435,7 @@ package body Sem_Ch11 is -- postcondition, since in that case there are no source references, and -- we need to preserve deferred references from the enclosing scope. - if ((Is_Subprogram (Current_Scope) or else Is_Entry (Current_Scope)) + if (Is_Subprogram_Or_Entry (Current_Scope) and then Chars (Current_Scope) /= Name_uPostconditions) or else Ekind (Current_Scope) in E_Block | E_Task_Type then diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 9ccc5c5..339bb42 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -9106,7 +9106,7 @@ package body Sem_Ch12 is -- Handle the following case: -- -- package Parent_Inst is new ... - -- Parent_Inst [] + -- freeze Parent_Inst [] -- -- procedure P ... -- this body freezes Parent_Inst -- @@ -9942,7 +9942,7 @@ package body Sem_Ch12 is -- Handle the following case: -- package Parent_Inst is new ... - -- Parent_Inst [] + -- freeze Parent_Inst [] -- procedure P ... -- this body freezes Parent_Inst @@ -11258,7 +11258,8 @@ package body Sem_Ch12 is A_Gen_Obj : constant Entity_Id := Defining_Identifier (Analyzed_Formal); Acc_Def : Node_Id := Empty; - Act_Assoc : constant Node_Id := Parent (Actual); + Act_Assoc : constant Node_Id := + (if No (Actual) then Empty else Parent (Actual)); Actual_Decl : Node_Id := Empty; Decl_Node : Node_Id; Def : Node_Id; @@ -11289,7 +11290,7 @@ package body Sem_Ch12 is Error_Msg_N ("duplicate instantiation of generic parameter", Actual); end if; - Set_Parent (List, Parent (Actual)); + Set_Parent (List, Act_Assoc); -- OUT present @@ -11654,7 +11655,9 @@ package body Sem_Ch12 is end if; end if; - if Nkind (Actual) in N_Has_Entity then + if Nkind (Actual) in N_Has_Entity + and then Present (Entity (Actual)) + then Actual_Decl := Parent (Entity (Actual)); end if; @@ -16339,7 +16342,7 @@ package body Sem_Ch12 is -- global in the current generic it must be preserved for its -- instantiation. - if Nkind (Parent (Typ)) = N_Subtype_Declaration + if Parent_Kind (Typ) = N_Subtype_Declaration and then Present (Generic_Parent_Type (Parent (Typ))) then Typ := Base_Type (Typ); diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index cfcbe14..dcd5954 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -8561,7 +8561,7 @@ package body Sem_Ch13 is Generate_Reference (Comp, Component_Name (CC), Set_Ref => False); - Set_Entity (Component_Name (CC), Comp); + Set_Entity_With_Checks (Component_Name (CC), Comp); -- Update Fbit and Lbit to the actual bit number @@ -10652,7 +10652,7 @@ package body Sem_Ch13 is -- in particular, it has no type. Err : Boolean; - -- Set False if error + -- Set True if error -- On entry to this procedure, Entity (Ident) contains a copy of the -- original expression from the aspect, saved for this purpose, and @@ -10786,7 +10786,9 @@ package body Sem_Ch13 is -- Indicate that the expression comes from an aspect specification, -- which is used in subsequent analysis even if expansion is off. - Set_Parent (End_Decl_Expr, ASN); + if Present (End_Decl_Expr) then + Set_Parent (End_Decl_Expr, ASN); + end if; -- In a generic context the original aspect expressions have not -- been preanalyzed, so do it now. There are no conformance checks @@ -12479,8 +12481,6 @@ package body Sem_Ch13 is else Size_Too_Small_Error (Asiz); - Set_Esize (T, Asiz); - Set_RM_Size (T, Asiz); end if; end; @@ -12518,8 +12518,6 @@ package body Sem_Ch13 is if Siz < M then Size_Too_Small_Error (M); - Set_Esize (T, M); - Set_RM_Size (T, M); else Biased := True; end if; diff --git a/gcc/ada/sem_ch13.ads b/gcc/ada/sem_ch13.ads index 3869f92..7579812 100644 --- a/gcc/ada/sem_ch13.ads +++ b/gcc/ada/sem_ch13.ads @@ -125,8 +125,7 @@ package Sem_Ch13 is -- set if the type is not currently biased, but biasing it is the only -- way to meet the requirement. If the type is currently biased, then -- this biased size is used in the initial check, and Biased is False. - -- If the size is too small, and an error message is given, then both - -- Esize and RM_Size are reset to the allowed minimum value in T. + -- For a Component_Size clause, T is the component type. function Has_Compatible_Representation (Target_Type, Operand_Type : Entity_Id) return Boolean; diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 594e08e..7dfb5c8 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -2758,7 +2758,6 @@ package body Sem_Ch3 is Resolve_Aspects; elsif L /= Visible_Declarations (Parent (L)) - or else No (Private_Declarations (Parent (L))) or else Is_Empty_List (Private_Declarations (Parent (L))) then Adjust_Decl; @@ -6189,7 +6188,7 @@ package body Sem_Ch3 is -- the master_id associated with an anonymous access to task type -- component (see Expand_N_Full_Type_Declaration.Build_Master) - Set_Parent (Element_Type, Parent (T)); + Copy_Parent (To => Element_Type, From => T); -- Ada 2005 (AI-230): In case of components that are anonymous access -- types the level of accessibility depends on the enclosing type @@ -10361,7 +10360,7 @@ package body Sem_Ch3 is if Discrim_Present then null; - elsif Nkind (Parent (Parent (Def))) = N_Component_Declaration + elsif Parent_Kind (Parent (Def)) = N_Component_Declaration and then Has_Per_Object_Constraint (Defining_Identifier (Parent (Parent (Def)))) then @@ -19133,21 +19132,8 @@ package body Sem_Ch3 is ------------------- function Is_Local_Type (Typ : Entity_Id) return Boolean is - Scop : Entity_Id; - begin - Scop := Scope (Typ); - while Present (Scop) - and then Scop /= Standard_Standard - loop - if Scop = Scope (Current_Scope) then - return True; - end if; - - Scop := Scope (Scop); - end loop; - - return False; + return Scope_Within (Inner => Typ, Outer => Scope (Current_Scope)); end Is_Local_Type; -- Start of processing for Is_Visible_Component @@ -22391,10 +22377,10 @@ package body Sem_Ch3 is Final_Storage_Only := not Is_Controlled (T); - -- Ada 2005: Check whether an explicit Limited is present in a derived + -- Ada 2005: Check whether an explicit "limited" is present in a derived -- type declaration. - if Nkind (Parent (Def)) = N_Derived_Type_Definition + if Parent_Kind (Def) = N_Derived_Type_Definition and then Limited_Present (Parent (Def)) then Set_Is_Limited_Record (T); diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index d37f295..c361acc 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -132,9 +132,6 @@ package body Sem_Ch6 is -- Does all the real work of Analyze_Subprogram_Body. This is split out so -- that we can use RETURN but not skip the debug output at the end. - function Can_Override_Operator (Subp : Entity_Id) return Boolean; - -- Returns true if Subp can override a predefined operator. - procedure Check_Conformance (New_Id : Entity_Id; Old_Id : Entity_Id; @@ -7321,7 +7318,7 @@ package body Sem_Ch6 is -- predefined signature, because we know already that there is no -- explicit overridden operation. - elsif Nkind (Subp) = N_Defining_Operator_Symbol then + elsif Chars (Subp) in Any_Operator_Name then if Must_Not_Override (Spec) then -- If this is not a primitive or a protected subprogram, then @@ -8313,7 +8310,12 @@ package body Sem_Ch6 is Typ : Entity_Id; begin - if Nkind (Subp) /= N_Defining_Operator_Symbol then + -- Return False if not an operator. We test the name rather than testing + -- that the Nkind is N_Defining_Operator_Symbol, because there are cases + -- where an operator entity can be an N_Defining_Identifier (such as for + -- function instantiations). + + if Chars (Subp) not in Any_Operator_Name then return False; else @@ -11709,7 +11711,7 @@ package body Sem_Ch6 is if Inside_Freezing_Actions = 0 and then Is_Package_Or_Generic_Package (Current_Scope) and then In_Private_Part (Current_Scope) - and then Nkind (Parent (E)) = N_Private_Extension_Declaration + and then Parent_Kind (E) = N_Private_Extension_Declaration and then Nkind (Parent (S)) = N_Full_Type_Declaration and then Full_View (Defining_Identifier (Parent (E))) = Defining_Identifier (Parent (S)) diff --git a/gcc/ada/sem_ch6.ads b/gcc/ada/sem_ch6.ads index 9579582..4afcf36 100644 --- a/gcc/ada/sem_ch6.ads +++ b/gcc/ada/sem_ch6.ads @@ -51,6 +51,9 @@ package Sem_Ch6 is -- and body declarations. Returns the defining entity for the -- specification N. + function Can_Override_Operator (Subp : Entity_Id) return Boolean; + -- Returns true if Subp can override a predefined operator + procedure Check_Conventions (Typ : Entity_Id); -- Ada 2005 (AI-430): Check that the conventions of all inherited and -- overridden dispatching operations of type Typ are consistent with their diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 1c68eed..aa33c50 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -3299,7 +3299,9 @@ package body Sem_Ch8 is Style.Missing_Overriding (N, Rename_Spec); end if; - elsif Must_Override (Specification (N)) then + elsif Must_Override (Specification (N)) + and then not Can_Override_Operator (Rename_Spec) + then Error_Msg_NE ("subprogram& is not overriding", N, Rename_Spec); end if; diff --git a/gcc/ada/sem_dim.adb b/gcc/ada/sem_dim.adb index a52b58a..b303229 100644 --- a/gcc/ada/sem_dim.adb +++ b/gcc/ada/sem_dim.adb @@ -3765,16 +3765,20 @@ package body Sem_Dim is --------------- function System_Of (E : Entity_Id) return System_Type is - Type_Decl : constant Node_Id := Parent (E); - begin - -- Look for Type_Decl in System_Table + if Present (E) then + declare + Type_Decl : constant Node_Id := Parent (E); + begin + -- Look for Type_Decl in System_Table - for Dim_Sys in 1 .. System_Table.Last loop - if Type_Decl = System_Table.Table (Dim_Sys).Type_Decl then - return System_Table.Table (Dim_Sys); - end if; - end loop; + for Dim_Sys in 1 .. System_Table.Last loop + if Type_Decl = System_Table.Table (Dim_Sys).Type_Decl then + return System_Table.Table (Dim_Sys); + end if; + end loop; + end; + end if; return Null_System; end System_Of; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index ea0a5bb..14351b3 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -9257,7 +9257,9 @@ package body Sem_Prag is -- just the same scope). If the pragma comes from an aspect -- specification we know that it is part of the declaration. - elsif Parent (Unit_Declaration_Node (Def_Id)) /= Parent (N) + elsif (No (Unit_Declaration_Node (Def_Id)) + or else Parent (Unit_Declaration_Node (Def_Id)) /= + Parent (N)) and then Nkind (Parent (N)) /= N_Compilation_Unit_Aux and then not From_Aspect_Specification (N) then @@ -9848,7 +9850,7 @@ package body Sem_Prag is -- inlineable either. elsif Is_Generic_Instance (Subp) - or else Nkind (Parent (Parent (Subp))) = N_Subprogram_Declaration + or else Parent_Kind (Parent (Subp)) = N_Subprogram_Declaration then null; @@ -9894,7 +9896,11 @@ package body Sem_Prag is if In_Same_Source_Unit (Subp, Inner_Subp) then Set_Inline_Flags (Inner_Subp); - Decl := Parent (Parent (Inner_Subp)); + if Present (Parent (Inner_Subp)) then + Decl := Parent (Parent (Inner_Subp)); + else + Decl := Empty; + end if; if Nkind (Decl) = N_Subprogram_Declaration and then Present (Corresponding_Body (Decl)) @@ -30892,7 +30898,7 @@ package body Sem_Prag is -- Follow subprogram renaming chain if Is_Subprogram (Def_Id) - and then Nkind (Parent (Declaration_Node (Def_Id))) = + and then Parent_Kind (Declaration_Node (Def_Id)) = N_Subprogram_Renaming_Declaration and then Present (Alias (Def_Id)) then diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index be09453..e639fab 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -9162,8 +9162,9 @@ package body Sem_Res is return; end if; - if Nkind (Parent (N)) = N_Indexed_Component - or else Nkind (Parent (Parent (N))) = N_Indexed_Component + if Present (Parent (N)) + and then (Nkind (Parent (N)) = N_Indexed_Component + or else Nkind (Parent (Parent (N))) = N_Indexed_Component) then Result_Type := Base_Type (Typ); end if; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 479bb14..a543268 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -2027,7 +2027,7 @@ package body Sem_Util is -- the original constraint from its component declaration. Sel := Entity (Selector_Name (N)); - if Nkind (Parent (Sel)) /= N_Component_Declaration then + if Parent_Kind (Sel) /= N_Component_Declaration then return Empty; end if; end if; @@ -6366,8 +6366,8 @@ package body Sem_Util is Is_Type_In_Pkg := Is_Package_Or_Generic_Package (B_Scope) and then - Nkind (Parent (Declaration_Node (First_Subtype (T)))) /= - N_Package_Body; + Parent_Kind (Declaration_Node (First_Subtype (T))) /= + N_Package_Body; while Present (Id) loop @@ -6385,8 +6385,8 @@ package body Sem_Util is and then (Is_Type_In_Pkg or else Is_Derived_Type (B_Type) or else Is_Primitive (Id)) - and then Nkind (Parent (Parent (Id))) - not in N_Formal_Subprogram_Declaration + and then Parent_Kind (Parent (Id)) + not in N_Formal_Subprogram_Declaration then Is_Prim := False; @@ -10772,22 +10772,26 @@ package body Sem_Util is when E_Class_Wide_Type => return Get_Fullest_View (Root_Type (E), Include_PAT); - when E_Class_Wide_Subtype => + when E_Class_Wide_Subtype => if Present (Equivalent_Type (E)) then return Get_Fullest_View (Equivalent_Type (E), Include_PAT); elsif Present (Cloned_Subtype (E)) then return Get_Fullest_View (Cloned_Subtype (E), Include_PAT); end if; - when E_Protected_Type | E_Protected_Subtype - | E_Task_Type | E_Task_Subtype => + when E_Protected_Subtype + | E_Protected_Type + | E_Task_Subtype + | E_Task_Type + => if Present (Corresponding_Record_Type (E)) then return Get_Fullest_View (Corresponding_Record_Type (E), Include_PAT); end if; when E_Access_Protected_Subprogram_Type - | E_Anonymous_Access_Protected_Subprogram_Type => + | E_Anonymous_Access_Protected_Subprogram_Type + => if Present (Equivalent_Type (E)) then return Get_Fullest_View (Equivalent_Type (E), Include_PAT); end if; @@ -20042,7 +20046,8 @@ package body Sem_Util is function Is_Renamed_Entry (Proc_Nam : Entity_Id) return Boolean is Orig_Node : Node_Id := Empty; - Subp_Decl : Node_Id := Parent (Parent (Proc_Nam)); + Subp_Decl : Node_Id := + (if No (Parent (Proc_Nam)) then Empty else Parent (Parent (Proc_Nam))); function Is_Entry (Nam : Node_Id) return Boolean; -- Determine whether Nam is an entry. Traverse selectors if there are @@ -24339,6 +24344,26 @@ package body Sem_Util is EWA_Inner_Scope_Level := EWA_Inner_Scope_Level + 1; end if; + -- If the node is a block, we need to process all declarations + -- in the block and make new entities for each. + + if Nkind (N) = N_Block_Statement and then Present (Declarations (N)) + then + declare + Decl : Node_Id := First (Declarations (N)); + + begin + while Present (Decl) loop + if Nkind (Decl) = N_Object_Declaration then + Add_New_Entity (Defining_Identifier (Decl), + New_Copy (Defining_Identifier (Decl))); + end if; + + Next (Decl); + end loop; + end; + end if; + declare procedure Action (U : Union_Id); procedure Action (U : Union_Id) is @@ -27072,7 +27097,7 @@ package body Sem_Util is -- or an exception handler). We skip this if Cond is True, since the -- capturing of values from conditional tests handles this ok. - if Cond then + if Cond or else No (N) then return True; end if; @@ -29471,42 +29496,55 @@ package body Sem_Util is -------------------- function Validated_View (Typ : Entity_Id) return Entity_Id is - Continue : Boolean; - Val_Typ : Entity_Id; - begin - Continue := True; - Val_Typ := Base_Type (Typ); + -- Scalar types can be always validated. In fast, switiching to the base + -- type would drop the range constraints and force validation to use a + -- larger type than necessary. + + if Is_Scalar_Type (Typ) then + return Typ; + + -- Array types can be validated even when they are derived, because + -- validation only requires their bounds and component types to be + -- accessible. In fact, switching to the parent type would pollute + -- expansion of attribute Valid_Scalars with unnecessary conversion + -- that might not be eliminated by the frontend. + + elsif Is_Array_Type (Typ) then + return Typ; + + -- For other types, in particular for record subtypes, we switch to the + -- base type. + + elsif not Is_Base_Type (Typ) then + return Validated_View (Base_Type (Typ)); -- Obtain the full view of the input type by stripping away concurrency, -- derivations, and privacy. - while Continue loop - Continue := False; - - if Is_Concurrent_Type (Val_Typ) then - if Present (Corresponding_Record_Type (Val_Typ)) then - Continue := True; - Val_Typ := Corresponding_Record_Type (Val_Typ); - end if; + elsif Is_Concurrent_Type (Typ) then + if Present (Corresponding_Record_Type (Typ)) then + return Corresponding_Record_Type (Typ); + else + return Typ; + end if; - elsif Is_Derived_Type (Val_Typ) then - Continue := True; - Val_Typ := Etype (Val_Typ); + elsif Is_Derived_Type (Typ) then + return Validated_View (Etype (Typ)); - elsif Is_Private_Type (Val_Typ) then - if Present (Underlying_Full_View (Val_Typ)) then - Continue := True; - Val_Typ := Underlying_Full_View (Val_Typ); + elsif Is_Private_Type (Typ) then + if Present (Underlying_Full_View (Typ)) then + return Validated_View (Underlying_Full_View (Typ)); - elsif Present (Full_View (Val_Typ)) then - Continue := True; - Val_Typ := Full_View (Val_Typ); - end if; + elsif Present (Full_View (Typ)) then + return Validated_View (Full_View (Typ)); + else + return Typ; end if; - end loop; - return Val_Typ; + else + return Typ; + end if; end Validated_View; ----------------------- diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index a1ed43c..10375ff 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -1328,9 +1328,9 @@ package Sem_Util is function Get_Fullest_View (E : Entity_Id; Include_PAT : Boolean := True) return Entity_Id; - -- Get the fullest possible view of E, looking through private, - -- limited, packed array and other implementation types. If Include_PAT - -- is False, don't look inside packed array types. + -- Get the fullest possible view of E, looking through private, limited, + -- packed array and other implementation types. If Include_PAT is False, + -- don't look inside packed array types. function Has_Access_Values (T : Entity_Id) return Boolean; -- Returns true if the underlying type of T is an access type, or has a @@ -3290,7 +3290,7 @@ package Sem_Util is function Validated_View (Typ : Entity_Id) return Entity_Id; -- Obtain the "validated view" of arbitrary type Typ which is suitable for - -- verification by attributes 'Valid_Scalars. This view is the type itself + -- verification by attribute 'Valid_Scalars. This view is the type itself -- or its full view while stripping away concurrency, derivations, and -- privacy. diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index 23f2771..9e337f9 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -3729,6 +3729,11 @@ package body Sem_Warn is if Nkind (N) not in N_Subprogram_Call | N_Entry_Call_Statement then return; + + -- Guard against previous errors + + elsif Error_Posted (N) then + return; end if; -- If a call C has two or more parameters of mode in out or out that are @@ -3800,10 +3805,9 @@ package body Sem_Warn is and then Is_Composite_Type (Etype (Form1))) then - -- Guard against previous errors + -- Guard against previous errors - if Error_Posted (N) - or else No (Etype (Act1)) + if No (Etype (Act1)) or else No (Etype (Act2)) then null; diff --git a/gcc/ada/sinfo-utils.adb b/gcc/ada/sinfo-utils.adb index f9db669..7f9bb89 100644 --- a/gcc/ada/sinfo-utils.adb +++ b/gcc/ada/sinfo-utils.adb @@ -137,6 +137,29 @@ package body Sinfo.Utils is Write_Eol; end Node_Debug_Output; + ------------------------------- + -- Parent-related operations -- + ------------------------------- + + procedure Copy_Parent (To, From : Node_Or_Entity_Id) is + begin + if Atree.Present (To) and Atree.Present (From) then + Atree.Set_Parent (To, Atree.Parent (From)); + else + pragma Assert + (if Atree.Present (To) then Atree.No (Atree.Parent (To))); + end if; + end Copy_Parent; + + function Parent_Kind (N : Node_Id) return Node_Kind is + begin + if Atree.No (N) then + return N_Empty; + else + return Nkind (Atree.Parent (N)); + end if; + end Parent_Kind; + ------------------------- -- Iterator Procedures -- ------------------------- diff --git a/gcc/ada/sinfo-utils.ads b/gcc/ada/sinfo-utils.ads index ab8e528..2023e67 100644 --- a/gcc/ada/sinfo-utils.ads +++ b/gcc/ada/sinfo-utils.ads @@ -27,6 +27,18 @@ with Sinfo.Nodes; use Sinfo.Nodes; package Sinfo.Utils is + ------------------------------- + -- Parent-related operations -- + ------------------------------- + + procedure Copy_Parent (To, From : Node_Or_Entity_Id); + -- Does Set_Parent (To, Parent (From)), except that if To or From are + -- empty, does nothing. If From is empty but To is not, then Parent (To) + -- should already be Empty. + + function Parent_Kind (N : Node_Id) return Node_Kind; + -- Same as Nkind (Parent (N)), except if N is Empty, return N_Empty + ------------------------- -- Iterator Procedures -- ------------------------- diff --git a/gcc/ada/style.adb b/gcc/ada/style.adb index a34d3e0..1409cc6 100644 --- a/gcc/ada/style.adb +++ b/gcc/ada/style.adb @@ -136,48 +136,42 @@ package body Style is Tref := Source_Text (Get_Source_File_Index (Sref)); Tdef := Source_Text (Get_Source_File_Index (Sdef)); - -- Ignore operator name case completely. This also catches the - -- case of where one is an operator and the other is not. This - -- is a phenomenon from rewriting of operators as functions, - -- and is to be ignored. + -- Ignore case of operator names. This also catches the case + -- where one is an operator and the other is not. This is a + -- phenomenon from rewriting of operators as functions, and is + -- to be ignored. if Tref (Sref) = '"' or else Tdef (Sdef) = '"' then return; else - while Tref (Sref) = Tdef (Sdef) loop + loop + -- If end of identifiers, all done. Note that they are the + -- same length. - -- If end of identifier, all done + pragma Assert + (Identifier_Char (Tref (Sref)) = + Identifier_Char (Tdef (Sdef))); if not Identifier_Char (Tref (Sref)) then return; - - -- Otherwise loop continues - - else - Sref := Sref + 1; - Sdef := Sdef + 1; end if; - end loop; - -- Fall through loop when mismatch between identifiers - -- If either identifier is not terminated, error. + -- Case mismatch - if Identifier_Char (Tref (Sref)) - or else - Identifier_Char (Tdef (Sdef)) - then - Error_Msg_Node_1 := Def; - Error_Msg_Sloc := Sloc (Def); - Error_Msg -- CODEFIX - ("(style) bad casing of & declared#", Sref, Ref); - return; + if Tref (Sref) /= Tdef (Sdef) then + Error_Msg_Node_1 := Def; + Error_Msg_Sloc := Sloc (Def); + Error_Msg -- CODEFIX + ("(style) bad casing of & declared#", Sref, Ref); + return; + end if; - -- Else end of identifiers, and they match + Sref := Sref + 1; + Sdef := Sdef + 1; + end loop; - else - return; - end if; + pragma Assert (False); end if; end if; diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb index 519242e..ff4ff84 100644 --- a/gcc/ada/treepr.adb +++ b/gcc/ada/treepr.adb @@ -412,7 +412,7 @@ package body Treepr is return Nlists.Parent (List_Id (N)); when Node_Range => - return Atree.Parent (Node_Or_Entity_Id (N)); + return Parent (Node_Or_Entity_Id (N)); when others => Write_Int (Int (N)); diff --git a/gcc/btfout.c b/gcc/btfout.c index 2316dea..e58c969 100644 --- a/gcc/btfout.c +++ b/gcc/btfout.c @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" #include "target.h" +#include "memmodel.h" #include "tm_p.h" #include "output.h" #include "dwarf2asm.h" diff --git a/gcc/common.opt b/gcc/common.opt index 1dd4456..eaee74c 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2100,9 +2100,15 @@ fnon-call-exceptions Common Var(flag_non_call_exceptions) Optimization Support synchronous non-call exceptions. +; -foffload=<targets> is documented +; -foffload=<targets>=<options> is supported for backward compatibility foffload= -Common Driver Joined MissingArgError(options or targets missing after %qs) --foffload=<targets>=<options> Specify offloading targets and options for them. +Driver Joined MissingArgError(targets missing after %qs) +-foffload=<targets> Specify offloading targets + +foffload-options= +Common Driver Joined MissingArgError(options or targets=options missing after %qs) +-foffload=<targets>=<options> Specify options for the offloading targets foffload-abi= Common Joined RejectNegative Enum(offload_abi) Var(flag_offload_abi) Init(OFFLOAD_ABI_UNSET) diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c index 54a1c0b..aa9d455 100644 --- a/gcc/config/gcn/gcn.c +++ b/gcc/config/gcn/gcn.c @@ -3610,6 +3610,34 @@ gcn_init_builtins (void) #endif } +/* Implement TARGET_INIT_LIBFUNCS. */ + +static void +gcn_init_libfuncs (void) +{ + /* BITS_PER_UNIT * 2 is 64 bits, which causes + optabs-libfuncs.c:gen_int_libfunc to omit TImode (i.e 128 bits) + libcalls that we need to support operations for that type. Initialise + them here instead. */ + set_optab_libfunc (udiv_optab, TImode, "__udivti3"); + set_optab_libfunc (umod_optab, TImode, "__umodti3"); + set_optab_libfunc (sdiv_optab, TImode, "__divti3"); + set_optab_libfunc (smod_optab, TImode, "__modti3"); + set_optab_libfunc (smul_optab, TImode, "__multi3"); + set_optab_libfunc (addv_optab, TImode, "__addvti3"); + set_optab_libfunc (subv_optab, TImode, "__subvti3"); + set_optab_libfunc (negv_optab, TImode, "__negvti2"); + set_optab_libfunc (absv_optab, TImode, "__absvti2"); + set_optab_libfunc (smulv_optab, TImode, "__mulvti3"); + set_optab_libfunc (ffs_optab, TImode, "__ffsti2"); + set_optab_libfunc (clz_optab, TImode, "__clzti2"); + set_optab_libfunc (ctz_optab, TImode, "__ctzti2"); + set_optab_libfunc (clrsb_optab, TImode, "__clrsbti2"); + set_optab_libfunc (popcount_optab, TImode, "__popcountti2"); + set_optab_libfunc (parity_optab, TImode, "__parityti2"); + set_optab_libfunc (bswap_optab, TImode, "__bswapti2"); +} + /* Expand the CMP_SWAP GCN builtins. We have our own versions that do not require taking the address of any object, other than the memory cell being operated on. @@ -6345,6 +6373,8 @@ gcn_dwarf_register_span (rtx rtl) #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed #undef TARGET_INIT_BUILTINS #define TARGET_INIT_BUILTINS gcn_init_builtins +#undef TARGET_INIT_LIBFUNCS +#define TARGET_INIT_LIBFUNCS gcn_init_libfuncs #undef TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS #define TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS \ gcn_ira_change_pseudo_allocno_class diff --git a/gcc/config/gcn/gcn.h b/gcc/config/gcn/gcn.h index eba4646..540835b 100644 --- a/gcc/config/gcn/gcn.h +++ b/gcc/config/gcn/gcn.h @@ -46,9 +46,12 @@ #define BYTES_BIG_ENDIAN 0 #define WORDS_BIG_ENDIAN 0 -#define BITS_PER_WORD 32 -#define UNITS_PER_WORD (BITS_PER_WORD/BITS_PER_UNIT) -#define LIBGCC2_UNITS_PER_WORD 4 +#ifdef IN_LIBGCC2 +/* We want DImode and TImode helpers. */ +#define UNITS_PER_WORD 8 +#else +#define UNITS_PER_WORD 4 +#endif #define POINTER_SIZE 64 #define PARM_BOUNDARY 64 @@ -56,7 +59,7 @@ #define FUNCTION_BOUNDARY 32 #define BIGGEST_ALIGNMENT 64 #define EMPTY_FIELD_BOUNDARY 32 -#define MAX_FIXED_MODE_SIZE 64 +#define MAX_FIXED_MODE_SIZE 128 #define MAX_REGS_PER_ADDRESS 2 #define STACK_SIZE_MODE DImode #define Pmode DImode diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index b5f895a..ae7249a 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -81,7 +81,8 @@ UNSPEC_MOV_FROM_LANE63 UNSPEC_GATHER UNSPEC_SCATTER - UNSPEC_RCP]) + UNSPEC_RCP + UNSPEC_FLBIT_INT]) ;; }}} ;; {{{ Attributes @@ -338,7 +339,8 @@ [(not "not%b") (popcount "bcnt1_i32%b") (clz "flbit_i32%b") - (ctz "ff1_i32%b")]) + (ctz "ff1_i32%b") + (clrsb "flbit_i32%i")]) (define_code_attr revmnemonic [(minus "subrev%i") @@ -1371,10 +1373,13 @@ ; Vector multiply has vop3a encoding, but no corresponding vop2a, so no long ; immediate. +; The "s_mulk_i32" variant sets SCC to indicate overflow (which we don't care +; about here, but we need to indicate the clobbering). (define_insn "mulsi3" [(set (match_operand:SI 0 "register_operand" "= Sg,Sg, Sg, v") (mult:SI (match_operand:SI 1 "gcn_alu_operand" "%SgA, 0,SgA, v") - (match_operand:SI 2 "gcn_alu_operand" " SgA, J, B,vASv")))] + (match_operand:SI 2 "gcn_alu_operand" " SgA, J, B,vASv"))) + (clobber (match_scratch:BI 3 "=X,cs, X, X"))] "" "@ s_mul_i32\t%0, %1, %2 @@ -1391,20 +1396,162 @@ (define_code_attr iu [(sign_extend "i") (zero_extend "u")]) (define_code_attr e [(sign_extend "e") (zero_extend "")]) -(define_insn "<su>mulsi3_highpart" - [(set (match_operand:SI 0 "register_operand" "= v") +(define_expand "<su>mulsi3_highpart" + [(set (match_operand:SI 0 "register_operand" "") (truncate:SI (lshiftrt:DI (mult:DI (any_extend:DI - (match_operand:SI 1 "register_operand" "% v")) + (match_operand:SI 1 "register_operand" "")) (any_extend:DI - (match_operand:SI 2 "register_operand" "vSv"))) + (match_operand:SI 2 "gcn_alu_operand" ""))) (const_int 32))))] "" - "v_mul_hi<sgnsuffix>0\t%0, %2, %1" - [(set_attr "type" "vop3a") - (set_attr "length" "8")]) +{ + if (can_create_pseudo_p () + && !TARGET_GCN5 + && !gcn_inline_immediate_operand (operands[2], SImode)) + operands[2] = force_reg (SImode, operands[2]); + + if (REG_P (operands[2])) + emit_insn (gen_<su>mulsi3_highpart_reg (operands[0], operands[1], + operands[2])); + else + emit_insn (gen_<su>mulsi3_highpart_imm (operands[0], operands[1], + operands[2])); + + DONE; +}) + +(define_insn "<su>mulsi3_highpart_reg" + [(set (match_operand:SI 0 "register_operand" "=Sg, v") + (truncate:SI + (lshiftrt:DI + (mult:DI + (any_extend:DI + (match_operand:SI 1 "register_operand" "%Sg, v")) + (any_extend:DI + (match_operand:SI 2 "register_operand" "Sg,vSv"))) + (const_int 32))))] + "" + "@ + s_mul_hi<sgnsuffix>0\t%0, %1, %2 + v_mul_hi<sgnsuffix>0\t%0, %2, %1" + [(set_attr "type" "sop2,vop3a") + (set_attr "length" "4,8") + (set_attr "gcn_version" "gcn5,*")]) + +(define_insn "<su>mulsi3_highpart_imm" + [(set (match_operand:SI 0 "register_operand" "=Sg,Sg,v") + (truncate:SI + (lshiftrt:DI + (mult:DI + (any_extend:DI + (match_operand:SI 1 "register_operand" "Sg,Sg,v")) + (match_operand:DI 2 "gcn_32bit_immediate_operand" "A, B,A")) + (const_int 32))))] + "TARGET_GCN5 || gcn_inline_immediate_operand (operands[2], SImode)" + "@ + s_mul_hi<sgnsuffix>0\t%0, %1, %2 + s_mul_hi<sgnsuffix>0\t%0, %1, %2 + v_mul_hi<sgnsuffix>0\t%0, %2, %1" + [(set_attr "type" "sop2,sop2,vop3a") + (set_attr "length" "4,8,8") + (set_attr "gcn_version" "gcn5,gcn5,*")]) + +(define_expand "<su>mulsidi3" + [(set (match_operand:DI 0 "register_operand" "") + (mult:DI (any_extend:DI + (match_operand:SI 1 "register_operand" "")) + (any_extend:DI + (match_operand:SI 2 "nonmemory_operand" ""))))] + "" +{ + if (can_create_pseudo_p () + && !TARGET_GCN5 + && !gcn_inline_immediate_operand (operands[2], SImode)) + operands[2] = force_reg (SImode, operands[2]); + + if (REG_P (operands[2])) + emit_insn (gen_<su>mulsidi3_reg (operands[0], operands[1], operands[2])); + else + emit_insn (gen_<su>mulsidi3_imm (operands[0], operands[1], operands[2])); + + DONE; +}) + +(define_insn_and_split "<su>mulsidi3_reg" + [(set (match_operand:DI 0 "register_operand" "=&Sg, &v") + (mult:DI (any_extend:DI + (match_operand:SI 1 "register_operand" "%Sg, v")) + (any_extend:DI + (match_operand:SI 2 "register_operand" "Sg,vSv"))))] + "" + "#" + "reload_completed" + [(const_int 0)] + { + rtx dstlo = gen_lowpart (SImode, operands[0]); + rtx dsthi = gen_highpart_mode (SImode, DImode, operands[0]); + emit_insn (gen_mulsi3 (dstlo, operands[1], operands[2])); + emit_insn (gen_<su>mulsi3_highpart (dsthi, operands[1], operands[2])); + DONE; + } + [(set_attr "gcn_version" "gcn5,*")]) + +(define_insn_and_split "<su>mulsidi3_imm" + [(set (match_operand:DI 0 "register_operand" "=&Sg,&Sg,&v") + (mult:DI (any_extend:DI + (match_operand:SI 1 "register_operand" "Sg, Sg, v")) + (match_operand:DI 2 "gcn_32bit_immediate_operand" + "A, B, A")))] + "TARGET_GCN5 || gcn_inline_immediate_operand (operands[2], SImode)" + "#" + "&& reload_completed" + [(const_int 0)] + { + rtx dstlo = gen_lowpart (SImode, operands[0]); + rtx dsthi = gen_highpart_mode (SImode, DImode, operands[0]); + emit_insn (gen_mulsi3 (dstlo, operands[1], operands[2])); + emit_insn (gen_<su>mulsi3_highpart (dsthi, operands[1], operands[2])); + DONE; + } + [(set_attr "gcn_version" "gcn5,gcn5,*")]) + +(define_insn_and_split "muldi3" + [(set (match_operand:DI 0 "register_operand" "=&Sg,&Sg, &v,&v") + (mult:DI (match_operand:DI 1 "register_operand" "%Sg, Sg, v, v") + (match_operand:DI 2 "nonmemory_operand" "Sg, i,vSv, A"))) + (clobber (match_scratch:SI 3 "=&Sg,&Sg,&v,&v")) + (clobber (match_scratch:BI 4 "=cs, cs, X, X")) + (clobber (match_scratch:DI 5 "=X, X,cV,cV"))] + "" + "#" + "reload_completed" + [(const_int 0)] + { + rtx tmp = operands[3]; + rtx dsthi = gen_highpart_mode (SImode, DImode, operands[0]); + rtx op1lo = gcn_operand_part (DImode, operands[1], 0); + rtx op1hi = gcn_operand_part (DImode, operands[1], 1); + rtx op2lo = gcn_operand_part (DImode, operands[2], 0); + rtx op2hi = gcn_operand_part (DImode, operands[2], 1); + emit_insn (gen_umulsidi3 (operands[0], op1lo, op2lo)); + emit_insn (gen_mulsi3 (tmp, op1lo, op2hi)); + rtx add = gen_rtx_SET (dsthi, gen_rtx_PLUS (SImode, dsthi, tmp)); + rtx clob1 = gen_rtx_CLOBBER (VOIDmode, operands[4]); + rtx clob2 = gen_rtx_CLOBBER (VOIDmode, operands[5]); + add = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (3, add, clob1, clob2)); + emit_insn (add); + emit_insn (gen_mulsi3 (tmp, op1hi, op2lo)); + add = gen_rtx_SET (dsthi, gen_rtx_PLUS (SImode, dsthi, tmp)); + clob1 = gen_rtx_CLOBBER (VOIDmode, operands[4]); + clob2 = gen_rtx_CLOBBER (VOIDmode, operands[5]); + add = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (3, add, clob1, clob2)); + emit_insn (add); + DONE; + } + [(set_attr "gcn_version" "gcn5,gcn5,*,*")]) (define_insn "<u>mulhisi3" [(set (match_operand:SI 0 "register_operand" "=v") @@ -1466,6 +1613,40 @@ [(set_attr "type" "sop1") (set_attr "length" "4,8")]) +(define_insn "gcn_flbit<mode>_int" + [(set (match_operand:SI 0 "register_operand" "=Sg,Sg") + (unspec:SI [(match_operand:SIDI 1 "gcn_alu_operand" "SgA, B")] + UNSPEC_FLBIT_INT))] + "" + { + if (<MODE>mode == SImode) + return "s_flbit_i32\t%0, %1"; + else + return "s_flbit_i32_i64\t%0, %1"; + } + [(set_attr "type" "sop1") + (set_attr "length" "4,8")]) + +(define_expand "clrsb<mode>2" + [(set (match_operand:SI 0 "register_operand" "") + (clrsb:SI (match_operand:SIDI 1 "gcn_alu_operand" "")))] + "" + { + rtx tmp = gen_reg_rtx (SImode); + /* FLBIT_I* counts sign or zero bits at the most-significant end of the + input register (and returns -1 for 0/-1 inputs). We want the number of + *redundant* bits (i.e. that value minus one), and an answer of 31/63 for + 0/-1 inputs. We can do that in three instructions... */ + emit_insn (gen_gcn_flbit<mode>_int (tmp, operands[1])); + emit_insn (gen_uminsi3 (tmp, tmp, + gen_int_mode (GET_MODE_BITSIZE (<MODE>mode), + SImode))); + /* If we put this last, it can potentially be folded into a subsequent + arithmetic operation. */ + emit_insn (gen_subsi3 (operands[0], tmp, const1_rtx)); + DONE; + }) + ;; }}} ;; {{{ ALU: generic 32-bit binop diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md index e887f034..5f105727 100644 --- a/gcc/config/i386/mmx.md +++ b/gcc/config/i386/mmx.md @@ -788,6 +788,24 @@ (set_attr "prefix_extra" "1") (set_attr "mode" "V2SF")]) +(define_insn "vec_addsubv2sf3" + [(set (match_operand:V2SF 0 "register_operand" "=x,x") + (vec_merge:V2SF + (minus:V2SF + (match_operand:V2SF 1 "register_operand" "0,x") + (match_operand:V2SF 2 "register_operand" "x,x")) + (plus:V2SF (match_dup 1) (match_dup 2)) + (const_int 1)))] + "TARGET_SSE3 && TARGET_MMX_WITH_SSE" + "@ + addsubps\t{%2, %0|%0, %2} + vaddsubps\t{%2, %1, %0|%0, %1, %2}" + [(set_attr "isa" "noavx,avx") + (set_attr "type" "sseadd") + (set_attr "prefix" "orig,vex") + (set_attr "prefix_rep" "1,*") + (set_attr "mode" "V4SF")]) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Parallel single-precision floating point comparisons diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index ffcc0c8..d3f5a74 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -9942,7 +9942,7 @@ DONE; }) -(define_insn "avx512f_sfixupimm<mode><sd_maskz_name><round_saeonly_name>" +(define_insn "avx512f_sfixupimm<mode><maskz_scalar_name><round_saeonly_name>" [(set (match_operand:VF_128 0 "register_operand" "=v") (vec_merge:VF_128 (unspec:VF_128 @@ -9951,10 +9951,10 @@ (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>") (match_operand:SI 4 "const_0_to_255_operand")] UNSPEC_FIXUPIMM) - (match_dup 1) + (match_dup 2) (const_int 1)))] "TARGET_AVX512F" - "vfixupimm<ssescalarmodesuffix>\t{%4, <round_saeonly_sd_mask_op5>%3, %2, %0<sd_mask_op5>|%0<sd_mask_op5>, %2, %<iptr>3<round_saeonly_sd_mask_op5>, %4}"; + "vfixupimm<ssescalarmodesuffix>\t{%4, <round_saeonly_maskz_scalar_op5>%3, %2, %0<maskz_scalar_op5>|%0<maskz_scalar_op5>, %2, %<iptr>3<round_saeonly_maskz_scalar_op5>, %4}"; [(set_attr "prefix" "evex") (set_attr "mode" "<ssescalarmode>")]) @@ -9968,7 +9968,7 @@ (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>") (match_operand:SI 4 "const_0_to_255_operand")] UNSPEC_FIXUPIMM) - (match_dup 1) + (match_dup 2) (const_int 1)) (match_dup 1) (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))] diff --git a/gcc/config/i386/subst.md b/gcc/config/i386/subst.md index 477a898..6614e04 100644 --- a/gcc/config/i386/subst.md +++ b/gcc/config/i386/subst.md @@ -117,6 +117,25 @@ (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk"))) ]) +(define_subst_attr "maskz_scalar_name" "maskz_scalar" "" "_maskz_1") +(define_subst_attr "maskz_scalar_op5" "maskz_scalar" "" "%{%6%}%N5") + +(define_subst "maskz_scalar" + [(set (match_operand:SUBST_V 0) + (vec_merge:SUBST_V + (match_operand:SUBST_V 1) + (match_operand:SUBST_V 2) + (const_int 1)))] + "TARGET_AVX512F" + [(set (match_dup 0) + (vec_merge:SUBST_V + (vec_merge:SUBST_V + (match_dup 1) + (match_operand:SUBST_V 3 "const0_operand" "C") + (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")) + (match_dup 2) + (const_int 1)))]) + (define_subst_attr "round_name" "round" "" "_round") (define_subst_attr "round_mask_operand2" "mask" "%R2" "%R4") (define_subst_attr "round_mask_operand3" "mask" "%R3" "%R5") @@ -163,6 +182,7 @@ (define_subst_attr "round_saeonly_mask_operand3" "mask" "%r3" "%r5") (define_subst_attr "round_saeonly_mask_operand4" "mask" "%r4" "%r6") (define_subst_attr "round_saeonly_mask_scalar_merge_operand4" "mask_scalar_merge" "%r4" "%r5") +(define_subst_attr "round_saeonly_maskz_scalar_operand5" "maskz_scalar" "%r5" "%r7") (define_subst_attr "round_saeonly_sd_mask_operand5" "sd" "%r5" "%r7") (define_subst_attr "round_saeonly_op2" "round_saeonly" "" "%r2") (define_subst_attr "round_saeonly_op3" "round_saeonly" "" "%r3") @@ -175,6 +195,7 @@ (define_subst_attr "round_saeonly_mask_op4" "round_saeonly" "" "<round_saeonly_mask_operand4>") (define_subst_attr "round_saeonly_mask_scalar_merge_op4" "round_saeonly" "" "<round_saeonly_mask_scalar_merge_operand4>") (define_subst_attr "round_saeonly_sd_mask_op5" "round_saeonly" "" "<round_saeonly_sd_mask_operand5>") +(define_subst_attr "round_saeonly_maskz_scalar_op5" "round_saeonly" "" "<round_saeonly_maskz_scalar_operand5>") (define_subst_attr "round_saeonly_mask_arg3" "round_saeonly" "" ", operands[<mask_expand_op3>]") (define_subst_attr "round_saeonly_constraint" "round_saeonly" "vm" "v") (define_subst_attr "round_saeonly_constraint2" "round_saeonly" "m" "v") diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c index b663b43..4cab3ae 100644 --- a/gcc/config/pdp11/pdp11.c +++ b/gcc/config/pdp11/pdp11.c @@ -829,12 +829,12 @@ pdp11_asm_print_operand_punct_valid_p (unsigned char c) } void -print_operand_address (FILE *file, register rtx addr) +print_operand_address (FILE *file, rtx addr) { - register rtx breg; + rtx breg; rtx offset; int again = 0; - + retry: switch (GET_CODE (addr)) @@ -1160,12 +1160,11 @@ pdp11_addr_cost (rtx addr, machine_mode mode, addr_space_t as ATTRIBUTE_UNUSED, static int pdp11_insn_cost (rtx_insn *insn, bool speed) { - int base_cost, i; + int base_cost; rtx pat, set, dest, src, src2; machine_mode mode; - const char *fmt; enum rtx_code op; - + if (recog_memoized (insn) < 0) return 0; @@ -1462,24 +1461,24 @@ bool pushpop_regeq (rtx op, int regno) { rtx addr; - + /* False if not memory reference. */ if (GET_CODE (op) != MEM) return FALSE; - + /* Get the address of the memory reference. */ addr = XEXP (op, 0); if (GET_CODE (addr) == MEM) addr = XEXP (addr, 0); - + switch (GET_CODE (addr)) { case PRE_DEC: case POST_INC: case PRE_MODIFY: case POST_MODIFY: - return REGNO (XEXP (addr, 0)) == regno; + return REGNO (XEXP (addr, 0)) == (unsigned) regno; default: return FALSE; } @@ -1771,8 +1770,7 @@ int pdp11_initial_elimination_offset (int from, int to) { /* Get the size of the register save area. */ - int spoff; - + if (from == FRAME_POINTER_REGNUM && to == STACK_POINTER_REGNUM) return get_frame_size (); else if (from == ARG_POINTER_REGNUM && to == FRAME_POINTER_REGNUM) @@ -2106,15 +2104,14 @@ pdp11_cmp_length (rtx *operands, int words) { rtx inops[2]; rtx exops[4][2]; - rtx lb[1]; int i, len = 0; if (!reload_completed) return 2; - + inops[0] = operands[0]; inops[1] = operands[1]; - + pdp11_expand_operands (inops, exops, 2, words, NULL, big); for (i = 0; i < words; i++) diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h index a21ae64..9bc5e08 100644 --- a/gcc/config/pdp11/pdp11.h +++ b/gcc/config/pdp11/pdp11.h @@ -618,10 +618,12 @@ extern int current_first_parm_offset; fprintf (FILE, "\t.even\n") #define ASM_OUTPUT_SKIP(FILE,SIZE) \ - if (TARGET_DEC_ASM) \ - fprintf (FILE, "\t.blkb\t%o\n", (SIZE) & 0xffff); \ - else \ - fprintf (FILE, "\t.=.+ %#o\n", (SIZE) & 0xffff); + do { \ + if (TARGET_DEC_ASM) \ + fprintf (FILE, "\t.blkb\t%o\n", (int) ((SIZE) & 0xffff)); \ + else \ + fprintf (FILE, "\t.=.+ %#o\n", (int) ((SIZE) & 0xffff)); \ + } while (0) /* This says how to output an assembler line to define a global common symbol. */ diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 2c249e1..075c156 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0-or-later /* Subroutines used for code generation on IBM RS/6000. Copyright (C) 1991-2021 Free Software Foundation, Inc. Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) @@ -21361,8 +21362,11 @@ rs6000_xcoff_section_type_flags (tree decl, const char *name, int reloc) flags |= SECTION_BSS; /* Align to at least UNIT size. */ - if ((flags & SECTION_CODE) != 0 || !decl || !DECL_P (decl)) + if (!decl || !DECL_P (decl)) align = MIN_UNITS_PER_WORD; + /* Align code CSECT to at least 32 bytes. */ + else if ((flags & SECTION_CODE) != 0) + align = MAX ((DECL_ALIGN (decl) / BITS_PER_UNIT), 32); else /* Increase alignment of large objects if not already stricter. */ align = MAX ((DECL_ALIGN (decl) / BITS_PER_UNIT), diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h index 5ba565f..f3546fa 100644 --- a/gcc/config/rs6000/xcoff.h +++ b/gcc/config/rs6000/xcoff.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0-or-later /* Definitions of target machine for GNU compiler, for some generic XCOFF file format Copyright (C) 2001-2021 Free Software Foundation, Inc. @@ -249,7 +250,7 @@ #define DOUBLE_INT_ASM_OP "\t.llong\t" /* Output before instructions. */ -#define TEXT_SECTION_ASM_OP "\t.csect .text[PR]" +#define TEXT_SECTION_ASM_OP "\t.csect .text[PR],5" /* Output before writable data. */ #define DATA_SECTION_ASM_OP \ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3791ac4..01b29b1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2021-06-29 Jason Merrill <jason@redhat.com> + + * pt.c (instantiate_decl): Only consider partial specializations of + actual variable templates. + 2021-06-26 Patrick Palka <ppalka@redhat.com> PR c++/96204 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f2039e0..d2936c1 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -26003,7 +26003,7 @@ instantiate_decl (tree d, bool defer_ok, bool expl_inst_class_mem_p) td = template_for_substitution (d); args = gen_args; - if (VAR_P (d)) + if (variable_template_specialization_p (d)) { /* Look up an explicit specialization, if any. */ tree tid = lookup_template_variable (gen_tmpl, gen_args); diff --git a/gcc/ctfout.c b/gcc/ctfout.c index 71d7a62..682d852 100644 --- a/gcc/ctfout.c +++ b/gcc/ctfout.c @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" #include "target.h" +#include "memmodel.h" #include "tm_p.h" #include "output.h" #include "dwarf2asm.h" diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi index 642cbc8..d317f65 100644 --- a/gcc/doc/generic.texi +++ b/gcc/doc/generic.texi @@ -33,7 +33,7 @@ before handing off to @code{tree_rest_of_compilation}, but this seems inelegant. @menu -* Deficiencies:: Topics net yet covered in this document. +* Deficiencies:: Topics not yet covered in this document. * Tree overview:: All about @code{tree}s. * Types:: Fundamental and aggregate types. * Declarations:: Type declarations and variables. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index fa05888..073dff8 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -160,17 +160,17 @@ in the following sections. @item C Language Options @xref{C Dialect Options,,Options Controlling C Dialect}. -@gccoptlist{-ansi -std=@var{standard} -fgnu89-inline @gol --fpermitted-flt-eval-methods=@var{standard} @gol --aux-info @var{filename} -fallow-parameterless-variadic-functions @gol --fno-asm -fno-builtin -fno-builtin-@var{function} -fgimple@gol --fhosted -ffreestanding @gol +@gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} @gol +-fallow-parameterless-variadic-functions -fno-asm @gol +-fno-builtin -fno-builtin-@var{function} -fcond-mismatch @gol +-ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted @gol +-flax-vector-conversions -fms-extensions @gol +-foffload=@var{arg} -foffload-options=@var{arg} @gol -fopenacc -fopenacc-dim=@var{geom} @gol -fopenmp -fopenmp-simd @gol --fms-extensions -fplan9-extensions -fsso-struct=@var{endianness} @gol --fallow-single-precision -fcond-mismatch -flax-vector-conversions @gol --fsigned-bitfields -fsigned-char @gol --funsigned-bitfields -funsigned-char} +-fpermitted-flt-eval-methods=@var{standard} @gol +-fplan9-extensions -fsigned-bitfields -funsigned-bitfields @gol +-fsigned-char -funsigned-char -fsso-struct=@var{endianness}} @item C++ Language Options @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. @@ -2412,50 +2412,6 @@ and will almost certainly change in incompatible ways in future releases. @end table -@item -fgnu89-inline -@opindex fgnu89-inline -The option @option{-fgnu89-inline} tells GCC to use the traditional -GNU semantics for @code{inline} functions when in C99 mode. -@xref{Inline,,An Inline Function is As Fast As a Macro}. -Using this option is roughly equivalent to adding the -@code{gnu_inline} function attribute to all inline functions -(@pxref{Function Attributes}). - -The option @option{-fno-gnu89-inline} explicitly tells GCC to use the -C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it -specifies the default behavior). -This option is not supported in @option{-std=c90} or -@option{-std=gnu90} mode. - -The preprocessor macros @code{__GNUC_GNU_INLINE__} and -@code{__GNUC_STDC_INLINE__} may be used to check which semantics are -in effect for @code{inline} functions. @xref{Common Predefined -Macros,,,cpp,The C Preprocessor}. - -@item -fpermitted-flt-eval-methods=@var{style} -@opindex fpermitted-flt-eval-methods -@opindex fpermitted-flt-eval-methods=c11 -@opindex fpermitted-flt-eval-methods=ts-18661-3 -ISO/IEC TS 18661-3 defines new permissible values for -@code{FLT_EVAL_METHOD} that indicate that operations and constants with -a semantic type that is an interchange or extended format should be -evaluated to the precision and range of that type. These new values are -a superset of those permitted under C99/C11, which does not specify the -meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code -conforming to C11 may not have been written expecting the possibility of -the new values. - -@option{-fpermitted-flt-eval-methods} specifies whether the compiler -should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11, -or the extended set of values specified in ISO/IEC TS 18661-3. - -@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate. - -The default when in a standards compliant mode (@option{-std=c11} or similar) -is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU -dialect (@option{-std=gnu11} or similar) is -@option{-fpermitted-flt-eval-methods=ts-18661-3}. - @item -aux-info @var{filename} @opindex aux-info Output to the given filename prototyped declarations for all functions @@ -2536,6 +2492,25 @@ built-in functions selectively when using @option{-fno-builtin} or #define strcpy(d, s) __builtin_strcpy ((d), (s)) @end smallexample +@item -fcond-mismatch +@opindex fcond-mismatch +Allow conditional expressions with mismatched types in the second and +third arguments. The value of such an expression is void. This option +is not supported for C++. + +@item -ffreestanding +@opindex ffreestanding +@cindex hosted environment + +Assert that compilation targets a freestanding environment. This +implies @option{-fno-builtin}. A freestanding environment +is one in which the standard library may not exist, and program startup may +not necessarily be at @code{main}. The most obvious example is an OS kernel. +This is equivalent to @option{-fno-hosted}. + +@xref{Standards,,Language Standards Supported by GCC}, for details of +freestanding and hosted environments. + @item -fgimple @opindex fgimple @@ -2543,6 +2518,42 @@ Enable parsing of function definitions marked with @code{__GIMPLE}. This is an experimental feature that allows unit testing of GIMPLE passes. +@item -fgnu-tm +@opindex fgnu-tm +When the option @option{-fgnu-tm} is specified, the compiler +generates code for the Linux variant of Intel's current Transactional +Memory ABI specification document (Revision 1.1, May 6 2009). This is +an experimental feature whose interface may change in future versions +of GCC, as the official specification changes. Please note that not +all architectures are supported for this feature. + +For more information on GCC's support for transactional memory, +@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU +Transactional Memory Library}. + +Note that the transactional memory feature is not supported with +non-call exceptions (@option{-fnon-call-exceptions}). + +@item -fgnu89-inline +@opindex fgnu89-inline +The option @option{-fgnu89-inline} tells GCC to use the traditional +GNU semantics for @code{inline} functions when in C99 mode. +@xref{Inline,,An Inline Function is As Fast As a Macro}. +Using this option is roughly equivalent to adding the +@code{gnu_inline} function attribute to all inline functions +(@pxref{Function Attributes}). + +The option @option{-fno-gnu89-inline} explicitly tells GCC to use the +C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it +specifies the default behavior). +This option is not supported in @option{-std=c90} or +@option{-std=gnu90} mode. + +The preprocessor macros @code{__GNUC_GNU_INLINE__} and +@code{__GNUC_STDC_INLINE__} may be used to check which semantics are +in effect for @code{inline} functions. @xref{Common Predefined +Macros,,,cpp,The C Preprocessor}. + @item -fhosted @opindex fhosted @cindex hosted environment @@ -2553,18 +2564,72 @@ entire standard library is available, and in which @code{main} has a return type of @code{int}. Examples are nearly everything except a kernel. This is equivalent to @option{-fno-freestanding}. -@item -ffreestanding -@opindex ffreestanding -@cindex hosted environment +@item -flax-vector-conversions +@opindex flax-vector-conversions +Allow implicit conversions between vectors with differing numbers of +elements and/or incompatible element types. This option should not be +used for new code. -Assert that compilation targets a freestanding environment. This -implies @option{-fno-builtin}. A freestanding environment -is one in which the standard library may not exist, and program startup may -not necessarily be at @code{main}. The most obvious example is an OS kernel. -This is equivalent to @option{-fno-hosted}. +@item -fms-extensions +@opindex fms-extensions +Accept some non-standard constructs used in Microsoft header files. -@xref{Standards,,Language Standards Supported by GCC}, for details of -freestanding and hosted environments. +In C++ code, this allows member names in structures to be similar +to previous types declarations. + +@smallexample +typedef int UOW; +struct ABC @{ + UOW UOW; +@}; +@end smallexample + +Some cases of unnamed fields in structures and unions are only +accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union +fields within structs/unions}, for details. + +Note that this option is off for all targets except for x86 +targets using ms-abi. + +@item -foffload=disable +@itemx -foffload=default +@itemx -foffload=@var{target-list} +@opindex foffload +@cindex Offloading targets +@cindex OpenACC offloading targets +@cindex OpenMP offloading targets +Specify for which OpenMP and OpenACC offload targets code should be generated. +The default behavior, equivalent to @option{-foffload=default}, is to generate +code for all supported offload targets. The @option{-foffload=disable} form +generates code only for the host fallback, while +@option{-foffload=@var{target-list}} generates code only for the specified +comma-separated list of offload targets. + +Offload targets are specified in GCC's internal target-triplet format. You can +run the compiler with @option{-v} to show the list of configured offload targets +under @code{OFFLOAD_TARGET_NAMES}. + +@item -foffload-options=@var{options} +@itemx -foffload-options=@var{target-triplet-list}=@var{options} +@opindex foffload +@cindex Offloading options +@cindex OpenACC offloading options +@cindex OpenMP offloading options + +With @option{-foffload-options=@var{options}}, GCC passes the specified +@var{options} to the compilers for all enabled offloading targets. You can +specify options that apply only to a specific target or targets by using +the @option{-foffload-options=@var{target-list}=@var{options}} form. The +@var{target-list} is a comma-separated list in the same format as for the +@option{-foffload=} option. + +Typical command lines are + +@smallexample +-foffload-options=-lgfortran -foffload-options=-lm +-foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic +-foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm +@end smallexample @item -fopenacc @opindex fopenacc @@ -2603,42 +2668,29 @@ Enable handling of OpenMP's SIMD directives with @code{#pragma omp} in C/C++ and @code{!$omp} in Fortran. Other OpenMP directives are ignored. -@item -fgnu-tm -@opindex fgnu-tm -When the option @option{-fgnu-tm} is specified, the compiler -generates code for the Linux variant of Intel's current Transactional -Memory ABI specification document (Revision 1.1, May 6 2009). This is -an experimental feature whose interface may change in future versions -of GCC, as the official specification changes. Please note that not -all architectures are supported for this feature. - -For more information on GCC's support for transactional memory, -@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU -Transactional Memory Library}. - -Note that the transactional memory feature is not supported with -non-call exceptions (@option{-fnon-call-exceptions}). - -@item -fms-extensions -@opindex fms-extensions -Accept some non-standard constructs used in Microsoft header files. - -In C++ code, this allows member names in structures to be similar -to previous types declarations. +@item -fpermitted-flt-eval-methods=@var{style} +@opindex fpermitted-flt-eval-methods +@opindex fpermitted-flt-eval-methods=c11 +@opindex fpermitted-flt-eval-methods=ts-18661-3 +ISO/IEC TS 18661-3 defines new permissible values for +@code{FLT_EVAL_METHOD} that indicate that operations and constants with +a semantic type that is an interchange or extended format should be +evaluated to the precision and range of that type. These new values are +a superset of those permitted under C99/C11, which does not specify the +meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code +conforming to C11 may not have been written expecting the possibility of +the new values. -@smallexample -typedef int UOW; -struct ABC @{ - UOW UOW; -@}; -@end smallexample +@option{-fpermitted-flt-eval-methods} specifies whether the compiler +should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11, +or the extended set of values specified in ISO/IEC TS 18661-3. -Some cases of unnamed fields in structures and unions are only -accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union -fields within structs/unions}, for details. +@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate. -Note that this option is off for all targets except for x86 -targets using ms-abi. +The default when in a standards compliant mode (@option{-std=c11} or similar) +is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU +dialect (@option{-std=gnu11} or similar) is +@option{-fpermitted-flt-eval-methods=ts-18661-3}. @item -fplan9-extensions @opindex fplan9-extensions @@ -2651,17 +2703,26 @@ fields declared using a typedef. @xref{Unnamed Fields,,Unnamed struct/union fields within structs/unions}, for details. This is only supported for C, not C++. -@item -fcond-mismatch -@opindex fcond-mismatch -Allow conditional expressions with mismatched types in the second and -third arguments. The value of such an expression is void. This option -is not supported for C++. +@item -fsigned-bitfields +@itemx -funsigned-bitfields +@itemx -fno-signed-bitfields +@itemx -fno-unsigned-bitfields +@opindex fsigned-bitfields +@opindex funsigned-bitfields +@opindex fno-signed-bitfields +@opindex fno-unsigned-bitfields +These options control whether a bit-field is signed or unsigned, when the +declaration does not use either @code{signed} or @code{unsigned}. By +default, such a bit-field is signed, because this is consistent: the +basic integer types such as @code{int} are signed types. -@item -flax-vector-conversions -@opindex flax-vector-conversions -Allow implicit conversions between vectors with differing numbers of -elements and/or incompatible element types. This option should not be -used for new code. +@item -fsigned-char +@opindex fsigned-char +Let the type @code{char} be signed, like @code{signed char}. + +Note that this is equivalent to @option{-fno-unsigned-char}, which is +the negative form of @option{-funsigned-char}. Likewise, the option +@option{-fno-signed-char} is equivalent to @option{-funsigned-char}. @item -funsigned-char @opindex funsigned-char @@ -2682,27 +2743,6 @@ The type @code{char} is always a distinct type from each of @code{signed char} or @code{unsigned char}, even though its behavior is always just like one of those two. -@item -fsigned-char -@opindex fsigned-char -Let the type @code{char} be signed, like @code{signed char}. - -Note that this is equivalent to @option{-fno-unsigned-char}, which is -the negative form of @option{-funsigned-char}. Likewise, the option -@option{-fno-signed-char} is equivalent to @option{-funsigned-char}. - -@item -fsigned-bitfields -@itemx -funsigned-bitfields -@itemx -fno-signed-bitfields -@itemx -fno-unsigned-bitfields -@opindex fsigned-bitfields -@opindex funsigned-bitfields -@opindex fno-signed-bitfields -@opindex fno-unsigned-bitfields -These options control whether a bit-field is signed or unsigned, when the -declaration does not use either @code{signed} or @code{unsigned}. By -default, such a bit-field is signed, because this is consistent: the -basic integer types such as @code{int} are signed types. - @item -fsso-struct=@var{endianness} @opindex fsso-struct Set the default scalar storage order of structures and unions to the @@ -3977,6 +3977,86 @@ driver_wrong_lang_callback (const struct cl_decoded_option *decoded, static const char *spec_lang = 0; static int last_language_n_infiles; + +/* Check that GCC is configured to support the offload target. */ + +static bool +check_offload_target_name (const char *target, ptrdiff_t len) +{ + const char *n, *c = OFFLOAD_TARGETS; + while (c) + { + n = strchr (c, ','); + if (n == NULL) + n = strchr (c, '\0'); + if (len == n - c && strncmp (target, c, n - c) == 0) + break; + c = *n ? n + 1 : NULL; + } + if (!c) + { + char *s; + auto_vec<const char*> candidates; + char *cand = (char *) alloca (strlen (OFFLOAD_TARGETS) + 1); + c = OFFLOAD_TARGETS; + while (c) + { + n = strchr (c, ','); + if (n == NULL) + n = strchr (c, '\0'); + if (n - c == 0) + break; + strncpy (cand, c, n - c); + cand[n - c] = '\0'; + candidates.safe_push (cand); + c = *n ? n + 1 : NULL; + } + error ("GCC is not configured to support %q.*s as offload target", + (int) len, target); + const char *hint = candidates_list_and_hint (target, s, candidates); + if (hint) + inform (UNKNOWN_LOCATION, + "valid offload targets are: %s; did you mean %qs?", s, hint); + else + inform (UNKNOWN_LOCATION, "valid offload targets are: %s", s); + XDELETEVEC (s); + return false; + } + return true; +} + +/* Sanity check for -foffload-options. */ + +static void +check_foffload_target_names (const char *arg) +{ + const char *cur, *next, *end; + /* If option argument starts with '-' then no target is specified and we + do not need to parse it. */ + if (arg[0] == '-') + return; + end = strchr (arg, '='); + if (end == NULL) + { + error ("%<=%>options missing after %<-foffload-options=%>target"); + return; + } + + cur = arg; + while (cur < end) + { + next = strchr (cur, ','); + if (next == NULL) + next = end; + next = (next > end) ? end : next; + + /* Retain non-supported targets after printing an error as those will not + be processed; each enabled target only processes its triplet. */ + check_offload_target_name (cur, next - cur); + cur = next + 1; + } +} + /* Parse -foffload option argument. */ static void @@ -4006,34 +4086,25 @@ handle_foffload_option (const char *arg) memcpy (target, cur, next - cur); target[next - cur] = '\0'; - /* If 'disable' is passed to the option, stop parsing the option and clean - the list of offload targets. */ - if (strcmp (target, "disable") == 0) + /* Reset offloading list and continue. */ + if (strcmp (target, "default") == 0) { free (offload_targets); - offload_targets = xstrdup (""); - break; + offload_targets = NULL; + goto next_item; } - /* Check that GCC is configured to support the offload target. */ - c = OFFLOAD_TARGETS; - while (c) + /* If 'disable' is passed to the option, clean the list of + offload targets and return, even if more targets follow. + Likewise if GCC is not configured to support that offload target. */ + if (strcmp (target, "disable") == 0 + || !check_offload_target_name (target, next - cur)) { - n = strchr (c, ','); - if (n == NULL) - n = strchr (c, '\0'); - - if (next - cur == n - c && strncmp (target, c, n - c) == 0) - break; - - c = *n ? n + 1 : NULL; + free (offload_targets); + offload_targets = xstrdup (""); + return; } - if (!c) - fatal_error (input_location, - "GCC is not configured to support %s as offload target", - target); - if (!offload_targets) { offload_targets = target; @@ -4067,7 +4138,7 @@ handle_foffload_option (const char *arg) memcpy (offload_targets + offload_targets_len, target, next - cur + 1); } } - +next_item: cur = next + 1; XDELETEVEC (target); } @@ -4499,8 +4570,16 @@ driver_handle_option (struct gcc_options *opts, flag_wpa = ""; break; + case OPT_foffload_options_: + check_foffload_target_names (arg); + break; + case OPT_foffload_: handle_foffload_option (arg); + if (arg[0] == '-' || NULL != strchr (arg, '=')) + save_switch (concat ("-foffload-options=", arg, NULL), + 0, NULL, validated, true); + do_save = false; break; default: diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index b6ec83c..60ebb89 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,10 @@ +2021-06-29 Ian Lance Taylor <iant@golang.org> + + * go-gcc.cc (Gcc_backend::static_chain_variable): Set + DECL_NAMELESS on the new decl. + (Gcc_backend::temporary_variable): Likewise. + (Gcc_backend::function): Set DECL_NAMELESS on the result decl. + 2021-05-27 Ian Lance Taylor <iant@golang.org> * gccgo.texi (Function Names): Don't HTML quote ampersand. diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index 41f309e..f812796 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -2853,6 +2853,7 @@ Gcc_backend::static_chain_variable(Bfunction* function, const std::string& name, TREE_USED(decl) = 1; DECL_ARTIFICIAL(decl) = 1; DECL_IGNORED_P(decl) = 1; + DECL_NAMELESS(decl) = 1; TREE_READONLY(decl) = 1; struct function *f = DECL_STRUCT_FUNCTION(fndecl); @@ -2912,6 +2913,7 @@ Gcc_backend::temporary_variable(Bfunction* function, Bblock* bblock, type_tree); DECL_ARTIFICIAL(var) = 1; DECL_IGNORED_P(var) = 1; + DECL_NAMELESS(var) = 1; TREE_USED(var) = 1; DECL_CONTEXT(var) = decl; @@ -3290,6 +3292,7 @@ Gcc_backend::function(Btype* fntype, const std::string& name, build_decl(location.gcc_location(), RESULT_DECL, NULL_TREE, restype); DECL_ARTIFICIAL(resdecl) = 1; DECL_IGNORED_P(resdecl) = 1; + DECL_NAMELESS(resdecl) = 1; DECL_CONTEXT(resdecl) = decl; DECL_RESULT(decl) = resdecl; } diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index f16fb9f..ab1384d 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -bcafcb3c39530bb325514d6377747eb3127d1a03 +01cb2b5e69a2d08ef3cc1ea023c22ed9b79f5114 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 5d45e4b..a0472ac 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -15147,44 +15147,6 @@ Struct_construction_expression::do_copy() return ret; } -// Flatten a struct construction expression. Store the values into -// temporaries in case they need interface conversion. - -Expression* -Struct_construction_expression::do_flatten(Gogo*, Named_object*, - Statement_inserter* inserter) -{ - if (this->vals() == NULL) - return this; - - // If this is a constant struct, we don't need temporaries. - if (this->is_constant_struct() || this->is_static_initializer()) - return this; - - Location loc = this->location(); - for (Expression_list::iterator pv = this->vals()->begin(); - pv != this->vals()->end(); - ++pv) - { - if (*pv != NULL) - { - if ((*pv)->is_error_expression() || (*pv)->type()->is_error_type()) - { - go_assert(saw_errors()); - return Expression::make_error(loc); - } - if (!(*pv)->is_multi_eval_safe()) - { - Temporary_statement* temp = - Statement::make_temporary(NULL, *pv, loc); - inserter->insert(temp); - *pv = Expression::make_temporary_reference(temp, loc); - } - } - } - return this; -} - // Make implicit type conversions explicit. void @@ -15447,50 +15409,6 @@ Array_construction_expression::do_check_types(Gogo*) } } -// Flatten an array construction expression. Store the values into -// temporaries in case they need interface conversion. - -Expression* -Array_construction_expression::do_flatten(Gogo*, Named_object*, - Statement_inserter* inserter) -{ - if (this->is_error_expression()) - { - go_assert(saw_errors()); - return this; - } - - if (this->vals() == NULL) - return this; - - // If this is a constant array, we don't need temporaries. - if (this->is_constant_array() || this->is_static_initializer()) - return this; - - Location loc = this->location(); - for (Expression_list::iterator pv = this->vals()->begin(); - pv != this->vals()->end(); - ++pv) - { - if (*pv != NULL) - { - if ((*pv)->is_error_expression() || (*pv)->type()->is_error_type()) - { - go_assert(saw_errors()); - return Expression::make_error(loc); - } - if (!(*pv)->is_multi_eval_safe()) - { - Temporary_statement* temp = - Statement::make_temporary(NULL, *pv, loc); - inserter->insert(temp); - *pv = Expression::make_temporary_reference(temp, loc); - } - } - } - return this; -} - // Make implicit type conversions explicit. void @@ -15759,14 +15677,14 @@ Slice_construction_expression::create_array_val() // the new temp statement. Expression* -Slice_construction_expression::do_flatten(Gogo* gogo, Named_object* no, +Slice_construction_expression::do_flatten(Gogo*, Named_object*, Statement_inserter* inserter) { if (this->type()->array_type() == NULL) - return NULL; - - // Base class flattening first - this->Array_construction_expression::do_flatten(gogo, no, inserter); + { + go_assert(saw_errors()); + return Expression::make_error(this->location()); + } // Create a stack-allocated storage temp if storage won't escape if (!this->storage_escapes_ @@ -15775,7 +15693,7 @@ Slice_construction_expression::do_flatten(Gogo* gogo, Named_object* no, { Location loc = this->location(); this->array_val_ = this->create_array_val(); - go_assert(this->array_val_); + go_assert(this->array_val_ != NULL); Temporary_statement* temp = Statement::make_temporary(this->valtype_, this->array_val_, loc); inserter->insert(temp); diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index e3747cc..57c974d 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -3806,9 +3806,6 @@ class Struct_construction_expression : public Expression, Expression* do_copy(); - Expression* - do_flatten(Gogo*, Named_object*, Statement_inserter*); - Bexpression* do_get_backend(Translate_context*); @@ -3881,9 +3878,6 @@ protected: indexes() { return this->indexes_; } - Expression* - do_flatten(Gogo*, Named_object*, Statement_inserter*); - // Get the backend constructor for the array values. Bexpression* get_constructor(Translate_context* context, Btype* btype); diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c index 6dd55b6..9496b3c 100644 --- a/gcc/lto-opts.c +++ b/gcc/lto-opts.c @@ -174,7 +174,8 @@ lto_write_options (void) We do not need those. The only exception is -foffload option, if we write it in offload_lto section. Also drop all diagnostic options. */ if ((cl_options[option->opt_index].flags & (CL_DRIVER|CL_WARNING)) - && (!lto_stream_offload_p || option->opt_index != OPT_foffload_)) + && (!lto_stream_offload_p + || option->opt_index != OPT_foffload_options_)) continue; for (j = 0; j < option->canonical_option_num_elements; ++j) diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index 1c26439..aae48af 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -453,7 +453,7 @@ merge_and_complain (vec<cl_decoded_option> decoded_options, break; - case OPT_foffload_: + case OPT_foffload_options_: decoded_options.safe_push (*foption); break; @@ -833,7 +833,7 @@ append_offload_options (obstack *argv_obstack, const char *target, unsigned argc; cl_decoded_option *option = &options[i]; - if (option->opt_index != OPT_foffload_) + if (option->opt_index != OPT_foffload_options_) continue; /* If option argument starts with '-' then no target is specified. That @@ -844,11 +844,7 @@ append_offload_options (obstack *argv_obstack, const char *target, else { opts = strchr (option->arg, '='); - /* If there are offload targets specified, but no actual options, - there is nothing to do here. */ - if (!opts) - continue; - + gcc_assert (opts); cur = option->arg; while (cur < opts) diff --git a/gcc/match.pd b/gcc/match.pd index 39fb57e..8205271 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -5124,7 +5124,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cmp (convert @0) INTEGER_CST@1) (if (((POINTER_TYPE_P (TREE_TYPE (@0)) && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@0))) - && INTEGRAL_TYPE_P (TREE_TYPE (@1))) + && INTEGRAL_TYPE_P (TREE_TYPE (@1)) + /* Don't perform this optimization in GENERIC if @0 has reference + type when sanitizing. See PR101210. */ + && !(GENERIC + && TREE_CODE (TREE_TYPE (@0)) == REFERENCE_TYPE + && (flag_sanitize & (SANITIZE_NULL | SANITIZE_ALIGNMENT)))) || (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && POINTER_TYPE_P (TREE_TYPE (@1)) && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@1))))) @@ -2724,7 +2724,7 @@ common_handle_option (struct gcc_options *opts, /* Deferred. */ break; - case OPT_foffload_: + case OPT_foffload_options_: /* Deferred. */ break; diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 29ee9e0..97b9843 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -1314,24 +1314,54 @@ operator_minus::op1_op2_relation_effect (irange &lhs_range, tree type, unsigned prec = TYPE_PRECISION (type); signop sgn = TYPE_SIGN (type); - switch (rel) + // == and != produce [0,0] and ~[0,0] regardless of wrapping. + if (rel == EQ_EXPR) + rel_range = int_range<2> (type, wi::zero (prec), wi::zero (prec)); + else if (rel == NE_EXPR) + rel_range = int_range<2> (type, wi::zero (prec), wi::zero (prec), + VR_ANTI_RANGE); + else if (TYPE_OVERFLOW_WRAPS (type)) { - // op1 > op2, op1 - op2 can be restricted to [1, max] - case GT_EXPR: - rel_range = int_range<2> (type, wi::one (prec), - wi::max_value (prec, sgn)); - break; - // op1 >= op2, op1 - op2 can be restricted to [0, max] - case GE_EXPR: - rel_range = int_range<2> (type, wi::zero (prec), - wi::max_value (prec, sgn)); - break; - // op1 == op2, op1 - op2 can be restricted to [0, 0] - case EQ_EXPR: - rel_range = int_range<2> (type, wi::zero (prec), wi::zero (prec)); - break; - default: - return false; + switch (rel) + { + // For wrapping signed values and unsigned, if op1 > op2 or + // op1 < op2, then op1 - op2 can be restricted to ~[0, 0]. + case GT_EXPR: + case LT_EXPR: + rel_range = int_range<2> (type, wi::zero (prec), wi::zero (prec), + VR_ANTI_RANGE); + break; + default: + return false; + } + } + else + { + switch (rel) + { + // op1 > op2, op1 - op2 can be restricted to [1, +INF] + case GT_EXPR: + rel_range = int_range<2> (type, wi::one (prec), + wi::max_value (prec, sgn)); + break; + // op1 >= op2, op1 - op2 can be restricted to [0, +INF] + case GE_EXPR: + rel_range = int_range<2> (type, wi::zero (prec), + wi::max_value (prec, sgn)); + break; + // op1 < op2, op1 - op2 can be restricted to [-INF, -1] + case LT_EXPR: + rel_range = int_range<2> (type, wi::min_value (prec, sgn), + wi::minus_one (prec)); + break; + // op1 <= op2, op1 - op2 can be restricted to [-INF, 0] + case LE_EXPR: + rel_range = int_range<2> (type, wi::min_value (prec, sgn), + wi::zero (prec)); + break; + default: + return false; + } } lhs_range.intersect (rel_range); return true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a80c438..51fc7ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,28 @@ +2021-06-29 Andrew MacLeod <amacleod@redhat.com> + + * gcc.dg/pr101254.c: New. + +2021-06-29 Uroš Bizjak <ubizjak@gmail.com> + + PR target/95046 + * gcc.target/i386/pr95046-9.c: New test. + +2021-06-29 Richard Biener <rguenther@suse.de> + + * gcc.dg/vect/pr67790.c: Un-XFAIL. + * gcc.dg/vect/bb-slp-71.c: New testcase. + +2021-06-29 Jakub Jelinek <jakub@redhat.com> + + PR c++/101210 + * g++.dg/ubsan/pr101210.C: New test. + +2021-06-29 Richard Biener <rguenther@suse.de> + + PR tree-optimization/101242 + * gcc.dg/vect/bb-slp-pr101242.c: New testcase. + * gcc.dg/vect/pr67790.c: XFAIL scan for zero VEC_PERM_EXPR. + 2021-06-28 Martin Sebor <msebor@redhat.com> * g++.dg/uninit-pr74762.C: New test. diff --git a/gcc/testsuite/g++.dg/ubsan/pr101210.C b/gcc/testsuite/g++.dg/ubsan/pr101210.C new file mode 100644 index 0000000..955b820 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr101210.C @@ -0,0 +1,13 @@ +// PR c++/101210 +// { dg-do run } +// { dg-options "-fsanitize=null,alignment -fno-sanitize-recover=null,alignment" } + +int v[2]; +int +main () +{ + int x; + int &y = x; + v[0] = reinterpret_cast<__INTPTR_TYPE__>(&y) == 0; + v[1] = reinterpret_cast<__INTPTR_TYPE__>(&y) == 1; +} diff --git a/gcc/testsuite/gcc.dg/pr101254.c b/gcc/testsuite/gcc.dg/pr101254.c new file mode 100644 index 0000000..b2460ed --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr101254.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/101254 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fwrapv" } */ + +int +foo (long long imin, long long imax) +{ + if (imin > imax) + return 0; + else if (imax - imin < 0 || (imax - imin) + 1 < 0) + return 0; + return 1; +} + +int +main () +{ + long long imax = __LONG_LONG_MAX__; + long long imin = -imax - 1; + if (!foo (-10, 10)) + __builtin_abort (); + if (foo (-10, imax)) + __builtin_abort (); + if (foo (imin, imax)) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-71.c b/gcc/testsuite/gcc.dg/vect/bb-slp-71.c new file mode 100644 index 0000000..6816511 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-71.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ + +#include "tree-vect.h" + +int a[4], b[4]; + +void __attribute__((noipa)) +foo(int x, int y) +{ + int tem0 = x + 1; + int tem1 = y + 2; + int tem2 = x + 3; + int tem3 = y + 4; + a[0] = tem0 + b[1]; + a[1] = tem1 + b[0]; + a[2] = tem2 + b[2]; + a[3] = tem3 + b[3]; +} + +int main() +{ + check_vect (); + + b[0] = 10; + b[1] = 14; + b[2] = 18; + b[3] = 22; + foo (-1, -3); + if (a[0] != 14 || a[1] != 9 || a[2] != 20 || a[3] != 23) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c new file mode 100644 index 0000000..d885446 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr101242.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ + +typedef struct { + double real; + double imag; +} complex; +typedef struct { + complex e[3][3]; +} su3_matrix; +su3_matrix check_su3_c; +double check_su3_ar, check_su3_ari, check_su3_max; +int arireturn(); +int check_su3() { + check_su3_ar = check_su3_c.e[0][0].real * check_su3_c.e[1][0].real + + check_su3_c.e[0][0].imag * check_su3_c.e[1][0].imag + + check_su3_c.e[0][1].real * check_su3_c.e[1][1].real + + check_su3_c.e[0][1].imag * check_su3_c.e[1][1].imag + + check_su3_c.e[0][2].real * check_su3_c.e[1][2].real + + check_su3_c.e[0][2].imag * check_su3_c.e[1][2].imag; + check_su3_max = check_su3_c.e[0][0].real * check_su3_c.e[2][0].real + + check_su3_c.e[0][0].imag * check_su3_c.e[2][0].imag + + check_su3_c.e[0][1].real * check_su3_c.e[2][1].real + + check_su3_c.e[0][1].imag * check_su3_c.e[2][1].imag + + check_su3_c.e[0][2].real * check_su3_c.e[2][2].real + + check_su3_c.e[0][2].imag * check_su3_c.e[2][2].imag; + check_su3_ari = check_su3_ar; + if (check_su3_ari) + check_su3_max = check_su3_c.e[1][0].real * check_su3_c.e[2][0].real + + check_su3_c.e[1][0].imag * check_su3_c.e[2][0].imag + + check_su3_c.e[1][1].real * check_su3_c.e[2][1].real + + check_su3_c.e[1][1].imag * check_su3_c.e[2][1].imag + + check_su3_c.e[1][2].real * check_su3_c.e[2][2].real + + check_su3_c.e[1][2].imag * check_su3_c.e[2][2].imag; + if (check_su3_max) + arireturn(); + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/pr101248.c b/gcc/testsuite/gcc.target/i386/pr101248.c new file mode 100644 index 0000000..f5ac94f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr101248.c @@ -0,0 +1,123 @@ +/* PR target/101248 */ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512vl -std=gnu99" } */ +/* { dg-require-effective-target avx512vl } */ +/* { dg-require-effective-target c99_runtime } */ + +#define AVX512VL +#define AVX512F_LEN 128 +#define AVX512F_LEN_HALF 128 + +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 64) +#include "avx512f-mask-type.h" +#include "math_m_pi.h" +#include "float.h" + + +static void +CALC (double *r, double dest, double src, long long tbl) +{ + switch (tbl & 0xf) + { + case 0: + *r = dest; + break; + case 1: + *r = src; + break; + case 2: + *r = signbit (src) ? -NAN : NAN; + break; + case 3: + *r = -NAN; + break; + case 4: + *r = -INFINITY; + break; + case 5: + *r = INFINITY; + break; + case 6: + *r = signbit (src) ? -INFINITY : INFINITY; + break; + case 7: + *r = 1.0 / -INFINITY; + break; + case 8: + *r = 0.0; + break; + case 9: + *r = -1.0; + break; + case 10: + *r = 1.0; + break; + case 11: + *r = 1.0 / 2.0; + break; + case 12: + *r = 90.0; + break; + case 13: + *r = M_PI_2; + break; + case 14: + *r = DBL_MAX; + break; + case 15: + *r = -DBL_MAX; + break; + default: + abort (); + } +} + +void +TEST (void) +{ + int i, j; + UNION_TYPE (AVX512F_LEN, d) res1, res2, res3, s1; + UNION_TYPE (AVX512F_LEN, i_q) s2; + double res_ref[SIZE]; + + + float vals[2] = { -10, 10 }; + int controls[8] = {0, 0x11111111, 0x77777777, 0x88888888, + 0x99999999, 0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc}; + + MASK_TYPE mask = 1; + + for (i = 0; i < 2; i++) + { + for (j = 0; j < SIZE; j++) + { + s1.a[j] = vals[i]; + s2.a[j] = controls[j]; + res1.a[j] = DEFAULT_VALUE; + res2.a[j] = DEFAULT_VALUE; + res3.a[j] = DEFAULT_VALUE; + + CALC (&res_ref[j], res1.a[j], s1.a[j], s2.a[j]); + } + + res1.x = INTRINSIC (_fixupimm_pd) (res1.x, s1.x, s2.x, 0); + res2.x = INTRINSIC (_mask_fixupimm_pd) (res2.x, mask, s1.x, s2.x, 0); + res3.x = INTRINSIC (_maskz_fixupimm_pd) (mask, res3.x, s1.x, s2.x, 0); + + if (UNION_CHECK (AVX512F_LEN, d) (res1, res_ref)) + abort (); + + MASK_MERGE(d) (res_ref, mask, SIZE); + if (UNION_CHECK (AVX512F_LEN, d) (res2, res_ref)) + abort (); + MASK_ZERO(d) (res_ref, mask, SIZE); + if (UNION_CHECK (AVX512F_LEN, d) (res3, res_ref)) + abort (); + } +} + +void +test_256 (void) +{} diff --git a/gcc/testsuite/gcc.target/i386/pr95046-9.c b/gcc/testsuite/gcc.target/i386/pr95046-9.c new file mode 100644 index 0000000..54e948c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr95046-9.c @@ -0,0 +1,14 @@ +/* PR target/95046 */ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O3 -msse3" } */ + +float r[2], a[2], b[2]; + +void +test (void) +{ + r[0] = a[0] - b[0]; + r[1] = a[1] + b[1]; +} + +/* { dg-final { scan-assembler "\tv?addsubps" } } */ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 5401dbe..9155af4 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3470,12 +3470,11 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size) struct slpg_vertex { slpg_vertex (slp_tree node_) - : node (node_), visited (0), perm_out (0), materialize (0) {} + : node (node_), perm_out (-1), materialize (0) {} int get_perm_in () const { return materialize ? materialize : perm_out; } slp_tree node; - unsigned visited : 1; /* The permutation on the outgoing lanes (towards SLP parents). */ int perm_out; /* The permutation that is applied by this node. perm_out is @@ -3499,13 +3498,21 @@ vect_slp_build_vertices (hash_set<slp_tree> &visited, slp_tree node, vertices.safe_push (slpg_vertex (node)); bool leaf = true; + bool force_leaf = false; FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child) if (child) { leaf = false; vect_slp_build_vertices (visited, child, vertices, leafs); } - if (leaf) + else + force_leaf = true; + /* Since SLP discovery works along use-def edges all cycles have an + entry - but there's the exception of cycles where we do not handle + the entry explicitely (but with a NULL SLP node), like some reductions + and inductions. Force those SLP PHIs to act as leafs to make them + backwards reachable. */ + if (leaf || force_leaf) leafs.safe_push (node->vertex); } @@ -3519,18 +3526,8 @@ vect_slp_build_vertices (vec_info *info, vec<slpg_vertex> &vertices, unsigned i; slp_instance instance; FOR_EACH_VEC_ELT (info->slp_instances, i, instance) - { - unsigned n_v = vertices.length (); - unsigned n_l = leafs.length (); - vect_slp_build_vertices (visited, SLP_INSTANCE_TREE (instance), vertices, - leafs); - /* If we added vertices but no entries to the reverse graph we've - added a cycle that is not backwards-reachable. Push the entry - to mimic as leaf then. */ - if (vertices.length () > n_v - && leafs.length () == n_l) - leafs.safe_push (SLP_INSTANCE_TREE (instance)->vertex); - } + vect_slp_build_vertices (visited, SLP_INSTANCE_TREE (instance), vertices, + leafs); } /* Apply (reverse) bijectite PERM to VEC. */ @@ -3569,7 +3566,8 @@ vect_slp_perms_eq (const vec<vec<unsigned> > &perms, int perm_a, int perm_b) { return (perm_a == perm_b - || (perms[perm_a].length () == perms[perm_b].length () + || (perm_a != -1 && perm_b != -1 + && perms[perm_a].length () == perms[perm_b].length () && memcmp (&perms[perm_a][0], &perms[perm_b][0], sizeof (unsigned) * perms[perm_a].length ()) == 0)); } @@ -3616,7 +3614,7 @@ vect_optimize_slp (vec_info *vinfo) /* Leafs do not change across iterations. Note leafs also double as entries to the reverse graph. */ if (!slpg->vertices[idx].succ) - vertices[idx].visited = 1; + vertices[idx].perm_out = 0; /* Loads are the only thing generating permutes. */ if (!SLP_TREE_LOAD_PERMUTATION (node).exists ()) continue; @@ -3670,12 +3668,17 @@ vect_optimize_slp (vec_info *vinfo) /* Propagate permutes along the graph and compute materialization points. */ bool changed; + bool do_materialization = false; unsigned iteration = 0; do { changed = false; ++iteration; + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "SLP optimize iteration %d\n", iteration); + for (i = vertices.length (); i > 0 ; --i) { int idx = ipo[i-1]; @@ -3687,19 +3690,21 @@ vect_optimize_slp (vec_info *vinfo) || SLP_TREE_DEF_TYPE (node) == vect_constant_def) continue; - vertices[idx].visited = 1; - /* We still eventually have failed backedge SLP nodes in the graph, those are only cancelled when analyzing operations. Simply treat them as transparent ops, propagating permutes through them. */ if (SLP_TREE_DEF_TYPE (node) == vect_internal_def) { - /* We do not handle stores with a permutation. */ + /* We do not handle stores with a permutation, so all + incoming permutes must have been materialized. */ stmt_vec_info rep = SLP_TREE_REPRESENTATIVE (node); if (STMT_VINFO_DATA_REF (rep) && DR_IS_WRITE (STMT_VINFO_DATA_REF (rep))) - continue; + { + vertices[idx].perm_out = 0; + continue; + } /* We cannot move a permute across an operation that is not independent on lanes. Note this is an explicit negative list since that's much shorter than the respective @@ -3712,63 +3717,86 @@ vect_optimize_slp (vec_info *vinfo) case CFN_COMPLEX_MUL: case CFN_COMPLEX_MUL_CONJ: case CFN_VEC_ADDSUB: + vertices[idx].perm_out = 0; continue; default:; } } - int perm = -1; - for (graph_edge *succ = slpg->vertices[idx].succ; - succ; succ = succ->succ_next) + int perm; + if (!slpg->vertices[idx].succ) + /* Pick up pre-computed leaf values. */ + perm = vertices[idx].perm_out; + else { - int succ_idx = succ->dest; - /* Handle unvisited nodes optimistically. */ - /* ??? But for constants once we want to handle non-bijective - permutes we have to verify the permute, when unifying lanes, - will not unify different constants. For example see - gcc.dg/vect/bb-slp-14.c for a case that would break. */ - if (!vertices[succ_idx].visited) - continue; - int succ_perm = vertices[succ_idx].perm_out; - if (perm == -1) - perm = succ_perm; - else if (succ_perm == 0) + perm = vertices[idx].get_perm_in (); + for (graph_edge *succ = slpg->vertices[idx].succ; + succ; succ = succ->succ_next) { - perm = 0; - break; + int succ_idx = succ->dest; + int succ_perm = vertices[succ_idx].perm_out; + /* Handle unvisited (and constant) nodes optimistically. */ + /* ??? But for constants once we want to handle + non-bijective permutes we have to verify the permute, + when unifying lanes, will not unify different constants. + For example see gcc.dg/vect/bb-slp-14.c for a case + that would break. */ + if (succ_perm == -1) + continue; + if (perm == -1) + perm = succ_perm; + else if (succ_perm == 0 + || !vect_slp_perms_eq (perms, perm, succ_perm)) + { + perm = 0; + break; + } } - else if (!vect_slp_perms_eq (perms, perm, succ_perm)) + + /* If this is a node we do not want to eventually unshare + but it can be permuted at will, verify all users have + the same permutations registered and otherwise drop to + zero. */ + if (perm == -1 + && SLP_TREE_DEF_TYPE (node) != vect_external_def + && SLP_TREE_DEF_TYPE (node) != vect_constant_def) { - perm = 0; - break; + int preds_perm = -1; + for (graph_edge *pred = slpg->vertices[idx].pred; + pred; pred = pred->pred_next) + { + int pred_perm = vertices[pred->src].get_perm_in (); + if (preds_perm == -1) + preds_perm = pred_perm; + else if (!vect_slp_perms_eq (perms, + pred_perm, preds_perm)) + perm = 0; + } } - } - if (perm == -1) - /* Pick up pre-computed leaf values. */ - perm = vertices[idx].perm_out; - else if (!vect_slp_perms_eq (perms, perm, - vertices[idx].get_perm_in ())) - { - if (iteration > 1) - /* Make sure we eventually converge. */ - gcc_checking_assert (perm == 0); - if (perm == 0) + if (!vect_slp_perms_eq (perms, perm, + vertices[idx].get_perm_in ())) { - vertices[idx].perm_out = 0; - vertices[idx].materialize = 0; + /* Make sure we eventually converge. */ + gcc_checking_assert (vertices[idx].get_perm_in () == -1 + || perm == 0); + if (perm == 0) + { + vertices[idx].perm_out = 0; + vertices[idx].materialize = 0; + } + if (!vertices[idx].materialize) + vertices[idx].perm_out = perm; + changed = true; } - if (!vertices[idx].materialize) - vertices[idx].perm_out = perm; - changed = true; } - if (perm == 0) + /* Elide pruning at materialization points in the first + iteration phase. */ + if (!do_materialization) continue; - /* Elide pruning at materialization points in the first - iteration so every node was visited once at least. */ - if (iteration == 1) + if (perm == 0 || perm == -1) continue; /* Decide on permute materialization. Look whether there's @@ -3786,8 +3814,8 @@ vect_optimize_slp (vec_info *vinfo) for (graph_edge *pred = slpg->vertices[idx].pred; pred; pred = pred->pred_next) { - gcc_checking_assert (vertices[pred->src].visited); int pred_perm = vertices[pred->src].get_perm_in (); + gcc_checking_assert (pred_perm != -1); if (!vect_slp_perms_eq (perms, perm, pred_perm)) { all_preds_permuted = false; @@ -3802,8 +3830,57 @@ vect_optimize_slp (vec_info *vinfo) vertices[idx].perm_out = 0; } } + + /* If the initial propagation converged, switch on materialization + and re-propagate. */ + if (!changed && !do_materialization) + { + do_materialization = true; + changed = true; + } + } + while (changed); + statistics_counter_event (cfun, "SLP optimize perm iterations", iteration); + + /* Compute pre-order. */ + auto_vec<int> heads; + heads.reserve (vinfo->slp_instances.length ()); + for (slp_instance inst : vinfo->slp_instances) + heads.quick_push (SLP_INSTANCE_TREE (inst)->vertex); + auto_vec<int> po; + graphds_dfs (slpg, &heads[0], heads.length (), &po, true, NULL, NULL); + + /* Propagate materialized permutes to "any" permute nodes. For heads + ending up as "any" (reductions with just invariants), set them to + no permute. */ + for (int idx : heads) + if (vertices[idx].perm_out == -1) + vertices[idx].perm_out = 0; + for (i = po.length (); i > 0; --i) + { + int idx = po[i-1]; + int perm_in = vertices[idx].get_perm_in (); + slp_tree node = vertices[idx].node; + if (SLP_TREE_DEF_TYPE (node) == vect_external_def + || SLP_TREE_DEF_TYPE (node) == vect_constant_def) + continue; + gcc_assert (perm_in != -1); + for (graph_edge *succ = slpg->vertices[idx].succ; + succ; succ = succ->succ_next) + { + slp_tree succ_node = vertices[succ->dest].node; + if (SLP_TREE_DEF_TYPE (succ_node) == vect_external_def + || SLP_TREE_DEF_TYPE (succ_node) == vect_constant_def) + continue; + if (vertices[succ->dest].perm_out == -1) + vertices[succ->dest].perm_out = perm_in; + else + /* Propagation should have ensured that all preds have the same + permutation. */ + gcc_assert (vect_slp_perms_eq (perms, perm_in, + vertices[succ->dest].perm_out)); + } } - while (changed || iteration == 1); /* Materialize. */ for (i = 0; i < vertices.length (); ++i) diff --git a/gcc/value-query.cc b/gcc/value-query.cc index 17dfdb1..730a214 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -419,7 +419,8 @@ gimple_range_global (tree name) gcc_checking_assert (gimple_range_ssa_p (name)); tree type = TREE_TYPE (name); - if (SSA_NAME_IS_DEFAULT_DEF (name) || (cfun && cfun->after_inlining)) + if (SSA_NAME_IS_DEFAULT_DEF (name) || (cfun && cfun->after_inlining) + || is_a<gphi *> (SSA_NAME_DEF_STMT (name))) { value_range vr; get_range_global (vr, name); diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 3ae2c68..190676d 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -429,7 +429,7 @@ vr_values::vrp_stmt_computes_nonzero (gimple *stmt) && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (expr)))) { const value_range_equiv *vr - = get_value_range (TREE_OPERAND (base, 0)); + = get_value_range (TREE_OPERAND (base, 0), stmt); if (!range_includes_zero_p (vr)) return true; } @@ -486,7 +486,7 @@ vr_values::op_with_constant_singleton_value_range (tree op) /* Return true if op is in a boolean [0, 1] value-range. */ bool -simplify_using_ranges::op_with_boolean_value_range_p (tree op) +simplify_using_ranges::op_with_boolean_value_range_p (tree op, gimple *s) { if (TYPE_PRECISION (TREE_TYPE (op)) == 1) return true; @@ -500,7 +500,7 @@ simplify_using_ranges::op_with_boolean_value_range_p (tree op) /* ?? Errr, this should probably check for [0,0] and [1,1] as well as [0,1]. */ - const value_range *vr = query->get_value_range (op); + const value_range *vr = query->get_value_range (op, s); return *vr == value_range (build_zero_cst (TREE_TYPE (op)), build_one_cst (TREE_TYPE (op))); } @@ -1057,18 +1057,18 @@ vr_values::extract_range_from_comparison (value_range_equiv *vr, static bool check_for_binary_op_overflow (range_query *query, enum tree_code subcode, tree type, - tree op0, tree op1, bool *ovf) + tree op0, tree op1, bool *ovf, gimple *s = NULL) { value_range vr0, vr1; if (TREE_CODE (op0) == SSA_NAME) - vr0 = *query->get_value_range (op0); + vr0 = *query->get_value_range (op0, s); else if (TREE_CODE (op0) == INTEGER_CST) vr0.set (op0); else vr0.set_varying (TREE_TYPE (op0)); if (TREE_CODE (op1) == SSA_NAME) - vr1 = *query->get_value_range (op1); + vr1 = *query->get_value_range (op1, s); else if (TREE_CODE (op1) == INTEGER_CST) vr1.set (op1); else @@ -1980,10 +1980,11 @@ vr_values::vrp_visit_assignment_or_call (gimple *stmt, tree *output_p, is varying or undefined. Uses TEM as storage for the alternate range. */ const value_range_equiv * -simplify_using_ranges::get_vr_for_comparison (int i, value_range_equiv *tem) +simplify_using_ranges::get_vr_for_comparison (int i, value_range_equiv *tem, + gimple *s) { /* Shallow-copy equiv bitmap. */ - const value_range_equiv *vr = query->get_value_range (ssa_name (i)); + const value_range_equiv *vr = query->get_value_range (ssa_name (i), s); /* If name N_i does not have a valid range, use N_i as its own range. This allows us to compare against names that may @@ -2005,10 +2006,11 @@ simplify_using_ranges::get_vr_for_comparison (int i, value_range_equiv *tem) tree simplify_using_ranges::compare_name_with_value (enum tree_code comp, tree var, tree val, - bool *strict_overflow_p, bool use_equiv_p) + bool *strict_overflow_p, bool use_equiv_p, + gimple *s) { /* Get the set of equivalences for VAR. */ - bitmap e = query->get_value_range (var)->equiv (); + bitmap e = query->get_value_range (var, s)->equiv (); /* Start at -1. Set it to 0 if we do a comparison without relying on overflow, or 1 if all comparisons rely on overflow. */ @@ -2017,7 +2019,7 @@ simplify_using_ranges::compare_name_with_value /* Compare vars' value range with val. */ value_range_equiv tem_vr; const value_range_equiv *equiv_vr - = get_vr_for_comparison (SSA_NAME_VERSION (var), &tem_vr); + = get_vr_for_comparison (SSA_NAME_VERSION (var), &tem_vr, s); bool sop = false; tree retval = compare_range_with_value (comp, equiv_vr, val, &sop); if (retval) @@ -2044,7 +2046,7 @@ simplify_using_ranges::compare_name_with_value && prop_simulate_again_p (SSA_NAME_DEF_STMT (name))) continue; - equiv_vr = get_vr_for_comparison (i, &tem_vr); + equiv_vr = get_vr_for_comparison (i, &tem_vr, s); sop = false; tree t = compare_range_with_value (comp, equiv_vr, val, &sop); if (t) @@ -2084,12 +2086,12 @@ simplify_using_ranges::compare_name_with_value tree simplify_using_ranges::compare_names (enum tree_code comp, tree n1, tree n2, - bool *strict_overflow_p) + bool *strict_overflow_p, gimple *s) { /* Compare the ranges of every name equivalent to N1 against the ranges of every name equivalent to N2. */ - bitmap e1 = query->get_value_range (n1)->equiv (); - bitmap e2 = query->get_value_range (n2)->equiv (); + bitmap e1 = query->get_value_range (n1, s)->equiv (); + bitmap e2 = query->get_value_range (n2, s)->equiv (); /* Use the fake bitmaps if e1 or e2 are not available. */ static bitmap s_e1 = NULL, s_e2 = NULL; @@ -2139,7 +2141,7 @@ simplify_using_ranges::compare_names (enum tree_code comp, tree n1, tree n2, continue; value_range_equiv tem_vr1; - const value_range_equiv *vr1 = get_vr_for_comparison (i1, &tem_vr1); + const value_range_equiv *vr1 = get_vr_for_comparison (i1, &tem_vr1, s); tree t = NULL_TREE, retval = NULL_TREE; bitmap_iterator bi2; @@ -2152,7 +2154,8 @@ simplify_using_ranges::compare_names (enum tree_code comp, tree n1, tree n2, bool sop = false; value_range_equiv tem_vr2; - const value_range_equiv *vr2 = get_vr_for_comparison (i2, &tem_vr2); + const value_range_equiv *vr2 = get_vr_for_comparison (i2, &tem_vr2, + s); t = compare_ranges (comp, vr1, vr2, &sop); if (t) @@ -2198,11 +2201,12 @@ simplify_using_ranges::compare_names (enum tree_code comp, tree n1, tree n2, tree simplify_using_ranges::vrp_evaluate_conditional_warnv_with_ops_using_ranges - (enum tree_code code, tree op0, tree op1, bool * strict_overflow_p) + (enum tree_code code, tree op0, tree op1, bool * strict_overflow_p, + gimple *s) { const value_range_equiv *vr0, *vr1; - vr0 = (TREE_CODE (op0) == SSA_NAME) ? query->get_value_range (op0) : NULL; - vr1 = (TREE_CODE (op1) == SSA_NAME) ? query->get_value_range (op1) : NULL; + vr0 = (TREE_CODE (op0) == SSA_NAME) ? query->get_value_range (op0, s) : NULL; + vr1 = (TREE_CODE (op1) == SSA_NAME) ? query->get_value_range (op1, s) : NULL; tree res = NULL_TREE; if (vr0 && vr1) @@ -2302,20 +2306,20 @@ simplify_using_ranges::vrp_evaluate_conditional_warnv_with_ops } if ((ret = vrp_evaluate_conditional_warnv_with_ops_using_ranges - (code, op0, op1, strict_overflow_p))) + (code, op0, op1, strict_overflow_p, stmt))) return ret; if (only_ranges) *only_ranges = false; /* Do not use compare_names during propagation, it's quadratic. */ if (TREE_CODE (op0) == SSA_NAME && TREE_CODE (op1) == SSA_NAME && use_equiv_p) - return compare_names (code, op0, op1, strict_overflow_p); + return compare_names (code, op0, op1, strict_overflow_p, stmt); else if (TREE_CODE (op0) == SSA_NAME) return compare_name_with_value (code, op0, op1, - strict_overflow_p, use_equiv_p); + strict_overflow_p, use_equiv_p, stmt); else if (TREE_CODE (op1) == SSA_NAME) return compare_name_with_value (swap_tree_comparison (code), op1, op0, - strict_overflow_p, use_equiv_p); + strict_overflow_p, use_equiv_p, stmt); return NULL_TREE; } @@ -2929,11 +2933,11 @@ simplify_using_ranges::simplify_truth_ops_using_ranges gcc_assert (rhs_code == EQ_EXPR || rhs_code == NE_EXPR); op0 = gimple_assign_rhs1 (stmt); - if (!op_with_boolean_value_range_p (op0)) + if (!op_with_boolean_value_range_p (op0, stmt)) return false; op1 = gimple_assign_rhs2 (stmt); - if (!op_with_boolean_value_range_p (op1)) + if (!op_with_boolean_value_range_p (op1, stmt)) return false; /* Reduce number of cases to handle to NE_EXPR. As there is no @@ -3131,12 +3135,12 @@ simplify_using_ranges::simplify_min_or_max_using_ranges tree val; val = (vrp_evaluate_conditional_warnv_with_ops_using_ranges - (LE_EXPR, op0, op1, &sop)); + (LE_EXPR, op0, op1, &sop, stmt)); if (!val) { sop = false; val = (vrp_evaluate_conditional_warnv_with_ops_using_ranges - (LT_EXPR, op0, op1, &sop)); + (LT_EXPR, op0, op1, &sop, stmt)); } if (val) @@ -4000,7 +4004,7 @@ simplify_using_ranges::simplify_internal_call_using_ranges return false; else type = TREE_TYPE (TREE_TYPE (gimple_call_lhs (stmt))); - if (!check_for_binary_op_overflow (query, subcode, type, op0, op1, &ovf) + if (!check_for_binary_op_overflow (query, subcode, type, op0, op1, &ovf, stmt) || (is_ubsan && ovf)) return false; @@ -4057,9 +4061,10 @@ simplify_using_ranges::simplify_internal_call_using_ranges two-values when it is true. Return false otherwise. */ bool -simplify_using_ranges::two_valued_val_range_p (tree var, tree *a, tree *b) +simplify_using_ranges::two_valued_val_range_p (tree var, tree *a, tree *b, + gimple *s) { - value_range vr = *query->get_value_range (var); + value_range vr = *query->get_value_range (var, s); vr.normalize_symbolics (); if (vr.varying_p () || vr.undefined_p ()) return false; @@ -4133,7 +4138,7 @@ simplify_using_ranges::simplify (gimple_stmt_iterator *gsi) tree cmp_var = NULL_TREE; if (TREE_CODE (rhs2) == SSA_NAME - && two_valued_val_range_p (rhs2, &val1, &val2)) + && two_valued_val_range_p (rhs2, &val1, &val2, stmt)) { /* Optimize RHS1 OP [VAL1, VAL2]. */ new_rhs1 = int_const_binop (rhs_code, rhs1, val1); @@ -4141,7 +4146,7 @@ simplify_using_ranges::simplify (gimple_stmt_iterator *gsi) cmp_var = rhs2; } else if (TREE_CODE (rhs1) == SSA_NAME - && two_valued_val_range_p (rhs1, &val1, &val2)) + && two_valued_val_range_p (rhs1, &val1, &val2, stmt)) { /* Optimize [VAL1, VAL2] OP RHS2. */ new_rhs1 = int_const_binop (rhs_code, val1, rhs2); diff --git a/gcc/vr-values.h b/gcc/vr-values.h index 81b9131..7fdefef 100644 --- a/gcc/vr-values.h +++ b/gcc/vr-values.h @@ -56,14 +56,16 @@ private: gimple *); bool simplify_internal_call_using_ranges (gimple_stmt_iterator *, gimple *); - bool two_valued_val_range_p (tree, tree *, tree *); - bool op_with_boolean_value_range_p (tree); - tree compare_name_with_value (enum tree_code, tree, tree, bool *, bool); - tree compare_names (enum tree_code, tree, tree, bool *); - const value_range_equiv *get_vr_for_comparison (int, value_range_equiv *); + bool two_valued_val_range_p (tree, tree *, tree *, gimple *); + bool op_with_boolean_value_range_p (tree, gimple *); + tree compare_name_with_value (enum tree_code, tree, tree, bool *, bool, + gimple *); + tree compare_names (enum tree_code, tree, tree, bool *, gimple *s); + const value_range_equiv *get_vr_for_comparison (int, value_range_equiv *, + gimple *s); tree vrp_evaluate_conditional_warnv_with_ops_using_ranges (enum tree_code, tree, tree, - bool *); + bool *, gimple *s); void cleanup_edges_and_switches (void); /* Vectors of edges that need removing and switch statements that diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index d453f87..274f12b 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,19 @@ +2021-06-29 Julian Brown <julian@codesourcery.com> + + * config/gcn/lib2-bswapti2.c: New file. + * config/gcn/lib2-divmod-di.c: New file. + * config/gcn/lib2-gcn.h (DItype, UDItype, TItype, UTItype): Add + typedefs. + (__divdi3, __moddi3, __udivdi3, __umoddi3): Add prototypes. + * config/gcn/t-amdgcn (LIB2ADD): Add lib2-divmod-di.c and + lib2-bswapti2.c. + +2021-06-29 Julian Brown <julian@codesourcery.com> + + * config/gcn/lib2-divmod.c (__udivsi3, __umodsi3): Change argument and + return types to USItype. + * config/gcn/lib2-gcn.h (__udivsi3, __umodsi3): Update prototypes. + 2021-06-23 Kewen Lin <linkw@linux.ibm.com> * configure: Regenerate. diff --git a/libgcc/config/gcn/lib2-bswapti2.c b/libgcc/config/gcn/lib2-bswapti2.c new file mode 100644 index 0000000..c19b70b --- /dev/null +++ b/libgcc/config/gcn/lib2-bswapti2.c @@ -0,0 +1,47 @@ +/* Copyright (C) 2021 Free Software Foundation, Inc. + +This file is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3, or (at your option) any +later version. + +This file is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + +#include "lib2-gcn.h" + +UTItype +__bswapti2 (UTItype x) +{ + UDItype lo, hi, outlo, outhi; + lo = (UDItype) x; + hi = (UDItype) (x >> 64); + outhi = (lo >> 56) & 0xff; + outhi |= ((lo >> 48) & 0xff) << 8; + outhi |= ((lo >> 40) & 0xff) << 16; + outhi |= ((lo >> 32) & 0xff) << 24; + outhi |= ((lo >> 24) & 0xff) << 32; + outhi |= ((lo >> 16) & 0xff) << 40; + outhi |= ((lo >> 8) & 0xff) << 48; + outhi |= (lo & 0xff) << 56; + outlo = (hi >> 56) & 0xff; + outlo |= ((hi >> 48) & 0xff) << 8; + outlo |= ((hi >> 40) & 0xff) << 16; + outlo |= ((hi >> 32) & 0xff) << 24; + outlo |= ((hi >> 24) & 0xff) << 32; + outlo |= ((hi >> 16) & 0xff) << 40; + outlo |= ((hi >> 8) & 0xff) << 48; + outlo |= (hi & 0xff) << 56; + return ((UTItype) outhi << 64) | outlo; +} diff --git a/libgcc/config/gcn/lib2-divmod-di.c b/libgcc/config/gcn/lib2-divmod-di.c new file mode 100644 index 0000000..ceb3962 --- /dev/null +++ b/libgcc/config/gcn/lib2-divmod-di.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2021 Free Software Foundation, Inc. + Contributed by Mentor Graphics, Inc. + +This file is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3, or (at your option) any +later version. + +This file is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + +#include "lib2-gcn.h" + +/* We really want DImode here: override LIBGCC2_UNITS_PER_WORD. */ +#define LIBGCC2_UNITS_PER_WORD 4 +#define TARGET_HAS_NO_HW_DIVIDE + +#define L_divmoddi4 +#define L_divdi3 +#define L_moddi3 +#define L_udivdi3 +#define L_umoddi3 + +#include "libgcc2.c" diff --git a/libgcc/config/gcn/lib2-divmod.c b/libgcc/config/gcn/lib2-divmod.c index 0d6ca44..7c72e24 100644 --- a/libgcc/config/gcn/lib2-divmod.c +++ b/libgcc/config/gcn/lib2-divmod.c @@ -102,15 +102,15 @@ __modsi3 (SItype a, SItype b) } -SItype -__udivsi3 (SItype a, SItype b) +USItype +__udivsi3 (USItype a, USItype b) { return udivmodsi4 (a, b, 0); } -SItype -__umodsi3 (SItype a, SItype b) +USItype +__umodsi3 (USItype a, USItype b) { return udivmodsi4 (a, b, 1); } diff --git a/libgcc/config/gcn/lib2-gcn.h b/libgcc/config/gcn/lib2-gcn.h index 11476c4..155cf7c 100644 --- a/libgcc/config/gcn/lib2-gcn.h +++ b/libgcc/config/gcn/lib2-gcn.h @@ -33,13 +33,21 @@ typedef short HItype __attribute__ ((mode (HI))); typedef unsigned short UHItype __attribute__ ((mode (HI))); typedef int SItype __attribute__ ((mode (SI))); typedef unsigned int USItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); +typedef unsigned int UDItype __attribute__ ((mode (DI))); +typedef int TItype __attribute__ ((mode (TI))); +typedef unsigned int UTItype __attribute__ ((mode (TI))); typedef int word_type __attribute__ ((mode (__word__))); /* Exported functions. */ +extern DItype __divdi3 (DItype, DItype); +extern DItype __moddi3 (DItype, DItype); +extern UDItype __udivdi3 (UDItype, UDItype); +extern UDItype __umoddi3 (UDItype, UDItype); extern SItype __divsi3 (SItype, SItype); extern SItype __modsi3 (SItype, SItype); -extern SItype __udivsi3 (SItype, SItype); -extern SItype __umodsi3 (SItype, SItype); +extern USItype __udivsi3 (USItype, USItype); +extern USItype __umodsi3 (USItype, USItype); extern HItype __divhi3 (HItype, HItype); extern HItype __modhi3 (HItype, HItype); extern UHItype __udivhi3 (UHItype, UHItype); diff --git a/libgcc/config/gcn/t-amdgcn b/libgcc/config/gcn/t-amdgcn index fe7b5fa..38bde54 100644 --- a/libgcc/config/gcn/t-amdgcn +++ b/libgcc/config/gcn/t-amdgcn @@ -1,6 +1,8 @@ LIB2ADD += $(srcdir)/config/gcn/atomic.c \ $(srcdir)/config/gcn/lib2-divmod.c \ $(srcdir)/config/gcn/lib2-divmod-hi.c \ + $(srcdir)/config/gcn/lib2-divmod-di.c \ + $(srcdir)/config/gcn/lib2-bswapti2.c \ $(srcdir)/config/gcn/unwind-gcn.c LIB2ADDEH= diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index b763a22..91a0c67 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2021-06-29 Julian Brown <julian@codesourcery.com> + + PR target/96306 + * configure.ac: Remove stanza that removes KIND=16 integers for AMD GCN. + * configure: Regenerate. + 2021-06-22 Sandra Loosemore <sandra@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> diff --git a/libgfortran/configure b/libgfortran/configure index f363438..886216f 100755 --- a/libgfortran/configure +++ b/libgfortran/configure @@ -6017,7 +6017,7 @@ case "$host" in case "$enable_cet" in auto) # Check if target supports multi-byte NOPs - # and if assembler supports CET insn. + # and if compiler and assembler support CET insn. cet_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fcf-protection" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6216,10 +6216,6 @@ fi LIBGOMP_CHECKED_INT_KINDS="1 2 4 8 16" LIBGOMP_CHECKED_REAL_KINDS="4 8 10 16" -if test "x${target_cpu}" = xamdgcn; then - # amdgcn only has limited support for __int128. - LIBGOMP_CHECKED_INT_KINDS="1 2 4 8" -fi @@ -12731,7 +12727,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12744 "configure" +#line 12730 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12837,7 +12833,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12850 "configure" +#line 12836 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15532,16 +15528,6 @@ freebsd* | dragonfly*) esac ;; -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - haiku*) version_type=linux need_lib_prefix=no @@ -15663,7 +15649,7 @@ linux*oldld* | linux*aout* | linux*coff*) # project, but have not yet been accepted: they are GCC-local changes # for the time being. (See # https://lists.gnu.org/archive/html/libtool-patches/2018-05/msg00000.html) -linux* | k*bsd*-gnu | kopensolaris*-gnu | uclinuxfdpiceabi) +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu* | uclinuxfdpiceabi) version_type=linux need_lib_prefix=no need_version=no diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac index 8961e31..523eb24 100644 --- a/libgfortran/configure.ac +++ b/libgfortran/configure.ac @@ -222,10 +222,6 @@ AM_CONDITIONAL(LIBGFOR_MINIMAL, [test "x${target_cpu}" = xnvptx]) LIBGOMP_CHECKED_INT_KINDS="1 2 4 8 16" LIBGOMP_CHECKED_REAL_KINDS="4 8 10 16" -if test "x${target_cpu}" = xamdgcn; then - # amdgcn only has limited support for __int128. - LIBGOMP_CHECKED_INT_KINDS="1 2 4 8" -fi AC_SUBST(LIBGOMP_CHECKED_INT_KINDS) AC_SUBST(LIBGOMP_CHECKED_REAL_KINDS) diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index c0f2a5f..827b840 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,19 @@ +2021-06-29 Tobias Burnus <tobias@codesourcery.com> + + PR other/67300 + * testsuite/libgomp.c-c++-common/reduction-16.c: Replace + -foffload=nvptx-none= by -foffload-options=nvptx-none= to + avoid disabling other offload targets. + * testsuite/libgomp.c-c++-common/reduction-5.c: Likewise. + * testsuite/libgomp.c-c++-common/reduction-6.c: Likewise. + * testsuite/libgomp.c/target-44.c: Likewise. + +2021-06-29 Tobias Burnus <tobias@codesourcery.com> + + * testsuite/libgomp.fortran/defaultmap-8.f90 (bar): Determine whether + target has shared memory and disable some scalar pointer/allocatable + checks if not as firstprivate does not work. + 2021-06-25 Chung-Lin Tang <cltang@codesourcery.com> PR testsuite/101114 diff --git a/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c b/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c index 0eea73b..4bf62c3 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c +++ b/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-additional-options "-foffload=nvptx-none=-latomic" { target offload_target_nvptx } } */ +/* { dg-additional-options "-foffload-options=nvptx-none=-latomic" { target offload_target_nvptx } } */ #include <stdlib.h> diff --git a/libgomp/testsuite/libgomp.c-c++-common/reduction-5.c b/libgomp/testsuite/libgomp.c-c++-common/reduction-5.c index 31fa267..52f23e3 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/reduction-5.c +++ b/libgomp/testsuite/libgomp.c-c++-common/reduction-5.c @@ -1,4 +1,4 @@ -/* { dg-additional-options "-foffload=nvptx-none=-latomic" { target { offload_target_nvptx } } } */ +/* { dg-additional-options "-foffload-options=nvptx-none=-latomic" { target { offload_target_nvptx } } } */ /* C / C++'s logical AND and OR operators take any scalar argument which compares (un)equal to 0 - the result 1 or 0 and of type int. diff --git a/libgomp/testsuite/libgomp.c-c++-common/reduction-6.c b/libgomp/testsuite/libgomp.c-c++-common/reduction-6.c index 727e11e..62e8150 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/reduction-6.c +++ b/libgomp/testsuite/libgomp.c-c++-common/reduction-6.c @@ -1,4 +1,4 @@ -/* { dg-additional-options "-foffload=nvptx-none=-latomic" { target { offload_target_nvptx } } } */ +/* { dg-additional-options "-foffload-options=nvptx-none=-latomic" { target { offload_target_nvptx } } } */ /* C / C++'s logical AND and OR operators take any scalar argument which compares (un)equal to 0 - the result 1 or 0 and of type int. diff --git a/libgomp/testsuite/libgomp.c/target-44.c b/libgomp/testsuite/libgomp.c/target-44.c index b95e807..a5da81d 100644 --- a/libgomp/testsuite/libgomp.c/target-44.c +++ b/libgomp/testsuite/libgomp.c/target-44.c @@ -1,4 +1,4 @@ -/* { dg-additional-options "-foffload=nvptx-none=-latomic" { target { offload_target_nvptx } } } */ +/* { dg-additional-options "-foffload-options=nvptx-none=-latomic" { target { offload_target_nvptx } } } */ #include <stdlib.h> diff --git a/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90 b/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90 index ddf5057..54f4b2e 100644 --- a/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90 +++ b/libgomp/testsuite/libgomp.fortran/defaultmap-8.f90 @@ -205,6 +205,7 @@ subroutine bar (ea1, ea2, ep1, ep2, eat1, eat2, et1, et2, ei1, ei2) pointer :: ep1, ep2, ep3 target :: eat1, eat2, eat3, et1, et2, et3 optional :: ea1, ep1, eat1, et1, ei1 + logical :: shared_memory allocate(ea3, eat3, ep3) @@ -212,19 +213,28 @@ subroutine bar (ea1, ea2, ep1, ep2, eat1, eat2, et1, et2, ei1, ei2) eat1 = 2; eat2 = 2; eat3 = 2; et1 = 2; et2 = 2; et3 = 2 ei1 = 2; ei2 = 2; ei3 = 2 + shared_memory = .false. + !$omp target map(to: shared_memory) + shared_memory = .true. + !$omp end target + ! While here 'scalar' implies nonallocatable/nonpointer and ! the target attribute plays no role. !$omp target defaultmap(tofrom:scalar) defaultmap(firstprivate:allocatable) & - !$omp& defaultmap(none:aggregate) defaultmap(firstprivate:pointer) - if (ea1 /= 2) stop 91 - if (ea2 /= 2) stop 92 - if (ea3 /= 2) stop 93 - if (ep1 /= 2) stop 94 - if (ep2 /= 2) stop 95 - if (ep3 /= 2) stop 96 - if (eat1 /= 2) stop 97 - if (eat2 /= 2) stop 98 - if (eat3 /= 2) stop 99 + !$omp& defaultmap(none:aggregate) defaultmap(firstprivate:pointer) & + !$omp& map(always, to: shared_memory) + if (shared_memory) then + ! Due to fortran/90742 this fails when doing non-shared memory offloading + if (ea1 /= 2) stop 91 + if (ea2 /= 2) stop 92 + if (ea3 /= 2) stop 93 + if (ep1 /= 2) stop 94 + if (ep2 /= 2) stop 95 + if (ep3 /= 2) stop 96 + if (eat1 /= 2) stop 97 + if (eat2 /= 2) stop 98 + if (eat3 /= 2) stop 99 + end if if (et1 /= 2) stop 100 if (et2 /= 2) stop 101 if (et3 /= 2) stop 102 @@ -232,8 +242,11 @@ subroutine bar (ea1, ea2, ep1, ep2, eat1, eat2, et1, et2, ei1, ei2) if (ei2 /= 2) stop 104 if (ei3 /= 2) stop 105 ep1 => null(); ep2 => null(); ep3 => null() - ea1 = 1; ea2 = 1; ea3 = 1 - eat1 = 1; eat2 = 1; eat3 = 1 + if (shared_memory) then + ! Due to fortran/90742 this fails when doing non-shared memory offloading + ea1 = 1; ea2 = 1; ea3 = 1 + eat1 = 1; eat2 = 1; eat3 = 1 + end if et1 = 1; et2 = 1; et3 = 1 ei1 = 1; ei2 = 1; ei3 = 1 !$omp end target |