From 5b96c823e591980a80481eb3fe72092a6146f742 Mon Sep 17 00:00:00 2001 From: Lulu Cheng Date: Tue, 26 Jul 2022 21:03:52 +0800 Subject: LoongArch: Modify the output message string of the warning. Fix bug for "error: spurious trailing punctuation sequence '.' in format [-Werror=format-diag]". gcc/ChangeLog: * config/loongarch/loongarch-opts.cc: Modify the output message string of the warning. --- gcc/config/loongarch/loongarch-opts.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/config/loongarch/loongarch-opts.cc b/gcc/config/loongarch/loongarch-opts.cc index fc477bf..3f70943 100644 --- a/gcc/config/loongarch/loongarch-opts.cc +++ b/gcc/config/loongarch/loongarch-opts.cc @@ -378,8 +378,8 @@ fallback: t.cmodel = constrained.cmodel ? opt_cmodel : CMODEL_NORMAL; if (t.cmodel != CMODEL_NORMAL) { - warning (0, "%qs is not supported, now cmodel is set to 'normal'.", - loongarch_cmodel_strings[t.cmodel]); + warning (0, "%qs is not supported, now cmodel is set to %qs", + loongarch_cmodel_strings[t.cmodel], "normal"); t.cmodel = CMODEL_NORMAL; } -- cgit v1.1 From 975658b782f36dcf6eb190966d5b705977bfd5eb Mon Sep 17 00:00:00 2001 From: Peter Bergner Date: Fri, 17 Jun 2022 23:43:23 -0500 Subject: c: Handle initializations of opaque types [PR106016] The initial commit that added opaque types thought that there couldn't be any valid initializations for variables of these types, but the test case in the bug report shows that isn't true. The solution is to handle OPAQUE_TYPE initializations like the other scalar types. 2022-06-17 Peter Bergner gcc/ PR c/106016 * expr.cc (count_type_elements): Handle OPAQUE_TYPE. gcc/testsuite/ PR c/106016 * gcc.target/powerpc/pr106016.c: New test. --- gcc/expr.cc | 2 +- gcc/testsuite/gcc.target/powerpc/pr106016.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106016.c (limited to 'gcc') diff --git a/gcc/expr.cc b/gcc/expr.cc index f9753d4..80bb1b8 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -6462,13 +6462,13 @@ count_type_elements (const_tree type, bool for_ctor_p) case OFFSET_TYPE: case REFERENCE_TYPE: case NULLPTR_TYPE: + case OPAQUE_TYPE: return 1; case ERROR_MARK: return 0; case VOID_TYPE: - case OPAQUE_TYPE: case METHOD_TYPE: case FUNCTION_TYPE: case LANG_TYPE: diff --git a/gcc/testsuite/gcc.target/powerpc/pr106016.c b/gcc/testsuite/gcc.target/powerpc/pr106016.c new file mode 100644 index 0000000..3db8345 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr106016.c @@ -0,0 +1,14 @@ +/* PR target/106016 */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ + +/* Make sure we do not ICE on the following test case. */ + +extern void bar (__vector_quad *); + +void +foo (__vector_quad *a, __vector_quad *b) +{ + __vector_quad arr[2] = {*a, *b}; + bar (&arr[0]); +} -- cgit v1.1 From 600956c81c784f4a0cc9d10f6e03e01847afd961 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 25 Jul 2022 22:29:50 +0200 Subject: Fortran: error recovery from calculation of storage size of a symbol [PR103504] gcc/fortran/ChangeLog: PR fortran/103504 * interface.cc (get_sym_storage_size): Array bounds and character length can only be of integer type. gcc/testsuite/ChangeLog: PR fortran/103504 * gfortran.dg/pr103504.f90: New test. --- gcc/fortran/interface.cc | 7 +++++-- gcc/testsuite/gfortran.dg/pr103504.f90 | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr103504.f90 (limited to 'gcc') diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc index 7ed6e13..71eec78 100644 --- a/gcc/fortran/interface.cc +++ b/gcc/fortran/interface.cc @@ -2792,7 +2792,8 @@ get_sym_storage_size (gfc_symbol *sym) if (sym->ts.type == BT_CHARACTER) { if (sym->ts.u.cl && sym->ts.u.cl->length - && sym->ts.u.cl->length->expr_type == EXPR_CONSTANT) + && sym->ts.u.cl->length->expr_type == EXPR_CONSTANT + && sym->ts.u.cl->length->ts.type == BT_INTEGER) strlen = mpz_get_ui (sym->ts.u.cl->length->value.integer); else return 0; @@ -2809,7 +2810,9 @@ get_sym_storage_size (gfc_symbol *sym) for (i = 0; i < sym->as->rank; i++) { if (sym->as->upper[i]->expr_type != EXPR_CONSTANT - || sym->as->lower[i]->expr_type != EXPR_CONSTANT) + || sym->as->lower[i]->expr_type != EXPR_CONSTANT + || sym->as->upper[i]->ts.type != BT_INTEGER + || sym->as->lower[i]->ts.type != BT_INTEGER) return 0; elements *= mpz_get_si (sym->as->upper[i]->value.integer) diff --git a/gcc/testsuite/gfortran.dg/pr103504.f90 b/gcc/testsuite/gfortran.dg/pr103504.f90 new file mode 100644 index 0000000..607d1c6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103504.f90 @@ -0,0 +1,28 @@ +! { dg-do compile } +! PR fortran/103504 - ICE in get_sym_storage_size, at fortran/interface.c:2800 +! Contributed by G.Steinmetz + +program p + implicit none + real :: y(1) + character :: b + call s(y) + call t(y) + call u(y) + call c(b) +contains + subroutine s(x) + real :: x(abs(1.):1) ! { dg-error "must be of INTEGER type" } + end + subroutine t(x) + real :: x(abs(1.):1) ! { dg-error "must be of INTEGER type" } + end + subroutine u(x) + real :: x(1:abs(1.)) ! { dg-error "must be of INTEGER type" } + end + subroutine c(z) + character(len=abs(1.)) :: z ! { dg-error "must be of INTEGER type" } + end subroutine c +end + +! { dg-prune-output "must be of INTEGER type" } -- cgit v1.1 From 0460ba622e833db5cc1cc793201762bbbd30af6b Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 26 Jul 2022 14:43:59 -0400 Subject: analyzer: fix stray get_element decls These were copy&paste errors. gcc/analyzer/ChangeLog: * region.h (code_region::get_element): Remove stray decl. (function_region::get_element): Likewise. Signed-off-by: David Malcolm --- gcc/analyzer/region.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'gcc') diff --git a/gcc/analyzer/region.h b/gcc/analyzer/region.h index fd0d4a0..1067748 100644 --- a/gcc/analyzer/region.h +++ b/gcc/analyzer/region.h @@ -400,10 +400,6 @@ public: /* region vfuncs. */ void dump_to_pp (pretty_printer *pp, bool simple) const final override; enum region_kind get_kind () const final override { return RK_CODE; } - - const region *get_element (region_model *model, - const svalue *index, - region_model_context *ctxt); }; } // namespace ana @@ -439,10 +435,6 @@ public: tree get_fndecl () const { return m_fndecl; } - region *get_element (region_model *model, - const svalue *index_sid, - region_model_context *ctxt); - private: tree m_fndecl; }; -- cgit v1.1 From db613e8fa841259f74740665ee9e508bd73ea1c4 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 26 Jul 2022 17:17:18 -0400 Subject: analyzer: fix false +ves from -Wanalyzer-va-arg-type-mismatch on int promotion [PR106319] gcc/analyzer/ChangeLog: PR analyzer/106319 * store.cc (store::set_value): Don't strip away casts if the region has NULL type. gcc/testsuite/ChangeLog: PR analyzer/106319 * gcc.dg/analyzer/stdarg-types-3.c: New test. * gcc.dg/analyzer/stdarg-types-4.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/store.cc | 4 +- gcc/testsuite/gcc.dg/analyzer/stdarg-types-3.c | 67 ++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/analyzer/stdarg-types-4.c | 22 +++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/analyzer/stdarg-types-3.c create mode 100644 gcc/testsuite/gcc.dg/analyzer/stdarg-types-4.c (limited to 'gcc') diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc index 0b3fb37..46475f6 100644 --- a/gcc/analyzer/store.cc +++ b/gcc/analyzer/store.cc @@ -2445,7 +2445,9 @@ store::set_value (store_manager *mgr, const region *lhs_reg, remove_overlapping_bindings (mgr, lhs_reg, uncertainty); - rhs_sval = simplify_for_binding (rhs_sval); + if (lhs_reg->get_type ()) + rhs_sval = simplify_for_binding (rhs_sval); + /* ...but if we have no type for the region, retain any cast. */ const region *lhs_base_reg = lhs_reg->get_base_region (); binding_cluster *lhs_cluster; diff --git a/gcc/testsuite/gcc.dg/analyzer/stdarg-types-3.c b/gcc/testsuite/gcc.dg/analyzer/stdarg-types-3.c new file mode 100644 index 0000000..7351261 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/stdarg-types-3.c @@ -0,0 +1,67 @@ +static void __attribute__((noinline)) +__analyzer_consume_n_ints (int num, ...) +{ + __builtin_va_list ap; + __builtin_va_start (ap, num); + + int i, v; + for (i = 0; i < num; i++) + v = __builtin_va_arg (ap, int); + + __builtin_va_end (ap); +} + +void test_int (int x) +{ + __analyzer_consume_n_ints (1, x); +} + +void test_3_ints (int x, int y, int z) +{ + __analyzer_consume_n_ints (3, x, y, z); +} + +/* Verify that we don't complain about types that get promoted to int + at the variadic call. */ + +void test_short (short s) +{ + __analyzer_consume_n_ints (1, s); +} + +void test_ushort (unsigned short s) +{ + __analyzer_consume_n_ints (1, s); +} + +void test_schar (signed char ch) +{ + __analyzer_consume_n_ints (1, ch); +} + +void test_uchar (unsigned char ch) +{ + __analyzer_consume_n_ints (1, ch); +} + +struct ust +{ + int b0123 : 4; + int b4567 : 4; +}; + +void test_signed_bitfield (struct ust s) +{ + __analyzer_consume_n_ints (2, s.b0123, s.b4567); +} + +struct sst +{ + unsigned int b0123 : 4; + unsigned int b4567 : 4; +}; + +void test_unsigned_bitfield (struct sst s) +{ + __analyzer_consume_n_ints (2, s.b0123, s.b4567); +} diff --git a/gcc/testsuite/gcc.dg/analyzer/stdarg-types-4.c b/gcc/testsuite/gcc.dg/analyzer/stdarg-types-4.c new file mode 100644 index 0000000..920ecce --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/stdarg-types-4.c @@ -0,0 +1,22 @@ +static void __attribute__((noinline)) +__analyzer_consume_n_uints (int num, ...) +{ + __builtin_va_list ap; + __builtin_va_start (ap, num); + + int i, v; + for (i = 0; i < num; i++) + v = __builtin_va_arg (ap, unsigned int); + + __builtin_va_end (ap); +} + +void test_uint (unsigned int x) +{ + __analyzer_consume_n_uints (1, x); +} + +void test_3_uints (unsigned int x, unsigned int y, unsigned int z) +{ + __analyzer_consume_n_uints (3, x, y, z); +} -- cgit v1.1 From fd96c4b51a733f72fa567a96c253fb3ddf11bd2a Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 27 Jul 2022 00:16:58 +0000 Subject: Daily bump. --- gcc/ChangeLog | 343 ++++++++++++++++++++++++++++++++++++++++++++++++ gcc/DATESTAMP | 2 +- gcc/analyzer/ChangeLog | 11 ++ gcc/cp/ChangeLog | 6 + gcc/fortran/ChangeLog | 6 + gcc/testsuite/ChangeLog | 60 +++++++++ 6 files changed, 427 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 258cc48..f0963bb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,346 @@ +2022-07-26 Peter Bergner + + PR c/106016 + * expr.cc (count_type_elements): Handle OPAQUE_TYPE. + +2022-07-26 Lulu Cheng + + * config/loongarch/loongarch-opts.cc: Modify the output message string + of the warning. + +2022-07-26 Martin Liska + + * doc/tm.texi.in: Fix placement of defmac. + * doc/tm.texi: Copy. + +2022-07-26 Martin Liska + + * doc/tm.texi.in: Fix cross @defmac and @hook. + * doc/tm.texi: Copy. + +2022-07-26 Aldy Hernandez + + PR tree-optimization/106444 + * value-range-pretty-print.cc (vrange_printer::visit): Handle + legacy ranges. + (vrange_printer::print_irange_bound): Work on wide_int's. + * value-range-pretty-print.h (print_irange_bound): Same. + * value-range.cc (irange::get_nonzero_bits): Handle legacy ranges. + +2022-07-26 Richard Biener + + * tree-ssa-alias.cc (ptr_derefs_may_alias_p): If ptr1 + points to a constant continue checking ptr2. + +2022-07-26 Andrew Carlotti + + * config/aarch64/aarch64-builtins.cc + (MODE_d_bf16, MODE_d_f16, MODE_d_f32, MODE_d_f64, MODE_d_s8) + (MODE_d_s16, MODE_d_s32, MODE_d_s64, MODE_d_u8, MODE_d_u16) + (MODE_d_u32, MODE_d_u64, MODE_d_p8, MODE_d_p16, MODE_d_p64) + (MODE_q_bf16, MODE_q_f16, MODE_q_f32, MODE_q_f64, MODE_q_s8) + (MODE_q_s16, MODE_q_s32, MODE_q_s64, MODE_q_u8, MODE_q_u16) + (MODE_q_u32, MODE_q_u64, MODE_q_p8, MODE_q_p16, MODE_q_p64) + (MODE_q_p128): Define macro to map to corresponding mode name. + (QUAL_bf16, QUAL_f16, QUAL_f32, QUAL_f64, QUAL_s8, QUAL_s16) + (QUAL_s32, QUAL_s64, QUAL_u8, QUAL_u16, QUAL_u32, QUAL_u64) + (QUAL_p8, QUAL_p16, QUAL_p64, QUAL_p128): Define macro to map to + corresponding qualifier name. + (LENGTH_d, LENGTH_q): Define macro to map to "" or "q" suffix. + (SIMD_INTR_MODE, SIMD_INTR_QUAL, SIMD_INTR_LENGTH_CHAR): Macro + functions for the above mappings + (VREINTERPRET_BUILTIN2, VREINTERPRET_BUILTINS1, VREINTERPRET_BUILTINS) + (VREINTERPRETQ_BUILTIN2, VREINTERPRETQ_BUILTINS1) + (VREINTERPRETQ_BUILTINS, VREINTERPRET_BUILTIN) + (AARCH64_SIMD_VREINTERPRET_BUILTINS): New macros to create definitions + for all vreinterpret intrinsics + (enum aarch64_builtins): Add vreinterpret function codes + (aarch64_init_simd_intrinsics): New + (handle_arm_neon_h): Improved comment. + (aarch64_general_fold_builtin): Fold vreinterpret calls + * config/aarch64/arm_neon.h + (vreinterpret_p8_f16, vreinterpret_p8_f64, vreinterpret_p8_s8) + (vreinterpret_p8_s16, vreinterpret_p8_s32, vreinterpret_p8_s64) + (vreinterpret_p8_f32, vreinterpret_p8_u8, vreinterpret_p8_u16) + (vreinterpret_p8_u32, vreinterpret_p8_u64, vreinterpret_p8_p16) + (vreinterpret_p8_p64, vreinterpretq_p8_f64, vreinterpretq_p8_s8) + (vreinterpretq_p8_s16, vreinterpretq_p8_s32, vreinterpretq_p8_s64) + (vreinterpretq_p8_f16, vreinterpretq_p8_f32, vreinterpretq_p8_u8) + (vreinterpretq_p8_u16, vreinterpretq_p8_u32, vreinterpretq_p8_u64) + (vreinterpretq_p8_p16, vreinterpretq_p8_p64, vreinterpretq_p8_p128) + (vreinterpret_p16_f16, vreinterpret_p16_f64, vreinterpret_p16_s8) + (vreinterpret_p16_s16, vreinterpret_p16_s32, vreinterpret_p16_s64) + (vreinterpret_p16_f32, vreinterpret_p16_u8, vreinterpret_p16_u16) + (vreinterpret_p16_u32, vreinterpret_p16_u64, vreinterpret_p16_p8) + (vreinterpret_p16_p64, vreinterpretq_p16_f64, vreinterpretq_p16_s8) + (vreinterpretq_p16_s16, vreinterpretq_p16_s32, vreinterpretq_p16_s64) + (vreinterpretq_p16_f16, vreinterpretq_p16_f32, vreinterpretq_p16_u8) + (vreinterpretq_p16_u16, vreinterpretq_p16_u32, vreinterpretq_p16_u64) + (vreinterpretq_p16_p8, vreinterpretq_p16_p64, vreinterpretq_p16_p128) + (vreinterpret_p64_f16, vreinterpret_p64_f64, vreinterpret_p64_s8) + (vreinterpret_p64_s16, vreinterpret_p64_s32, vreinterpret_p64_s64) + (vreinterpret_p64_f32, vreinterpret_p64_u8, vreinterpret_p64_u16) + (vreinterpret_p64_u32, vreinterpret_p64_u64, vreinterpret_p64_p8) + (vreinterpret_p64_p16, vreinterpretq_p64_f64, vreinterpretq_p64_s8) + (vreinterpretq_p64_s16, vreinterpretq_p64_s32, vreinterpretq_p64_s64) + (vreinterpretq_p64_f16, vreinterpretq_p64_f32, vreinterpretq_p64_p128) + (vreinterpretq_p64_u8, vreinterpretq_p64_u16, vreinterpretq_p64_p16) + (vreinterpretq_p64_u32, vreinterpretq_p64_u64, vreinterpretq_p64_p8) + (vreinterpretq_p128_p8, vreinterpretq_p128_p16, vreinterpretq_p128_f16) + (vreinterpretq_p128_f32, vreinterpretq_p128_p64, vreinterpretq_p128_s64) + (vreinterpretq_p128_u64, vreinterpretq_p128_s8, vreinterpretq_p128_s16) + (vreinterpretq_p128_s32, vreinterpretq_p128_u8, vreinterpretq_p128_u16) + (vreinterpretq_p128_u32, vreinterpret_f16_f64, vreinterpret_f16_s8) + (vreinterpret_f16_s16, vreinterpret_f16_s32, vreinterpret_f16_s64) + (vreinterpret_f16_f32, vreinterpret_f16_u8, vreinterpret_f16_u16) + (vreinterpret_f16_u32, vreinterpret_f16_u64, vreinterpret_f16_p8) + (vreinterpret_f16_p16, vreinterpret_f16_p64, vreinterpretq_f16_f64) + (vreinterpretq_f16_s8, vreinterpretq_f16_s16, vreinterpretq_f16_s32) + (vreinterpretq_f16_s64, vreinterpretq_f16_f32, vreinterpretq_f16_u8) + (vreinterpretq_f16_u16, vreinterpretq_f16_u32, vreinterpretq_f16_u64) + (vreinterpretq_f16_p8, vreinterpretq_f16_p128, vreinterpretq_f16_p16) + (vreinterpretq_f16_p64, vreinterpret_f32_f16, vreinterpret_f32_f64) + (vreinterpret_f32_s8, vreinterpret_f32_s16, vreinterpret_f32_s32) + (vreinterpret_f32_s64, vreinterpret_f32_u8, vreinterpret_f32_u16) + (vreinterpret_f32_u32, vreinterpret_f32_u64, vreinterpret_f32_p8) + (vreinterpret_f32_p16, vreinterpret_f32_p64, vreinterpretq_f32_f16) + (vreinterpretq_f32_f64, vreinterpretq_f32_s8, vreinterpretq_f32_s16) + (vreinterpretq_f32_s32, vreinterpretq_f32_s64, vreinterpretq_f32_u8) + (vreinterpretq_f32_u16, vreinterpretq_f32_u32, vreinterpretq_f32_u64) + (vreinterpretq_f32_p8, vreinterpretq_f32_p16, vreinterpretq_f32_p64) + (vreinterpretq_f32_p128, vreinterpret_f64_f16, vreinterpret_f64_f32) + (vreinterpret_f64_p8, vreinterpret_f64_p16, vreinterpret_f64_p64) + (vreinterpret_f64_s8, vreinterpret_f64_s16, vreinterpret_f64_s32) + (vreinterpret_f64_s64, vreinterpret_f64_u8, vreinterpret_f64_u16) + (vreinterpret_f64_u32, vreinterpret_f64_u64, vreinterpretq_f64_f16) + (vreinterpretq_f64_f32, vreinterpretq_f64_p8, vreinterpretq_f64_p16) + (vreinterpretq_f64_p64, vreinterpretq_f64_s8, vreinterpretq_f64_s16) + (vreinterpretq_f64_s32, vreinterpretq_f64_s64, vreinterpretq_f64_u8) + (vreinterpretq_f64_u16, vreinterpretq_f64_u32, vreinterpretq_f64_u64) + (vreinterpret_s64_f16, vreinterpret_s64_f64, vreinterpret_s64_s8) + (vreinterpret_s64_s16, vreinterpret_s64_s32, vreinterpret_s64_f32) + (vreinterpret_s64_u8, vreinterpret_s64_u16, vreinterpret_s64_u32) + (vreinterpret_s64_u64, vreinterpret_s64_p8, vreinterpret_s64_p16) + (vreinterpret_s64_p64, vreinterpretq_s64_f64, vreinterpretq_s64_s8) + (vreinterpretq_s64_s16, vreinterpretq_s64_s32, vreinterpretq_s64_f16) + (vreinterpretq_s64_f32, vreinterpretq_s64_u8, vreinterpretq_s64_u16) + (vreinterpretq_s64_u32, vreinterpretq_s64_u64, vreinterpretq_s64_p8) + (vreinterpretq_s64_p16, vreinterpretq_s64_p64, vreinterpretq_s64_p128) + (vreinterpret_u64_f16, vreinterpret_u64_f64, vreinterpret_u64_s8) + (vreinterpret_u64_s16, vreinterpret_u64_s32, vreinterpret_u64_s64) + (vreinterpret_u64_f32, vreinterpret_u64_u8, vreinterpret_u64_u16) + (vreinterpret_u64_u32, vreinterpret_u64_p8, vreinterpret_u64_p16) + (vreinterpret_u64_p64, vreinterpretq_u64_f64, vreinterpretq_u64_s8) + (vreinterpretq_u64_s16, vreinterpretq_u64_s32, vreinterpretq_u64_s64) + (vreinterpretq_u64_f16, vreinterpretq_u64_f32, vreinterpretq_u64_u8) + (vreinterpretq_u64_u16, vreinterpretq_u64_u32, vreinterpretq_u64_p8) + (vreinterpretq_u64_p16, vreinterpretq_u64_p64, vreinterpretq_u64_p128) + (vreinterpret_s8_f16, vreinterpret_s8_f64, vreinterpret_s8_s16) + (vreinterpret_s8_s32, vreinterpret_s8_s64, vreinterpret_s8_f32) + (vreinterpret_s8_u8, vreinterpret_s8_u16, vreinterpret_s8_u32) + (vreinterpret_s8_u64, vreinterpret_s8_p8, vreinterpret_s8_p16) + (vreinterpret_s8_p64, vreinterpretq_s8_f64, vreinterpretq_s8_s16) + (vreinterpretq_s8_s32, vreinterpretq_s8_s64, vreinterpretq_s8_f16) + (vreinterpretq_s8_f32, vreinterpretq_s8_u8, vreinterpretq_s8_u16) + (vreinterpretq_s8_u32, vreinterpretq_s8_u64, vreinterpretq_s8_p8) + (vreinterpretq_s8_p16, vreinterpretq_s8_p64, vreinterpretq_s8_p128) + (vreinterpret_s16_f16, vreinterpret_s16_f64, vreinterpret_s16_s8) + (vreinterpret_s16_s32, vreinterpret_s16_s64, vreinterpret_s16_f32) + (vreinterpret_s16_u8, vreinterpret_s16_u16, vreinterpret_s16_u32) + (vreinterpret_s16_u64, vreinterpret_s16_p8, vreinterpret_s16_p16) + (vreinterpret_s16_p64, vreinterpretq_s16_f64, vreinterpretq_s16_s8) + (vreinterpretq_s16_s32, vreinterpretq_s16_s64, vreinterpretq_s16_f16) + (vreinterpretq_s16_f32, vreinterpretq_s16_u8, vreinterpretq_s16_u16) + (vreinterpretq_s16_u32, vreinterpretq_s16_u64, vreinterpretq_s16_p8) + (vreinterpretq_s16_p16, vreinterpretq_s16_p64, vreinterpretq_s16_p128) + (vreinterpret_s32_f16, vreinterpret_s32_f64, vreinterpret_s32_s8) + (vreinterpret_s32_s16, vreinterpret_s32_s64, vreinterpret_s32_f32) + (vreinterpret_s32_u8, vreinterpret_s32_u16, vreinterpret_s32_u32) + (vreinterpret_s32_u64, vreinterpret_s32_p8, vreinterpret_s32_p16) + (vreinterpret_s32_p64, vreinterpretq_s32_f64, vreinterpretq_s32_s8) + (vreinterpretq_s32_s16, vreinterpretq_s32_s64, vreinterpretq_s32_f16) + (vreinterpretq_s32_f32, vreinterpretq_s32_u8, vreinterpretq_s32_u16) + (vreinterpretq_s32_u32, vreinterpretq_s32_u64, vreinterpretq_s32_p8) + (vreinterpretq_s32_p16, vreinterpretq_s32_p64, vreinterpretq_s32_p128) + (vreinterpret_u8_f16, vreinterpret_u8_f64, vreinterpret_u8_s8) + (vreinterpret_u8_s16, vreinterpret_u8_s32, vreinterpret_u8_s64) + (vreinterpret_u8_f32, vreinterpret_u8_u16, vreinterpret_u8_u32) + (vreinterpret_u8_u64, vreinterpret_u8_p8, vreinterpret_u8_p16) + (vreinterpret_u8_p64, vreinterpretq_u8_f64, vreinterpretq_u8_s8) + (vreinterpretq_u8_s16, vreinterpretq_u8_s32, vreinterpretq_u8_s64) + (vreinterpretq_u8_f16, vreinterpretq_u8_f32, vreinterpretq_u8_u16) + (vreinterpretq_u8_u32, vreinterpretq_u8_u64, vreinterpretq_u8_p8) + (vreinterpretq_u8_p16, vreinterpretq_u8_p64, vreinterpretq_u8_p128) + (vreinterpret_u16_f16, vreinterpret_u16_f64, vreinterpret_u16_s8) + (vreinterpret_u16_s16, vreinterpret_u16_s32, vreinterpret_u16_s64) + (vreinterpret_u16_f32, vreinterpret_u16_u8, vreinterpret_u16_u32) + (vreinterpret_u16_u64, vreinterpret_u16_p8, vreinterpret_u16_p16) + (vreinterpret_u16_p64, vreinterpretq_u16_f64, vreinterpretq_u16_s8) + (vreinterpretq_u16_s16, vreinterpretq_u16_s32, vreinterpretq_u16_s64) + (vreinterpretq_u16_f16, vreinterpretq_u16_f32, vreinterpretq_u16_u8) + (vreinterpretq_u16_u32, vreinterpretq_u16_u64, vreinterpretq_u16_p8) + (vreinterpretq_u16_p16, vreinterpretq_u16_p64, vreinterpretq_u16_p128) + (vreinterpret_u32_f16, vreinterpret_u32_f64, vreinterpret_u32_s8) + (vreinterpret_u32_s16, vreinterpret_u32_s32, vreinterpret_u32_s64) + (vreinterpret_u32_f32, vreinterpret_u32_u8, vreinterpret_u32_u16) + (vreinterpret_u32_u64, vreinterpret_u32_p8, vreinterpret_u32_p16) + (vreinterpret_u32_p64, vreinterpretq_u32_f64, vreinterpretq_u32_s8) + (vreinterpretq_u32_s16, vreinterpretq_u32_s32, vreinterpretq_u32_s64) + (vreinterpretq_u32_f16, vreinterpretq_u32_f32, vreinterpretq_u32_u8) + (vreinterpretq_u32_u16, vreinterpretq_u32_u64, vreinterpretq_u32_p8) + (vreinterpretq_u32_p16, vreinterpretq_u32_p64, vreinterpretq_u32_p128) + (vreinterpretq_f64_p128, vreinterpretq_p128_f64, vreinterpret_bf16_u8) + (vreinterpret_bf16_u16, vreinterpret_bf16_u32, vreinterpret_bf16_u64) + (vreinterpret_bf16_s8, vreinterpret_bf16_s16, vreinterpret_bf16_s32) + (vreinterpret_bf16_s64, vreinterpret_bf16_p8, vreinterpret_bf16_p16) + (vreinterpret_bf16_p64, vreinterpret_bf16_f16, vreinterpret_bf16_f32) + (vreinterpret_bf16_f64, vreinterpretq_bf16_u8, vreinterpretq_bf16_u16) + (vreinterpretq_bf16_u32, vreinterpretq_bf16_u64, vreinterpretq_bf16_s8) + (vreinterpretq_bf16_s16, vreinterpretq_bf16_s32, vreinterpretq_bf16_s64) + (vreinterpretq_bf16_p8, vreinterpretq_bf16_p16, vreinterpretq_bf16_p64) + (vreinterpretq_bf16_p128, vreinterpretq_bf16_f16) + (vreinterpretq_bf16_f32, vreinterpretq_bf16_f64, vreinterpret_s8_bf16) + (vreinterpret_s16_bf16, vreinterpret_s32_bf16, vreinterpret_s64_bf16) + (vreinterpret_u8_bf16, vreinterpret_u16_bf16, vreinterpret_u32_bf16) + (vreinterpret_u64_bf16, vreinterpret_f16_bf16, vreinterpret_f32_bf16) + (vreinterpret_f64_bf16, vreinterpret_p8_bf16, vreinterpret_p16_bf16) + (vreinterpret_p64_bf16, vreinterpretq_s8_bf16, vreinterpretq_s16_bf16) + (vreinterpretq_s32_bf16, vreinterpretq_s64_bf16, vreinterpretq_u8_bf16) + (vreinterpretq_u16_bf16, vreinterpretq_u32_bf16, vreinterpretq_u64_bf16) + (vreinterpretq_f16_bf16, vreinterpretq_f32_bf16, vreinterpretq_f64_bf16) + (vreinterpretq_p8_bf16, vreinterpretq_p16_bf16, vreinterpretq_p64_bf16) + (vreinterpretq_p128_bf16): Delete + +2022-07-26 Andrew Carlotti + + * config/aarch64/aarch64-builtins.cc + (aarch64_simd_builtin_std_type): Rename to... + (aarch64_int_or_fp_type): ...this, and allow irrelevant qualifiers. + (aarch64_lookup_simd_builtin_type): Rename to... + (aarch64_simd_builtin_type): ...this. Add const/pointer + support, and extract table lookup to... + (aarch64_lookup_simd_type_in_table): ...this function. + (aarch64_init_crc32_builtins): Update to use aarch64_simd_builtin_type. + (aarch64_init_fcmla_laneq_builtins): Ditto. + (aarch64_init_simd_builtin_functions): Ditto. + +2022-07-26 Andrew Carlotti + + * config/aarch64/aarch64-builtins.cc + (aarch64_general_gimple_fold_builtin): Add combine. + +2022-07-26 Richard Biener + + PR tree-optimization/106189 + * gimple-array-bounds.cc (array_bounds_checker::check_mem_ref): + Divide using offset_ints. + +2022-07-26 Lulu Cheng + + * common/config/loongarch/loongarch-common.cc: + Enable '-fsection-anchors' when O1 and more advanced optimization. + * config/loongarch/genopts/loongarch.opt.in: Add new option + '-mexplicit-relocs', and enable by default. + * config/loongarch/loongarch-protos.h (loongarch_split_move_insn_p): + Delete function declaration. + (loongarch_split_move_insn): Delete function declaration. + (loongarch_split_symbol_type): Add function declaration. + * config/loongarch/loongarch.cc (enum loongarch_address_type): + Add new address type 'ADDRESS_LO_SUM'. + (loongarch_classify_symbolic_expression): New function definitions. + Classify the base of symbolic expression X, given that X appears in + context CONTEXT. + (loongarch_symbol_insns): Add a judgment condition TARGET_EXPLICIT_RELOCS. + (loongarch_split_symbol_type): New function definitions. + Determines whether the symbol load should be split into two instructions. + (loongarch_valid_lo_sum_p): New function definitions. + Return true if a LO_SUM can address a value of mode MODE when the LO_SUM + symbol has type SYMBOL_TYPE. + (loongarch_classify_address): Add handling of 'LO_SUM'. + (loongarch_address_insns): Add handling of 'ADDRESS_LO_SUM'. + (loongarch_signed_immediate_p): Sort code. + (loongarch_12bit_offset_address_p): Return true if address type is ADDRESS_LO_SUM. + (loongarch_const_insns): Add handling of 'HIGH'. + (loongarch_split_move_insn_p): Add the static attribute to the function. + (loongarch_emit_set): New function definitions. + (loongarch_call_tls_get_addr): Add symbol handling when defining TARGET_EXPLICIT_RELOCS. + (loongarch_legitimize_tls_address): Add symbol handling when defining the + TARGET_EXPLICIT_RELOCS macro. + (loongarch_split_symbol): New function definitions. Split symbol. + (loongarch_legitimize_address): Add codes see if the address can split into a high part + and a LO_SUM. + (loongarch_legitimize_const_move): Add codes split moves of symbolic constants into + high and low. + (loongarch_split_move_insn): Delete function definitions. + (loongarch_output_move): Add support for HIGH and LO_SUM. + (loongarch_print_operand_reloc): New function definitions. + Print symbolic operand OP, which is part of a HIGH or LO_SUM in context CONTEXT. + (loongarch_memmodel_needs_release_fence): Sort code. + (loongarch_print_operand): Rearrange alphabetical order and add H and L to support HIGH + and LOW output. + (loongarch_print_operand_address): Add handling of 'ADDRESS_LO_SUM'. + (TARGET_MIN_ANCHOR_OFFSET): Define macro to -IMM_REACH/2. + (TARGET_MAX_ANCHOR_OFFSET): Define macro to IMM_REACH/2-1. + * config/loongarch/loongarch.md (movti): Delete the template. + (*movti): Delete the template. + (movtf): Delete the template. + (*movtf): Delete the template. + (*low): New template of normal symbol low address. + (@tls_low): New template of tls symbol low address. + (@ld_from_got): New template load address from got table. + (@ori_l_lo12): New template. + * config/loongarch/loongarch.opt: Update from loongarch.opt.in. + * config/loongarch/predicates.md: Add support for symbol_type HIGH. + +2022-07-26 Lulu Cheng + + * config/loongarch/constraints.md (a): Delete the constraint. + (b): A constant call not local address. + (h): Delete the constraint. + (t): Delete the constraint. + * config/loongarch/loongarch-opts.cc (loongarch_config_target): + Remove cModel type support other than normal. + * config/loongarch/loongarch-protos.h (enum loongarch_symbol_type): + Add new symbol type 'SYMBOL_PCREL', 'SYMBOL_TLS_IE' and 'SYMBOL_TLS_LE'. + (loongarch_split_symbol): Delete useless function declarations. + (loongarch_split_symbol_type): Delete useless function declarations. + * config/loongarch/loongarch.cc (enum loongarch_address_type): + Delete unnecessary comment information. + (loongarch_symbol_binds_local_p): Modified the judgment order of label + and symbol. + (loongarch_classify_symbol): Return symbol type. If symbol is a label, + or symbol is a local symbol return SYMBOL_PCREL. If is a tls symbol, + return SYMBOL_TLS. If is a not local symbol return SYMBOL_GOT_DISP. + (loongarch_symbolic_constant_p): Add handling of 'SYMBOL_TLS_IE' + 'SYMBOL_TLS_LE' and 'SYMBOL_PCREL'. + (loongarch_symbol_insns): Add handling of 'SYMBOL_TLS_IE' 'SYMBOL_TLS_LE' + and 'SYMBOL_PCREL'. + (loongarch_address_insns): Sort code. + (loongarch_12bit_offset_address_p): Sort code. + (loongarch_14bit_shifted_offset_address_p): Sort code. + (loongarch_call_tls_get_addr): Sort code. + (loongarch_legitimize_tls_address): Sort code. + (loongarch_output_move): Remove schema support for cmodel other than normal. + (loongarch_memmodel_needs_release_fence): Sort code. + (loongarch_print_operand): Sort code. + * config/loongarch/loongarch.h (LARCH_U12BIT_OFFSET_P): + Rename to LARCH_12BIT_OFFSET_P. + (LARCH_12BIT_OFFSET_P): New macro. + * config/loongarch/loongarch.md: Reimplement the function call. Remove schema + support for cmodel other than normal. + * config/loongarch/predicates.md (is_const_call_weak_symbol): Delete this predicate. + (is_const_call_plt_symbol): Delete this predicate. + (is_const_call_global_noplt_symbol): Delete this predicate. + (is_const_call_no_local_symbol): New predicate, determines whether it is a local + symbol or label. + +2022-07-26 Kewen Lin + + PR target/106091 + * config/rs6000/rs6000-p8swap.cc (replace_swapped_aligned_store): Copy + REG_EH_REGION when replacing one store insn having it. + (replace_swapped_aligned_load): Likewise. + 2022-07-25 Aldy Hernandez * Makefile.in (OBJS): Add range-op-float.o. diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 5d98481..b7375eb 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20220726 +20220727 diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog index 00905b2..6c883b7 100644 --- a/gcc/analyzer/ChangeLog +++ b/gcc/analyzer/ChangeLog @@ -1,3 +1,14 @@ +2022-07-26 David Malcolm + + PR analyzer/106319 + * store.cc (store::set_value): Don't strip away casts if the + region has NULL type. + +2022-07-26 David Malcolm + + * region.h (code_region::get_element): Remove stray decl. + (function_region::get_element): Likewise. + 2022-07-25 Martin Liska * sm-fd.cc: Run dos2unix and fix coding style issues. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 208275e..a5ed51a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2022-07-26 Marek Polacek + + PR c++/106311 + * pt.cc (redeclare_class_template): Check DECL_P before accessing + DECL_SOURCE_LOCATION. + 2022-07-26 Jason Merrill PR c++/106230 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2404d85..acd60ff 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2022-07-26 Harald Anlauf + + PR fortran/103504 + * interface.cc (get_sym_storage_size): Array bounds and character + length can only be of integer type. + 2022-07-21 Martin Liska * intrinsic.texi: Remove trailing dots for 2 Fortran fns. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 18e136c..c846ad4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,63 @@ +2022-07-26 David Malcolm + + PR analyzer/106319 + * gcc.dg/analyzer/stdarg-types-3.c: New test. + * gcc.dg/analyzer/stdarg-types-4.c: New test. + +2022-07-26 Harald Anlauf + + PR fortran/103504 + * gfortran.dg/pr103504.f90: New test. + +2022-07-26 Peter Bergner + + PR c/106016 + * gcc.target/powerpc/pr106016.c: New test. + +2022-07-26 Marek Polacek + + PR c++/106311 + * g++.dg/template/redecl5.C: New test. + +2022-07-26 Aldy Hernandez + + PR tree-optimization/106444 + * gcc.dg/tree-ssa/evrp4.c: Adjust. + +2022-07-26 Andrew Carlotti + + * gcc.target/aarch64/advsimd-intrinsics/combine.c: + New test. + +2022-07-26 Richard Biener + + PR tree-optimization/106189 + * gcc.dg/pr106189.c: New testcase. + +2022-07-26 Lulu Cheng + + * gcc.target/loongarch/func-call-1.c: Add build option '-mno-explicit-relocs'. + * gcc.target/loongarch/func-call-2.c: Add build option '-mno-explicit-relocs'. + * gcc.target/loongarch/func-call-3.c: Add build option '-mno-explicit-relocs'. + * gcc.target/loongarch/func-call-4.c: Add build option '-mno-explicit-relocs'. + * gcc.target/loongarch/func-call-5.c: New test. + * gcc.target/loongarch/func-call-6.c: New test. + * gcc.target/loongarch/func-call-7.c: New test. + * gcc.target/loongarch/func-call-8.c: New test. + * gcc.target/loongarch/relocs-symbol-noaddend.c: New test. + +2022-07-26 Lulu Cheng + + * gcc.target/loongarch/func-call-1.c: New test. + * gcc.target/loongarch/func-call-2.c: New test. + * gcc.target/loongarch/func-call-3.c: New test. + * gcc.target/loongarch/func-call-4.c: New test. + +2022-07-26 Kewen Lin + + PR target/106091 + * gcc.target/powerpc/pr106091.c: New test. + 2022-07-26 Jason Merrill PR c++/106230 -- cgit v1.1 From 66434729a79dfa2d9790aadeca7082511c387980 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Tue, 26 Jul 2022 21:46:20 +0800 Subject: LoongArch: adjust the default of -mexplicit-relocs by checking gas feature The assembly produced with -mexplicit-relocs is not supported by gas <= 2.39. Check if the assembler supports explicit relocations and set the default accordingly. gcc/ChangeLog: * configure.ac (HAVE_AS_EXPLICIT_RELOCS): Define to 1 if the assembler supports explicit relocation for LoongArch. * configure: Regenerate. * config/loongarch/loongarch-opts.h (HAVE_AS_EXPLICIT_RELOCS): Define to 0 if not defined. * config/loongarch/genopts/loongarch.opt.in (TARGET_EXPLICIT_RELOCS): Default to HAVE_AS_EXPLICIT_RELOCS. * config/loongarch/loongarch.opt: Regenerate. --- gcc/config/loongarch/genopts/loongarch.opt.in | 2 +- gcc/config/loongarch/loongarch-opts.h | 4 +++ gcc/config/loongarch/loongarch.opt | 2 +- gcc/configure | 37 ++++++++++++++++++++++++--- gcc/configure.ac | 7 ++++- 5 files changed, 46 insertions(+), 6 deletions(-) (limited to 'gcc') diff --git a/gcc/config/loongarch/genopts/loongarch.opt.in b/gcc/config/loongarch/genopts/loongarch.opt.in index 6f39500..a571b6b 100644 --- a/gcc/config/loongarch/genopts/loongarch.opt.in +++ b/gcc/config/loongarch/genopts/loongarch.opt.in @@ -155,7 +155,7 @@ Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init -mmax-inline-memcpy-size=SIZE Set the max size of memcpy to inline, default is 1024. mexplicit-relocs -Target Var(TARGET_EXPLICIT_RELOCS) Init(1) +Target Var(TARGET_EXPLICIT_RELOCS) Init(HAVE_AS_EXPLICIT_RELOCS) Use %reloc() assembly operators. ; The code model option names for -mcmodel. diff --git a/gcc/config/loongarch/loongarch-opts.h b/gcc/config/loongarch/loongarch-opts.h index eaa6fc0..da24ecd 100644 --- a/gcc/config/loongarch/loongarch-opts.h +++ b/gcc/config/loongarch/loongarch-opts.h @@ -87,4 +87,8 @@ loongarch_config_target (struct loongarch_target *target, while -m[no]-memcpy imposes a global constraint. */ #define TARGET_DO_OPTIMIZE_BLOCK_MOVE_P loongarch_do_optimize_block_move_p() +#ifndef HAVE_AS_EXPLICIT_RELOCS +#define HAVE_AS_EXPLICIT_RELOCS 0 +#endif + #endif /* LOONGARCH_OPTS_H */ diff --git a/gcc/config/loongarch/loongarch.opt b/gcc/config/loongarch/loongarch.opt index 7a8c5b4..9df7e18 100644 --- a/gcc/config/loongarch/loongarch.opt +++ b/gcc/config/loongarch/loongarch.opt @@ -162,7 +162,7 @@ Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init -mmax-inline-memcpy-size=SIZE Set the max size of memcpy to inline, default is 1024. mexplicit-relocs -Target Var(TARGET_EXPLICIT_RELOCS) Init(1) +Target Var(TARGET_EXPLICIT_RELOCS) Init(HAVE_AS_EXPLICIT_RELOCS) Use %reloc() assembly operators. ; The code model option names for -mcmodel. diff --git a/gcc/configure b/gcc/configure index 62872d1..7eb9479 100755 --- a/gcc/configure +++ b/gcc/configure @@ -19674,7 +19674,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19679 "configure" +#line 19677 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19780,7 +19780,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19785 "configure" +#line 19783 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -28771,7 +28771,7 @@ $as_echo "#define HAVE_AS_MARCH_ZIFENCEI 1" >>confdefs.h fi ;; - loongarch*-*-*) + loongarch*-*-*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .dtprelword support" >&5 $as_echo_n "checking assembler for .dtprelword support... " >&6; } if ${gcc_cv_as_loongarch_dtprelword+:} false; then : @@ -28807,6 +28807,37 @@ if test $gcc_cv_as_loongarch_dtprelword != yes; then $as_echo "#define HAVE_AS_DTPRELWORD 1" >>confdefs.h fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for explicit relocation support" >&5 +$as_echo_n "checking assembler for explicit relocation support... " >&6; } +if ${gcc_cv_as_loongarch_explicit_relocs+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_loongarch_explicit_relocs=no + if test x$gcc_cv_as != x; then + $as_echo 'a:pcalau12i $t0,%pc_hi20(a)' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_loongarch_explicit_relocs=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_loongarch_explicit_relocs" >&5 +$as_echo "$gcc_cv_as_loongarch_explicit_relocs" >&6; } +if test $gcc_cv_as_loongarch_explicit_relocs = yes; then + +$as_echo "#define HAVE_AS_EXPLICIT_RELOCS 1" >>confdefs.h + +fi + ;; s390*-*-*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .gnu_attribute support" >&5 diff --git a/gcc/configure.ac b/gcc/configure.ac index 4467473..e5f708c 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5287,7 +5287,7 @@ configured with --enable-newlib-nano-formatted-io.]) [AC_DEFINE(HAVE_AS_MARCH_ZIFENCEI, 1, [Define if the assembler understands -march=rv*_zifencei.])]) ;; - loongarch*-*-*) + loongarch*-*-*) gcc_GAS_CHECK_FEATURE([.dtprelword support], gcc_cv_as_loongarch_dtprelword, [2,18,0],, [.section .tdata,"awT",@progbits @@ -5297,6 +5297,11 @@ x: .dtprelword x+0x8000],, [AC_DEFINE(HAVE_AS_DTPRELWORD, 1, [Define if your assembler supports .dtprelword.])]) + gcc_GAS_CHECK_FEATURE([explicit relocation support], + gcc_cv_as_loongarch_explicit_relocs,, + [a:pcalau12i $t0,%pc_hi20(a)],, + [AC_DEFINE(HAVE_AS_EXPLICIT_RELOCS, 1, + [Define if your assembler supports explicit relocation.])]) ;; s390*-*-*) gcc_GAS_CHECK_FEATURE([.gnu_attribute support], -- cgit v1.1 From 3044a7a824981496875acc6debf467fb904c55f2 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 27 Jul 2022 12:00:36 +0200 Subject: testsuite: Add extra ia32 options so that -fprefetch-loop-arrays works [PR106397] -fprefetch-loop-arrays isn't supported on ia32 with just -march=i386 and similar, the following patch adds extra options similar testcases use. 2022-07-27 Jakub Jelinek PR tree-optimization/106397 * gcc.dg/pr106397.c: For ia32, add dg-additional-options -march=i686 -msse. --- gcc/testsuite/gcc.dg/pr106397.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc') diff --git a/gcc/testsuite/gcc.dg/pr106397.c b/gcc/testsuite/gcc.dg/pr106397.c index a6b2e91..2bc17f8 100644 --- a/gcc/testsuite/gcc.dg/pr106397.c +++ b/gcc/testsuite/gcc.dg/pr106397.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O3 -fprefetch-loop-arrays --param l2-cache-size=0 --param prefetch-latency=3 -fprefetch-loop-arrays" } */ +/* { dg-additional-options "-march=i686 -msse" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ int bar (void) -- cgit v1.1 From 0bc1566dec0cab9410723c96d2ef3280fdab8e8e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 27 Jul 2022 12:02:12 +0200 Subject: testsuite: Add -Wno-psabi to pr94920 tests [PR94920] These tests fail on ia32, because we get -Wpsabi warnings. Fixed by adding -Wno-psabi. The pr94920.C test still fails the ABS_EXPR scan-tree-dump though, I think we'll need to add vect options and use vect_int effective target or something similar. 2022-07-27 Jakub Jelinek PR tree-optimization/94920 * g++.dg/pr94920.C: Add -Wno-psabi to dg-options. * g++.dg/pr94920-1.C: Add dg-additional-options -Wno-psabi. --- gcc/testsuite/g++.dg/pr94920-1.C | 1 + gcc/testsuite/g++.dg/pr94920.C | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/testsuite/g++.dg/pr94920-1.C b/gcc/testsuite/g++.dg/pr94920-1.C index 6c6483e..f8fa14a 100644 --- a/gcc/testsuite/g++.dg/pr94920-1.C +++ b/gcc/testsuite/g++.dg/pr94920-1.C @@ -1,4 +1,5 @@ /* PR tree-optimization/94920 */ +/* { dg-additional-options "-Wno-psabi" } */ /* { dg-do run } */ #include "pr94920.C" diff --git a/gcc/testsuite/g++.dg/pr94920.C b/gcc/testsuite/g++.dg/pr94920.C index 925ec4f..126b004 100644 --- a/gcc/testsuite/g++.dg/pr94920.C +++ b/gcc/testsuite/g++.dg/pr94920.C @@ -1,6 +1,6 @@ /* PR tree-optimization/94920 */ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-options "-O2 -Wno-psabi -fdump-tree-optimized" } */ typedef int __attribute__((vector_size(4*sizeof(int)))) vint; -- cgit v1.1 From cc078cf85295ec5d0a63a16afbd045efac0d455e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 27 Jul 2022 12:04:50 +0200 Subject: opts: Add an assertion to help static analyzers [PR106332] This function would have UB if called with empty candidates vector (accessing p[-1] where p is malloc (0) result). As analyzed in the PR, we never call it with empty vector, so this just adds an assertion to make it clear. 2022-07-27 Jakub Jelinek PR middle-end/106332 * opts-common.cc (candidates_list_and_hint): Add gcc_assert that candidates is not an empty vector. --- gcc/opts-common.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc') diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc index 1663be1..8097c05 100644 --- a/gcc/opts-common.cc +++ b/gcc/opts-common.cc @@ -1347,6 +1347,8 @@ candidates_list_and_hint (const char *arg, char *&str, const char *candidate; char *p; + gcc_assert (!candidates.is_empty ()); + FOR_EACH_VEC_ELT (candidates, i, candidate) len += strlen (candidate) + 1; -- cgit v1.1 From f9671b60f9395cb1dca128b92f5dd215f5aeaae1 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 27 Jul 2022 12:06:22 +0200 Subject: cgraphunit: Don't emit asm thunks for -dx [PR106261] When -dx option is used (didn't know we have it and no idea what is it useful for), we just expand functions to RTL and then omit all further RTL passes, so the normal functions aren't actually emitted into assembly, just variables. The following testcase ICEs, because we don't emit the methods, but do emit thunks pointing to that and those thunks have unwind info and rely on at least some real functions to be emitted (which is normally the case, thunks are only emitted for locally defined functions) because otherwise there are no CIEs, only FDEs and dwarf2out is upset about it. The following patch fixes that by not emitting assembly thunks for -dx either. 2022-07-27 Jakub Jelinek PR debug/106261 * cgraphunit.cc (cgraph_node::assemble_thunks_and_aliases): Don't output asm thunks for -dx. * g++.dg/debug/pr106261.C: New test. --- gcc/cgraphunit.cc | 2 +- gcc/testsuite/g++.dg/debug/pr106261.C | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/debug/pr106261.C (limited to 'gcc') diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc index 836e759..7b5be0f 100644 --- a/gcc/cgraphunit.cc +++ b/gcc/cgraphunit.cc @@ -1753,7 +1753,7 @@ cgraph_node::assemble_thunks_and_aliases (void) cgraph_node *thunk = e->caller; e = e->next_caller; - expand_thunk (thunk, true, false); + expand_thunk (thunk, !rtl_dump_and_exit, false); thunk->assemble_thunks_and_aliases (); } else diff --git a/gcc/testsuite/g++.dg/debug/pr106261.C b/gcc/testsuite/g++.dg/debug/pr106261.C new file mode 100644 index 0000000..6dee7e6 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr106261.C @@ -0,0 +1,36 @@ +// PR debug/106261 +// { dg-do compile } +// { dg-options "-dx -fno-dwarf2-cfi-asm" } + +struct A +{ + virtual void foo (); + int a; +}; +class C : virtual public A +{ +}; +struct B +{ + A *b; + + B (A *x) : b (x) { b->foo (); } +}; +struct E +{ + virtual ~E (); +}; +class D : public C, E +{ +}; +struct F : D +{ + F (int); + + static void bar () + { + F a (0); + B b (&a); + } +}; +void baz () { F::bar (); } -- cgit v1.1 From 98cf74a2ad893d26de81911e571b634a282a61aa Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Wed, 27 Jul 2022 11:09:42 +0100 Subject: RISC-V: Add RTX costs for `if_then_else' expressions Fix a performance regression from commit 391500af1932 ("Do not ignore costs of jump insns in combine."), a part of the m68k series for MODE_CC conversion (), observed in soft-fp code in libgcc used by some of the embench-iot benchmarks. The immediate origin of the regression is the middle end, which in the absence of cost information from the backend estimates the cost of an RTL expression by assuming a single machine instruction for each of the expression's subexpression. So for `if_then_else', which takes 3 operands, the estimated cost is 3 instructions (i.e. 12 units) even though a branch instruction evaluates it in a single machine cycle (ignoring the cost of actually taking the branch of course, which is handled elsewhere). Consequently an insn sequence like: (insn 595 594 596 43 (set (reg:DI 305) (lshiftrt:DI (reg/v:DI 160 [ R_f ]) (const_int 55 [0x37]))) ".../libgcc/soft-fp/adddf3.c":46:3 216 {lshrdi3} (nil)) (insn 596 595 597 43 (set (reg:DI 304) (and:DI (reg:DI 305) (const_int 1 [0x1]))) ".../libgcc/soft-fp/adddf3.c":46:3 109 {anddi3} (expr_list:REG_DEAD (reg:DI 305) (nil))) (jump_insn 597 596 598 43 (set (pc) (if_then_else (eq (reg:DI 304) (const_int 0 [0])) (label_ref:DI 1644) (pc))) ".../libgcc/soft-fp/adddf3.c":46:3 237 {*branchdi} (expr_list:REG_DEAD (reg:DI 304) (int_list:REG_BR_PROB 536870916 (nil))) -> 1644) does not (anymore, as from the commit referred) get combined into: (note 595 594 596 43 NOTE_INSN_DELETED) (note 596 595 597 43 NOTE_INSN_DELETED) (jump_insn 597 596 598 43 (parallel [ (set (pc) (if_then_else (eq (zero_extract:DI (reg/v:DI 160 [ R_f ]) (const_int 1 [0x1]) (const_int 55 [0x37])) (const_int 0 [0])) (label_ref:DI 1644) (pc))) (clobber (scratch:DI)) ]) ".../libgcc/soft-fp/adddf3.c":46:3 243 {*branch_on_bitdi} (int_list:REG_BR_PROB 536870916 (nil)) -> 1644) This is because the new cost is incorrectly calculated as 28 units while the cost of the original 3 instructions was 24: rejecting combination of insns 595, 596 and 597 original costs 4 + 4 + 16 = 24 replacement cost 28 Before the commit referred the cost of jump instruction was ignored and considered 0 (i.e. unknown) and a sequence of instructions of a known cost used to win: allowing combination of insns 595, 596 and 597 original costs 4 + 4 + 0 = 0 replacement cost 28 Add the missing costs for the 3 variants of `if_then_else' expressions we currently define in the backend. With the fix in place the cost of this particular `if_then_else' pattern is 2 instructions or 8 units (because of the shift operation) and therefore the ultimate cost of the original 3 RTL insns will work out at 16 units (4 + 4 + 8), however the replacement single RTL insn will cost 8 units only. gcc/ * config/riscv/riscv.cc (riscv_rtx_costs) : New case. --- gcc/config/riscv/riscv.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'gcc') diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 2e83ca0..5a0adff 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -1853,6 +1853,33 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN /* Otherwise use the default handling. */ return false; + case IF_THEN_ELSE: + if (TARGET_SFB_ALU + && register_operand (XEXP (x, 1), mode) + && sfb_alu_operand (XEXP (x, 2), mode) + && comparison_operator (XEXP (x, 0), VOIDmode)) + { + /* For predicated conditional-move operations we assume the cost + of a single instruction even though there are actually two. */ + *total = COSTS_N_INSNS (1); + return true; + } + else if (LABEL_REF_P (XEXP (x, 1)) && XEXP (x, 2) == pc_rtx) + { + if (equality_operator (XEXP (x, 0), mode) + && GET_CODE (XEXP (XEXP (x, 0), 0)) == ZERO_EXTRACT) + { + *total = COSTS_N_INSNS (SINGLE_SHIFT_COST + 1); + return true; + } + if (order_operator (XEXP (x, 0), mode)) + { + *total = COSTS_N_INSNS (1); + return true; + } + } + return false; + case NOT: *total = COSTS_N_INSNS (GET_MODE_SIZE (mode) > UNITS_PER_WORD ? 2 : 1); return false; -- cgit v1.1 From 3cf07cc5e51c833f39f5bad5ca6fbe23c853a214 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Wed, 27 Jul 2022 11:09:43 +0100 Subject: RISC-V: Remove duplicate backslashes from `stack_protect_set_' Remove redundant duplicate backslash characters from \t sequences in the output pattern of the `stack_protect_set_' RTL insn. gcc/ * config/riscv/riscv.md (stack_protect_set_): Remove duplicate backslashes. --- gcc/config/riscv/riscv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index 308b64d..aa43d5f 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -2848,7 +2848,7 @@ UNSPEC_SSP_SET)) (set (match_scratch:GPR 2 "=&r") (const_int 0))] "" - "\\t%2, %1\;\\t%2, %0\;li\t%2, 0" + "\t%2, %1\;\t%2, %0\;li\t%2, 0" [(set_attr "length" "12")]) (define_expand "stack_protect_test" -- cgit v1.1 From c2481a6bb70a23a9e279c4f23cf76671afca2145 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Wed, 27 Jul 2022 15:01:17 +0800 Subject: LoongArch: document -m[no-]explicit-relocs gcc/ChangeLog: * doc/invoke.texi: Document -m[no-]explicit-relocs for LoongArch. --- gcc/doc/invoke.texi | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc') diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 9a3f2d1..fa23fbe 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -24939,6 +24939,19 @@ global symbol: The data got table must be within +/-8EiB addressing space. @end itemize @end table The default code model is @code{normal}. + +@item -mexplicit-relocs +@itemx -mno-explicit-relocs +@opindex mexplicit-relocs +@opindex mno-explicit-relocs +Use or do not use assembler relocation operators when dealing with symbolic +addresses. The alternative is to use assembler macros instead, which may +limit optimization. The default value for the option is determined during +GCC build-time by detecting corresponding assembler support: +@code{-mexplicit-relocs} if said support is present, +@code{-mno-explicit-relocs} otherwise. This option is mostly useful for +debugging, or interoperation with assemblers different from the build-time +one. @end table @node M32C Options -- cgit v1.1 From 0f82c0ea8d86ee3bb404c460a04ff2ccfb56d2a0 Mon Sep 17 00:00:00 2001 From: Immad Mir Date: Wed, 27 Jul 2022 19:16:36 +0530 Subject: analyzer: add get_meaning_for_state_change vfunc to fd_diagnostic in sm-fd.cc [PR106286] This patch adds get_meaning_for_state_change vfunc to fd_diagnostic in sm-fd.cc which could be used by SARIF output. Lightly tested on x86_64 Linux. gcc/analyzer/ChangeLog: PR analyzer/106286 * sm-fd.cc: (fd_diagnostic::get_meaning_for_state_change): New. gcc/testsuite/ChangeLog: PR analyzer/106286 * gcc.dg/analyzer/fd-meaning.c: New test. Signed-off-by: Immad Mir --- gcc/analyzer/sm-fd.cc | 14 +++++++++++ gcc/testsuite/gcc.dg/analyzer/fd-meaning.c | 37 ++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/analyzer/fd-meaning.c (limited to 'gcc') diff --git a/gcc/analyzer/sm-fd.cc b/gcc/analyzer/sm-fd.cc index 56b0063..ed923ad 100644 --- a/gcc/analyzer/sm-fd.cc +++ b/gcc/analyzer/sm-fd.cc @@ -229,6 +229,20 @@ public: return label_text (); } + diagnostic_event::meaning + get_meaning_for_state_change ( + const evdesc::state_change &change) const final override + { + if (change.m_old_state == m_sm.get_start_state () + && (m_sm.is_unchecked_fd_p (change.m_new_state))) + return diagnostic_event::meaning (diagnostic_event::VERB_acquire, + diagnostic_event::NOUN_resource); + if (change.m_new_state == m_sm.m_closed) + return diagnostic_event::meaning (diagnostic_event::VERB_release, + diagnostic_event::NOUN_resource); + return diagnostic_event::meaning (); + } + protected: const fd_state_machine &m_sm; tree m_arg; diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-meaning.c b/gcc/testsuite/gcc.dg/analyzer/fd-meaning.c new file mode 100644 index 0000000..6a9ec92 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/fd-meaning.c @@ -0,0 +1,37 @@ + /* { dg-additional-options "-fanalyzer-verbose-state-changes" } */ +int open(const char *, int mode); +void close(int fd); + +#define O_RDONLY 0 +#define O_WRONLY 1 +#define O_RDWR 2 + +void test_1 (const char* path) +{ + int fd = open (path, O_RDWR); /* { dg-message "meaning: \\{verb: 'acquire', noun: 'resource'\\}" } */ + if (fd != -1) + { + close(fd); /* { dg-message "meaning: \\{verb: 'release', noun: 'resource'\\}" } */ + close(fd); /* { dg-warning "double 'close' of file descriptor 'fd' \\\[CWE-1341\\\]" } */ + } +} + +void test_2 (const char* path) +{ + int fd = open (path, O_RDONLY); /* { dg-message "meaning: \\{verb: 'acquire', noun: 'resource'\\}" } */ + if (fd != -1) + { + close(fd); /* { dg-message "meaning: \\{verb: 'release', noun: 'resource'\\}" } */ + close(fd); /* { dg-warning "double 'close' of file descriptor 'fd' \\\[CWE-1341\\\]" } */ + } +} + +void test_3 (const char* path) +{ + int fd = open (path, O_WRONLY); /* { dg-message "meaning: \\{verb: 'acquire', noun: 'resource'\\}" } */ + if (fd != -1) + { + close(fd); /* { dg-message "meaning: \\{verb: 'release', noun: 'resource'\\}" } */ + close(fd); /* { dg-warning "double 'close' of file descriptor 'fd' \\\[CWE-1341\\\]" } */ + } +} \ No newline at end of file -- cgit v1.1 From 5eb9f117a361538834b9740d59219911680717d1 Mon Sep 17 00:00:00 2001 From: Andrew Carlotti Date: Wed, 27 Jul 2022 15:11:51 +0100 Subject: docs: Fix outdated reference to LOOPS_HAVE_MARKED_SINGLE_EXITS gcc/ChangeLog: * doc/loop.texi: Refer to LOOPS_HAVE_RECORDED_EXITS instead. --- gcc/doc/loop.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/doc/loop.texi b/gcc/doc/loop.texi index d7b71a2..6e8657a 100644 --- a/gcc/doc/loop.texi +++ b/gcc/doc/loop.texi @@ -210,7 +210,7 @@ loop in depth-first search order in reversed CFG, ordered by dominance relation, and breath-first search order, respectively. @item @code{single_exit}: Returns the single exit edge of the loop, or @code{NULL} if the loop has more than one exit. You can only use this -function if LOOPS_HAVE_MARKED_SINGLE_EXITS property is used. +function if @code{LOOPS_HAVE_RECORDED_EXITS} is used. @item @code{get_loop_exit_edges}: Enumerates the exit edges of a loop. @item @code{just_once_each_iteration_p}: Returns true if the basic block is executed exactly once during each iteration of a loop (that is, it -- cgit v1.1 From 219f86495791fd27b012678f13e10cada211daab Mon Sep 17 00:00:00 2001 From: Lewis Hyatt Date: Sun, 10 Jul 2022 09:30:29 -0400 Subject: preprocessor: Set input_location to the most recently seen token When preprocessing with -E and -save-temps, input_location points always to the first character of the current file. This was previously irrelevant because nothing was called during the token streaming process that would inspect input_location. But since r13-1544, "#pragma GCC diagnostic" is supported in preprocess-only mode, and that pragma relies on input_location to decide if a given source code location is subject to a diagnostic or not. Most diagnostics work fine anyway, because they are handled as soon as they are seen and so everything is still seen in the expected order even though all the diagnostic pragmas are treated as if they applied at the start of the file. One example that doesn't work correctly is the new testcase, since here the warning is not triggered until the end of the file and so it is necessary to track the location properly. Fixed by setting input_location to point to each token as it is being streamed, similar to how C++ mode sets it. gcc/c-family/ChangeLog: * c-ppoutput.cc (token_streamer::stream): Update input_location prior to streaming each token. gcc/testsuite/ChangeLog: * c-c++-common/pragma-diag-14.c: New test. * c-c++-common/pragma-diag-15.c: New test. --- gcc/c-family/c-ppoutput.cc | 4 ++++ gcc/testsuite/c-c++-common/pragma-diag-14.c | 9 +++++++++ gcc/testsuite/c-c++-common/pragma-diag-15.c | 13 +++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/pragma-diag-14.c create mode 100644 gcc/testsuite/c-c++-common/pragma-diag-15.c (limited to 'gcc') diff --git a/gcc/c-family/c-ppoutput.cc b/gcc/c-family/c-ppoutput.cc index cd38c96..98081cc 100644 --- a/gcc/c-family/c-ppoutput.cc +++ b/gcc/c-family/c-ppoutput.cc @@ -210,6 +210,10 @@ void token_streamer::stream (cpp_reader *pfile, const cpp_token *token, location_t loc) { + /* Keep input_location up to date, since it is needed for processing early + pragmas such as #pragma GCC diagnostic. */ + input_location = loc; + if (token->type == CPP_PADDING) { avoid_paste = true; diff --git a/gcc/testsuite/c-c++-common/pragma-diag-14.c b/gcc/testsuite/c-c++-common/pragma-diag-14.c new file mode 100644 index 0000000..618e7e1 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pragma-diag-14.c @@ -0,0 +1,9 @@ +/* { dg-do preprocess } */ +/* { dg-additional-options "-Wunused-macros" } */ + +/* In the past, the pragma has erroneously disabled the warning because the + location was not tracked properly with -E or -save-temps; check that it works + now. */ + +#define X /* { dg-warning "-:-Wunused-macros" } */ +#pragma GCC diagnostic ignored "-Wunused-macros" diff --git a/gcc/testsuite/c-c++-common/pragma-diag-15.c b/gcc/testsuite/c-c++-common/pragma-diag-15.c new file mode 100644 index 0000000..d8076b4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pragma-diag-15.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wunused-macros" } */ + +/* In the past, the pragma has erroneously disabled the warning because the + location was not tracked properly with -E or -save-temps; check that it works + now. + + This test currently fails for C++ but it's not because of the pragma, it's + because the location of the macro definition is incorrectly set. This is a + separate issue, will resolve it in a later patch. */ + +#define X /* { dg-warning "-:-Wunused-macros" {} { xfail c++ } } */ +#pragma GCC diagnostic ignored "-Wunused-macros" -- cgit v1.1 From 1e2c5f4c2d13346e2181ebe65d2fa84f2184de07 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 28 Jul 2022 00:16:35 +0000 Subject: Daily bump. --- gcc/ChangeLog | 42 ++++++++++++++++++++++++++++++++++++++++++ gcc/DATESTAMP | 2 +- gcc/analyzer/ChangeLog | 6 ++++++ gcc/c-family/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 27 +++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f0963bb..3fc56a6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,45 @@ +2022-07-27 Andrew Carlotti + + * doc/loop.texi: Refer to LOOPS_HAVE_RECORDED_EXITS instead. + +2022-07-27 WANG Xuerui + + * doc/invoke.texi: Document -m[no-]explicit-relocs for + LoongArch. + +2022-07-27 Maciej W. Rozycki + + * config/riscv/riscv.md (stack_protect_set_): Remove + duplicate backslashes. + +2022-07-27 Maciej W. Rozycki + + * config/riscv/riscv.cc (riscv_rtx_costs) : New + case. + +2022-07-27 Jakub Jelinek + + PR debug/106261 + * cgraphunit.cc (cgraph_node::assemble_thunks_and_aliases): Don't + output asm thunks for -dx. + +2022-07-27 Jakub Jelinek + + PR middle-end/106332 + * opts-common.cc (candidates_list_and_hint): Add gcc_assert + that candidates is not an empty vector. + +2022-07-27 Xi Ruoyao + + * configure.ac (HAVE_AS_EXPLICIT_RELOCS): Define to 1 if the + assembler supports explicit relocation for LoongArch. + * configure: Regenerate. + * config/loongarch/loongarch-opts.h (HAVE_AS_EXPLICIT_RELOCS): + Define to 0 if not defined. + * config/loongarch/genopts/loongarch.opt.in + (TARGET_EXPLICIT_RELOCS): Default to HAVE_AS_EXPLICIT_RELOCS. + * config/loongarch/loongarch.opt: Regenerate. + 2022-07-26 Peter Bergner PR c/106016 diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index b7375eb..12a0671 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20220727 +20220728 diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog index 6c883b7..d10a5c8 100644 --- a/gcc/analyzer/ChangeLog +++ b/gcc/analyzer/ChangeLog @@ -1,3 +1,9 @@ +2022-07-27 Immad Mir + + PR analyzer/106286 + * sm-fd.cc: + (fd_diagnostic::get_meaning_for_state_change): New. + 2022-07-26 David Malcolm PR analyzer/106319 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 9e5f83c..73e959d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2022-07-27 Lewis Hyatt + + * c-ppoutput.cc (token_streamer::stream): Update input_location + prior to streaming each token. + 2022-07-23 Immad Mir * c-attribs.cc: (c_common_attribute_table): add three new attributes diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c846ad4..50686c7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,30 @@ +2022-07-27 Lewis Hyatt + + * c-c++-common/pragma-diag-14.c: New test. + * c-c++-common/pragma-diag-15.c: New test. + +2022-07-27 Immad Mir + + PR analyzer/106286 + * gcc.dg/analyzer/fd-meaning.c: New test. + +2022-07-27 Jakub Jelinek + + PR debug/106261 + * g++.dg/debug/pr106261.C: New test. + +2022-07-27 Jakub Jelinek + + PR tree-optimization/94920 + * g++.dg/pr94920.C: Add -Wno-psabi to dg-options. + * g++.dg/pr94920-1.C: Add dg-additional-options -Wno-psabi. + +2022-07-27 Jakub Jelinek + + PR tree-optimization/106397 + * gcc.dg/pr106397.c: For ia32, add dg-additional-options + -march=i686 -msse. + 2022-07-26 David Malcolm PR analyzer/106319 -- cgit v1.1 From ea1a4694e5a1a07a1545338c34b792d9274ecbd1 Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 25 Jul 2022 10:52:56 +0200 Subject: jit,docs: use enum directive for enumeral types gcc/jit/ChangeLog: * docs/conf.py: Add needs_sphinx = '3.0' where c:type was added. * docs/index.rst: Remove note about it. * docs/topics/compilation.rst: Use enum directive and reference. * docs/topics/contexts.rst: Likewise. * docs/topics/expressions.rst: Likewise. * docs/topics/functions.rst: Likewise. --- gcc/jit/docs/conf.py | 3 +++ gcc/jit/docs/index.rst | 7 ------- gcc/jit/docs/topics/compilation.rst | 4 ++-- gcc/jit/docs/topics/contexts.rst | 6 +++--- gcc/jit/docs/topics/expressions.rst | 10 +++++----- gcc/jit/docs/topics/functions.rst | 2 +- 6 files changed, 14 insertions(+), 18 deletions(-) (limited to 'gcc') diff --git a/gcc/jit/docs/conf.py b/gcc/jit/docs/conf.py index 00f0e98..062232a 100644 --- a/gcc/jit/docs/conf.py +++ b/gcc/jit/docs/conf.py @@ -39,6 +39,9 @@ source_suffix = '.rst' # The master toctree document. master_doc = 'index' +# c:type directive is supported since 3.0 +needs_sphinx = '3.0' + # General information about the project. project = u'libgccjit' copyright = u'2014-2022 Free Software Foundation, Inc.' diff --git a/gcc/jit/docs/index.rst b/gcc/jit/docs/index.rst index 3aff17d..21c3140 100644 --- a/gcc/jit/docs/index.rst +++ b/gcc/jit/docs/index.rst @@ -45,10 +45,3 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` - -.. Some notes: - - The Sphinx C domain appears to lack explicit support for enum values, - so I've been using :c:macro: for them. - - See https://sphinx-doc.org/domains.html#the-c-domain diff --git a/gcc/jit/docs/topics/compilation.rst b/gcc/jit/docs/topics/compilation.rst index 9b1eed2..c5fa6eb 100644 --- a/gcc/jit/docs/topics/compilation.rst +++ b/gcc/jit/docs/topics/compilation.rst @@ -158,14 +158,14 @@ For linking in object files, use :c:func:`gcc_jit_context_add_driver_option`. :c:func:`gcc_jit_context_compile_to_file` ignores the suffix of ``output_path``, and insteads uses the given -:c:type:`enum gcc_jit_output_kind` to decide what to do. +:c:enum:`gcc_jit_output_kind` to decide what to do. .. note:: This is different from the ``gcc`` program, which does make use of the suffix of the output file when determining what to do. -.. type:: enum gcc_jit_output_kind +.. enum:: gcc_jit_output_kind The available kinds of output are: diff --git a/gcc/jit/docs/topics/contexts.rst b/gcc/jit/docs/topics/contexts.rst index dfbe968..205b5f3 100644 --- a/gcc/jit/docs/topics/contexts.rst +++ b/gcc/jit/docs/topics/contexts.rst @@ -311,7 +311,7 @@ String Options Set a string option of the context. - .. type:: enum gcc_jit_str_option + .. enum:: gcc_jit_str_option The parameter ``value`` can be NULL. If non-NULL, the call takes a copy of the underlying string, so it is valid to pass in a pointer to @@ -334,7 +334,7 @@ Boolean options Set a boolean option of the context. Zero is "false" (the default), non-zero is "true". - .. type:: enum gcc_jit_bool_option + .. enum:: gcc_jit_bool_option .. macro:: GCC_JIT_BOOL_OPTION_DEBUGINFO @@ -513,7 +513,7 @@ Integer options Set an integer option of the context. - .. type:: enum gcc_jit_int_option + .. enum:: gcc_jit_int_option There is just one integer option specified this way: diff --git a/gcc/jit/docs/topics/expressions.rst b/gcc/jit/docs/topics/expressions.rst index 91ee8a9..49b7e14 100644 --- a/gcc/jit/docs/topics/expressions.rst +++ b/gcc/jit/docs/topics/expressions.rst @@ -309,7 +309,7 @@ Unary Operations The parameter ``result_type`` must be a numeric type. -.. type:: enum gcc_jit_unary_op +.. enum:: gcc_jit_unary_op The available unary operations are: @@ -376,7 +376,7 @@ Binary Operations The parameter ``result_type`` must be a numeric type. -.. type:: enum gcc_jit_binary_op +.. enum:: gcc_jit_binary_op The available binary operations are: @@ -534,7 +534,7 @@ Comparisons Build a boolean rvalue out of the comparison of two other rvalues. -.. type:: enum gcc_jit_comparison +.. enum:: gcc_jit_comparison ======================================= ============ Comparison C equivalent @@ -711,7 +711,7 @@ where the rvalue is computed by reading from the storage area. The "model" parameter determines the thread-local storage model of the "lvalue": - .. type:: enum gcc_jit_tls_model + .. enum:: gcc_jit_tls_model .. c:macro:: GCC_JIT_TLS_MODEL_NONE @@ -841,7 +841,7 @@ Global variables The "kind" parameter determines the visibility of the "global" outside of the :c:type:`gcc_jit_result`: - .. type:: enum gcc_jit_global_kind + .. enum:: gcc_jit_global_kind .. c:macro:: GCC_JIT_GLOBAL_EXPORTED diff --git a/gcc/jit/docs/topics/functions.rst b/gcc/jit/docs/topics/functions.rst index 0845fe0..d6d4fe9 100644 --- a/gcc/jit/docs/topics/functions.rst +++ b/gcc/jit/docs/topics/functions.rst @@ -80,7 +80,7 @@ Functions Create a gcc_jit_function with the given name and parameters. - .. type:: enum gcc_jit_function_kind + .. enum:: gcc_jit_function_kind This enum controls the kind of function created, and has the following values: -- cgit v1.1 From 68c994f9aa8a60e69d080693f0cbef119ab65886 Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 25 Jul 2022 11:03:23 +0200 Subject: jit,docs: replace c:type:`int_type` with :expr:`int_type` Use expression that work fine for basic type. gcc/jit/ChangeLog: * docs/cp/topics/expressions.rst: Use :expr: for basic types. * docs/topics/compilation.rst: Likewise. * docs/topics/expressions.rst: Likewise. * docs/topics/function-pointers.rst: Likewise. --- gcc/jit/docs/cp/topics/expressions.rst | 6 +++--- gcc/jit/docs/topics/compilation.rst | 4 ++-- gcc/jit/docs/topics/expressions.rst | 6 +++--- gcc/jit/docs/topics/function-pointers.rst | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'gcc') diff --git a/gcc/jit/docs/cp/topics/expressions.rst b/gcc/jit/docs/cp/topics/expressions.rst index 239e004..003dbce 100644 --- a/gcc/jit/docs/cp/topics/expressions.rst +++ b/gcc/jit/docs/cp/topics/expressions.rst @@ -57,14 +57,14 @@ Simple expressions int value) const Given a numeric type (integer or floating point), build an rvalue for - the given constant :c:type:`int` value. + the given constant :expr:`int` value. .. function:: gccjit::rvalue \ gccjit::context::new_rvalue (gccjit::type numeric_type, \ long value) const Given a numeric type (integer or floating point), build an rvalue for - the given constant :c:type:`long` value. + the given constant :expr:`long` value. .. function:: gccjit::rvalue \ gccjit::context::zero (gccjit::type numeric_type) const @@ -91,7 +91,7 @@ Simple expressions double value) const Given a numeric type (integer or floating point), build an rvalue for - the given constant :c:type:`double` value. + the given constant :expr:`double` value. .. function:: gccjit::rvalue \ gccjit::context::new_rvalue (gccjit::type pointer_type, \ diff --git a/gcc/jit/docs/topics/compilation.rst b/gcc/jit/docs/topics/compilation.rst index c5fa6eb..91b9c25 100644 --- a/gcc/jit/docs/topics/compilation.rst +++ b/gcc/jit/docs/topics/compilation.rst @@ -98,8 +98,8 @@ In-memory compilation If the global is found, the result will need to be cast to a pointer of the correct type before it can be called. - This is a *pointer* to the global, so e.g. for an :c:type:`int` this is - an :c:type:`int *`. + This is a *pointer* to the global, so e.g. for an :expr:`int` this is + an :expr:`int *`. For example, given an ``int foo;`` created this way: diff --git a/gcc/jit/docs/topics/expressions.rst b/gcc/jit/docs/topics/expressions.rst index 49b7e14..00e2ec8 100644 --- a/gcc/jit/docs/topics/expressions.rst +++ b/gcc/jit/docs/topics/expressions.rst @@ -60,7 +60,7 @@ Simple expressions int value) Given a numeric type (integer or floating point), build an rvalue for - the given constant :c:type:`int` value. + the given constant :expr:`int` value. .. function:: gcc_jit_rvalue *\ gcc_jit_context_new_rvalue_from_long (gcc_jit_context *ctxt, \ @@ -68,7 +68,7 @@ Simple expressions long value) Given a numeric type (integer or floating point), build an rvalue for - the given constant :c:type:`long` value. + the given constant :expr:`long` value. .. function:: gcc_jit_rvalue *gcc_jit_context_zero (gcc_jit_context *ctxt, \ gcc_jit_type *numeric_type) @@ -96,7 +96,7 @@ Simple expressions double value) Given a numeric type (integer or floating point), build an rvalue for - the given constant :c:type:`double` value. + the given constant :expr:`double` value. .. function:: gcc_jit_rvalue *\ gcc_jit_context_new_rvalue_from_ptr (gcc_jit_context *ctxt, \ diff --git a/gcc/jit/docs/topics/function-pointers.rst b/gcc/jit/docs/topics/function-pointers.rst index e6f9970..dde4921 100644 --- a/gcc/jit/docs/topics/function-pointers.rst +++ b/gcc/jit/docs/topics/function-pointers.rst @@ -48,7 +48,7 @@ to it in :c:type:`gcc_jit_rvalue` form using type obtained using :c:func:`gcc_jit_context_new_function_ptr_type`. Here's an example of creating a function pointer type corresponding to C's -:c:type:`void (*) (int, int, int)`: +:expr:`void (*) (int, int, int)`: .. code-block:: c -- cgit v1.1 From a8a282d5202f3e3305bd5f4b40adc0ce743c9b98 Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 25 Jul 2022 11:15:25 +0200 Subject: jit,docs: various fixes gcc/jit/ChangeLog: * docs/cp/intro/tutorial02.rst: Use proper reference. * docs/cp/topics/contexts.rst: Likewise. * docs/cp/topics/functions.rst: Put `class` directive before a function as it is not allowed declaring a class in a fn. * docs/cp/topics/types.rst: Add template keyword. * docs/examples/tut04-toyvm/toyvm.c (toyvm_function_compile): Add removed comment used for code snippet ending detection. * docs/intro/tutorial04.rst: Fix to match the real comment. --- gcc/jit/docs/cp/intro/tutorial02.rst | 2 +- gcc/jit/docs/cp/topics/contexts.rst | 2 +- gcc/jit/docs/cp/topics/functions.rst | 46 +++++++++++++++---------------- gcc/jit/docs/cp/topics/types.rst | 2 +- gcc/jit/docs/examples/tut04-toyvm/toyvm.c | 1 + gcc/jit/docs/intro/tutorial04.rst | 2 +- 6 files changed, 28 insertions(+), 27 deletions(-) (limited to 'gcc') diff --git a/gcc/jit/docs/cp/intro/tutorial02.rst b/gcc/jit/docs/cp/intro/tutorial02.rst index 2064f8e..55675cc 100644 --- a/gcc/jit/docs/cp/intro/tutorial02.rst +++ b/gcc/jit/docs/cp/intro/tutorial02.rst @@ -121,7 +121,7 @@ in this case just one: params.push_back (param_i); Now we can create the function, using -:c:func:`gccjit::context::new_function`: +:cpp:func:`gccjit::context::new_function`: .. code-block:: c++ diff --git a/gcc/jit/docs/cp/topics/contexts.rst b/gcc/jit/docs/cp/topics/contexts.rst index e5bccfb..f60f210 100644 --- a/gcc/jit/docs/cp/topics/contexts.rst +++ b/gcc/jit/docs/cp/topics/contexts.rst @@ -141,7 +141,7 @@ Debugging If "update_locations" is true, then also set up :class:`gccjit::location` information throughout the context, pointing at the dump file as if it were a source file. This may be of use in conjunction with - :c:macro:`GCCJIT::BOOL_OPTION_DEBUGINFO` to allow stepping through the + :c:macro:`GCC_JIT_BOOL_OPTION_DEBUGINFO` to allow stepping through the code in a debugger. .. function:: void\ diff --git a/gcc/jit/docs/cp/topics/functions.rst b/gcc/jit/docs/cp/topics/functions.rst index 0e266ab..4e325ac 100644 --- a/gcc/jit/docs/cp/topics/functions.rst +++ b/gcc/jit/docs/cp/topics/functions.rst @@ -243,6 +243,29 @@ Statements return; +.. class:: gccjit::case_ + + A `gccjit::case_` represents a case within a switch statement, and + is created within a particular :class:`gccjit::context` using + :func:`gccjit::context::new_case`. It is a subclass of + :class:`gccjit::object`. + + Each case expresses a multivalued range of integer values. You + can express single-valued cases by passing in the same value for + both `min_value` and `max_value`. + +.. function:: gccjit::case_ *\ + gccjit::context::new_case (gccjit::rvalue min_value,\ + gccjit::rvalue max_value,\ + gccjit::block dest_block) + + Create a new gccjit::case for use in a switch statement. + `min_value` and `max_value` must be constants of an integer type, + which must match that of the expression of the switch statement. + + `dest_block` must be within the same function as the switch + statement. + .. function:: void\ gccjit::block::end_with_switch (gccjit::rvalue expr,\ gccjit::block default_block,\ @@ -292,29 +315,6 @@ Statements #ifdef LIBGCCJIT_HAVE_SWITCH_STATEMENTS - .. class:: gccjit::case_ - - A `gccjit::case_` represents a case within a switch statement, and - is created within a particular :class:`gccjit::context` using - :func:`gccjit::context::new_case`. It is a subclass of - :class:`gccjit::object`. - - Each case expresses a multivalued range of integer values. You - can express single-valued cases by passing in the same value for - both `min_value` and `max_value`. - - .. function:: gccjit::case_ *\ - gccjit::context::new_case (gccjit::rvalue min_value,\ - gccjit::rvalue max_value,\ - gccjit::block dest_block) - - Create a new gccjit::case for use in a switch statement. - `min_value` and `max_value` must be constants of an integer type, - which must match that of the expression of the switch statement. - - `dest_block` must be within the same function as the switch - statement. - Here's an example of creating a switch statement: .. literalinclude:: ../../../../testsuite/jit.dg/test-switch.cc diff --git a/gcc/jit/docs/cp/topics/types.rst b/gcc/jit/docs/cp/topics/types.rst index c695ceb..5d50a39 100644 --- a/gcc/jit/docs/cp/topics/types.rst +++ b/gcc/jit/docs/cp/topics/types.rst @@ -65,7 +65,7 @@ Standard types Access the integer type of the given size. -.. function:: gccjit::type \ +.. function:: template gccjit::type \ gccjit::context::get_int_type () Access the given integer type. For example, you could map the diff --git a/gcc/jit/docs/examples/tut04-toyvm/toyvm.c b/gcc/jit/docs/examples/tut04-toyvm/toyvm.c index 8334b97..c2333f0 100644 --- a/gcc/jit/docs/examples/tut04-toyvm/toyvm.c +++ b/gcc/jit/docs/examples/tut04-toyvm/toyvm.c @@ -764,6 +764,7 @@ toyvm_function_compile (toyvm_function *fn) toyvm_result->cf_code = (toyvm_compiled_code)gcc_jit_result_get_code (jit_result, funcname); + /* (this leaks "jit_result" and "funcname") */ free (funcname); diff --git a/gcc/jit/docs/intro/tutorial04.rst b/gcc/jit/docs/intro/tutorial04.rst index e1c47a0..8909887 100644 --- a/gcc/jit/docs/intro/tutorial04.rst +++ b/gcc/jit/docs/intro/tutorial04.rst @@ -308,7 +308,7 @@ We can now compile it, and extract machine code from the result: .. literalinclude:: ../examples/tut04-toyvm/toyvm.c :start-after: /* We've now finished populating the context. Compile it. */ - :end-before: /* (this leaks "result" and "funcname") */ + :end-before: /* (this leaks "jit_result" and "funcname") */ :language: c We can now run the result: -- cgit v1.1 From 3c5f312b4477dd8622c3a26f378dad85e72a558e Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 25 Jul 2022 11:51:51 +0200 Subject: jit,docs: compact function declarations gcc/jit/ChangeLog: * docs/cp/topics/expressions.rst: Compact so that the generated output is also more compact. --- gcc/jit/docs/cp/topics/expressions.rst | 42 ++++++++++++---------------------- 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'gcc') diff --git a/gcc/jit/docs/cp/topics/expressions.rst b/gcc/jit/docs/cp/topics/expressions.rst index 003dbce..dec5b47 100644 --- a/gcc/jit/docs/cp/topics/expressions.rst +++ b/gcc/jit/docs/cp/topics/expressions.rst @@ -236,48 +236,39 @@ operation: gccjit::context::new_plus (gccjit::type result_type, \ gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_minus (gccjit::type result_type, \ gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_mult (gccjit::type result_type, \ gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_divide (gccjit::type result_type, \ gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_modulo (gccjit::type result_type, \ gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_bitwise_and (gccjit::type result_type, \ gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_bitwise_xor (gccjit::type result_type, \ gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_bitwise_or (gccjit::type result_type, \ gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_logical_and (gccjit::type result_type, \ gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_logical_or (gccjit::type result_type, \ gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) @@ -375,24 +366,19 @@ operation: .. function:: gccjit::rvalue \ gccjit::context::new_eq (gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_ne (gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_lt (gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_le (gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_gt (gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) - -.. function:: gccjit::rvalue \ + gccjit::rvalue \ gccjit::context::new_ge (gccjit::rvalue a, gccjit::rvalue b, \ gccjit::location loc) -- cgit v1.1 From 85cf5a23772ee14b1b19320f19a4749f874854d7 Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 25 Jul 2022 12:35:26 +0200 Subject: jit,docs: use list-table instead of fixed table Use rather list-table that is easible to maintainer and one does not have to wrap lines. Moreover, it provides great attribute :widths: that correctly works (tested for HTML and PDF). gcc/jit/ChangeLog: * docs/cp/intro/tutorial04.rst: Use list-table. * docs/intro/tutorial04.rst: Likewise. * docs/intro/tutorial05.rst: Likewise. * docs/topics/compilation.rst: Likewise. * docs/topics/expressions.rst: Likewise. * docs/topics/types.rst: Likewise. --- gcc/jit/docs/cp/intro/tutorial04.rst | 73 +++++++++++++++-------- gcc/jit/docs/intro/tutorial04.rst | 73 +++++++++++++++-------- gcc/jit/docs/intro/tutorial05.rst | 37 ++++++++---- gcc/jit/docs/topics/compilation.rst | 22 ++++--- gcc/jit/docs/topics/expressions.rst | 97 +++++++++++++++++++----------- gcc/jit/docs/topics/types.rst | 111 +++++++++++++++++++++++------------ 6 files changed, 270 insertions(+), 143 deletions(-) (limited to 'gcc') diff --git a/gcc/jit/docs/cp/intro/tutorial04.rst b/gcc/jit/docs/cp/intro/tutorial04.rst index 45198ce..66dcce9 100644 --- a/gcc/jit/docs/cp/intro/tutorial04.rst +++ b/gcc/jit/docs/cp/intro/tutorial04.rst @@ -50,30 +50,55 @@ Naturally, a real interpreter would be much more complicated that this. The following operations are supported: -====================== ======================== =============== ============== -Operation Meaning Old Stack New Stack -====================== ======================== =============== ============== -DUP Duplicate top of stack. ``[..., x]`` ``[..., x, x]`` -ROT Swap top two elements ``[..., x, y]`` ``[..., y, x]`` - of stack. -BINARY_ADD Add the top two elements ``[..., x, y]`` ``[..., (x+y)]`` - on the stack. -BINARY_SUBTRACT Likewise, but subtract. ``[..., x, y]`` ``[..., (x-y)]`` -BINARY_MULT Likewise, but multiply. ``[..., x, y]`` ``[..., (x*y)]`` -BINARY_COMPARE_LT Compare the top two ``[..., x, y]`` ``[..., (x`` ``idx += 1`` -``<`` ``idx -= 1`` -``+`` ``data[idx] += 1`` -``-`` ``data[idx] -= 1`` -``.`` ``output (data[idx])`` -``,`` ``data[idx] = input ()`` -``[`` loop until ``data[idx] == 0`` -``]`` end of loop -Anything else ignored -====================== ============================= +.. list-table:: + :header-rows: 1 + + * - Character + - Meaning + + * - ``>`` + - ``idx += 1`` + * - ``<`` + - ``idx -= 1`` + * - ``+`` + - ``data[idx] += 1`` + * - ``-`` + - ``data[idx] -= 1`` + * - ``.`` + - ``output (data[idx])`` + * - ``,`` + - ``data[idx] = input ()`` + * - ``[`` + - loop until ``data[idx] == 0`` + * - ``]`` + - end of loop + * - Anything else + - ignored Unlike the previous example, we'll implement an ahead-of-time compiler, which reads ``.bf`` scripts and outputs executables (though it would diff --git a/gcc/jit/docs/topics/compilation.rst b/gcc/jit/docs/topics/compilation.rst index 91b9c25..adcde8d 100644 --- a/gcc/jit/docs/topics/compilation.rst +++ b/gcc/jit/docs/topics/compilation.rst @@ -169,14 +169,20 @@ For linking in object files, use :c:func:`gcc_jit_context_add_driver_option`. The available kinds of output are: -============================================== ============== -Output kind Typical suffix -============================================== ============== -:c:macro:`GCC_JIT_OUTPUT_KIND_ASSEMBLER` .s -:c:macro:`GCC_JIT_OUTPUT_KIND_OBJECT_FILE` .o -:c:macro:`GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY` .so or .dll -:c:macro:`GCC_JIT_OUTPUT_KIND_EXECUTABLE` None, or .exe -============================================== ============== +.. list-table:: + :header-rows: 1 + + * - Output kind + - Typical suffix + + * - :c:macro:`GCC_JIT_OUTPUT_KIND_ASSEMBLER` + - .s + * - :c:macro:`GCC_JIT_OUTPUT_KIND_OBJECT_FILE` + - .o + * - :c:macro:`GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY` + - .so or .dll + * - :c:macro:`GCC_JIT_OUTPUT_KIND_EXECUTABLE` + - None, or .exe .. c:macro:: GCC_JIT_OUTPUT_KIND_ASSEMBLER diff --git a/gcc/jit/docs/topics/expressions.rst b/gcc/jit/docs/topics/expressions.rst index 00e2ec8..ff1eec8 100644 --- a/gcc/jit/docs/topics/expressions.rst +++ b/gcc/jit/docs/topics/expressions.rst @@ -313,14 +313,20 @@ Unary Operations The available unary operations are: -========================================== ============ -Unary Operation C equivalent -========================================== ============ -:c:macro:`GCC_JIT_UNARY_OP_MINUS` `-(EXPR)` -:c:macro:`GCC_JIT_UNARY_OP_BITWISE_NEGATE` `~(EXPR)` -:c:macro:`GCC_JIT_UNARY_OP_LOGICAL_NEGATE` `!(EXPR)` -:c:macro:`GCC_JIT_UNARY_OP_ABS` `abs (EXPR)` -========================================== ============ +.. list-table:: + :header-rows: 1 + + * - Unary Operation + - C equivalent + + * - :c:macro:`GCC_JIT_UNARY_OP_MINUS` + - `-(EXPR)` + * - :c:macro:`GCC_JIT_UNARY_OP_BITWISE_NEGATE` + - `~(EXPR)` + * - :c:macro:`GCC_JIT_UNARY_OP_LOGICAL_NEGATE` + - `!(EXPR)` + * - :c:macro:`GCC_JIT_UNARY_OP_ABS` + - `abs (EXPR)` .. c:macro:: GCC_JIT_UNARY_OP_MINUS @@ -380,22 +386,36 @@ Binary Operations The available binary operations are: -======================================== ============ -Binary Operation C equivalent -======================================== ============ -:c:macro:`GCC_JIT_BINARY_OP_PLUS` `x + y` -:c:macro:`GCC_JIT_BINARY_OP_MINUS` `x - y` -:c:macro:`GCC_JIT_BINARY_OP_MULT` `x * y` -:c:macro:`GCC_JIT_BINARY_OP_DIVIDE` `x / y` -:c:macro:`GCC_JIT_BINARY_OP_MODULO` `x % y` -:c:macro:`GCC_JIT_BINARY_OP_BITWISE_AND` `x & y` -:c:macro:`GCC_JIT_BINARY_OP_BITWISE_XOR` `x ^ y` -:c:macro:`GCC_JIT_BINARY_OP_BITWISE_OR` `x | y` -:c:macro:`GCC_JIT_BINARY_OP_LOGICAL_AND` `x && y` -:c:macro:`GCC_JIT_BINARY_OP_LOGICAL_OR` `x || y` -:c:macro:`GCC_JIT_BINARY_OP_LSHIFT` `x << y` -:c:macro:`GCC_JIT_BINARY_OP_RSHIFT` `x >> y` -======================================== ============ +.. list-table:: + :header-rows: 1 + + * - Binary Operation + - C equivalent + + * - :c:macro:`GCC_JIT_BINARY_OP_PLUS` + - `x + y` + * - :c:macro:`GCC_JIT_BINARY_OP_MINUS` + - `x - y` + * - :c:macro:`GCC_JIT_BINARY_OP_MULT` + - `x * y` + * - :c:macro:`GCC_JIT_BINARY_OP_DIVIDE` + - `x / y` + * - :c:macro:`GCC_JIT_BINARY_OP_MODULO` + - `x % y` + * - :c:macro:`GCC_JIT_BINARY_OP_BITWISE_AND` + - `x & y` + * - :c:macro:`GCC_JIT_BINARY_OP_BITWISE_XOR` + - `x ^ y` + * - :c:macro:`GCC_JIT_BINARY_OP_BITWISE_OR` + - `x | y` + * - :c:macro:`GCC_JIT_BINARY_OP_LOGICAL_AND` + - `x && y` + * - :c:macro:`GCC_JIT_BINARY_OP_LOGICAL_OR` + - `x || y` + * - :c:macro:`GCC_JIT_BINARY_OP_LSHIFT` + - `x << y` + * - :c:macro:`GCC_JIT_BINARY_OP_RSHIFT` + - `x >> y` .. c:macro:: GCC_JIT_BINARY_OP_PLUS @@ -536,17 +556,24 @@ Comparisons .. enum:: gcc_jit_comparison -======================================= ============ -Comparison C equivalent -======================================= ============ -:c:macro:`GCC_JIT_COMPARISON_EQ` `x == y` -:c:macro:`GCC_JIT_COMPARISON_NE` `x != y` -:c:macro:`GCC_JIT_COMPARISON_LT` `x < y` -:c:macro:`GCC_JIT_COMPARISON_LE` `x <= y` -:c:macro:`GCC_JIT_COMPARISON_GT` `x > y` -:c:macro:`GCC_JIT_COMPARISON_GE` `x >= y` -======================================= ============ - +.. list-table:: + :header-rows: 1 + + * - Comparison + - C equivalent + + * - :c:macro:`GCC_JIT_COMPARISON_EQ` + - `x == y` + * - :c:macro:`GCC_JIT_COMPARISON_NE` + - `x != y` + * - :c:macro:`GCC_JIT_COMPARISON_LT` + - `x < y` + * - :c:macro:`GCC_JIT_COMPARISON_LE` + - `x <= y` + * - :c:macro:`GCC_JIT_COMPARISON_GT` + - `x > y` + * - :c:macro:`GCC_JIT_COMPARISON_GE` + - `x >= y` Function calls ************** diff --git a/gcc/jit/docs/topics/types.rst b/gcc/jit/docs/topics/types.rst index db7fac6..457b362 100644 --- a/gcc/jit/docs/topics/types.rst +++ b/gcc/jit/docs/topics/types.rst @@ -57,45 +57,78 @@ Standard types Access a specific type. The available types are: - ========================================== ================================ - `enum gcc_jit_types` value Meaning - ========================================== ================================ - :c:data:`GCC_JIT_TYPE_VOID` C's ``void`` type. - :c:data:`GCC_JIT_TYPE_VOID_PTR` C's ``void *``. - :c:data:`GCC_JIT_TYPE_BOOL` C++'s ``bool`` type; also C99's - ``_Bool`` type, aka ``bool`` if - using stdbool.h. - :c:data:`GCC_JIT_TYPE_CHAR` C's ``char`` (of some signedness) - :c:data:`GCC_JIT_TYPE_SIGNED_CHAR` C's ``signed char`` - :c:data:`GCC_JIT_TYPE_UNSIGNED_CHAR` C's ``unsigned char`` - :c:data:`GCC_JIT_TYPE_SHORT` C's ``short`` (signed) - :c:data:`GCC_JIT_TYPE_UNSIGNED_SHORT` C's ``unsigned short`` - :c:data:`GCC_JIT_TYPE_INT` C's ``int`` (signed) - :c:data:`GCC_JIT_TYPE_UNSIGNED_INT` C's ``unsigned int`` - :c:data:`GCC_JIT_TYPE_LONG` C's ``long`` (signed) - :c:data:`GCC_JIT_TYPE_UNSIGNED_LONG` C's ``unsigned long`` - :c:data:`GCC_JIT_TYPE_LONG_LONG` C99's ``long long`` (signed) - :c:data:`GCC_JIT_TYPE_UNSIGNED_LONG_LONG` C99's ``unsigned long long`` - :c:data:`GCC_JIT_TYPE_UINT8_T` C99's ``uint8_t`` - :c:data:`GCC_JIT_TYPE_UINT16_T` C99's ``uint16_t`` - :c:data:`GCC_JIT_TYPE_UINT32_T` C99's ``uint32_t`` - :c:data:`GCC_JIT_TYPE_UINT64_T` C99's ``uint64_t`` - :c:data:`GCC_JIT_TYPE_UINT128_T` C99's ``__uint128_t`` - :c:data:`GCC_JIT_TYPE_INT8_T` C99's ``int8_t`` - :c:data:`GCC_JIT_TYPE_INT16_T` C99's ``int16_t`` - :c:data:`GCC_JIT_TYPE_INT32_T` C99's ``int32_t`` - :c:data:`GCC_JIT_TYPE_INT64_T` C99's ``int64_t`` - :c:data:`GCC_JIT_TYPE_INT128_T` C99's ``__int128_t`` - :c:data:`GCC_JIT_TYPE_FLOAT` - :c:data:`GCC_JIT_TYPE_DOUBLE` - :c:data:`GCC_JIT_TYPE_LONG_DOUBLE` - :c:data:`GCC_JIT_TYPE_CONST_CHAR_PTR` C type: ``(const char *)`` - :c:data:`GCC_JIT_TYPE_SIZE_T` C's ``size_t`` type - :c:data:`GCC_JIT_TYPE_FILE_PTR` C type: ``(FILE *)`` - :c:data:`GCC_JIT_TYPE_COMPLEX_FLOAT` C99's ``_Complex float`` - :c:data:`GCC_JIT_TYPE_COMPLEX_DOUBLE` C99's ``_Complex double`` - :c:data:`GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE` C99's ``_Complex long double`` - ========================================== ================================ + .. list-table:: + :header-rows: 1 + + * - `enum gcc_jit_types` value + - Meaning + + * - :c:data:`GCC_JIT_TYPE_VOID` + - C's ``void`` type. + * - :c:data:`GCC_JIT_TYPE_VOID_PTR` + - C's ``void *``. + * - :c:data:`GCC_JIT_TYPE_BOOL` + - C++'s ``bool`` type; also C99's ``_Bool`` type, aka ``bool`` if using stdbool.h. + * - :c:data:`GCC_JIT_TYPE_CHAR` + - C's ``char`` (of some signedness) + * - :c:data:`GCC_JIT_TYPE_SIGNED_CHAR` + - C's ``signed char`` + * - :c:data:`GCC_JIT_TYPE_UNSIGNED_CHAR` + - C's ``unsigned char`` + * - :c:data:`GCC_JIT_TYPE_SHORT` + - C's ``short`` (signed) + * - :c:data:`GCC_JIT_TYPE_UNSIGNED_SHORT` + - C's ``unsigned short`` + * - :c:data:`GCC_JIT_TYPE_INT` + - C's ``int`` (signed) + * - :c:data:`GCC_JIT_TYPE_UNSIGNED_INT` + - C's ``unsigned int`` + * - :c:data:`GCC_JIT_TYPE_LONG` + - C's ``long`` (signed) + * - :c:data:`GCC_JIT_TYPE_UNSIGNED_LONG` + - C's ``unsigned long`` + * - :c:data:`GCC_JIT_TYPE_LONG_LONG` + - C99's ``long long`` (signed) + * - :c:data:`GCC_JIT_TYPE_UNSIGNED_LONG_LONG` + - C99's ``unsigned long long`` + * - :c:data:`GCC_JIT_TYPE_UINT8_T` + - C99's ``uint8_t`` + * - :c:data:`GCC_JIT_TYPE_UINT16_T` + - C99's ``uint16_t`` + * - :c:data:`GCC_JIT_TYPE_UINT32_T` + - C99's ``uint32_t`` + * - :c:data:`GCC_JIT_TYPE_UINT64_T` + - C99's ``uint64_t`` + * - :c:data:`GCC_JIT_TYPE_UINT128_T` + - C99's ``__uint128_t`` + * - :c:data:`GCC_JIT_TYPE_INT8_T` + - C99's ``int8_t`` + * - :c:data:`GCC_JIT_TYPE_INT16_T` + - C99's ``int16_t`` + * - :c:data:`GCC_JIT_TYPE_INT32_T` + - C99's ``int32_t`` + * - :c:data:`GCC_JIT_TYPE_INT64_T` + - C99's ``int64_t`` + * - :c:data:`GCC_JIT_TYPE_INT128_T` + - C99's ``__int128_t`` + * - :c:data:`GCC_JIT_TYPE_FLOAT` + - + * - :c:data:`GCC_JIT_TYPE_DOUBLE` + - + * - :c:data:`GCC_JIT_TYPE_LONG_DOUBLE` + - + * - :c:data:`GCC_JIT_TYPE_CONST_CHAR_PTR` + - C type: ``(const char *)`` + * - :c:data:`GCC_JIT_TYPE_SIZE_T` + - C's ``size_t`` type + * - :c:data:`GCC_JIT_TYPE_FILE_PTR` + - C type: ``(FILE *)`` + * - :c:data:`GCC_JIT_TYPE_COMPLEX_FLOAT` + - C99's ``_Complex float`` + * - :c:data:`GCC_JIT_TYPE_COMPLEX_DOUBLE` + - C99's ``_Complex double`` + * - :c:data:`GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE` + - C99's ``_Complex long double`` .. function:: gcc_jit_type *\ gcc_jit_context_get_int_type (gcc_jit_context *ctxt, \ -- cgit v1.1 From 85c943f307934c10c6a3890b3a0305ac76a4f41c Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 25 Jul 2022 14:39:46 +0200 Subject: jit,docs: use :expr:`type *` for pointers to a type gcc/jit/ChangeLog: * docs/cp/intro/tutorial02.rst: Use :expr:`type *` for pointers to a type * docs/cp/topics/asm.rst: Likewise. * docs/cp/topics/contexts.rst: Likewise. * docs/cp/topics/expressions.rst: Likewise. * docs/cp/topics/functions.rst: Likewise. * docs/cp/topics/objects.rst: Likewise. * docs/intro/tutorial02.rst: Likewise. * docs/intro/tutorial03.rst: Likewise. * docs/intro/tutorial04.rst: Likewise. * docs/intro/tutorial05.rst: Likewise. * docs/topics/compilation.rst: Likewise. * docs/topics/contexts.rst: Likewise. * docs/topics/objects.rst: Likewise. --- gcc/jit/docs/cp/intro/tutorial02.rst | 4 ++-- gcc/jit/docs/cp/topics/asm.rst | 2 +- gcc/jit/docs/cp/topics/contexts.rst | 6 +++--- gcc/jit/docs/cp/topics/expressions.rst | 4 ++-- gcc/jit/docs/cp/topics/functions.rst | 2 +- gcc/jit/docs/cp/topics/objects.rst | 2 +- gcc/jit/docs/intro/tutorial02.rst | 16 ++++++++-------- gcc/jit/docs/intro/tutorial03.rst | 28 ++++++++++++++-------------- gcc/jit/docs/intro/tutorial04.rst | 2 +- gcc/jit/docs/intro/tutorial05.rst | 4 ++-- gcc/jit/docs/topics/compilation.rst | 8 ++++---- gcc/jit/docs/topics/contexts.rst | 6 +++--- gcc/jit/docs/topics/objects.rst | 6 +++--- 13 files changed, 45 insertions(+), 45 deletions(-) (limited to 'gcc') diff --git a/gcc/jit/docs/cp/intro/tutorial02.rst b/gcc/jit/docs/cp/intro/tutorial02.rst index 55675cc..9f9a7f3 100644 --- a/gcc/jit/docs/cp/intro/tutorial02.rst +++ b/gcc/jit/docs/cp/intro/tutorial02.rst @@ -39,7 +39,7 @@ First we need to include the relevant header: All state associated with compilation is associated with a :type:`gccjit::context`, which is a thin C++ wrapper around the C API's -:c:type:`gcc_jit_context *`. +:c:expr:`gcc_jit_context *`. Create one using :func:`gccjit::context::acquire`: @@ -194,7 +194,7 @@ OK, we've populated the context. We can now compile it using gcc_jit_result *result; result = ctxt.compile (); -and get a :c:type:`gcc_jit_result *`. +and get a :c:expr:`gcc_jit_result *`. We can now use :c:func:`gcc_jit_result_get_code` to look up a specific machine code routine within the result, in this case, the function we diff --git a/gcc/jit/docs/cp/topics/asm.rst b/gcc/jit/docs/cp/topics/asm.rst index f7e4e95..0d63da3 100644 --- a/gcc/jit/docs/cp/topics/asm.rst +++ b/gcc/jit/docs/cp/topics/asm.rst @@ -43,7 +43,7 @@ Adding assembler instructions within a function to outputs. :class:`gccjit::extended_asm` is a subclass of :class:`gccjit::object`. - It is a thin wrapper around the C API's :c:type:`gcc_jit_extended_asm *`. + It is a thin wrapper around the C API's :c:expr:`gcc_jit_extended_asm *`. To avoid having an API entrypoint with a very large number of parameters, an extended ``asm`` statement is made in stages: diff --git a/gcc/jit/docs/cp/topics/contexts.rst b/gcc/jit/docs/cp/topics/contexts.rst index f60f210..2f2456a 100644 --- a/gcc/jit/docs/cp/topics/contexts.rst +++ b/gcc/jit/docs/cp/topics/contexts.rst @@ -29,9 +29,9 @@ compilation. You can set up options on it, and add types, functions and code. Invoking :func:`gccjit::context::compile` on it gives you a -:c:type:`gcc_jit_result *`. +:c:expr:`gcc_jit_result *`. -It is a thin wrapper around the C API's :c:type:`gcc_jit_context *`. +It is a thin wrapper around the C API's :c:expr:`gcc_jit_context *`. Lifetime-management ------------------- @@ -48,7 +48,7 @@ cleanup of such objects is done for you when the context is released. .. function:: void gccjit::context::release () This function releases all resources associated with the given context. - Both the context itself and all of its :c:type:`gccjit::object *` + Both the context itself and all of its :expr:`gccjit::object *` instances are cleaned up. It should be called exactly once on a given context. diff --git a/gcc/jit/docs/cp/topics/expressions.rst b/gcc/jit/docs/cp/topics/expressions.rst index dec5b47..01eb289 100644 --- a/gcc/jit/docs/cp/topics/expressions.rst +++ b/gcc/jit/docs/cp/topics/expressions.rst @@ -26,7 +26,7 @@ Rvalues A :class:`gccjit::rvalue` is an expression that can be computed. It is a subclass of :class:`gccjit::object`, and is a thin wrapper around -:c:type:`gcc_jit_rvalue *` from the C API. +:c:expr:`gcc_jit_rvalue *` from the C API. It can be simple, e.g.: @@ -491,7 +491,7 @@ a storage area (such as a variable). It is a subclass of :class:`gccjit::rvalue`, where the rvalue is computed by reading from the storage area. -It iss a thin wrapper around :c:type:`gcc_jit_lvalue *` from the C API. +It iss a thin wrapper around :c:expr:`gcc_jit_lvalue *` from the C API. .. function:: gccjit::rvalue \ gccjit::lvalue::get_address (gccjit::location loc) diff --git a/gcc/jit/docs/cp/topics/functions.rst b/gcc/jit/docs/cp/topics/functions.rst index 4e325ac..24534cc 100644 --- a/gcc/jit/docs/cp/topics/functions.rst +++ b/gcc/jit/docs/cp/topics/functions.rst @@ -36,7 +36,7 @@ Params :class:`gccjit::param` is a subclass of :class:`gccjit::lvalue` (and thus of :class:`gccjit::rvalue` and :class:`gccjit::object`). It is a thin -wrapper around the C API's :c:type:`gcc_jit_param *`. +wrapper around the C API's :c:expr:`gcc_jit_param *`. Functions --------- diff --git a/gcc/jit/docs/cp/topics/objects.rst b/gcc/jit/docs/cp/topics/objects.rst index d81a84c..ca9243b 100644 --- a/gcc/jit/docs/cp/topics/objects.rst +++ b/gcc/jit/docs/cp/topics/objects.rst @@ -23,7 +23,7 @@ Objects .. class:: gccjit::object Almost every entity in the API (with the exception of -:class:`gccjit::context` and :c:type:`gcc_jit_result *`) is a +:class:`gccjit::context` and :c:expr:`gcc_jit_result *`) is a "contextual" object, a :class:`gccjit::object`. A JIT object: diff --git a/gcc/jit/docs/intro/tutorial02.rst b/gcc/jit/docs/intro/tutorial02.rst index 5739548..9fcaad5 100644 --- a/gcc/jit/docs/intro/tutorial02.rst +++ b/gcc/jit/docs/intro/tutorial02.rst @@ -38,7 +38,7 @@ First we need to include the relevant header: #include All state associated with compilation is associated with a -:c:type:`gcc_jit_context *`. +:c:expr:`gcc_jit_context *`. Create one using :c:func:`gcc_jit_context_acquire`: @@ -50,7 +50,7 @@ Create one using :c:func:`gcc_jit_context_acquire`: The JIT library has a system of types. It is statically-typed: every expression is of a specific type, fixed at compile-time. In our example, all of the expressions are of the C `int` type, so let's obtain this from -the context, as a :c:type:`gcc_jit_type *`, using +the context, as a :c:expr:`gcc_jit_type *`, using :c:func:`gcc_jit_context_get_type`: .. code-block:: c @@ -58,8 +58,8 @@ the context, as a :c:type:`gcc_jit_type *`, using gcc_jit_type *int_type = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); -:c:type:`gcc_jit_type *` is an example of a "contextual" object: every -entity in the API is associated with a :c:type:`gcc_jit_context *`. +:c:expr:`gcc_jit_type *` is an example of a "contextual" object: every +entity in the API is associated with a :c:expr:`gcc_jit_context *`. Memory management is easy: all such "contextual" objects are automatically cleaned up for you when the context is released, using @@ -93,7 +93,7 @@ For example, :c:func:`gcc_jit_type_as_object`: gcc_jit_object *obj = gcc_jit_type_as_object (int_type); -One thing you can do with a :c:type:`gcc_jit_object *` is +One thing you can do with a :c:expr:`gcc_jit_object *` is to ask it for a human-readable description, using :c:func:`gcc_jit_object_get_debug_string`: @@ -157,8 +157,8 @@ We can build the expression using :c:func:`gcc_jit_context_new_binary_op`: gcc_jit_param_as_rvalue (param_i), gcc_jit_param_as_rvalue (param_i)); -A :c:type:`gcc_jit_rvalue *` is another example of a -:c:type:`gcc_jit_object *` subclass. We can upcast it using +A :c:expr:`gcc_jit_rvalue *` is another example of a +:c:expr:`gcc_jit_object *` subclass. We can upcast it using :c:func:`gcc_jit_rvalue_as_object` and as before print it with :c:func:`gcc_jit_object_get_debug_string`. @@ -190,7 +190,7 @@ OK, we've populated the context. We can now compile it using gcc_jit_result *result; result = gcc_jit_context_compile (ctxt); -and get a :c:type:`gcc_jit_result *`. +and get a :c:expr:`gcc_jit_result *`. At this point we're done with the context; we can release it: diff --git a/gcc/jit/docs/intro/tutorial03.rst b/gcc/jit/docs/intro/tutorial03.rst index 50d71ba..478ea27 100644 --- a/gcc/jit/docs/intro/tutorial03.rst +++ b/gcc/jit/docs/intro/tutorial03.rst @@ -55,7 +55,7 @@ Here's what the final control flow graph will look like: :alt: image of a control flow graph As before, we include the libgccjit header and make a -:c:type:`gcc_jit_context *`. +:c:expr:`gcc_jit_context *`. .. code-block:: c @@ -98,14 +98,14 @@ Let's build the function: Expressions: lvalues and rvalues ******************************** -The base class of expression is the :c:type:`gcc_jit_rvalue *`, +The base class of expression is the :c:expr:`gcc_jit_rvalue *`, representing an expression that can be on the *right*-hand side of an assignment: a value that can be computed somehow, and assigned *to* a storage area (such as a variable). It has a specific -:c:type:`gcc_jit_type *`. +:c:expr:`gcc_jit_type *`. -Anothe important class is :c:type:`gcc_jit_lvalue *`. -A :c:type:`gcc_jit_lvalue *`. is something that can of the *left*-hand +Anothe important class is :c:expr:`gcc_jit_lvalue *`. +A :c:expr:`gcc_jit_lvalue *`. is something that can of the *left*-hand side of an assignment: a storage area (such as a variable). In other words, every assignment can be thought of as: @@ -114,8 +114,8 @@ In other words, every assignment can be thought of as: LVALUE = RVALUE; -Note that :c:type:`gcc_jit_lvalue *` is a subclass of -:c:type:`gcc_jit_rvalue *`, where in an assignment of the form: +Note that :c:expr:`gcc_jit_lvalue *` is a subclass of +:c:expr:`gcc_jit_rvalue *`, where in an assignment of the form: .. code-block:: c @@ -135,10 +135,10 @@ So far the only expressions we've seen are `i * i`: gcc_jit_param_as_rvalue (param_i), gcc_jit_param_as_rvalue (param_i)); -which is a :c:type:`gcc_jit_rvalue *`, and the various function +which is a :c:expr:`gcc_jit_rvalue *`, and the various function parameters: `param_i` and `param_n`, instances of -:c:type:`gcc_jit_param *`, which is a subclass of -:c:type:`gcc_jit_lvalue *` (and, in turn, of :c:type:`gcc_jit_rvalue *`): +:c:expr:`gcc_jit_param *`, which is a subclass of +:c:expr:`gcc_jit_lvalue *` (and, in turn, of :c:expr:`gcc_jit_rvalue *`): we can both read from and write to function parameters within the body of a function. @@ -154,7 +154,7 @@ name: gcc_jit_lvalue *sum = gcc_jit_function_new_local (func, NULL, the_type, "sum"); -These are instances of :c:type:`gcc_jit_lvalue *` - they can be read from +These are instances of :c:expr:`gcc_jit_lvalue *` - they can be read from and written to. Note that there is no precanned way to create *and* initialize a variable @@ -178,8 +178,8 @@ handle the control flow. In this case, we need 4 blocks: 3. the body of the loop 4. after the loop terminates (`return sum`) -so we create these as :c:type:`gcc_jit_block *` instances within the -:c:type:`gcc_jit_function *`: +so we create these as :c:expr:`gcc_jit_block *` instances within the +:c:expr:`gcc_jit_function *`: .. code-block:: c @@ -224,7 +224,7 @@ We can then terminate the entry block by jumping to the conditional: The conditional block is equivalent to the line `while (i < n)` from our C example. It contains a single statement: a conditional, which jumps to one of two destination blocks depending on a boolean -:c:type:`gcc_jit_rvalue *`, in this case the comparison of `i` and `n`. +:c:expr:`gcc_jit_rvalue *`, in this case the comparison of `i` and `n`. We build the comparison using :c:func:`gcc_jit_context_new_comparison`: .. code-block:: c diff --git a/gcc/jit/docs/intro/tutorial04.rst b/gcc/jit/docs/intro/tutorial04.rst index c2e3fb5..a08119f 100644 --- a/gcc/jit/docs/intro/tutorial04.rst +++ b/gcc/jit/docs/intro/tutorial04.rst @@ -126,7 +126,7 @@ then directly executed in-process: :end-before: enum opcode :language: c -The lifetime of the code is tied to that of a :c:type:`gcc_jit_result *`. +The lifetime of the code is tied to that of a :c:expr:`gcc_jit_result *`. We'll handle this by bundling them up in a structure, so that we can clean them up together by calling :c:func:`gcc_jit_result_release`: diff --git a/gcc/jit/docs/intro/tutorial05.rst b/gcc/jit/docs/intro/tutorial05.rst index b977d1d..1c47744 100644 --- a/gcc/jit/docs/intro/tutorial05.rst +++ b/gcc/jit/docs/intro/tutorial05.rst @@ -95,7 +95,7 @@ Here's what a simple ``.bf`` script looks like: Converting a brainf script to libgccjit IR ****************************************** -As before we write simple code to populate a :c:type:`gcc_jit_context *`. +As before we write simple code to populate a :c:expr:`gcc_jit_context *`. .. literalinclude:: ../examples/tut05-bf.c :start-after: #define MAX_OPEN_PARENS 16 @@ -261,7 +261,7 @@ state ``idx`` and ``data_cells``: Other forms of ahead-of-time-compilation **************************************** -The above demonstrates compiling a :c:type:`gcc_jit_context *` directly +The above demonstrates compiling a :c:expr:`gcc_jit_context *` directly to an executable. It's also possible to compile it to an object file, and to a dynamic library. See the documentation of :c:func:`gcc_jit_context_compile_to_file` for more information. diff --git a/gcc/jit/docs/topics/compilation.rst b/gcc/jit/docs/topics/compilation.rst index adcde8d..3dd9bc6 100644 --- a/gcc/jit/docs/topics/compilation.rst +++ b/gcc/jit/docs/topics/compilation.rst @@ -20,7 +20,7 @@ Compiling a context =================== -Once populated, a :c:type:`gcc_jit_context *` can be compiled to +Once populated, a :c:expr:`gcc_jit_context *` can be compiled to machine code, either in-memory via :c:func:`gcc_jit_context_compile` or to disk via :c:func:`gcc_jit_context_compile_to_file`. @@ -80,7 +80,7 @@ In-memory compilation Note that the resulting machine code becomes invalid after :func:`gcc_jit_result_release` is called on the - :type:`gcc_jit_result *`; attempting to call it after that may lead + :expr:`gcc_jit_result *`; attempting to call it after that may lead to a segmentation fault. .. function:: void *\ @@ -125,7 +125,7 @@ In-memory compilation Note that the resulting address becomes invalid after :func:`gcc_jit_result_release` is called on the - :type:`gcc_jit_result *`; attempting to use it after that may lead + :expr:`gcc_jit_result *`; attempting to use it after that may lead to a segmentation fault. .. function:: void\ @@ -153,7 +153,7 @@ For linking in object files, use :c:func:`gcc_jit_context_add_driver_option`. enum gcc_jit_output_kind output_kind,\ const char *output_path) - Compile the :c:type:`gcc_jit_context *` to a file of the given + Compile the :c:expr:`gcc_jit_context *` to a file of the given kind. :c:func:`gcc_jit_context_compile_to_file` ignores the suffix of diff --git a/gcc/jit/docs/topics/contexts.rst b/gcc/jit/docs/topics/contexts.rst index 205b5f3..f746e28 100644 --- a/gcc/jit/docs/topics/contexts.rst +++ b/gcc/jit/docs/topics/contexts.rst @@ -39,14 +39,14 @@ cleanup of such objects is done for you when the context is released. .. function:: gcc_jit_context *gcc_jit_context_acquire (void) - This function acquires a new :c:type:`gcc_jit_context *` instance, + This function acquires a new :c:expr:`gcc_jit_context *` instance, which is independent of any others that may be present within this process. .. function:: void gcc_jit_context_release (gcc_jit_context *ctxt) This function releases all resources associated with the given context. - Both the context itself and all of its :c:type:`gcc_jit_object *` + Both the context itself and all of its :c:expr:`gcc_jit_object *` instances are cleaned up. It should be called exactly once on a given context. @@ -89,7 +89,7 @@ cleanup of such objects is done for you when the context is released. Thread-safety ------------- -Instances of :c:type:`gcc_jit_context *` created via +Instances of :c:expr:`gcc_jit_context *` created via :c:func:`gcc_jit_context_acquire` are independent from each other: only one thread may use a given context at once, but multiple threads could each have their own contexts without needing locks. diff --git a/gcc/jit/docs/topics/objects.rst b/gcc/jit/docs/topics/objects.rst index cd117e2..42f3675 100644 --- a/gcc/jit/docs/topics/objects.rst +++ b/gcc/jit/docs/topics/objects.rst @@ -23,12 +23,12 @@ Objects .. type:: gcc_jit_object Almost every entity in the API (with the exception of -:c:type:`gcc_jit_context *` and :c:type:`gcc_jit_result *`) is a -"contextual" object, a :c:type:`gcc_jit_object *` +:c:expr:`gcc_jit_context *` and :c:expr:`gcc_jit_result *`) is a +"contextual" object, a :c:expr:`gcc_jit_object *` A JIT object: - * is associated with a :c:type:`gcc_jit_context *`. + * is associated with a :c:expr:`gcc_jit_context *`. * is automatically cleaned up for you when its context is released so you don't need to manually track and cleanup all objects, just the -- cgit v1.1 From 75a392d0317ee0a5af1fdcb0669322df96b34f80 Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 25 Jul 2022 14:45:01 +0200 Subject: jit,docs: remove :ref:`modindex` gcc/jit/ChangeLog: * docs/index.rst: Remove reference to module index as we don't emit any. --- gcc/jit/docs/index.rst | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc') diff --git a/gcc/jit/docs/index.rst b/gcc/jit/docs/index.rst index 21c3140..0f57596 100644 --- a/gcc/jit/docs/index.rst +++ b/gcc/jit/docs/index.rst @@ -43,5 +43,4 @@ Indices and tables ================== * :ref:`genindex` -* :ref:`modindex` * :ref:`search` -- cgit v1.1 From 0652087375e7813f06140f1bb5e18375f45d28ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Li=C5=A1ka?= Date: Tue, 26 Jul 2022 08:42:29 +0200 Subject: jit,docs: shorten assembly output Shorten the assembly example so that there is not slider. Ready for master? Thanks, Martin gcc/jit/ChangeLog: * docs/cp/intro/tutorial02.rst: Shorten the assembly example so that there is not slider. * docs/cp/intro/tutorial04.rst: Likewise. * docs/intro/tutorial02.rst: Likewise. * docs/intro/tutorial04.rst: Likewise. * docs/topics/contexts.rst: Likewise. --- gcc/jit/docs/cp/intro/tutorial02.rst | 4 ++-- gcc/jit/docs/cp/intro/tutorial04.rst | 2 +- gcc/jit/docs/intro/tutorial02.rst | 4 ++-- gcc/jit/docs/intro/tutorial04.rst | 2 +- gcc/jit/docs/topics/contexts.rst | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'gcc') diff --git a/gcc/jit/docs/cp/intro/tutorial02.rst b/gcc/jit/docs/cp/intro/tutorial02.rst index 9f9a7f3..d1132a4 100644 --- a/gcc/jit/docs/cp/intro/tutorial02.rst +++ b/gcc/jit/docs/cp/intro/tutorial02.rst @@ -286,7 +286,7 @@ before compiling: .cfi_endproc .LFE6: .size square, .-square - .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2-0.5.1920c315ff984892399893b380305ab36e07b455.fc20)" + .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2)" .section .note.GNU-stack,"",@progbits By default, no optimizations are performed, the equivalent of GCC's @@ -315,7 +315,7 @@ By default, no optimizations are performed, the equivalent of GCC's .cfi_endproc .LFE7: .size square, .-square - .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2-0.5.1920c315ff984892399893b380305ab36e07b455.fc20)" + .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2)" .section .note.GNU-stack,"",@progbits Naturally this has only a small effect on such a trivial function. diff --git a/gcc/jit/docs/cp/intro/tutorial04.rst b/gcc/jit/docs/cp/intro/tutorial04.rst index 66dcce9..d50a1e4 100644 --- a/gcc/jit/docs/cp/intro/tutorial04.rst +++ b/gcc/jit/docs/cp/intro/tutorial04.rst @@ -574,7 +574,7 @@ yields this code, which is simple enough to quote in its entirety: .cfi_endproc .LFE0: .size factorial, .-factorial - .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2-%{gcc_release})" + .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2)" .section .note.GNU-stack,"",@progbits Note that the stack pushing and popping have been eliminated, as has the diff --git a/gcc/jit/docs/intro/tutorial02.rst b/gcc/jit/docs/intro/tutorial02.rst index 9fcaad5..8ac59a7 100644 --- a/gcc/jit/docs/intro/tutorial02.rst +++ b/gcc/jit/docs/intro/tutorial02.rst @@ -332,7 +332,7 @@ before compiling: .cfi_endproc .LFE6: .size square, .-square - .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2-0.5.1920c315ff984892399893b380305ab36e07b455.fc20)" + .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2)" .section .note.GNU-stack,"",@progbits By default, no optimizations are performed, the equivalent of GCC's @@ -364,7 +364,7 @@ By default, no optimizations are performed, the equivalent of GCC's .cfi_endproc .LFE7: .size square, .-square - .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2-0.5.1920c315ff984892399893b380305ab36e07b455.fc20)" + .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2)" .section .note.GNU-stack,"",@progbits Naturally this has only a small effect on such a trivial function. diff --git a/gcc/jit/docs/intro/tutorial04.rst b/gcc/jit/docs/intro/tutorial04.rst index a08119f..cfcad46 100644 --- a/gcc/jit/docs/intro/tutorial04.rst +++ b/gcc/jit/docs/intro/tutorial04.rst @@ -596,7 +596,7 @@ yields this code, which is simple enough to quote in its entirety: .cfi_endproc .LFE0: .size factorial, .-factorial - .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2-%{gcc_release})" + .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2)" .section .note.GNU-stack,"",@progbits Note that the stack pushing and popping have been eliminated, as has the diff --git a/gcc/jit/docs/topics/contexts.rst b/gcc/jit/docs/topics/contexts.rst index f746e28..b1a7a0a 100644 --- a/gcc/jit/docs/topics/contexts.rst +++ b/gcc/jit/docs/topics/contexts.rst @@ -423,7 +423,7 @@ Boolean options .cfi_endproc .LFE0: .size square, .-square - .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.1-%{gcc_release})" + .ident "GCC: (GNU) 4.9.0 20131023 (Red Hat 0.2)" .section .note.GNU-stack,"",@progbits -- cgit v1.1 From f64eb636677d714781b4543f111b1c9239328db6 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 28 Jul 2022 12:42:14 +0200 Subject: gimple, internal-fn: Add IFN_TRAP and use it for __builtin_unreachable [PR106099] __builtin_unreachable and __ubsan_handle_builtin_unreachable don't use vops, they are marked const/leaf/noreturn/nothrow/cold. But __builtin_trap uses vops, isn't const, just leaf/noreturn/nothrow/cold. This is I believe so that when users explicitly use __builtin_trap in their sources they get stores visible at the trap side. -fsanitize=unreachable -fsanitize-undefined-trap-on-error used to transform __builtin_unreachable to __builtin_trap even in the past, but the sanopt pass has TODO_update_ssa, so it worked fine. Now that gimple_build_builtin_unreachable can build a __builtin_trap call right away, we can run into problems that whenever we need it we would need to either manually or through TODO_update* ensure the vops being updated. Though, as it is originally __builtin_unreachable which is just implemented as trap, I think for this case it is fine to avoid vops. For this the patch introduces IFN_TRAP, which has ECF_* flags like __builtin_unreachable and is expanded as __builtin_trap. 2022-07-28 Jakub Jelinek PR tree-optimization/106099 * internal-fn.def (TRAP): New internal fn. * internal-fn.h (expand_TRAP): Declare. * internal-fn.cc (expand_TRAP): Define. * gimple.cc (gimple_build_builtin_unreachable): For BUILT_IN_TRAP, use internal fn rather than builtin. * gcc.dg/ubsan/pr106099.c: New test. --- gcc/gimple.cc | 11 ++++++++++- gcc/internal-fn.cc | 6 ++++++ gcc/internal-fn.def | 4 ++++ gcc/internal-fn.h | 1 + gcc/testsuite/gcc.dg/ubsan/pr106099.c | 10 ++++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/ubsan/pr106099.c (limited to 'gcc') diff --git a/gcc/gimple.cc b/gcc/gimple.cc index 9b15639..cd5ad0c 100644 --- a/gcc/gimple.cc +++ b/gcc/gimple.cc @@ -430,7 +430,16 @@ gimple_build_builtin_unreachable (location_t loc) { tree data = NULL_TREE; tree fn = sanitize_unreachable_fn (&data, loc); - gcall *g = gimple_build_call (fn, data != NULL_TREE, data); + gcall *g; + if (DECL_FUNCTION_CODE (fn) != BUILT_IN_TRAP) + g = gimple_build_call (fn, data != NULL_TREE, data); + else + { + /* Instead of __builtin_trap use .TRAP, so that it doesn't + need vops. */ + gcc_checking_assert (data == NULL_TREE); + g = gimple_build_call_internal (IFN_TRAP, 0); + } gimple_set_location (g, loc); return g; } diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc index 28973d9..aa7c482 100644 --- a/gcc/internal-fn.cc +++ b/gcc/internal-fn.cc @@ -4494,3 +4494,9 @@ expand_SPACESHIP (internal_fn, gcall *stmt) if (!rtx_equal_p (target, ops[0].value)) emit_move_insn (target, ops[0].value); } + +void +expand_TRAP (internal_fn, gcall *) +{ + expand_builtin_trap (); +} diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def index 7c398ba..7bf661c 100644 --- a/gcc/internal-fn.def +++ b/gcc/internal-fn.def @@ -456,6 +456,10 @@ DEF_INTERNAL_FN (SHUFFLEVECTOR, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL) /* <=> optimization. */ DEF_INTERNAL_FN (SPACESHIP, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL) +/* __builtin_trap created from/for __builtin_unreachable. */ +DEF_INTERNAL_FN (TRAP, ECF_CONST | ECF_LEAF | ECF_NORETURN + | ECF_NOTHROW | ECF_COLD, NULL) + #undef DEF_INTERNAL_INT_FN #undef DEF_INTERNAL_FLT_FN #undef DEF_INTERNAL_FLT_FLOATN_FN diff --git a/gcc/internal-fn.h b/gcc/internal-fn.h index 23c014a..c4c94f8 100644 --- a/gcc/internal-fn.h +++ b/gcc/internal-fn.h @@ -242,6 +242,7 @@ extern void expand_internal_call (internal_fn, gcall *); extern void expand_PHI (internal_fn, gcall *); extern void expand_SHUFFLEVECTOR (internal_fn, gcall *); extern void expand_SPACESHIP (internal_fn, gcall *); +extern void expand_TRAP (internal_fn, gcall *); extern bool vectorized_internal_fn_supported_p (internal_fn, tree); diff --git a/gcc/testsuite/gcc.dg/ubsan/pr106099.c b/gcc/testsuite/gcc.dg/ubsan/pr106099.c new file mode 100644 index 0000000..e3f17b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ubsan/pr106099.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/106099 */ +/* { dg-do compile } */ +/* { dg-options "-O -fsanitize=unreachable -fsanitize-undefined-trap-on-error -fno-tree-ccp -fno-tree-dominator-opts" } */ + +void +foo (void) +{ + for (unsigned i = 0; i == 0; i++) + ; +} -- cgit v1.1 From ff26f0ba68fe6e870f315d0601b596f889b89680 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 28 Jul 2022 10:07:32 +0200 Subject: middle-end/106457 - improve array_at_struct_end_p for array objects Array references to array objects are never at struct end. PR middle-end/106457 * tree.cc (array_at_struct_end_p): Handle array objects specially. --- gcc/tree.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc') diff --git a/gcc/tree.cc b/gcc/tree.cc index 84000dd..fed1434 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -12778,6 +12778,10 @@ array_at_struct_end_p (tree ref) && DECL_SIZE_UNIT (ref) && TREE_CODE (DECL_SIZE_UNIT (ref)) == INTEGER_CST) { + /* If the object itself is the array it is not at struct end. */ + if (DECL_P (ref_to_array)) + return false; + /* Check whether the array domain covers all of the available padding. */ poly_int64 offset; -- cgit v1.1 From 94f5a8f0d4910be2d861f7a9699e93efd609d042 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Thu, 28 Jul 2022 14:04:33 +0100 Subject: RISC-V: Split unordered FP comparisons into individual RTL insns We have unordered FP comparisons implemented as RTL insns that produce multiple machine instructions. Such RTL insns are hard to match with a processor pipeline description and additionally there is a redundant SNEZ instruction produced on the result of these comparisons even though the FLT.fmt and FLE.fmt machine instructions already produce either 0 or 1, e.g.: long flt (double x, double y) { return __builtin_isless (x, y); } with `-O2 -fno-finite-math-only -ftrapping-math -fno-signaling-nans' gets compiled to: .globl flt .type flt, @function flt: frflags a5 flt.d a0,fa0,fa1 fsflags a5 snez a0,a0 ret .size flt, .-flt because the middle end can't see through the UNSPEC operation unordered FP comparisons have been defined in terms of. These instructions are only produced via an expander already, so change the expander to emit individual RTL insns for each machine instruction in the ultimate ultimate sequence produced rather than deferring to a single RTL insn producing the whole sequence at once. gcc/ * config/riscv/riscv.md (UNSPECV_FSNVSNAN): New constant. (QUIET_PATTERN): New int attribute. (f_quiet4): Emit the intended RTL insns entirely within the preparation statements. (*f_quiet4_default) (*f_quiet4_snan): Remove insns. (*riscv_fsnvsnan2): New insn. gcc/testsuite/ * gcc.target/riscv/fle-ieee.c: New test. * gcc.target/riscv/fle-snan.c: New test. * gcc.target/riscv/fle.c: New test. * gcc.target/riscv/flef-ieee.c: New test. * gcc.target/riscv/flef-snan.c: New test. * gcc.target/riscv/flef.c: New test. * gcc.target/riscv/flt-ieee.c: New test. * gcc.target/riscv/flt-snan.c: New test. * gcc.target/riscv/flt.c: New test. * gcc.target/riscv/fltf-ieee.c: New test. * gcc.target/riscv/fltf-snan.c: New test. * gcc.target/riscv/fltf.c: New test. --- gcc/config/riscv/riscv.md | 69 ++++++++++++++++-------------- gcc/testsuite/gcc.target/riscv/fle-ieee.c | 12 ++++++ gcc/testsuite/gcc.target/riscv/fle-snan.c | 12 ++++++ gcc/testsuite/gcc.target/riscv/fle.c | 12 ++++++ gcc/testsuite/gcc.target/riscv/flef-ieee.c | 12 ++++++ gcc/testsuite/gcc.target/riscv/flef-snan.c | 12 ++++++ gcc/testsuite/gcc.target/riscv/flef.c | 12 ++++++ gcc/testsuite/gcc.target/riscv/flt-ieee.c | 12 ++++++ gcc/testsuite/gcc.target/riscv/flt-snan.c | 12 ++++++ gcc/testsuite/gcc.target/riscv/flt.c | 12 ++++++ gcc/testsuite/gcc.target/riscv/fltf-ieee.c | 12 ++++++ gcc/testsuite/gcc.target/riscv/fltf-snan.c | 12 ++++++ gcc/testsuite/gcc.target/riscv/fltf.c | 12 ++++++ 13 files changed, 180 insertions(+), 33 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/fle-ieee.c create mode 100644 gcc/testsuite/gcc.target/riscv/fle-snan.c create mode 100644 gcc/testsuite/gcc.target/riscv/fle.c create mode 100644 gcc/testsuite/gcc.target/riscv/flef-ieee.c create mode 100644 gcc/testsuite/gcc.target/riscv/flef-snan.c create mode 100644 gcc/testsuite/gcc.target/riscv/flef.c create mode 100644 gcc/testsuite/gcc.target/riscv/flt-ieee.c create mode 100644 gcc/testsuite/gcc.target/riscv/flt-snan.c create mode 100644 gcc/testsuite/gcc.target/riscv/flt.c create mode 100644 gcc/testsuite/gcc.target/riscv/fltf-ieee.c create mode 100644 gcc/testsuite/gcc.target/riscv/fltf-snan.c create mode 100644 gcc/testsuite/gcc.target/riscv/fltf.c (limited to 'gcc') diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index aa43d5f..0796f91 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -57,6 +57,7 @@ ;; Floating-point unspecs. UNSPECV_FRFLAGS UNSPECV_FSFLAGS + UNSPECV_FSNVSNAN ;; Interrupt handler instructions. UNSPECV_MRET @@ -360,6 +361,7 @@ ;; Iterator and attributes for quiet comparisons. (define_int_iterator QUIET_COMPARISON [UNSPEC_FLT_QUIET UNSPEC_FLE_QUIET]) (define_int_attr quiet_pattern [(UNSPEC_FLT_QUIET "lt") (UNSPEC_FLE_QUIET "le")]) +(define_int_attr QUIET_PATTERN [(UNSPEC_FLT_QUIET "LT") (UNSPEC_FLE_QUIET "LE")]) ;; This code iterator allows signed and unsigned widening multiplications ;; to use the same template. @@ -2326,39 +2328,31 @@ (set_attr "mode" "")]) (define_expand "f_quiet4" - [(parallel [(set (match_operand:X 0 "register_operand") - (unspec:X - [(match_operand:ANYF 1 "register_operand") - (match_operand:ANYF 2 "register_operand")] - QUIET_COMPARISON)) - (clobber (match_scratch:X 3))])] - "TARGET_HARD_FLOAT") - -(define_insn "*f_quiet4_default" - [(set (match_operand:X 0 "register_operand" "=r") - (unspec:X - [(match_operand:ANYF 1 "register_operand" " f") - (match_operand:ANYF 2 "register_operand" " f")] - QUIET_COMPARISON)) - (clobber (match_scratch:X 3 "=&r"))] - "TARGET_HARD_FLOAT && ! HONOR_SNANS (mode)" - "frflags\t%3\n\tf.\t%0,%1,%2\n\tfsflags\t%3" - [(set_attr "type" "fcmp") - (set_attr "mode" "") - (set (attr "length") (const_int 12))]) - -(define_insn "*f_quiet4_snan" - [(set (match_operand:X 0 "register_operand" "=r") - (unspec:X - [(match_operand:ANYF 1 "register_operand" " f") - (match_operand:ANYF 2 "register_operand" " f")] - QUIET_COMPARISON)) - (clobber (match_scratch:X 3 "=&r"))] - "TARGET_HARD_FLOAT && HONOR_SNANS (mode)" - "frflags\t%3\n\tf.\t%0,%1,%2\n\tfsflags\t%3\n\tfeq.\tzero,%1,%2" - [(set_attr "type" "fcmp") - (set_attr "mode" "") - (set (attr "length") (const_int 16))]) + [(set (match_operand:X 0 "register_operand") + (unspec:X [(match_operand:ANYF 1 "register_operand") + (match_operand:ANYF 2 "register_operand")] + QUIET_COMPARISON))] + "TARGET_HARD_FLOAT" +{ + rtx op0 = operands[0]; + rtx op1 = operands[1]; + rtx op2 = operands[2]; + rtx tmp = gen_reg_rtx (SImode); + rtx cmp = gen_rtx_ (mode, op1, op2); + rtx frflags = gen_rtx_UNSPEC_VOLATILE (SImode, gen_rtvec (1, const0_rtx), + UNSPECV_FRFLAGS); + rtx fsflags = gen_rtx_UNSPEC_VOLATILE (SImode, gen_rtvec (1, tmp), + UNSPECV_FSFLAGS); + + emit_insn (gen_rtx_SET (tmp, frflags)); + emit_insn (gen_rtx_SET (op0, cmp)); + emit_insn (fsflags); + if (HONOR_SNANS (mode)) + emit_insn (gen_rtx_UNSPEC_VOLATILE (mode, + gen_rtvec (2, op1, op2), + UNSPECV_FSNVSNAN)); + DONE; +}) (define_insn "*seq_zero_" [(set (match_operand:GPR 0 "register_operand" "=r") @@ -2766,6 +2760,15 @@ "TARGET_HARD_FLOAT" "fsflags\t%0") +(define_insn "*riscv_fsnvsnan2" + [(unspec_volatile [(match_operand:ANYF 0 "register_operand" "f") + (match_operand:ANYF 1 "register_operand" "f")] + UNSPECV_FSNVSNAN)] + "TARGET_HARD_FLOAT" + "feq.\tzero,%0,%1" + [(set_attr "type" "fcmp") + (set_attr "mode" "")]) + (define_insn "riscv_mret" [(return) (unspec_volatile [(const_int 0)] UNSPECV_MRET)] diff --git a/gcc/testsuite/gcc.target/riscv/fle-ieee.c b/gcc/testsuite/gcc.target/riscv/fle-ieee.c new file mode 100644 index 0000000..af9d503 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/fle-ieee.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -ftrapping-math -fno-signaling-nans" } */ + +long +fle (double x, double y) +{ + return __builtin_islessequal (x, y); +} + +/* { dg-final { scan-assembler "\tfrflags\t(\[^\n\]*)\n\tfle\\.d\t\[^\n\]*\n\tfsflags\t\\1\n" } } */ +/* { dg-final { scan-assembler-not "snez" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/fle-snan.c b/gcc/testsuite/gcc.target/riscv/fle-snan.c new file mode 100644 index 0000000..0579d93 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/fle-snan.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -ftrapping-math -fsignaling-nans" } */ + +long +fle (double x, double y) +{ + return __builtin_islessequal (x, y); +} + +/* { dg-final { scan-assembler "\tfrflags\t(\[^\n\]*)\n\tfle\\.d\t\[^,\]*,(\[^,\]*),(\[^,\]*)\n\tfsflags\t\\1\n\tfeq\\.d\tzero,\\2,\\3\n" } } */ +/* { dg-final { scan-assembler-not "snez" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/fle.c b/gcc/testsuite/gcc.target/riscv/fle.c new file mode 100644 index 0000000..97c8ab9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/fle.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -fno-trapping-math -fno-signaling-nans" } */ + +long +fle (double x, double y) +{ + return __builtin_islessequal (x, y); +} + +/* { dg-final { scan-assembler "\tf(?:gt|le)\\.d\t\[^\n\]*\n" } } */ +/* { dg-final { scan-assembler-not "f\[rs\]flags" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/flef-ieee.c b/gcc/testsuite/gcc.target/riscv/flef-ieee.c new file mode 100644 index 0000000..e2d6b0d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/flef-ieee.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -ftrapping-math -fno-signaling-nans" } */ + +long +flef (float x, float y) +{ + return __builtin_islessequal (x, y); +} + +/* { dg-final { scan-assembler "\tfrflags\t(\[^\n\]*)\n\tfle\\.s\t\[^\n\]*\n\tfsflags\t\\1\n" } } */ +/* { dg-final { scan-assembler-not "snez" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/flef-snan.c b/gcc/testsuite/gcc.target/riscv/flef-snan.c new file mode 100644 index 0000000..2d2c5b9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/flef-snan.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -ftrapping-math -fsignaling-nans" } */ + +long +flef (float x, float y) +{ + return __builtin_islessequal (x, y); +} + +/* { dg-final { scan-assembler "\tfrflags\t(\[^\n\]*)\n\tfle\\.s\t\[^,\]*,(\[^,\]*),(\[^,\]*)\n\tfsflags\t\\1\n\tfeq\\.s\tzero,\\2,\\3\n" } } */ +/* { dg-final { scan-assembler-not "snez" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/flef.c b/gcc/testsuite/gcc.target/riscv/flef.c new file mode 100644 index 0000000..379f511 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/flef.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -fno-trapping-math -fno-signaling-nans" } */ + +long +flef (float x, float y) +{ + return __builtin_islessequal (x, y); +} + +/* { dg-final { scan-assembler "\tf(?:gt|le)\\.s\t\[^\n\]*\n" } } */ +/* { dg-final { scan-assembler-not "f\[rs\]flags" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/flt-ieee.c b/gcc/testsuite/gcc.target/riscv/flt-ieee.c new file mode 100644 index 0000000..7d7aae3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/flt-ieee.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -ftrapping-math -fno-signaling-nans" } */ + +long +flt (double x, double y) +{ + return __builtin_isless (x, y); +} + +/* { dg-final { scan-assembler "\tfrflags\t(\[^\n\]*)\n\tflt\\.d\t\[^\n\]*\n\tfsflags\t\\1\n" } } */ +/* { dg-final { scan-assembler-not "snez" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/flt-snan.c b/gcc/testsuite/gcc.target/riscv/flt-snan.c new file mode 100644 index 0000000..ff4c4e9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/flt-snan.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -ftrapping-math -fsignaling-nans" } */ + +long +flt (double x, double y) +{ + return __builtin_isless (x, y); +} + +/* { dg-final { scan-assembler "\tfrflags\t(\[^\n\]*)\n\tflt\\.d\t\[^,\]*,(\[^,\]*),(\[^,\]*)\n\tfsflags\t\\1\n\tfeq\\.d\tzero,\\2,\\3\n" } } */ +/* { dg-final { scan-assembler-not "snez" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/flt.c b/gcc/testsuite/gcc.target/riscv/flt.c new file mode 100644 index 0000000..4f5ef1d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/flt.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -fno-trapping-math -fno-signaling-nans" } */ + +long +flt (double x, double y) +{ + return __builtin_isless (x, y); +} + +/* { dg-final { scan-assembler "\tf(?:ge|lt)\\.d\t\[^\n\]*\n" } } */ +/* { dg-final { scan-assembler-not "f\[rs\]flags" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/fltf-ieee.c b/gcc/testsuite/gcc.target/riscv/fltf-ieee.c new file mode 100644 index 0000000..ede076e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/fltf-ieee.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -ftrapping-math -fno-signaling-nans" } */ + +long +fltf (float x, float y) +{ + return __builtin_isless (x, y); +} + +/* { dg-final { scan-assembler "\tfrflags\t(\[^\n\]*)\n\tflt\\.s\t\[^\n\]*\n\tfsflags\t\\1\n" } } */ +/* { dg-final { scan-assembler-not "snez" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/fltf-snan.c b/gcc/testsuite/gcc.target/riscv/fltf-snan.c new file mode 100644 index 0000000..d29d786 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/fltf-snan.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -ftrapping-math -fsignaling-nans" } */ + +long +fltf (float x, float y) +{ + return __builtin_isless (x, y); +} + +/* { dg-final { scan-assembler "\tfrflags\t(\[^\n\]*)\n\tflt\\.s\t\[^,\]*,(\[^,\]*),(\[^,\]*)\n\tfsflags\t\\1\n\tfeq\\.s\tzero,\\2,\\3\n" } } */ +/* { dg-final { scan-assembler-not "snez" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/fltf.c b/gcc/testsuite/gcc.target/riscv/fltf.c new file mode 100644 index 0000000..c9e6a2b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/fltf.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-fno-finite-math-only -fno-trapping-math -fno-signaling-nans" } */ + +long +fltf (float x, float y) +{ + return __builtin_isless (x, y); +} + +/* { dg-final { scan-assembler "\tf(?:ge|lt)\\.s\t\[^\n\]*\n" } } */ +/* { dg-final { scan-assembler-not "f\[rs\]flags" } } */ -- cgit v1.1 From e32ca426242f0e3c650f3122342792ad42255511 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Thu, 28 Jul 2022 14:04:33 +0100 Subject: doc: Clarify FENV_ACCESS pragma semantics WRT `-ftrapping-math' Our documentation indicates that it is the `-frounding-math' invocation option that controls whether we respect what the FENV_ACCESS pragma would imply, should we implement it, regarding the floating point environment. It is only a part of the picture however, because the `-ftrapping-math' invocation option also affects how we handle said environment. Clarify that in the description of both options then, as well as the FENV_ACCESS pragma itself. gcc/ * doc/implement-c.texi (Floating point implementation): Mention `-fno-trapping-math' in the context of FENV_ACCESS pragma. * doc/invoke.texi (Optimize Options): Clarify FENV_ACCESS pragma implication in the descriptions of `-fno-trapping-math' and `-frounding-math'. --- gcc/doc/implement-c.texi | 3 ++- gcc/doc/invoke.texi | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/doc/implement-c.texi b/gcc/doc/implement-c.texi index 93b8dda..c2088ff 100644 --- a/gcc/doc/implement-c.texi +++ b/gcc/doc/implement-c.texi @@ -339,7 +339,8 @@ This is subject to change. 7.6.1).} This pragma is not implemented, but the default is to ``off'' unless -@option{-frounding-math} is used in which case it is ``on''. +@option{-frounding-math} is used and @option{-fno-trapping-math} is not +in which case it is ``on''. @item @cite{Additional floating-point exceptions, rounding modes, environments, diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index fa23fbe..fd7edd1 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -13674,6 +13674,11 @@ math functions. The default is @option{-ftrapping-math}. +Future versions of GCC may provide finer control of this setting +using C99's @code{FENV_ACCESS} pragma. This command-line option +will be used along with @option{-frounding-math} to specify the +default state for @code{FENV_ACCESS}. + @item -frounding-math @opindex frounding-math Disable transformations and optimizations that assume default floating-point @@ -13692,7 +13697,8 @@ This option is experimental and does not currently guarantee to disable all GCC optimizations that are affected by rounding mode. Future versions of GCC may provide finer control of this setting using C99's @code{FENV_ACCESS} pragma. This command-line option -will be used to specify the default state for @code{FENV_ACCESS}. +will be used along with @option{-ftrapping-math} to specify the +default state for @code{FENV_ACCESS}. @item -fsignaling-nans @opindex fsignaling-nans -- cgit v1.1 From b8ce0c4361c267406d5eba1901e42fc5942dc775 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 28 Jul 2022 17:21:28 -0400 Subject: jit: update docs to reflect .c to .cc renaming gcc/jit/ChangeLog: * docs/internals/index.rst: Remove reference to ".c" extensions of source files. Signed-off-by: David Malcolm --- gcc/jit/docs/internals/index.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/jit/docs/internals/index.rst b/gcc/jit/docs/internals/index.rst index 9200181..092380c 100644 --- a/gcc/jit/docs/internals/index.rst +++ b/gcc/jit/docs/internals/index.rst @@ -291,8 +291,7 @@ For example: Overview of code structure -------------------------- -The library is implemented in C++. The source files have the ``.c`` -extension for legacy reasons. +The library is implemented in C++. * ``libgccjit.cc`` implements the API entrypoints. It performs error checking, then calls into classes of the gcc::jit::recording namespace -- cgit v1.1 From 9cac6811cf0d6c1437426aaf13ea52c16c16fc80 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 28 Jul 2022 17:21:28 -0400 Subject: analyzer: expand the comment in region.h gcc/analyzer/ChangeLog: * region.h: Add notes to the comment describing the region class hierarchy. Signed-off-by: David Malcolm --- gcc/analyzer/region.h | 52 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 21 deletions(-) (limited to 'gcc') diff --git a/gcc/analyzer/region.h b/gcc/analyzer/region.h index 1067748..a5b3029 100644 --- a/gcc/analyzer/region.h +++ b/gcc/analyzer/region.h @@ -72,27 +72,37 @@ enum region_kind region space_region - frame_region (RK_FRAME) - globals_region (RK_GLOBALS) - code_region (RK_CODE) - stack_region (RK_STACK) - heap_region (RK_HEAP) - root_region (RK_ROOT) - function_region (RK_FUNCTION) - label_region (RK_LABEL) - symbolic_region (RK_SYMBOLIC) - decl_region (RK_DECL), - field_region (RK_FIELD) - element_region (RK_ELEMENT) - offset_region (RK_OFFSET) - sized_region (RK_SIZED) - cast_region (RK_CAST) - heap_allocated_region (RK_HEAP_ALLOCATED) - alloca_region (RK_ALLOCA) - string_region (RK_STRING) - bit_range_region (RK_BIT_RANGE) - var_arg_region (RK_VAR_ARG) - unknown_region (RK_UNKNOWN). */ + frame_region (RK_FRAME): a function frame on the stack + globals_region (RK_GLOBALS): holds globals variables (data and bss) + code_region (RK_CODE): represents the code segment, containing functions + stack_region (RK_STACK): a stack, containing all stack frames + heap_region (RK_HEAP): the heap, containing heap_allocated_regions + root_region (RK_ROOT): the top-level region + function_region (RK_FUNCTION): the code for a particular function + label_region (RK_LABEL): a particular label within a function + symbolic_region (RK_SYMBOLIC): dereferencing a symbolic pointer + decl_region (RK_DECL): the memory occupied by a particular global, local, + or SSA name + field_region (RK_FIELD): the memory occupied by a field within a struct + or union + element_region (RK_ELEMENT): an element within an array + offset_region (RK_OFFSET): a byte-offset within another region, for + handling pointer arithmetic as a region + sized_region (RK_SIZED): a subregion of symbolic size (in bytes) + within its parent + cast_region (RK_CAST): a region that views another region using a + different type + heap_allocated_region (RK_HEAP_ALLOCATED): an untyped region dynamically + allocated on the heap via + "malloc" or similar + alloca_region (RK_ALLOCA): an untyped region dynamically allocated on the + stack via "alloca" + string_region (RK_STRING): a region for a STRING_CST + bit_range_region (RK_BIT_RANGE): a region for a specific range of bits + within another region + var_arg_region (RK_VAR_ARG): a region for the N-th vararg within a + frame_region for a variadic call + unknown_region (RK_UNKNOWN): for handling unimplemented tree codes. */ /* Abstract base class for representing ways of accessing chunks of memory. -- cgit v1.1 From 9c60338061bf3679f925be12273dc723b3913b75 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 28 Jul 2022 17:21:29 -0400 Subject: analyzer: add CWE identifier URLs to docs gcc/analyzer/ChangeLog: * sm-malloc.cc (free_of_non_heap::emit): Add comment about CWE. * sm-taint.cc (tainted_size::emit): Likewise. gcc/ChangeLog: * doc/invoke.texi (-fdiagnostics-show-cwe): Use uref rather than url. (Static Analyzer Options): Likewise. Add urefs for all of the warnings that have associated CWE identifiers. Signed-off-by: David Malcolm --- gcc/analyzer/sm-malloc.cc | 1 + gcc/analyzer/sm-taint.cc | 1 + gcc/doc/invoke.texi | 50 ++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 47 insertions(+), 5 deletions(-) (limited to 'gcc') diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc index 608aceb..73c549f 100644 --- a/gcc/analyzer/sm-malloc.cc +++ b/gcc/analyzer/sm-malloc.cc @@ -1300,6 +1300,7 @@ public: bool emit (rich_location *rich_loc) final override { + /* "CWE-401: Missing Release of Memory after Effective Lifetime". */ diagnostic_metadata m; m.add_cwe (401); if (m_arg) diff --git a/gcc/analyzer/sm-taint.cc b/gcc/analyzer/sm-taint.cc index 51bfe06..549373b 100644 --- a/gcc/analyzer/sm-taint.cc +++ b/gcc/analyzer/sm-taint.cc @@ -435,6 +435,7 @@ public: bool emit (rich_location *rich_loc) override { + /* "CWE-129: Improper Validation of Array Index". */ diagnostic_metadata m; m.add_cwe (129); if (m_arg) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index fd7edd1..38ae900 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -5045,7 +5045,7 @@ the vertical bars and the ``char *'' and ``long int'' text). @opindex fno-diagnostics-show-cwe @opindex fdiagnostics-show-cwe Diagnostic messages can optionally have an associated -@url{https://cwe.mitre.org/index.html, CWE} identifier. +@uref{https://cwe.mitre.org/index.html, CWE} identifier. GCC itself only provides such metadata for some of the @option{-fanalyzer} diagnostics. GCC plugins may also provide diagnostics with such metadata. By default, if this information is present, it will be printed with @@ -9808,7 +9808,7 @@ This diagnostic warns for paths through the code in which a pointer to a buffer is assigned to point at a buffer with a size that is not a multiple of @code{sizeof (*pointer)}. -See @url{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}. +See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}. @item -Wno-analyzer-double-fclose @opindex Wanalyzer-double-fclose @@ -9819,6 +9819,8 @@ This warning requires @option{-fanalyzer}, which enables it; use This diagnostic warns for paths through the code in which a @code{FILE *} can have @code{fclose} called on it more than once. +See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. + @item -Wno-analyzer-double-free @opindex Wanalyzer-double-free @opindex Wno-analyzer-double-free @@ -9829,6 +9831,8 @@ This diagnostic warns for paths through the code in which a pointer can have a deallocator called on it more than once, either @code{free}, or a deallocator referenced by attribute @code{malloc}. +See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}. + @item -Wno-analyzer-exposure-through-output-file @opindex Wanalyzer-exposure-through-output-file @opindex Wno-analyzer-exposure-through-output-file @@ -9840,6 +9844,8 @@ This diagnostic warns for paths through the code in which a security-sensitive value is written to an output file (such as writing a password to a log file). +See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}. + @item -Wno-analyzer-fd-access-mode-mismatch @opindex Wanalyzer-fd-access-mode-mismatch @opindex Wno-analyzer-fd-access-mode-mismatch @@ -9866,6 +9872,8 @@ to disable it. This diagnostic warns for paths through code in which a file descriptor can be closed more than once. +See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. + @item -Wno-analyzer-fd-leak @opindex Wanalyzer-fd-leak @opindex Wno-analyzer-fd-leak @@ -9876,6 +9884,8 @@ to disable it. This diagnostic warns for paths through code in which an open file descriptor is leaked. +See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. + @item -Wno-analyzer-fd-use-after-close @opindex Wanalyzer-fd-use-after-close @opindex Wno-analyzer-fd-use-after-close @@ -9916,6 +9926,8 @@ to disable it. This diagnostic warns for paths through the code in which a @code{} @code{FILE *} stream object is leaked. +See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. + @item -Wno-analyzer-free-of-non-heap @opindex Wanalyzer-free-of-non-heap @opindex Wno-analyzer-free-of-non-heap @@ -9926,6 +9938,8 @@ to disable it. This diagnostic warns for paths through the code in which @code{free} is called on a non-heap pointer (e.g. an on-stack buffer, or a global). +See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}. + @item -Wno-analyzer-malloc-leak @opindex Wanalyzer-malloc-leak @opindex Wno-analyzer-malloc-leak @@ -9937,6 +9951,8 @@ This diagnostic warns for paths through the code in which a pointer allocated via an allocator is leaked: either @code{malloc}, or a function marked with attribute @code{malloc}. +See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}. + @item -Wno-analyzer-mismatching-deallocation @opindex Wanalyzer-mismatching-deallocation @opindex Wno-analyzer-mismatching-deallocation @@ -9951,6 +9967,8 @@ will warn about mismatches between @code{free}, scalar @code{delete} and vector @code{delete[]}, and those marked as allocator/deallocator pairs using attribute @code{malloc}. +See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}. + @item -Wno-analyzer-possible-null-argument @opindex Wanalyzer-possible-null-argument @opindex Wno-analyzer-possible-null-argument @@ -9962,6 +9980,8 @@ possibly-NULL value is passed to a function argument marked with @code{__attribute__((nonnull))} as requiring a non-NULL value. +See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. + @item -Wno-analyzer-possible-null-dereference @opindex Wanalyzer-possible-null-dereference @opindex Wno-analyzer-possible-null-dereference @@ -9971,6 +9991,8 @@ This warning requires @option{-fanalyzer}, which enables it; use This diagnostic warns for paths through the code in which a possibly-NULL value is dereferenced. +See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. + @item -Wno-analyzer-null-argument @opindex Wanalyzer-null-argument @opindex Wno-analyzer-null-argument @@ -9982,6 +10004,8 @@ value known to be NULL is passed to a function argument marked with @code{__attribute__((nonnull))} as requiring a non-NULL value. +See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. + @item -Wno-analyzer-null-dereference @opindex Wanalyzer-null-dereference @opindex Wno-analyzer-null-dereference @@ -9991,6 +10015,8 @@ This warning requires @option{-fanalyzer}, which enables it; use This diagnostic warns for paths through the code in which a value known to be NULL is dereferenced. +See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. + @item -Wno-analyzer-shift-count-negative @opindex Wanalyzer-shift-count-negative @opindex Wno-analyzer-shift-count-negative @@ -10049,7 +10075,7 @@ of an allocation without being sanitized, so that an attacker could inject an excessively large allocation and potentially cause a denial of service attack. -See @url{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}. +See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}. @item -Wno-analyzer-tainted-array-index @opindex Wanalyzer-tainted-array-index @@ -10063,7 +10089,7 @@ that could be under an attacker's control is used as the index of an array access without being sanitized, so that an attacker could inject an out-of-bounds access. -See @url{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. +See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. @item -Wno-analyzer-tainted-divisor @opindex Wanalyzer-tainted-divisor @@ -10077,6 +10103,8 @@ that could be under an attacker's control is used as the divisor in a division or modulus operation without being sanitized, so that an attacker could inject a division-by-zero. +See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}. + @item -Wno-analyzer-tainted-offset @opindex Wanalyzer-tainted-offset @opindex Wno-analyzer-tainted-offset @@ -10089,7 +10117,7 @@ that could be under an attacker's control is used as a pointer offset without being sanitized, so that an attacker could inject an out-of-bounds access. -See @url{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}. +See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}. @item -Wno-analyzer-tainted-size @opindex Wanalyzer-tainted-size @@ -10103,6 +10131,8 @@ that could be under an attacker's control is used as the size of an operation such as @code{memset} without being sanitized, so that an attacker could inject an out-of-bounds access. +See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. + @item -Wno-analyzer-unsafe-call-within-signal-handler @opindex Wanalyzer-unsafe-call-within-signal-handler @opindex Wno-analyzer-unsafe-call-within-signal-handler @@ -10113,6 +10143,8 @@ This diagnostic warns for paths through the code in which a function known to be async-signal-unsafe (such as @code{fprintf}) is called from a signal handler. +See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}. + @item -Wno-analyzer-use-after-free @opindex Wanalyzer-use-after-free @opindex Wno-analyzer-use-after-free @@ -10123,6 +10155,8 @@ This diagnostic warns for paths through the code in which a pointer is used after a deallocator is called on it: either @code{free}, or a deallocator referenced by attribute @code{malloc}. +See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}. + @item -Wno-analyzer-use-of-pointer-in-stale-stack-frame @opindex Wanalyzer-use-of-pointer-in-stale-stack-frame @opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame @@ -10145,6 +10179,8 @@ the analyzer detects an attempt to use @code{va_arg} to extract a value passed to a variadic call, but uses a type that does not match that of the expression passed to the call. +See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}. + @item -Wno-analyzer-va-list-exhausted @opindex Wanalyzer-va-list-exhausted @opindex Wno-analyzer-va-list-exhausted @@ -10157,6 +10193,8 @@ the analyzer detects an attempt to use @code{va_arg} to access the next value passed to a variadic call, but all of the values in the @code{va_list} have already been consumed. +See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}. + @item -Wno-analyzer-va-list-leak @opindex Wanalyzer-va-list-leak @opindex Wno-analyzer-va-list-leak @@ -10213,6 +10251,8 @@ This warning requires @option{-fanalyzer}, which enables it; use This diagnostic warns for paths through the code in which an uninitialized value is used. +See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}. + @end table Pertinent parameters for controlling the exploration are: -- cgit v1.1 From 872693eebb6b88f4b6a2767727a9565d05172768 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 28 Jul 2022 17:21:29 -0400 Subject: analyzer: new warning: -Wanalyzer-putenv-of-auto-var [PR105893] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch implements a new -fanalyzer warning: -Wanalyzer-putenv-of-auto-var which complains about stack pointers passed to putenv(3) calls, as per SEI CERT C Coding Standard rule POS34-C ("Do not call putenv() with a pointer to an automatic variable as the argument"). For example, given: #include #include void test_arr (void) { char arr[] = "NAME=VALUE"; putenv (arr); } it emits: demo.c: In function ‘test_arr’: demo.c:7:3: warning: ‘putenv’ on a pointer to automatic variable ‘arr’ [POS34-C] [-Wanalyzer-putenv-of-auto-var] 7 | putenv (arr); | ^~~~~~~~~~~~ ‘test_arr’: event 1 | | 7 | putenv (arr); | | ^~~~~~~~~~~~ | | | | | (1) ‘putenv’ on a pointer to automatic variable ‘arr’ | demo.c:6:8: note: ‘arr’ declared on stack here 6 | char arr[] = "NAME=VALUE"; | ^~~ demo.c:7:3: note: perhaps use ‘setenv’ rather than ‘putenv’ 7 | putenv (arr); | ^~~~~~~~~~~~ gcc/analyzer/ChangeLog: PR analyzer/105893 * analyzer.opt (Wanalyzer-putenv-of-auto-var): New. * region-model-impl-calls.cc (class putenv_of_auto_var): New. (region_model::impl_call_putenv): New. * region-model.cc (region_model::on_call_pre): Handle putenv. * region-model.h (region_model::impl_call_putenv): New decl. gcc/ChangeLog: PR analyzer/105893 * doc/invoke.texi: Add -Wanalyzer-putenv-of-auto-var. gcc/testsuite/ChangeLog: PR analyzer/105893 * gcc.dg/analyzer/putenv-1.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/analyzer.opt | 4 ++ gcc/analyzer/region-model-impl-calls.cc | 117 +++++++++++++++++++++++++++++++ gcc/analyzer/region-model.cc | 6 ++ gcc/analyzer/region-model.h | 1 + gcc/doc/invoke.texi | 14 ++++ gcc/testsuite/gcc.dg/analyzer/putenv-1.c | 109 ++++++++++++++++++++++++++++ 6 files changed, 251 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/analyzer/putenv-1.c (limited to 'gcc') diff --git a/gcc/analyzer/analyzer.opt b/gcc/analyzer/analyzer.opt index 5021376..808ff36 100644 --- a/gcc/analyzer/analyzer.opt +++ b/gcc/analyzer/analyzer.opt @@ -126,6 +126,10 @@ Wanalyzer-null-dereference Common Var(warn_analyzer_null_dereference) Init(1) Warning Warn about code paths in which a NULL pointer is dereferenced. +Wanalyzer-putenv-of-auto-var +Common Var(warn_analyzer_putenv_of_auto_var) Init(1) Warning +Warn about code paths in which an on-stack buffer is passed to putenv. + Wanalyzer-shift-count-negative Common Var(warn_analyzer_shift_count_negative) Init(1) Warning Warn about code paths in which a shift with negative count is attempted. diff --git a/gcc/analyzer/region-model-impl-calls.cc b/gcc/analyzer/region-model-impl-calls.cc index 8c38e92..3f821ff 100644 --- a/gcc/analyzer/region-model-impl-calls.cc +++ b/gcc/analyzer/region-model-impl-calls.cc @@ -549,6 +549,123 @@ region_model::impl_call_memset (const call_details &cd) fill_region (sized_dest_reg, fill_value_u8); } +/* A subclass of pending_diagnostic for complaining about 'putenv' + called on an auto var. */ + +class putenv_of_auto_var +: public pending_diagnostic_subclass +{ +public: + putenv_of_auto_var (tree fndecl, const region *reg) + : m_fndecl (fndecl), m_reg (reg), + m_var_decl (reg->get_base_region ()->maybe_get_decl ()) + { + } + + const char *get_kind () const final override + { + return "putenv_of_auto_var"; + } + + bool operator== (const putenv_of_auto_var &other) const + { + return (m_fndecl == other.m_fndecl + && m_reg == other.m_reg + && same_tree_p (m_var_decl, other.m_var_decl)); + } + + int get_controlling_option () const final override + { + return OPT_Wanalyzer_putenv_of_auto_var; + } + + bool emit (rich_location *rich_loc) final override + { + auto_diagnostic_group d; + diagnostic_metadata m; + + /* SEI CERT C Coding Standard: "POS34-C. Do not call putenv() with a + pointer to an automatic variable as the argument". */ + diagnostic_metadata::precanned_rule + rule ("POS34-C", "https://wiki.sei.cmu.edu/confluence/x/6NYxBQ"); + m.add_rule (rule); + + bool warned; + if (m_var_decl) + warned = warning_meta (rich_loc, m, get_controlling_option (), + "%qE on a pointer to automatic variable %qE", + m_fndecl, m_var_decl); + else + warned = warning_meta (rich_loc, m, get_controlling_option (), + "%qE on a pointer to an on-stack buffer", + m_fndecl); + if (warned) + { + if (m_var_decl) + inform (DECL_SOURCE_LOCATION (m_var_decl), + "%qE declared on stack here", m_var_decl); + inform (rich_loc->get_loc (), "perhaps use %qs rather than %qE", + "setenv", m_fndecl); + } + + return warned; + } + + label_text describe_final_event (const evdesc::final_event &ev) final override + { + if (m_var_decl) + return ev.formatted_print ("%qE on a pointer to automatic variable %qE", + m_fndecl, m_var_decl); + else + return ev.formatted_print ("%qE on a pointer to an on-stack buffer", + m_fndecl); + } + + void mark_interesting_stuff (interesting_t *interest) final override + { + if (!m_var_decl) + interest->add_region_creation (m_reg->get_base_region ()); + } + +private: + tree m_fndecl; // non-NULL + const region *m_reg; // non-NULL + tree m_var_decl; // could be NULL +}; + +/* Handle the on_call_pre part of "putenv". + + In theory we could try to model the state of the environment variables + for the process; for now we merely complain about putenv of regions + on the stack. */ + +void +region_model::impl_call_putenv (const call_details &cd) +{ + tree fndecl = cd.get_fndecl_for_call (); + gcc_assert (fndecl); + region_model_context *ctxt = cd.get_ctxt (); + const svalue *ptr_sval = cd.get_arg_svalue (0); + const region *reg = deref_rvalue (ptr_sval, cd.get_arg_tree (0), ctxt); + m_store.mark_as_escaped (reg); + enum memory_space mem_space = reg->get_memory_space (); + switch (mem_space) + { + default: + gcc_unreachable (); + case MEMSPACE_UNKNOWN: + case MEMSPACE_CODE: + case MEMSPACE_GLOBALS: + case MEMSPACE_HEAP: + case MEMSPACE_READONLY_DATA: + break; + case MEMSPACE_STACK: + if (ctxt) + ctxt->warn (new putenv_of_auto_var (fndecl, reg)); + break; + } +} + /* Handle the on_call_pre part of "operator new". */ void diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index f7df2fc..a140f4d 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -1539,6 +1539,12 @@ region_model::on_call_pre (const gcall *call, region_model_context *ctxt, impl_call_memset (cd); return false; } + else if (is_named_call_p (callee_fndecl, "putenv", call, 1) + && POINTER_TYPE_P (cd.get_arg_type (0))) + { + impl_call_putenv (cd); + return false; + } else if (is_named_call_p (callee_fndecl, "strchr", call, 2) && POINTER_TYPE_P (cd.get_arg_type (0))) { diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h index 42f8abe..a9657e0 100644 --- a/gcc/analyzer/region-model.h +++ b/gcc/analyzer/region-model.h @@ -630,6 +630,7 @@ class region_model void impl_call_malloc (const call_details &cd); void impl_call_memcpy (const call_details &cd); void impl_call_memset (const call_details &cd); + void impl_call_putenv (const call_details &cd); void impl_call_realloc (const call_details &cd); void impl_call_strchr (const call_details &cd); void impl_call_strcpy (const call_details &cd); diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 38ae900..e8cd601 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -459,6 +459,7 @@ Objective-C and Objective-C++ Dialects}. -Wno-analyzer-null-dereference @gol -Wno-analyzer-possible-null-argument @gol -Wno-analyzer-possible-null-dereference @gol +-Wno-analyzer-putenv-of-auto-var @gol -Wno-analyzer-shift-count-negative @gol -Wno-analyzer-shift-count-overflow @gol -Wno-analyzer-stale-setjmp-buffer @gol @@ -9761,6 +9762,7 @@ Enabling this option effectively enables the following warnings: -Wanalyzer-null-dereference @gol -Wanalyzer-possible-null-argument @gol -Wanalyzer-possible-null-dereference @gol +-Wanalyzer-putenv-of-auto-var @gol -Wanalyzer-shift-count-negative @gol -Wanalyzer-shift-count-overflow @gol -Wanalyzer-stale-setjmp-buffer @gol @@ -10017,6 +10019,18 @@ value known to be NULL is dereferenced. See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. +@item -Wno-analyzer-putenv-of-auto-var +@opindex Wanalyzer-putenv-of-auto-var +@opindex Wno-analyzer-putenv-of-auto-var +This warning requires @option{-fanalyzer}, which enables it; use +@option{-Wno-analyzer-possible-null-dereference} to disable it. + +This diagnostic warns for paths through the code in which a +call to @code{putenv} is passed a pointer to an automatic variable +or an on-stack buffer. + +See @uref{https://wiki.sei.cmu.edu/confluence/x/6NYxBQ, POS34-C. Do not call putenv() with a pointer to an automatic variable as the argument}. + @item -Wno-analyzer-shift-count-negative @opindex Wanalyzer-shift-count-negative @opindex Wno-analyzer-shift-count-negative diff --git a/gcc/testsuite/gcc.dg/analyzer/putenv-1.c b/gcc/testsuite/gcc.dg/analyzer/putenv-1.c new file mode 100644 index 0000000..4c3f0ae --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/putenv-1.c @@ -0,0 +1,109 @@ +/* { dg-additional-options "-Wno-analyzer-null-argument" } */ + +#include +#include + +extern void populate (char *buf); + +void test_passthrough (char *s) +{ + putenv (s); +} + +void test_str_lit (void) +{ + putenv ("NAME=value"); +} + +/* glibc allows strings without an equal sign. */ + +void test_no_eq (void) +{ + putenv ("NAME"); +} + +void test_empty_string (void) +{ + putenv (""); +} + +void test_NULL (void) +{ + putenv (NULL); /* possibly -Wanalyzer-null-argument */ +} + +void test_auto_buf_name_and_value (const char *name, const char *value) +{ + char buf[100]; /* { dg-message "'buf' declared on stack here" } */ + snprintf (buf, sizeof (buf), "%s=%s", name, value); + putenv (buf); /* { dg-warning "'putenv' on a pointer to automatic variable 'buf' \\\[POS34-C\\\]" "warning" } */ + /* { dg-message "perhaps use 'setenv' rather than 'putenv'" "setenv suggestion" { target *-*-* } .-1 } */ +} + +void test_auto_buf_value (const char *value) +{ + char buf[100]; /* { dg-message "'buf' declared on stack here" } */ + snprintf (buf, sizeof (buf), "NAME=%s", value); + putenv (buf); /* { dg-warning "'putenv' on a pointer to automatic variable 'buf' \\\[POS34-C\\\]" } */ +} + +void test_static_buf (const char *value) +{ + static char buf[100]; + snprintf (buf, sizeof (buf), "NAME=%s", value); + putenv (buf); +} + +static char global_buf[1024]; + +void test_global (const char *value) +{ + snprintf (global_buf, sizeof (global_buf), "NAME=%s", value); + putenv (global_buf); +} + +void test_alloca (void) +{ + char *buf = __builtin_alloca (256); /* { dg-message "region created on stack here" } */ + populate (buf); + putenv (buf); /* { dg-warning "'putenv' on a pointer to an on-stack buffer \\\[POS34-C\\\]" } */ +} + +void test_malloc_1 (void) +{ + char *buf = malloc (1024); + if (!buf) + return; + populate (buf); + putenv (buf); +} + +void test_malloc_2 (void) +{ + const char *kvstr = "NAME=value"; + size_t len = __builtin_strlen (kvstr); + char *buf = __builtin_malloc (len + 1); + if (!buf) + return; + __builtin_memcpy (buf, kvstr, len); + buf[len] = '\0'; + putenv (buf); /* { dg-bogus "leak" } */ +} + +void test_arr (void) +{ + char arr[] = "NAME=VALUE"; /* { dg-message "'arr' declared on stack here" } */ + putenv (arr); /* { dg-warning "'putenv' on a pointer to automatic variable 'arr' \\\[POS34-C\\\]" } */ +} + +static void __attribute__((noinline)) +__analyzer_test_inner (char *kvstr) +{ + putenv (kvstr); /* { dg-warning "'putenv' on a pointer to automatic variable 'arr_outer' \\\[POS34-C\\\]" } */ +} + +void test_outer (void) +{ + char arr_outer[] = "NAME=VALUE"; /* { dg-message "'arr_outer' declared on stack here" } */ + __analyzer_test_inner (arr_outer); +} -- cgit v1.1 From af086d19112bfd011fafaee41b0da292b2176def Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 29 Jul 2022 00:16:21 +0000 Subject: Daily bump. --- gcc/ChangeLog | 46 ++++++++++++++++++++++++++++++ gcc/DATESTAMP | 2 +- gcc/analyzer/ChangeLog | 19 +++++++++++++ gcc/jit/ChangeLog | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ gcc/testsuite/ChangeLog | 25 ++++++++++++++++ 5 files changed, 167 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3fc56a6..8c86ab2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,49 @@ +2022-07-28 David Malcolm + + PR analyzer/105893 + * doc/invoke.texi: Add -Wanalyzer-putenv-of-auto-var. + +2022-07-28 David Malcolm + + * doc/invoke.texi (-fdiagnostics-show-cwe): Use uref rather than + url. + (Static Analyzer Options): Likewise. Add urefs for all of the + warnings that have associated CWE identifiers. + +2022-07-28 Maciej W. Rozycki + + * doc/implement-c.texi (Floating point implementation): Mention + `-fno-trapping-math' in the context of FENV_ACCESS pragma. + * doc/invoke.texi (Optimize Options): Clarify FENV_ACCESS pragma + implication in the descriptions of `-fno-trapping-math' and + `-frounding-math'. + +2022-07-28 Maciej W. Rozycki + + * config/riscv/riscv.md (UNSPECV_FSNVSNAN): New constant. + (QUIET_PATTERN): New int attribute. + (f_quiet4): Emit the intended + RTL insns entirely within the preparation statements. + (*f_quiet4_default) + (*f_quiet4_snan): Remove + insns. + (*riscv_fsnvsnan2): New insn. + +2022-07-28 Richard Biener + + PR middle-end/106457 + * tree.cc (array_at_struct_end_p): Handle array objects + specially. + +2022-07-28 Jakub Jelinek + + PR tree-optimization/106099 + * internal-fn.def (TRAP): New internal fn. + * internal-fn.h (expand_TRAP): Declare. + * internal-fn.cc (expand_TRAP): Define. + * gimple.cc (gimple_build_builtin_unreachable): For BUILT_IN_TRAP, + use internal fn rather than builtin. + 2022-07-27 Andrew Carlotti * doc/loop.texi: Refer to LOOPS_HAVE_RECORDED_EXITS instead. diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 12a0671..87ee496 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20220728 +20220729 diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog index d10a5c8..d1cb3ad 100644 --- a/gcc/analyzer/ChangeLog +++ b/gcc/analyzer/ChangeLog @@ -1,3 +1,22 @@ +2022-07-28 David Malcolm + + PR analyzer/105893 + * analyzer.opt (Wanalyzer-putenv-of-auto-var): New. + * region-model-impl-calls.cc (class putenv_of_auto_var): New. + (region_model::impl_call_putenv): New. + * region-model.cc (region_model::on_call_pre): Handle putenv. + * region-model.h (region_model::impl_call_putenv): New decl. + +2022-07-28 David Malcolm + + * sm-malloc.cc (free_of_non_heap::emit): Add comment about CWE. + * sm-taint.cc (tainted_size::emit): Likewise. + +2022-07-28 David Malcolm + + * region.h: Add notes to the comment describing the region + class hierarchy. + 2022-07-27 Immad Mir PR analyzer/106286 diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index 581f682..df8bf40 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,79 @@ +2022-07-28 David Malcolm + + * docs/internals/index.rst: Remove reference to ".c" extensions + of source files. + +2022-07-28 Martin Liška + + * docs/cp/intro/tutorial02.rst: + Shorten the assembly example so that there is not slider. + * docs/cp/intro/tutorial04.rst: Likewise. + * docs/intro/tutorial02.rst: Likewise. + * docs/intro/tutorial04.rst: Likewise. + * docs/topics/contexts.rst: Likewise. + +2022-07-28 marxin + + * docs/index.rst: Remove reference to module index + as we don't emit any. + +2022-07-28 marxin + + * docs/cp/intro/tutorial02.rst: Use :expr:`type *` for pointers to a type + * docs/cp/topics/asm.rst: Likewise. + * docs/cp/topics/contexts.rst: Likewise. + * docs/cp/topics/expressions.rst: Likewise. + * docs/cp/topics/functions.rst: Likewise. + * docs/cp/topics/objects.rst: Likewise. + * docs/intro/tutorial02.rst: Likewise. + * docs/intro/tutorial03.rst: Likewise. + * docs/intro/tutorial04.rst: Likewise. + * docs/intro/tutorial05.rst: Likewise. + * docs/topics/compilation.rst: Likewise. + * docs/topics/contexts.rst: Likewise. + * docs/topics/objects.rst: Likewise. + +2022-07-28 marxin + + * docs/cp/intro/tutorial04.rst: Use list-table. + * docs/intro/tutorial04.rst: Likewise. + * docs/intro/tutorial05.rst: Likewise. + * docs/topics/compilation.rst: Likewise. + * docs/topics/expressions.rst: Likewise. + * docs/topics/types.rst: Likewise. + +2022-07-28 marxin + + * docs/cp/topics/expressions.rst: Compact so that the generated + output is also more compact. + +2022-07-28 marxin + + * docs/cp/intro/tutorial02.rst: Use proper reference. + * docs/cp/topics/contexts.rst: Likewise. + * docs/cp/topics/functions.rst: Put `class` directive before a + function as it is not allowed declaring a class in a fn. + * docs/cp/topics/types.rst: Add template keyword. + * docs/examples/tut04-toyvm/toyvm.c (toyvm_function_compile): + Add removed comment used for code snippet ending detection. + * docs/intro/tutorial04.rst: Fix to match the real comment. + +2022-07-28 marxin + + * docs/cp/topics/expressions.rst: Use :expr: for basic types. + * docs/topics/compilation.rst: Likewise. + * docs/topics/expressions.rst: Likewise. + * docs/topics/function-pointers.rst: Likewise. + +2022-07-28 marxin + + * docs/conf.py: Add needs_sphinx = '3.0' where c:type was added. + * docs/index.rst: Remove note about it. + * docs/topics/compilation.rst: Use enum directive and reference. + * docs/topics/contexts.rst: Likewise. + * docs/topics/expressions.rst: Likewise. + * docs/topics/functions.rst: Likewise. + 2022-07-14 Jonathan Wakely * jit-recording.h (recording::memento): Define copy constructor diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 50686c7..f47c2ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,28 @@ +2022-07-28 David Malcolm + + PR analyzer/105893 + * gcc.dg/analyzer/putenv-1.c: New test. + +2022-07-28 Maciej W. Rozycki + + * gcc.target/riscv/fle-ieee.c: New test. + * gcc.target/riscv/fle-snan.c: New test. + * gcc.target/riscv/fle.c: New test. + * gcc.target/riscv/flef-ieee.c: New test. + * gcc.target/riscv/flef-snan.c: New test. + * gcc.target/riscv/flef.c: New test. + * gcc.target/riscv/flt-ieee.c: New test. + * gcc.target/riscv/flt-snan.c: New test. + * gcc.target/riscv/flt.c: New test. + * gcc.target/riscv/fltf-ieee.c: New test. + * gcc.target/riscv/fltf-snan.c: New test. + * gcc.target/riscv/fltf.c: New test. + +2022-07-28 Jakub Jelinek + + PR tree-optimization/106099 + * gcc.dg/ubsan/pr106099.c: New test. + 2022-07-27 Lewis Hyatt * c-c++-common/pragma-diag-14.c: New test. -- cgit v1.1 From b234f5240cafe63c124a8457015aa0447d6db525 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 28 Jul 2022 15:08:23 +0200 Subject: Avoid vect_get_vector_types_for_stmt This replaces vect_get_vector_types_for_stmt with get_vectype_for_scalar_type in vect_recog_bool_pattern. * tree-vect-patterns.cc (vect_recog_bool_pattern): Use get_vectype_for_scalar_type instead of vect_get_vector_types_for_stmt. --- gcc/tree-vect-patterns.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'gcc') diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index dfbfb71..09574bb 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -4509,10 +4509,8 @@ vect_recog_bool_pattern (vec_info *vinfo, && STMT_VINFO_DATA_REF (stmt_vinfo)) { stmt_vec_info pattern_stmt_info; - tree nunits_vectype; - if (!vect_get_vector_types_for_stmt (vinfo, stmt_vinfo, &vectype, - &nunits_vectype) - || !VECTOR_MODE_P (TYPE_MODE (vectype))) + vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (lhs)); + if (!vectype || !VECTOR_MODE_P (TYPE_MODE (vectype))) return NULL; if (check_bool_pattern (var, vinfo, bool_stmts)) -- cgit v1.1 From 0c0feae60aa2f1a29d2624399cbcc6b1a52cc07c Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 28 Jul 2022 15:07:28 +0200 Subject: Use CONVERT_EXPR_CODE_P * gimple-ssa-warn-restrict.cc (builtin_memref::set_base_and_offset): Use CONVERT_EXPR_CODE_P. --- gcc/gimple-ssa-warn-restrict.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/gimple-ssa-warn-restrict.cc b/gcc/gimple-ssa-warn-restrict.cc index 6b6097a..b7ed15c 100644 --- a/gcc/gimple-ssa-warn-restrict.cc +++ b/gcc/gimple-ssa-warn-restrict.cc @@ -430,7 +430,7 @@ builtin_memref::set_base_and_offset (tree expr) else if (is_gimple_assign (stmt)) { tree_code code = gimple_assign_rhs_code (stmt); - if (code == NOP_EXPR) + if (CONVERT_EXPR_CODE_P (code)) { tree rhs = gimple_assign_rhs1 (stmt); if (POINTER_TYPE_P (TREE_TYPE (rhs))) -- cgit v1.1 From 201e8d9f82444403682cd583ce0a03e3e3dd2b73 Mon Sep 17 00:00:00 2001 From: Lulu Cheng Date: Fri, 29 Jul 2022 09:44:52 +0800 Subject: LoongArch: Define the macro ASM_PREFERRED_EH_DATA_FORMAT by checking the assembler's support for eh_frame encoding. .eh_frame DW_EH_PE_pcrel encoding format is not supported by gas <= 2.39. Check if the assembler support DW_EH_PE_PCREL encoding and define .eh_frame encoding type. gcc/ChangeLog: * config.in: Regenerate. * config/loongarch/loongarch.h (ASM_PREFERRED_EH_DATA_FORMAT): Select the value of the macro definition according to whether HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT is defined. * configure: Regenerate. * configure.ac: Reinstate HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT test. --- gcc/config.in | 8 +++++++- gcc/config/loongarch/loongarch.h | 5 +++++ gcc/configure | 34 ++++++++++++++++++++++++++++++++++ gcc/configure.ac | 8 ++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/config.in b/gcc/config.in index 16bb963..413b2bd 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -404,13 +404,19 @@ #endif +/* Define if your assembler supports eh_frame pcrel encoding. */ +#ifndef USED_FOR_TARGET +#undef HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT +#endif + + /* Define if your assembler supports the R_PPC64_ENTRY relocation. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_ENTRY_MARKERS #endif -/* Define if your assembler supports explicit relocations. */ +/* Define if your assembler supports explicit relocation. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_EXPLICIT_RELOCS #endif diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h index 89a5bd7..8b12889 100644 --- a/gcc/config/loongarch/loongarch.h +++ b/gcc/config/loongarch/loongarch.h @@ -1127,8 +1127,13 @@ struct GTY (()) machine_function }; #endif +#ifdef HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT +#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ + (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) +#else #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_absptr) +#endif /* Do emit .note.GNU-stack by default. */ #ifndef NEED_INDICATE_EXEC_STACK diff --git a/gcc/configure b/gcc/configure index 7eb9479..05efa5b 100755 --- a/gcc/configure +++ b/gcc/configure @@ -28838,6 +28838,40 @@ $as_echo "#define HAVE_AS_EXPLICIT_RELOCS 1" >>confdefs.h fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for eh_frame pcrel encoding support" >&5 +$as_echo_n "checking assembler for eh_frame pcrel encoding support... " >&6; } +if ${gcc_cv_as_loongarch_eh_frame_pcrel_encoding_support+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_loongarch_eh_frame_pcrel_encoding_support=no + if test x$gcc_cv_as != x; then + $as_echo '.cfi_startproc + .cfi_personality 0x9b,a + .cfi_lsda 0x1b,b + .cfi_endproc' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_loongarch_eh_frame_pcrel_encoding_support=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_loongarch_eh_frame_pcrel_encoding_support" >&5 +$as_echo "$gcc_cv_as_loongarch_eh_frame_pcrel_encoding_support" >&6; } +if test $gcc_cv_as_loongarch_eh_frame_pcrel_encoding_support = yes; then + +$as_echo "#define HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT 1" >>confdefs.h + +fi + ;; s390*-*-*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .gnu_attribute support" >&5 diff --git a/gcc/configure.ac b/gcc/configure.ac index e5f708c..f70b6c2 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5302,6 +5302,14 @@ x: [a:pcalau12i $t0,%pc_hi20(a)],, [AC_DEFINE(HAVE_AS_EXPLICIT_RELOCS, 1, [Define if your assembler supports explicit relocation.])]) + gcc_GAS_CHECK_FEATURE([eh_frame pcrel encoding support], + gcc_cv_as_loongarch_eh_frame_pcrel_encoding_support,, + [.cfi_startproc + .cfi_personality 0x9b,a + .cfi_lsda 0x1b,b + .cfi_endproc],, + [AC_DEFINE(HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT, 1, + [Define if your assembler supports eh_frame pcrel encoding.])]) ;; s390*-*-*) gcc_GAS_CHECK_FEATURE([.gnu_attribute support], -- cgit v1.1 From 4796d16de657d7c2720471e61432de0f4a5cb6df Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 29 Jul 2022 09:43:34 +0200 Subject: openmp: Simplify fold_build_pointer_plus callers in omp-expand Tobias mentioned in PR106449 that fold_build_pointer_plus already fold_converts the second argument to sizetype if it doesn't already have an integral type gimple compatible with sizetype. So, this patch simplifies the callers of fold_build_pointer_plus in omp-expand so that they don't do those conversions manually. 2022-07-29 Jakub Jelinek * omp-expand.cc (expand_omp_for_init_counts, expand_omp_for_init_vars, extract_omp_for_update_vars, expand_omp_for_ordered_loops, expand_omp_simd): Don't fold_convert second argument to fold_build_pointer_plus to sizetype. --- gcc/omp-expand.cc | 51 +++++++++++++++------------------------------------ 1 file changed, 15 insertions(+), 36 deletions(-) (limited to 'gcc') diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc index 1023c56..9cc61fe 100644 --- a/gcc/omp-expand.cc +++ b/gcc/omp-expand.cc @@ -2267,8 +2267,7 @@ expand_omp_for_init_counts (struct omp_for_data *fd, gimple_stmt_iterator *gsi, else if (POINTER_TYPE_P (itype)) { gcc_assert (integer_onep (fd->loops[i].m1)); - t = fold_convert (sizetype, - unshare_expr (fd->loops[i].n1)); + t = unshare_expr (fd->loops[i].n1); n1 = fold_build_pointer_plus (vs[i - fd->loops[i].outer], t); } else @@ -2291,8 +2290,7 @@ expand_omp_for_init_counts (struct omp_for_data *fd, gimple_stmt_iterator *gsi, else if (POINTER_TYPE_P (itype)) { gcc_assert (integer_onep (fd->loops[i].m2)); - t = fold_convert (sizetype, - unshare_expr (fd->loops[i].n2)); + t = unshare_expr (fd->loops[i].n2); n2 = fold_build_pointer_plus (vs[i - fd->loops[i].outer], t); } else @@ -2353,8 +2351,7 @@ expand_omp_for_init_counts (struct omp_for_data *fd, gimple_stmt_iterator *gsi, tree step = fold_convert (itype, unshare_expr (fd->loops[i].step)); if (POINTER_TYPE_P (TREE_TYPE (vs[i]))) - t = fold_build_pointer_plus (vs[i], - fold_convert (sizetype, step)); + t = fold_build_pointer_plus (vs[i], step); else t = fold_build2 (PLUS_EXPR, itype, vs[i], step); t = force_gimple_operand_gsi (&gsi2, t, true, NULL_TREE, @@ -2794,8 +2791,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi, else if (POINTER_TYPE_P (itype)) { gcc_assert (integer_onep (fd->loops[j].m1)); - t = fold_convert (sizetype, - unshare_expr (fd->loops[j].n1)); + t = unshare_expr (fd->loops[j].n1); n1 = fold_build_pointer_plus (vs[j - fd->loops[j].outer], t); } else @@ -2818,8 +2814,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi, else if (POINTER_TYPE_P (itype)) { gcc_assert (integer_onep (fd->loops[j].m2)); - t = fold_convert (sizetype, - unshare_expr (fd->loops[j].n2)); + t = unshare_expr (fd->loops[j].n2); n2 = fold_build_pointer_plus (vs[j - fd->loops[j].outer], t); } else @@ -2895,8 +2890,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi, tree step = fold_convert (itype, unshare_expr (fd->loops[j].step)); if (POINTER_TYPE_P (vtype)) - t = fold_build_pointer_plus (vs[j], fold_convert (sizetype, - step)); + t = fold_build_pointer_plus (vs[j], step); else t = fold_build2 (PLUS_EXPR, itype, vs[j], step); } @@ -2959,8 +2953,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi, = fold_convert (itype, unshare_expr (fd->loops[j].step)); t = fold_build2 (MULT_EXPR, itype, t, t2); if (POINTER_TYPE_P (vtype)) - t = fold_build_pointer_plus (n1, - fold_convert (sizetype, t)); + t = fold_build_pointer_plus (n1, t); else t = fold_build2 (PLUS_EXPR, itype, n1, t); } @@ -2970,8 +2963,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi, t = fold_build2 (MULT_EXPR, itype, t, fold_convert (itype, fd->loops[j].step)); if (POINTER_TYPE_P (vtype)) - t = fold_build_pointer_plus (fd->loops[j].n1, - fold_convert (sizetype, t)); + t = fold_build_pointer_plus (fd->loops[j].n1, t); else t = fold_build2 (PLUS_EXPR, itype, fd->loops[j].n1, t); } @@ -3035,9 +3027,8 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi, if (POINTER_TYPE_P (itype)) { gcc_assert (integer_onep (fd->loops[i].m2)); - t = fold_convert (sizetype, unshare_expr (fd->loops[i].n2)); t = fold_build_pointer_plus (fd->loops[i - fd->loops[i].outer].v, - t); + unshare_expr (fd->loops[i].n2)); } else { @@ -3130,7 +3121,7 @@ extract_omp_for_update_vars (struct omp_for_data *fd, tree *nonrect_bounds, { if (POINTER_TYPE_P (TREE_TYPE (l->v))) t = fold_build_pointer_plus (fd->loops[i + 1 - l->outer].v, - fold_convert (sizetype, t)); + t); else { tree t2 @@ -3186,9 +3177,7 @@ extract_omp_for_update_vars (struct omp_for_data *fd, tree *nonrect_bounds, if (l->m1) { if (POINTER_TYPE_P (TREE_TYPE (l->v))) - t = fold_build_pointer_plus (fd->loops[i].v, - fold_convert (sizetype, - l->n1)); + t = fold_build_pointer_plus (fd->loops[i].v, l->n1); else { t = fold_build2 (MULT_EXPR, TREE_TYPE (l->m1), l->m1, @@ -3210,9 +3199,7 @@ extract_omp_for_update_vars (struct omp_for_data *fd, tree *nonrect_bounds, if (l->m2) { if (POINTER_TYPE_P (TREE_TYPE (l->v))) - t = fold_build_pointer_plus (fd->loops[i].v, - fold_convert (sizetype, - l->n2)); + t = fold_build_pointer_plus (fd->loops[i].v, l->n2); else { t = fold_build2 (MULT_EXPR, TREE_TYPE (l->m2), l->m2, @@ -3640,9 +3627,7 @@ expand_omp_for_ordered_loops (struct omp_for_data *fd, tree *counts, { gsi = gsi_last_bb (cont_bb); if (POINTER_TYPE_P (type)) - t = fold_build_pointer_plus (fd->loops[i].v, - fold_convert (sizetype, - fd->loops[i].step)); + t = fold_build_pointer_plus (fd->loops[i].v, fd->loops[i].step); else t = fold_build2 (PLUS_EXPR, type, fd->loops[i].v, fold_convert (type, fd->loops[i].step)); @@ -6669,10 +6654,7 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd) { i = fd->collapse - 1; if (POINTER_TYPE_P (TREE_TYPE (fd->loops[i].v))) - { - t = fold_convert (sizetype, fd->loops[i].step); - t = fold_build_pointer_plus (fd->loops[i].v, t); - } + t = fold_build_pointer_plus (fd->loops[i].v, fd->loops[i].step); else { t = fold_convert (TREE_TYPE (fd->loops[i].v), @@ -6820,10 +6802,7 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd) e = EDGE_SUCC (last_bb, 1); basic_block bb = split_edge (e); if (POINTER_TYPE_P (TREE_TYPE (fd->loops[i].v))) - { - t = fold_convert (sizetype, fd->loops[i].step); - t = fold_build_pointer_plus (fd->loops[i].v, t); - } + t = fold_build_pointer_plus (fd->loops[i].v, fd->loops[i].step); else { t = fold_convert (TREE_TYPE (fd->loops[i].v), -- cgit v1.1 From 97d32048c04e9787fccadc4bae1c042754503e34 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 29 Jul 2022 09:49:11 +0200 Subject: openmp: Fix up handling of non-rectangular simd loops with pointer type iterators [PR106449] There were 2 issues visible on this new testcase, one that we didn't have special POINTER_TYPE_P handling in a few spots of expand_omp_simd - for pointers we need to use POINTER_PLUS_EXPR and need to have the non-pointer part in sizetype, for non-rectangular loop on the other side we can rely on multiplication factor 1, pointers can't be multiplied, without those changes we'd ICE. The other issue was that we put n2 expression directly into a comparison in a condition and regimplified that, for the &a[512] case that and with gimplification being destructed that unfortunately meant modification of original fd->loops[?].n2. Fixed by unsharing the expression. This was causing a runtime failure on the testcase. 2022-07-29 Jakub Jelinek PR middle-end/106449 * omp-expand.cc (expand_omp_simd): Fix up handling of pointer iterators in non-rectangular simd loops. Unshare fd->loops[i].n2 or n2 before regimplifying it inside of a condition. * testsuite/libgomp.c-c++-common/pr106449.c: New test. --- gcc/omp-expand.cc | 57 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 18 deletions(-) (limited to 'gcc') diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc index 9cc61fe..936adff 100644 --- a/gcc/omp-expand.cc +++ b/gcc/omp-expand.cc @@ -6696,7 +6696,7 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd) if (fd->loops[i].m2) t = n2v = create_tmp_var (itype); else - t = fold_convert (itype, fd->loops[i].n2); + t = fold_convert (itype, unshare_expr (fd->loops[i].n2)); t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, false, GSI_CONTINUE_LINKING); tree v = fd->loops[i].v; @@ -6710,7 +6710,7 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd) if (fd->collapse > 1 && !broken_loop) t = n2var; else - t = fold_convert (type, n2); + t = fold_convert (type, unshare_expr (n2)); t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, false, GSI_CONTINUE_LINKING); tree v = fd->loop.v; @@ -6819,7 +6819,7 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd) if (fd->loops[i].m2) t = nextn2v = create_tmp_var (itype); else - t = fold_convert (itype, fd->loops[i].n2); + t = fold_convert (itype, unshare_expr (fd->loops[i].n2)); t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, false, GSI_CONTINUE_LINKING); tree v = fd->loops[i].v; @@ -6849,17 +6849,25 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd) ne->probability = e->probability.invert (); gsi = gsi_after_labels (init_bb); - t = fold_convert (TREE_TYPE (fd->loops[i + 1].v), - fd->loops[i + 1].n1); if (fd->loops[i + 1].m1) { - tree t2 = fold_convert (TREE_TYPE (t), + tree t2 = fold_convert (TREE_TYPE (fd->loops[i + 1].v), fd->loops[i + 1 - fd->loops[i + 1].outer].v); - tree t3 = fold_convert (TREE_TYPE (t), fd->loops[i + 1].m1); - t2 = fold_build2 (MULT_EXPR, TREE_TYPE (t), t2, t3); - t = fold_build2 (PLUS_EXPR, TREE_TYPE (t), t, t2); + if (POINTER_TYPE_P (TREE_TYPE (t2))) + t = fold_build_pointer_plus (t2, fd->loops[i + 1].n1); + else + { + t = fold_convert (TREE_TYPE (fd->loops[i + 1].v), + fd->loops[i + 1].n1); + tree t3 = fold_convert (TREE_TYPE (t), fd->loops[i + 1].m1); + t2 = fold_build2 (MULT_EXPR, TREE_TYPE (t), t2, t3); + t = fold_build2 (PLUS_EXPR, TREE_TYPE (t), t, t2); + } } + else + t = fold_convert (TREE_TYPE (fd->loops[i + 1].v), + fd->loops[i + 1].n1); expand_omp_build_assign (&gsi, fd->loops[i + 1].v, t); if (fd->loops[i + 1].m2) { @@ -6868,14 +6876,19 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd) gcc_assert (n2v == NULL_TREE); n2v = create_tmp_var (TREE_TYPE (fd->loops[i + 1].v)); } - t = fold_convert (TREE_TYPE (fd->loops[i + 1].v), - fd->loops[i + 1].n2); - tree t2 = fold_convert (TREE_TYPE (t), + tree t2 = fold_convert (TREE_TYPE (fd->loops[i + 1].v), fd->loops[i + 1 - fd->loops[i + 1].outer].v); - tree t3 = fold_convert (TREE_TYPE (t), fd->loops[i + 1].m2); - t2 = fold_build2 (MULT_EXPR, TREE_TYPE (t), t2, t3); - t = fold_build2 (PLUS_EXPR, TREE_TYPE (t), t, t2); + if (POINTER_TYPE_P (TREE_TYPE (t2))) + t = fold_build_pointer_plus (t2, fd->loops[i + 1].n2); + else + { + t = fold_convert (TREE_TYPE (fd->loops[i + 1].v), + fd->loops[i + 1].n2); + tree t3 = fold_convert (TREE_TYPE (t), fd->loops[i + 1].m2); + t2 = fold_build2 (MULT_EXPR, TREE_TYPE (t), t2, t3); + t = fold_build2 (PLUS_EXPR, TREE_TYPE (t), t, t2); + } expand_omp_build_assign (&gsi, n2v, t); } if (i + 2 == fd->collapse && n2var) @@ -6891,17 +6904,25 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd) tree t2 = fold_build2 (MINUS_EXPR, type, n2, fd->loop.v); if (fd->loops[i + 1].m1 || fd->loops[i + 1].m2) { + tree itype = TREE_TYPE (fd->loops[i].v); + if (POINTER_TYPE_P (itype)) + itype = signed_type_for (itype); t = build_int_cst (itype, (fd->loops[i + 1].cond_code == LT_EXPR ? -1 : 1)); t = fold_build2 (PLUS_EXPR, itype, fold_convert (itype, fd->loops[i + 1].step), t); - if (fd->loops[i + 1].m2) - t = fold_build2 (PLUS_EXPR, itype, t, n2v); - else + if (fd->loops[i + 1].m2 == NULL_TREE) t = fold_build2 (PLUS_EXPR, itype, t, fold_convert (itype, fd->loops[i + 1].n2)); + else if (POINTER_TYPE_P (TREE_TYPE (n2v))) + { + t = fold_build_pointer_plus (n2v, t); + t = fold_convert (itype, t); + } + else + t = fold_build2 (PLUS_EXPR, itype, t, n2v); t = fold_build2 (MINUS_EXPR, itype, t, fold_convert (itype, fd->loops[i + 1].v)); tree step = fold_convert (itype, fd->loops[i + 1].step); -- cgit v1.1 From 2dcceedb3c121f2498ae58d8414e7b8454b7bf55 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 29 Jul 2022 09:59:19 +0200 Subject: openmp: Reject invalid forms of C++ #pragma omp atomic compare [PR106448] The allowed syntaxes of atomic compare don't allow ()s around the condition of ?:, but we were accepting it in one case for C++. Fixed thusly. 2022-07-29 Jakub Jelinek PR c++/106448 * parser.cc (cp_parser_omp_atomic): For simple cast followed by CPP_QUERY token, don't try cp_parser_binary_operation if compare is true. * c-c++-common/gomp/atomic-32.c: New test. --- gcc/cp/parser.cc | 4 +++- gcc/testsuite/c-c++-common/gomp/atomic-32.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/c-c++-common/gomp/atomic-32.c (limited to 'gcc') diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 4f67441..826595a 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -41535,7 +41535,9 @@ restart: goto saw_error; } token = cp_lexer_peek_token (parser->lexer); - if (token->type != CPP_SEMICOLON && !cp_tree_equal (lhs, rhs1)) + if (token->type != CPP_SEMICOLON + && (!compare || token->type != CPP_QUERY) + && !cp_tree_equal (lhs, rhs1)) { cp_parser_abort_tentative_parse (parser); cp_parser_parse_tentatively (parser); diff --git a/gcc/testsuite/c-c++-common/gomp/atomic-32.c b/gcc/testsuite/c-c++-common/gomp/atomic-32.c new file mode 100644 index 0000000..e39a967 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/atomic-32.c @@ -0,0 +1,14 @@ +/* PR c++/106448 */ + +int x, expr; + +void +foo (void) +{ + #pragma omp atomic compare + x = (expr > x) ? expr : x; /* { dg-error "invalid (form|operator)" } */ + #pragma omp atomic compare + x = (x < expr) ? expr : x; /* { dg-error "invalid (form|operator)" } */ + #pragma omp atomic compare + x = (x == expr) ? expr : x; /* { dg-error "invalid (form|operator)" } */ +} -- cgit v1.1 From 4894ba078692a780a461d2f358b5dfaa25719859 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 29 Jul 2022 08:24:52 +0200 Subject: tree-optimization/106422 - verify block copying in forward threading The forward threader failed to check whether it can actually duplicate blocks. The following adds this in a similar place the backwards threader performs this check. PR tree-optimization/106422 * tree-ssa-threadupdate.cc (fwd_jt_path_registry::update_cfg): Check whether we can copy thread blocks and cancel the thread if not. * gcc.dg/torture/pr106422.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr106422.c | 14 ++++++++++++++ gcc/tree-ssa-threadupdate.cc | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr106422.c (limited to 'gcc') diff --git a/gcc/testsuite/gcc.dg/torture/pr106422.c b/gcc/testsuite/gcc.dg/torture/pr106422.c new file mode 100644 index 0000000..a2cef1a --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr106422.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +void vfork() __attribute__((__leaf__)); +void semanage_reload_policy(char *arg, void cb(void)) +{ + if (!arg) + { + cb(); + return; + } + vfork(); + if (arg) + __builtin_free(arg); +} diff --git a/gcc/tree-ssa-threadupdate.cc b/gcc/tree-ssa-threadupdate.cc index f901c77..0f2b319 100644 --- a/gcc/tree-ssa-threadupdate.cc +++ b/gcc/tree-ssa-threadupdate.cc @@ -2678,7 +2678,9 @@ fwd_jt_path_registry::update_cfg (bool may_peel_loop_headers) for (j = 0; j < path->length (); j++) { edge e = (*path)[j]->e; - if (m_removed_edges->find_slot (e, NO_INSERT)) + if (m_removed_edges->find_slot (e, NO_INSERT) + || ((*path)[j]->type == EDGE_COPY_SRC_BLOCK + && !can_duplicate_block_p (e->src))) break; } -- cgit v1.1 From 49ba4fdeb648c149fa7d964ba812084262c3d06f Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 29 Jul 2022 10:40:34 +0200 Subject: tree-optimization/105679 - disable backward threading of unlikely entry The following makes the backward threader reject threads whose entry edge is probably never executed according to the profile. That in particular, for the testcase, avoids threading the irq == 1 check on the path where irq > 31, thereby avoiding spurious -Warray-bounds diagnostics if (irq_1(D) > 31) goto ; [0.00%] else goto ; [100.00%] ;; basic block 3, loop depth 0, count 0 (precise), probably never executed _2 = (unsigned long) irq_1(D); __builtin___ubsan_handle_shift_out_of_bounds (&*.Lubsan_data0, 1, _2); _3 = 1 << irq_1(D); mask_4 = (u32) _3; entry = instance_5(D)->array[irq_1(D)]; capture (mask_4); if (level_6(D) != 0) goto ; [34.00%] else goto ; [66.00%] ;; basic block 5, loop depth 0, count 708669600 (estimated locally), maybe hot if (irq_1(D) == 1) goto ; [20.97%] else goto ; [79.03%] PR tree-optimization/105679 * tree-ssa-threadbackward.cc (back_threader_profitability::profitable_path_p): Avoid threading when the entry edge is probably never executed. --- gcc/tree-ssa-threadbackward.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc') diff --git a/gcc/tree-ssa-threadbackward.cc b/gcc/tree-ssa-threadbackward.cc index 3519aca..90f5331 100644 --- a/gcc/tree-ssa-threadbackward.cc +++ b/gcc/tree-ssa-threadbackward.cc @@ -777,6 +777,15 @@ back_threader_profitability::profitable_path_p (const vec &m_path, "exceeds PARAM_MAX_FSM_THREAD_PATH_INSNS.\n"); return false; } + edge entry = find_edge (m_path[m_path.length () - 1], + m_path[m_path.length () - 2]); + if (probably_never_executed_edge_p (cfun, entry)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, " FAIL: Jump-thread path not considered: " + "path entry is probably never executed.\n"); + return false; + } } else if (!m_speed_p && n_insns > 1) { -- cgit v1.1 From a6afbe5e9528e9ec3f0426d9791bd28e6e584d82 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Fri, 29 Jul 2022 12:36:07 +0200 Subject: OpenMP/Fortran: Permit assumed-size arrays in uniform clause gcc/fortran/ChangeLog: * openmp.cc (resolve_omp_clauses): Permit assumed-size arrays in uniform clause. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/declare-simd-3.f90: New test. --- gcc/fortran/openmp.cc | 3 ++- gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 | 30 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 (limited to 'gcc') diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index df9cdf4..a7eb6c3 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -7386,7 +7386,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, || code->op == EXEC_OACC_PARALLEL || code->op == EXEC_OACC_SERIAL)) check_array_not_assumed (n->sym, n->where, name); - else if (n->sym->as && n->sym->as->type == AS_ASSUMED_SIZE) + else if (list != OMP_LIST_UNIFORM + && n->sym->as && n->sym->as->type == AS_ASSUMED_SIZE) gfc_error ("Assumed size array %qs in %s clause at %L", n->sym->name, name, &n->where); if (n->sym->attr.in_namelist && !is_reduction) diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 new file mode 100644 index 0000000..b94587ef --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 @@ -0,0 +1,30 @@ +! { dg-do compile } + +module m + implicit none (type, external) +contains + real function add(x, y, j) result(res) + !$omp declare simd(add) uniform(x, y) linear(j : 1) simdlen(4) + integer, value :: j + real, intent(in) :: x(*), y(*) + res = x(j) + y(j) + end function +end module m + +program main + use m + implicit none (type, external) + real, allocatable :: A(:), B(:), C(:) + integer :: i, N + N = 128 + A = [(3*i, i = 1, N)] + B = [(7*i, i = 1, N)] + allocate (C(N)) + + !$omp simd + do i = 1, N + C(i) = add(A, B, i) + end do + + if (any (C /= [(10*i, i = 1, N)])) error stop +end program main -- cgit v1.1 From 8f4d9c1dedac54942ad28cc1647d48959bec9e77 Mon Sep 17 00:00:00 2001 From: Andrew Stubbs Date: Fri, 15 Jul 2022 15:28:44 +0100 Subject: amdgcn: 64-bit not This makes the auto-vectorizer happier when handling masks. gcc/ChangeLog: * config/gcn/gcn.md (one_cmpldi2): New. --- gcc/config/gcn/gcn.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gcc') diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index 033c170..70a769b 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -1676,6 +1676,26 @@ ;; }}} ;; {{{ ALU: generic 64-bit +(define_insn_and_split "one_cmpldi2" + [(set (match_operand:DI 0 "register_operand" "=Sg, v") + (not:DI (match_operand:DI 1 "gcn_alu_operand" "SgA,vSvDB"))) + (clobber (match_scratch:BI 2 "=cs, X"))] + "" + "#" + "reload_completed" + [(parallel [(set (match_dup 3) (not:SI (match_dup 4))) + (clobber (match_dup 2))]) + (parallel [(set (match_dup 5) (not:SI (match_dup 6))) + (clobber (match_dup 2))])] + { + operands[3] = gcn_operand_part (DImode, operands[0], 0); + operands[4] = gcn_operand_part (DImode, operands[1], 0); + operands[5] = gcn_operand_part (DImode, operands[0], 1); + operands[6] = gcn_operand_part (DImode, operands[1], 1); + } + [(set_attr "type" "mult")] +) + (define_code_iterator vec_and_scalar64_com [and ior xor]) (define_insn_and_split "di3" -- cgit v1.1 From 6e0ca3fe88d8f98ba6b4009c9483e87afbcf4ee8 Mon Sep 17 00:00:00 2001 From: Andrew Stubbs Date: Tue, 19 Jul 2022 11:14:28 +0100 Subject: amdgcn: 64-bit vector shifts Enable 64-bit vector-vector and vector-scalar shifts. gcc/ChangeLog: * config/gcn/gcn-valu.md (V_INT_noHI): New iterator. (3): Use V_INT_noHI. (v3): Likewise. --- gcc/config/gcn/gcn-valu.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'gcc') diff --git a/gcc/config/gcn/gcn-valu.md b/gcc/config/gcn/gcn-valu.md index abe4620..8c33ae0 100644 --- a/gcc/config/gcn/gcn-valu.md +++ b/gcc/config/gcn/gcn-valu.md @@ -60,6 +60,8 @@ (define_mode_iterator V_INT_noQI [V64HI V64SI V64DI]) +(define_mode_iterator V_INT_noHI + [V64SI V64DI]) ; All of above (define_mode_iterator V_ALL @@ -2086,10 +2088,10 @@ }) (define_insn "3" - [(set (match_operand:V_SI 0 "register_operand" "= v") - (shiftop:V_SI - (match_operand:V_SI 1 "gcn_alu_operand" " v") - (vec_duplicate:V_SI + [(set (match_operand:V_INT_noHI 0 "register_operand" "= v") + (shiftop:V_INT_noHI + (match_operand:V_INT_noHI 1 "gcn_alu_operand" " v") + (vec_duplicate: (match_operand:SI 2 "gcn_alu_operand" "SvB"))))] "" "v_0\t%0, %2, %1" @@ -2117,10 +2119,10 @@ }) (define_insn "v3" - [(set (match_operand:V_SI 0 "register_operand" "=v") - (shiftop:V_SI - (match_operand:V_SI 1 "gcn_alu_operand" " v") - (match_operand:V_SI 2 "gcn_alu_operand" "vB")))] + [(set (match_operand:V_INT_noHI 0 "register_operand" "=v") + (shiftop:V_INT_noHI + (match_operand:V_INT_noHI 1 "gcn_alu_operand" " v") + (match_operand: 2 "gcn_alu_operand" "vB")))] "" "v_0\t%0, %2, %1" [(set_attr "type" "vop2") -- cgit v1.1 From b2bf04739fb4170d24a3a83327fdf2b5d1a88520 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 30 Jul 2022 00:16:30 +0000 Subject: Daily bump. --- gcc/ChangeLog | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ gcc/DATESTAMP | 2 +- gcc/cp/ChangeLog | 7 ++++++ gcc/fortran/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 14 ++++++++++++ 5 files changed, 84 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8c86ab2..c5d5cb7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,60 @@ +2022-07-29 Andrew Stubbs + + * config/gcn/gcn-valu.md (V_INT_noHI): New iterator. + (3): Use V_INT_noHI. + (v3): Likewise. + +2022-07-29 Andrew Stubbs + + * config/gcn/gcn.md (one_cmpldi2): New. + +2022-07-29 Richard Biener + + PR tree-optimization/105679 + * tree-ssa-threadbackward.cc + (back_threader_profitability::profitable_path_p): Avoid threading + when the entry edge is probably never executed. + +2022-07-29 Richard Biener + + PR tree-optimization/106422 + * tree-ssa-threadupdate.cc (fwd_jt_path_registry::update_cfg): + Check whether we can copy thread blocks and cancel the thread if not. + +2022-07-29 Jakub Jelinek + + PR middle-end/106449 + * omp-expand.cc (expand_omp_simd): Fix up handling of pointer + iterators in non-rectangular simd loops. Unshare fd->loops[i].n2 + or n2 before regimplifying it inside of a condition. + +2022-07-29 Jakub Jelinek + + * omp-expand.cc (expand_omp_for_init_counts, expand_omp_for_init_vars, + extract_omp_for_update_vars, expand_omp_for_ordered_loops, + expand_omp_simd): Don't fold_convert second argument to + fold_build_pointer_plus to sizetype. + +2022-07-29 Lulu Cheng + + * config.in: Regenerate. + * config/loongarch/loongarch.h (ASM_PREFERRED_EH_DATA_FORMAT): + Select the value of the macro definition according to whether + HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT is defined. + * configure: Regenerate. + * configure.ac: Reinstate HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT test. + +2022-07-29 Richard Biener + + * gimple-ssa-warn-restrict.cc (builtin_memref::set_base_and_offset): + Use CONVERT_EXPR_CODE_P. + +2022-07-29 Richard Biener + + * tree-vect-patterns.cc (vect_recog_bool_pattern): Use + get_vectype_for_scalar_type instead of + vect_get_vector_types_for_stmt. + 2022-07-28 David Malcolm PR analyzer/105893 diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 87ee496..3d4df68 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20220729 +20220730 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a5ed51a..8ff65cb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2022-07-29 Jakub Jelinek + + PR c++/106448 + * parser.cc (cp_parser_omp_atomic): For simple cast followed by + CPP_QUERY token, don't try cp_parser_binary_operation if compare + is true. + 2022-07-26 Marek Polacek PR c++/106311 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index acd60ff..0473563 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2022-07-29 Tobias Burnus + + * openmp.cc (resolve_omp_clauses): Permit assumed-size arrays + in uniform clause. + 2022-07-26 Harald Anlauf PR fortran/103504 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f47c2ea..9dbecbc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,17 @@ +2022-07-29 Tobias Burnus + + * gfortran.dg/gomp/declare-simd-3.f90: New test. + +2022-07-29 Richard Biener + + PR tree-optimization/106422 + * gcc.dg/torture/pr106422.c: New testcase. + +2022-07-29 Jakub Jelinek + + PR c++/106448 + * c-c++-common/gomp/atomic-32.c: New test. + 2022-07-28 David Malcolm PR analyzer/105893 -- cgit v1.1 From 48e9954d0865b5e5e31cb77ad05c45f7206eeb9f Mon Sep 17 00:00:00 2001 From: Takayuki 'January June' Suwa Date: Sat, 30 Jul 2022 04:31:44 +0900 Subject: xtensa: Add RTX costs for if_then_else It takes one machine instruction for both condtional branch and move. gcc/ChangeLog: * config/xtensa/xtensa.cc (xtensa_rtx_costs): Add new case for IF_THEN_ELSE. --- gcc/config/xtensa/xtensa.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc') diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index a851a7a..6ac879c 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -4273,6 +4273,7 @@ xtensa_rtx_costs (rtx x, machine_mode mode, int outer_code, case ZERO_EXTRACT: case ZERO_EXTEND: + case IF_THEN_ELSE: *total = COSTS_N_INSNS (1); return true; -- cgit v1.1 From 2fa8c4a659a19ec971c80704f48f96c13aae9ac3 Mon Sep 17 00:00:00 2001 From: Takayuki 'January June' Suwa Date: Sat, 30 Jul 2022 04:32:46 +0900 Subject: xtensa: Fix conflicting hard regno between indirect sibcall fixups and EH_RETURN_STACKADJ_RTX The hard register A10 was already allocated for EH_RETURN_STACKADJ_RTX. (although exception handling and sibling call may not apply at the same time, but for safety) gcc/ChangeLog: * config/xtensa/xtensa.md: Change hard register number used in the split patterns for indirect sibling call fixups from 10 to 11, the last free one for the CALL0 ABI. --- gcc/config/xtensa/xtensa.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gcc') diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 899ce27..1294aab 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -25,7 +25,7 @@ (A7_REG 7) (A8_REG 8) (A9_REG 9) - (A10_REG 10) + (A11_REG 11) (UNSPEC_NOP 2) (UNSPEC_PLT 3) @@ -2295,9 +2295,9 @@ "reload_completed && !TARGET_WINDOWED_ABI && SIBLING_CALL_P (insn) && ! call_used_or_fixed_reg_p (REGNO (operands[0]))" - [(set (reg:SI A10_REG) + [(set (reg:SI A11_REG) (match_dup 0)) - (call (mem:SI (reg:SI A10_REG)) + (call (mem:SI (reg:SI A11_REG)) (match_dup 1))]) (define_expand "sibcall_value" @@ -2328,10 +2328,10 @@ "reload_completed && !TARGET_WINDOWED_ABI && SIBLING_CALL_P (insn) && ! call_used_or_fixed_reg_p (REGNO (operands[1]))" - [(set (reg:SI A10_REG) + [(set (reg:SI A11_REG) (match_dup 1)) (set (match_dup 0) - (call (mem:SI (reg:SI A10_REG)) + (call (mem:SI (reg:SI A11_REG)) (match_dup 2)))]) (define_insn "entry" -- cgit v1.1 From a63b99f24df3f2a65133e22dd8a0f70e7b706fd6 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 30 Jul 2022 07:29:28 -0700 Subject: libgo: use SYS_timer_settime32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Musl defines SYS_timer_settime32, not SYS_timer_settime, on 32-bit systems. Based on patch by Sören Tempel. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/420222 --- gcc/go/gofrontend/MERGE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 2f2fafd..ca79704 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -a62f20ae78ddd41be682dde8cab075ca4f5dbb2a +d53e8a0e94e34dc609e34dd5e404debda2640cfb The first line of this file holds the git revision number of the last merge done from the gofrontend repository. -- cgit v1.1 From 9ef2c9aa5b351efa9b751de4f10180427cd0fe70 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 31 Jul 2022 00:16:37 +0000 Subject: Daily bump. --- gcc/ChangeLog | 11 +++++++++++ gcc/DATESTAMP | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5d5cb7..892a683 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2022-07-30 Takayuki 'January June' Suwa + + * config/xtensa/xtensa.md: Change hard register number used in + the split patterns for indirect sibling call fixups from 10 to 11, + the last free one for the CALL0 ABI. + +2022-07-30 Takayuki 'January June' Suwa + + * config/xtensa/xtensa.cc (xtensa_rtx_costs): + Add new case for IF_THEN_ELSE. + 2022-07-29 Andrew Stubbs * config/gcn/gcn-valu.md (V_INT_noHI): New iterator. diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 3d4df68..a519ff3 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20220730 +20220731 -- cgit v1.1 From 9efe4e153d994974afcbba09c3c683f5f4a19c63 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 26 Jul 2022 11:02:21 -0400 Subject: c++: constexpr, empty base after non-empty [PR106369] Here the CONSTRUCTOR we were providing for D{} had an entry for the B base subobject at offset 0 following the entry for the C base, causing output_constructor_regular_field to ICE due to going backwards. It might be nice for that function to be more tolerant of empty fields, but it also seems reasonable for the front end to prune the useless entry. PR c++/106369 gcc/cp/ChangeLog: * constexpr.cc (reduced_constant_expression_p): Return false if a CONSTRUCTOR initializes an empty field. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/constexpr-lambda27.C: New test. --- gcc/cp/constexpr.cc | 8 +++++++- gcc/testsuite/g++.dg/cpp1z/constexpr-lambda27.C | 26 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/constexpr-lambda27.C (limited to 'gcc') diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index 5f7fc6f..5e0d339 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -3081,7 +3081,13 @@ reduced_constant_expression_p (tree t) element. */ if (!reduced_constant_expression_p (e.value)) return false; - /* Empty class field may or may not have an initializer. */ + /* We want to remove initializers for empty fields in a struct to + avoid confusing output_constructor. */ + if (is_empty_field (e.index) + && TREE_CODE (TREE_TYPE (t)) == RECORD_TYPE) + return false; + /* Check for non-empty fields between initialized fields when + CONSTRUCTOR_NO_CLEARING. */ for (; field && e.index != field; field = next_subobject_field (DECL_CHAIN (field))) if (!is_really_empty_class (TREE_TYPE (field), diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda27.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda27.C new file mode 100644 index 0000000..24e2e9b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda27.C @@ -0,0 +1,26 @@ +// PR c++/106369 +// { dg-do compile { target c++17 } } + +struct A { + int a[256]; + constexpr int &operator[] (int n) noexcept { return a[n]; } + constexpr const int &operator[] (int n) const noexcept { return a[n]; } +}; +struct B {}; +template +struct C { + constexpr T &foo (const char x) noexcept { c = T::d[x]; return static_cast(*this); } + int c; +}; +struct D : public C, public B +{ + D () noexcept = default; + static constexpr char e[9] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I' }; + static constexpr A d = [] () constexpr { + A f {}; + for (int i = 0; i < 9; ++i) + f[e[i]] = 1; + return f; + } (); +}; +constexpr auto g = D{}.foo ('E'); -- cgit v1.1 From b04c399e258e686dddad879bf7e27d9e28fd6fde Mon Sep 17 00:00:00 2001 From: Lewis Hyatt Date: Tue, 12 Jul 2022 09:47:47 -0400 Subject: c++: Fix location for -Wunused-macros [PR66290] In C++, since all tokens are lexed from libcpp up front, diagnostics generated by libcpp after lexing has completed do not get a valid location from libcpp (rather, libcpp thinks they all pertain to the end of the file.) This has long been addressed using the global variable "done_lexing", which the C++ frontend sets at the appropriate time; when done_lexing is true, then c_cpp_diagnostic(), which outputs libcpp's diagnostics, uses input_location instead of the wrong libcpp location. The C++ frontend arranges that input_location will point to the token it is currently processing, so this generally works fine. However, there is one exception currently, which is -Wunused-macros. This gets generated at the end of processing in cpp_finish (), since we need to wait until then to determine whether a macro was eventually used or not. But the locations it passes to c_cpp_diagnostic () were remembered from the original lexing and hence they should not be overridden with input_location, which is now the one incorrectly pointing to the end of the file. Fixed by setting done_lexing=false again just prior to calling cpp_finish (). I also renamed the variable from done_lexing to "override_libcpp_locations", since it's now not strictly about lexing anymore. There is no new testcase with this patch, since we already had an xfailed testcase which is now fixed. gcc/c-family/ChangeLog: PR c++/66290 * c-common.h: Rename global done_lexing to override_libcpp_locations. * c-common.cc (c_cpp_diagnostic): Likewise. * c-opts.cc (c_common_finish): Set override_libcpp_locations (formerly done_lexing) immediately prior to calling cpp_finish (). gcc/cp/ChangeLog: PR c++/66290 * parser.cc (cp_lexer_new_main): Rename global done_lexing to override_libcpp_locations. gcc/testsuite/ChangeLog: PR c++/66290 * c-c++-common/pragma-diag-15.c: Remove xfail for C++. --- gcc/c-family/c-common.cc | 10 ++++++---- gcc/c-family/c-common.h | 8 +++++--- gcc/c-family/c-opts.cc | 6 ++++++ gcc/cp/parser.cc | 2 +- gcc/testsuite/c-c++-common/pragma-diag-15.c | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) (limited to 'gcc') diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 655c3ae..6e41ceb 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -284,9 +284,11 @@ int c_inhibit_evaluation_warnings; be generated. */ bool in_late_binary_op; -/* Whether lexing has been completed, so subsequent preprocessor - errors should use the compiler's input_location. */ -bool done_lexing = false; +/* Depending on which phase of processing we are in, we may need + to prefer input_location to libcpp's locations. (Specifically, + after the C++ lexer is done lexing tokens, but prior to calling + cpp_finish (), we need to do so. */ +bool override_libcpp_locations; /* Information about how a function name is generated. */ struct fname_var_t @@ -6681,7 +6683,7 @@ c_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED, default: gcc_unreachable (); } - if (done_lexing) + if (override_libcpp_locations) richloc->set_range (0, input_location, SHOW_RANGE_WITH_CARET); diagnostic_set_info_translated (&diagnostic, msg, ap, richloc, dlevel); diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index f906439..c06769b 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -767,10 +767,12 @@ extern int max_tinst_depth; extern int c_inhibit_evaluation_warnings; -/* Whether lexing has been completed, so subsequent preprocessor - errors should use the compiler's input_location. */ +/* Depending on which phase of processing we are in, we may need + to prefer input_location to libcpp's locations. (Specifically, + after the C++ lexer is done lexing tokens, but prior to calling + cpp_finish (), we need to do so. */ -extern bool done_lexing; +extern bool override_libcpp_locations; /* C types are partitioned into three subsets: object, function, and incomplete types. */ diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index b9f01a6..4e14636 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -1281,6 +1281,12 @@ c_common_finish (void) } } + /* When we call cpp_finish (), it may generate some diagnostics using + locations it remembered from the preprocessing phase, e.g. for + -Wunused-macros. So inform c_cpp_diagnostic () not to override those + locations with input_location, which would be incorrect now. */ + override_libcpp_locations = false; + /* For performance, avoid tearing down cpplib's internal structures with cpp_destroy (). */ cpp_finish (parse_in, deps_stream); diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 826595a..33926d2 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -755,7 +755,7 @@ cp_lexer_new_main (void) /* Subsequent preprocessor diagnostics should use compiler diagnostic functions to get the compiler source location. */ - done_lexing = true; + override_libcpp_locations = true; maybe_check_all_macros (parse_in); diff --git a/gcc/testsuite/c-c++-common/pragma-diag-15.c b/gcc/testsuite/c-c++-common/pragma-diag-15.c index d8076b4..8ffff88 100644 --- a/gcc/testsuite/c-c++-common/pragma-diag-15.c +++ b/gcc/testsuite/c-c++-common/pragma-diag-15.c @@ -9,5 +9,5 @@ because the location of the macro definition is incorrectly set. This is a separate issue, will resolve it in a later patch. */ -#define X /* { dg-warning "-:-Wunused-macros" {} { xfail c++ } } */ +#define X /* { dg-warning "-:-Wunused-macros" } */ #pragma GCC diagnostic ignored "-Wunused-macros" -- cgit v1.1 From 0110cfd5449bae3a772f45ea2e4c5dab5b7a8ccd Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 27 Jul 2022 21:34:22 +0200 Subject: Fortran: fix invalid rank error in ASSOCIATED when rank is remapped [PR77652] gcc/fortran/ChangeLog: PR fortran/77652 * check.cc (gfc_check_associated): Make the rank check of POINTER vs. TARGET match the allowed forms of pointer assignment for the selected Fortran standard. gcc/testsuite/ChangeLog: PR fortran/77652 * gfortran.dg/associated_target_9a.f90: New test. * gfortran.dg/associated_target_9b.f90: New test. --- gcc/fortran/check.cc | 23 ++++++++++++++++-- gcc/testsuite/gfortran.dg/associated_target_9a.f90 | 27 ++++++++++++++++++++++ gcc/testsuite/gfortran.dg/associated_target_9b.f90 | 23 ++++++++++++++++++ 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/associated_target_9a.f90 create mode 100644 gcc/testsuite/gfortran.dg/associated_target_9b.f90 (limited to 'gcc') diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index 91d87a1..1da0b3c 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -1502,8 +1502,27 @@ gfc_check_associated (gfc_expr *pointer, gfc_expr *target) t = false; /* F2018 C838 explicitly allows an assumed-rank variable as the first argument of intrinsic inquiry functions. */ - if (pointer->rank != -1 && !rank_check (target, 0, pointer->rank)) - t = false; + if (pointer->rank != -1 && pointer->rank != target->rank) + { + if (pointer->rank == 0 || target->rank == 0) + { + /* There exists no valid pointer assignment using bounds + remapping for scalar => array or array => scalar. */ + if (!rank_check (target, 0, pointer->rank)) + t = false; + } + else if (target->rank != 1) + { + if (!gfc_notify_std (GFC_STD_F2008, "Rank remapping target is not " + "rank 1 at %L", &target->where)) + t = false; + } + else if ((gfc_option.allow_std & GFC_STD_F2003) == 0) + { + if (!rank_check (target, 0, pointer->rank)) + t = false; + } + } if (target->rank > 0 && target->ref) { for (i = 0; i < target->rank; i++) diff --git a/gcc/testsuite/gfortran.dg/associated_target_9a.f90 b/gcc/testsuite/gfortran.dg/associated_target_9a.f90 new file mode 100644 index 0000000..708645d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associated_target_9a.f90 @@ -0,0 +1,27 @@ +! { dg-do run } +! { dg-options "-std=f2018" } +! PR fortran/77652 - Invalid rank error in ASSOCIATED when rank is remapped +! Contributed by Paul Thomas + +program p + real, dimension(100), target :: array + real, dimension(:,:), pointer :: matrix + real, dimension(20,5), target :: array2 + real, dimension(:), pointer :: matrix2 + matrix(1:20,1:5) => array + matrix2(1:100) => array2 + ! + ! F2018:16.9.16, ASSOCIATED (POINTER [, TARGET]) + ! Case(v): If TARGET is present and is an array target, the result is + ! true if and only if POINTER is associated with a target that has + ! the same shape as TARGET, ... + if (associated (matrix, array )) stop 1 + if (associated (matrix2,array2)) stop 2 + call check (matrix2, array2) +contains + subroutine check (ptr, tgt) + real, pointer :: ptr(..) + real, target :: tgt(:,:) + if (associated (ptr, tgt)) stop 3 + end subroutine check +end diff --git a/gcc/testsuite/gfortran.dg/associated_target_9b.f90 b/gcc/testsuite/gfortran.dg/associated_target_9b.f90 new file mode 100644 index 0000000..1daa0a7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associated_target_9b.f90 @@ -0,0 +1,23 @@ +! { dg-do compile } +! { dg-options "-std=f2003" } +! PR fortran/77652 - Invalid rank error in ASSOCIATED when rank is remapped +! Contributed by Paul Thomas + +subroutine s + real, dimension(100), target :: array + real, dimension(:,:), pointer :: matrix + real, dimension(20,5), target :: array2 + real, dimension(:), pointer :: matrix2 + real, pointer :: scalar, scalar2 + scalar => scalar2 + print *, associated (scalar, scalar2) + + matrix(1:20,1:5) => array ! F2003+ +! matrix2(1:100) => array2 ! F2008+ + print *, associated (matrix, array ) ! Technically legal F2003 + print *, associated (matrix2,array2) ! { dg-error "is not rank 1" } + + ! There exists no related valid pointer assignment for these cases: + print *, associated (scalar,matrix2) ! { dg-error "must be of rank 0" } + print *, associated (matrix2,scalar) ! { dg-error "must be of rank 1" } +end -- cgit v1.1 From d325e7048c85e13f12ea79aebf9623eddc7ffcaf Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 28 Jul 2022 22:07:02 +0200 Subject: Fortran: detect blanks within literal constants in free-form mode [PR92805] gcc/fortran/ChangeLog: PR fortran/92805 * match.cc (gfc_match_small_literal_int): Make gobbling of leading whitespace optional. (gfc_match_name): Likewise. (gfc_match_char): Likewise. * match.h (gfc_match_small_literal_int): Adjust prototype. (gfc_match_name): Likewise. (gfc_match_char): Likewise. * primary.cc (match_kind_param): Match small literal int or name without gobbling whitespace. (get_kind): Do not skip over blanks. (match_string_constant): Likewise. gcc/testsuite/ChangeLog: PR fortran/92805 * gfortran.dg/literal_constants.f: New test. * gfortran.dg/literal_constants.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/match.cc | 24 +++++++++++++++--------- gcc/fortran/match.h | 6 +++--- gcc/fortran/primary.cc | 14 +++----------- gcc/testsuite/gfortran.dg/literal_constants.f | 20 ++++++++++++++++++++ gcc/testsuite/gfortran.dg/literal_constants.f90 | 24 ++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 23 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/literal_constants.f create mode 100644 gcc/testsuite/gfortran.dg/literal_constants.f90 (limited to 'gcc') diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index 1aa3053..8b8b6e7 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -454,10 +454,11 @@ gfc_match_eos (void) /* Match a literal integer on the input, setting the value on MATCH_YES. Literal ints occur in kind-parameters as well as old-style character length specifications. If cnt is non-NULL it - will be set to the number of digits. */ + will be set to the number of digits. + When gobble_ws is false, do not skip over leading blanks. */ match -gfc_match_small_literal_int (int *value, int *cnt) +gfc_match_small_literal_int (int *value, int *cnt, bool gobble_ws) { locus old_loc; char c; @@ -466,7 +467,8 @@ gfc_match_small_literal_int (int *value, int *cnt) old_loc = gfc_current_locus; *value = -1; - gfc_gobble_whitespace (); + if (gobble_ws) + gfc_gobble_whitespace (); c = gfc_next_ascii_char (); if (cnt) *cnt = 0; @@ -608,17 +610,19 @@ gfc_match_label (void) /* See if the current input looks like a name of some sort. Modifies the passed buffer which must be GFC_MAX_SYMBOL_LEN+1 bytes long. Note that options.cc restricts max_identifier_length to not more - than GFC_MAX_SYMBOL_LEN. */ + than GFC_MAX_SYMBOL_LEN. + When gobble_ws is false, do not skip over leading blanks. */ match -gfc_match_name (char *buffer) +gfc_match_name (char *buffer, bool gobble_ws) { locus old_loc; int i; char c; old_loc = gfc_current_locus; - gfc_gobble_whitespace (); + if (gobble_ws) + gfc_gobble_whitespace (); c = gfc_next_ascii_char (); if (!(ISALPHA (c) || (c == '_' && flag_allow_leading_underscore))) @@ -1053,15 +1057,17 @@ cleanup: /* Tries to match the next non-whitespace character on the input. - This subroutine does not return MATCH_ERROR. */ + This subroutine does not return MATCH_ERROR. + When gobble_ws is false, do not skip over leading blanks. */ match -gfc_match_char (char c) +gfc_match_char (char c, bool gobble_ws) { locus where; where = gfc_current_locus; - gfc_gobble_whitespace (); + if (gobble_ws) + gfc_gobble_whitespace (); if (gfc_next_ascii_char () == c) return MATCH_YES; diff --git a/gcc/fortran/match.h b/gcc/fortran/match.h index 495c93e..1f53e0c 100644 --- a/gcc/fortran/match.h +++ b/gcc/fortran/match.h @@ -45,14 +45,14 @@ extern gfc_access gfc_typebound_default_access; match gfc_match_special_char (gfc_char_t *); match gfc_match_space (void); match gfc_match_eos (void); -match gfc_match_small_literal_int (int *, int *); +match gfc_match_small_literal_int (int *, int *, bool = true); match gfc_match_st_label (gfc_st_label **); match gfc_match_small_int (int *); -match gfc_match_name (char *); +match gfc_match_name (char *, bool = true); match gfc_match_symbol (gfc_symbol **, int); match gfc_match_sym_tree (gfc_symtree **, int); match gfc_match_intrinsic_op (gfc_intrinsic_op *); -match gfc_match_char (char); +match gfc_match_char (char, bool = true); match gfc_match (const char *, ...); match gfc_match_iterator (gfc_iterator *, int); match gfc_match_parens (void); diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc index 3f01f67..19f2e78 100644 --- a/gcc/fortran/primary.cc +++ b/gcc/fortran/primary.cc @@ -45,11 +45,11 @@ match_kind_param (int *kind, int *is_iso_c) *is_iso_c = 0; - m = gfc_match_small_literal_int (kind, NULL); + m = gfc_match_small_literal_int (kind, NULL, false); if (m != MATCH_NO) return m; - m = gfc_match_name (name); + m = gfc_match_name (name, false); if (m != MATCH_YES) return m; @@ -95,7 +95,7 @@ get_kind (int *is_iso_c) *is_iso_c = 0; - if (gfc_match_char ('_') != MATCH_YES) + if (gfc_match_char ('_', false) != MATCH_YES) return -2; m = match_kind_param (&kind, is_iso_c); @@ -1074,17 +1074,9 @@ match_string_constant (gfc_expr **result) c = gfc_next_char (); } - if (c == ' ') - { - gfc_gobble_whitespace (); - c = gfc_next_char (); - } - if (c != '_') goto no_match; - gfc_gobble_whitespace (); - c = gfc_next_char (); if (c != '\'' && c != '"') goto no_match; diff --git a/gcc/testsuite/gfortran.dg/literal_constants.f b/gcc/testsuite/gfortran.dg/literal_constants.f new file mode 100644 index 0000000..4d1f1b7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/literal_constants.f @@ -0,0 +1,20 @@ +! { dg-do compile } +! { dg-options "-ffixed-form" } +! PR fortran/92805 - blanks within literal constants in fixed-form mode + + implicit none + integer, parameter :: ck = kind ("a") ! default character kind + integer, parameter :: rk = kind (1.0) ! default real kind + print *, 1_"abc" + print *, 1 _"abc" + print *, 1_ "abc" + print *, ck_"a" + print *, ck _"ab" + print *, ck_ "ab" + print *, 3.1415_4 + print *, 3.1415 _4 + print *, 3.1415_ 4 + print *, 3.1415_rk + print *, 3.1415 _rk + print *, 3.1415_ rk + end diff --git a/gcc/testsuite/gfortran.dg/literal_constants.f90 b/gcc/testsuite/gfortran.dg/literal_constants.f90 new file mode 100644 index 0000000..f8908f9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/literal_constants.f90 @@ -0,0 +1,24 @@ +! { dg-do compile } +! { dg-options "-ffree-form" } +! PR fortran/92805 - blanks within literal constants in free-form mode + + implicit none + integer, parameter :: ck = kind ("a") ! default character kind + integer, parameter :: rk = kind (1.0) ! default real kind + print *, 1_"abc" + print *, 1 _"abc" ! { dg-error "Syntax error" } + print *, 1_ "abc" ! { dg-error "Missing kind-parameter" } + print *, 1 _ "abc" ! { dg-error "Syntax error" } + print *, ck_"a" + print *, ck _"ab" ! { dg-error "Syntax error" } + print *, ck_ "ab" ! { dg-error "Syntax error" } + print *, ck _ "ab" ! { dg-error "Syntax error" } + print *, 3.1415_4 + print *, 3.1415 _4 ! { dg-error "Syntax error" } + print *, 3.1415_ 4 ! { dg-error "Missing kind-parameter" } + print *, 3.1415 _ 4 ! { dg-error "Syntax error" } + print *, 3.1415_rk + print *, 3.1415 _rk ! { dg-error "Syntax error" } + print *, 3.1415_ rk ! { dg-error "Missing kind-parameter" } + print *, 3.141 _ rk ! { dg-error "Syntax error" } + end -- cgit v1.1 From 493f4e6cf081ea2d016547629b29d130c1533ccb Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Sun, 31 Jul 2022 21:44:51 +0100 Subject: PR target/106450: Tweak timode_remove_non_convertible_regs on x86_64. This patch resolves PR target/106450, some more fall-out from more aggressive TImode scalar-to-vector (STV) optimizations. I continue to be caught out by how far TImode STV has diverged from DImode/SImode STV, and therefore requires additional (unexpected) tweaking. Many thanks to H.J. Lu for pointing out timode_remove_non_convertible_regs needs to be extended to handle XOR (and other new operations). Unhelpfully the comment above this function states that it's the TImode version of "remove_non_convertible_regs", which doesn't exist anymore, so I've resurrected an explanatory comment from the git history. By refactoring the checks for hard regs and already "marked" regs into timode_check_non_convertible_regs itself, all of its callers are simplified. This patch then FOR_EACH_INSN_USE and FOR_EACH_INSN_DEF to generically handle arbitrary (non-move) instructions (including unary and binary operations), calling timode_check_non_convertible_regs on each TImode register USE and DEF. 2022-07-31 Roger Sayle H.J. Lu gcc/ChangeLog PR target/106450 * config/i386/i386-features.cc (timode_check_non_convertible_regs): Do nothing if REGNO is set in the REGS bitmap, or is a hard reg. (timode_remove_non_convertible_regs): Update comment. Call timode_check_non_convertible_reg on all TImode register DEFs and USEs in each instruction. gcc/testsuite/ChangeLog PR target/106450 * gcc.target/i386/pr106450.c: New test case. --- gcc/config/i386/i386-features.cc | 46 ++++++++++++++++++-------------- gcc/testsuite/gcc.target/i386/pr106450.c | 14 ++++++++++ 2 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr106450.c (limited to 'gcc') diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc index aa5de71..e4cc4a3 100644 --- a/gcc/config/i386/i386-features.cc +++ b/gcc/config/i386/i386-features.cc @@ -1808,6 +1808,11 @@ static void timode_check_non_convertible_regs (bitmap candidates, bitmap regs, unsigned int regno) { + /* Do nothing if REGNO is already in REGS or is a hard reg. */ + if (bitmap_bit_p (regs, regno) + || HARD_REGISTER_NUM_P (regno)) + return; + for (df_ref def = DF_REG_DEF_CHAIN (regno); def; def = DF_REF_NEXT_REG (def)) @@ -1843,7 +1848,13 @@ timode_check_non_convertible_regs (bitmap candidates, bitmap regs, } } -/* The TImode version of remove_non_convertible_regs. */ +/* For a given bitmap of insn UIDs scans all instructions and + remove insn from CANDIDATES in case it has both convertible + and not convertible definitions. + + All insns in a bitmap are conversion candidates according to + scalar_to_vector_candidate_p. Currently it implies all insns + are single_set. */ static void timode_remove_non_convertible_regs (bitmap candidates) @@ -1857,25 +1868,20 @@ timode_remove_non_convertible_regs (bitmap candidates) changed = false; EXECUTE_IF_SET_IN_BITMAP (candidates, 0, id, bi) { - rtx def_set = single_set (DF_INSN_UID_GET (id)->insn); - rtx dest = SET_DEST (def_set); - rtx src = SET_SRC (def_set); - - if ((!REG_P (dest) - || bitmap_bit_p (regs, REGNO (dest)) - || HARD_REGISTER_P (dest)) - && (!REG_P (src) - || bitmap_bit_p (regs, REGNO (src)) - || HARD_REGISTER_P (src))) - continue; - - if (REG_P (dest)) - timode_check_non_convertible_regs (candidates, regs, - REGNO (dest)); - - if (REG_P (src)) - timode_check_non_convertible_regs (candidates, regs, - REGNO (src)); + rtx_insn *insn = DF_INSN_UID_GET (id)->insn; + df_ref ref; + + FOR_EACH_INSN_DEF (ref, insn) + if (!DF_REF_REG_MEM_P (ref) + && GET_MODE (DF_REF_REG (ref)) == TImode) + timode_check_non_convertible_regs (candidates, regs, + DF_REF_REGNO (ref)); + + FOR_EACH_INSN_USE (ref, insn) + if (!DF_REF_REG_MEM_P (ref) + && GET_MODE (DF_REF_REG (ref)) == TImode) + timode_check_non_convertible_regs (candidates, regs, + DF_REF_REGNO (ref)); } EXECUTE_IF_SET_IN_BITMAP (regs, 0, id, bi) diff --git a/gcc/testsuite/gcc.target/i386/pr106450.c b/gcc/testsuite/gcc.target/i386/pr106450.c new file mode 100644 index 0000000..d16231f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr106450.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -fsplit-paths" } */ + +__int128 n; + +__attribute__ ((simd)) void +foo (void) +{ + __int128 uninitialized; + unsigned __int128 *p = &n; + + n >>= *p ? : 2; + n |= uninitialized; +} -- cgit v1.1 From 525a1a73a5a563c829a5f76858fe122c9b39f254 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Sun, 31 Jul 2022 21:51:44 +0100 Subject: Add rotl64ti2_doubleword pattern to i386.md This patch adds rot[lr]64ti2_doubleword patterns to the x86_64 backend, to move splitting of 128-bit TImode rotates by 64 bits after reload, matching what we now do for 64-bit DImode rotations by 32 bits with -m32. In theory moving when this rotation is split should have little influence on code generation, but in practice "reload" sometimes decides to make use of the increased flexibility to reduce the number of registers used, and the code size, by using xchg. For example: __int128 x; __int128 y; __int128 a; __int128 b; void foo() { unsigned __int128 t = x; t ^= a; t = (t<<64) | (t>>64); t ^= b; y = t; } Before: movq x(%rip), %rsi movq x+8(%rip), %rdi xorq a(%rip), %rsi xorq a+8(%rip), %rdi movq %rdi, %rax movq %rsi, %rdx xorq b(%rip), %rax xorq b+8(%rip), %rdx movq %rax, y(%rip) movq %rdx, y+8(%rip) ret After: movq x(%rip), %rax movq x+8(%rip), %rdx xorq a(%rip), %rax xorq a+8(%rip), %rdx xchgq %rdx, %rax xorq b(%rip), %rax xorq b+8(%rip), %rdx movq %rax, y(%rip) movq %rdx, y+8(%rip) ret One some modern architectures this is a small win, on some older architectures this is a small loss. The decision which code to generate is made in "reload", and could probably be tweaked by register preferencing. The much bigger win is that (eventually) all TImode mode shifts and rotates by constants will become potential candidates for TImode STV. 2022-07-31 Roger Sayle gcc/ChangeLog * config/i386/i386.md (define_expand ti3): For rotations by 64 bits use new rot[lr]64ti2_doubleword pattern. (rot[lr]64ti2_doubleword): New post-reload splitter. --- gcc/config/i386/i386.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gcc') diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index fab6aed..f1158e1 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -13820,6 +13820,8 @@ if (const_1_to_63_operand (operands[2], VOIDmode)) emit_insn (gen_ix86_ti3_doubleword (operands[0], operands[1], operands[2])); + else if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 64) + emit_insn (gen_64ti2_doubleword (operands[0], operands[1])); else { rtx amount = force_reg (QImode, operands[2]); @@ -14045,6 +14047,24 @@ } }) +(define_insn_and_split "64ti2_doubleword" + [(set (match_operand:TI 0 "register_operand" "=r,r,r") + (any_rotate:TI (match_operand:TI 1 "nonimmediate_operand" "0,r,o") + (const_int 64)))] + "TARGET_64BIT" + "#" + "&& reload_completed" + [(set (match_dup 0) (match_dup 3)) + (set (match_dup 2) (match_dup 1))] +{ + split_double_mode (TImode, &operands[0], 2, &operands[0], &operands[2]); + if (rtx_equal_p (operands[0], operands[1])) + { + emit_insn (gen_swapdi (operands[0], operands[2])); + DONE; + } +}) + (define_mode_attr rorx_immediate_operand [(SI "const_0_to_31_operand") (DI "const_0_to_63_operand")]) -- cgit v1.1 From 4a7274ddc4970c1ad011343ed285d6219dffa396 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Mon, 1 Aug 2022 00:16:31 +0000 Subject: Daily bump. --- gcc/ChangeLog | 16 ++++++++++++++++ gcc/DATESTAMP | 2 +- gcc/c-family/ChangeLog | 9 +++++++++ gcc/cp/ChangeLog | 12 ++++++++++++ gcc/fortran/ChangeLog | 23 +++++++++++++++++++++++ gcc/testsuite/ChangeLog | 29 +++++++++++++++++++++++++++++ 6 files changed, 90 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 892a683..22cf563 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2022-07-31 Roger Sayle + + * config/i386/i386.md (define_expand ti3): For + rotations by 64 bits use new rot[lr]64ti2_doubleword pattern. + (rot[lr]64ti2_doubleword): New post-reload splitter. + +2022-07-31 Roger Sayle + H.J. Lu + + PR target/106450 + * config/i386/i386-features.cc (timode_check_non_convertible_regs): + Do nothing if REGNO is set in the REGS bitmap, or is a hard reg. + (timode_remove_non_convertible_regs): Update comment. + Call timode_check_non_convertible_reg on all TImode register + DEFs and USEs in each instruction. + 2022-07-30 Takayuki 'January June' Suwa * config/xtensa/xtensa.md: Change hard register number used in diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index a519ff3..ed14e56 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20220731 +20220801 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 73e959d..68fc6e2 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,12 @@ +2022-07-31 Lewis Hyatt + + PR c++/66290 + * c-common.h: Rename global done_lexing to + override_libcpp_locations. + * c-common.cc (c_cpp_diagnostic): Likewise. + * c-opts.cc (c_common_finish): Set override_libcpp_locations + (formerly done_lexing) immediately prior to calling cpp_finish (). + 2022-07-27 Lewis Hyatt * c-ppoutput.cc (token_streamer::stream): Update input_location diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ff65cb..4d7761c2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2022-07-31 Lewis Hyatt + + PR c++/66290 + * parser.cc (cp_lexer_new_main): Rename global done_lexing to + override_libcpp_locations. + +2022-07-31 Jason Merrill + + PR c++/106369 + * constexpr.cc (reduced_constant_expression_p): Return false + if a CONSTRUCTOR initializes an empty field. + 2022-07-29 Jakub Jelinek PR c++/106448 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0473563..74968c9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,26 @@ +2022-07-31 Harald Anlauf + Steven G. Kargl + + PR fortran/92805 + * match.cc (gfc_match_small_literal_int): Make gobbling of leading + whitespace optional. + (gfc_match_name): Likewise. + (gfc_match_char): Likewise. + * match.h (gfc_match_small_literal_int): Adjust prototype. + (gfc_match_name): Likewise. + (gfc_match_char): Likewise. + * primary.cc (match_kind_param): Match small literal int or name + without gobbling whitespace. + (get_kind): Do not skip over blanks. + (match_string_constant): Likewise. + +2022-07-31 Harald Anlauf + + PR fortran/77652 + * check.cc (gfc_check_associated): Make the rank check of POINTER + vs. TARGET match the allowed forms of pointer assignment for the + selected Fortran standard. + 2022-07-29 Tobias Burnus * openmp.cc (resolve_omp_clauses): Permit assumed-size arrays diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9dbecbc..781bba7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,32 @@ +2022-07-31 Roger Sayle + H.J. Lu + + PR target/106450 + * gcc.target/i386/pr106450.c: New test case. + +2022-07-31 Harald Anlauf + Steven G. Kargl + + PR fortran/92805 + * gfortran.dg/literal_constants.f: New test. + * gfortran.dg/literal_constants.f90: New test. + +2022-07-31 Harald Anlauf + + PR fortran/77652 + * gfortran.dg/associated_target_9a.f90: New test. + * gfortran.dg/associated_target_9b.f90: New test. + +2022-07-31 Lewis Hyatt + + PR c++/66290 + * c-c++-common/pragma-diag-15.c: Remove xfail for C++. + +2022-07-31 Jason Merrill + + PR c++/106369 + * g++.dg/cpp1z/constexpr-lambda27.C: New test. + 2022-07-29 Tobias Burnus * gfortran.dg/gomp/declare-simd-3.f90: New test. -- cgit v1.1