- Mar 01, 2025
-
-
Jan Dubiec authored
This patch fixes annoying -Wformat warnings when gcc is built on Windows/MinGW64. Instead of %ld it uses HOST_WIDE_INT_PRINT_DEC macro, just like many other targets do. PR target/109189 gcc/ChangeLog: * config/h8300/h8300.cc (h8300_print_operand): Replace %ld format strings with HOST_WIDE_INT_PRINT_DEC macro in order to silence -Wformat warnings when building on Windows/MinGW64.
-
Xi Ruoyao authored
Like RISC-V, on LoongArch we don't really support %cN for SYMBOL_REFs even with -fno-pic. gcc/testsuite/ChangeLog: * c-c++-common/toplevel-asm-1.c: Use %cc3 %cc4 instead of %c3 %c4 on LoongArch.
-
- Feb 28, 2025
-
-
Jonathan Wakely authored
The specification for std::ranges::iter_move apparently requires us to handle types which do not satisfy std::indirectly_readable, for example with overloaded operator* which behaves differently for different value categories. libstdc++-v3/ChangeLog: PR libstdc++/106612 * include/bits/iterator_concepts.h (_IterMove::__iter_ref_t): New alias template. (_IterMove::__result): Use __iter_ref_t instead of std::iter_reference_t. (_IterMove::__type): Remove incorrect __dereferenceable constraint. (_IterMove::operator()): Likewise. Add correct constraints. Use __iter_ref_t instead of std::iter_reference_t. Forward parameter as correct value category. (iter_swap): Add comments. * testsuite/24_iterators/customization_points/iter_move.cc: Test that iter_move is found by ADL and that rvalue arguments are handled correctly. Reviewed-by:
Patrick Palka <ppalka@redhat.com>
-
Jonathan Wakely authored
The ranges::move and ranges::move_backward algorithms are supposed to use ranges::iter_move(iter) instead of std::move(*iter), which matters for an iterator type with an iter_move overload findable by ADL. Currently those algorithms use std::__assign_one which uses std::move, so define a new ranges::__detail::__assign_one helper function that uses ranges::iter_move. libstdc++-v3/ChangeLog: PR libstdc++/105609 * include/bits/ranges_algobase.h (__detail::__assign_one): New helper function. (__copy_or_move, __copy_or_move_backward): Use new function instead of std::__assign_one. * testsuite/25_algorithms/move/constrained.cc: Check that ADL iter_move is used in preference to std::move. * testsuite/25_algorithms/move_backward/constrained.cc: Likewise.
-
Jonathan Wakely authored
The standard requires that we reject attempts to create a ranges::to adaptor for cv-qualified types and non-class types. Currently we only diagnose it once the adaptor is used in a pipeline. This adds static assertions to diagnose it immediately. libstdc++-v3/ChangeLog: PR libstdc++/112803 * include/std/ranges (ranges::to): Add static assertions to enforce Mandates conditions. * testsuite/std/ranges/conv/112803.cc: New test.
-
Iain Buclaw authored
Floating-point emulation in the D front-end is done via a type named `struct longdouble`, which in GDC is a small interface around the real_value type. Because the D code cannot include gcc/real.h directly, a big enough buffer is used for the data instead. On x86_64, this buffer is actually bigger than real_value itself, so when a new longdouble object is created with longdouble r; real_from_string3 (&r.rv (), buffer, mode); return r; there is uninitialized padding at the end of `r`. This was never a problem when D was implemented in C++ (until GCC 12) as comparing two longdouble objects with `==' would be forwarded to the relevant operator== overload that extracted the underlying real_value. However when the front-end was translated to D, such conditions were instead rewritten into identity comparisons return exp.toReal() is CTFloat.zero The `is` operator gets lowered as a call to `memcmp() == 0', which is where the read of uninitialized memory occurs, as seen by valgrind. ==26778== Conditional jump or move depends on uninitialised value(s) ==26778== at 0x911F41: dmd.dstruct._isZeroInit(dmd.expression.Expression) (dstruct.d:635) ==26778== by 0x9123BE: StructDeclaration::finalizeSize() (dstruct.d:373) ==26778== by 0x86747C: dmd.aggregate.AggregateDeclaration.determineSize(ref const(dmd.location.Loc)) (aggregate.d:226) [...] To avoid accidentally reading uninitialized data, explicitly initialize all `longdouble` variables with an empty constructor on C++ side of the implementation before initializing underlying real_value type it holds. PR d/116961 gcc/d/ChangeLog: * d-codegen.cc (build_float_cst): Change new_value type from real_t to real_value. * d-ctfloat.cc (CTFloat::fabs): Default initialize the return value. (CTFloat::ldexp): Likewise. (CTFloat::parse): Likewise. * d-longdouble.cc (longdouble::add): Likewise. (longdouble::sub): Likewise. (longdouble::mul): Likewise. (longdouble::div): Likewise. (longdouble::mod): Likewise. (longdouble::neg): Likewise. * d-port.cc (Port::isFloat32LiteralOutOfRange): Likewise. (Port::isFloat64LiteralOutOfRange): Likewise. gcc/testsuite/ChangeLog: * gdc.dg/pr116961.d: New test.
-
Marek Polacek authored
Since r10-7718 the attached tests produce an ICE in verify_address: error: constant not recomputed when 'ADDR_EXPR' changed but before that we wrongly rejected the tests with "is not a constant expression". This patch fixes both problems. Since r10-7718 replace_decl_r can replace {._M_dataplus=&<retval>._M_local_buf, ._M_local_buf=0} with {._M_dataplus=&HelloWorld._M_local_buf, ._M_local_buf=0} The initial &<retval>._M_local_buf was not constant, but since HelloWorld is a static VAR_DECL, the resulting &HelloWorld._M_local_buf should have been marked as TREE_CONSTANT. And since we're taking its address, the whole thing should be TREE_ADDRESSABLE. PR c++/114913 PR c++/110822 gcc/cp/ChangeLog: * constexpr.cc (replace_decl_r): If we've replaced something inside of an ADDR_EXPR, call cxx_mark_addressable and recompute_tree_invariant_for_addr_expr on the resulting ADDR_EXPR. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-nsdmi4.C: New test. * g++.dg/cpp0x/constexpr-nsdmi5.C: New test. Reviewed-by:
Jason Merrill <jason@redhat.com>
-
Marek Polacek authored
Yet another problem that started with r15-6052, compile time evaluation of prvalues. cp_fold_r/TARGET_EXPR sees: TARGET_EXPR <D.2701, <<< Unknown tree: expr_stmt D.2701.__p = TARGET_EXPR <D.2684, <<< Unknown tree: aggr_init_expr 3 f1 D.2684 >>>> >>>> so when we call maybe_constant_init, the object we're initializing is D.2701, and the init is the expr_stmt. We unwrap the EXPR_STMT/INIT_EXPR/TARGET_EXPR in maybe_constant_init_1 and so end up evaluating the f1 call. But f1 returns c2 whereas the type of D.2701 is ._anon_0 -- the closure. So then we crash in replace_decl on: gcc_checking_assert (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (decl), TREE_TYPE (replacement))); due to the mismatched types. cxx_eval_outermost_constant_expr is already ready for the types to be different, in which case the result isn't constant. But replace_decl is called before that check. I'm leaving the assert in replace_decl on purpose, maybe we'll find another use for it. PR c++/118986 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_call_expression): Check that the types match before calling replace_decl, if not, set *non_constant_p. (maybe_constant_init_1): Don't strip INIT_EXPR if it would change the type of the expression. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-prvalue1.C: New test. Reviewed-by:
Jason Merrill <jason@redhat.com>
-
Martin Jambor authored
Among other things, IPA-SRA checks whether splitting out a bit of an aggregate or something passed by reference would lead into a clash with an already known IPA-CP constant a way which would cause problems later on. Unfortunately the test is done only in adjust_parameter_descriptions and is missing when accesses are propagated from callees to callers, which leads to miscompilation reported as PR 118243 (where the callee is a function created by ipa-split). The matter is then further complicated by the fact that we consider complex numbers as scalars even though they can be modified piecemeal (IPA-CP can detect and propagate the pieces separately too) which then confuses the parameter manipulation machinery furter. This patch simply adds the missing check to avoid the IPA-SRA transform in these cases too, which should be suitable for backporting to all affected release branches. It is a bit of a shame as in the PR testcase we do propagate both components of the complex number in question and the transformation phase could recover. I have some prototype patches in this direction but that is something for (a) stage 1. gcc/ChangeLog: 2025-02-10 Martin Jambor <mjambor@suse.cz> PR ipa/118243 * ipa-sra.cc (pull_accesses_from_callee): New parameters caller_ipcp_ts and param_idx. Check that scalar pulled accesses would not clash with a known IPA-CP aggregate constant. (param_splitting_across_edge): Pass IPA-CP transformation summary and caller parameter index to pull_accesses_from_callee. gcc/testsuite/ChangeLog: 2025-02-10 Martin Jambor <mjambor@suse.cz> PR ipa/118243 * g++.dg/ipa/pr118243.C: New test.
-
Patrick Palka authored
When a generic lambda calls an overload set containing an iobj member function we speculatively capture 'this'. We need to do the same for an xobj member function. PR c++/119038 gcc/cp/ChangeLog: * lambda.cc (maybe_generic_this_capture): Consider xobj member functions as well, not just iobj. Update function comment. gcc/testsuite/ChangeLog: * g++.dg/cpp23/explicit-obj-lambda15.C: New test. Reviewed-by:
Jason Merrill <jason@redhat.com>
-
Patrick Palka authored
It turns out the reason the behavior of this testcase changed after CWG 2369 is because validity of the substituted return type is now checked later, after constraints. So a more reliable workaround for this issue is to add a constraint to check the validity of the return type earlier, matching the pre-CWG 2369 semantics. PR libstdc++/104606 libstdc++-v3/ChangeLog: * include/std/optional (operator<=>): Revert r14-9771 change. Add constraint checking the validity of the return type compare_three_way_result_t before the three_way_comparable_with constraint. Reviewed-by:
Jonathan Wakely <jwakely@redhat.com>
-
Patrick Palka authored
Here for using RCI = reverse_iterator<basic_const_iterator<vector<int>::iterator>> static_assert(std::totally_ordered<RCI>); we effectively need to check the requirement requires (RCI x) { x RELOP x; } for each RELOP in {<, >, <=, >=} which we expect to be straightforwardly satisfied by reverse_iterator's namespace-scope relops. But due to ADL we find ourselves also considering the basic_const_iterator relop friends, which before CWG 2369 would be quickly discarded since RCI clearly isn't convertible to basic_const_iterator. After CWG 2369 though we must first check these relops' constraints (with _It = vector<int>::iterator and _It2 = RCI), which entails checking totally_ordered<RCI> recursively. This patch fixes this by turning the problematic non-dependent function parameters of type basic_const_iterator<_It> into dependent ones of type basic_const_iterator<_It3> where _It3 is constrained to match _It. Thus the basic_const_iterator relop friends now get quickly discarded during deduction and before the constraint check if the second operand isn't a specialization of basic_const_iterator (or derived from one) like before CWG 2369. PR libstdc++/112490 libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (basic_const_iterator::operator<): Replace non-dependent basic_const_iterator function parameter with a dependent one of type basic_const_iterator<_It3> where _It3 matches _It. (basic_const_iterator::operator>): Likewise. (basic_const_iterator::operator<=): Likewise. (basic_const_iterator::operator>=): Likewise. * testsuite/24_iterators/const_iterator/112490.cc: New test. Reviewed-by:
Jonathan Wakely <jwakely@redhat.com>
-
Jakub Jelinek authored
I've added the asserts that probe == target because {REAL,IMAG}PART_EXPR always implies a scalar type and so applying ARRAY_REF/COMPONENT_REF etc. on it further doesn't make sense and the later code relies on it to be the last one in refs array. But as the following testcase shows, we can fail those assertions in case there is a reference or pointer to the __real__ or __imag__ part, in that case we just evaluate the constant expression and so probe won't be the same as target. That case doesn't push anything into the refs array though. The following patch changes those asserts to verify that refs is still empty, which fixes it. 2025-02-28 Jakub Jelinek <jakub@redhat.com> PR c++/119045 * constexpr.cc (cxx_eval_store_expression) <case REALPART_EXPR>: Assert that refs->is_empty () rather than probe == target. (cxx_eval_store_expression) <case IMAGPART_EXPR>: Likewise. * g++.dg/cpp1y/constexpr-complex2.C: New test.
-
Jakub Jelinek authored
Now that the #embed paper has been voted in, the following patch removes the pedwarn for C++26 on it (and adjusts pedwarn warning for older C++ versions) and predefines __cpp_pp_embed FTM. Also, the patch changes cpp_error to cpp_pedwarning with for C++ -Wc++26-extensions guarding, and for C add -Wc11-c23-compat warning about #embed. I believe we otherwise implement everything in the paper already, except I'm really confused by the [Example: #embed <data.dat> limit(__has_include("a.h")) #if __has_embed(<data.dat> limit(__has_include("a.h"))) // ill-formed: __has_include [cpp.cond] cannot appear here #endif — end example] part. My reading of both C23 and C++ with the P1967R14 paper in is that the first case (#embed with __has_include or __has_embed in its clauses) is what is clearly invalid and so the ill-formed note should be for #embed. And the __has_include/__has_embed in __has_embed is actually questionable. Both C and C++ have something like "The identifiers __has_include, __has_embed, and __has_c_attribute shall not appear in any context not mentioned in this subclause." or "The identifiers __has_include and __has_cpp_attribute shall not appear in any context not mentioned in this subclause." (into which P1967R14 adds __has_embed) in the conditional inclusion subclause. #embed is defined in a different one, so using those in there is invalid (unless "using the rules specified for conditional inclusion" wording e.g. in limit clause overrides that). The reason why I think it is fuzzy for __has_embed is that __has_embed is actually defined in the Conditional inclusion subclause (so that would mean one can use __has_include, __has_embed and __has_*attribute in there) but its clauses are described in a different one. GCC currently accepts #embed __FILE__ limit (__has_include (<stdarg.h>)) #if __has_embed (__FILE__ limit (__has_include (<stdarg.h>))) #endif #embed __FILE__ limit (__has_embed (__FILE__)) #if __has_embed (__FILE__ limit (__has_embed (__FILE__))) #endif Note, it isn't just about limit clause, but also about prefix/suffix/if_empty, except that in those cases the "using the rules specified for conditional inclusion" doesn't apply. In any case, I'd hope that can be dealt with incrementally (and should be handled the same for both C and C++). 2025-02-28 Jakub Jelinek <jakub@redhat.com> libcpp/ * include/cpplib.h (enum cpp_warning_reason): Add CPP_W_CXX26_EXTENSIONS enumerator. * init.cc (lang_defaults): Set embed for GNUCXX26 and CXX26. * directives.cc (do_embed): Adjust pedwarn wording for embed in C++, use cpp_pedwarning instead of cpp_error and add CPP_W_C11_C23_COMPAT warning of cpp_pedwarning hasn't diagnosed anything. gcc/c-family/ * c.opt (Wc++26-extensions): Add CppReason(CPP_W_CXX26_EXTENSIONS). * c-cppbuiltin.cc (c_cpp_builtins): Predefine __cpp_pp_embed=202502 for C++26. gcc/testsuite/ * g++.dg/cpp/embed-1.C: Adjust for pedwarn wording change and don't expect any error for C++26. * g++.dg/cpp/embed-2.C: Adjust for pedwarn wording change and don't expect any warning for C++26. * g++.dg/cpp26/feat-cxx26.C: Test __cpp_pp_embed value. * gcc.dg/cpp/embed-17.c: New test.
-
Richard Biener authored
The following fixes a thinko in the handling of interposed weak definitions which confused the interposition check in get_availability by setting DECL_EXTERNAL too early. PR lto/91299 gcc/lto/ * lto-symtab.cc (lto_symtab_merge_symbols): Set DECL_EXTERNAL only after calling get_availability. gcc/testsuite/ * gcc.dg/lto/pr91299_0.c: New testcase. * gcc.dg/lto/pr91299_1.c: Likewise.
-
Richard Biener authored
We currently record a kill for *x_4(D) = always_throws (); because we consider the store always executing since the appropriate check for whether the stmt could throw is guarded by !cfun->can_throw_non_call_exceptions. PR ipa/111245 * ipa-modref.cc (modref_access_analysis::analyze_store): Do not guard the check of whether the stmt could throw by cfun->can_throw_non_call_exceptions. * g++.dg/torture/pr111245.C: New testcase.
-
Jakub Jelinek authored
As documented in the manual, FIX/UNSIGNED_FIX from floating point mode to integral mode has unspecified rounding and FIX from floating point mode to the same floating point mode is expressing rounding toward zero. So, some targets (arc, arm, csky, m68k, mmix, nds32, pdp11, sparc and visium) use (fix:SI (fix:SF (match_operand:SF 1 "..._operand"))) etc. to express the rounding toward zero during conversion to integer. For some reason other targets don't use that. Anyway, the 2 FIXes (or inner FIX with outer UNSIGNED_FIX) cause problems since the r15-2890 which removed some strict checks in ifcvt.cc on what SET_SRC can be actually conditionalized (I must say I'm still worried about the change, don't know why one can't get e.g. inline asm or something with UNSPEC or some complex backend specific RTLs that force_operand can't handle), force_operand just ICEs on it, it can only handle (through expand_fix) conversions from floating point to integral. The following patch fixes this by detecting this case and just pretend the inner FIX isn't there, i.e. call expand_fix with the inner FIX's operand instead, which works and on targets like arm it will just create the nested FIXes again. 2025-02-28 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/117712 * expr.cc (force_operand): Handle {,UNSIGNED_}FIX with FIX operand using expand_fix on the inner FIX operand. * gcc.dg/pr117712.c: New test.
-
Richard Biener authored
The following disables redundant store elimination to hard register variables which isn't valid. PR tree-optimization/87984 * tree-ssa-dom.cc (dom_opt_dom_walker::optimize_stmt): Do not perform redundant store elimination to hard register variables. * tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_stmt): Likewise. * gcc.target/i386/pr87984.c: New testcase.
-
Richard Biener authored
When the C++ frontend clones a CTOR we do not copy ASM_EXPR constraints fully as walk_tree does not recurse to TREE_PURPOSE of TREE_LIST nodes. At this point doing that seems too dangerous so the following instead avoids gimplification of ASM_EXPRs to clobber the shared constraints and unshares it there, like it also unshares TREE_VALUE when it re-writes a "+" output constraint to separate "=" output and matching input constraint. PR middle-end/66279 * gimplify.cc (gimplify_asm_expr): Copy TREE_PURPOSE before rewriting it for "+" processing. * g++.dg/pr66279.C: New testcase.
-
Jakub Jelinek authored
I found another test which uses -m32 in gcc.target/i386/ . Similarly to the previously posted test, the test ought to be tested during i686-linux testing or x86_64-linux test with --target_board=unix\{-m32,-m64\} There is nothing ia32 specific on the test, so I've just dropped the -m32. 2025-02-28 Jakub Jelinek <jakub@redhat.com> * gcc.target/i386/strub-pr118006.c: Remove -m32 from dg-options.
-
Jakub Jelinek authored
The testcase uses -m32 in dg-options, something we try hard not to do, if something should be tested only for -m32, it is { target ia32 } test, if it can be tested for -m64/-mx32 too, just some extra options are needed for ia32, it should have dg-additional-options with ia32 target. Also, the test wasn't reduced, so I've reduced it using cvise and manual tweaks and verified the test still FAILs before r15-7700 and succeeds with current trunk. 2025-02-28 Jakub Jelinek <jakub@redhat.com> PR target/118940 * gcc.target/i386/pr118940.c: Drop -w, -g and -m32 from dg-options, move -march=i386 -mregparm=3 to dg-additional-options for ia32 and -fno-pie to dg-additional-options for pie. Reduce the test.
-
Andre Vehreschild authored
PR fortran/118730 gcc/fortran/ChangeLog: * resolve.cc: Mark unused derived type variable with finalizers referenced to execute finalizer when leaving scope. gcc/testsuite/ChangeLog: * gfortran.dg/class_array_15.f03: Remove unused variable. * gfortran.dg/coarray_poly_7.f90: Adapt scan-tree-dump expr. * gfortran.dg/coarray_poly_8.f90: Same. * gfortran.dg/finalize_60.f90: New test.
-
Giuseppe D'Angelo authored
ChangeLog: * MAINTAINERS: Added myself as write after approval and DCO.
-
H.J. Lu authored
Move the TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P target hook from i386.h to i386.cc. * config/i386/i386.h (TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P): Moved to ... * config/i386/i386.cc (TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P): Here. Signed-off-by:
H.J. Lu <hjl.tools@gmail.com>
-
GCC Administrator authored
-
- Feb 27, 2025
-
-
Pan Li authored
This patch would like to fix one bug when expanding const vector for the interleave case. For example, we have: base1 = 151 step = 121 For vec_series, we will generate vector in format of v[i] = base + i * step. Then the vec_series will have below result for HImode, and we can find that the result overflow to the highest 8 bits of HImode. v1.b = {151, 255, 7, 0, 119, 0, 231, 0, 87, 1, 199, 1, 55, 2, 167, 2} Aka we expect v1.b should be: v1.b = {151, 0, 7, 0, 119, 0, 231, 0, 87, 0, 199, 0, 55, 0, 167, 0} After that it will perform the IOR with v2 for the base2(aka another series). v2.b = {0, 17, 0, 33, 0, 49, 0, 65, 0, 81, 0, 97, 0, 113, 0, 129} Unfortunately, the base1 + i * step1 in HImode may overflow to the high 8 bits, and the high 8 bits will pollute the v2 and result in incorrect value in const_vector. This patch would like to perform the overflow to smode check before the optimized interleave code generation. If overflow or VLA, it will fall back to the default merge approach. The below test suites are passed for this patch. * The rv64gcv fully regression test. PR target/118931 gcc/ChangeLog: * config/riscv/riscv-v.cc (expand_const_vector): Add overflow to smode check and clean up highest bits if overflow. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/pr118931-run-1.c: New test. Signed-off-by:
Pan Li <pan2.li@intel.com>
-
Iain Buclaw authored
Use `dg-runtest' test driver rather than `dg-test' to run the libphobos unittest testsuite, same as all other libphobos tests. This prevents the tests from being ran multiple times when parallelized. Set `libphobos_test_name' as well so that all tests get a unique name. libphobos/ChangeLog: * testsuite/libphobos.unittest/unittest.exp: Use `dg-runtest' rather than `dg-test'. Set `libphobos_test_name'.
-
Jonathan Wakely authored
My r15-998-g2a83084ce55363 change replaced the use of nothrow operator new with a call to __get_temporary_buffer, so update the comment to match. libstdc++-v3/ChangeLog: * include/std/stacktrace (_Impl::_M_allocate): Fix outdated comment.
-
Jakub Jelinek authored
The following testcase is miscompiled since r15-7597. The left comparison is unsigned (x & 0x8000U) != 0) while the right one is signed (x >> 16) >= 0 and is actually a signbit test, so rsignbit is 64. After debugging this and reading the r15-7597 change, I believe there is just a pasto, the if (lsignbit) and if (rsignbit) blocks are pretty much identical with just the first l on all variables starting with l replaced with r (the only difference is that if (lsignbit) has a comment explaining the sign <<= 1; stuff, while it isn't repeated in the second one. Except the second one was using ll_unsignedp instead of rl_unsignedp in one spot. I think it should use the latter, the signedness of the left comparison doesn't affect the other one, they are basically independent with the exception that we check that after transformations they are both EQ or both NE and later on we try to merge them together. 2025-02-27 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/119030 * gimple-fold.cc (fold_truth_andor_for_ifcombine): Fix a pasto, ll_unsignedp -> rl_unsignedp. * gcc.c-torture/execute/pr119030.c: New test.
-
Jakub Jelinek authored
The following testcase ICEs, because we first construct file_cache object inside of *global_dc, then process options and then call file_cache::tune. The earlier construction allocates the m_file_slots array (using new) based on the static data member file_cache::num_file_slots, but then tune changes it, without actually reallocating all m_file_slots arrays in already constructed file_cache objects. I think it is just weird to have the count be a static data member and the pointer be non-static data member, that is just asking for issues like this. So, this patch changes num_file_slots into m_num_file_slots and turns tune into a non-static member function and changes toplev.cc to call it on the global_gc->get_file_cache () object. And let's the tune just delete the array and allocate it freshly if there is a change in the number of slots or lines. Note, file_cache_slot has similar problem, but because there are many, I haven't moved the count into those objects; I just hope that when tune is called there is exactly one file_cache constructed and all the file_cache_slot objects constructed are pointed by its m_file_slots member, so also on lines change it just deletes it and allocates again. I think it should be unlikely that the cache actually has any used slots by the time it is called. 2025-02-27 Jakub Jelinek <jakub@redhat.com> PR middle-end/118860 * input.h (file_cache::tune): No longer static. Rename argument from num_file_slots_ to num_file_slots. Formatting fix. (file_cache::num_file_slots): Renamed to ... (file_cache::m_num_file_slots): ... this. No longer static. * input.cc (file_cache_slot::tune): Change return type from void to size_t, return previous file_cache_slot::line_record_size value. Formatting fixes. (file_cache::tune): Rename argument from num_file_slots_ to num_file_slots. Set m_num_file_slots rather than num_file_slots. If m_num_file_slots or file_cache_slot::line_record_size changes, delete[] m_file_slots and new it again. (file_cache::num_file_slots): Remove definition. (file_cache::lookup_file): Use m_num_file_slots rather than num_file_slots. (file_cache::evicted_cache_tab_entry): Likewise. (file_cache::file_cache): Likewise. Initialize m_num_file_slots to 16. (file_cache::dump): Use m_num_file_slots rather than num_file_slots. (file_cache_slot::get_next_line): Formatting fixes. (file_cache_slot::read_line_num): Likewise. (get_source_text_between): Likewise. * toplev.cc (toplev::main): Call global_dc->get_file_cache ().tune rather than file_cache::tune. * gcc.dg/pr118860.c: New test.
-
Thomas Schwinge authored
... instead of 64 via 'gcc/defaults.h': MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (DImode) This fixes ICEs: [-FAIL: c-c++-common/pr111309-1.c -Wc++-compat (internal compiler error: in expand_fn_using_insn, at internal-fn.cc:268)-] [-FAIL:-]{+PASS:+} c-c++-common/pr111309-1.c -Wc++-compat (test for excess errors) [-UNRESOLVED:-]{+PASS:+} c-c++-common/pr111309-1.c -Wc++-compat [-compilation failed to produce executable-]{+execution test+} [-FAIL: c-c++-common/pr111309-1.c -std=gnu++17 (internal compiler error: in expand_fn_using_insn, at internal-fn.cc:268)-] [-FAIL:-]{+PASS:+} c-c++-common/pr111309-1.c -std=gnu++17 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} c-c++-common/pr111309-1.c -std=gnu++17 [-compilation failed to produce executable-]{+execution test+} [-FAIL: c-c++-common/pr111309-1.c -std=gnu++26 (internal compiler error: in expand_fn_using_insn, at internal-fn.cc:268)-] [-FAIL:-]{+PASS:+} c-c++-common/pr111309-1.c -std=gnu++26 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} c-c++-common/pr111309-1.c -std=gnu++26 [-compilation failed to produce executable-]{+execution test+} [-FAIL: c-c++-common/pr111309-1.c -std=gnu++98 (internal compiler error: in expand_fn_using_insn, at internal-fn.cc:268)-] [-FAIL:-]{+PASS:+} c-c++-common/pr111309-1.c -std=gnu++98 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} c-c++-common/pr111309-1.c -std=gnu++98 [-compilation failed to produce executable-]{+execution test+} [-FAIL: gcc.dg/torture/pr116480-1.c -O0 (internal compiler error: in expand_fn_using_insn, at internal-fn.cc:268)-] [-FAIL:-]{+PASS:+} gcc.dg/torture/pr116480-1.c -O0 (test for excess errors) [-FAIL: gcc.dg/torture/pr116480-1.c -O1 (internal compiler error: in expand_fn_using_insn, at internal-fn.cc:268)-] [-FAIL:-]{+PASS:+} gcc.dg/torture/pr116480-1.c -O1 (test for excess errors) PASS: gcc.dg/torture/pr116480-1.c -O2 (test for excess errors) PASS: gcc.dg/torture/pr116480-1.c -O3 -g (test for excess errors) PASS: gcc.dg/torture/pr116480-1.c -Os (test for excess errors) ..., where we ran into 'gcc_assert (icode != CODE_FOR_nothing);' in 'gcc/internal-fn.cc:expand_fn_using_insn' for '__int128' '__builtin_clzg' etc.: during RTL pass: expand [...]/c-c++-common/pr111309-1.c: In function 'clzI': [...]/c-c++-common/pr111309-1.c:69:10: internal compiler error: in expand_fn_using_insn, at internal-fn.cc:268 0x120ec2cf internal_error(char const*, ...) [...]/gcc/diagnostic-global-context.cc:517 0x102c7c5b fancy_abort(char const*, int, char const*) [...]/gcc/diagnostic.cc:1722 0x109708eb expand_fn_using_insn [...]/gcc/internal-fn.cc:268 0x1098114f expand_internal_call(internal_fn, gcall*) [...]/gcc/internal-fn.cc:5273 0x1098114f expand_internal_call(gcall*) [...]/gcc/internal-fn.cc:5281 0x10594fc7 expand_call_stmt [...]/gcc/cfgexpand.cc:3049 [...] Likewise, as of commit e8ad697a "libstdc++: Use new type-generic built-ins in <bit> [PR118855]", the libstdc++ target library build ICEd in the same way. Additionally, this change fixes: [-FAIL:-]{+PASS:+} gcc.dg/pr105094.c (test for excess errors) ..., which was: [...]/gcc.dg/pr105094.c: In function 'foo': [...]/gcc.dg/pr105094.c:11:12: error: size of variable 's' is too large And, finally, regarding 'gcc.target/nvptx/stack_frame-1.c'. Before, in 'gcc/cfgexpand.cc': 'expand_used_vars' -> 'expand_used_vars_for_block' -> 'expand_one_var' for 'ww' -> 'gcc/function.cc:use_register_for_decl' due to 'DECL_MODE (decl) == BLKmode' did 'return false;', thus -> 'add_stack_var' (even if 'ww' wasn't then actually living on the stack). Now, 'ww' has 'TImode' and 'use_register_for_decl' does 'return true;', thus -> 'expand_one_register_var', and therefore no unused stack frame emitted. gcc/ * config/nvptx/nvptx.h (MAX_FIXED_MODE_SIZE): '#define'. gcc/testsuite/ * gcc.target/nvptx/stack_frame-1.c: Adjust.
-
Thomas Schwinge authored
gcc/testsuite/ * gcc.target/nvptx/stack_frame-1.c: New.
-
Thomas Schwinge authored
As of recent commit 8bf0ee8d "Fortran: Add transfer_between_remotes [PR107635]", we've got 'alloca' usage in 'libgfortran/caf/single.c:_gfortran_caf_transfer_between_remotes', and the libgfortran target library fails to build for legacy configurations where PTX 'alloca' is not available: ../../../../source-gcc/libgfortran/caf/single.c: In function ‘_gfortran_caf_transfer_between_remotes’: ../../../../source-gcc/libgfortran/caf/single.c:675:23: sorry, unimplemented: dynamic stack allocation not supported 675 | transfer_desc = __builtin_alloca (desc_size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../../source-gcc/libgfortran/caf/single.c:680:20: sorry, unimplemented: dynamic stack allocation not supported 680 | transfer_ptr = __builtin_alloca (*opt_dst_charlen * src_size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[6]: *** [Makefile:4675: caf/single.lo] Error 1 With '-mfake-ptx-alloca', libgfortran again succeeds to build, and compared to before, we've got only a small number of regressions due to nvptx 'ld' complaining about 'unresolved symbol __GCC_nvptx__PTX_alloca_not_supported': [-PASS:-]{+FAIL:+} gfortran.dg/coarray/codimension_2.f90 -fcoarray=lib -O2 -lcaf_single (test for excess errors) [-PASS:-]{+FAIL:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib -O2 -lcaf_single (test for excess errors) [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib -O2 -lcaf_single [-execution test-]{+compilation failed to produce executable+} [-PASS:-]{+FAIL:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib -O2 -lcaf_single (test for excess errors) [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib -O2 -lcaf_single [-execution test-]{+compilation failed to produce executable+} [-PASS:-]{+FAIL:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 -fcoarray=lib -O2 -lcaf_single (test for excess errors) [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 -fcoarray=lib -O2 -lcaf_single [-execution test-]{+compilation failed to produce executable+} [-PASS:-]{+FAIL:+} gfortran.dg/coarray_43.f90 -O (test for excess errors) That's acceptable for such legacy PTX configurations. PR target/107635 libgfortran/ * config/t-nvptx: New. * configure.host [nvptx] (tmake_file): Add it.
-
Thomas Schwinge authored
With '-mfake-ptx-alloca' enabled, the user-visible behavior changes only for configurations where PTX 'alloca' is not available. Rather than a compile-time 'sorry, unimplemented: dynamic stack allocation not supported' in presence of dynamic stack allocation, compilation and assembly then succeeds. However, attempting to link in such '*.o' files then fails due to unresolved symbol '__GCC_nvptx__PTX_alloca_not_supported'. This is meant to be used in scenarios where large volumes of code are compiled, a small fraction of which runs into dynamic stack allocation, but these parts are not important for specific use cases, and we'd thus like the build to succeed, and error out just upon actual, very rare use of the offending '*.o' files. gcc/ * config/nvptx/nvptx.opt (-mfake-ptx-alloca): New. * config/nvptx/nvptx-protos.h (nvptx_output_fake_ptx_alloca): Declare. * config/nvptx/nvptx.cc (nvptx_output_fake_ptx_alloca): New. * config/nvptx/nvptx.md (define_insn "@nvptx_alloca_<mode>") [!(TARGET_PTX_7_3 && TARGET_SM52)]: Use it for '-mfake-ptx-alloca'. gcc/testsuite/ * gcc.target/nvptx/alloca-1-O0_-mfake-ptx-alloca.c: New. * gcc.target/nvptx/alloca-2-O0_-mfake-ptx-alloca.c: Likewise. * gcc.target/nvptx/alloca-4-O3_-mfake-ptx-alloca.c: Likewise. * gcc.target/nvptx/vla-1-O0_-mfake-ptx-alloca.c: Likewise. * gcc.target/nvptx/alloca-4-O3.c: 'dg-additional-options -mfake-ptx-alloca'.
-
Thomas Schwinge authored
nvptx: Delay 'sorry, unimplemented: dynamic stack allocation not supported' from expansion time to code generation This gives the back end a chance to clean out a few more unnecessary instances of dynamic stack allocation. This progresses: PASS: gcc.dg/pr78902.c (test for warnings, line 7) PASS: gcc.dg/pr78902.c (test for warnings, line 8) PASS: gcc.dg/pr78902.c (test for warnings, line 9) PASS: gcc.dg/pr78902.c (test for warnings, line 10) PASS: gcc.dg/pr78902.c (test for warnings, line 11) PASS: gcc.dg/pr78902.c (test for warnings, line 12) PASS: gcc.dg/pr78902.c (test for warnings, line 13) PASS: gcc.dg/pr78902.c strndup excessive bound at line 14 (test for warnings, line 13) [-UNSUPPORTED: gcc.dg/pr78902.c: dynamic stack allocation not supported-] {+PASS: gcc.dg/pr78902.c (test for excess errors)+} UNSUPPORTED: gcc.dg/torture/pr71901.c -O0 : dynamic stack allocation not supported [-UNSUPPORTED:-]{+PASS:+} gcc.dg/torture/pr71901.c -O1 [-: dynamic stack allocation not supported-]{+(test for excess errors)+} UNSUPPORTED: gcc.dg/torture/pr71901.c -O2 : dynamic stack allocation not supported UNSUPPORTED: gcc.dg/torture/pr71901.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions : dynamic stack allocation not supported UNSUPPORTED: gcc.dg/torture/pr71901.c -O3 -g : dynamic stack allocation not supported [-UNSUPPORTED:-]{+PASS:+} gcc.dg/torture/pr71901.c -Os [-: dynamic stack allocation not supported-]{+(test for excess errors)+} UNSUPPORTED: gcc.dg/torture/pr78742.c -O0 : dynamic stack allocation not supported [-UNSUPPORTED:-]{+PASS:+} gcc.dg/torture/pr78742.c -O1 [-: dynamic stack allocation not supported-]{+(test for excess errors)+} [-UNSUPPORTED:-]{+PASS:+} gcc.dg/torture/pr78742.c -O2 [-: dynamic stack allocation not supported-]{+(test for excess errors)+} [-UNSUPPORTED:-]{+PASS:+} gcc.dg/torture/pr78742.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions [-: dynamic stack allocation not supported-]{+(test for excess errors)+} [-UNSUPPORTED:-]{+PASS:+} gcc.dg/torture/pr78742.c -O3 -g [-: dynamic stack allocation not supported-]{+(test for excess errors)+} UNSUPPORTED: gcc.dg/torture/pr78742.c -Os : dynamic stack allocation not supported [-UNSUPPORTED:-]{+PASS:+} gfortran.dg/pr101267.f90 -O [-: dynamic stack allocation not supported-]{+(test for excess errors)+} [-UNSUPPORTED:-]{+PASS:+} gfortran.dg/pr112404.f90 -O [-: dynamic stack allocation not supported-]{+(test for excess errors)+} gcc/ * config/nvptx/nvptx.md (define_expand "allocate_stack") [!TARGET_SOFT_STACK]: Move 'sorry ("dynamic stack allocation not supported");'... (define_insn "@nvptx_alloca_<mode>"): ... here. gcc/testsuite/ * gcc.target/nvptx/alloca-1-unused-O0-sm_30.c: Adjust.
-
Thomas Schwinge authored
gcc/testsuite/ * gcc.target/nvptx/alloca-1-dead-O0-sm_30.c: New. * gcc.target/nvptx/alloca-1-dead-O0.c: Likewise. * gcc.target/nvptx/alloca-1-dead-O1-sm_30.c: Likewise. * gcc.target/nvptx/alloca-1-dead-O1.c: Likewise. * gcc.target/nvptx/alloca-1-unused-O0-sm_30.c: Likewise. * gcc.target/nvptx/alloca-1-unused-O0.c: Likewise. * gcc.target/nvptx/alloca-1-unused-O1-sm_30.c: Likewise. * gcc.target/nvptx/alloca-1-unused-O1.c: Likewise. * gcc.target/nvptx/vla-1-dead-O0-sm_30.c: Likewise. * gcc.target/nvptx/vla-1-dead-O0.c: Likewise. * gcc.target/nvptx/vla-1-dead-O1-sm_30.c: Likewise. * gcc.target/nvptx/vla-1-dead-O1.c: Likewise. * gcc.target/nvptx/vla-1-unused-O0-sm_30.c: Likewise. * gcc.target/nvptx/vla-1-unused-O0.c: Likewise. * gcc.target/nvptx/vla-1-unused-O1-sm_30.c: Likewise. * gcc.target/nvptx/vla-1-unused-O1.c: Likewise.
-
Jerry DeLisle authored
This change updates information about the -x option to clarify that it does not ensure standards compliance. Sparked by discussions in the following PR. PR fortran/108369 gcc/ChangeLog: * doc/invoke.texi: Add a note to clarify. Adjust some wording.
-
Marek Polacek authored
In this PR we crash in cxx_eval_constant_expression/GOTO_EXPR on: gcc_assert (cxx_dialect >= cxx23); The code obviously doesn't expect to see a goto pre-C++23. But we can get here with the new prvalue optimization. In this test we found ourselves in synthesize_method for X::X(). This function calls: a) finish_function, which does cp_genericize -> ... -> genericize_c_loops, which creates the GOTO_EXPR; b) expand_or_defer_fn -> maybe_clone_body -> ... -> cp_fold_function where we reach the new maybe_constant_init call and crash on the goto. Since we can validly get to that assert, I think we should just remove it. I don't see other similar asserts like this one. PR c++/118928 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_constant_expression) <case GOTO_EXPR>: Remove an assert. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-prvalue5.C: New test. Reviewed-by:
Jason Merrill <jason@redhat.com>
-
Vladimir N. Makarov authored
PR115458 also solves given PR. So the patch adds only a test case which can be used for testing LRA work aspects different from PR115458 test case. gcc/testsuite/ChangeLog: PR target/118940 * gcc.target/i386/pr118940.c: New test.
-
Vladimir N. Makarov authored
Patch for PR116234 solves given PR116366. So the patch adds only the test case which is very different from PR116234 one. gcc/testsuite/ChangeLog: PR rtl-optimization/116336 * gcc.dg/pr116336.c: New test.
-