[gcc r14-9767] tree-optimization/114557 - reduce ehcleanup peak memory use
https://gcc.gnu.org/g:e7b7188b1cf8c174f0e890d4ac279ff480b51043 commit r14-9767-ge7b7188b1cf8c174f0e890d4ac279ff480b51043 Author: Richard Biener Date: Tue Apr 2 12:31:04 2024 +0200 tree-optimization/114557 - reduce ehcleanup peak memory use The following reduces peak memory use for the PR114480 testcase at -O1 which is almost exclusively spent by the ehcleanup pass in allocating PHI nodes. The free_phinodes cache we maintain isn't very effective since it has effectively two slots, one for 4 and one for 9 argument PHIs and it is only ever used for allocations up to 9 arguments but we put all larger PHIs in the 9 argument bucket. This proves uneffective resulting in much garbage to be kept when incrementally growing PHI nodes by edge redirection. The mitigation is to rely on the GC freelist for larger sizes and thus immediately return all larger bucket sized PHIs to it via ggc_free. This reduces the peak memory use from 19.8GB to 11.3GB and compile-time from 359s to 168s. PR tree-optimization/114557 PR tree-optimization/114480 * tree-phinodes.cc (release_phi_node): Return PHIs from allocation buckets not covered by free_phinodes to GC. (remove_phi_node): Release the PHI LHS before freeing the PHI node. * tree-vect-loop.cc (vectorizable_live_operation): Get PHI lhs before releasing it. Diff: --- gcc/tree-phinodes.cc | 10 +- gcc/tree-vect-loop.cc | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/tree-phinodes.cc b/gcc/tree-phinodes.cc index ddd731323e1..5a7e4a94e57 100644 --- a/gcc/tree-phinodes.cc +++ b/gcc/tree-phinodes.cc @@ -223,6 +223,14 @@ release_phi_node (gimple *phi) delink_imm_use (imm); } + /* Immediately return the memory to the allocator when we would + only ever re-use it for a smaller size allocation. */ + if (len - 2 >= NUM_BUCKETS - 2) +{ + ggc_free (phi); + return; +} + bucket = len > NUM_BUCKETS - 1 ? NUM_BUCKETS - 1 : len; bucket -= 2; vec_safe_push (free_phinodes[bucket], phi); @@ -445,9 +453,9 @@ remove_phi_node (gimple_stmt_iterator *gsi, bool release_lhs_p) /* If we are deleting the PHI node, then we should release the SSA_NAME node so that it can be reused. */ - release_phi_node (phi); if (release_lhs_p) release_ssa_name (gimple_phi_result (phi)); + release_phi_node (phi); } /* Remove all the phi nodes from BB. */ diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index f33629e9b04..984636edbc5 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -10962,8 +10962,8 @@ vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info, lhs_type, &exit_gsi); auto gsi = gsi_for_stmt (use_stmt); - remove_phi_node (&gsi, false); tree lhs_phi = gimple_phi_result (use_stmt); + remove_phi_node (&gsi, false); gimple *copy = gimple_build_assign (lhs_phi, new_tree); gsi_insert_before (&exit_gsi, copy, GSI_SAME_STMT); break;
[gcc r14-9766] LoongArch: Remove unused code.
https://gcc.gnu.org/g:8677182f32234786fccce25583232ec5181dde75 commit r14-9766-g8677182f32234786fccce25583232ec5181dde75 Author: Jiahao Xu Date: Wed Apr 3 09:38:23 2024 +0800 LoongArch: Remove unused code. gcc/ChangeLog: * config/loongarch/lasx.md: Remove unused code. * config/loongarch/loongarch-protos.h (loongarch_split_lsx_copy_d): Remove. (loongarch_split_lsx_insert_d): Ditto. (loongarch_split_lsx_fill_d): Ditto. * config/loongarch/loongarch.cc (loongarch_split_lsx_copy_d): Ditto. (loongarch_split_lsx_insert_d): Ditto. (loongarch_split_lsx_fill_d): Ditto. * config/loongarch/lsx.md (lsx_vpickve2gr_du): Remove splitter. (lsx_vpickve2gr_): Ditto. (abs2): Remove expander. (vabs2): Rename 2 abs2. gcc/testsuite/ChangeLog: * gcc.target/loongarch/vector/lsx/lsx-abs.c: New test. Diff: --- gcc/config/loongarch/lasx.md | 12 +-- gcc/config/loongarch/loongarch-protos.h| 3 - gcc/config/loongarch/loongarch.cc | 76 -- gcc/config/loongarch/lsx.md| 89 ++ .../gcc.target/loongarch/vector/lsx/lsx-abs.c | 26 +++ 5 files changed, 35 insertions(+), 171 deletions(-) diff --git a/gcc/config/loongarch/lasx.md b/gcc/config/loongarch/lasx.md index 2fa5e46c8e8..7bd61f8ed5b 100644 --- a/gcc/config/loongarch/lasx.md +++ b/gcc/config/loongarch/lasx.md @@ -572,12 +572,7 @@ (match_operand 3 "const__operand" "")))] "ISA_HAS_LASX" { -#if 0 - if (!TARGET_64BIT && (mode == V4DImode || mode == V4DFmode)) -return "#"; - else -#endif -return "xvinsgr2vr.\t%u0,%z1,%y3"; + return "xvinsgr2vr.\t%u0,%z1,%y3"; } [(set_attr "type" "simd_insert") (set_attr "mode" "")]) @@ -1446,10 +1441,7 @@ if (which_alternative == 1) return "xvldi.b\t%u0,0" ; - if (!TARGET_64BIT && (mode == V2DImode || mode == V2DFmode)) -return "#"; - else -return "xvreplgr2vr.\t%u0,%z1"; + return "xvreplgr2vr.\t%u0,%z1"; } [(set_attr "type" "simd_fill") (set_attr "mode" "") diff --git a/gcc/config/loongarch/loongarch-protos.h b/gcc/config/loongarch/loongarch-protos.h index e3ed2b912a5..e238d795a73 100644 --- a/gcc/config/loongarch/loongarch-protos.h +++ b/gcc/config/loongarch/loongarch-protos.h @@ -89,9 +89,6 @@ extern void loongarch_split_128bit_move (rtx, rtx); extern bool loongarch_split_128bit_move_p (rtx, rtx); extern void loongarch_split_256bit_move (rtx, rtx); extern bool loongarch_split_256bit_move_p (rtx, rtx); -extern void loongarch_split_lsx_copy_d (rtx, rtx, rtx, rtx (*)(rtx, rtx, rtx)); -extern void loongarch_split_lsx_insert_d (rtx, rtx, rtx, rtx); -extern void loongarch_split_lsx_fill_d (rtx, rtx); extern const char *loongarch_output_move (rtx, rtx); #ifdef RTX_CODE extern void loongarch_expand_scc (rtx *); diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index cbc91c94d9d..c90b701a533 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -4775,82 +4775,6 @@ loongarch_split_256bit_move (rtx dest, rtx src) } } - -/* Split a COPY_S.D with operands DEST, SRC and INDEX. GEN is a function - used to generate subregs. */ - -void -loongarch_split_lsx_copy_d (rtx dest, rtx src, rtx index, - rtx (*gen_fn)(rtx, rtx, rtx)) -{ - gcc_assert ((GET_MODE (src) == V2DImode && GET_MODE (dest) == DImode) - || (GET_MODE (src) == V2DFmode && GET_MODE (dest) == DFmode)); - - /* Note that low is always from the lower index, and high is always - from the higher index. */ - rtx low = loongarch_subword (dest, false); - rtx high = loongarch_subword (dest, true); - rtx new_src = simplify_gen_subreg (V4SImode, src, GET_MODE (src), 0); - - emit_insn (gen_fn (low, new_src, GEN_INT (INTVAL (index) * 2))); - emit_insn (gen_fn (high, new_src, GEN_INT (INTVAL (index) * 2 + 1))); -} - -/* Split a INSERT.D with operand DEST, SRC1.INDEX and SRC2. */ - -void -loongarch_split_lsx_insert_d (rtx dest, rtx src1, rtx index, rtx src2) -{ - int i; - gcc_assert (GET_MODE (dest) == GET_MODE (src1)); - gcc_assert ((GET_MODE (dest) == V2DImode - && (GET_MODE (src2) == DImode || src2 == const0_rtx)) - || (GET_MODE (dest) == V2DFmode && GET_MODE (src2) == DFmode)); - - /* Note that low is always from the lower index, and high is always - from the higher index. */ - rtx low = loongarch_subword (src2, false); - rtx high = loongarch_subword (src2, true); - rtx new_dest = simplify_gen_subreg (V4SImode, dest, GET_MODE (dest), 0); - rtx new_src1 = simplify_gen_subreg (V4SImode, src1, GET_MODE (src1), 0); - i = exact_log2 (INTVAL (index)); - gcc_assert (i != -1); - - emit_insn (gen_lsx_vinsgr2vr_w (new_dest, low, new_src1, -
[gcc r14-9764] PR modula2/114565 progress trace would be useful to isolate ICE for users
https://gcc.gnu.org/g:1bafa6a3fdbb53651ffa5d854c2341c487bf3269 commit r14-9764-g1bafa6a3fdbb53651ffa5d854c2341c487bf3269 Author: Gaius Mulley Date: Tue Apr 2 23:47:42 2024 +0100 PR modula2/114565 progress trace would be useful to isolate ICE for users This patch introduces the internal option -fm2-debug-trace= which can be given a comma separated list of filter terms. Currently it allows: all,line,token,quad. The patch allows users to trace the progress of cc1gm2 so that source which causes an ICE can be reduced. Once PR113836 is complete it is expected that the trace information will be written to file. gcc/m2/ChangeLog: PR modula2/114565 * gm2-compiler/M2GenGCC.mod (CodeStatement): Test GetDebugTraceQuad before calling DisplayQuad. * gm2-compiler/M2LexBuf.mod (NumberIO): Import CardToStr. (GetToken): Test GetDebugTraceToken before writing the token number or token line. * gm2-compiler/M2Options.def (SetDebugTraceQuad): Rename to (SetM2DebugTraceFilter): ...this. (SetDebugTraceAPI): Remove. (GetDebugTraceQuad): New procedure function. (GetDebugTraceTree): Ditto. (GetDebugTraceToken): Ditto. (GetDebugTraceLine): Ditto. (GetDebugFunctionLineNumbers): Ditto. * gm2-compiler/M2Options.mod (DebugFunctionLineNumbers): New boolean variable. (DebugTraceQuad): Ditto. (DebugTraceTree): Ditto. (DebugTraceLine): Ditto. (DebugTraceToken): Ditto. (errors1): New procedure. (SetDebugTraceQuad): Remove. (SetM2DebugTraceFilter): New procedure implemented. (SetM2DebugTrace): Ditto. (GetDebugTraceQuad): Ditto. (GetDebugTraceToken ): Ditto. (GetDebugTraceLine): Ditto. (SetDebugTraceLine): Remove. * gm2-compiler/M2Quads.mod (GenQuadOTrash): Test GetDebugTraceQuad and call DisplayQuad. (GenQuadOTypetok): Ditto. * gm2-compiler/SymbolTable.mod: Replace DebugFunctionLineNumbers with GetDebugFunctionLineNumbers. * gm2-gcc/init.cc (_M2_M2LangDump_init): Add prototype. (init_PerCompilationInit): Add call. * gm2-gcc/m2misc.cc (m2misc_cerror): New function. (m2misc_error): Ditto. * gm2-gcc/m2misc.def (error): New procedure. (cerror): Ditto. * gm2-gcc/m2misc.h (m2misc_cerror): New prototype. (m2misc_error): Ditto. * gm2-gcc/m2options.h (M2Options_SetDebugTraceQuad): New prototype. (M2Options_SetDebugTraceAPI): Remove. (M2Options_GetDebugTraceToken): New prototype. (M2Options_GetDebugTraceLine): Ditto. (M2Options_SetDebugFunctionLineNumbers): Ditto. (M2Options_GetDebugFunctionLineNumbers): Ditto. (M2Options_SetM2DebugTraceFilter): Ditto. * gm2-lang.cc (gm2_langhook_init_options): Remove OPT_fdebug_trace_quad case. Remove OPT_fdebug_trace_api case. Add OPT_fm2_debug_trace_ case. * lang.opt (fm2-debug-trace): New option. (fdebug-trace-api): Remove. (fdebug-trace-quad): Remove. * m2.flex (m2flex_M2Error): Check s for NULL. (skipnewline): New function. (consumeLine): Call traceline. Signed-off-by: Gaius Mulley Diff: --- gcc/m2/gm2-compiler/M2GenGCC.mod| 5 +- gcc/m2/gm2-compiler/M2LexBuf.mod| 24 +- gcc/m2/gm2-compiler/M2Options.def | 54 + gcc/m2/gm2-compiler/M2Options.mod | 154 +++- gcc/m2/gm2-compiler/M2Quads.mod | 18 - gcc/m2/gm2-compiler/SymbolTable.mod | 6 +- gcc/m2/gm2-gcc/init.cc | 2 + gcc/m2/gm2-gcc/m2misc.cc| 16 gcc/m2/gm2-gcc/m2misc.def | 4 + gcc/m2/gm2-gcc/m2misc.h | 2 + gcc/m2/gm2-gcc/m2options.h | 7 +- gcc/m2/gm2-lang.cc | 9 +-- gcc/m2/lang.opt | 14 ++-- gcc/m2/m2.flex | 35 +++- 14 files changed, 285 insertions(+), 65 deletions(-) diff --git a/gcc/m2/gm2-compiler/M2GenGCC.mod b/gcc/m2/gm2-compiler/M2GenGCC.mod index 7e27373a6ac..60f58cc2d1b 100644 --- a/gcc/m2/gm2-compiler/M2GenGCC.mod +++ b/gcc/m2/gm2-compiler/M2GenGCC.mod @@ -96,8 +96,7 @@ FROM M2MetaError IMPORT MetaErrorT0, MetaErrorT1, MetaErrorT2, MetaErrorT3, FROM M2Options IMPORT UnboundedByReference, PedanticCast, VerboseUnbounded, Iso, Pim, DebugBuiltins, WholeProgram, StrictTypeChecking, AutoInit, cflag, ScaffoldMain, - ScaffoldDynamic, ScaffoldStatic, - DebugTraceQuad, DebugTraceAPI ; +
[gcc r14-9763] Fix ICE with -g and -std=c23 related to incomplete types [PR114361]
https://gcc.gnu.org/g:871bb5ad2dd56343d80b6a6d269e85efdce5 commit r14-9763-g871bb5ad2dd56343d80b6a6d269e85efdce5 Author: Martin Uecker Date: Thu Mar 28 19:15:40 2024 +0100 Fix ICE with -g and -std=c23 related to incomplete types [PR114361] We did not copy TYPE_CANONICAL to the incomplete variants when completing a structure. PR c/114361 gcc/c/ * c-decl.cc (finish_struct): Set TYPE_CANONICAL when completing strucute types. gcc/testsuite/ * gcc.dg/pr114361.c: New test. * gcc.dg/c23-tag-incomplete-1.c: New test. * gcc.dg/c23-tag-incomplete-2.c: New test. Diff: --- gcc/c/c-decl.cc | 1 + gcc/testsuite/gcc.dg/c23-tag-incomplete-1.c | 14 ++ gcc/testsuite/gcc.dg/c23-tag-incomplete-2.c | 13 + gcc/testsuite/gcc.dg/pr114361.c | 11 +++ 4 files changed, 39 insertions(+) diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index c747abe9f4e..f2083b9d96f 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -9722,6 +9722,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, C_TYPE_VARIABLE_SIZE (x) = C_TYPE_VARIABLE_SIZE (t); C_TYPE_VARIABLY_MODIFIED (x) = C_TYPE_VARIABLY_MODIFIED (t); C_TYPE_INCOMPLETE_VARS (x) = NULL_TREE; + TYPE_CANONICAL (x) = TYPE_CANONICAL (t); } /* Update type location to the one of the definition, instead of e.g. diff --git a/gcc/testsuite/gcc.dg/c23-tag-incomplete-1.c b/gcc/testsuite/gcc.dg/c23-tag-incomplete-1.c new file mode 100644 index 000..82d652569e9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-tag-incomplete-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } + * { dg-options "-std=c23 -g" } */ + +struct a; +typedef struct a b; + +void g() { +struct a { b* x; }; +} + +struct a { b* x; }; + + + diff --git a/gcc/testsuite/gcc.dg/c23-tag-incomplete-2.c b/gcc/testsuite/gcc.dg/c23-tag-incomplete-2.c new file mode 100644 index 000..bc47a04ece5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-tag-incomplete-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } + * { dg-options "-std=c23 -g" } */ + +struct a; +typedef struct a b; + +void f() { + extern struct a { b* x; } t; +} + +extern struct a { b* x; } t; + + diff --git a/gcc/testsuite/gcc.dg/pr114361.c b/gcc/testsuite/gcc.dg/pr114361.c new file mode 100644 index 000..0f3feb53566 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr114361.c @@ -0,0 +1,11 @@ +/* PR c/114361 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu23 -g" } */ + +void f() +{ +typedef struct foo bar; +typedef __typeof( ({ (struct foo { bar *x; }){ }; }) ) wuz; +struct foo { wuz *x; }; +} +
[gcc r14-9762] analyzer: prevent ICEs with null types
https://gcc.gnu.org/g:e945d322fcbc68f91388b1d1297bdf6a6c6fcbaa commit r14-9762-ge945d322fcbc68f91388b1d1297bdf6a6c6fcbaa Author: David Malcolm Date: Tue Apr 2 17:42:16 2024 -0400 analyzer: prevent ICEs with null types Fixes some ICEs seen analyzing the Linux kernel. gcc/analyzer/ChangeLog: * region-model-manager.cc (maybe_undo_optimize_bit_field_compare): Guard against null types. * region-model.cc (apply_constraints_for_gswitch): Likewise. Signed-off-by: David Malcolm Diff: --- gcc/analyzer/region-model-manager.cc | 2 ++ gcc/analyzer/region-model.cc | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc index 4feb349c914..f155eeb87c0 100644 --- a/gcc/analyzer/region-model-manager.cc +++ b/gcc/analyzer/region-model-manager.cc @@ -616,6 +616,8 @@ maybe_undo_optimize_bit_field_compare (tree type, tree cst, const svalue *arg1) { + if (!type) +return nullptr; if (!INTEGRAL_TYPE_P (type)) return NULL; diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 902b887fc07..98f287145c6 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -5781,7 +5781,8 @@ apply_constraints_for_gswitch (const switch_cfg_superedge &edge, && is_a (unaryop->get_arg ())) if (const initial_svalue *initvalop = (as_a (unaryop->get_arg ( - if (TREE_CODE (initvalop->get_type ()) == ENUMERAL_TYPE) + if (initvalop->get_type () + && TREE_CODE (initvalop->get_type ()) == ENUMERAL_TYPE) { index_sval = initvalop; check_index_type = false;
[gcc r14-9761] libstdc++: Guard uses of char8_t with __cpp_char8_t [PR114519]
https://gcc.gnu.org/g:21aa57e73b820395b7b01843d61ef5b84cd20d02 commit r14-9761-g21aa57e73b820395b7b01843d61ef5b84cd20d02 Author: Jonathan Wakely Date: Thu Mar 28 21:29:17 2024 + libstdc++: Guard uses of char8_t with __cpp_char8_t [PR114519] libstdc++-v3/ChangeLog: PR libstdc++/114519 * include/bits/unicode.h (_Utf8_view): Guard with check for char8_t being enabled. (__literal_encoding_is_unicode): Guard use of char8_t with check for it being enabled. * testsuite/std/format/functions/114519.cc: New test. Diff: --- libstdc++-v3/include/bits/unicode.h | 10 +++--- libstdc++-v3/testsuite/std/format/functions/114519.cc | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/include/bits/unicode.h b/libstdc++-v3/include/bits/unicode.h index 51bf02e927f..0e95c86a0b0 100644 --- a/libstdc++-v3/include/bits/unicode.h +++ b/libstdc++-v3/include/bits/unicode.h @@ -578,8 +578,10 @@ namespace __unicode constexpr bool empty() const { return ranges::empty(_M_base); } }; +#ifdef __cpp_char8_t template using _Utf8_view = _Utf_view; +#endif template using _Utf16_view = _Utf_view; template @@ -991,12 +993,14 @@ inline namespace __v15_1_0 consteval bool __literal_encoding_is_unicode() { - if constexpr (is_same_v<_CharT, char8_t>) - return true; - else if constexpr (is_same_v<_CharT, char16_t>) + if constexpr (is_same_v<_CharT, char16_t>) return true; else if constexpr (is_same_v<_CharT, char32_t>) return true; +#ifdef __cpp_char8_t + else if constexpr (is_same_v<_CharT, char8_t>) + return true; +#endif const char* __enc = ""; diff --git a/libstdc++-v3/testsuite/std/format/functions/114519.cc b/libstdc++-v3/testsuite/std/format/functions/114519.cc new file mode 100644 index 000..25a112a954e --- /dev/null +++ b/libstdc++-v3/testsuite/std/format/functions/114519.cc @@ -0,0 +1,3 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-fno-char8_t" } +#include
[gcc r14-9760] libiberty: Invoke D demangler when --format=auto
https://gcc.gnu.org/g:ca2f7c84927f85b95f0f48f82b93f1460c372db4 commit r14-9760-gca2f7c84927f85b95f0f48f82b93f1460c372db4 Author: Tom Tromey Date: Sat Mar 30 13:48:30 2024 -0600 libiberty: Invoke D demangler when --format=auto Investigating GDB PR d/31580 showed that the libiberty demangler doesn't automatically demangle D mangled names. However, I think it should -- like C++ and Rust (new-style), D mangled names are readily distinguished by the leading "_D", and so the likelihood of confusion is low. The other non-"auto" cases in this code are Ada (where the encoded form could more easily be confused by ordinary programs) and Java (which is long gone, but which also shared the C++ mangling and thus was just an output style preference). This patch also fixed another GDB bug, though of course that part won't apply to the GCC repository. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31580 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30276 libiberty * cplus-dem.c (cplus_demangle): Try the D demangler with "auto" format. * testsuite/d-demangle-expected: Add --format=auto test. Diff: --- libiberty/cplus-dem.c | 2 +- libiberty/testsuite/d-demangle-expected | 5 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c index 8b92946981f..ee9e84f5d6b 100644 --- a/libiberty/cplus-dem.c +++ b/libiberty/cplus-dem.c @@ -186,7 +186,7 @@ cplus_demangle (const char *mangled, int options) if (GNAT_DEMANGLING) return ada_demangle (mangled, options); - if (DLANG_DEMANGLING) + if (DLANG_DEMANGLING || AUTO_DEMANGLING) { ret = dlang_demangle (mangled, options); if (ret) diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected index 47b059c4298..cfbdf2a52cb 100644 --- a/libiberty/testsuite/d-demangle-expected +++ b/libiberty/testsuite/d-demangle-expected @@ -1470,3 +1470,8 @@ demangle.anonymous --format=dlang _D8demangle9anonymous03fooZ demangle.anonymous.foo +# +# Test that 'auto' works. +--format=auto +_D8demangle9anonymous03fooZ +demangle.anonymous.foo
[gcc r13-8566] testsuite, Darwin: Skip g++.dg/debug/dwarf2/pr85550.C
https://gcc.gnu.org/g:84e9d97ec642521fa976d82c3dc0b89765ade1c2 commit r13-8566-g84e9d97ec642521fa976d82c3dc0b89765ade1c2 Author: Iain Sandoe Date: Sun Oct 1 20:38:44 2023 +0100 testsuite, Darwin: Skip g++.dg/debug/dwarf2/pr85550.C There are two problems here; first that the emitted asm for -fdebug-types-section is ELF-specfic leading to assembler errors for Mach-O. If we fix this, we get a secondary fail since the debug linker does not recognise DW_FORM_ref_sig8. Disable ths test until we get DWARF-5 support in the external Darwin toolchain components. gcc/testsuite/ChangeLog: * g++.dg/debug/dwarf2/pr85550.C: Skip for Darwin. Signed-off-by: Iain Sandoe (cherry picked from commit 76547f4c97b1c0744487d624c5e2e5a15d0370a9) Diff: --- gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C index 35b0f56e959..c95f75255d4 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C @@ -2,6 +2,7 @@ // { dg-do link } // { dg-options "-O2 -g -fdebug-types-section" } // { dg-skip-if "AIX DWARF5" { powerpc-ibm-aix* } } +// { dg-skip-if "No debug linker support" { *-*-darwin* } } struct A { int bar () const { return 0; }
[gcc r13-8565] testsuite: adjust for darwin linker warning
https://gcc.gnu.org/g:83f10a9ac04a616a9c7c7d3f35401653afe3296c commit r13-8565-g83f10a9ac04a616a9c7c7d3f35401653afe3296c Author: Francois-Xavier Coudert Date: Fri Sep 8 21:55:56 2023 +0200 testsuite: adjust for darwin linker warning On recent macOS versions, no_pie is deprecated and the linker complains about it: "-no_pie is deprecated when targeting new OS versions" gcc/testsuite/ChangeLog: * gcc.dg/darwin-segaddr.c: Adjust for darwin linker warning. * gcc.dg/pie-7.c: Likewise. (cherry picked from commit d9926c0d974646dc6024d5a881fe1bee2f499139) Diff: --- gcc/testsuite/gcc.dg/darwin-segaddr.c | 1 + gcc/testsuite/gcc.dg/pie-7.c | 1 + 2 files changed, 2 insertions(+) diff --git a/gcc/testsuite/gcc.dg/darwin-segaddr.c b/gcc/testsuite/gcc.dg/darwin-segaddr.c index 526db77bd9c..77112ddb484 100644 --- a/gcc/testsuite/gcc.dg/darwin-segaddr.c +++ b/gcc/testsuite/gcc.dg/darwin-segaddr.c @@ -2,6 +2,7 @@ /* { dg-do run { target *-*-darwin* } } */ /* { dg-options "-O0 -segaddr __TEST 0x20 -fno-pie" { target { *-*-darwin* && { ! lp64 } } } } */ /* { dg-options "-O0 -segaddr __TEST 0x11000 -fno-pie" { target { *-*-darwin* && lp64 } } } */ +/* { dg-prune-output "-no_pie is deprecated when targeting new OS versions" } */ extern void abort (); diff --git a/gcc/testsuite/gcc.dg/pie-7.c b/gcc/testsuite/gcc.dg/pie-7.c index e118a98bafd..3879a6cc120 100644 --- a/gcc/testsuite/gcc.dg/pie-7.c +++ b/gcc/testsuite/gcc.dg/pie-7.c @@ -1,5 +1,6 @@ /* { dg-do run { target pie } } */ /* { dg-options "-fno-pie -no-pie" } */ +/* { dg-prune-output "-no_pie is deprecated when targeting new OS versions" } */ int main(void) {
[gcc r13-8564] Testsuite: fix contructor priority test
https://gcc.gnu.org/g:f650cfccc61f0352f9c3a0993457e1cb7845bc7a commit r13-8564-gf650cfccc61f0352f9c3a0993457e1cb7845bc7a Author: Francois-Xavier Coudert Date: Sat Aug 19 22:37:33 2023 +0200 Testsuite: fix contructor priority test Fix the expected warning wording for targets without constructor priority, like Darwin, making the test pass. gcc/testsuite/ChangeLog: PR testsuite/111066 * g++.dg/special/initpri3.C: Fix wording. (cherry picked from commit 78f636d979530c8a649262dbd44914bdfb6f7290) Diff: --- gcc/testsuite/g++.dg/special/initpri3.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/g++.dg/special/initpri3.C b/gcc/testsuite/g++.dg/special/initpri3.C index 3d745a42a6a..63ed3208228 100644 --- a/gcc/testsuite/g++.dg/special/initpri3.C +++ b/gcc/testsuite/g++.dg/special/initpri3.C @@ -7,4 +7,4 @@ #endif struct A { A(); } a __attribute__((init_priority(500))); -// { dg-warning "attribute directive ignored" "" { target { ! init_priority } } .-1 } +// { dg-warning "attribute ignored" "" { target { ! init_priority } } .-1 }
[gcc r13-8563] testsuite, jit, Darwin: Handle Mach-O in assembler tests.
https://gcc.gnu.org/g:6709e6b08d1b0f59da0f3e2a8cb376bc3d203323 commit r13-8563-g6709e6b08d1b0f59da0f3e2a8cb376bc3d203323 Author: Iain Sandoe Date: Sat Jan 13 13:40:51 2024 + testsuite, jit, Darwin: Handle Mach-O in assembler tests. Several of the jit tests check for assembler-specific output which differs on Mach-O from ELF. This patch uses the facility to make the scans target-dependent and adds handling for darwin. gcc/testsuite/ChangeLog: * jit.dg/test-setting-alignment.c: Handle Darwin in jit-verify-assemble output. Signed-off-by: Iain Sandoe (cherry picked from commit 283e3a974bf08e4fb64d51d2062e1f7ed7482ff4) Diff: --- gcc/testsuite/jit.dg/test-setting-alignment.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/jit.dg/test-setting-alignment.c b/gcc/testsuite/jit.dg/test-setting-alignment.c index 8489df9c6b9..14edc723f61 100644 --- a/gcc/testsuite/jit.dg/test-setting-alignment.c +++ b/gcc/testsuite/jit.dg/test-setting-alignment.c @@ -62,5 +62,6 @@ create_code (gcc_jit_context *ctxt, void *user_data) } /* { dg-final { jit-verify-output-file-was-created "" } } */ -/* { dg-final { jit-verify-assembler-output ".comm foo,4,8" } } */ +/* { dg-final { jit-verify-assembler-output ".comm foo,4,8" { target { ! *-*-darwin* } } } } */ +/* { dg-final { jit-verify-assembler-output ".comm\\s_foo,4,3" { target *-*-darwin* } } } */ /* { dg-final { jit-verify-assembler-output "movl -16\\\(%rbp\\\), %eax" } } */
[gcc r13-8562] testsuite, jit: Allow for target-specific assembler scans.
https://gcc.gnu.org/g:bb7718a5e180bf6fd31dbb885caa705b90c97a3b commit r13-8562-gbb7718a5e180bf6fd31dbb885caa705b90c97a3b Author: Iain Sandoe Date: Sat Jan 13 13:30:08 2024 + testsuite, jit: Allow for target-specific assembler scans. Partial backport of e0e3ef18a047d54d63be91d82a55448851353260 from trunk. If we want to support multiple object formats and to allow for scan-assembler tests, we need to make it possible to adjust the tests on a per-target basis. This adds similar mechamisms to jit-verify-assembler-output to those used for the general scan-assembler dg directives. As an aside; it would, perhaps, be possible to integrate this more with scanasm.exp (which would also give access to function body scanning) but I did not attempt that for this patch. After this, we can accept things like: ... { jit-verify-assembler-output ".." { target *-*-darwin* } } } gcc/testsuite/ChangeLog: * jit.dg/jit.exp: Accept target clauses in jit-verify-assembler handling. Signed-off-by: Iain Sandoe (cherry picked from commit e0e3ef18a047d54d63be91d82a55448851353260) Diff: --- gcc/testsuite/jit.dg/jit.exp | 14 ++ 1 file changed, 14 insertions(+) diff --git a/gcc/testsuite/jit.dg/jit.exp b/gcc/testsuite/jit.dg/jit.exp index 3568dbb9d63..35d38cec5bc 100644 --- a/gcc/testsuite/jit.dg/jit.exp +++ b/gcc/testsuite/jit.dg/jit.exp @@ -871,9 +871,23 @@ proc jit-verify-assembler { args } { proc jit-verify-assembler-output { args } { verbose "jit-verify-assembler: $args" +if { [llength $args] > 3 } { + error "jit-verify-assembler-output: too many arguments" + return +} + set dg-output-text [lindex $args 0] verbose "dg-output-text: ${dg-output-text}" +if { [llength $args] >= 2 } { + switch [dg-process-target [lindex $args 1]] { + "S" { } + "N" { return } + "F" { setup_xfail "*-*-*" } + "P" { } + } +} + upvar 2 name name verbose "name: $name"
[gcc r13-8561] testsuite, jit: Handle whitespace in test-link-section-assembler.c.
https://gcc.gnu.org/g:0b17c87414f0caa00b7b799258db91b1251e406c commit r13-8561-g0b17c87414f0caa00b7b799258db91b1251e406c Author: Iain Sandoe Date: Sat Jan 13 12:49:28 2024 + testsuite, jit: Handle whitespace in test-link-section-assembler.c. Darwin has a different .section directive that has more fields and uses different whitespace. Amend the whitespace in the scan-asm to be more flexible. gcc/testsuite/ChangeLog: * jit.dg/test-link-section-assembler.c: Accept any whitespace between the .section directive and its arguments. Signed-off-by: Iain Sandoe (cherry picked from commit 2b0abfd3f8dbe3e9af79bb6bdc06d727d36f1946) Diff: --- gcc/testsuite/jit.dg/test-link-section-assembler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/jit.dg/test-link-section-assembler.c b/gcc/testsuite/jit.dg/test-link-section-assembler.c index a90b00e9a82..a78e9fd26ef 100644 --- a/gcc/testsuite/jit.dg/test-link-section-assembler.c +++ b/gcc/testsuite/jit.dg/test-link-section-assembler.c @@ -34,4 +34,4 @@ create_code (gcc_jit_context *ctxt, void *user_data) } /* { dg-final { jit-verify-output-file-was-created "" } } */ -/* { dg-final { jit-verify-assembler-output ".section .my_section" } } */ +/* { dg-final { jit-verify-assembler-output ".section\\s.my_section" } } */
[gcc r14-9759] c++: make __is_array return false for T[0] [PR114479]
https://gcc.gnu.org/g:2f2924078ce51c2a0da3ad8f958f2d1de533969a commit r14-9759-g2f2924078ce51c2a0da3ad8f958f2d1de533969a Author: Marek Polacek Date: Mon Apr 1 12:55:46 2024 -0400 c++: make __is_array return false for T[0] [PR114479] When we switched to using the __is_array built-in trait to implement std::is_array in r14-6623-g7fd9c349e45534, we started saying that T[0] is an array. There are various opinions as to whether that is the best answer, but it seems prudent to keep the GCC 13 result. PR c++/114479 gcc/cp/ChangeLog: * semantics.cc (trait_expr_value) : Return false for zero-sized arrays. gcc/testsuite/ChangeLog: * g++.dg/ext/is_array.C: Extend. Diff: --- gcc/cp/semantics.cc | 8 +++- gcc/testsuite/g++.dg/ext/is_array.C | 12 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 9838331d2a9..0015ff4fb62 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12439,7 +12439,13 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) return CP_AGGREGATE_TYPE_P (type1); case CPTK_IS_ARRAY: - return type_code1 == ARRAY_TYPE; + return (type_code1 == ARRAY_TYPE + /* We don't want to report T[0] as being an array type. +This is for compatibility with an implementation of +std::is_array by template argument deduction, because +compute_array_index_type_loc rejects a zero-size array +in SFINAE context. */ + && !(TYPE_SIZE (type1) && integer_zerop (TYPE_SIZE (type1; case CPTK_IS_ASSIGNABLE: return is_xible (MODIFY_EXPR, type1, type2); diff --git a/gcc/testsuite/g++.dg/ext/is_array.C b/gcc/testsuite/g++.dg/ext/is_array.C index f1a6e08b87a..84993266629 100644 --- a/gcc/testsuite/g++.dg/ext/is_array.C +++ b/gcc/testsuite/g++.dg/ext/is_array.C @@ -1,4 +1,5 @@ // { dg-do compile { target c++11 } } +// { dg-options "" } #define SA(X) static_assert((X),#X) @@ -10,18 +11,29 @@ class ClassType { }; +constexpr int sz0 = 0; +constexpr int sz2 = 2; + SA_TEST_CATEGORY(__is_array, int[2], true); SA_TEST_CATEGORY(__is_array, int[], true); +SA_TEST_CATEGORY(__is_array, int[0], false); SA_TEST_CATEGORY(__is_array, int[2][3], true); SA_TEST_CATEGORY(__is_array, int[][3], true); +SA_TEST_CATEGORY(__is_array, int[0][3], false); +SA_TEST_CATEGORY(__is_array, int[3][0], false); SA_TEST_CATEGORY(__is_array, float*[2], true); SA_TEST_CATEGORY(__is_array, float*[], true); SA_TEST_CATEGORY(__is_array, float*[2][3], true); SA_TEST_CATEGORY(__is_array, float*[][3], true); SA_TEST_CATEGORY(__is_array, ClassType[2], true); SA_TEST_CATEGORY(__is_array, ClassType[], true); +SA_TEST_CATEGORY(__is_array, ClassType[0], false); SA_TEST_CATEGORY(__is_array, ClassType[2][3], true); SA_TEST_CATEGORY(__is_array, ClassType[][3], true); +SA_TEST_CATEGORY(__is_array, ClassType[0][3], false); +SA_TEST_CATEGORY(__is_array, ClassType[2][0], false); +SA_TEST_CATEGORY(__is_array, int[sz2], true); +SA_TEST_CATEGORY(__is_array, int[sz0], false); // Sanity check. SA_TEST_CATEGORY(__is_array, ClassType, false);
[gcc r13-8560] c++: ICE with scoped enum in switch condition [PR103825]
https://gcc.gnu.org/g:22510e4a68aa9ca850db34ae62c21c58442d8ab3 commit r13-8560-g22510e4a68aa9ca850db34ae62c21c58442d8ab3 Author: Marek Polacek Date: Fri Mar 29 16:59:37 2024 -0400 c++: ICE with scoped enum in switch condition [PR103825] Here we ICE when gimplifying enum class Type { Pawn }; struct Piece { Type type : 4; }; void foo() { switch (Piece().type) case Type::Pawn:; } because we ended up with TYPE_PRECISION (cond) < TYPE_PRECISION (case). That's because the case expr type here is the unlowered type Type, whereas the conditional's type is the lowered . This is not supposed to happen: see the comment in pop_switch around the is_bitfield_expr_with_lowered_type check. But here we did not revert to the lowered SWITCH_STMT_TYPE, because the conditional contains a TARGET_EXPR, which has side-effects, which means that finish_switch_cond -> maybe_cleanup_point_expr wraps it in a CLEANUP_POINT_EXPR. And is_bitfield_expr_with_lowered_type does not see through those. PR c++/103825 gcc/cp/ChangeLog: * typeck.cc (is_bitfield_expr_with_lowered_type): Handle CLEANUP_POINT_EXPR. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/enum44.C: New test. (cherry picked from commit daa2e7c7ffe49b788357f7f2c9ef1c9b125c1f8c) Diff: --- gcc/cp/typeck.cc| 1 + gcc/testsuite/g++.dg/cpp0x/enum44.C | 30 ++ 2 files changed, 31 insertions(+) diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 56bb21ab251..81bc9edd955 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -2400,6 +2400,7 @@ is_bitfield_expr_with_lowered_type (const_tree exp) case NEGATE_EXPR: case NON_LVALUE_EXPR: case BIT_NOT_EXPR: +case CLEANUP_POINT_EXPR: return is_bitfield_expr_with_lowered_type (TREE_OPERAND (exp, 0)); case COMPONENT_REF: diff --git a/gcc/testsuite/g++.dg/cpp0x/enum44.C b/gcc/testsuite/g++.dg/cpp0x/enum44.C new file mode 100644 index 000..92408c92217 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum44.C @@ -0,0 +1,30 @@ +// PR c++/103825 +// { dg-do compile { target c++11 } } + +enum class Type { Pawn }; +struct Piece { + Type type : 4; +}; + +void +foo () +{ + switch (Piece().type) +case Type::Pawn:; + + auto x = Piece().type; + switch (x) +case Type::Pawn:; +} + +enum class En {A}; +struct St {En field :1;}; + +void +bar () +{ + volatile St s = {En::A}; + switch(s.field) { +case En::A : break; + } +}
[gcc r14-9758] c++: ICE with scoped enum in switch condition [PR103825]
https://gcc.gnu.org/g:daa2e7c7ffe49b788357f7f2c9ef1c9b125c1f8c commit r14-9758-gdaa2e7c7ffe49b788357f7f2c9ef1c9b125c1f8c Author: Marek Polacek Date: Fri Mar 29 16:59:37 2024 -0400 c++: ICE with scoped enum in switch condition [PR103825] Here we ICE when gimplifying enum class Type { Pawn }; struct Piece { Type type : 4; }; void foo() { switch (Piece().type) case Type::Pawn:; } because we ended up with TYPE_PRECISION (cond) < TYPE_PRECISION (case). That's because the case expr type here is the unlowered type Type, whereas the conditional's type is the lowered . This is not supposed to happen: see the comment in pop_switch around the is_bitfield_expr_with_lowered_type check. But here we did not revert to the lowered SWITCH_STMT_TYPE, because the conditional contains a TARGET_EXPR, which has side-effects, which means that finish_switch_cond -> maybe_cleanup_point_expr wraps it in a CLEANUP_POINT_EXPR. And is_bitfield_expr_with_lowered_type does not see through those. PR c++/103825 gcc/cp/ChangeLog: * typeck.cc (is_bitfield_expr_with_lowered_type): Handle CLEANUP_POINT_EXPR. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/enum44.C: New test. Diff: --- gcc/cp/typeck.cc| 1 + gcc/testsuite/g++.dg/cpp0x/enum44.C | 30 ++ 2 files changed, 31 insertions(+) diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 88ed38e4f30..e5a52dc2b39 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -2400,6 +2400,7 @@ is_bitfield_expr_with_lowered_type (const_tree exp) case NEGATE_EXPR: case NON_LVALUE_EXPR: case BIT_NOT_EXPR: +case CLEANUP_POINT_EXPR: return is_bitfield_expr_with_lowered_type (TREE_OPERAND (exp, 0)); case COMPONENT_REF: diff --git a/gcc/testsuite/g++.dg/cpp0x/enum44.C b/gcc/testsuite/g++.dg/cpp0x/enum44.C new file mode 100644 index 000..92408c92217 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum44.C @@ -0,0 +1,30 @@ +// PR c++/103825 +// { dg-do compile { target c++11 } } + +enum class Type { Pawn }; +struct Piece { + Type type : 4; +}; + +void +foo () +{ + switch (Piece().type) +case Type::Pawn:; + + auto x = Piece().type; + switch (x) +case Type::Pawn:; +} + +enum class En {A}; +struct St {En field :1;}; + +void +bar () +{ + volatile St s = {En::A}; + switch(s.field) { +case En::A : break; + } +}
[gcc r14-9757] c++: binding reference to comma expr [PR114561]
https://gcc.gnu.org/g:5d7e9a35024f065b25f61747859c7cb7a770c92b commit r14-9757-g5d7e9a35024f065b25f61747859c7cb7a770c92b Author: Jason Merrill Date: Tue Apr 2 10:52:28 2024 -0400 c++: binding reference to comma expr [PR114561] We represent a reference binding where the referent type is more qualified by a ck_ref_bind around a ck_qual. We performed the ck_qual and then tried to undo it with STRIP_NOPS, but that doesn't work if the conversion is buried in COMPOUND_EXPR. So instead let's avoid performing that fake conversion in the first place. PR c++/114561 PR c++/114562 gcc/cp/ChangeLog: * call.cc (convert_like_internal): Avoid adding qualification conversion in direct reference binding. gcc/testsuite/ChangeLog: * g++.dg/conversion/ref10.C: New test. * g++.dg/conversion/ref11.C: New test. Diff: --- gcc/cp/call.cc | 23 +-- gcc/testsuite/g++.dg/conversion/ref10.C | 5 + gcc/testsuite/g++.dg/conversion/ref11.C | 33 + 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 9e4c8073600..9568b5eb2c4 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -8742,7 +8742,15 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, break; }; - expr = convert_like (next_conversion (convs), expr, fn, argnum, + conversion *nc = next_conversion (convs); + if (convs->kind == ck_ref_bind && nc->kind == ck_qual + && !convs->need_temporary_p) +/* direct_reference_binding might have inserted a ck_qual under + this ck_ref_bind for the benefit of conversion sequence ranking. + Don't actually perform that conversion. */ +nc = next_conversion (nc); + + expr = convert_like (nc, expr, fn, argnum, convs->kind == ck_ref_bind ? issue_conversion_warnings : false, c_cast_p, /*nested_p=*/true, complain & ~tf_no_cleanup); @@ -8820,19 +8828,6 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, { tree ref_type = totype; - /* direct_reference_binding might have inserted a ck_qual under - this ck_ref_bind for the benefit of conversion sequence ranking. - Ignore the conversion; we'll create our own below. */ - if (next_conversion (convs)->kind == ck_qual - && !convs->need_temporary_p) - { - gcc_assert (same_type_p (TREE_TYPE (expr), -next_conversion (convs)->type)); - /* Strip the cast created by the ck_qual; cp_build_addr_expr - below expects an lvalue. */ - STRIP_NOPS (expr); - } - if (convs->bad_p && !next_conversion (convs)->bad_p) { tree extype = TREE_TYPE (expr); diff --git a/gcc/testsuite/g++.dg/conversion/ref10.C b/gcc/testsuite/g++.dg/conversion/ref10.C new file mode 100644 index 000..1913f733a6b --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/ref10.C @@ -0,0 +1,5 @@ +// PR c++/114561 + +void create(void* u) { + const void* const& r = ( (void)0, u ); +} diff --git a/gcc/testsuite/g++.dg/conversion/ref11.C b/gcc/testsuite/g++.dg/conversion/ref11.C new file mode 100644 index 000..bb9b835034c --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/ref11.C @@ -0,0 +1,33 @@ +// PR c++/114562 +// { dg-do compile { target c++11 } } + +template +struct Optional { + Optional(T&&); +}; + +struct MyClass { + MyClass(Optional); +}; + +// const void* NONE = nullptr; // Correct Error +void* NONE = nullptr; // Crash + +void beforeParam(); + +template +struct Create { + template static T create(U &&) noexcept; +}; + + +template +template +T Create::create(U && u) noexcept { + return T( ( (beforeParam()), (u) ) ); // { dg-error "cannot bind rvalue reference" } + // return T( (u) ); // Correct Error +} + +void test_func() { + Create::create(NONE); +}
[gcc r13-8559] Fortran: error recovery while simplifying expressions [PR103707, PR106987]
https://gcc.gnu.org/g:2808797fc4da7cc455803e2b69368b52db857b4c commit r13-8559-g2808797fc4da7cc455803e2b69368b52db857b4c Author: Harald Anlauf Date: Tue Mar 5 21:54:26 2024 +0100 Fortran: error recovery while simplifying expressions [PR103707,PR106987] When an exception is encountered during simplification of arithmetic expressions, the result may depend on whether range-checking is active (-frange-check) or not. However, the code path in the front-end should stay the same for "soft" errors for which the exception is triggered by the check, while "hard" errors should always terminate the simplification, so that error recovery is independent of the flag. Separation of arithmetic error codes into "hard" and "soft" errors shall be done consistently via is_hard_arith_error(). PR fortran/103707 PR fortran/106987 gcc/fortran/ChangeLog: * arith.cc (is_hard_arith_error): New helper function to determine whether an arithmetic error is "hard" or not. (check_result): Use it. (gfc_arith_divide): Set "Division by zero" only for regular numerators of real and complex divisions. (reduce_unary): Use is_hard_arith_error to determine whether a hard or (recoverable) soft error was encountered. Terminate immediately on hard error, otherwise remember code of first soft error. (reduce_binary_ac): Likewise. (reduce_binary_ca): Likewise. (reduce_binary_aa): Likewise. gcc/testsuite/ChangeLog: * gfortran.dg/arithmetic_overflow_3.f90: New test. (cherry picked from commit 93e1d4d24ed014387da97e2ce11556d68fe98e66) Diff: --- gcc/fortran/arith.cc | 134 +++-- .../gfortran.dg/arithmetic_overflow_3.f90 | 48 2 files changed, 142 insertions(+), 40 deletions(-) diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc index 5673c76823a..fade085450c 100644 --- a/gcc/fortran/arith.cc +++ b/gcc/fortran/arith.cc @@ -130,6 +130,30 @@ gfc_arith_error (arith code) } +/* Check if a certain arithmetic error code is severe enough to prevent + further simplification, as opposed to errors thrown by the range check + (e.g. overflow) or arithmetic exceptions that are tolerated with + -fno-range-check. */ + +static bool +is_hard_arith_error (arith code) +{ + switch (code) +{ +case ARITH_OK: +case ARITH_OVERFLOW: +case ARITH_UNDERFLOW: +case ARITH_NAN: +case ARITH_DIV0: +case ARITH_ASYMMETRIC: + return false; + +default: + return true; +} +} + + /* Get things ready to do math. */ void @@ -579,10 +603,10 @@ check_result (arith rc, gfc_expr *x, gfc_expr *r, gfc_expr **rp) val = ARITH_OK; } - if (val == ARITH_OK || val == ARITH_OVERFLOW) -*rp = r; - else + if (is_hard_arith_error (val)) gfc_free_expr (r); + else +*rp = r; return val; } @@ -792,23 +816,26 @@ gfc_arith_divide (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp) break; case BT_REAL: - if (mpfr_sgn (op2->value.real) == 0 && flag_range_check == 1) - { - rc = ARITH_DIV0; - break; - } + /* Set "Division by zero" only for regular numerator. */ + if (flag_range_check == 1 + && mpfr_zero_p (op2->value.real) + && mpfr_regular_p (op1->value.real)) + rc = ARITH_DIV0; mpfr_div (result->value.real, op1->value.real, op2->value.real, GFC_RND_MODE); break; case BT_COMPLEX: - if (mpc_cmp_si_si (op2->value.complex, 0, 0) == 0 - && flag_range_check == 1) - { - rc = ARITH_DIV0; - break; - } + /* Set "Division by zero" only for regular numerator. */ + if (flag_range_check == 1 + && mpfr_zero_p (mpc_realref (op2->value.complex)) + && mpfr_zero_p (mpc_imagref (op2->value.complex)) + && ((mpfr_regular_p (mpc_realref (op1->value.complex)) + && mpfr_number_p (mpc_imagref (op1->value.complex))) + || (mpfr_regular_p (mpc_imagref (op1->value.complex)) + && mpfr_number_p (mpc_realref (op1->value.complex) + rc = ARITH_DIV0; gfc_set_model (mpc_realref (op1->value.complex)); if (mpc_cmp_si_si (op2->value.complex, 0, 0) == 0) @@ -1323,7 +1350,6 @@ reduce_unary (arith (*eval) (gfc_expr *, gfc_expr **), gfc_expr *op, gfc_constructor *c; gfc_expr *r; arith rc; - bool ov = false; if (op->expr_type == EXPR_CONSTANT) return eval (op, result); @@ -1335,19 +1361,22 @@ reduce_unary (arith (*eval) (gfc_expr *, gfc_expr **), gfc_expr *op, head = gfc_constructor_copy (op->value.constructor); for (c = gfc_constructor_first (head); c; c = gfc_constructor_next (c)) { - rc = reduce_unary (eval, c->expr, &r); + arith rc_tmp = r
[gcc r14-9756] libstdc++: Allow adjacent __maybe_present_t fields to overlap
https://gcc.gnu.org/g:0e64bbb8823f7b3757befc878ed177dfb59943d1 commit r14-9756-g0e64bbb8823f7b3757befc878ed177dfb59943d1 Author: Patrick Palka Date: Tue Apr 2 13:07:07 2024 -0400 libstdc++: Allow adjacent __maybe_present_t fields to overlap Currently __maybe_present_t maps to the same empty class type independent of T. This is suboptimal because it means adjacent __maybe_present_t members with the [[no_unique_address]] attribute can't overlap even if the conditionally present types are different. This patch turns this empty class type into a template parameterized by the conditionally present type, so that [[no_unique_address]] __maybe_present_t _M_a; [[no_unique_address]] __maybe_present_t _M_b; now overlap if T and U are different. This patch goes a step further and also adds an optional integer discriminator parameter to allow for overlapping when T and U are the same. libstdc++-v3/ChangeLog: * include/std/ranges (ranges::__detail::_Empty): Rename to ... (ranges::__detail::_Absent): ... this. Turn into a template parameterized by the absent type _Tp and discriminator _Disc. (ranges::__detail::__maybe_present_t): Add an optional discriminator parameter. (slide_view::_M_cached_begin): Pass a discriminator argument to __maybe_present_t. (slide_view::_M_cached_end): Likewise. * testsuite/std/ranges/adaptors/sizeof.cc: Verify the size of slide_view is 3 instead 4 pointers. Reviewed-by: Jonathan Wakely Diff: --- libstdc++-v3/include/std/ranges | 13 - libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc | 4 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 7d739852677..afce818376b 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -886,14 +886,17 @@ namespace views namespace __detail { - struct _Empty { }; + template +struct _Absent { }; // Alias for a type that is conditionally present // (and is an empty type otherwise). // Data members using this alias should use [[no_unique_address]] so that // they take no space when not needed. - template -using __maybe_present_t = __conditional_t<_Present, _Tp, _Empty>; + // The optional template parameter _Disc is for discriminating two otherwise + // equivalent absent types so that even they can overlap. + template +using __maybe_present_t = __conditional_t<_Present, _Tp, _Absent<_Tp, _Disc>>; // Alias for a type that is conditionally const. template @@ -6553,10 +6556,10 @@ namespace views::__adaptor range_difference_t<_Vp> _M_n; [[no_unique_address]] __detail::__maybe_present_t<__detail::__slide_caches_first<_Vp>, - __detail::_CachedPosition<_Vp>> _M_cached_begin; + __detail::_CachedPosition<_Vp>, 0> _M_cached_begin; [[no_unique_address]] __detail::__maybe_present_t<__detail::__slide_caches_last<_Vp>, - __detail::_CachedPosition<_Vp>> _M_cached_end; + __detail::_CachedPosition<_Vp>, 1> _M_cached_end; template class _Iterator; class _Sentinel; diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc index 12a9da3181d..08c01704d10 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc @@ -49,3 +49,7 @@ static_assert(sizeof(ranges::lazy_split_view) == 4*ptr); static_assert (sizeof(ranges::reverse_view>) == 3*ptr); + +#if __cpp_lib_ranges_slide +static_assert(sizeof(ranges::slide_view) == 3*ptr); +#endif
[gcc r13-8558] Fortran: error recovery on arithmetic overflow on unary operations [PR113799]
https://gcc.gnu.org/g:ec8303dea72ed4f9ae9fdf3c996a0deef6809351 commit r13-8558-gec8303dea72ed4f9ae9fdf3c996a0deef6809351 Author: Harald Anlauf Date: Thu Feb 8 21:51:38 2024 +0100 Fortran: error recovery on arithmetic overflow on unary operations [PR113799] PR fortran/113799 gcc/fortran/ChangeLog: * arith.cc (reduce_unary): Remember any overflow encountered during reduction of unary arithmetic operations on array constructors and continue, and return error status, but terminate on serious errors. gcc/testsuite/ChangeLog: * gfortran.dg/arithmetic_overflow_2.f90: New test. (cherry picked from commit b3d622d70ba209b63471fc1b0970870046e55745) Diff: --- gcc/fortran/arith.cc| 11 --- gcc/testsuite/gfortran.dg/arithmetic_overflow_2.f90 | 12 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc index fcf37d48bfc..5673c76823a 100644 --- a/gcc/fortran/arith.cc +++ b/gcc/fortran/arith.cc @@ -1323,6 +1323,7 @@ reduce_unary (arith (*eval) (gfc_expr *, gfc_expr **), gfc_expr *op, gfc_constructor *c; gfc_expr *r; arith rc; + bool ov = false; if (op->expr_type == EXPR_CONSTANT) return eval (op, result); @@ -1336,13 +1337,17 @@ reduce_unary (arith (*eval) (gfc_expr *, gfc_expr **), gfc_expr *op, { rc = reduce_unary (eval, c->expr, &r); - if (rc != ARITH_OK) + /* Remember any overflow encountered during reduction and continue, +but terminate on serious errors. */ + if (rc == ARITH_OVERFLOW) + ov = true; + else if (rc != ARITH_OK) break; gfc_replace_expr (c->expr, r); } - if (rc != ARITH_OK) + if (rc != ARITH_OK && rc != ARITH_OVERFLOW) gfc_constructor_free (head); else { @@ -1363,7 +1368,7 @@ reduce_unary (arith (*eval) (gfc_expr *, gfc_expr **), gfc_expr *op, *result = r; } - return rc; + return ov ? ARITH_OVERFLOW : rc; } diff --git a/gcc/testsuite/gfortran.dg/arithmetic_overflow_2.f90 b/gcc/testsuite/gfortran.dg/arithmetic_overflow_2.f90 new file mode 100644 index 000..6ca27f74215 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/arithmetic_overflow_2.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-additional-options "-frange-check" } +! +! PR fortran/113799 - handle arithmetic overflow on unary minus + +program p + implicit none + real, parameter :: inf = real(z'7F80') + real, parameter :: someInf(*) = [inf, 0.] + print *, -someInf ! { dg-error "Arithmetic overflow" } + print *, minval(-someInf) ! { dg-error "Arithmetic overflow" } +end
[gcc r13-8557] Fortran: set shape of initializers of zero-sized arrays [PR95374, PR104352]
https://gcc.gnu.org/g:0dd82c0fba660775ff76ae27077a67f2f1358920 commit r13-8557-g0dd82c0fba660775ff76ae27077a67f2f1358920 Author: Harald Anlauf Date: Wed May 17 20:39:18 2023 +0200 Fortran: set shape of initializers of zero-sized arrays [PR95374,PR104352] gcc/fortran/ChangeLog: PR fortran/95374 PR fortran/104352 * decl.cc (add_init_expr_to_sym): Set shape of initializer also for zero-sized arrays, so that bounds violations can be detected later. gcc/testsuite/ChangeLog: PR fortran/95374 PR fortran/104352 * gfortran.dg/zero_sized_13.f90: New test. (cherry picked from commit 7bafe652dba9167b65e7b5ef24e77eceb49709ba) Diff: --- gcc/fortran/decl.cc | 3 +-- gcc/testsuite/gfortran.dg/zero_sized_13.f90 | 28 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index 03e993eb0ff..527e84ad763 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -2248,8 +2248,7 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus) && gfc_is_constant_expr (init) && (init->expr_type == EXPR_CONSTANT || init->expr_type == EXPR_STRUCTURE) - && spec_size (sym->as, &size) - && mpz_cmp_si (size, 0) > 0) + && spec_size (sym->as, &size)) { array = gfc_get_array_expr (init->ts.type, init->ts.kind, &init->where); diff --git a/gcc/testsuite/gfortran.dg/zero_sized_13.f90 b/gcc/testsuite/gfortran.dg/zero_sized_13.f90 new file mode 100644 index 000..4035d458b32 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/zero_sized_13.f90 @@ -0,0 +1,28 @@ +! { dg-do compile } +! { dg-options "-w" } +! +! PR fortran/95374 +! PR fortran/104352 - Various ICEs for bounds violation with zero-sized arrays +! +! Contributed by G. Steinmetz + +program p + implicit none + integer :: i + integer, parameter :: a(0)= 0 + integer, parameter :: b(0:-5) = 0 + integer, parameter :: c(*) = [(a(i:i), i=0,0)] ! { dg-error "out of bounds" } + integer, parameter :: d(*) = [(b(i:i), i=1,1)] ! { dg-error "out of bounds" } + integer, parameter :: e(1) = [(a(i) , i=1,1)] ! { dg-error "out of bounds" } + integer, parameter :: f(1) = [(a(i:i), i=1,1)] ! { dg-error "out of bounds" } + integer:: g(1) = [(a(i:i), i=0,0)] ! { dg-error "out of bounds" } + integer:: h(1) = [(a(i:i), i=1,1)] ! { dg-error "out of bounds" } + print *, [(a(i:i), i=0,0)] ! { dg-error "out of bounds" } + print *, [(a(i:i), i=1,1)] ! { dg-error "out of bounds" } + print *, any (a(1:1) == 1) ! { dg-error "out of bounds" } + print *, all (a(0:0) == 1) ! { dg-error "out of bounds" } + print *, sum (a(1:1)) ! { dg-error "out of bounds" } + print *, iall (a(0:0)) ! { dg-error "out of bounds" } + print *, minloc (a(0:0),1) ! { dg-error "out of bounds" } + print *, dot_product(a(1:1),a(1:1)) ! { dg-error "out of bounds" } +end
[gcc r11-11306] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]
https://gcc.gnu.org/g:4de35949e462d89926a171cd1ef7b6f40a308dab commit r11-11306-g4de35949e462d89926a171cd1ef7b6f40a308dab Author: Qing Zhao Date: Mon Mar 25 14:17:56 2024 + Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407] This is a bug in tree-ssa-math-opts.c, when applying the widening mul optimization, the compiler needs to check whether the operand is in a ABNORMAL PHI, if YES, we should avoid the transformation. PR tree-optimization/111407 gcc/ChangeLog: * tree-ssa-math-opts.c (convert_mult_to_widen): Avoid the transform when one of the operands is subject to abnormal coalescing. gcc/testsuite/ChangeLog: * gcc.dg/pr111407.c: New test. (cherry picked from commit 4aca1cfd6235090e48a53dab734437740671bbf3) Diff: --- gcc/testsuite/gcc.dg/pr111407.c | 21 + gcc/tree-ssa-math-opts.c| 8 2 files changed, 29 insertions(+) diff --git a/gcc/testsuite/gcc.dg/pr111407.c b/gcc/testsuite/gcc.dg/pr111407.c new file mode 100644 index 000..a171074753f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr111407.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/111407*/ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +enum { SEND_TOFILE } __sigsetjmp(); +void fclose(); +void foldergets(); +void sendpart_stats(int *p1, int a1, int b1) { + int *a = p1; + fclose(); + p1 = 0; + long t = b1; + if (__sigsetjmp()) { + { + long t1 = a1; + a1+=1; + fclose(a1*(long)t1); + } + } + if (p1) + fclose(); +} diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index adeb70fd635..dcaf272d73f 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -2678,6 +2678,14 @@ convert_mult_to_widen (gimple *stmt, gimple_stmt_iterator *gsi) if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2)) return false; + /* if any one of rhs1 and rhs2 is subject to abnormal coalescing, + avoid the tranform. */ + if ((TREE_CODE (rhs1) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)) + || (TREE_CODE (rhs2) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs2))) +return false; + to_mode = SCALAR_INT_TYPE_MODE (type); from_mode = SCALAR_INT_TYPE_MODE (type1); if (to_mode == from_mode)
[gcc r14-9755] aarch64: Fix typo in comment about FEATURE_STRING
https://gcc.gnu.org/g:d5aa2ca06aa7a6a2f826c4da19204b6db1402995 commit r14-9755-gd5aa2ca06aa7a6a2f826c4da19204b6db1402995 Author: Christophe Lyon Date: Fri Mar 29 14:25:05 2024 + aarch64: Fix typo in comment about FEATURE_STRING Fix the comment to document FEATURE_STRING instead of FEAT_STRING. 2024-03-29 Christophe Lyon gcc/ * config/aarch64/aarch64-option-extensions.def: Fix comment. Diff: --- gcc/config/aarch64/aarch64-option-extensions.def | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/config/aarch64/aarch64-option-extensions.def b/gcc/config/aarch64/aarch64-option-extensions.def index 061a145e9e7..aa3cd99f791 100644 --- a/gcc/config/aarch64/aarch64-option-extensions.def +++ b/gcc/config/aarch64/aarch64-option-extensions.def @@ -54,14 +54,14 @@ If a feature A appears in this list then the list implicitly includes any features that are transitively dependent on A (according to REQUIRES). - - FEAT_STRING is a string containing the entries in the 'Features' field of - /proc/cpuinfo on a GNU/Linux system that correspond to this architecture - extension being available. Sometimes multiple entries are needed to enable - the extension (for example, the 'crypto' extension depends on four - entries: aes, pmull, sha1, sha2 being present). In that case this field - should contain a space (" ") separated list of the strings in 'Features' - that are required. Their order is not important. An empty string means - do not detect this feature during auto detection. + - FEATURE_STRING is a string containing the entries in the 'Features' field + of /proc/cpuinfo on a GNU/Linux system that correspond to this + architecture extension being available. Sometimes multiple entries are + needed to enable the extension (for example, the 'crypto' extension + depends on four entries: aes, pmull, sha1, sha2 being present). In that + case this field should contain a space (" ") separated list of the strings + in 'Features' that are required. Their order is not important. An empty + string means do not detect this feature during auto detection. - OPT_FLAGS is a list of feature IDENTS that should be enabled (along with their transitive dependencies) when the specified FMV feature is present.
[gcc r12-10306] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]
https://gcc.gnu.org/g:5f23f9f141c4b52e8f4a9aadc88b8155cf1959a3 commit r12-10306-g5f23f9f141c4b52e8f4a9aadc88b8155cf1959a3 Author: Qing Zhao Date: Thu Feb 29 15:07:49 2024 + Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407] This is a bug in tree-ssa-math-opts.cc, when applying the widening mul optimization, the compiler needs to check whether the operand is in a ABNORMAL PHI, if YES, we should avoid the transformation. PR tree-optimization/111407 gcc/ChangeLog: * tree-ssa-math-opts.cc (convert_mult_to_widen): Avoid the transform when one of the operands is subject to abnormal coalescing. gcc/testsuite/ChangeLog: * gcc.dg/pr111407.c: New test. (cherry picked from commit 4aca1cfd6235090e48a53dab734437740671bbf3) Diff: --- gcc/testsuite/gcc.dg/pr111407.c | 21 + gcc/tree-ssa-math-opts.cc | 8 2 files changed, 29 insertions(+) diff --git a/gcc/testsuite/gcc.dg/pr111407.c b/gcc/testsuite/gcc.dg/pr111407.c new file mode 100644 index 000..a171074753f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr111407.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/111407*/ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +enum { SEND_TOFILE } __sigsetjmp(); +void fclose(); +void foldergets(); +void sendpart_stats(int *p1, int a1, int b1) { + int *a = p1; + fclose(); + p1 = 0; + long t = b1; + if (__sigsetjmp()) { + { + long t1 = a1; + a1+=1; + fclose(a1*(long)t1); + } + } + if (p1) + fclose(); +} diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc index 232e903b0d2..bab0cc5aef4 100644 --- a/gcc/tree-ssa-math-opts.cc +++ b/gcc/tree-ssa-math-opts.cc @@ -2681,6 +2681,14 @@ convert_mult_to_widen (gimple *stmt, gimple_stmt_iterator *gsi) if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2)) return false; + /* if any one of rhs1 and rhs2 is subject to abnormal coalescing, + avoid the tranform. */ + if ((TREE_CODE (rhs1) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)) + || (TREE_CODE (rhs2) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs2))) +return false; + to_mode = SCALAR_INT_TYPE_MODE (type); from_mode = SCALAR_INT_TYPE_MODE (type1); if (to_mode == from_mode)
[gcc r14-9754] Prettify output of debug_dwarf_die
https://gcc.gnu.org/g:1e459e6625ff86babc461f8ceada0a63aee5b7a5 commit r14-9754-g1e459e6625ff86babc461f8ceada0a63aee5b7a5 Author: Tom Tromey Date: Thu Mar 28 13:22:34 2024 -0600 Prettify output of debug_dwarf_die When debugging gcc, I tried calling debug_dwarf_die and I saw this output: DW_AT_location: location descriptor: (0x7fffe9c2e870) DW_OP_dup 0, 0 (0x7fffe9c2e8c0) DW_OP_bra location descriptor (0x7fffe9c2e640) , 0 (0x7fffe9c2e820) DW_OP_lit4 4, 0 (0x7fffe9c2e910) DW_OP_skip location descriptor (0x7fffe9c2e9b0) , 0 (0x7fffe9c2e640) DW_OP_dup 0, 0 I think those ", 0" should not appear on their own lines. The issue seems to be that print_dw_val should not generally emit a newline, except when recursing. gcc/ChangeLog * dwarf2out.cc (print_dw_val) : Don't print newline when not recursing. Diff: --- gcc/dwarf2out.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 8f18bc4fe64..1b0e8b5a5b2 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -6651,7 +6651,7 @@ print_dw_val (dw_val_node *val, bool recurse, FILE *outfile) case dw_val_class_loc: fprintf (outfile, "location descriptor"); if (val->v.val_loc == NULL) - fprintf (outfile, " -> \n"); + fprintf (outfile, " -> "); else if (recurse) { fprintf (outfile, ":\n"); @@ -6662,9 +6662,9 @@ print_dw_val (dw_val_node *val, bool recurse, FILE *outfile) else { if (flag_dump_noaddr || flag_dump_unnumbered) - fprintf (outfile, " #\n"); + fprintf (outfile, " #"); else - fprintf (outfile, " (%p)\n", (void *) val->v.val_loc); + fprintf (outfile, " (%p)", (void *) val->v.val_loc); } break; case dw_val_class_loc_list:
[gcc r14-9753] Fortran: Add error for subroutine passed to a variable dummy [PR106999]
https://gcc.gnu.org/g:a7aa9455a8b9cb080649a7357b7360f2d99bcbf1 commit r14-9753-ga7aa9455a8b9cb080649a7357b7360f2d99bcbf1 Author: Paul Thomas Date: Tue Apr 2 15:53:29 2024 +0100 Fortran: Add error for subroutine passed to a variable dummy [PR106999] 2024-04-02 Paul Thomas gcc/fortran PR fortran/106999 * interface.cc (gfc_compare_interfaces): Add error for a subroutine proc pointer passed to a variable formal. (compare_parameter): If a procedure pointer is being passed to a non-procedure formal arg, and there is an an interface, use gfc_compare_interfaces to check and provide a more useful error message. gcc/testsuite/ PR fortran/106999 * gfortran.dg/pr106999.f90: New test. Diff: --- gcc/fortran/interface.cc | 20 +++- gcc/testsuite/gfortran.dg/pr106999.f90 | 33 + 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc index 7b86a338bc1..bf151dae743 100644 --- a/gcc/fortran/interface.cc +++ b/gcc/fortran/interface.cc @@ -1789,6 +1789,14 @@ gfc_compare_interfaces (gfc_symbol *s1, gfc_symbol *s2, const char *name2, return false; } + if (s2->attr.subroutine && s1->attr.flavor == FL_VARIABLE) +{ + if (errmsg != NULL) + snprintf (errmsg, err_len, "subroutine proc pointer '%s' passed " + "to dummy variable '%s'", name2, s1->name); + return false; +} + /* Do strict checks on all characteristics (for dummy procedures and procedure pointer assignments). */ if (!generic_flag && strict_flag) @@ -2425,12 +2433,22 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual, { gfc_symbol *act_sym = actual->symtree->n.sym; - if (formal->attr.flavor != FL_PROCEDURE) + if (formal->attr.flavor != FL_PROCEDURE && !act_sym->ts.interface) { if (where) gfc_error ("Invalid procedure argument at %L", &actual->where); return false; } + else if (act_sym->ts.interface + && !gfc_compare_interfaces (formal, act_sym->ts.interface, + act_sym->name, 0, 1, err, + sizeof(err),NULL, NULL)) + { + if (where) + gfc_error_opt (0, "Interface mismatch in dummy procedure %qs at %L:" + " %s", formal->name, &actual->where, err); + return false; + } if (!gfc_compare_interfaces (formal, act_sym, act_sym->name, 0, 1, err, sizeof(err), NULL, NULL)) diff --git a/gcc/testsuite/gfortran.dg/pr106999.f90 b/gcc/testsuite/gfortran.dg/pr106999.f90 new file mode 100644 index 000..f05a27006f6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr106999.f90 @@ -0,0 +1,33 @@ +! { dg-do compile } +! Test the fix for PR106999 +! Contributed by Gerhard Steinmetz +program p + type t + integer :: i + procedure(g), pointer :: f + end type + class(t), allocatable :: y, z + procedure(g), pointer :: ff + allocate (z) + z%i = 42 + z%f => g + ff => g + call r(z%f) + call s(z%f) ! { dg-error "Interface mismatch in dummy procedure" } + call s(ff) ! { dg-error "Interface mismatch in dummy procedure" } +contains + subroutine g(x) + class(t) :: x + x%i = 84 + end + subroutine r(x) + procedure(g) :: x + print *, "in r" + allocate (y) + call x(y) + print *, y%i + end + subroutine s(x) + class(*) :: x + end subroutine +end
[gcc r13-8556] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]
https://gcc.gnu.org/g:2d9a9488e26233eb9497722fa9ccb88258f7402c commit r13-8556-g2d9a9488e26233eb9497722fa9ccb88258f7402c Author: Qing Zhao Date: Thu Feb 29 15:07:49 2024 + Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407] This is a bug in tree-ssa-math-opts.cc, when applying the widening mul optimization, the compiler needs to check whether the operand is in a ABNORMAL PHI, if YES, we should avoid the transformation. PR tree-optimization/111407 gcc/ChangeLog: * tree-ssa-math-opts.cc (convert_mult_to_widen): Avoid the transform when one of the operands is subject to abnormal coalescing. gcc/testsuite/ChangeLog: * gcc.dg/pr111407.c: New test. (cherry picked from commit 4aca1cfd6235090e48a53dab734437740671bbf3) Diff: --- gcc/testsuite/gcc.dg/pr111407.c | 21 + gcc/tree-ssa-math-opts.cc | 8 2 files changed, 29 insertions(+) diff --git a/gcc/testsuite/gcc.dg/pr111407.c b/gcc/testsuite/gcc.dg/pr111407.c new file mode 100644 index 000..a171074753f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr111407.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/111407*/ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +enum { SEND_TOFILE } __sigsetjmp(); +void fclose(); +void foldergets(); +void sendpart_stats(int *p1, int a1, int b1) { + int *a = p1; + fclose(); + p1 = 0; + long t = b1; + if (__sigsetjmp()) { + { + long t1 = a1; + a1+=1; + fclose(a1*(long)t1); + } + } + if (p1) + fclose(); +} diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc index 15eed3e960c..ff949e4fec9 100644 --- a/gcc/tree-ssa-math-opts.cc +++ b/gcc/tree-ssa-math-opts.cc @@ -2754,6 +2754,14 @@ convert_mult_to_widen (gimple *stmt, gimple_stmt_iterator *gsi) if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2)) return false; + /* if any one of rhs1 and rhs2 is subject to abnormal coalescing, + avoid the tranform. */ + if ((TREE_CODE (rhs1) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)) + || (TREE_CODE (rhs2) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs2))) +return false; + to_mode = SCALAR_INT_TYPE_MODE (type); from_mode = SCALAR_INT_TYPE_MODE (type1); if (to_mode == from_mode)
[gcc r14-9752] Fortran: Fix wrong recursive errors and class initialization [PR112407]
https://gcc.gnu.org/g:35408b3669fac104cd380582b32e32c64a603d8b commit r14-9752-g35408b3669fac104cd380582b32e32c64a603d8b Author: Paul Thomas Date: Tue Apr 2 14:19:09 2024 +0100 Fortran: Fix wrong recursive errors and class initialization [PR112407] 2024-04-02 Paul Thomas gcc/fortran PR fortran/112407 * resolve.cc (resolve_procedure_expression): Change the test for for recursion in the case of hidden procedures from modules. (resolve_typebound_static): Add warning for possible recursive calls to typebound procedures. * trans-expr.cc (gfc_trans_class_init_assign): Do not apply default initializer to class dummy where component initializers are all null. gcc/testsuite/ PR fortran/112407 * gfortran.dg/pr112407a.f90: New test. * gfortran.dg/pr112407b.f90: New test. Diff: --- gcc/fortran/resolve.cc | 23 +-- gcc/fortran/trans-expr.cc | 16 gcc/testsuite/gfortran.dg/pr112407a.f90 | 71 + gcc/testsuite/gfortran.dg/pr112407b.f90 | 58 +++ 4 files changed, 164 insertions(+), 4 deletions(-) diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 50d51b06c92..43315a6a550 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -1963,12 +1963,20 @@ resolve_procedure_expression (gfc_expr* expr) || (sym->attr.function && sym->result == sym)) return true; - /* A non-RECURSIVE procedure that is used as procedure expression within its + /* A non-RECURSIVE procedure that is used as procedure expression within its own body is in danger of being called recursively. */ if (is_illegal_recursion (sym, gfc_current_ns)) -gfc_warning (0, "Non-RECURSIVE procedure %qs at %L is possibly calling" -" itself recursively. Declare it RECURSIVE or use" -" %<-frecursive%>", sym->name, &expr->where); +{ + if (sym->attr.use_assoc && expr->symtree->name[0] == '@') + gfc_warning (0, "Non-RECURSIVE procedure %qs from module %qs is " +" possibly calling itself recursively in procedure %qs. " +" Declare it RECURSIVE or use %<-frecursive%>", +sym->name, sym->module, gfc_current_ns->proc_name->name); + else + gfc_warning (0, "Non-RECURSIVE procedure %qs at %L is possibly calling" +" itself recursively. Declare it RECURSIVE or use" +" %<-frecursive%>", sym->name, &expr->where); +} return true; } @@ -6820,6 +6828,13 @@ resolve_typebound_static (gfc_expr* e, gfc_symtree** target, if (st) *target = st; } + + if (is_illegal_recursion ((*target)->n.sym, gfc_current_ns) + && !e->value.compcall.tbp->deferred) +gfc_warning (0, "Non-RECURSIVE procedure %qs at %L is possibly calling" +" itself recursively. Declare it RECURSIVE or use" +" %<-frecursive%>", (*target)->n.sym->name, &e->where); + return true; } diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index d21e3956d6e..f4c4724e1c3 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -1719,6 +1719,7 @@ gfc_trans_class_init_assign (gfc_code *code) tree tmp; gfc_se dst,src,memsz; gfc_expr *lhs, *rhs, *sz; + gfc_component *cmp; gfc_start_block (&block); @@ -1735,6 +1736,21 @@ gfc_trans_class_init_assign (gfc_code *code) /* The _def_init is always scalar. */ rhs->rank = 0; + /* Check def_init for initializers. If this is a dummy with all default + initializer components NULL, return NULL_TREE and use the passed value as + required by F2018(8.5.10). */ + if (!lhs->ref && lhs->symtree->n.sym->attr.dummy) +{ + cmp = rhs->ref->next->u.c.component->ts.u.derived->components; + for (; cmp; cmp = cmp->next) + { + if (cmp->initializer) + break; + else if (!cmp->next) + return build_empty_stmt (input_location); + } +} + if (code->expr1->ts.type == BT_CLASS && CLASS_DATA (code->expr1)->attr.dimension) { diff --git a/gcc/testsuite/gfortran.dg/pr112407a.f90 b/gcc/testsuite/gfortran.dg/pr112407a.f90 new file mode 100644 index 000..470f4191611 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr112407a.f90 @@ -0,0 +1,71 @@ +! { dg-do run } +! Test of an issue found in the investigation of PR112407 +! Contributed by Tomas Trnka +! +module m + private new_t + + type s +procedure(),pointer,nopass :: op + end type + + type :: t +integer :: i +type (s) :: s + contains +procedure :: new_t +procedure :: bar +procedure :: add_t +generic :: new => new_t, bar +generic, public :: assignment(=) => add_t +final :: final_t + end type + + integer :: i = 0, finals = 0 + +contain
[gcc r11-11305] fortran: Ignore use statements on error [PR107426]
https://gcc.gnu.org/g:3d05b9ac1c6ad950339f9487702c3165c189fe9e commit r11-11305-g3d05b9ac1c6ad950339f9487702c3165c189fe9e Author: Mikael Morin Date: Thu Mar 21 17:27:54 2024 +0100 fortran: Ignore use statements on error [PR107426] This fixes an access to freed memory on the testcase from the PR. The problem comes from an invalid subroutine statement in an interface, which is ignored and causes the following statements forming the procedure body to be rejected. One of them use-associates the intrinsic ISO_C_BINDING module, which imports new symbols in a namespace that is freed at the time the statement is rejected. However, this creates dangling pointers as ISO_C_BINDING is special and its import creates a reference to the imported C_PTR symbol in the return type of the global intrinsic symbol for C_LOC (see the function create_intrinsic_function). This change saves and restores the list of use statements, so that rejected use statements are removed before they have a chance to be applied to the current namespace and create dangling pointers. PR fortran/107426 gcc/fortran/ChangeLog: * gfortran.h (gfc_save_module_list, gfc_restore_old_module_list): New declarations. * module.c (old_module_list_tail): New global variable. (gfc_save_module_list, gfc_restore_old_module_list): New functions. (gfc_use_modules): Set module_list and old_module_list_tail. * parse.c (next_statement): Save module_list before doing any work. (reject_statement): Restore module_list to its saved value. gcc/testsuite/ChangeLog: * gfortran.dg/pr89943_3.f90: Update error pattern. * gfortran.dg/pr89943_4.f90: Likewise. * gfortran.dg/use_31.f90: New test. (cherry picked from commit a44d7e8a52007c2d45217709ca02947c6600de87) Diff: --- gcc/fortran/gfortran.h | 2 ++ gcc/fortran/module.c| 31 +++ gcc/fortran/parse.c | 4 gcc/testsuite/gfortran.dg/pr89943_3.f90 | 2 +- gcc/testsuite/gfortran.dg/pr89943_4.f90 | 2 +- gcc/testsuite/gfortran.dg/use_31.f90| 26 ++ 6 files changed, 65 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 0436c4f308f..e5a0bc2be60 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -3578,6 +3578,8 @@ void gfc_module_done_2 (void); void gfc_dump_module (const char *, int); bool gfc_check_symbol_access (gfc_symbol *); void gfc_free_use_stmts (gfc_use_list *); +void gfc_save_module_list (); +void gfc_restore_old_module_list (); const char *gfc_dt_lower_string (const char *); const char *gfc_dt_upper_string (const char *); diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 089453caa03..42bd585434f 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -195,7 +195,12 @@ static const char *module_name; /* The name of the .smod file that the submodule will write to. */ static const char *submodule_name; +/* The list of use statements to apply to the current namespace + before parsing the non-use statements. */ static gfc_use_list *module_list; +/* The end of the MODULE_LIST list above at the time the recognition + of the current statement started. */ +static gfc_use_list **old_module_list_tail; /* If we're reading an intrinsic module, this is its ID. */ static intmod_id current_intmod; @@ -7476,6 +7481,8 @@ gfc_use_modules (void) gfc_use_module (module_list); free (module_list); } + module_list = NULL; + old_module_list_tail = &module_list; gfc_rename_list = NULL; } @@ -7499,6 +7506,30 @@ gfc_free_use_stmts (gfc_use_list *use_stmts) } +/* Remember the end of the MODULE_LIST list, so that the list can be restored + to its previous state if the current statement is erroneous. */ + +void +gfc_save_module_list () +{ + gfc_use_list **tail = &module_list; + while (*tail != NULL) +tail = &(*tail)->next; + old_module_list_tail = tail; +} + + +/* Restore the MODULE_LIST list to its previous value and free the use + statements that are no longer part of the list. */ + +void +gfc_restore_old_module_list () +{ + gfc_free_use_stmts (*old_module_list_tail); + *old_module_list_tail = NULL; +} + + void gfc_module_init_2 (void) { diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 6893557733b..65fd0827c01 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -1519,6 +1519,7 @@ next_statement (void) locus old_locus; gfc_enforce_clean_symbol_state (); + gfc_save_module_list (); gfc_new_block = NULL; @@ -2674,6 +2675,9 @@ reject_statement (void) gfc_reject_data (gfc_current_ns); + /* Don't queue use-association of a module if we reject the use statement. */ + gfc_restore_old_module_list (); +
[gcc r12-10305] fortran: Ignore use statements on error [PR107426]
https://gcc.gnu.org/g:38dd703d368c9e60159e6f19cfc8303ad639b557 commit r12-10305-g38dd703d368c9e60159e6f19cfc8303ad639b557 Author: Mikael Morin Date: Thu Mar 21 17:27:54 2024 +0100 fortran: Ignore use statements on error [PR107426] This fixes an access to freed memory on the testcase from the PR. The problem comes from an invalid subroutine statement in an interface, which is ignored and causes the following statements forming the procedure body to be rejected. One of them use-associates the intrinsic ISO_C_BINDING module, which imports new symbols in a namespace that is freed at the time the statement is rejected. However, this creates dangling pointers as ISO_C_BINDING is special and its import creates a reference to the imported C_PTR symbol in the return type of the global intrinsic symbol for C_LOC (see the function create_intrinsic_function). This change saves and restores the list of use statements, so that rejected use statements are removed before they have a chance to be applied to the current namespace and create dangling pointers. PR fortran/107426 gcc/fortran/ChangeLog: * gfortran.h (gfc_save_module_list, gfc_restore_old_module_list): New declarations. * module.cc (old_module_list_tail): New global variable. (gfc_save_module_list, gfc_restore_old_module_list): New functions. (gfc_use_modules): Set module_list and old_module_list_tail. * parse.cc (next_statement): Save module_list before doing any work. (reject_statement): Restore module_list to its saved value. gcc/testsuite/ChangeLog: * gfortran.dg/pr89943_3.f90: Update error pattern. * gfortran.dg/pr89943_4.f90: Likewise. * gfortran.dg/use_31.f90: New test. (cherry picked from commit a44d7e8a52007c2d45217709ca02947c6600de87) Diff: --- gcc/fortran/gfortran.h | 2 ++ gcc/fortran/module.cc | 31 +++ gcc/fortran/parse.cc| 4 gcc/testsuite/gfortran.dg/pr89943_3.f90 | 2 +- gcc/testsuite/gfortran.dg/pr89943_4.f90 | 2 +- gcc/testsuite/gfortran.dg/use_31.f90| 26 ++ 6 files changed, 65 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 7bf1d5a0452..98c0cd39503 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -3800,6 +3800,8 @@ void gfc_module_done_2 (void); void gfc_dump_module (const char *, int); bool gfc_check_symbol_access (gfc_symbol *); void gfc_free_use_stmts (gfc_use_list *); +void gfc_save_module_list (); +void gfc_restore_old_module_list (); const char *gfc_dt_lower_string (const char *); const char *gfc_dt_upper_string (const char *); diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc index 85aa153bd77..7b06acb3133 100644 --- a/gcc/fortran/module.cc +++ b/gcc/fortran/module.cc @@ -195,7 +195,12 @@ static const char *module_name; /* The name of the .smod file that the submodule will write to. */ static const char *submodule_name; +/* The list of use statements to apply to the current namespace + before parsing the non-use statements. */ static gfc_use_list *module_list; +/* The end of the MODULE_LIST list above at the time the recognition + of the current statement started. */ +static gfc_use_list **old_module_list_tail; /* If we're reading an intrinsic module, this is its ID. */ static intmod_id current_intmod; @@ -7542,6 +7547,8 @@ gfc_use_modules (void) gfc_use_module (module_list); free (module_list); } + module_list = NULL; + old_module_list_tail = &module_list; gfc_rename_list = NULL; } @@ -7565,6 +7572,30 @@ gfc_free_use_stmts (gfc_use_list *use_stmts) } +/* Remember the end of the MODULE_LIST list, so that the list can be restored + to its previous state if the current statement is erroneous. */ + +void +gfc_save_module_list () +{ + gfc_use_list **tail = &module_list; + while (*tail != NULL) +tail = &(*tail)->next; + old_module_list_tail = tail; +} + + +/* Restore the MODULE_LIST list to its previous value and free the use + statements that are no longer part of the list. */ + +void +gfc_restore_old_module_list () +{ + gfc_free_use_stmts (*old_module_list_tail); + *old_module_list_tail = NULL; +} + + void gfc_module_init_2 (void) { diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index 3e9c6514c80..2b3a1a91fd9 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -1600,6 +1600,7 @@ next_statement (void) locus old_locus; gfc_enforce_clean_symbol_state (); + gfc_save_module_list (); gfc_new_block = NULL; @@ -2875,6 +2876,9 @@ reject_statement (void) gfc_reject_data (gfc_current_ns); + /* Don't queue use-association of a module if we reject the use statement. */ + gfc_restore_old_module_
[gcc r14-9751] Fix up postboot dependencies [PR106472]
https://gcc.gnu.org/g:9a5e4aade2b847c5262577a1490ce6f3df9a9841 commit r14-9751-g9a5e4aade2b847c5262577a1490ce6f3df9a9841 Author: Jakub Jelinek Date: Tue Apr 2 13:40:27 2024 +0200 Fix up postboot dependencies [PR106472] On Wed, Mar 13, 2024 at 10:13:37AM +0100, Jakub Jelinek wrote: > While the first Makefile.tpl hunk looks obviously ok, the others look > completely wrong to me. > There is nothing special about libgo vs. libbacktrace/libatomic > compared to any other target library which is not bootstrapped vs. any > of its dependencies which are in the bootstrapped set. > So, Makefile.tpl shouldn't hardcode such dependencies. Here is my version of the fix. The dependencies in the toplevel Makefile simply didn't take into account that some target modules could be in a bootstrapped build built in some configurations as bootstrap modules (typically as dependencies of other target bootstrap modules), while in other configurations just as dependencies of non-bootstrap target modules and so not built during the bootstrap, but after it. Makefile.tpl arranges for those postboot target module -> target module dependencies to be emitted only inside of an @unless gcc-bootstrap block, while for @if gcc-bootstrap it just emits configure-target-whatever: stage_last dependencies which ensure those postbootstrap target modules are only built after everything that is bootstrapped has been. Now, the libbacktrace/libatomic target modules have bootstrap=true target_modules = { module= libbacktrace; bootstrap=true; }; target_modules = { module= libatomic; bootstrap=true; lib_path=.libs; }; because those modules are dependencies of libphobos target module, so when d is included among bootstrapped languages, those are all bootstrapped and everything works correctly. While if d is not included, libphobos target module is disabled, libbacktrace/libatomic target modules aren't bootstrapped, nothing during bootstrap needs them, but post bootstrap libgo target module depends on the libatomic and libbacktrace target modules, libgfortran target module depends on the libbacktrace target module and libgm2 target module depends on the libatomic target module, but those dependencies were emitted only @unless gcc-bootstrap. There is a similar theoretical problem for zlib target module if GCJ would be ressurected, libphobos as bootstrap target module depends on the zlib target module, but if d is not configured, fastjar also depends on it. The following patch arranges for the @if gcc-bootstrap case to emit also target module -> target module dependencies, but conditionally on the on dependency not being bootstrapped. In the generated Makefile.in you can see what the Makefile.tpl change produces and that it just adds extra dependencies which weren't there before in the @if gcc-bootstrap case. I've bootstrapped without this patch with ../configure --enable-languages=c,c++,go; make on x86_64-linux (note, make -j2 or higher usually worked) which failed as described in the PR, then with this patch with the same command which built fine and the Makefile difference between the two builds being diff -up obj40{a,b}/Makefile --- obj40a/Makefile 2024-03-31 00:35:22.243791499 +0100 +++ obj40b/Makefile 2024-03-31 22:40:38.143299144 +0200 @@ -29376,6 +29376,14 @@ configure-bison: stage_last configure-flex: stage_last configure-m4: stage_last +configure-target-fastjar: maybe-configure-target-zlib +all-target-fastjar: maybe-all-target-zlib +all-target-libgo: maybe-all-target-libbacktrace +all-target-libgo: maybe-all-target-libatomic +all-target-libgm2: maybe-all-target-libatomic +configure-target-libgfortran: maybe-all-target-libbacktrace +configure-target-libgo: maybe-all-target-libbacktrace + # Dependencies for target modules on other target modules are # described by lang_env_dependencies; the defaults apply to anything which I believe are exactly the extra dependencies we want. Plus I've done normal x86_64-linux and i686-linux bootstraps/regtests which in my case include --enable-languages=default,ada,obj-c++,lto,go,d,rust,m2 for x86_64 and the same except ada for i686; those with my usual make -j32. The Makefile difference in those builds vs. unpatched case is just an extra empty line. 2024-04-02 Jakub Jelinek PR bootstrap/106472 * Makefile.tpl (make-postboot-target-dep): New lambda. Use it to add --enable-bootstrap dependencies of target modules on other target modules if the latter aren't bootstrapped. * Makefile.in: Regenerate. Diff: --- Makefile.in | 33 + Makefile.tpl | 24 2
[gcc r14-9750] Fix up duplicated words mostly in comments, part 1
https://gcc.gnu.org/g:94792057ad4a81bb10cdd20085c31df3ca59177e commit r14-9750-g94792057ad4a81bb10cdd20085c31df3ca59177e Author: Jakub Jelinek Date: Tue Apr 2 13:39:11 2024 +0200 Fix up duplicated words mostly in comments, part 1 Like in r12-7519-g027e30414492d50feb2854aff38227b14300dc4b, I've done git grep -v 'long long\|optab optab\|template template\|double double' | grep ' \([a-zA-Z]\+\) \1 ' This is just part of the changes, mostly for non-gcc directories. I'll try to get to the rest soon. Obviously, the above command also finds cases which are correct as is and shouldn't be changed, so one needs to manually inspect everything. I'd hope most of it is pretty obvious, but the config/ and libstdc++-v3/ hunks include a tweak in a license wording, though other copies of the similar license have the wording right. 2024-04-02 Jakub Jelinek * Makefile.tpl: Fix duplicated words; returns returns -> returns. config/ * lcmessage.m4: Fix duplicated words; can can -> can, package package -> package. libdecnumber/ * decCommon.c (decFinalize): Fix duplicated words in comment; the the -> the. libgcc/ * unwind-dw2-fde.c (struct fde_accumulator): Fix duplicated words in comment; is is -> is. libgfortran/ * configure.host: Fix duplicated words; the the -> the. libgm2/ * configure.host: Fix duplicated words; the the -> the. libgomp/ * libgomp.texi (OpenMP 5.2): Fix duplicated words; with with -> with. (omp_target_associate_ptr): Fix duplicated words; either either -> either. (omp_init_allocator): Fix duplicated words; be be -> be. (omp_realloc): Fix duplicated words; is is -> is. (OMP_ALLOCATOR): Fix duplicated words; other other -> other. * priority_queue.h (priority_queue_multi_p): Fix duplicated words; to to -> to. libiberty/ * regex.c (byte_re_match_2_internal): Fix duplicated words in comment; next next -> next. * dyn-string.c (dyn_string_init): Fix duplicated words in comment; of of -> of. libitm/ * beginend.cc (GTM::gtm_thread::begin_transaction): Fix duplicated words in comment; not not -> not to. libobjc/ * init.c (duplicate_classes): Fix duplicated words in comment; in in -> in. * sendmsg.c (__objc_prepare_dtable_for_class): Fix duplicated words in comment; the the -> the. * encoding.c (objc_layout_structure): Likewise. libstdc++-v3/ * acinclude.m4: Fix duplicated words; file file -> file can. * configure.host: Fix duplicated words; the the -> the. libvtv/ * vtv_rts.cc (vtv_fail): Fix duplicated words; to to -> to. * vtv_fail.cc (vtv_fail): Likewise. Diff: --- Makefile.tpl| 2 +- config/lcmessage.m4 | 4 ++-- libdecnumber/decCommon.c| 2 +- libgcc/unwind-dw2-fde.c | 2 +- libgfortran/configure.host | 2 +- libgm2/configure.host | 2 +- libgomp/libgomp.texi| 10 +- libgomp/priority_queue.h| 2 +- libiberty/dyn-string.c | 2 +- libiberty/regex.c | 2 +- libitm/beginend.cc | 2 +- libobjc/encoding.c | 2 +- libobjc/init.c | 2 +- libobjc/sendmsg.c | 2 +- libstdc++-v3/acinclude.m4 | 2 +- libstdc++-v3/configure.host | 2 +- libvtv/vtv_fail.cc | 2 +- libvtv/vtv_rts.cc | 2 +- 18 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Makefile.tpl b/Makefile.tpl index adbcbdd1d57..0d5f0a1b9b0 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -1976,7 +1976,7 @@ configure-target-[+module+]: maybe-all-gcc[+ (define dep-maybe (lambda () (if (exist? "hard") "" "maybe-"))) - ;; dep-kind returns returns "prebootstrap" for configure or build + ;; dep-kind returns "prebootstrap" for configure or build ;; dependencies of bootstrapped modules on a build module ;; (e.g. all-gcc on all-build-bison); "normal" if the dependency is ;; on an "install" target, or if the dependence module is not diff --git a/config/lcmessage.m4 b/config/lcmessage.m4 index ffd4008b825..62a9186af2f 100644 --- a/config/lcmessage.m4 +++ b/config/lcmessage.m4 @@ -6,13 +6,13 @@ dnl Public License, this file may be distributed as part of a program dnl that contains a configuration script generated by Autoconf, under dnl the same distribution terms as the rest of that program. dnl -dnl This file can can be used in projects which are not available under +dnl This file can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the
[gcc r14-9749] jit, Darwin: Implement library exports list.
https://gcc.gnu.org/g:b120e355e59142bd15d6b010461d07236288d843 commit r14-9749-gb120e355e59142bd15d6b010461d07236288d843 Author: Iain Sandoe Date: Sat Jan 13 17:20:47 2024 + jit, Darwin: Implement library exports list. Currently, we have no exports list for libgccjit, which means that all symbols are exported, including those from libstdc++ which is linked statically into the lib. This causes failures when the shared libstdc++ is used but some c++ symbols are satisfied from libgccjit. This implements an export file for Darwin (which is currently manually created by cross-checking libgccjit.map). Ideally we'd script this, at some point. Update libtool current and age to reflect the current ABI version (we are not bumping the SO name at this stage). This fixes a number of new failures in jit testing. gcc/jit/ChangeLog: * Make-lang.in: Implement exports list, and use a shared libgcc. * libgccjit.exports: New file. Signed-off-by: Iain Sandoe Diff: --- gcc/jit/Make-lang.in | 47 ++ gcc/jit/libgccjit.exports | 233 ++ 2 files changed, 263 insertions(+), 17 deletions(-) diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in index b1f0ce73e12..99b3d549d5d 100644 --- a/gcc/jit/Make-lang.in +++ b/gcc/jit/Make-lang.in @@ -55,7 +55,17 @@ else ifneq (,$(findstring darwin,$(host))) -LIBGCCJIT_AGE = 1 +# NOTE that we are building here for the host, and so tests for target- +# specific functionality will only work when host == target. This causes +# fails when building cross-compilers with different object formats (at +# least when the respective linkers do not accept the same command line +# options). Fortunately, for Darwin we can safely hard-code the relevant +# host options, since all usable linkers support them). + +LIBGCCJIT_CURRENT = 26 +LIBGCCJIT_REVISION = 0 +LIBGCCJIT_AGE = 26 +LIBGCCJIT_COMPAT = 0 LIBGCCJIT_BASENAME = libgccjit LIBGCCJIT_SONAME = \ @@ -63,18 +73,18 @@ LIBGCCJIT_SONAME = \ LIBGCCJIT_FILENAME = $(LIBGCCJIT_BASENAME).$(LIBGCCJIT_VERSION_NUM).dylib LIBGCCJIT_LINKER_NAME = $(LIBGCCJIT_BASENAME).dylib -# Conditionalize the use of the LD_VERSION_SCRIPT_OPTION and -# LD_SONAME_OPTION depending if configure found them, using $(if) -# We have to define a COMMA here, otherwise the commas in the "true" -# result are treated as separators by the $(if). +# Darwin does not have a version script option. Exported symbols are controlled +# by the following, and library versioning is done using libtool. +# We have to define a COMMA here, otherwise the commas are treated as +# separators. COMMA := , LIBGCCJIT_VERSION_SCRIPT_OPTION = \ - $(if $(LD_VERSION_SCRIPT_OPTION),\ - -Wl$(COMMA)$(LD_VERSION_SCRIPT_OPTION)$(COMMA)$(srcdir)/jit/libgccjit.map) + -Wl$(COMMA)-exported_symbols_list$(COMMA)$(srcdir)/jit/libgccjit.exports +# For Darwin host, we need a l64 or ld64-compatible linker, that uses +# -install_name to introduce this. LIBGCCJIT_SONAME_OPTION = \ - $(if $(LD_SONAME_OPTION), \ --Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME)) + -Wl$(COMMA)-install_name$(COMMA)$(LIBGCCJIT_SONAME) LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_FILENAME) LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME) @@ -143,15 +153,18 @@ ifneq (,$(findstring mingw,$(target))) # Create import library LIBGCCJIT_EXTRA_OPTS = -Wl,--out-implib,$(LIBGCCJIT_IMPORT_LIB) else - ifneq (,$(findstring darwin,$(host))) -# TODO : Construct a Darwin-style symbol export file. -LIBGCCJIT_EXTRA_OPTS = -Wl,-compatibility_version,$(LIBGCCJIT_VERSION_NUM) \ - -Wl,-current_version,$(LIBGCCJIT_VERSION_NUM).$(LIBGCCJIT_MINOR_NUM).$(LIBGCCJIT_AGE) \ - $(LIBGCCJIT_VERSION_SCRIPT_OPTION) \ - $(LIBGCCJIT_SONAME_OPTION) +LIBGCCJIT_VERS = $(LIBGCCJIT_CURRENT).$(LIBGCCJIT_REVISION).$(LIBGCCJIT_AGE) +LIBGCCJIT_EXTRA_OPTS = -Wl,-current_version,$(LIBGCCJIT_VERS) \ + -Wl,-compatibility_version,$(LIBGCCJIT_COMPAT) \ + $(LIBGCCJIT_VERSION_SCRIPT_OPTION) $(LIBGCCJIT_SONAME_OPTION) +# Use the default (shared) libgcc. +JIT_LDFLAGS = $(filter-out -static-libgcc, $(LDFLAGS)) +ifeq (,$(findstring darwin8,$(host))) +JIT_LDFLAGS += -Wl,-rpath,@loader_path +endif else - +JIT_LDFLAGS = $(LDFLAGS) LIBGCCJIT_EXTRA_OPTS = $(LIBGCCJIT_VERSION_SCRIPT_OPTION) \ $(LIBGCCJIT_SONAME_OPTION) endif @@ -170,7 +183,7 @@ $(LIBGCCJIT_FILENAME): $(jit_OBJS) \ $(LIBDEPS) $(srcdir)/jit/libgccjit.map \ $(EXTRA_GCC_OBJS_EXCLUSIVE) $(jit.prev) @$(call LINK_PROGRESS,$(INDEX.jit),start) - +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ -shared \ + +$(LLINKER) $(ALL_LINKERFLAGS) $(JIT_LDFLAGS) -o $@ -shared \ $(jit_OBJS) libbackend.a libcommon-target.a libcommon.a \ $(CPPLIB) $(LIBDECNUMBER) $(EXTRA_GCC_LIBS) $(LIBS) $(BACKENDLIBS) \ $(EXT
[gcc r14-9748] testsuite: Remove duplicate -lgcov [PR114034]
https://gcc.gnu.org/g:799a056cf804f433ce0050a5a6bf900f7a01ecb1 commit r14-9748-g799a056cf804f433ce0050a5a6bf900f7a01ecb1 Author: Iain Sandoe Date: Sun Mar 31 11:22:58 2024 +0100 testsuite: Remove duplicate -lgcov [PR114034] Duplicate library entries now cause linker warnings with newer linker versions on Darwin which leads to these tests regressing. The library is already added by the test flags so there is no need to put an extra one in the options. PR testsuite/114034 gcc/testsuite/ChangeLog: * g++.dg/gcov/gcov-dump-1.C: Remove extra -lgcov. * g++.dg/gcov/gcov-dump-2.C: Likewise. Signed-off-by: Iain Sandoe Diff: --- gcc/testsuite/g++.dg/gcov/gcov-dump-1.C | 2 +- gcc/testsuite/g++.dg/gcov/gcov-dump-2.C | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C b/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C index f0e81e9b042..774a7269ff2 100644 --- a/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C +++ b/gcc/testsuite/g++.dg/gcov/gcov-dump-1.C @@ -1,4 +1,4 @@ -/* { dg-options "-fprofile-generate -ftest-coverage -lgcov" } */ +/* { dg-options "-fprofile-generate -ftest-coverage " } */ /* { dg-do run { target native } } */ int value; diff --git a/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C b/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C index 6234a81a586..e748989d2c0 100644 --- a/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C +++ b/gcc/testsuite/g++.dg/gcov/gcov-dump-2.C @@ -1,4 +1,4 @@ -/* { dg-options "-fprofile-generate -ftest-coverage -lgcov" } */ +/* { dg-options "-fprofile-generate -ftest-coverage " } */ /* { dg-do run { target native } } */ int value;
[gcc r14-9747] testsuite, Darwin: Allow for an undefined symbol [PR114036].
https://gcc.gnu.org/g:ad8e34eaa870608e2b07b4e7147e6ef2944bb8b5 commit r14-9747-gad8e34eaa870608e2b07b4e7147e6ef2944bb8b5 Author: Iain Sandoe Date: Sun Mar 31 11:27:53 2024 +0100 testsuite, Darwin: Allow for an undefined symbol [PR114036]. Darwin's linker defaults to requiring all symbols to be defined at static link time (unless specifically noted or dynamic lookuo is enabled). For this test, we just need to note that the symbol is expected to be undefined. PR testsuite/114036 gcc/testsuite/ChangeLog: * gcc.misc-tests/gcov-14.c: Allow for 'Foo' to be undefined on Darwin link lines. Signed-off-by: Iain Sandoe Diff: --- gcc/testsuite/gcc.misc-tests/gcov-14.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.misc-tests/gcov-14.c b/gcc/testsuite/gcc.misc-tests/gcov-14.c index 2bebf7e4a93..61a9191c068 100644 --- a/gcc/testsuite/gcc.misc-tests/gcov-14.c +++ b/gcc/testsuite/gcc.misc-tests/gcov-14.c @@ -3,7 +3,7 @@ /* { dg-do run { target native } } */ /* { dg-options "-O2 -fprofile-arcs -ftest-coverage -fgnu89-inline" } */ /* The following line arranges that Darwin has behavior like elf weak import. */ -/* { dg-additional-options "-flat_namespace -undefined suppress" { target *-*-darwin* } } */ +/* { dg-additional-options "-Wl,-U,_Foo" { target *-*-darwin* } } */ /* { dg-require-weak "" } */ /* { dg-skip-if "undefined weak not supported" { { hppa*-*-hpux* } && { ! lp64 } } } */ /* { dg-skip-if "undefined weak not supported" { powerpc-ibm-aix* } } */
[gcc r14-9746] Darwin: Correct a version check.
https://gcc.gnu.org/g:451bb0b9262d2f54173937569a29d7f1ad234e30 commit r14-9746-g451bb0b9262d2f54173937569a29d7f1ad234e30 Author: Iain Sandoe Date: Mon Apr 1 20:47:25 2024 +0100 Darwin: Correct a version check. When the version for dsymutil comes from a clang build, it is of the form NNmm.pp.qq where NN and mm are the major and minor LLVM version components. We need to check for a major version greater than or equal to 7 - so use 700 in the check. gcc/ChangeLog: * config/darwin.cc (darwin_override_options): Update the clang major version value in the dsymutil check. Signed-off-by: Iain Sandoe Diff: --- gcc/config/darwin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index c37a1a4756f..63b8c509405 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3420,7 +3420,7 @@ darwin_override_options (void) /* External toolchains based on LLVM or clang 7+ have support for dwarf-4. */ if ((dsymutil_version.kind == LLVM && dsymutil_version.major >= 7) - || (dsymutil_version.kind == CLANG && dsymutil_version.major >= 7)) + || (dsymutil_version.kind == CLANG && dsymutil_version.major >= 700)) dwarf_version = 4; else if (dsymutil_version.kind == DWARFUTILS && dsymutil_version.major >= 121)
[gcc r14-9745] Darwin: Do not emit .macinfo when dsymutil cannot consume it.
https://gcc.gnu.org/g:3c499f8f6f7d19b21d7047efabbe6396ee1c2cac commit r14-9745-g3c499f8f6f7d19b21d7047efabbe6396ee1c2cac Author: Iain Sandoe Date: Sun Mar 31 23:25:31 2024 +0100 Darwin: Do not emit .macinfo when dsymutil cannot consume it. Some verions of dsymutil do not ignore .macinfo sections, but instead ignore the entire debug in the file. To avoid this total loss of debug, when we detect that the debug level is g3 and the dsymutil version cannot support it, we reduce the level to g2 and issue a note. This behaviour can be overidden by -gstrict-dwarf (although the objects will contain macinfo; dsymutil will not produce a .dSYM with it). gcc/ChangeLog: * config/darwin.cc (darwin_override_options): Reduce the debug level to 2 if dsymutil cannot handle .macinfo sections. Signed-off-by: Iain Sandoe Diff: --- gcc/config/darwin.cc | 23 ++- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index 9e5d64e6f32..c37a1a4756f 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3415,11 +3415,6 @@ darwin_override_options (void) global_options.x_flag_objc_abi); } - /* Limit DWARF to the chosen version, the linker and debug linker might not - be able to consume newer structures. */ - if (!OPTION_SET_P (dwarf_strict)) -dwarf_strict = 1; - if (!OPTION_SET_P (dwarf_version)) { /* External toolchains based on LLVM or clang 7+ have support for @@ -3442,6 +3437,24 @@ darwin_override_options (void) OPTION_SET_P (dwarf_split_debug_info) = 0; } + /* Cases where dsymutil will exclude files with .macinfo sections; we are + better off forcing the debug level to 2 than completely excluding the + files. If strict dwarf is set, then emit the macinfo anyway. */ + if (debug_info_level == DINFO_LEVEL_VERBOSE + && (!OPTION_SET_P (dwarf_strict) || dwarf_strict == 0) + && ((dsymutil_version.kind == CLANG && dsymutil_version.major >= 1500) + || (dsymutil_version.kind == LLVM && dsymutil_version.major >= 15))) +{ + inform (input_location, + "%<-g3%> is not supported by the debug linker in use (set to 2)"); + debug_info_level = DINFO_LEVEL_NORMAL; +} + + /* Limit DWARF to the chosen version, the linker and debug linker might not + be able to consume newer structures. */ + if (!OPTION_SET_P (dwarf_strict)) +dwarf_strict = 1; + /* Do not allow unwind tables to be generated by default for m32. fnon-call-exceptions will override this, regardless of what we do. */ if (generating_for_darwin_version < 10
[gcc r14-9744] testsuite, Darwin: Update bad-mapper-1 after libiberty changes.
https://gcc.gnu.org/g:c85c2e26b8de2781ac22e7687e8c9652a56b0a07 commit r14-9744-gc85c2e26b8de2781ac22e7687e8c9652a56b0a07 Author: Iain Sandoe Date: Fri Mar 8 09:21:39 2024 + testsuite, Darwin: Update bad-mapper-1 after libiberty changes. A recent change to libiberty has improved the process spawning on older Darwin platforms. This patch updates the expected test output after the changes. gcc/testsuite/ChangeLog: * g++.dg/modules/bad-mapper-1.C: Update expected test output for earlier Darwin. Signed-off-by: Iain Sandoe Diff: --- gcc/testsuite/g++.dg/modules/bad-mapper-1.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/g++.dg/modules/bad-mapper-1.C b/gcc/testsuite/g++.dg/modules/bad-mapper-1.C index b0b0b86c9cd..3dfb5a6073e 100644 --- a/gcc/testsuite/g++.dg/modules/bad-mapper-1.C +++ b/gcc/testsuite/g++.dg/modules/bad-mapper-1.C @@ -1,9 +1,9 @@ // { dg-additional-options "-fmodules-ts -fmodule-mapper=|this-will-not-work" } import unique1.bob; -// { dg-error "-:failed (exec|CreateProcess|posix_spawn).*mapper.* .*this-will-not-work" "" { target { ! { *-*-darwin[89]* *-*-darwin10* hppa*-*-hpux* } } } 0 } +// { dg-error "-:failed (exec|CreateProcess|posix_spawn).*mapper.* .*this-will-not-work" "" { target { ! { hppa*-*-hpux* } } } 0 } // { dg-prune-output "fatal error:" } // { dg-prune-output "failed to read" } // { dg-prune-output "compilation terminated" } -// { dg-error "-:failed mapper handshake communication" "" { target { *-*-darwin[89]* *-*-darwin10* hppa*-*-hpux* } } 0 } +// { dg-error "-:failed mapper handshake communication" "" { target { hppa*-*-hpux* } } 0 } // { dg-prune-output "trying to exec .this-will-not-work." } // { dg-prune-output "unknown Compiled Module Interface" }
[gcc r13-8555] handle unwind tables that are embedded within unwinding code [PR111731]
https://gcc.gnu.org/g:11f37868bb5812c4f0ac023909f5421595f68a43 commit r13-8555-g11f37868bb5812c4f0ac023909f5421595f68a43 Author: Thomas Neumann Date: Mon Mar 11 14:35:20 2024 +0100 handle unwind tables that are embedded within unwinding code [PR111731] Original bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111731 The unwinding mechanism registers both the code range and the unwind table itself within a b-tree lookup structure. That data structure assumes that is consists of non-overlappping intervals. This becomes a problem if the unwinding table is embedded within the code itself, as now the intervals do overlap. To fix this problem we now keep the unwind tables in a separate b-tree, which prevents the overlap. libgcc/ChangeLog: PR libgcc/111731 * unwind-dw2-fde.c: Split unwind ranges if they contain the unwind table. Diff: --- libgcc/unwind-dw2-fde.c | 37 + 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/libgcc/unwind-dw2-fde.c b/libgcc/unwind-dw2-fde.c index 51129906fac..6a54450253f 100644 --- a/libgcc/unwind-dw2-fde.c +++ b/libgcc/unwind-dw2-fde.c @@ -48,6 +48,7 @@ typedef __UINTPTR_TYPE__ uintptr_type; #include "unwind-dw2-btree.h" static struct btree registered_frames; +static struct btree registered_objects; static bool in_shutdown; static void @@ -58,6 +59,7 @@ release_registered_frames (void) /* Release the b-tree and all frames. Frame releases that happen later are * silently ignored */ btree_destroy (®istered_frames); + btree_destroy (®istered_objects); in_shutdown = true; } @@ -103,6 +105,21 @@ static __gthread_mutex_t object_mutex; #endif #endif +#ifdef ATOMIC_FDE_FAST_PATH +// Register the pc range for a given object in the lookup structure. +static void +register_pc_range_for_object (uintptr_type begin, struct object *ob) +{ + // Register the object itself to know the base pointer on deregistration. + btree_insert (®istered_objects, begin, 1, ob); + + // Register the frame in the b-tree + uintptr_type range[2]; + get_pc_range (ob, range); + btree_insert (®istered_frames, range[0], range[1] - range[0], ob); +} +#endif + /* Called from crtbegin.o to register the unwind info for an object. */ void @@ -124,13 +141,7 @@ __register_frame_info_bases (const void *begin, struct object *ob, #endif #ifdef ATOMIC_FDE_FAST_PATH - // Register the object itself to know the base pointer on deregistration. - btree_insert (®istered_frames, (uintptr_type) begin, 1, ob); - - // Register the frame in the b-tree - uintptr_type range[2]; - get_pc_range (ob, range); - btree_insert (®istered_frames, range[0], range[1] - range[0], ob); + register_pc_range_for_object ((uintptr_type) begin, ob); #else init_object_mutex_once (); __gthread_mutex_lock (&object_mutex); @@ -178,13 +189,7 @@ __register_frame_info_table_bases (void *begin, struct object *ob, ob->s.b.encoding = DW_EH_PE_omit; #ifdef ATOMIC_FDE_FAST_PATH - // Register the object itself to know the base pointer on deregistration. - btree_insert (®istered_frames, (uintptr_type) begin, 1, ob); - - // Register the frame in the b-tree - uintptr_type range[2]; - get_pc_range (ob, range); - btree_insert (®istered_frames, range[0], range[1] - range[0], ob); + register_pc_range_for_object ((uintptr_type) begin, ob); #else init_object_mutex_once (); __gthread_mutex_lock (&object_mutex); @@ -232,7 +237,7 @@ __deregister_frame_info_bases (const void *begin) #ifdef ATOMIC_FDE_FAST_PATH // Find the originally registered object to get the base pointer. - ob = btree_remove (®istered_frames, (uintptr_type) begin); + ob = btree_remove (®istered_objects, (uintptr_type) begin); // Remove the corresponding PC range. if (ob) @@ -240,7 +245,7 @@ __deregister_frame_info_bases (const void *begin) uintptr_type range[2]; get_pc_range (ob, range); if (range[0] != range[1]) -btree_remove (®istered_frames, range[0]); + btree_remove (®istered_frames, range[0]); } // Deallocate the sort array if any.
[gcc r14-9743] LoongArch: Fix missing plugin header
https://gcc.gnu.org/g:078f4a958cd2267d5b1dccda838785836ac19b79 commit r14-9743-g078f4a958cd2267d5b1dccda838785836ac19b79 Author: Yang Yujie Date: Tue Apr 2 09:20:32 2024 +0800 LoongArch: Fix missing plugin header gcc/ChangeLog: * config/loongarch/t-loongarch: Add loongarch-def-arrays.h to OPTION_H_EXTRA. Diff: --- gcc/config/loongarch/t-loongarch | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/loongarch/t-loongarch b/gcc/config/loongarch/t-loongarch index 3dd7c4b031e..acf5da95310 100644 --- a/gcc/config/loongarch/t-loongarch +++ b/gcc/config/loongarch/t-loongarch @@ -18,8 +18,9 @@ GTM_H += loongarch-multilib.h -OPTIONS_H_EXTRA += $(srcdir)/config/loongarch/loongarch-def.h \ - $(srcdir)/config/loongarch/loongarch-tune.h \ +OPTIONS_H_EXTRA += $(srcdir)/config/loongarch/loongarch-def.h \ + $(srcdir)/config/loongarch/loongarch-def-array.h \ + $(srcdir)/config/loongarch/loongarch-tune.h \ $(srcdir)/config/loongarch/loongarch-cpucfg-map.h # Canonical target triplet from config.gcc