aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2025-04-14GCN, nvptx: Support '-mfake-exceptions', and use it for offloading ↵Thomas Schwinge20-8/+179
compilation [PR118794] With '-mfake-exceptions' enabled, the user-visible behavior in presence of exception handling constructs changes such that the compile-time 'sorry, unimplemented: exception handling not supported' is skipped, code generation proceeds, and instead, exception handling constructs 'abort' at run time. (..., or don't, if they're in dead code.) PR target/118794 gcc/ * config/gcn/gcn.opt (-mfake-exceptions): Support. * config/nvptx/nvptx.opt (-mfake-exceptions): Likewise. * config/gcn/gcn.md (define_expand "exception_receiver"): Use it. * config/nvptx/nvptx.md (define_expand "exception_receiver"): Likewise. * config/gcn/mkoffload.cc (main): Set it. * config/nvptx/mkoffload.cc (main): Likewise. * config/nvptx/nvptx.cc (nvptx_assemble_integer) <in_section == exception_section>: Special handling for 'SYMBOL_REF's. * except.cc (expand_dw2_landing_pad_for_region): Don't generate bogus code for (default) '#define EH_RETURN_DATA_REGNO(N) INVALID_REGNUM'. libgcc/ * config/gcn/unwind-gcn.c (_Unwind_Resume): New. * config/nvptx/unwind-nvptx.c (_Unwind_Resume): Likewise. gcc/testsuite/ * g++.target/gcn/exceptions-bad_cast-2.C: Set '-mno-fake-exceptions'. * g++.target/gcn/exceptions-pr118794-1.C: Likewise. * g++.target/gcn/exceptions-throw-2.C: Likewise. * g++.target/nvptx/exceptions-bad_cast-2.C: Likewise. * g++.target/nvptx/exceptions-pr118794-1.C: Likewise. * g++.target/nvptx/exceptions-throw-2.C: Likewise. * g++.target/gcn/exceptions-bad_cast-2_-mfake-exceptions.C: New. * g++.target/gcn/exceptions-pr118794-1_-mfake-exceptions.C: Likewise. * g++.target/gcn/exceptions-throw-2_-mfake-exceptions.C: Likewise. * g++.target/nvptx/exceptions-bad_cast-2_-mfake-exceptions.C: Likewise. * g++.target/nvptx/exceptions-pr118794-1_-mfake-exceptions.C: Likewise. * g++.target/nvptx/exceptions-throw-2_-mfake-exceptions.C: Likewise. libgomp/ * testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C: Set '-foffload-options=-mno-fake-exceptions'. * testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C: Likewise. * testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C: Likewise. * testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C: Likewise. * testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C: Likewise. * testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-GCN.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-nvptx.C: Likewise. * testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: Adjust. * testsuite/libgomp.c++/target-exceptions-pr118794-1.C: Likewise. * testsuite/libgomp.c++/target-exceptions-throw-2.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise. * testsuite/libgomp.c++/target-exceptions-throw-2-O0.C: New.
2025-04-14Add 'throw', dead code test cases for GCN, nvptx target and OpenACC, OpenMP ↵Thomas Schwinge2-0/+22
'target' offloading gcc/testsuite/ * g++.target/gcn/exceptions-throw-3.C: New. * g++.target/nvptx/exceptions-throw-3.C: Likewise. libgomp/ * testsuite/libgomp.c++/target-exceptions-throw-3.C: New. * testsuite/libgomp.oacc-c++/exceptions-throw-3.C: Likewise.
2025-04-14Add 'throw', caught test cases for GCN, nvptx target and OpenACC, OpenMP ↵Thomas Schwinge2-0/+26
'target' offloading gcc/testsuite/ * g++.target/gcn/exceptions-throw-2.C: New. * g++.target/nvptx/exceptions-throw-2.C: Likewise. libgomp/ * testsuite/libgomp.c++/target-exceptions-throw-2.C: New. * testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C: Likewise. * testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-GCN.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-nvptx.C: Likewise.
2025-04-14Add 'throw' test cases for GCN, nvptx target and OpenACC, OpenMP 'target' ↵Thomas Schwinge2-0/+32
offloading gcc/testsuite/ * g++.target/gcn/exceptions-throw-1.C: New. * g++.target/nvptx/exceptions-throw-1.C: Likewise. libgomp/ * testsuite/libgomp.c++/target-exceptions-throw-1.C: New. * testsuite/libgomp.c++/target-exceptions-throw-1-O0.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-throw-1.C: Likewise.
2025-04-14Add 'std::bad_cast' exception, dead code test cases for GCN, nvptx target ↵Thomas Schwinge2-0/+20
and OpenACC, OpenMP 'target' offloading gcc/testsuite/ * g++.target/gcn/exceptions-bad_cast-3.C: New. * g++.target/nvptx/exceptions-bad_cast-3.C: Likewise. libgomp/ * testsuite/libgomp.c++/target-exceptions-bad_cast-3.C: New. * testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C: Likewise.
2025-04-14Add 'std::bad_cast' exception, caught test cases for GCN, nvptx target and ↵Thomas Schwinge2-0/+24
OpenACC, OpenMP 'target' offloading gcc/testsuite/ * g++.target/gcn/exceptions-bad_cast-2.C: New. * g++.target/nvptx/exceptions-bad_cast-2.C: Likewise. libgomp/ * testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: New. * testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C: Likewise. * testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C: Likewise. * testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C: Likewise.
2025-04-14Add 'std::bad_cast' exception test cases for GCN, nvptx target and OpenACC, ↵Thomas Schwinge2-0/+30
OpenMP 'target' offloading gcc/testsuite/ * g++.target/gcn/exceptions-bad_cast-1.C: New. * g++.target/nvptx/exceptions-bad_cast-1.C: Likewise. libgomp/ * testsuite/libgomp.c++/target-exceptions-bad_cast-1.C: New. * testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C: Likewise.
2025-04-14Add test cases for exception handling constructs in dead code for GCN, nvptx ↵Thomas Schwinge2-0/+32
target and OpenMP 'target' offloading [PR118794] PR target/118794 gcc/testsuite/ * g++.target/gcn/exceptions-pr118794-1.C: New. * g++.target/nvptx/exceptions-pr118794-1.C: Likewise. libgomp/ * testsuite/libgomp.c++/target-exceptions-pr118794-1.C: New. * testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C: Likewise. * testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C: Likewise.
2025-04-14Add PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' ↵Thomas Schwinge2-0/+12
offloading" test cases [PR119692] ... documenting the status quo. PR c++/119692 gcc/testsuite/ * g++.target/gcn/pr119692-1-1.C: New. * g++.target/nvptx/pr119692-1-1.C: Likewise. libgomp/ * testsuite/libgomp.c++/pr119692-1-1.C: New. * testsuite/libgomp.c++/pr119692-1-2.C: Likewise. * testsuite/libgomp.c++/pr119692-1-3.C: Likewise. * testsuite/libgomp.c++/pr119692-1-4.C: Likewise. * testsuite/libgomp.c++/pr119692-1-5.C: Likewise. * testsuite/libgomp.oacc-c++/pr119692-1-1.C: Likewise. * testsuite/libgomp.oacc-c++/pr119692-1-2.C: Likewise. * testsuite/libgomp.oacc-c++/pr119692-1-3.C: Likewise.
2025-04-14Add 'g++.target/gcn/gcn.exp' for GCN-specific C++ test casesThomas Schwinge1-0/+56
Like 'gcc.target/gcn/gcn.exp' is modeled after 'gcc.dg/dg.exp', this new 'g++.target/gcn/gcn.exp' is modeled after 'g++.dg/dg.exp'. gcc/testsuite/ * g++.target/gcn/gcn.exp: New.
2025-04-14Polish 'dg-output-file' test logsThomas Schwinge1-2/+1
Per commit r15-8260-g563e6d926d9826d76895086d0c40a29dc90d66e5 "testsuite: Add support for dg-output-file directive", this currently produces test logs as follows: PASS: gcc.dg/dg-output-file-1.c (test for excess errors) PASS: dg-output-file-1-lp64.txt output file test PASS: gcc.dg/dg-output-file-1.c execution test PASS: cobol.dg/group2/COMP-6_arithmetic.cob -O0 (test for excess errors) PASS: COMP-6_arithmetic.out output file test PASS: cobol.dg/group2/COMP-6_arithmetic.cob -O0 execution test PASS: cobol.dg/group2/COMP-6_arithmetic.cob -O1 (test for excess errors) PASS: COMP-6_arithmetic.out output file test PASS: cobol.dg/group2/COMP-6_arithmetic.cob -O1 execution test [Etc.] Notice that the 'PASS: [...] output file test' lines easily produce duplicate test names, or might even produce PASS plus FAIL for the same test names. Make the "output file test" use the same "descriptive name" as the other parts, and get properly sorted with parallel-testing 'contrib/dg-extract-results.sh' processing: PASS: c-c++-common/zero-scratch-regs-leafy-2.c -Wc++-compat (test for excess errors) -PASS: dg-output-file-1-lp64.txt output file test PASS: gcc.dg/20000108-1.c (test for excess errors) [...] PASS: gcc.dg/devnull-dump.c (test for excess errors) PASS: gcc.dg/dg-output-file-1.c (test for excess errors) PASS: gcc.dg/dg-output-file-1.c execution test +PASS: gcc.dg/dg-output-file-1.c output file test PASS: gcc.dg/dg-test-1.c (test for excess errors) ..., and gets de-duplicated test names, for example: PASS: cobol.dg/group2/COMP-6_arithmetic.cob -O0 (test for excess errors) -PASS: COMP-6_arithmetic.out output file test +PASS: cobol.dg/group2/COMP-6_arithmetic.cob -O0 output file test PASS: cobol.dg/group2/COMP-6_arithmetic.cob -O0 execution test PASS: cobol.dg/group2/COMP-6_arithmetic.cob -O1 (test for excess errors) -PASS: COMP-6_arithmetic.out output file test +PASS: cobol.dg/group2/COMP-6_arithmetic.cob -O1 output file test PASS: cobol.dg/group2/COMP-6_arithmetic.cob -O1 execution test [Etc.] (Given that only ever a single 'dg-output-file' directive is active, don't print the output filename.) gcc/testsuite/ * lib/gcc-dg.exp (${tool}_load): Polish 'dg-output-file' test logs.
2025-04-14testsuite: Fix up ipa/pr119530.c testcase [PR119318]Jakub Jelinek1-2/+2
I'm seeing +FAIL: gcc.dg/ipa/pr119530.c execution test on i686-linux. The problem is that when long is just 32-bit and so is unsigned, the testcase then behaves differently and should abort. Fixed by making the argument long long instead. While at it, just in case I've changed type of d variable to signed char as well just in case there is -funsigned-char 8-bit int target or something similar. 2025-04-14 Jakub Jelinek <jakub@redhat.com> PR ipa/119318 * gcc.dg/ipa/pr119530.c (d): Change type from char to signed char. (e): Change argument type from long to long long.
2025-04-14expmed: Always use QImode for init_expmed set_zero_cost [PR119785]Jakub Jelinek1-1/+1
This is a regression on some targets introduced I believe by r6-2055 which added mode argument to set_src_cost. The problem here is that in the first iteration, mode is always QImode and we get as -Os zero cost set_src_cost (const0_rtx, QImode, false). But then we use the mode variable for iterating over int, partial int and vector int modes, so for the second iteration we call set_src_cost with mode which is at that time (machine_mode) (MAX_MODE_VECTOR_INT + 1). In the x86 case that happens to be V2HFmode and we don't crash (and compute the same 0 cost as we would for QImode). But e.g. in the SPARC case (machine_mode) (MAX_MODE_VECTOR_INT + 1) is MAX_MACHINE_MODE and that does all kinds of weird things especially when doing ubsan bootstrap. Fixed by always using QImode. 2025-04-14 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/119785 * expmed.cc (init_expmed): Always pass QImode rather than mode to set_src_cost passed to set_zero_cost.
2025-04-14cobol: Fix -fmax-errors option [PR119776]Jakub Jelinek4-12/+1
There seems to be inconsistency in the -fmax-errors option naming. It is a generic option in common.opt (so applies to all languages) but with the = character in it. The gcobol.1 man page in one spot documents the generic option (in the syntax, -fmax-errors=nerror) but in another spot without the = character. In common.opt it is fmax-errors= Common Joined RejectNegative UInteger Var(flag_max_errors) -fmax-errors=<number> Maximum number of errors to report. I hope the cobol addition is just a mistake, having -fmax-errors variant without = character when Joined Separate would allow to specify -fmax-errors 10 with the same meaning as -fmax-errors=10 but also -fmax-errors10 with the same meaning which is just weird. Also, there is no UInteger and RejectNegative on it, so one can also specific -fno-max-errors42 or -fmax-errors blah. So, unless the spelling without = is intentional, here is a patch to just remove it, the common option already should have arranged for flag_max_errors to be set to the right number. Or if it is intentional, I guess we'd need to at least add RejectNegative UInteger (plus using atoi is generally undesirable anywhere in the compiler because it does no error checking). And the man page would need to be updated to specify both forms. 2025-04-14 Jakub Jelinek <jakub@redhat.com> PR cobol/119776 * lang.opt (fmax-errors): Remove. * lang.opt.urls: Regenerate. * cobol1.cc (cobol_langhook_handle_option) <case OPT_fmax_errors>: Remove. * gcobol.1: Document -fmax-errors=nerror rather than -fmax-errors nerror.
2025-04-14cobol: Fix up COBOL -include [PR119777]Jakub Jelinek2-3/+3
I was looking through options.cc diff between GCC 14 and 15, looking for entries with added CL_Cobol where at least one other language is present and was present before too. Besides the -fsyntax-only changes this is the only other one I found, COBOL adds Var(cobol_include) to something which didn't have a Var at all before and IMHO it is actively harmful. Because one can specify multiple -include file1 -include file2 options, both in C/C++ etc. and in COBOL as well (as documented in the man page). A Var can track just one entry. cobol_langhook_handle_option should use arg instead. 2025-04-14 Jakub Jelinek <jakub@redhat.com> PR cobol/119777 * lang.opt (include): Remove Var(cobol_include). * cobol1.cc (cobol_langhook_handle_option) <case OPT_include>: Use arg instead of cobol_include.
2025-04-14cobol: Drop -fsyntax-only from COBOL lang.opt [PR119777]Jakub Jelinek2-7/+0
The comment is incorrect, fsyntax-only is not documented in c.opt, but in common.opt: fsyntax-only Common Var(flag_syntax_only) Check for syntax errors, then stop. and as such it applies to all languages, so adding CL_Cobol to the CL_COMMON is both unnecessary and because of RejectNegative which contradicts the generic option very harmful, because it makes -fno-syntax-only invalid for all languages. Fixed by just dropping it. 2025-04-14 Jakub Jelinek <jakub@redhat.com> PR cobol/119777 * lang.opt (fsyntax-only): Remove. * lang.opt.urls: Regenerate.
2025-04-14pretty-print, expand: Print [must tail call] for CALL_EXPRs and fix up ↵Jakub Jelinek2-5/+7
maybe_complain_about_tail_call [PR119718] Andrew P. mentioned earlier he'd like to see in the dump files a note whether it was a failed must tail call or not. We already print that on the tailc/musttail pass side, because print_gimple_stmt prints [must tail call] after the musttail calls. The first hunk below does it for GENERIC CALL_EXPRs too (which is needed for the expand diagnostics). That isn't enough though, because the error on it was done first and then CALL_EXPR_MUST_TAIL_CALL flag was cleared, so the dump didn't have it anymore. I've reordered the dump printing with error, so that it works properly. 2025-04-14 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/119718 * tree-pretty-print.cc (dump_generic_node) <case CALL_EXPR>: Dump also CALL_EXPR_MUST_TAIL_CALL flag. * calls.cc (maybe_complain_about_tail_call): Emit error about CALL_EXPR_MUST_TAIL_CALL only after emitting dump message, not before it.
2025-04-14gccrs: lang-items: Add ManuallyDrop<T>Arthur Cohen2-0/+3
gcc/rust/ChangeLog: * util/rust-lang-item.h: Add new manually_drop lang item. * util/rust-lang-item.cc: Likewise.
2025-04-14gccrs: attributes: Handle external tool annotations like rustfmt::Arthur Cohen4-3/+8
gcc/rust/ChangeLog: * util/rust-attribute-values.h: Add RUSTFMT value. * util/rust-attributes.cc: Define the attribute. * util/rust-attributes.h (enum CompilerPass): Add EXTERNAL variant. * expand/rust-macro-builtins.cc: Fix formatting.
2025-04-14gccrs: nr2.0: Only insert derive macros if they existArthur Cohen1-4/+3
This causes an assertion failure when compiling core with nr2.0, but should probably be improved. I'm not sure how this code enables built-in derive macros to be resolved so this is a temporary fix. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes): Remove assertion.
2025-04-14gccrs: attributes: Add missing attributes used in `core`Arthur Cohen3-1/+45
gcc/rust/ChangeLog: * util/rust-attribute-values.h: Add missing attributes. * util/rust-attributes.cc: Likewise. * util/rust-attributes.h (enum CompilerPass): Mention adding something for const functions.
2025-04-14gccrs: Add `#[track_caller]` as known attributebeamandala4-1/+10
gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (MacroBuiltin::builtin_transcribers): Add entry for track_caller. * util/rust-attribute-values.h: add `TRACK_CALLER` attribute. * util/rust-attributes.cc: add `track_caller` attribute definition. gcc/testsuite/ChangeLog: * rust/compile/track_caller.rs: New test. Signed-off-by: Bhavesh Mandalapu <mandalapubhavesh@gmail.com>
2025-04-14gccrs: install.texi: Mention Rust requirement for building gccrsArthur Cohen1-0/+6
Addresses PR#117869 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117869 gcc/ChangeLog: * doc/install.texi: Add requirements for building gccrs.
2025-04-14gccrs: Fix const checking of enum discriminantsOwen Avery3-0/+14
gcc/rust/ChangeLog: * checks/errors/rust-const-checker.cc (ConstChecker::visit): Visit the enum items of enums. * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Resolve enum discriminants during nr1.0. gcc/testsuite/ChangeLog: * rust/compile/enum_discriminant2.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-04-14gccrs: format_args: Allow extraneous commas, improve safetyArthur Cohen2-0/+54
gcc/rust/ChangeLog: * expand/rust-macro-builtins-format-args.cc (format_args_parse_arguments): Improve safety, allow extra commas after end of argument list. gcc/testsuite/ChangeLog: * rust/compile/format_args_extra_comma.rs: New test.
2025-04-14gccrs: expansion: Desugar doc comments into attributes before expansionArthur Cohen7-1/+234
gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::expand_decl_macro): Call into TokenTreeDesugar. * expand/rust-token-tree-desugar.cc: New file. * expand/rust-token-tree-desugar.h: New file. * Make-lang.in: Compile them. gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/macro-issue3709-1.rs: New test. * rust/compile/macros/mbe/macro-issue3709-2.rs: New test.
2025-04-14gccrs: expansion: Only add fragments if the matcher succeededArthur Cohen2-7/+88
gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::match_n_matches): Do not insert fragments and substack fragments if the matcher failed. gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/macro-issue3708.rs: New test.
2025-04-14gccrs: session: Desugar question mark operator after expansion instead.Arthur Cohen1-1/+1
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Call the visitor later in the pipeline.
2025-04-14gccrs: ast: Add get_locus() to DelimTokenTreeArthur Cohen1-0/+1
gcc/rust/ChangeLog: * ast/rust-ast.h (DelimTokenTree::get_locus): New function.
2025-04-14gccrs: ast: Support outer attributes for AST::RangeExprArthur Cohen1-6/+6
gcc/rust/ChangeLog: * ast/rust-expr.h (class RangeExpr): Add empty outer attributes and allow getting them and setting them.
2025-04-14gccrs: nr2.0: Do not resolve modules this run if they are unloadedArthur Cohen1-1/+11
Instead, mark the visitor as dirty and wait for the next round of the fixed point to take care of them. This avoids issues with module items being loaded while not being stripped yet. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Return if module is unloaded.
2025-04-14gccrs: typecheck: Properly select methods when dealing with specializationArthur Cohen3-24/+172
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (is_default_fn): New. (emit_ambiguous_resolution_error): New. (handle_multiple_candidates): Properly handle multiple candidates in the case of specialization. (TypeCheckExpr::visit): Call `handle_multiple_candidates`. gcc/testsuite/ChangeLog: * rust/execute/torture/min_specialization2.rs: New test. * rust/execute/torture/min_specialization3.rs: New test.
2025-04-14rust: Add comment inside block [PR119342]Andrew Pinski1-0/+2
Inside a BLOCK node, all of the variables of the scope/block are chained together and that connects them to the block. This just adds a comment to that effect as reading the code it is not so obvious why they need to be chained together. gcc/rust/ChangeLog: PR rust/119342 * rust-gcc.cc (block): Add comment on why chaining the variables of the scope toether. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-14rust: use range for inside rust-gcc.cc [PR119341]Andrew Pinski1-36/+21
There are some places inside rust-gcc.cc which are candidates to use range for instead of iterators directly. This changes the locations I saw and makes the code slightly more readable. gcc/rust/ChangeLog: PR rust/119341 * rust-gcc.cc (function_type): Use range fors. (function_type_variadic): Likewise. (fill_in_fields): Likewise. (statement_list): Likewise. (block): Likewise. (block_add_statements): Likewise. (function_set_parameters): Likewise. (write_global_definitions): Likewise. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-14rust: Use error_operand_p in rust-gcc.ccAndrew Pinski1-101/+88
Just a simple cleanupof the code to use error_operand_p instead of directly comparing against error_mark_node. This also moves some cdoe around when dealing with error_operand_p just to be faster and/or slightly tighten up the code slightly. gcc/rust/ChangeLog: * rust-gcc.cc (Bvariable::get_tree): Use error_operand_p. (pointer_type): Likewise. (reference_type): Likewise. (immutable_type): Likewise. (function_type): Likewise. (function_type_variadic): Likewise. Cleanup the check for receiver.type first. (function_ptr_type): Use error_operand_p. (fill_in_fields): Likewise. (fill_in_array): Likewise. (named_type): Likewise. (type_size): Likewise. (type_alignment): Likewise. (type_field_alignment): Likewise. (type_field_offset): Likewise. (zero_expression): Likewise. (float_constant_expression): Likewise. (convert_expression): Likewise. (struct_field_expression): Likewise. (compound_expression): Likewise. (conditional_expression): Likewise. (negation_expression): Likewise. (arithmetic_or_logical_expression): Likewise. (arithmetic_or_logical_expression_checked): Likewise. (comparison_expression): Likewise. (lazy_boolean_expression): Likewise. (constructor_expression): Likewise. (array_constructor_expression): Likewise. (array_index_expression): Likewise. (call_expression): Likewise. (init_statement): Likewise. (assignment_statement): Likewise. (return_statement): Likewise. (exception_handler_statement): Likewise. (if_statement): Likewise. (compound_statement): Likewise. Tighten up the code, removing t variable. (statement_list): Use error_operand_p. (block): Likewise. (block_add_statements): Likewise. (convert_tree): Likewise. (global_variable): Likewise. (global_variable_set_init): Likewise. (local_variable): Likewise. (parameter_variable): Likewise. (static_chain_variable): Likewise. (temporary_variable): Likewise. (function): Likewise. Tighten up the code. (function_defer_statement): Use error_operand_p. (function_set_parameters): Use error_operand_p. (write_global_definitions): Use error_operand_p. Tighten up the code around the loop. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-14rust: Use FLOAT_TYPE_P instead of manual checkingAndrew Pinski1-4/+4
This moves is_floating_point over to using FLOAT_TYPE_P instead of manually checking. Note before it would return true for all COMPLEX_TYPE but complex types' inner type could be integral. Also fixes up the comment to be in more of the GNU style. Bootstrapped and tested on x86_64-linux-gnu. gcc/rust/ChangeLog: * rust-gcc.cc (is_floating_point): Use FLOAT_TYPE_P instead of manually checking the type. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-14testcase: Add testcase for already fixed PR [PR118476]Andrew Pinski1-0/+14
This testcase was fixed by r15-3052-gc7b76a076cb2c6ded but is a testcase that failed in a different fashion and a much older failure than the one added with r15-3052. Pushed as obvious after a quick test. PR tree-optimization/118476 gcc/testsuite/ChangeLog: * gcc.dg/torture/pr118476-1.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-14c++: wrong targs in satisfaction diagnostic context line [PR99214]Patrick Palka2-1/+16
In the three-parameter version of satisfy_declaration_constraints, when 't' isn't the most general template, then 't' won't correspond with 'args' after we augment the latter via add_outermost_template_args, and so the instantiation context that we push via push_tinst_level isn't quite correct: 'args' is a complete set of template arguments, but 't' is not necessarily the most general template. This manifests as misleading diagnostic context lines when issuing a satisfaction failure error, e.g. the below testcase without this patch we emit: In substitution of '... void A<int>::f<U>() ... [with U = int]' and with this patch we emit: In substitution of '... void A<int>::f<U>() ... [with U = char]'. This patch fixes this by passing the original 'args' to push_tinst_level, which ought to properly correspond to 't'. PR c++/99214 gcc/cp/ChangeLog: * constraint.cc (satisfy_declaration_constraints): Pass the original ARGS to push_tinst_level. gcc/testsuite/ChangeLog: * g++.dg/concepts/diagnostic20.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-04-14APX: Don't use red-zone with 32 GPRs and no caller-saved registersH.J. Lu3-0/+189
Don't use red-zone when there are no caller-saved registers with 32 GPRs since 128-byte red-zone is too small for 31 GPRs. gcc/ PR target/119784 * config/i386/i386.cc (ix86_using_red_zone): Don't use red-zone with 32 GPRs and no caller-saved registers. gcc/testsuite/ PR target/119784 * gcc.target/i386/pr119784a.c: New test. * gcc.target/i386/pr119784b.c: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-14ipa-cp: Use the collected pass-through types to propgate constants (PR118097)Martin Jambor1-42/+52
This patch revisits the fix for PR 118097 and instead of deducing the necessary operation type it just uses the value collected and streamed by an earlier patch. It is bigger than the ones for propagating value ranges and known bits because we track constants both in parameters themselves and also in memory they point to or within aggregates, we clone functions for them and we do fancy things for some types of recursive calls. In the case of constants in aggregates or passed by reference, the situation should not change because the code creating jump functions for them does not allow type-casts, unlike for the plain ones. However, this patch changes how we handle them for the sake of consistency and also so that we can try and eliminate this limitation in the next stage 1. gcc/ChangeLog: 2025-03-20 Martin Jambor <mjambor@suse.cz> PR ipa/118097 * ipa-cp.cc (ipa_get_jf_arith_result): Require res_operand for anything except NOP_EXPR or ADDR_EXPR, document it and remove the code trying to deduce it. (ipa_value_from_jfunc): Use the stored and streamed type of arithmetic pass-through functions. (ipa_agg_value_from_jfunc): Use the stored and streamed type of arithmetic pass-through functions, convert to the type used to store the value if necessary. (get_val_across_arith_op): New parameter op_type, pass it to ipa_get_jf_arith_result. (propagate_vals_across_arith_jfunc): New parameter op_type, pass it to get_val_across_arith_op. (propagate_vals_across_pass_through): Use the stored and streamed type of arithmetic pass-through functions. (propagate_aggregate_lattice): Likewise. (push_agg_values_for_index_from_edge): Use the stored and streamed type of arithmetic pass-through functions, convert to the type used to store the value if necessary.
2025-04-14ipa-cp: Use the stored and streamed pass-through types in ipa-vr (PR118785)Martin Jambor1-26/+2
This patch revisits the fix for PR 118785 and intead of deducing the necessary operation type it just uses the value collected and streamed by an earlier patch. The main advantage is that we do not rely on expr_type_first_operand_type_p enumarating all operations. gcc/ChangeLog: 2025-03-20 Martin Jambor <mjambor@suse.cz> PR ipa/118785 * ipa-cp.cc (ipa_vr_intersect_with_arith_jfunc): Use the stored and streamed type of arithmetic pass-through functions.
2025-04-14ipa-cp: Make dumping of widest_ints even more saneMartin Jambor1-4/+11
This patch just introduces a form of dumping of widest ints that only have zeros in the lowest 128 bits so that instead of printing thousands of f's the output looks like: Bits: value = 0xffff, mask = all ones folled by 0xffffffffffffffffffffffffffff0000 and then makes sure we use the function not only to print bits but also to print masks where values like these can also occur. gcc/ChangeLog: 2025-03-21 Martin Jambor <mjambor@suse.cz> * ipa-cp.cc (ipcp_print_widest_int): Also add a truncated form of dumping of widest ints which only have zeros in the lowest 128 bits. Update the comment. (ipcp_bits_lattice::print): Also dump the mask using ipcp_print_widest_int. (ipcp_store_vr_results): Likewise.
2025-04-14ipa-cp: Make propagation of bits in IPA-CP aware of type conversions (PR119318)Martin Jambor3-5/+75
After the propagation of constants and value ranges, it turns out that the propagation of known bits also needs to be made aware of any intermediate types in which any arithmetic operations are made and must limit its precision there. This implements just that, using the newly collected and streamed types of the operations involved. This version removed the extra check that the type of a formal parameter is known pointed out in Honza in his review because I agree it is currently always known. I have also added the testcase of PR 119530 which is a duplicate of this bug. gcc/ChangeLog: 2025-04-11 Martin Jambor <mjambor@suse.cz> PR ipa/119318 * ipa-cp.cc (ipcp_bits_lattice::meet_with_1): Set all mask bits not covered by precision to one. (ipcp_bits_lattice::meet_with): Likewise. (propagate_bits_across_jump_function): Use the stored operation type to perform meet with other lattices. gcc/testsuite/ChangeLog: 2025-04-11 Martin Jambor <mjambor@suse.cz> PR ipa/119318 * gcc.dg/ipa/pr119318.c: New test. * gcc.dg/ipa/pr119530.c: Likwise.
2025-04-14ipa: Record and stream result types of arithemetic jump functionsMartin Jambor4-14/+80
In order to replace the use of somewhat unweildy expr_type_first_operand_type_p we need to record and stream the types of results of operations recorded in arithmetic jump functions. This is necessary so that we can then simulate them at the IPA stage with the corresponding precision and signedness. This patch does the recorsing and streaming, the following one adds the use of the date. Per Honza's request this version also checks that we do not put VLA types into the global LTO stream, even though I was not able to actually craft a test-case that would do that without them. gcc/ChangeLog: 2025-04-11 Martin Jambor <mjambor@suse.cz> PR ipa/118097 PR ipa/118785 PR ipa/119318 * lto-streamer.h (lto_variably_modified_type_p): Declare. * ipa-prop.h (ipa_pass_through_data): New field op_type. (ipa_get_jf_pass_through_op_type): New function. * ipa-prop.cc: Include lto-streamer.h. (ipa_dump_jump_function): Dump also pass-through operation types, if any. Dump pass-through operands only if not NULL. (ipa_set_jf_simple_pass_through): Set op_type accordingly. (compute_complex_assign_jump_func): Set op_type of arithmetic pass-through jump_functions. (analyze_agg_content_value): Update lhs when walking assighment copies. Set op_type of aggregate arithmetic pass-through jump_functions. (update_jump_functions_after_inlining): Also transfer the operation type from the source arithmentic pass-through jump function to the destination jump function. (ipa_write_jump_function): Stream also the op_type when necessary. (ipa_read_jump_function): Likewise. (ipa_agg_pass_through_jf_equivalent_p): Also compare operation types. * lto-streamer-out.cc (lto_variably_modified_type_p): Make public.
2025-04-14tree-optimization/119757 - reject mixed mask/non-mask ldst SLPRichard Biener2-8/+33
The following makes sure to not mix masked/non-masked stmts when forming a SLP node. PR tree-optimization/119757 * tree-vect-slp.cc (vect_build_slp_tree_1): Record and compare whether a stmt uses a maks. * gcc.dg/vect/pr119757.c: New testcase.
2025-04-14tree-optimization/119778 - properly mark abnormal edge sources during inliningRichard Biener2-2/+25
When inlining a call that abnormally transfers control-flow we make all inlined calls that can possibly transfer abnormal control-flow do so as well. But we failed to mark the calls as altering control-flow. This results in inconsistent behavior later and possibly wrong-code (we'd eventually prune those edges). PR tree-optimization/119778 * tree-inline.cc (copy_edges_for_bb): Mark calls that are source of abnormal edges as altering control-flow. * g++.dg/torture/pr119778.C: New testcase.
2025-04-14PR modula2/119779 ASM examples no longer workGaius Mulley6-4/+106
This patch introduces four dejagnu tests matching four documentation examples. Both asm examples are added and only built if the x86_64 target is available. The other two are hello world using libc and StrIO. The doc/gm2.texi asm examples are changed to use eax rather than rax. gcc/ChangeLog: PR modula2/119779 * doc/gm2.texi (Interface to assembly language): Use eax rather than rax in both examples. gcc/testsuite/ChangeLog: PR modula2/119779 * gm2.dg/doc/examples/pass/doc-examples-pass.exp: New test. * gm2.dg/doc/examples/pass/exampleadd.mod: New test. * gm2.dg/doc/examples/pass/exampleadd2.mod: New test. * gm2.dg/doc/examples/pass/hello.mod: New test. * gm2.dg/doc/examples/pass/hellopim.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2025-04-14driver: On linux hosts disable ASLR during -freport-bug [PR119727]Jakub Jelinek4-2/+67
Andi had a useful comment that even with the PR119727 workaround to ignore differences in libbacktrace printed addresses, it is still better to turn off ASLR when easily possible, e.g. in case some address leaks in somewhere in the ICE message elsewhere, or to verify the ICE doesn't depend on a particular library/binary load addresses. The following patch adds a configure check and uses personality syscall to turn off randomization for further -freport-bug subprocesses. 2025-04-14 Jakub Jelinek <jakub@redhat.com> PR driver/119727 * configure.ac (HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE): New check. * gcc.cc: Include sys/personality.h if HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE is defined. (try_generate_repro): Call personality (personality (0xffffffffU) | ADDR_NO_RANDOMIZE) if HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE is defined. * config.in: Regenerate. * configure: Regenerate.
2025-04-14Add testcase for PR lto/119792Eric Botcazou2-0/+24
It demonstrates a serious LTO breakage for the Ada language. gcc/testsuite/ PR lto/119792 * gnat.dg/lto29.adb: New test. * gnat.dg/lto29_pkg.ads: New helper.
2025-04-14Daily bump.GCC Administrator6-1/+98