[PATCH] Libquadmath: add nansq() function
Hi, This patch adds nansq() to libquadmath, a function that returns a signalling NaN. It is a need for full libgfortran support of signalling NaNs, because not all targets that have _Float128 define a __builtin_nanq() function. Bootstrapped and tested on x86_64-pc-gnu-linux and aarch64-apple-darwin21 (port under development). OK to commit? FX 0001-Libquadmath-Add-nansq-function.patch Description: Binary data
[PATCH, committed] PR 89639, fix testcase for targets without REAL128
Attached patch pushed as cb48166e52c0f159eb80a0666c4847825e294ec0 Confirmed by Dave to make the testcase pass on hppa-unknown-linux-gnu FX 0001-Fortran-Fix-test-on-targets-without-REAL128.patch Description: Binary data
Re: [gofrontend-dev] Re: Go patch committed: Don't pad epollevent on sparc64 GNU/Linux
On Fri, Dec 31, 2021 at 1:32 AM Jakub Jelinek wrote: > > The following patch adjusts the testcase for the above change. > Tested on x86_64-linux, ok for trunk? > > 2021-12-31 Jakub Jelinek > > * gcc.misc-tests/godump-1.c: Adjust for renaming of last > field from _align suffix to _ suffix. > This is OK. Thanks, and sorry for the trouble. Ian
Re: [power-ieee128] gfortran, v2: Introduce gfc_type_abi_kind
Hi Jakub, Actually playing with that (e.g. for matmul) revealed a brown paper bag bug in the previous patch, fixed thusly: OK. Thanks a lot! Best regards Thomas
Re: [power-ieee128] libgfortran: Small progress on the library side
Hi Jakub, Ok for power-ieee128 branch? OK. Thanks for stepping up! I am a little distracted right now, but I think I will also continue working on this for a bit. Best regards Thomas
[power-ieee128] gfortran, v2: Introduce gfc_type_abi_kind
On Fri, Dec 31, 2021 at 03:16:47PM +0100, Jakub Jelinek via Gcc-patches wrote: > Haven't played enough with it to see if the various *_r17 or *_c17 > API entrypoints are called (but verified abi_kind is right in the > debugger), in all my attempts so far everything was emitted inline. Actually playing with that (e.g. for matmul) revealed a brown paper bag bug in the previous patch, fixed thusly: 2021-12-31 Jakub Jelinek * gfortran.h (gfc_real_info): Add abi_kind member. (gfc_type_abi_kind): Declare. * trans-types.c (gfc_init_kinds): Initialize abi_kind. * intrinsic.c (gfc_type_abi_kind): New function. (conv_name): Use it. * iresolve.c (resolve_transformational, gfc_resolve_abs, gfc_resolve_char_achar, gfc_resolve_acos, gfc_resolve_acosh, gfc_resolve_aimag, gfc_resolve_and, gfc_resolve_aint, gfc_resolve_all, gfc_resolve_anint, gfc_resolve_any, gfc_resolve_asin, gfc_resolve_asinh, gfc_resolve_atan, gfc_resolve_atanh, gfc_resolve_atan2, gfc_resolve_bessel_n2, gfc_resolve_ceiling, gfc_resolve_cmplx, gfc_resolve_complex, gfc_resolve_cos, gfc_resolve_cosh, gfc_resolve_count, gfc_resolve_dble, gfc_resolve_dim, gfc_resolve_dot_product, gfc_resolve_dprod, gfc_resolve_exp, gfc_resolve_floor, gfc_resolve_hypot, gfc_resolve_int, gfc_resolve_int2, gfc_resolve_int8, gfc_resolve_long, gfc_resolve_log, gfc_resolve_log10, gfc_resolve_logical, gfc_resolve_matmul, gfc_resolve_minmax, gfc_resolve_maxloc, gfc_resolve_findloc, gfc_resolve_maxval, gfc_resolve_merge, gfc_resolve_minloc, gfc_resolve_minval, gfc_resolve_mod, gfc_resolve_modulo, gfc_resolve_nearest, gfc_resolve_or, gfc_resolve_real, gfc_resolve_realpart, gfc_resolve_reshape, gfc_resolve_sign, gfc_resolve_sin, gfc_resolve_sinh, gfc_resolve_sqrt, gfc_resolve_tan, gfc_resolve_tanh, gfc_resolve_transpose, gfc_resolve_trigd, gfc_resolve_xor, gfc_resolve_random_number): Likewise. * trans-decl.c (gfc_build_intrinsic_function_decls): Likewise. --- gcc/fortran/gfortran.h +++ gcc/fortran/gfortran.h @@ -2643,7 +2643,7 @@ extern gfc_logical_info gfc_logical_kinds[]; typedef struct { mpfr_t epsilon, huge, tiny, subnormal; - int kind, radix, digits, min_exponent, max_exponent; + int kind, abi_kind, radix, digits, min_exponent, max_exponent; int range, precision; /* The precision of the type as reported by GET_MODE_PRECISION. */ @@ -3499,6 +3499,12 @@ void gfc_intrinsic_init_1 (void); void gfc_intrinsic_done_1 (void); char gfc_type_letter (bt, bool logical_equals_int = false); +int gfc_type_abi_kind (bt, int); +static inline int +gfc_type_abi_kind (gfc_typespec *ts) +{ + return gfc_type_abi_kind (ts->type, ts->kind); +} gfc_symbol * gfc_get_intrinsic_sub_symbol (const char *); gfc_symbol *gfc_get_intrinsic_function_symbol (gfc_expr *); gfc_symbol *gfc_find_intrinsic_symbol (gfc_expr *); --- gcc/fortran/trans-types.c +++ gcc/fortran/trans-types.c @@ -363,6 +363,8 @@ gfc_init_kinds (void) int i_index, r_index, kind; bool saw_i4 = false, saw_i8 = false; bool saw_r4 = false, saw_r8 = false, saw_r10 = false, saw_r16 = false; + scalar_mode r16_mode = QImode; + scalar_mode composite_mode = QImode; i_index = 0; FOR_EACH_MODE_IN_CLASS (int_mode_iter, MODE_INT) @@ -428,6 +430,10 @@ gfc_init_kinds (void) if (!targetm.scalar_mode_supported_p (mode)) continue; + if (MODE_COMPOSITE_P (mode) + && (GET_MODE_PRECISION (mode) + 7) / 8 == 16) + composite_mode = mode; + /* Only let float, double, long double and TFmode go through. Runtime support for others is not provided, so they would be useless. */ @@ -471,7 +477,10 @@ gfc_init_kinds (void) if (kind == 10) saw_r10 = true; if (kind == 16) - saw_r16 = true; + { + saw_r16 = true; + r16_mode = mode; + } /* Careful we don't stumble a weird internal mode. */ gcc_assert (r_index <= 0 || gfc_real_kinds[r_index-1].kind != kind); @@ -479,6 +488,7 @@ gfc_init_kinds (void) gcc_assert (r_index != MAX_REAL_KINDS); gfc_real_kinds[r_index].kind = kind; + gfc_real_kinds[r_index].abi_kind = kind; gfc_real_kinds[r_index].radix = fmt->b; gfc_real_kinds[r_index].digits = fmt->p; gfc_real_kinds[r_index].min_exponent = fmt->emin; @@ -496,6 +506,19 @@ gfc_init_kinds (void) r_index += 1; } + /* Detect the powerpc64le-linux case with -mabi=ieeelongdouble, where + the long double type is non-MODE_COMPOSITE_P TFmode but one can use + -mabi=ibmlongdouble too and get MODE_COMPOSITE_P TFmode with the same + precision. For libgfortran calls pretend the IEEE 754 quad TFmode has + kind 17 rather than 16 and use kind 16 for the IBM extended format + TFmode. */ + if (composite_mode != QImode && saw_r16 && !MOD
[power-ieee128] gfortran: Introduce gfc_type_abi_kind
Hi! The following patch detects the powerpc64le-linux kind == 16 cases and for the -mabi=ieeelongdouble case (no matter whether it is the configured in default or just option used on the command line) uses _r17 or _c17 instead of _r16 or _c17 in the library API names. >From what I can see, e.g. calls to sin on real(kind = 16) works fine with or without this patch (we call __builtin_sinl and the backend uses rs6000_mangle_decl_assembler_name which ensures __sinieee128 is called). Haven't played enough with it to see if the various *_r17 or *_c17 API entrypoints are called (but verified abi_kind is right in the debugger), in all my attempts so far everything was emitted inline. What is clearly still broken is IO, where for real(kind=16) a a = 1.0 print *, a end we call _gfortran_transfer_real_write (&dt_parm.0, &a, 16); for both -mabi=ibmlongdouble and -mabi=ieeelongdouble I don't remember what was the agreement, do we want _gfortran_transfer_real_write (&dt_parm.0, &a, 17); for the ieeelongdouble case, or some new entrypoint for the abi_kind == 17 real/complex IO? Also, what about kind stored in array descriptors? Shall we use there the abi_kind or kind? I guess at least before the IO case is solved there is no point in checking the testsuite, too many things will be majorly broken... 2021-12-31 Jakub Jelinek * gfortran.h (gfc_real_info): Add abi_kind member. (gfc_type_abi_kind): Declare. * trans-types.c (gfc_init_kinds): Initialize abi_kind. * intrinsic.c (gfc_type_abi_kind): New function. (conv_name): Use it. * iresolve.c (resolve_transformational, gfc_resolve_abs, gfc_resolve_char_achar, gfc_resolve_acos, gfc_resolve_acosh, gfc_resolve_aimag, gfc_resolve_and, gfc_resolve_aint, gfc_resolve_all, gfc_resolve_anint, gfc_resolve_any, gfc_resolve_asin, gfc_resolve_asinh, gfc_resolve_atan, gfc_resolve_atanh, gfc_resolve_atan2, gfc_resolve_bessel_n2, gfc_resolve_ceiling, gfc_resolve_cmplx, gfc_resolve_complex, gfc_resolve_cos, gfc_resolve_cosh, gfc_resolve_count, gfc_resolve_dble, gfc_resolve_dim, gfc_resolve_dot_product, gfc_resolve_dprod, gfc_resolve_exp, gfc_resolve_floor, gfc_resolve_hypot, gfc_resolve_int, gfc_resolve_int2, gfc_resolve_int8, gfc_resolve_long, gfc_resolve_log, gfc_resolve_log10, gfc_resolve_logical, gfc_resolve_matmul, gfc_resolve_minmax, gfc_resolve_maxloc, gfc_resolve_findloc, gfc_resolve_maxval, gfc_resolve_merge, gfc_resolve_minloc, gfc_resolve_minval, gfc_resolve_mod, gfc_resolve_modulo, gfc_resolve_nearest, gfc_resolve_or, gfc_resolve_real, gfc_resolve_realpart, gfc_resolve_reshape, gfc_resolve_sign, gfc_resolve_sin, gfc_resolve_sinh, gfc_resolve_sqrt, gfc_resolve_tan, gfc_resolve_tanh, gfc_resolve_transpose, gfc_resolve_trigd, gfc_resolve_xor, gfc_resolve_random_number): Likewise. * trans-decl.c (gfc_build_intrinsic_function_decls): Use gfc_real_kinds[rkinds[rkind]].abi_kind instead of rkinds[rkind]. --- gcc/fortran/gfortran.h +++ gcc/fortran/gfortran.h @@ -2643,7 +2643,7 @@ extern gfc_logical_info gfc_logical_kinds[]; typedef struct { mpfr_t epsilon, huge, tiny, subnormal; - int kind, radix, digits, min_exponent, max_exponent; + int kind, abi_kind, radix, digits, min_exponent, max_exponent; int range, precision; /* The precision of the type as reported by GET_MODE_PRECISION. */ @@ -3499,6 +3499,7 @@ void gfc_intrinsic_init_1 (void); void gfc_intrinsic_done_1 (void); char gfc_type_letter (bt, bool logical_equals_int = false); +int gfc_type_abi_kind (gfc_typespec *); gfc_symbol * gfc_get_intrinsic_sub_symbol (const char *); gfc_symbol *gfc_get_intrinsic_function_symbol (gfc_expr *); gfc_symbol *gfc_find_intrinsic_symbol (gfc_expr *); --- gcc/fortran/trans-types.c +++ gcc/fortran/trans-types.c @@ -363,6 +363,8 @@ gfc_init_kinds (void) int i_index, r_index, kind; bool saw_i4 = false, saw_i8 = false; bool saw_r4 = false, saw_r8 = false, saw_r10 = false, saw_r16 = false; + scalar_mode r16_mode = QImode; + scalar_mode composite_mode = QImode; i_index = 0; FOR_EACH_MODE_IN_CLASS (int_mode_iter, MODE_INT) @@ -428,6 +430,10 @@ gfc_init_kinds (void) if (!targetm.scalar_mode_supported_p (mode)) continue; + if (MODE_COMPOSITE_P (mode) + && (GET_MODE_PRECISION (mode) + 7) / 8 == 16) + composite_mode = mode; + /* Only let float, double, long double and TFmode go through. Runtime support for others is not provided, so they would be useless. */ @@ -471,7 +477,10 @@ gfc_init_kinds (void) if (kind == 10) saw_r10 = true; if (kind == 16) - saw_r16 = true; + { + saw_r16 = true; + r16_mode = mode; + } /* Careful we don't stumble a weird internal mode. */ gcc_assert (r_index <= 0 || gfc_real_
[power-ieee128] libgfortran: Small progress on the library side
Hi! The following patch quiets ../../../libgfortran/generated/in_pack_r17.c:35:1: warning: no previous prototype for ‘internal_pack_r17’ [-Wmissing-prototypes] ../../../libgfortran/generated/in_pack_c17.c:35:1: warning: no previous prototype for ‘internal_pack_c17’ [-Wmissing-prototypes] ../../../libgfortran/generated/in_unpack_r17.c:33:1: warning: no previous prototype for ‘internal_unpack_r17’ [-Wmissing-prototypes] ../../../libgfortran/generated/in_unpack_c17.c:33:1: warning: no previous prototype for ‘internal_unpack_c17’ [-Wmissing-prototypes] ../../../libgfortran/generated/pack_r17.c:73:1: warning: no previous prototype for ‘pack_r17’ [-Wmissing-prototypes] ../../../libgfortran/generated/pack_c17.c:73:1: warning: no previous prototype for ‘pack_c17’ [-Wmissing-prototypes] ../../../libgfortran/generated/unpack_r17.c:34:1: warning: no previous prototype for ‘unpack0_r17’ [-Wmissing-prototypes] ../../../libgfortran/generated/unpack_r17.c:178:1: warning: no previous prototype for ‘unpack1_r17’ [-Wmissing-prototypes] ../../../libgfortran/generated/unpack_c17.c:34:1: warning: no previous prototype for ‘unpack0_c17’ [-Wmissing-prototypes] ../../../libgfortran/generated/unpack_c17.c:178:1: warning: no previous prototype for ‘unpack1_c17’ [-Wmissing-prototypes] ../../../libgfortran/generated/spread_r17.c:34:1: warning: no previous prototype for ‘spread_r17’ [-Wmissing-prototypes] ../../../libgfortran/generated/spread_r17.c:230:1: warning: no previous prototype for ‘spread_scalar_r17’ [-Wmissing-prototypes] ../../../libgfortran/generated/spread_c17.c:34:1: warning: no previous prototype for ‘spread_c17’ [-Wmissing-prototypes] ../../../libgfortran/generated/spread_c17.c:230:1: warning: no previous prototype for ‘spread_scalar_c17’ [-Wmissing-prototypes] ../../../libgfortran/generated/cshift0_r17.c:33:1: warning: no previous prototype for ‘cshift0_r17’ [-Wmissing-prototypes] ../../../libgfortran/generated/cshift0_c17.c:33:1: warning: no previous prototype for ‘cshift0_c17’ [-Wmissing-prototypes] ../../../libgfortran/generated/cshift1_4_r17.c:32:1: warning: no previous prototype for ‘cshift1_4_r17’ [-Wmissing-prototypes] ../../../libgfortran/generated/cshift1_4_c17.c:32:1: warning: no previous prototype for ‘cshift1_4_c17’ [-Wmissing-prototypes] ../../../libgfortran/generated/cshift1_8_r17.c:32:1: warning: no previous prototype for ‘cshift1_8_r17’ [-Wmissing-prototypes] ../../../libgfortran/generated/cshift1_8_c17.c:32:1: warning: no previous prototype for ‘cshift1_8_c17’ [-Wmissing-prototypes] ../../../libgfortran/generated/cshift1_16_r17.c:32:1: warning: no previous prototype for ‘cshift1_16_r17’ [-Wmissing-prototypes] ../../../libgfortran/generated/cshift1_16_c17.c:32:1: warning: no previous prototype for ‘cshift1_16_c17’ [-Wmissing-prototypes] warnings during libgfortran build and exports the new entrypoints. Note, not all of them, clearly e.g. there are fewer *_r17* entrypoints than *_r16* entrypoints, so more work is needed. Ok for power-ieee128 branch? 2021-12-31 Jakub Jelinek * libgfortran.h (internal_pack_r17, internal_pack_c17, internal_unpack_r17, internal_unpack_c17, pack_r17, pack_c17, unpack0_r17, unpack0_c17, unpack1_r17, unpack1_c17, spread_r17, spread_c17, spread_scalar_r17, spread_scalar_c17, cshift0_r17, cshift0_c17, cshift1_4_r17, cshift1_8_r17, cshift1_16_r17, cshift1_4_c17, cshift1_8_c17, cshift1_16_c17): Declare. * gfortran.map (GFORTRAN_12): Export *_r17 and *_c17. --- libgfortran/libgfortran.h +++ libgfortran/libgfortran.h @@ -968,6 +968,11 @@ GFC_REAL_16 *internal_pack_r16 (gfc_array_r16 *); internal_proto(internal_pack_r16); #endif +#if defined HAVE_GFC_REAL_17 +GFC_REAL_17 *internal_pack_r17 (gfc_array_r17 *); +internal_proto(internal_pack_r17); +#endif + GFC_COMPLEX_4 *internal_pack_c4 (gfc_array_c4 *); internal_proto(internal_pack_c4); @@ -984,6 +989,11 @@ GFC_COMPLEX_16 *internal_pack_c16 (gfc_array_c16 *); internal_proto(internal_pack_c16); #endif +#if defined HAVE_GFC_COMPLEX_17 +GFC_COMPLEX_17 *internal_pack_c17 (gfc_array_c17 *); +internal_proto(internal_pack_c17); +#endif + extern void internal_unpack_1 (gfc_array_i1 *, const GFC_INTEGER_1 *); internal_proto(internal_unpack_1); @@ -1017,6 +1027,11 @@ extern void internal_unpack_r16 (gfc_array_r16 *, const GFC_REAL_16 *); internal_proto(internal_unpack_r16); #endif +#if defined HAVE_GFC_REAL_17 +extern void internal_unpack_r17 (gfc_array_r17 *, const GFC_REAL_17 *); +internal_proto(internal_unpack_r17); +#endif + extern void internal_unpack_c4 (gfc_array_c4 *, const GFC_COMPLEX_4 *); internal_proto(internal_unpack_c4); @@ -1033,6 +1048,11 @@ extern void internal_unpack_c16 (gfc_array_c16 *, const GFC_COMPLEX_16 *); internal_proto(internal_unpack_c16); #endif +#if defined HAVE_GFC_COMPLEX_17 +extern void internal_unpack_c17 (gfc_array_c17 *, const GFC_COMPLEX_17 *); +internal_proto(internal_unpack_c17); +#endif + /
[pushed] libgfortran: Fix bootstrap on targets without static_assert macro.
Although we build the library with GCC which is known to support _Static_assert this might be done on a system without the macro mapping static_assert to the compiler keyword. The use of static_assert introduced with r12-6126-g3430132f3e82 causes bootstrap to fail on such targets, fixed by using the keyword directly. tested on i686-darwin9 and x86_64-darwin18, without regressions, pushed to master as an obvious bootstrap fix (and as approved by FX). thanks Iain Signed-off-by: Iain Sandoe libgfortran/ChangeLog: * runtime/string.c (gfc_itoa): Use _Static_assert directly instead of via the static_assert macro. --- libgfortran/runtime/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgfortran/runtime/string.c b/libgfortran/runtime/string.c index 21585f48dc9..5bc202320c0 100644 --- a/libgfortran/runtime/string.c +++ b/libgfortran/runtime/string.c @@ -242,8 +242,8 @@ gfc_itoa (GFC_UINTEGER_LARGEST n, char *buffer, size_t len) integers (we would need three calls), but they do suffice for all values up to 2^127, which is the largest that Fortran can produce (-HUGE(0_16)-1) with its signed integer types. */ - static_assert(sizeof(GFC_UINTEGER_LARGEST) <= 2 * sizeof(uint64_t), - "integer too large"); + _Static_assert (sizeof(GFC_UINTEGER_LARGEST) <= 2 * sizeof(uint64_t), + "integer too large"); GFC_UINTEGER_LARGEST r; r = n % TEN19; -- 2.24.3 (Apple Git-128)
[PATCH] testsuite: XFAIL some Wstringop-overflow tests ...
... for targets that support vectorization of 2-byte char stores with unaligned address at plain O2. 2021-12-31 Uroš Bizjak gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_vect_slp_store_usage): Handle TEST_V2QI_2. (check_effective_target_vect_slp_v2qi_store_unalign): New procedure. * c-c++-common/Wstringop-overflow-2.c: XFAIL specific tests for vect_slp_v2qi_store_unalign targets. * g++.dg/warn/Wstringop-overflow-3.C: Ditto. * gcc.dg/Wstringop-overflow-28.c: Ditto. * gcc.dg/Wstringop-overflow-68.c: Ditto. * gcc.dg/Wstringop-overflow-75.c: Ditto. * gcc.dg/Wstringop-overflow-76.c: Ditto. Patch was regression tested with and without V2QI vectorization enabled. Pushed to master. Uros. diff --git a/gcc/testsuite/c-c++-common/Wstringop-overflow-2.c b/gcc/testsuite/c-c++-common/Wstringop-overflow-2.c index e5802613a9c..3f9171947c2 100644 --- a/gcc/testsuite/c-c++-common/Wstringop-overflow-2.c +++ b/gcc/testsuite/c-c++-common/Wstringop-overflow-2.c @@ -19,7 +19,7 @@ struct Ax ax_; void gax_ (void) { ax_.a[0] = 0; // { dg-warning "\\\[-Wstringop-overflow" } - ax_.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" } + ax_.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" "" { xfail { vect_slp_v2qi_store_unalign } } } ax_.a[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" } } @@ -30,7 +30,7 @@ struct Ax ax0 = { 0 }; void gax0 (void) { ax0.a[0] = 0; // { dg-warning "\\\[-Wstringop-overflow" } - ax0.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" } + ax0.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" "" { xfail { vect_slp_v2qi_store_unalign } } } ax0.a[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" } } @@ -41,7 +41,7 @@ struct Ax ax0_ = { 0, { } }; void gax0_ (void) { ax0_.a[0] = 0;// { dg-warning "\\\[-Wstringop-overflow" } - ax0_.a[1] = 1;// { dg-warning "\\\[-Wstringop-overflow" } + ax0_.a[1] = 1;// { dg-warning "\\\[-Wstringop-overflow" "" { xfail { vect_slp_v2qi_store_unalign } } } ax0_.a[2] = 2;// { dg-warning "\\\[-Wstringop-overflow" } } @@ -51,8 +51,8 @@ struct Ax ax1 = { 1, { 0 } }; void gax1 (void) { - ax1.a[0] = 0; - ax1.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" } + ax1.a[0] = 0; // { dg-warning "\\\[-Wstringop-overflow" "" { target { vect_slp_v2qi_store_unalign } } } + ax1.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" "" { xfail { vect_slp_v2qi_store_unalign } } } ax1.a[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" } } @@ -100,7 +100,7 @@ struct A0 a0_; void ga0_ (void) { a0_.a[0] = 0; // { dg-warning "\\\[-Wstringop-overflow" } - a0_.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" } + a0_.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" "" { xfail { vect_slp_v2qi_store_unalign } } } a0_.a[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" } } @@ -111,7 +111,7 @@ struct A0 a00 = { 0 }; void ga00 (void) { a00.a[0] = 0; // { dg-warning "\\\[-Wstringop-overflow" } - a00.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" } + a00.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" "" { xfail { vect_slp_v2qi_store_unalign } } } a00.a[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" } } @@ -122,7 +122,7 @@ struct A0 a00_ = { 0, { } }; void ga00_ (void) { a00_.a[0] = 0;// { dg-warning "\\\[-Wstringop-overflow" } - a00_.a[1] = 1;// { dg-warning "\\\[-Wstringop-overflow" } + a00_.a[1] = 1;// { dg-warning "\\\[-Wstringop-overflow" "" { xfail { vect_slp_v2qi_store_unalign } } } a00_.a[2] = 2;// { dg-warning "\\\[-Wstringop-overflow" } } @@ -166,13 +166,13 @@ struct A1 a1_; void ga1_ (void) { - a1_.a[0] = 0; - a1_.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" } + a1_.a[0] = 0; // { dg-warning "\\\[-Wstringop-overflow" "" { target { vect_slp_v2qi_store_unalign } } } + a1_.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" "" { xfail { vect_slp_v2qi_store_unalign } } } a1_.a[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" } struct A1 a; - a.a[0] = 0; - a.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" } + a.a[0] = 0; // { dg-warning "\\\[-Wstringop-overflow" "" { target { vect_slp_v2qi_store_unalign } } } + a.a[1] = 1; // { dg-warning "\\\[-Wstringop-overflow" "" { xfail { vect_slp_v2qi_store_unalign } } } a.a[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" } sink (&a); } @@ -183,8 +183,8 @@ struct A1
Re: [PATCH] objc: Fix handling of break stmt inside of switch inside of ObjC foreach [PR103639]
Hi Jakub, thanks for looking at this, > On 30 Dec 2021, at 09:33, Jakub Jelinek via Gcc-patches > wrote: > > The r11-3302-g3696a50beeb73f changes broke the following ObjC testcase. > in_statement is either 0 (not in a looping statement), various IN_* flags > for various kinds of looping statements (or OpenMP structured blocks) or > those flags ored with IN_SWITCH_STMT when a switch appears inside of those > contexts. This is because break binds to switch in that last case, but > continue binds to the looping construct in that case. > The c_finish_bc_stmt function performs diagnostics on incorrect > break/continue uses and then checks if in_statement & IN_OBJC_FOREACH > and in that case jumps to the label provided by the caller, otherwise > emits a BREAK_STMT or CONTINUE_STMT. This is incorrect if we have > ObjC foreach with switch nested in it and break inside of that, > in_statement in that case is IN_OBJC_FOREACH | IN_SWITCH_STMT and > is_break is true. We want to handle it like other breaks inside of > switch, i.e. emit a BREAK_STMT. > > The following patch fixes that. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? I regstrapped this on x86_64-darwin9 and i686-darwin9 and checked this for NeXT and GNU runtimes for m32 and m64 (also on powerpc-darwin9, but without a bootstrap). From the Objective-C perspective, LGTM. thanks Iain > > 2021-12-30 Jakub Jelinek > > PR objc/103639 > * c-typeck.c (c_finish_bc_stmt): For break inside of switch inside of > ObjC foreach, emit normal BREAK_STMT rather than goto to label. > > 2021-12-30 Iain Sandoe > > PR objc/103639 > * objc.dg/pr103639.m: New test. > > --- gcc/c/c-typeck.c.jj 2021-12-09 15:37:27.657304583 +0100 > +++ gcc/c/c-typeck.c 2021-12-29 16:27:56.693351501 +0100 > @@ -11257,7 +11257,8 @@ c_finish_bc_stmt (location_t loc, tree l > > if (skip) > return NULL_TREE; > - else if (in_statement & IN_OBJC_FOREACH) > + else if ((in_statement & IN_OBJC_FOREACH) > +&& !(is_break && (in_statement & IN_SWITCH_STMT))) > { > /* The foreach expander produces low-level code using gotos instead >of a structured loop construct. */ > --- gcc/testsuite/objc.dg/pr103639.m.jj 2021-11-07 16:02:58.901842074 > +0100 > +++ gcc/testsuite/objc.dg/pr103639.m 2021-12-29 21:42:08.253107653 +0100 > @@ -0,0 +1,101 @@ > +/* PR objc/103639 */ > +/* { dg-do run } */ > +/* { dg-skip-if "No NeXT fast enum. pre-Darwin9" { *-*-darwin[5-8]* } { > "-fnext-runtime" } { "" } } */ > +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 > } } } { "-fnext-runtime" } { "" } } */ > +/* { dg-additional-sources > "../objc-obj-c++-shared/nsconstantstring-class-impl.m" } */ > +/* { dg-additional-options "-mno-constant-cfstrings" { target *-*-darwin* } > } */ > +/* { dg-additional-options "-Wno-objc-root-class" } */ > + > +#import "../objc-obj-c++-shared/TestsuiteObject.m" > +#ifndef __NEXT_RUNTIME__ > +#include > +#else > +#include "../objc-obj-c++-shared/nsconstantstring-class.h" > +#endif > + > +extern int printf (const char *, ...); > +#include > + > +/* A mini-array implementation that can be used to test fast > +enumeration. You create the array with some objects; you can > +mutate the array, and you can fast-enumerate it. > + */ > +@interface MyArray : TestsuiteObject > +{ > + unsigned int length; > + id *objects; > + unsigned long mutated; > +} > +- (id) initWithLength: (unsigned int)l objects: (id *)o; > +- (void) mutate; > +- (unsigned long)countByEnumeratingWithState: (struct > __objcFastEnumerationState *)state > + objects:(id *)stackbuf > + count:(unsigned long)len; > +@end > + > +@implementation MyArray : TestsuiteObject > +- (id) initWithLength: (unsigned int)l > + objects: (id *)o > +{ > + length = l; > + objects = o; > + mutated = 0; > + return self; > +} > +- (void) mutate > +{ > + mutated = 1; > +} > +- (unsigned long)countByEnumeratingWithState: (struct > __objcFastEnumerationState*)state > + objects: (id*)stackbuf > +count: (unsigned long)len > +{ > + unsigned long i, batch_size; > + > + /* We keep how many objects we served in the state->state counter. So the > next batch > + will contain up to length - state->state objects. */ > + batch_size = length - state->state; > + > + /* Make obvious adjustments. */ > + if (batch_size < 0) > +batch_size = 0; > + > + if (batch_size > len) > +batch_size = len; > + > + /* Copy the objects. */ > + for (i = 0; i < batch_size; i++) > +stackbuf[i] = objects[i]; > + > + state->state += batch_size; > + state->itemsPtr = stackbuf; > + state->mutationsPtr = &mutated; > + > + return batch_size; > +} > +@end > + > +int check = 0; > + > +int > +main() > +{ > + id *objects = malloc (sizeof (id) * 2); >
Re: Go patch committed: Don't pad epollevent on sparc64 GNU/Linux
On Wed, Dec 29, 2021 at 03:54:03PM -0800, Ian Lance Taylor via Gcc-patches wrote: > PR go/103847 > * godump.c (go_force_record_alignment): Name the alignment > field "_". > --- a/gcc/godump.c > +++ b/gcc/godump.c > @@ -651,7 +651,7 @@ go_force_record_alignment (struct obstack *ob, const char > *type_string, > unsigned int index, const char *error_string) > { >index = go_append_artificial_name (ob, index); > - obstack_grow (ob, "_align ", 7); > + obstack_grow (ob, "_ ", 2); >if (type_string == NULL) > obstack_grow (ob, error_string, strlen (error_string)); >else This change caused +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _ts_nested struct { u struct { s int16; Godump_0_pad [2]byte; Godump_1_align [0]u?int32; }; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _ts_nested2 struct { u struct { Godump_0_pad [4]byte; Godump_1_pad [2]byte; s int16; c int8; Godump_2_pad [1]byte; Godump_3_pad [2]byte; Godump_4_align [0]u?int32; }; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tsbf_gaps struct { bf1 uint8; c uint8; bf2 uint8; Godump_0_pad [2]byte; s uint16; Godump_1_align [0]int32; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tsbf_pad16_1 struct { Godump_0_pad [1]byte; c uint8; Godump_1_align [0]int16; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tsbf_pad16_2 struct { Godump_0_pad [2]byte; c uint8; Godump_1_pad [.]byte; Godump_2_align [0]int16; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tsbf_pad32_1 struct { Godump_0_pad [1]byte; c uint8; Godump_1_pad [.]byte; Godump_2_align [0]int32; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tsbf_pad32_2 struct { Godump_0_pad [4]byte; c uint8; Godump_1_pad [.]byte; Godump_2_align [0]int32; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tsbf_pad64_1 struct { Godump_0_pad [1]byte; c uint8; Godump_1_pad [.]byte; Godump_2_align [0]int64; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tsbf_pad64_2 struct { Godump_0_pad [8]byte; c uint8; Godump_1_pad [.]byte; Godump_2_align [0]int64; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tsn_anon struct { a uint8; s uint16; b uint8; Godump_0_pad [.]byte; Godump_1_align [0]int16; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tsu_anon struct { c uint8; Godump_0_pad [7]byte; Godump_1_align [0]u?int64; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tu1 struct { c uint8; Godump_0_pad [.]byte; Godump_1_align [0]u?int64; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tu3_size struct { ca [4+1]uint8; Godump_0_pad [.]byte; Godump_1_align [0]u?int64; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tu_nested struct { u struct { s int16; Godump_0_pad [2]byte; Godump_1_align [0]u?int32; }; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tu_nested2 struct { u struct { Godump_0_pad [4]byte; Godump_1_pad [2]byte; s int16; c int8; Godump_2_pad [1]byte; Godump_3_pad [2]byte; Godump_4_align [0]u?int32; }; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^type _tu_size struct { ca [4+1]uint8; Godump_0_pad [.]byte; Godump_1_align [0]u?int64; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^var _s_nested struct { u struct { s int16; Godump_0_pad [2]byte; Godump_1_align [0]u?int32; }; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^var _s_nested2 struct { u struct { Godump_0_pad [4]byte; Godump_1_pad [2]byte; s int16; c int8; Godump_2_pad [1]byte; Godump_3_pad [2]byte; Godump_4_align [0]u?int32; }; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^var _sbf_gaps struct { bf1 uint8; c uint8; bf2 uint8; Godump_0_pad [2]byte; s uint16; Godump_1_align [0]int32; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^var _sbf_pad16_1 struct { Godump_0_pad [1]byte; c uint8; Godump_1_align [0]int16; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^var _sbf_pad16_2 struct { Godump_0_pad [2]byte; c uint8; Godump_1_pad [.]byte; Godump_2_align [0]int16; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^var _sbf_pad32_1 struct { Godump_0_pad [1]byte; c uint8; Godump_1_pad [.]byte; Godump_2_align [0]int32; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^var _sbf_pad32_2 struct { Godump_0_pad [4]byte; c uint8; Godump_1_pad [.]byte; Godump_2_align [0]int32; }\$ +FAIL: gcc.misc-tests/godump-1.c scan-file (?n)^var _sbf_pad64_1 struct { Godump_0_pad [1]byte; c uint8; Godump_1_pad
[PATCH] c++: Silence -Wuseless-cast warnings during move [PR103480]
Hi! This is maybe just a shot in the dark, but IMHO we shouldn't be diagnosing -Wuseless-cast on casts the compiler adds on its own when calling its move function. We don't seem to warn when user calls std::move either. We call move on elinit (*NON_LVALUE_EXPR <(struct C[2] &&) &D.2497->b>)[0] so it is already an xvalue_p and try to static_cast it to struct C &&. But we don't warn e.g. on std::move (std::move (whatever)). Bootstrapped/regtested on x86_64-linux and i686-linux. 2021-12-31 Jakub Jelinek PR c++/103480 * tree.c (move): Add warn_useless_cast warning sentinel. * g++.dg/warn/Wuseless-cast2.C: New test. --- gcc/cp/tree.c.jj2021-12-30 15:12:42.739157171 +0100 +++ gcc/cp/tree.c 2021-12-30 18:39:08.050679041 +0100 @@ -1288,6 +1288,7 @@ move (tree expr) tree type = TREE_TYPE (expr); gcc_assert (!TYPE_REF_P (type)); type = cp_build_reference_type (type, /*rval*/true); + warning_sentinel w (warn_useless_cast); return build_static_cast (input_location, type, expr, tf_warning_or_error); } --- gcc/testsuite/g++.dg/warn/Wuseless-cast2.C.jj 2021-12-30 18:46:17.437651681 +0100 +++ gcc/testsuite/g++.dg/warn/Wuseless-cast2.C 2021-12-30 18:45:41.044162541 +0100 @@ -0,0 +1,24 @@ +// PR c++/103480 +// { dg-do compile { target c++14 } } +// { dg-options "-Wuseless-cast" } + +template +struct A { typedef T t[N]; }; +template +struct B { typename A::t b; }; +struct C { + constexpr C (C &&) {} + template + static auto bar () + { +B r; +return r; // { dg-bogus "useless cast to type" } + } + C () = default; +}; + +void +foo () +{ + C::bar<2> (); +} Jakub
[PATCH] c++: Fix ICEs with OBJ_TYPE_REF pretty printing [PR101597]
Hi! The following testcase ICEs, because middle-end uses the C++ FE pretty printing code through langhooks in the diagnostics. The FE expects OBJ_TYPE_REF_OBJECT's type to be useful (pointer to the class type it is called on), but in the middle-end conversions between pointer types are useless, so the actual type can be some random unrelated pointer type (in the testcase void * pointer). The pretty printing code then ICEs on it. The following patch fixes that by sticking the original OBJ_TYPE_REF_OBJECT's also as type of OBJ_TYPE_REF_TOKEN operand. That one must be an INTEGER_CST, all the current uses of OBJ_TYPE_REF_TOKEN just use tree_to_uhwi or tree_to_shwi on it, and because it is constant, there is no risk of the middle-end propagating into it some other pointer type. So, approach similar to how MEM_REF treats its second operand or a couple of internal functions (e.g. IFN_VA_ARG) some of its parameters. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2021-12-30 Jakub Jelinek PR c++/101597 gcc/cp/ * class.c (build_vfn_ref): Build OBJ_TYPE_REF with INTEGER_CST OBJ_TYPE_REF_TOKEN with type equal to OBJ_TYPE_REF_OBJECT type. * error.c (resolve_virtual_fun_from_obj_type_ref): Use type of OBJ_TYPE_REF_TOKEN rather than type of OBJ_TYPE_REF_OBJECT as obj_type. gcc/objc/ * objc-act.c (objc_rewrite_function_call): Build OBJ_TYPE_REF with INTEGER_CST OBJ_TYPE_REF_TOKEN with type equal to OBJ_TYPE_REF_OBJECT type. * objc-next-runtime-abi-01.c (build_objc_method_call): Likewise. * objc-gnu-runtime-abi-01.c (build_objc_method_call): Likewise. * objc-next-runtime-abi-02.c (build_v2_objc_method_fixup_call, build_v2_build_objc_method_call): Likewise. gcc/testsuite/ * g++.dg/opt/pr101597.C: New test. --- gcc/cp/class.c.jj 2021-12-30 15:12:42.706157630 +0100 +++ gcc/cp/class.c 2021-12-30 17:16:23.567589120 +0100 @@ -778,7 +778,8 @@ build_vfn_ref (tree instance_ptr, tree i cp_build_addr_expr (aref, tf_warning_or_error)); /* Remember this as a method reference, for later devirtualization. */ - aref = build3 (OBJ_TYPE_REF, TREE_TYPE (aref), aref, instance_ptr, idx); + aref = build3 (OBJ_TYPE_REF, TREE_TYPE (aref), aref, instance_ptr, +fold_convert (TREE_TYPE (instance_ptr), idx)); return aref; } --- gcc/cp/error.c.jj 2021-12-30 15:12:42.714157519 +0100 +++ gcc/cp/error.c 2021-12-30 17:16:23.568589106 +0100 @@ -2149,7 +2149,7 @@ dump_expr_init_vec (cxx_pretty_printer * static tree resolve_virtual_fun_from_obj_type_ref (tree ref) { - tree obj_type = TREE_TYPE (OBJ_TYPE_REF_OBJECT (ref)); + tree obj_type = TREE_TYPE (OBJ_TYPE_REF_TOKEN (ref)); HOST_WIDE_INT index = tree_to_uhwi (OBJ_TYPE_REF_TOKEN (ref)); tree fun = BINFO_VIRTUALS (TYPE_BINFO (TREE_TYPE (obj_type))); while (index) --- gcc/objc/objc-act.c.jj 2021-12-30 15:12:43.159151319 +0100 +++ gcc/objc/objc-act.c 2021-12-30 17:16:23.569589092 +0100 @@ -9644,11 +9644,9 @@ objc_rewrite_function_call (tree functio && TREE_CODE (TREE_OPERAND (function, 0)) == ADDR_EXPR && TREE_CODE (TREE_OPERAND (TREE_OPERAND (function, 0), 0)) == FUNCTION_DECL) -{ - function = build3 (OBJ_TYPE_REF, TREE_TYPE (function), -TREE_OPERAND (function, 0), -first_param, size_zero_node); -} +function = build3 (OBJ_TYPE_REF, TREE_TYPE (function), + TREE_OPERAND (function, 0), first_param, + build_int_cst (TREE_TYPE (first_param), 0)); return function; } --- gcc/objc/objc-next-runtime-abi-01.c.jj 2021-12-30 15:12:43.159151319 +0100 +++ gcc/objc/objc-next-runtime-abi-01.c 2021-12-30 17:16:23.569589092 +0100 @@ -883,7 +883,7 @@ build_objc_method_call (location_t loc, /* Build an obj_type_ref, with the correct cast for the method call. */ t = build3 (OBJ_TYPE_REF, sender_cast, method, - lookup_object, size_zero_node); + lookup_object, build_int_cst (TREE_TYPE (lookup_object), 0)); t = build_function_call_vec (loc, vNULL, t, parms, NULL); vec_free (parms); return t; --- gcc/objc/objc-gnu-runtime-abi-01.c.jj 2021-12-30 14:16:42.837908238 +0100 +++ gcc/objc/objc-gnu-runtime-abi-01.c 2021-12-30 17:16:23.569589092 +0100 @@ -725,7 +725,8 @@ build_objc_method_call (location_t loc, parms->quick_push (TREE_VALUE (method_params)); /* Build an obj_type_ref, with the correct cast for the method call. */ - t = build3 (OBJ_TYPE_REF, sender_cast, method, lookup_object, size_zero_node); + t = build3 (OBJ_TYPE_REF, sender_cast, method, lookup_object, + build_int_cst (TREE_TYPE (lookup_object), 0)); t = build_function_call_vec (loc, vNULL, t, parms, NULL); vec_free (parms); return t; --- gcc/objc/objc-next-runtime-abi-02.c.jj 2021-12-30 15:12:43.159151319 +