diff options
author | Martin Liska <mliska@suse.cz> | 2021-12-20 11:00:50 +0100 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2021-12-20 11:00:50 +0100 |
commit | 303634cc437784660b59f96b7ab9d4d52acf7dc3 (patch) | |
tree | e2949a253192c834e5fdc3be5ec7a01aa3a34f82 | |
parent | a29aa2eafa30efffed38b14fcbad9513c5dd2590 (diff) | |
parent | 8d1e342b4afbad77cb92f8057cf6d1e996bfb077 (diff) | |
download | gcc-303634cc437784660b59f96b7ab9d4d52acf7dc3.zip gcc-303634cc437784660b59f96b7ab9d4d52acf7dc3.tar.gz gcc-303634cc437784660b59f96b7ab9d4d52acf7dc3.tar.bz2 |
Merge branch 'master' into devel/sphinx
81 files changed, 1667 insertions, 153 deletions
@@ -1,3 +1,14 @@ +2021-12-17 Martin Liska <mliska@suse.cz> + + * config.sub: Sync from master. + +2021-12-17 Martin Liska <mliska@suse.cz> + + Revert: + 2021-12-16 Matthias Seidel <mseidel@apache.org> + + * config.sub: Fix typo. + 2021-12-16 Matthias Seidel <mseidel@apache.org> * config.sub: Fix typo. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 02e8f71..5ab864a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,187 @@ +2021-12-19 Jan Hubicka <hubicka@ucw.cz> + + PR ipa/103766 + * ipa-modref.c (modref_merge_call_site_flags): Fix early exit condition + +2021-12-19 Patrick Palka <ppalka@redhat.com> + + * print-tree.c (print_node) <case tcc_declaration>: Dump + DECL_LANG_FLAG_8. + +2021-12-19 Andrew Pinski <apinski@marvell.com> + + * tree-ssa-phiopt.c (gimple_simplify_phiopt): Annotate the + new sequence with the location of the conditional statement. + +2021-12-18 Roger Sayle <roger@nextmovesoftware.com> + Uroš Bizjak <ubizjak@gmail.com> + + PR target/103611 + * config/i386/i386.md (any_or_plus): New code iterator. + (define_split): Split (HI<<32)|zext(LO) into piece-wise + move instructions on !TARGET_64BIT. + * config/i386/sse.md (*vec_extractv4si_0_zext_sse4): + Restrict to TARGET_64BIT. + +2021-12-18 Roger Sayle <roger@nextmovesoftware.com> + + PR target/32803 + * common.opt (Oz): New command line option. + * doc/invoke.texi: Document the new -Oz option. + * lto-wrapper.c (merge_and_complain, append_compiler_options): + Treat OPT_Oz as synonymous with OPT_Os. + * optc-save-gen.awk: Increase maximum value of optimize_size to 2. + * opts.c (default_options_optimization) [OPT_Oz]: Handle OPT_Oz + just like OPT_Os, except set opt->x_optimize_size to 2. + (common_handle_option): Skip OPT_Oz just like OPT_Os. + * config/i386/i386.md (*movdi_internal): Use a push/pop sequence + for suitable SImode TYPE_IMOV moves when optimize_size > 1. + (*movsi_internal): Likewise. + +2021-12-18 Siddhesh Poyarekar <siddhesh@gotplt.org> + + PR tree-optimization/103759 + * tree-object-size.c (unknown, initval): Remove functions. + (size_unknown, size_initval, size_unknown_p): Operate directly + on trees. + +2021-12-18 François-Xavier Coudert <fxcoudert@gcc.gnu.org> + + * config/darwin-driver.c: Make version code more future-proof. + * config.gcc: Homogeneize darwin versions. + * configure.ac: Homogeneize darwin versions. + * configure: Regenerate. + +2021-12-17 Marek Polacek <polacek@redhat.com> + + PR c/103649 + * attribs.c (handle_ignored_attributes_option): Create the fake + attribute with max_length == -2. + (attribute_ignored_p): New overloads. + * attribs.h (attribute_ignored_p): Declare them. + * tree-core.h (struct attribute_spec): Document that max_length + can be -2. + +2021-12-17 Segher Boessenkool <segher@kernel.crashing.org> + + PR target/103624 + * config/rs6000/rs6000-builtins.def (__builtin_darn): Expand to + darn_64_di. Add {32bit} attribute. Return long. + (__builtin_darn_32): Expand to darn_32_di. Add {32bit} attribute. + Return long. + (__builtin_darn_raw): Expand to darn_raw_di. Add {32bit} attribute. + Return long. + * config/rs6000/rs6000-call.c (rs6000_expand_builtin): Expand the darn + builtins to the _si variants for -m32. + * config/rs6000/rs6000.md (UNSPECV_DARN_32, UNSPECV_DARN_RAW): Delete. + (UNSPECV_DARN): Update comment. + (darn_32, darn_raw, darn): Delete. + (darn_32_<mode>, darn_64_<mode>, darn_raw_<mode> for GPR): New. + (@darn<mode> for GPR): New. + +2021-12-17 Bill Schmidt <wschmidt@linux.ibm.com> + + * config/rs6000/rs6000-overload.def (__builtin_vec_promote): Add second + argument. + +2021-12-17 Richard Sandiford <richard.sandiford@arm.com> + + PR tree-optimization/103744 + * tree-vect-stmts.c (vectorizable_load): Handle multi-vector + SLP gather loads. + +2021-12-17 Martin Liska <mliska@suse.cz> + + * doc/invoke.texi: Rename to -fstack-protector. + +2021-12-17 Martin Liska <mliska@suse.cz> + + * doc/invoke.texi: Fix spelling issues. + +2021-12-17 Tamar Christina <tamar.christina@arm.com> + + PR tree-optimization/103741 + * tree-vect-stmts.c (vectorizable_operation): Check for boolean. + +2021-12-17 Iain Sandoe <iain@sandoe.co.uk> + + * config/darwin-driver.c (darwin_driver_init): Exit from the + option handling early if the command line is definitely enpty. + * config/darwin.h (SUBTARGET_DRIVER_SELF_SPECS): Remove + setting for the default content of weak_reference_mismatches. + +2021-12-17 Iain Sandoe <iain@sandoe.co.uk> + + * config/rs6000/darwin.h: Drop trailing _x from the + builtin_decls array name. + +2021-12-17 Haochen Jiang <haochen.jiang@intel.com> + + PR target/100738 + * config/i386/sse.md (*avx_cmp<mode>3_lt, *avx_cmp<mode>3_ltint): + Remove MEM_P restriction and add force_reg for operands[2]. + (*avx_cmp<mode>3_ltint_not): Add new define_insn_and_split. + +2021-12-17 Siddhesh Poyarekar <siddhesh@gotplt.org> + + * builtins.def (BUILT_IN_DYNAMIC_OBJECT_SIZE): New builtin. + * tree-object-size.h: Move object size type bits enum from + tree-object-size.c and add new value OST_DYNAMIC. + * builtins.c (expand_builtin, fold_builtin_2): Handle it. + (fold_builtin_object_size): Handle new builtin and adjust for + change to compute_builtin_object_size. + * tree-object-size.c: Include builtins.h. + (compute_builtin_object_size): Adjust. + (early_object_sizes_execute_one, + dynamic_object_sizes_execute_one): New functions. + (object_sizes_execute): Rename insert_min_max_p argument to + early. Handle BUILT_IN_DYNAMIC_OBJECT_SIZE and call the new + functions. + * doc/extend.texi (__builtin_dynamic_object_size): Document new + builtin. + +2021-12-17 Siddhesh Poyarekar <siddhesh@gotplt.org> + + * tree-object-size.h (compute_builtin_object_size): Return tree + instead of HOST_WIDE_INT. + * builtins.c (fold_builtin_object_size): Adjust. + * gimple-fold.c (gimple_fold_builtin_strncat): Likewise. + * ubsan.c (instrument_object_size): Likewise. + * tree-object-size.c (object_size): New structure. + (object_sizes): Change type to vec<object_size>. + (initval): New function. + (unknown): Use it. + (size_unknown_p, size_initval, size_unknown): New functions. + (object_sizes_unknown_p): Use it. + (object_sizes_get): Return tree. + (object_sizes_initialize): Rename from object_sizes_set_force + and set VAL parameter type as tree. Add new parameter WHOLEVAL. + (object_sizes_set): Set VAL parameter type as tree and adjust + implementation. Add new parameter WHOLEVAL. + (size_for_offset): New function. + (decl_init_size): Adjust comment. + (addr_object_size): Change PSIZE parameter to tree and adjust + implementation. Add new parameter PWHOLESIZE. + (alloc_object_size): Return tree. + (compute_builtin_object_size): Return tree in PSIZE. + (expr_object_size, call_object_size, unknown_object_size): + Adjust for object_sizes_set change. + (merge_object_sizes): Drop OFFSET parameter and adjust + implementation for tree change. + (plus_stmt_object_size): Call collect_object_sizes_for directly + instead of merge_object_size and call size_for_offset to get net + size. + (cond_expr_object_size, collect_object_sizes_for, + object_sizes_execute): Adjust for change of type from + HOST_WIDE_INT to tree. + (check_for_plus_in_loops_1): Likewise and skip non-positive + offsets. + +2021-12-17 Jason Merrill <jason@redhat.com> + + PR c++/103681 + * common.opt (fabi-version): Add v17. + 2021-12-16 Uroš Bizjak <ubizjak@gmail.com> PR target/103571 diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 7b090eb..40a9145 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20211217 +20211220 diff --git a/gcc/attribs.c b/gcc/attribs.c index 29703e7..9e7b7c1 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -304,7 +304,7 @@ handle_ignored_attributes_option (vec<char *> *v) We can't free it here, so squirrel away the pointers. */ attribute_spec *table = new attribute_spec[2]; ignored_attributes_table.safe_push (table); - table[0] = { attr, 0, 0, false, false, false, false, nullptr, nullptr }; + table[0] = { attr, 0, -2, false, false, false, false, nullptr, nullptr }; table[1] = { nullptr, 0, 0, false, false, false, false, nullptr, nullptr }; register_scoped_attributes (table, IDENTIFIER_POINTER (vendor_id), !attr); @@ -569,6 +569,32 @@ attr_namespace_ignored_p (tree ns) return r && r->ignored_p; } +/* Return true if the attribute ATTR should not be warned about. */ + +bool +attribute_ignored_p (tree attr) +{ + if (!cxx11_attribute_p (attr)) + return false; + if (tree ns = get_attribute_namespace (attr)) + { + if (attr_namespace_ignored_p (ns)) + return true; + const attribute_spec *as = lookup_attribute_spec (TREE_PURPOSE (attr)); + if (as && as->max_length == -2) + return true; + } + return false; +} + +/* Like above, but takes an attribute_spec AS, which must be nonnull. */ + +bool +attribute_ignored_p (const attribute_spec *const as) +{ + return as->max_length == -2; +} + /* Process the attributes listed in ATTRIBUTES and install them in *NODE, which is either a DECL (including a TYPE_DECL) or a TYPE. If a DECL, it should be modified in place; if a TYPE, a copy should be created diff --git a/gcc/attribs.h b/gcc/attribs.h index f5899d8..4928b12 100644 --- a/gcc/attribs.h +++ b/gcc/attribs.h @@ -39,6 +39,8 @@ extern tree get_attribute_name (const_tree); extern tree get_attribute_namespace (const_tree); extern void apply_tm_attr (tree, tree); extern tree make_attribute (const char *, const char *, tree); +extern bool attribute_ignored_p (tree); +extern bool attribute_ignored_p (const attribute_spec *const); extern struct scoped_attributes* register_scoped_attributes (const struct attribute_spec *, const char *, diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index e2dcb93..da83507 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2021-12-17 Jason Merrill <jason@redhat.com> + + PR c++/103681 + * c-opts.c (c_common_post_options): Update defaults. + 2021-12-16 Martin Liska <mliska@suse.cz> PR target/103709 diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index e9c054d..212d4c7 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,11 @@ +2021-12-17 Marek Polacek <polacek@redhat.com> + + PR c/103649 + * c-decl.c (c_warn_unused_attributes): Don't warn for + attribute_ignored_p. + * c-parser.c (c_parser_std_attribute): Skip parsing of the attribute + arguments when the attribute is ignored. + 2021-12-14 Jakub Jelinek <jakub@redhat.com> PR c/103587 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 4b5481c..516e3c2 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -4643,7 +4643,7 @@ c_warn_unused_attributes (tree attrs) constraint violation. */ pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored", get_attribute_name (t)); - else + else if (!attribute_ignored_p (t)) warning (OPT_Wattributes, "%qE attribute ignored", get_attribute_name (t)); } diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index d7e5f05..b09ad30 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -4943,7 +4943,9 @@ c_parser_std_attribute (c_parser *parser, bool for_tm) parens.skip_until_found_close (parser); return error_mark_node; } - if (as) + /* If this is a fake attribute created to handle -Wno-attributes, + we must skip parsing the arguments. */ + if (as && !attribute_ignored_p (as)) { bool takes_identifier = (ns != NULL_TREE diff --git a/gcc/common.opt b/gcc/common.opt index 4af89ce..2ed818d 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -483,6 +483,10 @@ Og Common Optimization Optimize for debugging experience rather than speed or size. +Oz +Common Optimization +Optimize for space aggressively rather than speed. + Q Driver diff --git a/gcc/config.gcc b/gcc/config.gcc index c882436..c8c0ef9 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1847,7 +1847,7 @@ hppa[12]*-*-hpux11*) dwarf2=no fi ;; -i[34567]86-*-darwin1[89]* | i[34567]86-*-darwin2[0-9]*) +i[34567]86-*-darwin1[89]* | i[34567]86-*-darwin2*) echo "Error: 32bit target is not supported after Darwin17" 1>&2 ;; i[34567]86-*-darwin*) @@ -1857,7 +1857,7 @@ i[34567]86-*-darwin*) tmake_file="${tmake_file} ${cpu_type}/t-darwin32-biarch t-slibgcc" tm_file="${cpu_type}/darwin32-biarch.h ${tm_file} " ;; -x86_64-*-darwin1[89]* | x86_64-*-darwin2[01]*) +x86_64-*-darwin1[89]* | x86_64-*-darwin2*) # Only 64b from now tm_defines="${tm_defines} TARGET_64BIT_DEFAULT=(OPTION_MASK_ISA_64BIT|OPTION_MASK_ABI_64)" tm_defines="${tm_defines} TARGET_BI_ARCH=0" diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c index 688fe8f..e459a72 100644 --- a/gcc/config/darwin-driver.c +++ b/gcc/config/darwin-driver.c @@ -64,7 +64,8 @@ validate_macosx_version_min (const char *version_str) major = strtoul (version_str, &end, 10); - if (major < 10 || major > 12 ) /* macOS 10, 11, and 12 are known. */ + /* macOS 10, 11, and 12 are known. clang accepts up to 99. */ + if (major < 10 || major > 99) return NULL; /* Skip a separating period, if there's one. */ @@ -160,8 +161,7 @@ darwin_find_version_from_kernel (void) /* Darwin20 sees a transition to macOS 11. In this, it seems that the mapping to macOS minor version is now shifted to the kernel minor - version - 1 (at least for the initial releases). At this stage, we - don't know what macOS version will correspond to Darwin21. */ + version - 1 (at least for the initial releases). */ if (major_vers >= 20) { int minor_vers = *version_p++ - '0'; diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index f6d9c4b..d25453f 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -2213,7 +2213,14 @@ case TYPE_IMOV: gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1])); if (get_attr_mode (insn) == MODE_SI) - return "mov{l}\t{%k1, %k0|%k0, %k1}"; + { + if (optimize_size > 1 + && TARGET_64BIT + && CONST_INT_P (operands[1]) + && IN_RANGE (INTVAL (operands[1]), -128, 127)) + return "push{q}\t%1\n\tpop{q}\t%0"; + return "mov{l}\t{%k1, %k0|%k0, %k1}"; + } else if (which_alternative == 4) return "movabs{q}\t{%1, %0|%0, %1}"; else if (ix86_use_lea_for_mov (insn, operands)) @@ -2431,6 +2438,14 @@ gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1])); if (ix86_use_lea_for_mov (insn, operands)) return "lea{l}\t{%E1, %0|%0, %E1}"; + else if (optimize_size > 1 + && CONST_INT_P (operands[1]) + && IN_RANGE (INTVAL (operands[1]), -128, 127)) + { + if (TARGET_64BIT) + return "push{q}\t%1\n\tpop{q}\t%q0"; + return "push{l}\t%1\n\tpop{l}\t%0"; + } else return "mov{l}\t{%1, %0|%0, %1}"; @@ -10629,6 +10644,38 @@ [(set_attr "isa" "*,nox64") (set_attr "type" "alu") (set_attr "mode" "QI")]) + +;; Split DST = (HI<<32)|LO early to minimize register usage. +(define_code_iterator any_or_plus [plus ior xor]) +(define_split + [(set (match_operand:DI 0 "register_operand") + (any_or_plus:DI + (ashift:DI (match_operand:DI 1 "register_operand") + (const_int 32)) + (zero_extend:DI (match_operand:SI 2 "register_operand"))))] + "!TARGET_64BIT" + [(set (match_dup 3) (match_dup 4)) + (set (match_dup 5) (match_dup 2))] +{ + operands[3] = gen_highpart (SImode, operands[0]); + operands[4] = gen_lowpart (SImode, operands[1]); + operands[5] = gen_lowpart (SImode, operands[0]); +}) + +(define_split + [(set (match_operand:DI 0 "register_operand") + (any_or_plus:DI + (zero_extend:DI (match_operand:SI 1 "register_operand")) + (ashift:DI (match_operand:DI 2 "register_operand") + (const_int 32))))] + "!TARGET_64BIT" + [(set (match_dup 3) (match_dup 4)) + (set (match_dup 5) (match_dup 1))] +{ + operands[3] = gen_highpart (SImode, operands[0]); + operands[4] = gen_lowpart (SImode, operands[2]); + operands[5] = gen_lowpart (SImode, operands[0]); +}) ;; Negation instructions diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 97ce5b3..5196149 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -4465,6 +4465,18 @@ (const_string "<sseinsnmode>") (const_string "XI")))]) +;; Generic part doesn't support the simpliciation of logic operation with +;; float_vector_all_ones_operand since it's not valid rtl. Add combine spiltter +;; for them, it should be safe since there's no SIMD Floating-Point Exceptions. +(define_insn_and_split "*bit_and_float_vector_all_ones" + [(set (match_operand:VFB 0 "nonimmediate_operand") + (and:VFB (match_operand:VFB 1 "nonimmediate_operand") + (match_operand:VFB 2 "float_vector_all_ones_operand")))] + "TARGET_SSE && ix86_pre_reload_split ()" + "#" + "&& 1" + [(set (match_dup 0) (match_dup 1))]) + (define_expand "copysign<mode>3" [(set (match_dup 4) (and:VFB @@ -18747,9 +18759,9 @@ (vec_select:SI (match_operand:V4SI 1 "register_operand" "v,x,v") (parallel [(const_int 0)]))))] - "TARGET_SSE4_1" + "TARGET_64BIT && TARGET_SSE4_1" "#" - [(set_attr "isa" "x64,*,avx512f") + [(set_attr "isa" "*,*,avx512f") (set (attr "preferred_for_speed") (cond [(eq_attr "alternative" "0") (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC") diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def index 45ce160..3ad5a13 100644 --- a/gcc/config/rs6000/rs6000-builtins.def +++ b/gcc/config/rs6000/rs6000-builtins.def @@ -2798,14 +2798,14 @@ ; Miscellaneous P9 functions [power9] - signed long long __builtin_darn (); - DARN darn {} + signed long __builtin_darn (); + DARN darn_64_di {32bit} - signed int __builtin_darn_32 (); - DARN_32 darn_32 {} + signed long __builtin_darn_32 (); + DARN_32 darn_32_di {32bit} - signed long long __builtin_darn_raw (); - DARN_RAW darn_raw {} + signed long __builtin_darn_raw (); + DARN_RAW darn_raw_di {32bit} const signed int __builtin_dtstsfi_eq_dd (const int<6>, _Decimal64); TSTSFI_EQ_DD dfptstsfi_eq_dd {} diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index b98f4a4..cc55174 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -5631,6 +5631,12 @@ rs6000_expand_builtin (tree exp, rtx target, rtx /* subtarget */, icode = CODE_FOR_rs6000_mftb_si; else if (fcode == RS6000_BIF_BPERMD) icode = CODE_FOR_bpermd_si; + else if (fcode == RS6000_BIF_DARN) + icode = CODE_FOR_darn_64_si; + else if (fcode == RS6000_BIF_DARN_32) + icode = CODE_FOR_darn_32_si; + else if (fcode == RS6000_BIF_DARN_RAW) + icode = CODE_FOR_darn_raw_si; else gcc_unreachable (); } diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def index 531a4fc..2b28539 100644 --- a/gcc/config/rs6000/rs6000-overload.def +++ b/gcc/config/rs6000/rs6000-overload.def @@ -3021,7 +3021,7 @@ ; is replaced by a constructor. The single overload here causes ; __builtin_vec_promote to be registered with the front end so that can happen. [VEC_PROMOTE, vec_promote, __builtin_vec_promote] - vsi __builtin_vec_promote (vsi); + vsi __builtin_vec_promote (vsi, const int); ABS_V4SI PROMOTE_FAKERY [VEC_RE, vec_re, __builtin_vec_re] diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 4122acb..9be484c 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -172,9 +172,7 @@ UNSPECV_EH_RR ; eh_reg_restore UNSPECV_ISYNC ; isync instruction UNSPECV_MFTB ; move from time base - UNSPECV_DARN ; darn 1 (deliver a random number) - UNSPECV_DARN_32 ; darn 2 - UNSPECV_DARN_RAW ; darn 0 + UNSPECV_DARN ; darn (deliver a random number) UNSPECV_NLGR ; non-local goto receiver UNSPECV_MFFS ; Move from FPSCR UNSPECV_MFFSL ; Move from FPSCR light instruction version @@ -15065,25 +15063,36 @@ ;; Miscellaneous ISA 3.0 (power9) instructions -(define_insn "darn_32" - [(set (match_operand:SI 0 "register_operand" "=r") - (unspec_volatile:SI [(const_int 0)] UNSPECV_DARN_32))] +(define_expand "darn_32_<mode>" + [(use (match_operand:GPR 0 "register_operand"))] "TARGET_P9_MISC" - "darn %0,0" - [(set_attr "type" "integer")]) +{ + emit_insn (gen_darn (<MODE>mode, operands[0], const0_rtx)); + DONE; +}) -(define_insn "darn_raw" - [(set (match_operand:DI 0 "register_operand" "=r") - (unspec_volatile:DI [(const_int 0)] UNSPECV_DARN_RAW))] - "TARGET_P9_MISC && TARGET_64BIT" - "darn %0,2" - [(set_attr "type" "integer")]) +(define_expand "darn_64_<mode>" + [(use (match_operand:GPR 0 "register_operand"))] + "TARGET_P9_MISC" +{ + emit_insn (gen_darn (<MODE>mode, operands[0], const1_rtx)); + DONE; +}) -(define_insn "darn" - [(set (match_operand:DI 0 "register_operand" "=r") - (unspec_volatile:DI [(const_int 0)] UNSPECV_DARN))] - "TARGET_P9_MISC && TARGET_64BIT" - "darn %0,1" +(define_expand "darn_raw_<mode>" + [(use (match_operand:GPR 0 "register_operand"))] + "TARGET_P9_MISC" +{ + emit_insn (gen_darn (<MODE>mode, operands[0], const2_rtx)); + DONE; +}) + +(define_insn "@darn<mode>" + [(set (match_operand:GPR 0 "register_operand" "=r") + (unspec_volatile:GPR [(match_operand 1 "const_int_operand" "n")] + UNSPECV_DARN))] + "TARGET_P9_MISC" + "darn %0,%1" [(set_attr "type" "integer")]) ;; Test byte within range. diff --git a/gcc/configure b/gcc/configure index 5470987..992a9d7 100755 --- a/gcc/configure +++ b/gcc/configure @@ -26947,7 +26947,7 @@ $as_echo "$as_me: WARNING: LTO for $target requires binutils >= 2.20.1, but vers ;; esac case $target_os in - darwin2[0-9]* | darwin19*) + darwin2* | darwin19*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for llvm assembler x86-pad-for-align option" >&5 $as_echo_n "checking assembler for llvm assembler x86-pad-for-align option... " >&6; } if ${gcc_cv_as_mllvm_x86_pad_for_align+:} false; then : diff --git a/gcc/configure.ac b/gcc/configure.ac index 2b4914b..0db9c4c 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -4692,7 +4692,7 @@ foo: nop ;; esac case $target_os in - darwin2[[0-9]]* | darwin19*) + darwin2* | darwin19*) gcc_GAS_CHECK_FEATURE([llvm assembler x86-pad-for-align option], gcc_cv_as_mllvm_x86_pad_for_align, [-mllvm -x86-pad-for-align=false], [.text],, diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b8a0726..bf5c30c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,69 @@ +2021-12-19 Matthias Kretz <m.kretz@gsi.de> + + * module.cc (trees_out::get_merge_kind): NAMESPACE_DECLs also + cannot have a DECL_TEMPLATE_INFO. + +2021-12-19 Patrick Palka <ppalka@redhat.com> + + PR c++/94376 + * lambda.c (lambda_capture_field_type): Strip location wrappers + before checking for a capture proxy. + (is_capture_proxy): Assert that we don't see a location wrapper. + (mark_const_cap_r): Don't call is_constant_capture_proxy on a + location wrapper. + +2021-12-19 Patrick Palka <ppalka@redhat.com> + + PR c++/103714 + * constraint.cc (satisfy_declaration_constraints): Do + push_to_top_level and pop_from_top_level around the call to + satisfy_normalized_constraints. + +2021-12-17 Marek Polacek <polacek@redhat.com> + + PR c/103649 + * parser.c (cp_parser_declaration): Don't warn for attribute_ignored_p. + (cp_parser_std_attribute): Skip parsing of the attribute + arguments when the attribute is ignored. + +2021-12-17 Marek Polacek <polacek@redhat.com> + + PR c++/103749 + * decl.c (lookup_and_check_tag): Give an error when a class was + declared as template but no template header has been provided. + * pt.c (do_class_deduction): Don't deduce CLASSTYPE_ERRONEOUS + types. + +2021-12-17 Iain Sandoe <iain@sandoe.co.uk> + + PR c++/100127 + * coroutines.cc (coro_rewrite_function_body): Handle initial + await expressions that try to produce a reference value. + +2021-12-17 Iain Sandoe <iain@sandoe.co.uk> + + PR c++/100772 + * coroutines.cc (morph_fn_to_coro): Convert function parms + from reference before constructing any operator-new args + list. + +2021-12-17 Jason Merrill <jason@redhat.com> + + * constraint.cc (deduce_concept_introduction): Adjust comment. + +2021-12-17 Jason Merrill <jason@redhat.com> + + PR c++/103681 + * cp-tree.h (struct lang_type): Add non_pod_aggregate. + (CLASSTYPE_NON_POD_AGGREGATE): New. + * class.c (check_field_decls): Set it. + (check_bases_and_members): Check it. + (check_non_pod_aggregate): New. + (enum eoc_mode): New. + (end_of_class): Always include non-empty fields. + Add eoc_nv_or_dsize mode. + (include_empty_classes, layout_class_type): Adjust. + 2021-12-16 Marek Polacek <polacek@redhat.com> PR c++/99980 diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 8386a7d..96fa6a7 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3177,9 +3177,11 @@ satisfy_declaration_constraints (tree t, sat_info info) { if (!push_tinst_level (t)) return result; + push_to_top_level (); push_access_scope (t); result = satisfy_normalized_constraints (norm, args, info); pop_access_scope (t); + pop_from_top_level (); pop_tinst_level (); } @@ -3235,9 +3237,11 @@ satisfy_declaration_constraints (tree t, tree args, sat_info info) if (!push_tinst_level (t, args)) return result; tree pattern = DECL_TEMPLATE_RESULT (t); + push_to_top_level (); push_access_scope (pattern); result = satisfy_normalized_constraints (norm, args, info); pop_access_scope (pattern); + pop_from_top_level (); pop_tinst_level (); } diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index c00672e..25931c9 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -4211,9 +4211,15 @@ coro_rewrite_function_body (location_t fn_start, tree fnbody, tree orig, { /* Build a compound expression that sets the initial-await-resume-called variable true and then calls the - initial suspend expression await resume. */ + initial suspend expression await resume. + In the case that the user decides to make the initial await + await_resume() return a value, we need to discard it and, it is + a reference type, look past the indirection. */ + if (INDIRECT_REF_P (initial_await)) + initial_await = TREE_OPERAND (initial_await, 0); tree vec = TREE_OPERAND (initial_await, 3); tree aw_r = TREE_VEC_ELT (vec, 2); + aw_r = convert_to_void (aw_r, ICV_STATEMENT, tf_warning_or_error); tree update = build2 (MODIFY_EXPR, boolean_type_node, i_a_r_c, boolean_true_node); aw_r = cp_build_compound_expr (update, aw_r, tf_warning_or_error); @@ -4595,8 +4601,8 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) If the lookup finds an allocation function in the scope of the promise type, overload resolution is performed on a function call created by assembling an argument list. The first argument is the amount of space - requested, and has type std::size_t. The succeeding arguments are - those of the original function. */ + requested, and has type std::size_t. The lvalues p1...pn are the + succeeding arguments.. */ vec<tree, va_gc> *args = make_tree_vector (); vec_safe_push (args, resizeable); /* Space needed. */ @@ -4614,10 +4620,10 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) this_ref = convert_to_reference (tt, this_ref, CONV_STATIC, LOOKUP_NORMAL , NULL_TREE, tf_warning_or_error); - vec_safe_push (args, this_ref); + vec_safe_push (args, convert_from_reference (this_ref)); } else - vec_safe_push (args, arg); + vec_safe_push (args, convert_from_reference (arg)); } /* Note the function selected; we test to see if it's NOTHROW. */ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7ca8770..982fca8 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -15439,6 +15439,16 @@ lookup_and_check_tag (enum tag_types tag_code, tree name, } if (DECL_CLASS_TEMPLATE_P (decl) + && !template_header_p + && how == TAG_how::CURRENT_ONLY) + { + error ("class template %qD redeclared as non-template", name); + inform (location_of (decl), "previous declaration here"); + CLASSTYPE_ERRONEOUS (TREE_TYPE (decl)) = true; + return error_mark_node; + } + + if (DECL_CLASS_TEMPLATE_P (decl) /* If scope is TAG_how::CURRENT_ONLY we're defining a class, so ignore a template template parameter. */ || (how != TAG_how::CURRENT_ONLY && DECL_TEMPLATE_TEMPLATE_PARM_P (decl))) diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index c39a2bc..b1cbe27 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -221,6 +221,8 @@ lambda_capture_field_type (tree expr, bool explicit_init_p, } else { + STRIP_ANY_LOCATION_WRAPPER (expr); + if (!by_reference_p && is_capture_proxy (expr)) { /* When capturing by-value another capture proxy from an enclosing @@ -246,6 +248,10 @@ lambda_capture_field_type (tree expr, bool explicit_init_p, bool is_capture_proxy (tree decl) { + /* Location wrappers should be stripped or otherwise handled by the + caller before using this predicate. */ + gcc_checking_assert (!location_wrapper_p (decl)); + return (VAR_P (decl) && DECL_HAS_VALUE_EXPR_P (decl) && !DECL_ANON_UNION_VAR_P (decl) @@ -1496,7 +1502,8 @@ mark_const_cap_r (tree *t, int *walk_subtrees, void *data) *walk_subtrees = 0; } } - else if (is_constant_capture_proxy (*t)) + else if (!location_wrapper_p (*t) /* is_capture_proxy dislikes them. */ + && is_constant_capture_proxy (*t)) var = DECL_CAPTURED_VARIABLE (*t); if (var) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index f3e7af2..8451e3d 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -10067,9 +10067,10 @@ trees_out::get_merge_kind (tree decl, depset *dep) tree ctx = CP_DECL_CONTEXT (decl); if (TREE_CODE (ctx) == FUNCTION_DECL) { - /* USING_DECLs cannot have DECL_TEMPLATE_INFO -- this isn't - permitting them to have one. */ + /* USING_DECLs and NAMESPACE_DECLs cannot have DECL_TEMPLATE_INFO -- + this isn't permitting them to have one. */ gcc_checking_assert (TREE_CODE (decl) == USING_DECL + || TREE_CODE (decl) == NAMESPACE_DECL || !DECL_LANG_SPECIFIC (decl) || !DECL_TEMPLATE_INFO (decl)); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 44eed7e..33fb40a 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14776,7 +14776,7 @@ cp_parser_declaration (cp_parser* parser, tree prefix_attrs) } } - if (std_attrs != NULL_TREE) + if (std_attrs != NULL_TREE && !attribute_ignored_p (std_attrs)) warning_at (make_location (attrs_loc, attrs_loc, parser->lexer), OPT_Wattributes, "attribute ignored"); if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) @@ -28979,7 +28979,9 @@ cp_parser_std_attribute (cp_parser *parser, tree attr_ns) /* A GNU attribute that takes an identifier in parameter. */ attr_flag = id_attr; - if (as == NULL) + /* If this is a fake attribute created to handle -Wno-attributes, + we must skip parsing the arguments. */ + if (as == NULL || attribute_ignored_p (as)) { if ((flag_openmp || flag_openmp_simd) && attr_ns == omp_identifier) { diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 18c6f11..4f0ae6d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -29601,6 +29601,13 @@ do_class_deduction (tree ptype, tree tmpl, tree init, if (DECL_TEMPLATE_TEMPLATE_PARM_P (tmpl)) return ptype; + /* If the class was erroneous, don't try to deduce, because that + can generate a lot of diagnostic. */ + if (TREE_TYPE (tmpl) + && TYPE_LANG_SPECIFIC (TREE_TYPE (tmpl)) + && CLASSTYPE_ERRONEOUS (TREE_TYPE (tmpl))) + return ptype; + /* Wait until the enclosing scope is non-dependent. */ if (DECL_CLASS_SCOPE_P (tmpl) && dependent_type_p (DECL_CONTEXT (tmpl))) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 03028c2..06b38f9 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -551,7 +551,7 @@ Objective-C and Objective-C++ Dialects}. -fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt @gol -fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs @gol --param @var{name}=@var{value} --O -O0 -O1 -O2 -O3 -Os -Ofast -Og} +-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz} @item Program Instrumentation Options @xref{Instrumentation Options,,Program Instrumentation Options}. @@ -10697,6 +10697,13 @@ optimization flags except for those that may interfere with debugging: -fmove-loop-invariants -fmove-loop-stores -fssa-phiopt @gol -ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra} +@item -Oz +@opindex Oz +Optimize aggressively for size rather than speed. This may increase +the number of instructions executed if those instructions require +fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os} +including enabling most @option{-O2} optimizations. + @end table If you use multiple @option{-O} options, with or without level numbers, diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 264fa1b..5efbba8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2021-12-18 Harald Anlauf <anlauf@gmx.de> + + PR fortran/103412 + * check.c (gfc_check_sizeof): Reject BOZ type argument. + 2021-12-14 Harald Anlauf <anlauf@gmx.de> PR fortran/103717 diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 3934336..625473c 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -5135,6 +5135,9 @@ gfc_check_sizeof (gfc_expr *arg) return false; } + if (illegal_boz_arg (arg)) + return false; + /* TYPE(*) is acceptable if and only if it uses an array descriptor. */ if (arg->ts.type == BT_ASSUMED && (arg->symtree->n.sym->as == NULL diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c index d3590f0..733fc21 100644 --- a/gcc/ipa-modref.c +++ b/gcc/ipa-modref.c @@ -2232,7 +2232,7 @@ class modref_eaf_analysis { public: /* Mark NAME as relevant for analysis. */ - void analyze_ssa_name (tree name); + void analyze_ssa_name (tree name, bool deferred = false); /* Dataflow slover. */ void propagate (); /* Return flags computed earlier for NAME. */ @@ -2373,33 +2373,36 @@ callee_to_caller_flags (int call_flags, bool ignore_stores, are processed later) */ void -modref_eaf_analysis::analyze_ssa_name (tree name) +modref_eaf_analysis::analyze_ssa_name (tree name, bool deferred) { imm_use_iterator ui; gimple *use_stmt; int index = SSA_NAME_VERSION (name); - /* See if value is already computed. */ - if (m_lattice[index].known || m_lattice[index].do_dataflow) - return; - if (m_lattice[index].open) + if (!deferred) { - if (dump_file) - fprintf (dump_file, - "%*sCycle in SSA graph\n", - m_depth * 4, ""); - return; - } - /* Recursion guard. */ - m_lattice[index].init (); - if (m_depth == param_modref_max_depth) - { - if (dump_file) - fprintf (dump_file, - "%*sMax recursion depth reached; postponing\n", - m_depth * 4, ""); - m_deferred_names.safe_push (name); - return; + /* See if value is already computed. */ + if (m_lattice[index].known || m_lattice[index].do_dataflow) + return; + if (m_lattice[index].open) + { + if (dump_file) + fprintf (dump_file, + "%*sCycle in SSA graph\n", + m_depth * 4, ""); + return; + } + /* Recursion guard. */ + m_lattice[index].init (); + if (m_depth == param_modref_max_depth) + { + if (dump_file) + fprintf (dump_file, + "%*sMax recursion depth reached; postponing\n", + m_depth * 4, ""); + m_deferred_names.safe_push (name); + return; + } } if (dump_file) @@ -2742,10 +2745,9 @@ modref_eaf_analysis::propagate () while (m_deferred_names.length ()) { tree name = m_deferred_names.pop (); - m_lattice[SSA_NAME_VERSION (name)].open = false; if (dump_file) fprintf (dump_file, "Analyzing deferred SSA name\n"); - analyze_ssa_name (name); + analyze_ssa_name (name, true); } if (!m_names_to_propagate.length ()) @@ -5019,9 +5021,15 @@ modref_merge_call_site_flags (escape_summary *sum, bool changed = false; bool ignore_stores = ignore_stores_p (caller, callee_ecf_flags); - /* If we have no useful info to propagate. */ - if ((!cur_summary || !cur_summary->arg_flags.length ()) - && (!cur_summary_lto || !cur_summary_lto->arg_flags.length ())) + /* Return early if we have no useful info to propagate. */ + if ((!cur_summary + || (!cur_summary->arg_flags.length () + && !cur_summary->static_chain_flags + && !cur_summary->retslot_flags)) + && (!cur_summary_lto + || (!cur_summary_lto->arg_flags.length () + && !cur_summary_lto->static_chain_flags + && !cur_summary_lto->retslot_flags))) return false; FOR_EACH_VEC_ELT (sum->esc, i, ee) diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index 54f642d..7d2b7e5 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -370,12 +370,14 @@ merge_and_complain (vec<cl_decoded_option> &decoded_options, case OPT_Ofast: case OPT_Og: case OPT_Os: + case OPT_Oz: existing_opt = -1; for (j = 0; j < decoded_options.length (); ++j) if (decoded_options[j].opt_index == OPT_O || decoded_options[j].opt_index == OPT_Ofast || decoded_options[j].opt_index == OPT_Og - || decoded_options[j].opt_index == OPT_Os) + || decoded_options[j].opt_index == OPT_Os + || decoded_options[j].opt_index == OPT_Oz) { existing_opt = j; break; @@ -407,6 +409,7 @@ merge_and_complain (vec<cl_decoded_option> &decoded_options, level = MAX (level, 1); break; case OPT_Os: + case OPT_Oz: level = MAX (level, 2); break; default: @@ -428,6 +431,7 @@ merge_and_complain (vec<cl_decoded_option> &decoded_options, level = MAX (level, 1); break; case OPT_Os: + case OPT_Oz: level = MAX (level, 2); break; default: @@ -725,6 +729,7 @@ append_compiler_options (obstack *argv_obstack, vec<cl_decoded_option> opts) case OPT_Ofast: case OPT_Og: case OPT_Os: + case OPT_Oz: break; case OPT_Xassembler: diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk index e363ac7..81c2db0 100644 --- a/gcc/optc-save-gen.awk +++ b/gcc/optc-save-gen.awk @@ -93,7 +93,7 @@ var_opt_char[1] = "optimize_size"; var_opt_char[2] = "optimize_debug"; var_opt_char[3] = "optimize_fast"; var_opt_range["optimize"] = "0, 255"; -var_opt_range["optimize_size"] = "0, 1"; +var_opt_range["optimize_size"] = "0, 2"; var_opt_range["optimize_debug"] = "0, 1"; var_opt_range["optimize_fast"] = "0, 1"; @@ -745,6 +745,15 @@ default_options_optimization (struct gcc_options *opts, opts->x_optimize_debug = 0; break; + case OPT_Oz: + opts->x_optimize_size = 2; + + /* Optimizing for size forces optimize to be 2. */ + opts->x_optimize = 2; + opts->x_optimize_fast = 0; + opts->x_optimize_debug = 0; + break; + case OPT_Ofast: /* -Ofast only adds flags to -O3. */ opts->x_optimize_size = 0; @@ -2609,6 +2618,7 @@ common_handle_option (struct gcc_options *opts, case OPT_Os: case OPT_Ofast: case OPT_Og: + case OPT_Oz: /* Currently handled in a prescan. */ break; diff --git a/gcc/print-tree.c b/gcc/print-tree.c index b5dc523..297492a 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -484,6 +484,8 @@ print_node (FILE *file, const char *prefix, tree node, int indent, fputs (" decl_6", file); if (DECL_LANG_FLAG_7 (node)) fputs (" decl_7", file); + if (DECL_LANG_FLAG_8 (node)) + fputs (" decl_8", file); mode = DECL_MODE (node); fprintf (file, " %s", GET_MODE_NAME (mode)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 919710f..87e4a2a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,160 @@ +2021-12-19 Andrew Pinski <apinski@marvell.com> + + * gcc.dg/uninit-pr89230-1.c: Change the dg-bogus messages + around and xfail both of them. + +2021-12-19 Patrick Palka <ppalka@redhat.com> + + PR c++/94376 + * g++.dg/cpp0x/lambda/lambda-nested9a.C: New test. + +2021-12-19 Patrick Palka <ppalka@redhat.com> + + PR c++/103714 + * g++.dg/cpp2a/concepts-uneval5.C: New test. + +2021-12-19 Francois-Xavier Coudert <fxcoudert@gmail.com> + + * gcc.dg/pr100509.c: Needs alias. + * gcc.dg/pragma-diag-10.c: Needs alias. + +2021-12-18 Harald Anlauf <anlauf@gmx.de> + + PR fortran/103412 + * gfortran.dg/illegal_boz_arg_2.f90: New test. + +2021-12-18 Roger Sayle <roger@nextmovesoftware.com> + Uroš Bizjak <ubizjak@gmail.com> + + PR target/103611 + * gcc.target/i386/pr103611-2.c: New test case. + +2021-12-18 Roger Sayle <roger@nextmovesoftware.com> + + PR target/32803 + * gcc.target/i386/pr32803.c: New test case. + +2021-12-18 François-Xavier Coudert <fxcoudert@gcc.gnu.org> + + * gcc.dg/darwin-minversion-link.c: Test darwin21. + * obj-c++.dg/cxx-ivars-3.mm: Homogeneize darwin versions. + * obj-c++.dg/objc-gc-3.mm: Homogeneize darwin versions. + * objc.dg/objc-gc-4.m: Homogeneize darwin versions. + +2021-12-17 Marek Polacek <polacek@redhat.com> + + PR c/103649 + * c-c++-common/Wno-attributes-6.c: New test. + +2021-12-17 David Edelsohn <dje.gcc@gmail.com> + + * gcc.target/powerpc/fold-vec-insert-float-p9.c + +2021-12-17 Olivier Hainque <hainque@adacore.com> + + * gcc.target/powerpc/pr97142.c: Add -mdejagnu-cpu=power7 + to the dg-options. + +2021-12-17 Marek Polacek <polacek@redhat.com> + + PR c++/103749 + * g++.dg/template/redecl4.C: Adjust dg-error. + * g++.dg/diagnostic/redeclaration-2.C: New test. + +2021-12-17 Segher Boessenkool <segher@kernel.crashing.org> + + PR target/103624 + * gcc.target/powerpc/darn-0.c: Remove target clause. + * gcc.target/powerpc/darn-1.c: Remove target clause. Remove lp64 + requirement. Change return type to long. + * gcc.target/powerpc/darn-2.c: Ditto. + * gcc.target/powerpc/darn-3.c: Remove target clause. + +2021-12-17 Iain Sandoe <iain@sandoe.co.uk> + + PR c++/100127 + * g++.dg/coroutines/pr100127.C: New test. + +2021-12-17 Iain Sandoe <iain@sandoe.co.uk> + + PR c++/100772 + * g++.dg/coroutines/pr100772-a.C: New test. + * g++.dg/coroutines/pr100772-b.C: New test. + +2021-12-17 Iain Sandoe <iain@sandoe.co.uk> + + PR c++/96517 + * g++.dg/coroutines/pr96517.C: New test. + +2021-12-17 David Edelsohn <dje.gcc@gmail.com> + + * gcc.target/powerpc/pragma-optimize.c: Require ifunc support. + +2021-12-17 Richard Sandiford <richard.sandiford@arm.com> + + PR tree-optimization/103744 + * gcc.dg/vect/pr103744-1.c: New test. + * gcc.dg/vect/pr103744-2.c: Likewise. + +2021-12-17 Tamar Christina <tamar.christina@arm.com> + + PR tree-optimization/103741 + * gcc.target/aarch64/pr103741.c: New test. + +2021-12-17 Haochen Jiang <haochen.jiang@intel.com> + + PR target/100738 + * g++.target/i386/avx512vl-pr100738-1.C: New test. + +2021-12-17 Siddhesh Poyarekar <siddhesh@gotplt.org> + + * g++.dg/ext/builtin-dynamic-object-size1.C: New test. + * g++.dg/ext/builtin-dynamic-object-size2.C: Likewise. + * gcc.dg/builtin-dynamic-alloc-size.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-1.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-10.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-11.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-12.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-13.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-14.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-15.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-16.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-17.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-18.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-19.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-2.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-3.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-4.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-5.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-6.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-7.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-8.c: Likewise. + * gcc.dg/builtin-dynamic-object-size-9.c: Likewise. + * gcc.dg/builtin-object-size-16.c: Adjust to allow inclusion + from builtin-dynamic-object-size-16.c. + * gcc.dg/builtin-object-size-17.c: Likewise. + +2021-12-17 Siddhesh Poyarekar <siddhesh@gotplt.org> + + * gcc.dg/builtin-object-size-1.c (test9): New test. + (main): Call it. + * gcc.dg/builtin-object-size-2.c (test8): New test. + (main): Call it. + * gcc.dg/builtin-object-size-3.c (test9): New test. + (main): Call it. + * gcc.dg/builtin-object-size-4.c (test8): New test. + (main): Call it. + * gcc.dg/builtin-object-size-5.c (test5, test6, test7): New + tests. + +2021-12-17 Jason Merrill <jason@redhat.com> + + PR c++/103681 + * g++.dg/abi/macro0.C: Update value. + * g++.dg/abi/no_unique_address6.C: New test. + * g++.dg/abi/nsdmi-aggr1.C: New test. + * g++.dg/abi/nsdmi-aggr1a.C: New test. + 2021-12-16 Sandra Loosemore <sandra@codesourcery.com> * gcc.dg/20021029-1.c: Build with -G0 for nios2. diff --git a/gcc/testsuite/c-c++-common/Wno-attributes-6.c b/gcc/testsuite/c-c++-common/Wno-attributes-6.c new file mode 100644 index 0000000..ca3c7be --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wno-attributes-6.c @@ -0,0 +1,16 @@ +/* PR c/103649 */ +/* { dg-do compile { target { c || c++11 } } } */ +/* { dg-additional-options "-Wno-attributes=foo::bar" } */ +/* { dg-additional-options "-Wno-attributes=baz::" } */ +/* { dg-additional-options "-Wno-attributes=womp::womp" } */ +/* { dg-additional-options "-Wno-attributes=qux::foo" } */ +/* { dg-additional-options "-Wno-attributes=vendor::assume" } */ + +[[vendor::assume(1 + 1 == 2)]]; +[[foo::bar(1, 2)]]; +[[baz::bar(1, 2)]]; +[[foo::bar(1, 2)]] void f1(); +[[baz::bar(1, 2)]] void f2(); +[[qux::foo({t})]] void f3(); +[[womp::womp (another::directive (threadprivate (t)))]] void f4(); +[[womp::womp (another::directive (threadprivate (t)))]]; diff --git a/gcc/testsuite/g++.dg/coroutines/pr100127.C b/gcc/testsuite/g++.dg/coroutines/pr100127.C new file mode 100644 index 0000000..374cd71 --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/pr100127.C @@ -0,0 +1,65 @@ +#ifdef __clang__ +#include <experimental/coroutine> +namespace std { + using namespace std::experimental; +} +#else +#include <coroutine> +#endif +#include <optional> + +struct future +{ + using value_type = int; + struct promise_type; + using handle_type = std::coroutine_handle<promise_type>; + + handle_type _coroutine; + + future(handle_type h) : _coroutine{h} {} + + ~future() noexcept{ + if (_coroutine) { + _coroutine.destroy(); + } + } + + value_type get() { + auto ptr = _coroutine.promise()._value; + return *ptr; + } + + struct promise_type { + std::optional<value_type> _value = std::nullopt; + + future get_return_object() { + return future{handle_type::from_promise(*this)}; + } + void return_value(value_type val) { + _value = static_cast<value_type &&>(val); + } + auto initial_suspend() noexcept { + class awaiter { + std::optional<value_type> & value; + public: + explicit awaiter(std::optional<value_type> & val) noexcept : value{val} {} + bool await_ready() noexcept { return value.has_value(); } + void await_suspend(handle_type) noexcept { } + value_type & await_resume() noexcept { return *value; } + }; + + return awaiter{_value}; + } + std::suspend_always final_suspend() noexcept { + return {}; + } + //void return_void() {} + void unhandled_exception() {} + }; +}; + +future create_future() +{ co_return 2021; } + +int main() +{ auto f = create_future(); } diff --git a/gcc/testsuite/g++.dg/coroutines/pr100772-a.C b/gcc/testsuite/g++.dg/coroutines/pr100772-a.C new file mode 100644 index 0000000..a325d38 --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/pr100772-a.C @@ -0,0 +1,77 @@ +// { dg-additional-options "-fsyntax-only " } +#ifdef __clang__ +#include <experimental/coroutine> +namespace std { + using namespace std::experimental; +} +#else +#include <coroutine> +#endif + +struct Task +{ + struct promise_type + { + void return_void() const noexcept {} + + void* operator new(std::size_t, auto &&...args) noexcept + { + static_assert(sizeof...(args) > 0); + static_assert(sizeof...(args) == 2); + + return nullptr; + } + + void operator delete(void *, std::size_t) noexcept + { + } + + static Task get_return_object_on_allocation_failure() noexcept + { + return {}; + } + + Task get_return_object() noexcept + { + return Task{ *this }; + } + + std::suspend_always initial_suspend() noexcept + { + return {}; + } + + std::suspend_always final_suspend() noexcept + { + return {}; + } + + void unhandled_exception() noexcept {} + }; + + using promise_handle = std::coroutine_handle<promise_type>; + + Task() = default; + Task(promise_type & promise) noexcept + : m_handle{ promise_handle::from_promise(promise) } + {} + + ~Task() + { + if (m_handle.address()) { m_handle.destroy(); } + } + + promise_handle m_handle{}; +}; + + +Task Foo(auto && ... args) noexcept +{ + co_return; +} + +int main() +{ + int v; + Foo(v, 2134); +} diff --git a/gcc/testsuite/g++.dg/coroutines/pr100772-b.C b/gcc/testsuite/g++.dg/coroutines/pr100772-b.C new file mode 100644 index 0000000..6cdf8d1 --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/pr100772-b.C @@ -0,0 +1,93 @@ +#ifdef __clang__ +#include <experimental/coroutine> +namespace std { + using namespace std::experimental; +} +#else +#include <coroutine> +#endif +#include <cstdio> +#include <typeinfo> +#include <cxxabi.h> // needed for abi::__cxa_demangle +#include <memory> + +std::shared_ptr<char> cppDemangle(const char *abiName) +{ + int status; + char *ret = abi::__cxa_demangle(abiName, 0, 0, &status); + + /* NOTE: must free() the returned char when done with it! */ + std::shared_ptr<char> retval; + retval.reset( (char *)ret, [](char *mem) { if (mem) free((void*)mem); } ); + return retval; +} + +template <typename T> +struct Id{}; +struct Task +{ + struct promise_type + { + void return_void() const noexcept {} + + static void is_int (std::string x) { + if (x != "Id<int>") + abort() ; + } + template <typename ... Args> + void* operator new(std::size_t len, Args ...args) noexcept + { + (is_int (cppDemangle(typeid(Id<Args>).name()).get()), ...); + (std::puts (cppDemangle(typeid(Id<Args>).name()).get()), ...); + return nullptr; + } + + static Task get_return_object_on_allocation_failure() noexcept + { + return {}; + } + + Task get_return_object() noexcept + { + return Task{ *this }; + } + + std::suspend_always initial_suspend() noexcept + { + return {}; + } + + std::suspend_always final_suspend() noexcept + { + return {}; + } + + void unhandled_exception() noexcept {} + }; + + using promise_handle = std::coroutine_handle<promise_type>; + + Task() = default; + Task(promise_type & promise) noexcept + : m_handle{ promise_handle::from_promise(promise) } + {} + + ~Task() + { + if (m_handle.address()) { m_handle.destroy(); } + } + + promise_handle m_handle{}; +}; + + +Task Foo(auto && ... args) noexcept +{ + co_return; +} + +int main() +{ + int v; + Foo(v, 2134); +} diff --git a/gcc/testsuite/g++.dg/coroutines/pr96517.C b/gcc/testsuite/g++.dg/coroutines/pr96517.C new file mode 100644 index 0000000..9cbac3e --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/pr96517.C @@ -0,0 +1,29 @@ +// { dg-additional-options " -O1 " } +#include <coroutine> + +struct coroutine { + struct promise_type { + coroutine get_return_object() { return {}; } + void return_void() {} + void unhandled_exception() {} + auto initial_suspend() noexcept { return std::suspend_never{}; } + auto final_suspend() noexcept { return std::suspend_never{}; } + }; +}; + +struct data { + constexpr int get() { return 5; } +}; + +struct test { + data _data; + + void foo() { + [this]() -> coroutine { + _data.get(); + co_return; + }; + } +}; + +int main() {} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested9a.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested9a.C new file mode 100644 index 0000000..d62f8f0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested9a.C @@ -0,0 +1,42 @@ +// PR c++/94376 +// Like lambda-nested9.C but using explicit captures in the inner lambda. +// { dg-do compile { target c++11 } } + +int main() { + // We used to incorrectly reject the first two cases. + int i = 0; + [=] () { + [i] () mutable { + ++i; + }; + }; + +#if __cpp_init_captures + [j=0] () { + [j] () mutable { + ++j; + }; + }; +#endif + + [=] () { + [&i] () mutable { + ++i; // { dg-error "read-only" } + }; + }; + + const int j = 0; + [=] () { + [j] () mutable { + ++j; // { dg-error "read-only" } + }; + }; + +#if __cpp_init_captures + [j=0] () { + [&j] () mutable { + ++j; // { dg-error "read-only" "" { target c++14 } } + }; + }; +#endif +} diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-uneval5.C b/gcc/testsuite/g++.dg/cpp2a/concepts-uneval5.C new file mode 100644 index 0000000..a315a59 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-uneval5.C @@ -0,0 +1,17 @@ +// PR c++/103714 +// { dg-do compile { target c++20 } } + +template<int I> +struct A { + static const int i = I; + + template<int J> + void f(A<J> d = {}) requires (d.i != i) { + f<I>(); // { dg-error "no match" } + } +}; + +int main() { + A<0> a; + a.f<1>(); +} diff --git a/gcc/testsuite/g++.dg/diagnostic/redeclaration-2.C b/gcc/testsuite/g++.dg/diagnostic/redeclaration-2.C new file mode 100644 index 0000000..4423e12 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/redeclaration-2.C @@ -0,0 +1,19 @@ +// PR c++/103749 + +struct foo { + template<typename> + friend struct bar; +}; + +struct bar { // { dg-error "redeclared as non-template" } + int baz; +}; + +template<typename> +struct T; // { dg-message "previous" } + +struct T { // { dg-error "redeclared as non-template" } +}; + +bar var; // { dg-error "" } +T t; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/template/redecl4.C b/gcc/testsuite/g++.dg/template/redecl4.C index 5638bde..c9282cd 100644 --- a/gcc/testsuite/g++.dg/template/redecl4.C +++ b/gcc/testsuite/g++.dg/template/redecl4.C @@ -2,4 +2,4 @@ // { dg-do compile } template<int> union A; // { dg-message "previous" } -struct A; // { dg-error "non-template" } +struct A; // { dg-error "redeclared as non-template" } diff --git a/gcc/testsuite/g++.dg/torture/pr103669.C b/gcc/testsuite/g++.dg/torture/pr103669.C new file mode 100644 index 0000000..a9509c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr103669.C @@ -0,0 +1,22 @@ +// { dg-do run } +/* { dg-additional-options "--param=modref-max-depth=1" } */ +#include <list> + +typedef std::list<void *> PtrList; + +void +SlList (PtrList *l) +{ + PtrList temp = *l; + PtrList::iterator iter; + for (iter = temp.begin (); iter != temp.end (); ++iter) + __builtin_abort (); +} + +int +main (void) +{ + PtrList list; + SlList (&list); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/darwin-minversion-link.c b/gcc/testsuite/gcc.dg/darwin-minversion-link.c index 765fb79..b6ede31 100644 --- a/gcc/testsuite/gcc.dg/darwin-minversion-link.c +++ b/gcc/testsuite/gcc.dg/darwin-minversion-link.c @@ -15,7 +15,8 @@ /* { dg-additional-options "-mmacosx-version-min=010.013.06 -DCHECK=101306" { target *-*-darwin17* } } */ /* { dg-additional-options "-mmacosx-version-min=010.014.05 -DCHECK=101405" { target *-*-darwin18* } } */ /* { dg-additional-options "-mmacosx-version-min=010.015.06 -DCHECK=101506" { target *-*-darwin19* } } */ -/* { dg-additional-options "-mmacosx-version-min=011.000.00 -DCHECK=110000" { target *-*-darwin20 } } */ +/* { dg-additional-options "-mmacosx-version-min=011.000.00 -DCHECK=110000" { target *-*-darwin20* } } */ +/* { dg-additional-options "-mmacosx-version-min=012.000.00 -DCHECK=120000" { target *-*-darwin21* } } */ int main () diff --git a/gcc/testsuite/gcc.dg/pr100509.c b/gcc/testsuite/gcc.dg/pr100509.c index 9405e2a..38e7002 100644 --- a/gcc/testsuite/gcc.dg/pr100509.c +++ b/gcc/testsuite/gcc.dg/pr100509.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O" } */ +/* { dg-require-alias "" } */ struct X { int a; diff --git a/gcc/testsuite/gcc.dg/pragma-diag-10.c b/gcc/testsuite/gcc.dg/pragma-diag-10.c index 127b299..a1637be 100644 --- a/gcc/testsuite/gcc.dg/pragma-diag-10.c +++ b/gcc/testsuite/gcc.dg/pragma-diag-10.c @@ -1,7 +1,8 @@ /* PR middle-end/98512 - #pragma GCC diagnostic ignored ineffective in conjunction with alias attribute { dg-do compile } - { dg-options "-O2 -Wall" } */ + { dg-options "-O2 -Wall" } + { dg-require-alias "" } */ void * __rawmemchr_ppc (const void *s, int c) diff --git a/gcc/testsuite/gcc.dg/uninit-pr89230-1.c b/gcc/testsuite/gcc.dg/uninit-pr89230-1.c index dfc87a5..bf536e2 100644 --- a/gcc/testsuite/gcc.dg/uninit-pr89230-1.c +++ b/gcc/testsuite/gcc.dg/uninit-pr89230-1.c @@ -9,7 +9,7 @@ struct S { int i, j; }; int g (void) { struct S *p = f (); - struct S *q; // { dg-bogus "may be used uninitialized" "uninitialized" { xfail *-*-* } } + struct S *q; // { dg-bogus "" "uninitialized" { xfail *-*-* } } if (p->i || !(q = f ()) || p->j != q->i) { @@ -18,7 +18,7 @@ int g (void) if (p->i) return 1; - if (!q) // { dg-bogus "\\\[-Wmaybe-uninitialized" } + if (!q) // { dg-bogus "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } } return 2; } diff --git a/gcc/testsuite/gcc.dg/vect/pr103744-1.c b/gcc/testsuite/gcc.dg/vect/pr103744-1.c new file mode 100644 index 0000000..1bc81e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr103744-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int r; + +void +foo (short int *s, short int *d1, short int *d2, int z) +{ + int *a; + + while (z < 1) + { + int i; + + i = *s++ - (*d1++ + *d2++); + r += a[i]; + i = *s++ - (*d1++ + *d2++); + r += a[i]; + ++z; + } +} diff --git a/gcc/testsuite/gcc.dg/vect/pr103744-2.c b/gcc/testsuite/gcc.dg/vect/pr103744-2.c new file mode 100644 index 0000000..52307ab --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr103744-2.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ + +int +f1 (int *restrict x, unsigned short *restrict y) +{ + int res = 0; + for (int i = 0; i < 100; i += 2) + { + unsigned short i1 = y[i + 0] + 1; + unsigned short i2 = y[i + 1] + 2; + res += x[i1]; + res += x[i2]; + } + return res; +} + +void +f2 (int *restrict x, unsigned short *restrict y) +{ + int res1 = 0; + int res2 = 0; + for (int i = 0; i < 100; i += 2) + { + unsigned short i1 = y[i + 0] + 1; + unsigned short i2 = y[i + 1] + 2; + res1 += x[i1]; + res2 += x[i2]; + } + x[0] = res1; + x[1] = res2; +} diff --git a/gcc/testsuite/gcc.target/i386/pr103611-2.c b/gcc/testsuite/gcc.target/i386/pr103611-2.c new file mode 100644 index 0000000..1555e99 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr103611-2.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-m32 -O2 -msse4" } */ +typedef int __v4si __attribute__ ((__vector_size__ (16))); + +long long test1(__v4si v) { + unsigned int loVal = (unsigned int)v[0]; + unsigned int hiVal = (unsigned int)v[1]; + return (long long)(loVal) | ((long long)(hiVal) << 32); +} + +long long test2(__v4si v) { + unsigned int loVal = (unsigned int)v[2]; + unsigned int hiVal = (unsigned int)v[3]; + return (long long)(loVal) | ((long long)(hiVal) << 32); +} + +long long test3(__v4si v) { + unsigned int loVal = (unsigned int)v[0]; + unsigned int hiVal = (unsigned int)v[1]; + return (long long)(loVal) ^ ((long long)(hiVal) << 32); +} + +long long test4(__v4si v) { + unsigned int loVal = (unsigned int)v[2]; + unsigned int hiVal = (unsigned int)v[3]; + return (long long)(loVal) ^ ((long long)(hiVal) << 32); +} + +long long test5(__v4si v) { + unsigned int loVal = (unsigned int)v[0]; + unsigned int hiVal = (unsigned int)v[1]; + return (long long)(loVal) + ((long long)(hiVal) << 32); +} + +long long test6(__v4si v) { + unsigned int loVal = (unsigned int)v[2]; + unsigned int hiVal = (unsigned int)v[3]; + return (long long)(loVal) + ((long long)(hiVal) << 32); +} + +/* { dg-final { scan-assembler-not "\tor" } } */ +/* { dg-final { scan-assembler-not "\txor" } } */ +/* { dg-final { scan-assembler-not "\tadd" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr32803.c b/gcc/testsuite/gcc.target/i386/pr32803.c new file mode 100644 index 0000000..f26f07a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr32803.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Oz" } */ + +int foo() +{ + return 25; +} + +/* { dg-final { scan-assembler "push" } } */ +/* { dg-final { scan-assembler "pop" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr98468.c b/gcc/testsuite/gcc.target/i386/pr98468.c new file mode 100644 index 0000000..ca3aa256 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr98468.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512dq -mavx512vl -O2" } */ +/* { dg-final { scan-assembler-not "vxorp" } } */ +/* { dg-final { scan-assembler-not "vandnp" } } */ + +#include<immintrin.h> +__m128 f(__m128 val) +{ + return _mm_andnot_ps(_mm_set_ps1(0.0f), val); +} + +__m256 f2(__m256 val) +{ + return _mm256_andnot_ps(_mm256_set1_ps(0.0f), val); +} + +__m512 f3(__m512 val) +{ + return _mm512_andnot_ps(_mm512_set1_ps(0.0f), val); +} + +__m128d f4(__m128d val) +{ + return _mm_andnot_pd(_mm_set_pd1(0.0), val); +} + +__m256d f5(__m256d val) +{ + return _mm256_andnot_pd(_mm256_set1_pd(0.0), val); +} + +__m512d f6(__m512d val) +{ + return _mm512_andnot_pd(_mm512_set1_pd(0.0), val); +} diff --git a/gcc/testsuite/gcc.target/powerpc/darn-0.c b/gcc/testsuite/gcc.target/powerpc/darn-0.c index f446f49..64d98f5 100644 --- a/gcc/testsuite/gcc.target/powerpc/darn-0.c +++ b/gcc/testsuite/gcc.target/powerpc/darn-0.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-do compile } */ /* { dg-require-effective-target powerpc_p9vector_ok } */ /* { dg-skip-if "" { powerpc*-*-aix* } } */ /* { dg-options "-mdejagnu-cpu=power9" } */ diff --git a/gcc/testsuite/gcc.target/powerpc/darn-1.c b/gcc/testsuite/gcc.target/powerpc/darn-1.c index 0938718..f483a89 100644 --- a/gcc/testsuite/gcc.target/powerpc/darn-1.c +++ b/gcc/testsuite/gcc.target/powerpc/darn-1.c @@ -1,12 +1,11 @@ -/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-do compile } */ /* { dg-require-effective-target powerpc_p9vector_ok } */ -/* { dg-require-effective-target lp64 } */ /* { dg-skip-if "" { powerpc*-*-aix* } } */ /* { dg-options "-mdejagnu-cpu=power9" } */ #include <altivec.h> -long long get_conditioned_random () +long get_conditioned_random () { return __builtin_darn (); } diff --git a/gcc/testsuite/gcc.target/powerpc/darn-2.c b/gcc/testsuite/gcc.target/powerpc/darn-2.c index 64e44b2..56a9ffb 100644 --- a/gcc/testsuite/gcc.target/powerpc/darn-2.c +++ b/gcc/testsuite/gcc.target/powerpc/darn-2.c @@ -1,12 +1,11 @@ -/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-do compile } */ /* { dg-require-effective-target powerpc_p9vector_ok } */ -/* { dg-require-effective-target lp64 } */ /* { dg-skip-if "" { powerpc*-*-aix* } } */ /* { dg-options "-mdejagnu-cpu=power9" } */ #include <altivec.h> -long long get_raw_random () +long get_raw_random () { return __builtin_darn_raw (); } diff --git a/gcc/testsuite/gcc.target/powerpc/darn-3.c b/gcc/testsuite/gcc.target/powerpc/darn-3.c index 477901f..4c68fad 100644 --- a/gcc/testsuite/gcc.target/powerpc/darn-3.c +++ b/gcc/testsuite/gcc.target/powerpc/darn-3.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-do compile } */ /* { dg-skip-if "" { powerpc*-*-aix* } } */ /* { dg-options "-O2 -mdejagnu-cpu=power9" } */ diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-insert-float-p9.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-insert-float-p9.c index 4541768..1c57672 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-insert-float-p9.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-insert-float-p9.c @@ -31,5 +31,5 @@ testf_cst (float f, vector float vf) /* { dg-final { scan-assembler-times {\mstfs\M} 2 { target ilp32 } } } */ /* { dg-final { scan-assembler-times {\mlxv\M} 2 { target ilp32 } } } */ /* { dg-final { scan-assembler-times {\mlvewx\M} 1 { target ilp32 } } } */ -/* { dg-final { scan-assembler-times {\mvperm\M} 2 { target ilp32 } } } */ -/* { dg-final { scan-assembler-times {\mxxperm\M} 1 { target ilp32 } } } */ +/* { dg-final { scan-assembler-times {\mvperm\M} 1 { target ilp32 } } } */ +/* { dg-final { scan-assembler-times {\mxxperm\M} 2 { target ilp32 } } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr97142.c b/gcc/testsuite/gcc.target/powerpc/pr97142.c index 0e5f1c1..dd10b06 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr97142.c +++ b/gcc/testsuite/gcc.target/powerpc/pr97142.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-Ofast" } */ +/* { dg-options "-Ofast -mdejagnu-cpu=power7" } */ #include <math.h> diff --git a/gcc/testsuite/gcc.target/powerpc/pragma-optimize.c b/gcc/testsuite/gcc.target/powerpc/pragma-optimize.c index e8ba63a..3b1fc6d 100644 --- a/gcc/testsuite/gcc.target/powerpc/pragma-optimize.c +++ b/gcc/testsuite/gcc.target/powerpc/pragma-optimize.c @@ -1,3 +1,4 @@ +/* { dg-require-ifunc "" } */ /* { dg-options "-O2 -mlong-double-128 -mabi=ibmlongdouble" } */ extern unsigned long int x; diff --git a/gcc/testsuite/gfortran.dg/illegal_boz_arg_2.f90 b/gcc/testsuite/gfortran.dg/illegal_boz_arg_2.f90 new file mode 100644 index 0000000..3e5f6b6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/illegal_boz_arg_2.f90 @@ -0,0 +1,6 @@ +! { dg-do compile } +! PR fortran/103412 + +program p + integer, parameter :: a = sizeof(z'1') ! { dg-error "cannot be an actual" } +end diff --git a/gcc/testsuite/obj-c++.dg/cxx-ivars-3.mm b/gcc/testsuite/obj-c++.dg/cxx-ivars-3.mm index 0712355..27bae63 100644 --- a/gcc/testsuite/obj-c++.dg/cxx-ivars-3.mm +++ b/gcc/testsuite/obj-c++.dg/cxx-ivars-3.mm @@ -2,7 +2,7 @@ // { dg-do run { target *-*-darwin* } } // { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } -// { dg-skip-if "Headers incompatible with 10.4 APIs" { *-*-darwin1[1-9]* *-*-darwin2[0-9]* } { "-fnext-runtime" } { "" } } +// { dg-skip-if "Headers incompatible with 10.4 APIs" { *-*-darwin1[1-9]* *-*-darwin2* } { "-fnext-runtime" } { "" } } // { dg-additional-options "-fobjc-call-cxx-cdtors -mmacosx-version-min=10.4 -framework Foundation" } // This test has no equivalent or meaning for m64/ABI V2 // { dg-xfail-run-if "No Test Avail" { *-*-darwin* && lp64 } { "-fnext-runtime" } { "" } } diff --git a/gcc/testsuite/obj-c++.dg/objc-gc-3.mm b/gcc/testsuite/obj-c++.dg/objc-gc-3.mm index 45ffbc5..18f2cbe 100644 --- a/gcc/testsuite/obj-c++.dg/objc-gc-3.mm +++ b/gcc/testsuite/obj-c++.dg/objc-gc-3.mm @@ -3,7 +3,7 @@ /* Contributed by Ziemowit Laski <zlaski@apple.com> */ /* { dg-do compile } */ -/* { dg-skip-if "GC API is an error from Darwin16." { *-*-darwin1[6-9]* *-*-darwin2[0-9]* } { "-fnext-runtime" } { "" } } */ +/* { dg-skip-if "GC API is an error from Darwin16." { *-*-darwin1[6-9]* *-*-darwin2* } { "-fnext-runtime" } { "" } } */ /* { dg-options "-fobjc-gc" } */ /* { dg-prune-output "cc1objplus: warning: '-fobjc-gc' is ignored for '-fgnu-runtime'" } */ diff --git a/gcc/testsuite/objc.dg/objc-gc-4.m b/gcc/testsuite/objc.dg/objc-gc-4.m index 8102a5a..1b2d9674 100644 --- a/gcc/testsuite/objc.dg/objc-gc-4.m +++ b/gcc/testsuite/objc.dg/objc-gc-4.m @@ -3,7 +3,7 @@ /* Contributed by Ziemowit Laski <zlaski@apple.com> */ /* { dg-do compile } */ -/* { dg-skip-if "GC API is an error from Darwin16." { *-*-darwin1[6-9]* *-*-darwin2[0-9]* } { "-fnext-runtime" } { "" } } */ +/* { dg-skip-if "GC API is an error from Darwin16." { *-*-darwin1[6-9]* *-*-darwin2* } { "-fnext-runtime" } { "" } } */ /* { dg-options "-fobjc-gc" } */ /* { dg-prune-output "cc1obj: warning: '-fobjc-gc' is ignored for '-fgnu-runtime'" } */ diff --git a/gcc/tree-core.h b/gcc/tree-core.h index 91ae523..9b37a06 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -2077,7 +2077,9 @@ struct attribute_spec { /* The minimum length of the list of arguments of the attribute. */ int min_length; /* The maximum length of the list of arguments of the attribute - (-1 for no maximum). */ + (-1 for no maximum). It can also be -2 for fake attributes + created for the sake of -Wno-attributes; in that case, we + should skip the balanced token sequence when parsing the attribute. */ int max_length; /* Whether this attribute requires a DECL. If it does, it will be passed from types of DECLs, function return types and array element types to diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index 71f6b74..ee9ea1b 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -83,30 +83,13 @@ static bitmap computed[OST_END]; /* Maximum value of offset we consider to be addition. */ static unsigned HOST_WIDE_INT offset_limit; -/* Initial value of object sizes; zero for maximum and SIZE_MAX for minimum - object size. */ - -static inline unsigned HOST_WIDE_INT -initval (int object_size_type) -{ - return (object_size_type & OST_MINIMUM) ? HOST_WIDE_INT_M1U : 0; -} - -/* Unknown object size value; it's the opposite of initval. */ - -static inline unsigned HOST_WIDE_INT -unknown (int object_size_type) -{ - return ~initval (object_size_type); -} - /* Return true if VAL is represents an unknown size for OBJECT_SIZE_TYPE. */ static inline bool size_unknown_p (tree val, int object_size_type) { - return (tree_fits_uhwi_p (val) - && tree_to_uhwi (val) == unknown (object_size_type)); + return ((object_size_type & OST_MINIMUM) + ? integer_zerop (val) : integer_all_onesp (val)); } /* Return a tree with initial value for OBJECT_SIZE_TYPE. */ @@ -114,7 +97,8 @@ size_unknown_p (tree val, int object_size_type) static inline tree size_initval (int object_size_type) { - return size_int (initval (object_size_type)); + return ((object_size_type & OST_MINIMUM) + ? TYPE_MAX_VALUE (sizetype) : size_zero_node); } /* Return a tree with unknown value for OBJECT_SIZE_TYPE. */ @@ -122,7 +106,8 @@ size_initval (int object_size_type) static inline tree size_unknown (int object_size_type) { - return size_int (unknown (object_size_type)); + return ((object_size_type & OST_MINIMUM) + ? size_zero_node : TYPE_MAX_VALUE (sizetype)); } /* Grow object_sizes[OBJECT_SIZE_TYPE] to num_ssa_names. */ diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 3eac9b1..714deab 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -900,6 +900,8 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, result = maybe_push_res_to_seq (&op, &seq1); if (result) { + if (loc != UNKNOWN_LOCATION) + annotate_all_with_location (seq1, loc); gimple_seq_add_seq_without_update (seq, seq1); return result; } @@ -929,6 +931,8 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, result = maybe_push_res_to_seq (&op1, &seq1); if (result) { + if (loc != UNKNOWN_LOCATION) + annotate_all_with_location (seq1, loc); gimple_seq_add_seq_without_update (seq, seq1); return result; } diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index ad90cdb..c842d50 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -9249,6 +9249,8 @@ vectorizable_load (vec_info *vinfo, group_size = vec_num = 1; group_gap_adj = 0; ref_type = reference_alias_ptr_type (DR_REF (first_dr_info->dr)); + if (slp) + vec_num = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node); } gcc_assert (alignment_support_scheme); @@ -9594,7 +9596,7 @@ vectorizable_load (vec_info *vinfo, final_mask = prepare_vec_mask (loop_vinfo, mask_vectype, final_mask, vec_mask, gsi); - if (i > 0) + if (i > 0 && !STMT_VINFO_GATHER_SCATTER_P (stmt_info)) dataref_ptr = bump_vector_ptr (vinfo, dataref_ptr, ptr_incr, gsi, stmt_info, bump); @@ -9611,7 +9613,7 @@ vectorizable_load (vec_info *vinfo, && gs_info.ifn != IFN_LAST) { if (STMT_VINFO_GATHER_SCATTER_P (stmt_info)) - vec_offset = vec_offsets[j]; + vec_offset = vec_offsets[vec_num * j + i]; tree zero = build_zero_cst (vectype); tree scale = size_int (gs_info.scale); gcall *call; diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index a8d55a9..2c6c35e 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,14 @@ +2021-12-17 Iain Sandoe <iain@sandoe.co.uk> + + * config.host: Add shim declaration header to powerpc*-darwin builds. + * config/rs6000/t-darwin-ehs: Remove dependency on the powerpc end + file. + * config/t-darwin-ehs: Add dependencies to the shared unwinder + objects. + * config/t-slibgcc-darwin: Add extra_parts to the dependencies for + the shared EH lib. Add all-multi to the dependencies for the + libgcc_s.1.dylib redirections. + 2021-12-13 Olivier Hainque <hainque@adacore.com> * config.host (powerpc*-*-vxworks7*): Remove diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 2f366c8..f95b524 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,17 @@ +2021-12-19 Francois-Xavier Coudert <fxcoudert@gmail.com> + + * configure.host: Add aarch64-apple-darwin support. + * config/fpu-aarch64.h: New file. + +2021-12-18 François-Xavier Coudert <fxcoudert@gcc.gnu.org> + + * libgfortran.h: include ctype.h, provide safe macros. + * io/format.c: use safe macros. + * io/list_read.c: use safe macros. + * io/read.c: use safe macros. + * io/write.c: use safe macros. + * runtime/environ.c: use safe macros. + 2021-12-16 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> * io/file_pos.c: Fix error code. diff --git a/libgfortran/config/fpu-aarch64.h b/libgfortran/config/fpu-aarch64.h new file mode 100644 index 0000000..0746f42 --- /dev/null +++ b/libgfortran/config/fpu-aarch64.h @@ -0,0 +1,331 @@ +/* FPU-related code for aarch64. + Copyright (C) 2020 Free Software Foundation, Inc. + Contributed by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> + +This file is part of the GNU Fortran runtime library (libgfortran). + +Libgfortran 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 of the License, or (at your option) any later version. + +Libgfortran 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/>. */ + + +/* Rounding mask and modes */ + +#define FPCR_RM_MASK 0x0c00000 +#define FE_TONEAREST 0x0000000 +#define FE_UPWARD 0x0400000 +#define FE_DOWNWARD 0x0800000 +#define FE_TOWARDZERO 0x0c00000 +#define FE_MAP_FZ 0x1000000 + +/* Exceptions */ + +#define FE_INVALID 1 +#define FE_DIVBYZERO 2 +#define FE_OVERFLOW 4 +#define FE_UNDERFLOW 8 +#define FE_INEXACT 16 + +#define FE_ALL_EXCEPT (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) +#define FE_EXCEPT_SHIFT 8 + + + +/* This structure corresponds to the layout of the block + written by FSTENV. */ +struct fenv +{ + unsigned int __fpcr; + unsigned int __fpsr; +}; + +/* Check we can actually store the FPU state in the allocated size. */ +_Static_assert (sizeof(struct fenv) <= (size_t) GFC_FPE_STATE_BUFFER_SIZE, + "GFC_FPE_STATE_BUFFER_SIZE is too small"); + + + +void +set_fpu (void) +{ + if (options.fpe & GFC_FPE_DENORMAL) + estr_write ("Fortran runtime warning: Floating point 'denormal operand' " + "exception not supported.\n"); + + set_fpu_trap_exceptions (options.fpe, 0); +} + + +int +get_fpu_trap_exceptions (void) +{ + unsigned int fpcr, exceptions; + int res = 0; + + fpcr = __builtin_aarch64_get_fpcr(); + exceptions = (fpcr >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT; + + if (exceptions & FE_INVALID) res |= GFC_FPE_INVALID; + if (exceptions & FE_DIVBYZERO) res |= GFC_FPE_ZERO; + if (exceptions & FE_OVERFLOW) res |= GFC_FPE_OVERFLOW; + if (exceptions & FE_UNDERFLOW) res |= GFC_FPE_UNDERFLOW; + if (exceptions & FE_INEXACT) res |= GFC_FPE_INEXACT; + + return res; +} + + +void set_fpu_trap_exceptions (int trap, int notrap) +{ + unsigned int mode_set = 0, mode_clr = 0; + unsigned int fpsr, fpsr_new; + unsigned int fpcr, fpcr_new; + + if (trap & GFC_FPE_INVALID) + mode_set |= FE_INVALID; + if (notrap & GFC_FPE_INVALID) + mode_clr |= FE_INVALID; + + if (trap & GFC_FPE_ZERO) + mode_set |= FE_DIVBYZERO; + if (notrap & GFC_FPE_ZERO) + mode_clr |= FE_DIVBYZERO; + + if (trap & GFC_FPE_OVERFLOW) + mode_set |= FE_OVERFLOW; + if (notrap & GFC_FPE_OVERFLOW) + mode_clr |= FE_OVERFLOW; + + if (trap & GFC_FPE_UNDERFLOW) + mode_set |= FE_UNDERFLOW; + if (notrap & GFC_FPE_UNDERFLOW) + mode_clr |= FE_UNDERFLOW; + + if (trap & GFC_FPE_INEXACT) + mode_set |= FE_INEXACT; + if (notrap & GFC_FPE_INEXACT) + mode_clr |= FE_INEXACT; + + /* Clear stalled exception flags. */ + fpsr = __builtin_aarch64_get_fpsr(); + fpsr_new = fpsr & ~FE_ALL_EXCEPT; + if (fpsr_new != fpsr) + __builtin_aarch64_set_fpsr(fpsr_new); + + fpcr_new = fpcr = __builtin_aarch64_get_fpcr(); + fpcr_new |= (mode_set << FE_EXCEPT_SHIFT); + fpcr_new &= ~(mode_clr << FE_EXCEPT_SHIFT); + + if (fpcr_new != fpcr) + __builtin_aarch64_set_fpcr(fpcr_new); +} + + +int +support_fpu_flag (int flag) +{ + if (flag & GFC_FPE_DENORMAL) + return 0; + + return 1; +} + + +int +support_fpu_trap (int flag) +{ + if (flag & GFC_FPE_DENORMAL) + return 0; + + return 1; +} + + +int +get_fpu_except_flags (void) +{ + int result; + unsigned int fpsr; + + result = 0; + fpsr = __builtin_aarch64_get_fpsr() & FE_ALL_EXCEPT; + + if (fpsr & FE_INVALID) + result |= GFC_FPE_INVALID; + if (fpsr & FE_DIVBYZERO) + result |= GFC_FPE_ZERO; + if (fpsr & FE_OVERFLOW) + result |= GFC_FPE_OVERFLOW; + if (fpsr & FE_UNDERFLOW) + result |= GFC_FPE_UNDERFLOW; + if (fpsr & FE_INEXACT) + result |= GFC_FPE_INEXACT; + + return result; +} + + +void +set_fpu_except_flags (int set, int clear) +{ + unsigned int exc_set = 0, exc_clr = 0; + unsigned int fpsr, fpsr_new; + + if (set & GFC_FPE_INVALID) + exc_set |= FE_INVALID; + else if (clear & GFC_FPE_INVALID) + exc_clr |= FE_INVALID; + + if (set & GFC_FPE_ZERO) + exc_set |= FE_DIVBYZERO; + else if (clear & GFC_FPE_ZERO) + exc_clr |= FE_DIVBYZERO; + + if (set & GFC_FPE_OVERFLOW) + exc_set |= FE_OVERFLOW; + else if (clear & GFC_FPE_OVERFLOW) + exc_clr |= FE_OVERFLOW; + + if (set & GFC_FPE_UNDERFLOW) + exc_set |= FE_UNDERFLOW; + else if (clear & GFC_FPE_UNDERFLOW) + exc_clr |= FE_UNDERFLOW; + + if (set & GFC_FPE_INEXACT) + exc_set |= FE_INEXACT; + else if (clear & GFC_FPE_INEXACT) + exc_clr |= FE_INEXACT; + + fpsr_new = fpsr = __builtin_aarch64_get_fpsr(); + fpsr_new &= ~exc_clr; + fpsr_new |= exc_set; + + if (fpsr_new != fpsr) + __builtin_aarch64_set_fpsr(fpsr_new); +} + + +void +get_fpu_state (void *state) +{ + struct fenv *envp = state; + envp->__fpcr = __builtin_aarch64_get_fpcr(); + envp->__fpsr = __builtin_aarch64_get_fpsr(); +} + + +void +set_fpu_state (void *state) +{ + struct fenv *envp = state; + __builtin_aarch64_set_fpcr(envp->__fpcr); + __builtin_aarch64_set_fpsr(envp->__fpsr); +} + + +int +get_fpu_rounding_mode (void) +{ + unsigned int fpcr = __builtin_aarch64_get_fpcr(); + fpcr &= FPCR_RM_MASK; + + switch (fpcr) + { + case FE_TONEAREST: + return GFC_FPE_TONEAREST; + case FE_UPWARD: + return GFC_FPE_UPWARD; + case FE_DOWNWARD: + return GFC_FPE_DOWNWARD; + case FE_TOWARDZERO: + return GFC_FPE_TOWARDZERO; + default: + return 0; /* Should be unreachable. */ + } +} + + +void +set_fpu_rounding_mode (int round) +{ + unsigned int fpcr, round_mode; + + switch (round) + { + case GFC_FPE_TONEAREST: + round_mode = FE_TONEAREST; + break; + case GFC_FPE_UPWARD: + round_mode = FE_UPWARD; + break; + case GFC_FPE_DOWNWARD: + round_mode = FE_DOWNWARD; + break; + case GFC_FPE_TOWARDZERO: + round_mode = FE_TOWARDZERO; + break; + default: + return; /* Should be unreachable. */ + } + + fpcr = __builtin_aarch64_get_fpcr(); + + /* Only set FPCR if requested mode is different from current. */ + round_mode = (fpcr ^ round_mode) & FPCR_RM_MASK; + if (round_mode != 0) + __builtin_aarch64_set_fpcr(fpcr ^ round_mode); +} + + +int +support_fpu_rounding_mode (int mode __attribute__((unused))) +{ + return 1; +} + + +int +support_fpu_underflow_control (int kind __attribute__((unused))) +{ + /* Not supported for binary128. */ + return (kind == 4 || kind == 8) ? 1 : 0; +} + + +int +get_fpu_underflow_mode (void) +{ + unsigned int fpcr = __builtin_aarch64_get_fpcr(); + + /* Return 0 for abrupt underflow (flush to zero), 1 for gradual underflow. */ + return (fpcr & FE_MAP_FZ) ? 0 : 1; +} + + +void +set_fpu_underflow_mode (int gradual __attribute__((unused))) +{ + unsigned int fpcr = __builtin_aarch64_get_fpcr(); + + if (gradual) + fpcr &= ~FE_MAP_FZ; + else + fpcr |= FE_MAP_FZ; + + __builtin_aarch64_set_fpcr(fpcr); +} diff --git a/libgfortran/configure.host b/libgfortran/configure.host index e9d92c9..3d6c2db 100644 --- a/libgfortran/configure.host +++ b/libgfortran/configure.host @@ -39,17 +39,29 @@ if test "x${have_feenableexcept}" = "xyes"; then ieee_support='yes' fi -# x86 asm should be used instead of glibc, since glibc doesn't support -# the x86 denormal exception. case "${host_cpu}" in + + # x86 asm should be used instead of glibc, since glibc doesn't support + # the x86 denormal exception. i?86 | x86_64) if test "x${have_soft_float}" = "xyes"; then fpu_host='fpu-generic' + ieee_support='no' else fpu_host='fpu-387' + ieee_support='yes' fi - ieee_support='yes' ;; + + # use asm on aarch64-darwin + aarch64) + case "${host_os}" in + darwin*) + fpu_host='fpu-aarch64' + ieee_support='yes' + ;; + esac + esac # Some targets require additional compiler options for NaN/Inf. diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c index 56f8dbd..927e378 100644 --- a/libgfortran/io/format.c +++ b/libgfortran/io/format.c @@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "io.h" #include "format.h" -#include <ctype.h> #include <string.h> @@ -193,7 +192,7 @@ next_char (format_data *fmt, int literal) return -1; fmt->format_string_len--; - c = toupper (*fmt->format_string++); + c = safe_toupper (*fmt->format_string++); fmt->error_element = c; } while ((c == ' ' || c == '\t') && !literal); @@ -328,7 +327,7 @@ format_lex (format_data *fmt) case '+': c = next_char (fmt, 0); - if (!isdigit (c)) + if (!safe_isdigit (c)) { token = FMT_UNKNOWN; break; @@ -339,7 +338,7 @@ format_lex (format_data *fmt) for (;;) { c = next_char (fmt, 0); - if (!isdigit (c)) + if (!safe_isdigit (c)) break; fmt->value = 10 * fmt->value + c - '0'; @@ -367,7 +366,7 @@ format_lex (format_data *fmt) for (;;) { c = next_char (fmt, 0); - if (!isdigit (c)) + if (!safe_isdigit (c)) break; fmt->value = 10 * fmt->value + c - '0'; diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index 8cc7ddb..f902ee4 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "fbuf.h" #include "unix.h" #include <string.h> -#include <ctype.h> typedef unsigned char uchar; @@ -811,7 +810,7 @@ read_logical (st_parameter_dt *dtp, int length) if (parse_repeat (dtp)) return; - c = tolower (next_char (dtp)); + c = safe_tolower (next_char (dtp)); l_push_char (dtp, c); switch (c) { @@ -837,7 +836,7 @@ read_logical (st_parameter_dt *dtp, int length) break; case '.': - c = tolower (next_char (dtp)); + c = safe_tolower (next_char (dtp)); switch (c) { case 't': @@ -1052,7 +1051,7 @@ read_integer (st_parameter_dt *dtp, int length) } get_integer: - if (!isdigit (c)) + if (!safe_isdigit (c)) goto bad_integer; push_char (dtp, c); @@ -1303,7 +1302,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) if (c == ',' && dtp->u.p.current_unit->decimal_status == DECIMAL_COMMA) c = '.'; - if (!isdigit (c) && c != '.') + if (!safe_isdigit (c) && c != '.') { if (c == 'i' || c == 'I' || c == 'n' || c == 'N') goto inf_nan; @@ -1377,7 +1376,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) } exp2: - if (!isdigit (c)) + if (!safe_isdigit (c)) { /* Extension: allow default exponent of 0 when omitted. */ if (dtp->common.flags & IOPARM_DT_DEC_EXT) @@ -1748,7 +1747,7 @@ read_real (st_parameter_dt *dtp, void *dest, int length) if (c == ',' && dtp->u.p.current_unit->decimal_status == DECIMAL_COMMA) c = '.'; - if (!isdigit (c) && c != '.') + if (!safe_isdigit (c) && c != '.') { if (c == 'i' || c == 'I' || c == 'n' || c == 'N') goto inf_nan; @@ -1828,7 +1827,7 @@ read_real (st_parameter_dt *dtp, void *dest, int length) } exp2: - if (!isdigit (c)) + if (!safe_isdigit (c)) { /* Extension: allow default exponent of 0 when omitted. */ if (dtp->common.flags & IOPARM_DT_DEC_EXT) @@ -2757,7 +2756,7 @@ nml_match_name (st_parameter_dt *dtp, const char *name, index_type len) for (i = 0; i < len; i++) { c = next_char (dtp); - if (c == EOF || (tolower (c) != tolower (name[i]))) + if (c == EOF || (safe_tolower (c) != safe_tolower (name[i]))) { dtp->u.p.nml_read_error = 1; break; @@ -3286,7 +3285,7 @@ get_name: do { if (!is_separator (c)) - push_char_default (dtp, tolower(c)); + push_char_default (dtp, safe_tolower(c)); if ((c = next_char (dtp)) == EOF) goto nml_err_ret; } diff --git a/libgfortran/io/read.c b/libgfortran/io/read.c index 7515d91..7b3f137 100644 --- a/libgfortran/io/read.c +++ b/libgfortran/io/read.c @@ -28,7 +28,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "format.h" #include "unix.h" #include <string.h> -#include <ctype.h> #include <assert.h> #include "async.h" @@ -959,7 +958,7 @@ read_f (st_parameter_dt *dtp, const fnode *f, char *dest, int length) between "NaN" and the optional perenthesis is not permitted. */ while (w > 0) { - *out = tolower (*p); + *out = safe_tolower (*p); switch (*p) { case ' ': @@ -981,7 +980,7 @@ read_f (st_parameter_dt *dtp, const fnode *f, char *dest, int length) goto bad_float; break; default: - if (!isalnum (*out)) + if (!safe_isalnum (*out)) goto bad_float; } --w; @@ -1109,7 +1108,7 @@ exponent: if (dtp->u.p.blank_status == BLANK_UNSPECIFIED) { - while (w > 0 && isdigit (*p)) + while (w > 0 && safe_isdigit (*p)) { exponent *= 10; exponent += *p - '0'; @@ -1137,7 +1136,7 @@ exponent: else assert (dtp->u.p.blank_status == BLANK_NULL); } - else if (!isdigit (*p)) + else if (!safe_isdigit (*p)) goto bad_float; else { diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index 278cd47..b9e9284 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -30,7 +30,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "unix.h" #include <assert.h> #include <string.h> -#include <ctype.h> #define star_fill(p, n) memset(p, '*', n) @@ -2101,14 +2100,14 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info *obj, index_type offset, base_name_len = strlen (base_name); for (dim_i = 0; dim_i < base_name_len; dim_i++) { - cup = toupper ((int) base_name[dim_i]); + cup = safe_toupper (base_name[dim_i]); write_character (dtp, &cup, 1, 1, NODELIM); } } clen = strlen (obj->var_name); for (dim_i = len; dim_i < clen; dim_i++) { - cup = toupper ((int) obj->var_name[dim_i]); + cup = safe_toupper (obj->var_name[dim_i]); if (cup == '+') cup = '%'; write_character (dtp, &cup, 1, 1, NODELIM); @@ -2426,7 +2425,7 @@ namelist_write (st_parameter_dt *dtp) /* Write namelist name in upper case - f95 std. */ for (gfc_charlen_type i = 0; i < dtp->namelist_name_len; i++ ) { - c = toupper ((int) dtp->namelist_name[i]); + c = safe_toupper (dtp->namelist_name[i]); write_character (dtp, &c, 1 ,1, NODELIM); } diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h index 285c36a..93e3591 100644 --- a/libgfortran/libgfortran.h +++ b/libgfortran/libgfortran.h @@ -39,6 +39,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* config.h MUST be first because it can affect system headers. */ #include "config.h" +#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <stddef.h> @@ -103,6 +104,20 @@ typedef off_t gfc_offset; #endif +/* These functions from <ctype.h> should only be used on values that can be + represented as unsigned char, otherwise the behavior is undefined. + Some targets have a char type that is signed, so we cast the argument + to unsigned char. See: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177 + https://wiki.sei.cmu.edu/confluence/x/BNcxBQ + */ + +#define safe_isalnum(x) isalnum((unsigned char) (x)) +#define safe_isdigit(x) isdigit((unsigned char) (x)) +#define safe_tolower(x) tolower((unsigned char) (x)) +#define safe_toupper(x) toupper((unsigned char) (x)) + + /* The following macros can be used to annotate conditions which are likely or unlikely to be true. Avoid using them when a condition is only slightly more likely/less unlikely than average to avoid the performance penalties of diff --git a/libgfortran/runtime/environ.c b/libgfortran/runtime/environ.c index fe16c08..ce408cf 100644 --- a/libgfortran/runtime/environ.c +++ b/libgfortran/runtime/environ.c @@ -26,7 +26,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include <string.h> #include <strings.h> -#include <ctype.h> #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -91,7 +90,7 @@ init_integer (variable * v) return; for (q = p; *q; q++) - if (!isdigit (*q) && (p != q || *q != '-')) + if (!safe_isdigit (*q) && (p != q || *q != '-')) return; *v->var = atoi (p); @@ -344,7 +343,7 @@ static int match_integer (void) { unit_num = 0; - while (isdigit (*p)) + while (safe_isdigit (*p)) unit_num = unit_num * 10 + (*p++ - '0'); return INTEGER; } |