aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-04-28gccrs: nr2.0: Handle StructPatternFieldIdentOwen Avery3-1/+9
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Handle StructPatternFieldIdent. * resolve/rust-late-name-resolver-2.0.h (Late::visit): Likewise. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entry. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-04-28gccrs: Add test case to show ICE is fixedPhilip Herron1-0/+8
Fixes Rust-GCC#3662 gcc/testsuite/ChangeLog: * rust/compile/issue-3662.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-28gccrs: Add test case to show issue is fixedPhilip Herron1-0/+17
This was already fixed in: bb01719f0e1 but we require fn_once lang item to be defined as we are working on libcore support still. Fixes Rust-GCC#3711 gcc/testsuite/ChangeLog: * rust/compile/issue-3711.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-28gccrs: Add gimple test for black box intrinsicPierre-Emmanuel Patry1-0/+28
gcc/testsuite/ChangeLog: * rust/compile/black_box.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Add execute test for black_box intrinsicPierre-Emmanuel Patry1-0/+30
gcc/testsuite/ChangeLog: * rust/execute/black_box.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Add LlvmInlineAsm node dumpPierre-Emmanuel Patry1-1/+38
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Dump llvm inline asm tokens. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Parse and lower llvm asm nodePierre-Emmanuel Patry36-17/+576
Add a new HIR LlvmInlineAsm HIR node as well as some structures to represent it's options and operands. Lower AST::LlvmInlineAsm node to it and then create a tree from that node. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Remove unreachable code. * ast/rust-expr.h (struct LlvmOperand): Add LlvmOperand struct to represent input and outputs. (class LlvmInlineAsm): Add input, output and clobber operands. (struct TupleTemplateStr): Add locus getter. * backend/rust-compile-block.h: Add visit for LlvmInlineAsm. * backend/rust-compile-expr.cc (CompileExpr::visit): Add llvm inline asm stmt compilation. * backend/rust-compile-expr.h: Add function prototype. * backend/rust-compile-asm.h (class CompileLlvmAsm): Add llvm asm hir not to gimple. * backend/rust-compile-asm.cc (CompileLlvmAsm::CompileLlvmAsm): Add constructor. (CompileLlvmAsm::construct_operands): Add function to construct operand tree. (CompileLlvmAsm::construct_clobbers): Add function to construct clobber tree. (CompileLlvmAsm::tree_codegen_asm): Generate the whole tree for a given llvm inline assembly node. * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Add visit function. * checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Add function prototype. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Add visit function. * checks/errors/borrowck/rust-bir-builder-struct.h: Likewise. * checks/errors/borrowck/rust-function-collector.h: Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.h: Add visit function prototype. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Add visit function. * checks/errors/rust-const-checker.h: Add visit function prototype. * checks/errors/rust-hir-pattern-analysis.cc (PatternChecker::visit): Add visit function. * checks/errors/rust-hir-pattern-analysis.h: Add visit function prototype. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Add visit function. * checks/errors/rust-unsafe-checker.h: Add function prototype. * expand/rust-macro-builtins-asm.cc (parse_llvm_templates): Parse templates. (parse_llvm_arguments): Add function to parse non template tokens. (parse_llvm_operands): Add function to parse operands, either input or output. (parse_llvm_outputs): Add function to parse and collect llvm asm outputs. (parse_llvm_inputs): Likewise with inputs. (parse_llvm_clobbers): Add function to parse llvm asm clobbers. (parse_llvm_options): Add function to parse llvm asm options. (parse_llvm_asm): Add function to parse llvm asm. * expand/rust-macro-builtins-asm.h (class LlvmAsmContext): Add context for llvm asm parser. (parse_llvm_outputs): Add function prototype. (parse_llvm_inputs): Likewise. (parse_llvm_clobbers): Likewise. (parse_llvm_options): Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Lower AST llvm asm node to HIR. * hir/rust-ast-lower-expr.h: Add function prototype. * hir/rust-hir-dump.cc (Dump::visit): Add visit function. * hir/rust-hir-dump.h: Add function prototype. * hir/tree/rust-hir-expr-abstract.h: Add HIR llvm asm node kind. * hir/tree/rust-hir-expr.h (struct LlvmOperand): Add LlvmOperand type to represent input and outputs. (class LlvmInlineAsm): Add LlvmInlineAsm hir node. * hir/tree/rust-hir-full-decls.h (class LlvmInlineAsm): Add LlvmInlineAsm hir node forward declaration. * hir/tree/rust-hir-visitor.h: Add visit functions for LlvmInlineAsm hir node. * hir/tree/rust-hir.cc (LlvmInlineAsm::accept_vis): Add hir node visitor related functions. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Type check input and output operands. * typecheck/rust-hir-type-check-expr.h: Add function prototype. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit input and output operand expressions. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Resolve input and output expressions. * resolve/rust-ast-resolve-expr.h: Add function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Add llvmInlineAsm nodePierre-Emmanuel Patry16-2/+124
InlineAsm node does not support memory clobbers. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Make visitor unreachable. * ast/rust-ast-collector.h: Add visit for LlvmInlineAsmNode. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Add visit function for the default ast visitor. * ast/rust-ast-visitor.h: Add function prototype. * ast/rust-ast.cc (LlvmInlineAsm::accept_vis): Add accept_vis to LlvmInlineAsm node. * ast/rust-ast.h: Add LlvmInlineAsm node kind. * ast/rust-expr.h (class LlvmInlineAsm): Add LlvmInlineAsm node. * expand/rust-derive.h: Add visit function for LlvmInlineAsm node. * expand/rust-macro-builtins-asm.cc (MacroBuiltin::llvm_asm_handler): Add handler for llvm inline assembly nodes. (parse_llvm_asm): Add function to parse llvm assembly nodes. * expand/rust-macro-builtins-asm.h (parse_llvm_asm): Add function prototypes. * expand/rust-macro-builtins.cc (inline_llvm_asm_maker): Add macro transcriber. * expand/rust-macro-builtins.h: Add transcriber function prototype. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add visit function for LlvmInlineAsm node. * hir/rust-ast-lower-base.h: Add visit function prototype. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add visit function for LlvmInlineAsm node. * resolve/rust-ast-resolve-base.h: Add visit function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Emit error with old asm syntax in new asm blocksPierre-Emmanuel Patry1-0/+8
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_asm_arg): Emit error message. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Add check for placeholder (infer) type in return positionPhilip Herron4-0/+134
It is not allowed to have a declared inference variable in the return position of a function as this may never get infered you need good points of truth. Ideally if we get a student for GSoC 25 we will get the Default Hir Visitor so that we can grab the HIR::InferredType locus instead of using the ref location lookups. Fixes Rust-GCC#402 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): add diagnostic * typecheck/rust-tyty.cc (BaseType::contains_infer): new helper to grab first infer var * typecheck/rust-tyty.h: prototype gcc/testsuite/ChangeLog: * rust/compile/issue-402.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-28gccrs: Fix ICE when checking shift's which are behind array refsPhilip Herron2-0/+6
I copied a bad form of this check from the c front-end this updates it to ensure the rhs is an INTEGER_CST and the lhs needs checked in the first place. Fixes Rust-GCC#3664 gcc/rust/ChangeLog: * rust-gcc.cc (arithmetic_or_logical_expression): Ensure this is an integer gcc/testsuite/ChangeLog: * rust/compile/issue-3664.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-28gccrs: Fix crash in hir dump as labels are optionalPhilip Herron1-1/+3
gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::visit): add guard for optional label Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-28gccrs: Update comments in repr parsing codeYap Zhi Heng2-2/+2
gcc/rust/ChangeLog: * typecheck/rust-tyty.h: Remove extra redundant comment. * typecheck/rust-hir-type-check-base.cc: Update comment on repr handling. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-04-28gccrs: Implement integer representation for enumsZhi Heng2-4/+11
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.cc: Set enum representing type properly if repr is an integer type. * typecheck/rust-hir-type-check-item.cc: Update comments. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-04-28gccrs: Implement typecheck for zero-variant enumsZhi Heng5-6/+61
gcc/rust/ChangeLog: * typecheck/rust-tyty.h: Add new `ReprKind` enum to `ReprOptions`. * typecheck/rust-hir-type-check-base.cc: Handle setting of `repr_kind`. * typecheck/rust-hir-type-check-item.cc: New check for zero-variant enums. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-04-28gccrs: Fix segv in unsafe chckerPhilip Herron4-1/+34
Trait constants were missing type resolution step, this adds that as if it was a normal constant. The unsafe checker was missing a null check. Fixes Rust-GCC#3612 gcc/rust/ChangeLog: * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): add null check * hir/tree/rust-hir-item.h: add has_type helper * typecheck/rust-hir-trait-resolve.cc (TraitItemReference::resolve_item): add missing type checking gcc/testsuite/ChangeLog: * rust/compile/issue-3612.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-28simplify-rtx: Split out native_decode_intRichard Sandiford2-13/+27
native_decode_rtx handles integer modes by building up a wide_int and then converting it to an rtx. This patch splits out the wide_int part, so that callers who don't want an rtx can avoid creating garbage rtl. gcc/ * rtl.h (native_decode_int): Declare. * simplify-rtx.cc (native_decode_int): New function, split out from... (native_decode_rtx): ...here.
2025-04-28x86: Properly find the maximum stack slot alignmentH.J. Lu6-21/+360
Don't assume that stack slots can only be accessed by stack or frame registers. We first find all registers defined by stack or frame registers. Then check memory accesses by such registers, including stack and frame registers. gcc/ PR target/109780 PR target/109093 * config/i386/i386.cc (stack_access_data): New. (ix86_update_stack_alignment): Likewise. (ix86_find_all_reg_use_1): Likewise. (ix86_find_all_reg_use): Likewise. (ix86_find_max_used_stack_alignment): Also check memory accesses from registers defined by stack or frame registers. gcc/testsuite/ PR target/109780 PR target/109093 * g++.target/i386/pr109780-1.C: New test. * gcc.target/i386/pr109093-1.c: Likewise. * gcc.target/i386/pr109780-1.c: Likewise. * gcc.target/i386/pr109780-2.c: Likewise. * gcc.target/i386/pr109780-3.c: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Co-Authored-By: Uros Bizjak <ubizjak@gmail.com>
2025-04-28ipa/119973 - IPA PTA issue with global initializersRichard Biener2-5/+44
For global initializers with IPA PTA we initialize them from the IPA reference data but that lacks references to the constant pool. The following conservatively considers the whole initializer. PR ipa/119973 * tree-ssa-structalias.cc (create_variable_info_for): Build constraints from DECL_INITIAL directly rather than the IPA reference list which is incomplete. * gcc.dg/torture/pr119973.c: New testcase.
2025-04-28lto/113207 - make fld_type_variant more pickyRichard Biener1-1/+6
The below adds additional verification to fld_type_variant that there's only one variant matching fld_type_variant_equal_p on the chain. The PR shows that variants built with build_qualified_type can be equal to others in that regard but not with regard to what build_qualified_type does. PR lto/113207 * ipa-free-lang-data.cc (fld_type_variant): Add extra checking.
2025-04-28tree-optimization/119044 - predcom fails to preserve alias infoRichard Biener1-0/+2
Predictive commoning fails to preserve alias info for the refs it creates. The following adds this to see whether it fixes the observed regression in 436.cactusADM after r15-7665. PR tree-optimization/119044 * tree-predcom.cc (ref_at_iteration): Copy alias info from the original ref.
2025-04-28tree-optimization/119103 - missed overwidening detection for shiftRichard Biener3-9/+40
When vectorizing a shift of u16 data by an amount that's known to be less than 16 we currently fail to emit a vector u16 shift. The first reason is that the promotion of the shift amount is hoisted only by PRE and that cannot preserve range info, the second reason is that pattern detection doesn't use range info when computing the precision required for an operation. The following addresses the first issue by making LIM hoist all expressions for the pass that runs right before PRE and the second issue by querying ranges for the shift amount. PR tree-optimization/119103 * tree-ssa-loop-im.cc (in_loop_pipeline): Globalize. (compute_invariantness): Override costing when we run right before PRE and PRE is enabled. (pass_lim::execute): Adjust. * tree-vect-patterns.cc (vect_determine_precisions_from_users): For variable shift amounts use range information. * gcc.target/i386/pr119103.c: New testcase.
2025-04-28middle-end/80342 - genmatch optimize outer conversionsRichard Biener2-51/+160
The following improves genmatch generated code so we avoid more spurious SSA assignments to be pushed to the GIMPLE sequence or simplifications rejected when we're not supposed to produce any for outer and intermediate conversions. * genmatch.cc (::gen_transform): Add in_place parameter. Assert it isn't set in unexpected places. (possible_noop_convert): New. (expr::gen_transform): Support in_place and emit code to compute a child in-place when the operation is a conversion. (dt_simplify::gen_1): Arrange for an outermost conversion to be elided by generating the transform of the operand in-place. * match.pd (__real cepxi (x) -> cos (x)): Use single_use.
2025-04-28middle-end/60779 - LTO vs. -fcx-fortran-rules and -fcx-limited-rangeRichard Biener7-29/+66
The following changes how flag_complex_method is managed towards being able to record that in the optimization set so we can stream and restore it per function. Currently -fcx-fortran-rules and -fcx-limited-range are separate recorded options but saving/restoring does not restore flag_complex_method which is later used in the middle-end. The solution is to make -fcx-fortran-rules and -fcx-limited-range aliases of a new -fcx-method= switch that represents flag_complex_method directly so we can save and restore it. PR middle-end/60779 * common.opt (fcx-method=): New, map to flag_complex_method. (Enum complex_method): New. (fcx-limited-range): Alias to -fcx-method=limited-range. (fcx-fortran-rules): Alias to -fcx-medhot=fortran. * ipa-inline-transform.cc (inline_call): Check flag_complex_method. * ipa-inline.cc (can_inline_edge_by_limits_p): Likewise. * opts.cc (finish_options): Adjust. (set_fast_math_flags): Likewise. * doc/invoke.texi (fcx-method=): Document. * gcc.dg/lto/pr60779_0.c: New testcase. * gcc.dg/lto/pr60779_1.c: Likewise.
2025-04-28middle-end/116083 - vectorizer slownessRichard Biener1-9/+14
Turns out SLP discovery can end up doing a lot of vector type builds from scalar types. Those are all ultimatively cached but end up built and layouted first. The latter is particularly expensive because it does tree node arithmetic to compute TYPE_SIZE and TYPE_SIZE_UNIT. The following replaces this with the appropriate poly-int arithmetic which speeds up the testcase by 50%. PR middle-end/116083 * stor-layout.cc (layout_type): Compute TYPE_SIZE and TYPE_SIZE_UNIT for vector types from the component mode sizes.
2025-04-28Prune non-SLP paths from vectorizer loop analysisRichard Biener1-109/+43
The following prunes non-SLP iteration and the parts of non-SLP stmt analysis that is no longer necessary - we need to keep the parts that bail on stmts not covered by SLP discovery or that failed SLP discovery. This will only go away when a we can build a fully covering single-lane SLP graph to fall back to. * tree-vect-loop.cc (vect_analyze_loop_operations): Prune all actual analysis and only fail when we discover a not SLP covered stmt. (vect_analyze_loop_2): Remove path trying without SLP.
2025-04-28Remove non-SLP vector loop transformRichard Biener2-288/+19
The following removes the stmt-based vectorization loop transform code. This also removes some debug stmt handling (that looked incomplete) which is also handled during peeling, and special-casing some stmts that should be killed off early and not left to DCE. Moving of dump from vect_transform_loop_stmt to vect_transform_stmt is to avoid regressing a few testcases. * tree-vect-loop.cc (vect_loop_kill_debug_uses): Remove. (maybe_set_vectorized_backedge_value): Likewise. (vect_transform_loop_stmt): Likewise. Move dump printing to vect_transform_stmt. (vect_transform_loop): Remove loop over loop stmts transforming them, but retain some DCE code still necessary. * tree-vect-stmts.cc (vect_transform_stmt): Dump that we're vectorizing a stmt.
2025-04-28Remove --param vect-force-slpRichard Biener4-9/+2
The following removes the ability to switch back to non SLP-only operation of the vectorizer - a requirement to start cleaning out non-SLP paths without risk of regressing that case. * params.opt (--param=vect-force-slp): Remove. * doc/invoke.texi (--param=vect-force-slp): Likewise. * tree-vect-loop.cc (vect_analyze_loop_2): Assume param_vect_force_slp is 1. * tree-vect-stmts.cc (vect_analyze_stmt): Likewise.
2025-04-28libstdc++: Fix mingw build by using _M_span [PR119970]Tomasz Kamiński2-2/+2
The r16-142-g01e5ef3e8b9128 chagned return type of _Str_sink::view() to basic_string_view<_CharT>. The mutable access is provided by _M_span function, that is now used for mingw path. PR libstdc++/119970 libstdc++-v3/ChangeLog: * include/std/ostream (vprint_unicode) [_WIN32 && !__CYGWIN__]: Call _Str_sink::_M_span instead of view. * include/std/print (vprint_unicode) [_WIN32 && !__CYGWIN__]: Call _Str_sink::_M_span instead of view.
2025-04-28libstdc++: Strip reference and cv-qual in range deduction guides for maps.Tomasz Kamiński12-44/+279
This implements part of LWG4223 that adjust the deduction guides for maps types (map, unordered_map, flat_map and non-unique equivalent) from "range" (std::from_range, iterator pair), such that referience and cv qualification are stripped from the element of the pair-like value_type. In combination with r15-8296-gd50171bc07006d, the LWG4223 is fully implemented now. libstdc++-v3/ChangeLog: * include/bits/ranges_base.h (__detail::__range_key_type): Replace remove_const_t with remove_cvref_t. (__detail::__range_mapped_type): Apply remove_cvref_t. * include/bits/stl_iterator.h: (__detail::__iter_key_t): Replace remove_const_t with __remove_cvref_t. (__detail::__iter_val_t): Apply __remove_cvref_t. * testsuite/23_containers/flat_map/1.cc: New tests. * testsuite/23_containers/flat_multimap/1.cc: New tests. * testsuite/23_containers/map/cons/deduction.cc: New tests. * testsuite/23_containers/map/cons/from_range.cc: New tests. * testsuite/23_containers/multimap/cons/deduction.cc: New tests. * testsuite/23_containers/multimap/cons/from_range.cc: New tests. * testsuite/23_containers/unordered_map/cons/deduction.cc: New tests. * testsuite/23_containers/unordered_map/cons/from_range.cc: New tests. * testsuite/23_containers/unordered_multimap/cons/deduction.cc: New tests. * testsuite/23_containers/unordered_multimap/cons/from_range.cc: New tests. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-28libstdc++: Implement missing allocator-aware constructors for unordered ↵Tomasz Kamiński12-16/+320
containers. This patch implements remainder of LWG2713 (after r15-8293-g64f5c854597759) by adding missing allocator aware version of unordered associative containers constructors accepting pair of iterators or initializer_list, and corresponding deduction guides. libstdc++-v3/ChangeLog: * include/bits/unordered_map.h (unordered_map): Define constructors accepting: (_InputIterator, _InputIterator, const allocator_type&), (initializer_list<value_type>, const allocator_type&), (unordered_multimap): Likewise. * include/debug/unordered_map (unordered_map): Likewise. (unordered_multimap): Likewise. * include/bits/unordered_set.h (unordered_set): Define constructors and deduction guide accepting: (_InputIterator, _InputIterator, const allocator_type&), (initializer_list<value_type>, const allocator_type&), (unordered_multiset): Likewise. * include/debug/unordered_set (unordered_set): Likewise. (unordered_multiset): Likewise. * testsuite/23_containers/unordered_map/cons/66055.cc: New tests. * testsuite/23_containers/unordered_map/cons/deduction.cc: New tests. * testsuite/23_containers/unordered_multimap/cons/66055.cc: New tests. * testsuite/23_containers/unordered_multimap/cons/deduction.cc: New tests. * testsuite/23_containers/unordered_multiset/cons/66055.cc: New tests. * testsuite/23_containers/unordered_multiset/cons/deduction.cc: New tests. * testsuite/23_containers/unordered_set/cons/66055.cc: New tests. * testsuite/23_containers/unordered_set/cons/deduction.cc: New tests. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-28tailc: Improve tail recursion handling [PR119493]Jakub Jelinek1-2/+1
Here is a patch to improve the tail recursion handling also for non-musttail calls. 2025-04-28 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/119493 * tree-tailcall.cc (find_tail_calls): Handle non-gimple_reg_type arguments which aren't just passed through for tail recursions even for non-musttail calls.
2025-04-27c-family: Improve location for -Wunknown-pragmas in a _Pragma [PR118838]Lewis Hyatt7-18/+54
The warning for -Wunknown-pragmas is issued at the location provided by libcpp to the def_pragma() callback. This location is cpp_reader::directive_line, which is a location for the start of the line only; it is also not a valid location in case the unknown pragma was lexed from a _Pragma string. These factors make it impossible to suppress -Wunknown-pragmas via _Pragma("GCC diagnostic...") directives on the same source line, as in the PR and the test case. Address that by issuing the warning at a better location returned by cpp_get_diagnostic_override_loc(). libcpp already maintains this location to handle _Pragma-related diagnostics internally; it was needed also to make a publicly accessible version of it. gcc/c-family/ChangeLog: PR c/118838 * c-lex.cc (cb_def_pragma): Call cpp_get_diagnostic_override_loc() to get a valid location at which to issue -Wunknown-pragmas, in case it was triggered from a _Pragma. libcpp/ChangeLog: PR c/118838 * errors.cc (cpp_get_diagnostic_override_loc): New function. * include/cpplib.h (cpp_get_diagnostic_override_loc): Declare. gcc/testsuite/ChangeLog: PR c/118838 * c-c++-common/cpp/pragma-diagnostic-loc-2.c: New test. * g++.dg/gomp/macro-4.C: Adjust expected output. * gcc.dg/gomp/macro-4.c: Likewise. * gcc.dg/cpp/Wunknown-pragmas-1.c: Likewise.
2025-04-28gcc: For Windows x86-32, always attempt to realign stack regardless of SSELIU Hao1-1/+1
For Windows x86-32 targets, the Microsoft ABI only guarantees that the stack is aligned to 4-byte boundaries. GCC knows about the default alignment of the stack. However, before this commit, it did not realign the stack unless SSE was also enabled. When a stricter (larger) alignment is requested, it's always necessary to realign the stack, as what Solaris does. Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111107#c14 Signed-off-by: LIU Hao <lh_mouse@126.com> Signed-off-by: Jonathan Yong <10walls@gmail.com> gcc/ChangeLog: PR target/111107 * config/i386/cygming.h (STACK_REALIGN_DEFAULT): Copy from sol2.h.
2025-04-28Fix size_t in id-15.c and infoleak-net-ethtool-ioctl.c for llp64Jonathan Yong2-3/+2
Use __SIZE_TYPE__ for size_t types so that it works for llp64. Signed-off-by: Jonathan Yong <10walls@gmail.com> gcc/testsuite/ChangeLog: * gcc.dg/graphite/id-15.c: Use __SIZE_TYPE__ instead of unsigned long. * gcc.dg/plugin/infoleak-net-ethtool-ioctl.c: ditto.
2025-04-28Daily bump.GCC Administrator6-1/+135
2025-04-27c++/modules: Ensure DECL_FRIEND_CONTEXT is streamed [PR119939]Nathaniel Shead3-2/+20
An instantiated friend function relies on DECL_FRIEND_CONTEXT being set to be able to recover the template arguments of the class that instantiated it, despite not being a template itself. This patch ensures that this data is streamed even when DECL_CLASS_SCOPE_P is not true. PR c++/119939 gcc/cp/ChangeLog: * module.cc (trees_out::lang_decl_vals): Also stream lang->u.fn.context when DECL_UNIQUE_FRIEND_P. (trees_in::lang_decl_vals): Likewise. gcc/testsuite/ChangeLog: * g++.dg/modules/concept-11_a.H: New test. * g++.dg/modules/concept-11_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2025-04-27ssa-fre-4.c: Enable for all targets and adjust scan matchH.J. Lu1-4/+2
Since the C frontend no longer promotes char argument, enable ssa-fre-4.c for all targets and adjust scan match. PR middle-end/112877 * gcc.dg/tree-ssa/ssa-fre-4.c: Enable for all targets and adjust scan match. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-27scev-cast.c: Enable for all targets and adjust scan matchesH.J. Lu1-3/+2
Since the C frontend no longer promotes char argument, enable scev-cast.c for all targets and adjust scan matches. PR middle-end/112877 * gcc.dg/tree-ssa/scev-cast.c: Enable for all targets and adjust scan match. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-27vect-simd-clone-1[6-8][cd].c: Expect in-branch clones for x86H.J. Lu6-23/+6
Since the C frontend no longer promotes char and short arguments, expect in-branch clones for x86. PR middle-end/112877 * gcc.dg/vect/vect-simd-clone-16c.c: Expect in-branch clones for x86. * gcc.dg/vect/vect-simd-clone-16d.c: Likewise. * gcc.dg/vect/vect-simd-clone-17c.c: Likewise. * gcc.dg/vect/vect-simd-clone-17d.c: Likewise. * gcc.dg/vect/vect-simd-clone-18c.c: Likewise. * gcc.dg/vect/vect-simd-clone-18d.c: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-27i386: Adjust apx-ndd.c for frontend promotion removalH.J. Lu1-6/+3
Since the C frontend no longer promotes integer argument smaller than int, the apx-ndd.c codgen is slightly different: apx-ndd.s (original) 2024-11-10 06:07:09.894876973 +0800 apx-ndd.s (updated) 2024-11-10 06:06:59.371860565 +0800 @@ -17,7 +17,7 @@ foo_add_char: foo1_add_char: .LFB1: .cfi_startproc - leal (%rsi,%rdi), %eax + leal (%rdi,%rsi), %eax ret .cfi_endproc .LFE1: @@ -50,7 +50,7 @@ foo_add_short: foo1_add_short: .LFB4: .cfi_startproc - leal (%rsi,%rdi), %eax + leal (%rdi,%rsi), %eax ret .cfi_endproc .LFE4: @@ -413,7 +413,7 @@ foo_and_char: foo1_and_char: .LFB37: .cfi_startproc - andl %edi, %esi, %eax + andl %esi, %edi, %eax ret .cfi_endproc .LFE37: @@ -435,7 +435,7 @@ foo_and_short: foo1_and_short: .LFB39: .cfi_startproc - andl %edi, %esi, %eax + andl %esi, %edi, %eax ret .cfi_endproc .LFE39: @@ -501,7 +501,7 @@ foo_or_char: foo1_or_char: .LFB45: .cfi_startproc - orl %edi, %esi, %eax + orl %esi, %edi, %eax ret .cfi_endproc .LFE45: @@ -523,7 +523,7 @@ foo_or_short: foo1_or_short: .LFB47: .cfi_startproc - orl %edi, %esi, %eax + orl %esi, %edi, %eax ret .cfi_endproc .LFE47: @@ -589,7 +589,7 @@ foo_xor_char: foo1_xor_char: .LFB53: .cfi_startproc - xorl %edi, %esi, %eax + xorl %esi, %edi, %eax ret .cfi_endproc .LFE53: @@ -611,7 +611,7 @@ foo_xor_short: foo1_xor_short: .LFB55: .cfi_startproc - xorl %edi, %esi, %eax + xorl %esi, %edi, %eax ret .cfi_endproc .LFE55: @@ -1018,7 +1018,7 @@ foo4_rol_uint64_t: foo1_imul_short: .LFB92: .cfi_startproc - imull %edi, %esi, %eax + imull %esi, %edi, %eax ret .cfi_endproc .LFE92: Adjust the assembler scans. PR middle-end/112877 * gcc.target/i386/apx-ndd.c: Adjusted. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-27Drop targetm.promote_prototypes from C, C++ and Ada frontendsH.J. Lu7-121/+9
Remove the targetm.calls.promote_prototypes call from C, C++ and Ada frontends. gcc/ PR c/48274 PR middle-end/112877 PR middle-end/118288 * gimple.cc (gimple_builtin_call_types_compatible_p): Remove the targetm.calls.promote_prototypes call. * tree.cc (tree_builtin_call_types_compatible_p): Likewise. gcc/ada/ PR middle-end/112877 * gcc-interface/utils.cc (create_param_decl): Remove the targetm.calls.promote_prototypes call. gcc/c/ PR c/48274 PR middle-end/112877 PR middle-end/118288 * c-decl.cc (start_decl): Remove the targetm.calls.promote_prototypes call. (store_parm_decls_oldstyle): Likewise. (finish_function): Likewise. * c-typeck.cc (convert_argument): Likewise. (c_safe_arg_type_equiv_p): Likewise. gcc/cp/ PR middle-end/112877 * call.cc (type_passed_as): Remove the targetm.calls.promote_prototypes call. (convert_for_arg_passing): Likewise. * typeck.cc (cxx_safe_arg_type_equiv_p): Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-27Honor TARGET_PROMOTE_PROTOTYPES during RTL expandH.J. Lu2-0/+26
Promote integer arguments smaller than int if TARGET_PROMOTE_PROTOTYPES returns true. gcc/ PR middle-end/112877 * calls.cc (initialize_argument_information): Promote small integer arguments if TARGET_PROMOTE_PROTOTYPES returns true. gcc/testsuite/ PR middle-end/112877 * gfortran.dg/pr112877-1.f90: New test. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-27RISC-V: Extract vector stepped for expand_const_vector [NFC]Pan Li1-291/+299
Consider the expand_const_vector is quit long (about 500 lines) and complicated, we would like to extract the different case into different functions. For example, the const vector stepped will be extracted into expand_const_vector_stepped. The below test suites are passed for this patch. * The rv64gcv fully regression test. gcc/ChangeLog: * config/riscv/riscv-v.cc (expand_const_vector): Extract const vector stepped into separated func. (expand_const_vector_single_step_npatterns): Add new func to take care of single step. (expand_const_vector_interleaved_stepped_npatterns): Add new func to take care of interleaved step. (expand_const_vector_stepped): Add new func to take care of const vector stepped. Signed-off-by: Pan Li <pan2.li@intel.com>
2025-04-27RISC-V: Extract vector duplicate for expand_const_vector [NFC]Pan Li1-76/+104
Consider the expand_const_vector is quit long (about 500 lines) and complicated, we would like to extract the different case into different functions. For example, the const vector duplicate will be extracted into expand_const_vector_duplicate, and then expand_const_vector_duplicate_repeating and expand_const_vector_duplicate_default for the underlying function. The below test suites are passed for this patch. * The rv64gcv fully regression test. gcc/ChangeLog: * config/riscv/riscv-v.cc (expand_const_vector_duplicate_repeating): Add new func to take care of vector duplicate with repeating. (expand_const_vector_duplicate_default): Add new func to take care of default const vector duplicate. (expand_const_vector_duplicate): Add new func to take care of all const vector duplicate. (expand_const_vector): Extract const vector duplicate into separated function. Signed-off-by: Pan Li <pan2.li@intel.com>
2025-04-27RISC-V: Extract vec_series for expand_const_vector [NFC]Pan Li1-7/+13
Consider the expand_const_vector is quit long (about 500 lines) and complicated, we would like to extract the different case into different functions. For example, the const vec_series will be extracted into expand_const_vec_series. The below test suites are passed for this patch. * The rv64gcv fully regression test. gcc/ChangeLog: * config/riscv/riscv-v.cc (expand_const_vec_series): Add new func to take care of the const vec_series. (expand_const_vector): Extract const vec_series into separated function. Signed-off-by: Pan Li <pan2.li@intel.com>
2025-04-27RISC-V: Extract vec_duplicate for expand_const_vector [NFC]Pan Li1-42/+50
Consider the expand_const_vector is quit long (about 500 lines) and complicated, we would like to extract the different case into different functions. For example, the const vec_duplicate will be extracted into expand_const_vec_duplicate. The below test suites are passed for this patch. * The rv64gcv fully regression test. gcc/ChangeLog: * config/riscv/riscv-v.cc (expand_const_vector): Extract const vec_duplicate into separated function. (expand_const_vec_duplicate): Add new func to take care of the const vec_duplicate. Signed-off-by: Pan Li <pan2.li@intel.com>
2025-04-26Refactor msse4 and mno-sse4.liuhongt3-23/+13
gcc/ChangeLog: PR target/119549 * common/config/i386/i386-common.cc (ix86_handle_option): Refactor msse4 and mno-sse4. * config/i386/i386.opt (msse4): Remove RejectNegative. (mno-sse4): Remove the entry. * config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p): Remove special code which handles mno-sse4.
2025-04-27Daily bump.GCC Administrator3-1/+20
2025-04-26Fix i386 vectorizer cost of FP scalar MAX_EXPR and MIN_EXPRJan Hubicka1-2/+4
I introduced a bug by last minute cleanups unifying the scalar and vector SSE conditional. This patch fixes it and restores cost of 1 of SSE scalar MIN/MAX Bootstrapped/regtested x86_64-linux, comitted. gcc/ChangeLog: PR target/105275 * config/i386/i386.cc (ix86_vector_costs::add_stmt_cost): Fix cost of FP scalar MAX_EXPR and MIN_EXPR