extract_bit_field can't handle extraction of non-mode precision
from complex mode operands which don't live in memory, e.g. gen_lowpart
crashes on those.
The following patch in that case defers the extract_bit_field call
until op0 is forced into memory.
2024-11-19 Jakub Jelinek <jakub@redhat.com>
PR middle-end/117458
* expr.cc (expand_expr_real_1) <case VIEW_CONVERT_EXPR>: Don't
call extract_bit_field if op0 has complex mode and isn't a MEM,
instead first force op0 into memory and then call extract_bit_field.
* gcc.dg/bitint-116.c: New test.
The following patch handles PAREN_EXPR in bitint lowering, and handles it
as an optimization barrier, so that temporary arithmetics from PAREN_EXPR
isn't mixed with temporary arithmetics from outside of the PAREN_EXPR.
2024-11-19 Jakub Jelinek <jakub@redhat.com>
PR middle-end/117459
* gimple-lower-bitint.cc (bitint_large_huge::handle_stmt,
bitint_large_huge::lower_stmt): Handle PAREN_EXPR.
* gcc.dg/torture/bitint-74.c: New test.
r15-4601 added match.pd simplification of some TRUNC_DIV_EXPR expressions
into EXACT_DIV_EXPR, so bitintlower can now encounter even those.
From bitint lowering POV the fact that the division will be exact
doesn't matter, we still need to call at runtime the __divmodbitint4
API and it wouldn't simplify there anything to know it is exact if
we duplicated that, so the following patch lowers EXACT_DIV_EXPR exactly
as TRUNC_DIV_EXPR.
I think we don't need to backport this unless something introduces
EXACT_DIV_EXPR on BITINT_TYPEd expressions on the 14 branch as well.
2024-11-19 Jakub Jelinek <jakub@redhat.com>
PR middle-end/117571
* gimple-lower-bitint.cc (bitint_large_huge::lower_muldiv_stmt,
bitint_large_huge::lower_stmt, stmt_needs_operand_addr,
build_bitint_stmt_ssa_conflicts, gimple_lower_bitint): Handle
EXACT_DIV_EXPR like TRUNC_DIV_EXPR.
* gcc.dg/bitint-114.c: New test.
pow-to-ldexp.c checks for calls to __builtin_ldexpf and __builtin_ldexpl, which
will only be performed when the compiler knows the target has a C99 libm
available.
Modified the test to add a C99 runtime requirement.
This fixes the failure on arm-eabi targets for this test case.
Signed-off-by: Soumya AR <soumyaa@nvidia.com>
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pow-to-ldexp.c: Require c99_runtime.
After we create a isolated folder to hold all SAT scalar test,
we have fully control of what optimization options passing to
the testcase. Thus, it is better to remove the unnecessary
work around for flto option, as well as the -O3 option for
each cases. The riscv.exp will pass sorts of different optimization
options for each case.
The below test suites are passed for this patch.
* The rv64gcv fully regression test.
It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/sat/sat_u_trunc-1-u16.c: Remove flto
dg-skip workaround and -O3 option.
* gcc.target/riscv/sat/sat_u_trunc-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u8.c: Ditto.
* gcc.target/riscv/sat/scalar_sat_unary.h: New test.
Signed-off-by: Pan Li <pan2.li@intel.com>
If a CodeView struct, class, or union has as a member an anonymous
struct, class, or union, this gets flattened. The sub-struct's members
will appear as if they were part of their parent.
For this, we move part of get_type_num_struct into a new function
add_to_fieldlist, which also handles creating an LF_INDEX overflow item
if an LF_FIELDLIST grows too large. This is because add_struct_member
now calls itself recursively, and so needs to handle overflows itself.
gcc/
* dwarf2codeview.cc (add_to_fieldlist): New function.
(add_struct_member): Call recursively to flatten structs, and call
add_to_fieldlist.
(add_struct_static_member): Call add_to_fieldlist.
(add_struct_function): Call add_to_fieldlist.
(add_struct_inheritance): Call add_to_fieldlist.
(add_struct_nested_type): Call add_to_fieldlist.
(get_type_num_struct): Move code to add_to_fieldlist, and move
responsibility for this to subfunctions.
If the DIE for a struct, class, or union contains a nested type, add a
LF_NESTTYPE entry to its field list recording this.
Plus if we use a nested type, make sure that its parent also gets
defined. This may entail adding a forward definition and creating a
deferred type, so we need to call flush_deferred_types in
codeview_debug_finish as well.
gcc/
* dwarf2codeview.cc (enum cv_leaf_type): Add LF_NESTTYPE.
(struct codeview_subtype): Add lf_nesttype to union.
(flush_deferred_types): Add declaration.
(write_lf_fieldlist): Handle LF_NESTTYPE.
(codeview_debug_finish): Call flush_deferred_types.
(add_struct_nested_type): New function.
(get_type_num_struct): Call add_struct_nested_type, and if nested make
that parent is added.
As reported in bug 112556, GCC wrongly rejects conversion of null
pointer constants with bool or enum type to pointers in
convert_for_assignment (assignment, initialization, argument passing,
return). Fix the code there to allow BOOLEAN_TYPE and ENUMERAL_TYPE;
it already allowed INTEGER_TYPE and BITINT_TYPE.
This bug (together with -std=gnu23 meaning false has type bool rather
than int) has in turn resulted in people thinking they need to fix
code using false as a null pointer constant for C23 compatibility.
While such a usage is certainly questionable, it has nothing to do
with C23 compatibility and the right place for warnings about such
usage is -Wzero-as-null-pointer-constant. I think it would be
appropriate to extend -Wzero-as-null-pointer-constant to cover
BOOLEAN_TYPE, ENUMERAL_TYPE and BITINT_TYPE (in all the various
contexts in which that option generates warnings), though this patch
doesn't do anything about that option.
Bootstrapped with no regressions for x86-64-pc-linux-gnu.
PR c/112556
gcc/c/
* c-typeck.cc (convert_for_assignment): Allow conversion of
ENUMERAL_TYPE and BOOLEAN_TYPE null pointer constants to pointers.
gcc/testsuite/
* gcc.dg/c11-null-pointer-constant-1.c,
gcc.dg/c23-null-pointer-constant-1.c: New tests.
This patch adds a new "sarif-replay" command-line tool for
viewing .sarif files. It uses libdiagnostics to "replay"
any diagnostics found in the .sarif files in text form as if
they were GCC diagnostics.
contrib/ChangeLog:
PR other/96032
* regenerate-sarif-spec-index.py: New file.
gcc/ChangeLog:
PR other/96032
* Makefile.in (lang_checks): If libdiagnostics is enabled, add
check-sarif-replay.
(SARIF_REPLAY_OBJS): New.
(ALL_HOST_OBJS): If libdiagnostics is enabled, add
$(SARIF_REPLAY_OBJS).
(sarif-replay): New.
(install-libdiagnostics): Add sarif-replay to deps, and install
it.
* configure: Regenerate.
* configure.ac (check_languages): If libdiagnostics is enabled,
add check-sarif-replay.
(LIBDIAGNOSTICS): If libdiagnostics is enabled, add sarif-replay.
* doc/install.texi (--enable-libdiagnostics): Note that it also
enables sarif-replay.
* libsarifreplay.cc: New file.
* libsarifreplay.h: New file.
* sarif-replay.cc: New file.
* sarif-spec-urls.def: New file.
gcc/testsuite/ChangeLog:
PR other/96032
* lib/gcc-dg.exp (gcc-dg-test-1): Add "replay-sarif".
* lib/sarif-replay-dg.exp: New file.
* lib/sarif-replay.exp: New file.
* sarif-replay.dg/2.1.0-invalid/3.1-not-an-object.sarif: New test.
* sarif-replay.dg/2.1.0-invalid/3.11.11-malformed-placeholder.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.11.11-missing-arguments-for-placeholders.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.11.11-not-enough-arguments-for-placeholders.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.13.2-no-version.sarif: New test.
* sarif-replay.dg/2.1.0-invalid/3.13.2-version-not-a-string.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.13.4-bad-runs.sarif: New test.
* sarif-replay.dg/2.1.0-invalid/3.13.4-no-runs.sarif: New test.
* sarif-replay.dg/2.1.0-invalid/3.13.4-non-object-in-runs.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.27.10-bad-level.sarif: New test.
* sarif-replay.dg/2.1.0-unhandled/3.27.10-none-level.sarif: New test.
* sarif-replay.dg/2.1.0-valid/error-with-note.sarif: New test.
* sarif-replay.dg/2.1.0-valid/escaped-braces.sarif: New test.
* sarif-replay.dg/2.1.0-valid/null-runs.sarif: New test.
* sarif-replay.dg/2.1.0-valid/signal-1.c.sarif: New test.
* sarif-replay.dg/2.1.0-valid/spec-example-1.sarif: New test.
* sarif-replay.dg/2.1.0-valid/spec-example-2.sarif: New test.
* sarif-replay.dg/2.1.0-valid/spec-example-3.sarif: New test.
* sarif-replay.dg/2.1.0-valid/spec-example-4.sarif: New test.
* sarif-replay.dg/2.1.0-valid/tutorial-example.sarif: New test.
* sarif-replay.dg/dg.exp: New script.
* sarif-replay.dg/malformed-json/array-missing-comma.sarif: New test.
* sarif-replay.dg/malformed-json/array-with-trailing-comma.sarif:
New test.
* sarif-replay.dg/malformed-json/bad-token.sarif: New test.
* sarif-replay.dg/malformed-json/object-missing-comma.sarif: New test.
* sarif-replay.dg/malformed-json/object-with-trailing-comma.sarif:
New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This patch implements JSON parsing support.
It's based on the parsing parts of the patch I posted here:
https://gcc.gnu.org/legacy-ml/gcc-patches/2017-08/msg00417.html
with the parsing moved to a separate source file and header, heavily
rewritten to capture source location information for JSON values, and
to capture errors via a result template.
I also added optional support for C and C++ style comments, which is
extremely useful in DejaGnu tests.
gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add json-parsing.o.
* json-parsing.cc: New file.
* json-parsing.h: New file.
* json.cc (selftest::assert_print_eq): Remove "static".
* json.h (json::array::begin): New.
(json::array::end): New.
(json::array::length): New.
(json::array::get): New.
(is_a_helper <json::value *>::test): New.
(is_a_helper <const json::value *>::test): New.
(is_a_helper <json::object *>::test): New.
(is_a_helper <const json::object *>::test): New.
(is_a_helper <json::array *>::test): New.
(is_a_helper <const json::array *>::test): New.
(is_a_helper <json::float_number *>::test): New.
(is_a_helper <const json::float_number *>::test): New.
(is_a_helper <json::integer_number *>::test): New.
(is_a_helper <const json::integer_number *>::test): New.
(is_a_helper <json::string *>::test): New.
(is_a_helper <const json::string *>::test): New.
(selftest::assert_print_eq): New decl.
* selftest-run-tests.cc (selftest::run_tests): Call
selftest::json_parser_cc_tests.
* selftest.h (selftest::json_parser_cc_tests): New decl.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This patch adds a new libdiagnostics shared library available as
part of the GCC build via --enable-libdiagnostics when
configuring GCC.
It combines the following patches from:
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668632.html
[PATCH 1/8] libdiagnostics v4: header
[PATCH 2/8] libdiagnostics v4: implementation
[PATCH 3/8] libdiagnostics: add API docs
[PATCH 4/8] libdiagnostics v4: add C++ wrapper API
[PATCH 6/8] libdiagnostics v4: test suite
ChangeLog:
* configure.ac (--enable-libdiagnostics): New.
* configure: Regenerate.
gcc/ChangeLog:
* configure.ac (check_languages): Add check-libdiagnostics.
(--enable-libdiagnostics): New.
* configure: Regenerate.
* Makefile.in (enable_libdiagnostics): New.
(lang_checks): If libdiagnostics is enabled, add
check-libdiagnostics.
(ALL_HOST_OBJS): If libdiagnostics is enabled, add
$(libdiagnostics_OBJS).
(start.encap): Add LIBDIAGNOSTICS.
(libdiagnostics_OBJS): New.
(LIBDIAGNOSTICS_VERSION_NUM): New, adapted from code in
jit/Make-lang.in.
(LIBDIAGNOSTICS_MINOR_NUM): Likewise.
(LIBDIAGNOSTICS_RELEASE_NUM): Likewise.
(LIBDIAGNOSTICS_FILENAME): Likewise.
(LIBDIAGNOSTICS_IMPORT_LIB): Likewise.
(libdiagnostics): Likewise.
(LIBDIAGNOSTICS_AGE): Likewise.
(LIBDIAGNOSTICS_BASENAME): Likewise.
(LIBDIAGNOSTICS_SONAME): Likewise.
(LIBDIAGNOSTICS_LINKER_NAME): Likewise.
(LIBDIAGNOSTICS_COMMA): Likewise.
(LIBDIAGNOSTICS_VERSION_SCRIPT_OPTION): Likewise.
(LIBDIAGNOSTICS_SONAME_OPTION): Likewise.
(LIBDIAGNOSTICS_SONAME_SYMLINK): Likewise.
(LIBDIAGNOSTICS_LINKER_NAME_SYMLINK): Likewise.
(LIBDIAGNOSTICS_FILENAME): Likewise.
(libdiagnostics.serial): Likewise.
(LIBDIAGNOSTICS_EXTRA_OPTS): Likewise.
(install): If libdiagnostics is enabled, add
install-libdiagnostics.
(libdiagnostics.install-headers): New.
(libdiagnostics.install-common): New, adapted from code in
jit/Make-lang.in.
(install-libdiagnostics): New.
* diagnostic-format-text.h
(diagnostic_text_output_format::get_location_text): Make public.
* doc/install.texi (--enable-libdiagnostics): New.
* doc/libdiagnostics/Makefile: New file.
* doc/libdiagnostics/conf.py: New file.
* doc/libdiagnostics/index.rst: New file.
* doc/libdiagnostics/make.bat: New file.
* doc/libdiagnostics/topics/diagnostic-manager.rst: New file.
* doc/libdiagnostics/topics/diagnostics.rst: New file.
* doc/libdiagnostics/topics/execution-paths.rst: New file.
* doc/libdiagnostics/topics/fix-it-hints.rst: New file.
* doc/libdiagnostics/topics/index.rst: New file.
* doc/libdiagnostics/topics/logical-locations.rst: New file.
* doc/libdiagnostics/topics/message-formatting.rst: New file.
* doc/libdiagnostics/topics/metadata.rst: New file.
* doc/libdiagnostics/topics/physical-locations.rst: New file.
* doc/libdiagnostics/topics/retrofitting.rst: New file.
* doc/libdiagnostics/topics/sarif.rst: New file.
* doc/libdiagnostics/topics/text-output.rst: New file.
* doc/libdiagnostics/topics/ux.rst: New file.
* doc/libdiagnostics/tutorial/01-hello-world.rst: New file.
* doc/libdiagnostics/tutorial/02-physical-locations.rst: New file.
* doc/libdiagnostics/tutorial/03-logical-locations.rst: New file.
* doc/libdiagnostics/tutorial/04-notes.rst: New file.
* doc/libdiagnostics/tutorial/05-warnings.rst: New file.
* doc/libdiagnostics/tutorial/06-fix-it-hints.rst: New file.
* doc/libdiagnostics/tutorial/07-execution-paths.rst: New file.
* doc/libdiagnostics/tutorial/index.rst: New file.
* libdiagnostics++.h: New file.
* libdiagnostics.cc: New file.
* libdiagnostics.h: New file.
* libdiagnostics.map: New file.
gcc/testsuite/ChangeLog:
* libdiagnostics.dg/libdiagnostics.exp: New, adapted from jit.exp.
* libdiagnostics.dg/sarif.py: New.
* libdiagnostics.dg/test-dump.c: New test.
* libdiagnostics.dg/test-error-c.py: New test.
* libdiagnostics.dg/test-error-with-note-c.py: New test.
* libdiagnostics.dg/test-error-with-note.c: New test.
* libdiagnostics.dg/test-error-with-note.cc: New test.
* libdiagnostics.dg/test-error.c: New test.
* libdiagnostics.dg/test-error.cc: New test.
* libdiagnostics.dg/test-example-1.c: New test.
* libdiagnostics.dg/test-fix-it-hint-c.py: New test.
* libdiagnostics.dg/test-fix-it-hint.c: New test.
* libdiagnostics.dg/test-fix-it-hint.cc: New test.
* libdiagnostics.dg/test-helpers++.h: New test.
* libdiagnostics.dg/test-helpers.h: New test.
* libdiagnostics.dg/test-labelled-ranges.c: New test.
* libdiagnostics.dg/test-labelled-ranges.cc: New test.
* libdiagnostics.dg/test-labelled-ranges.py: New test.
* libdiagnostics.dg/test-logical-location-c.py: New test.
* libdiagnostics.dg/test-logical-location.c: New test.
* libdiagnostics.dg/test-metadata-c.py: New test.
* libdiagnostics.dg/test-metadata.c: New test.
* libdiagnostics.dg/test-multiple-lines-c.py: New test.
* libdiagnostics.dg/test-multiple-lines.c: New test.
* libdiagnostics.dg/test-no-column-c.py: New test.
* libdiagnostics.dg/test-no-column.c: New test.
* libdiagnostics.dg/test-no-diagnostics-c.py: New test.
* libdiagnostics.dg/test-no-diagnostics.c: New test.
* libdiagnostics.dg/test-note-with-fix-it-hint-c.py: New test.
* libdiagnostics.dg/test-note-with-fix-it-hint.c: New test.
* libdiagnostics.dg/test-text-sink-options.c: New test.
* libdiagnostics.dg/test-warning-c.py: New test.
* libdiagnostics.dg/test-warning-with-path-c.py: New test.
* libdiagnostics.dg/test-warning-with-path.c: New test.
* libdiagnostics.dg/test-warning.c: New test.
* libdiagnostics.dg/test-write-sarif-to-file-c.py: New test.
* libdiagnostics.dg/test-write-sarif-to-file.c: New test.
* libdiagnostics.dg/test-write-text-to-file.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
I need to use this cleanup logic for the testsuite for libdiagnostics
where it's too awkward to directly use gcc-dg.exp itself.
No functional change intended.
gcc/testsuite/ChangeLog:
* lib/dg-test-cleanup.exp: New file, from material moved from
lib/gcc-dg.exp.
* lib/gcc-dg.exp: Add load_lib of dg-test-cleanup.exp.
(cleanup-after-saved-dg-test): Move to lib/dg-test-cleanup.exp.
(dg-test): Likewise for override.
(initialize_prune_notes): Likewise.
libatomic/ChangeLog:
* testsuite/lib/libatomic.exp: Add
"load_gcc_lib dg-test-cleanup.exp".
libgomp/ChangeLog:
* testsuite/lib/libgomp.exp: Add
"load_gcc_lib dg-test-cleanup.exp".
libitm/ChangeLog:
* testsuite/lib/libitm.exp: Add
"load_gcc_lib dg-test-cleanup.exp".
libphobos/ChangeLog:
* testsuite/lib/libphobos-dg.exp: Add
"load_gcc_lib dg-test-cleanup.exp".
libstdc++-v3/ChangeLog:
* testsuite/lib/libstdc++.exp: Add
"load_gcc_lib dg-test-cleanup.exp".
libvtv/ChangeLog:
* testsuite/lib/libvtv.exp: Add
"load_gcc_lib dg-test-cleanup.exp".
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
__builtin_ia32_rsqrtsf2 expander generates UNSPEC_RSQRT insn pattern
also when TARGET_SSE_MATH is not set. Enable *rsqrtsf2_sse without
TARGET_SSE_MATH to avoid ICE with unrecognizable insn.
PR target/117357
gcc/ChangeLog:
* config/i386/i386.md (*rsqrtsf2_sse):
Also enable for !TARGET_SSE_MATH.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr117357.c: New test.
The tests added for PR115157 fail on arm-eabi. Add __INT_MAX__
to enum to make sure they have size int.
PR testsuite/117419
gcc/testsuite/ChangeLog:
* gcc.dg/enum-alias-1.c: Add __INT_MAX__.
* gcc.dg/enum-alias-2.c: Likewise.
* gcc.dg/enum-alias-3.c: Likewise.
Tested-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
When adding late-combine.cc, I forgot to add a timevar for it.
gcc/
* timevar.def (TV_LATE_COMBINE): New timevar.
* late-combine.cc (pass_data_late_combine): Use it.
At the moment, early-ra ducks out of allocating any region
that contains a register with both a strong FPR affinity and
a strong GPR affinity. The proper allocators are much better
at handling that situation.
But this means that early-ra tends not to allocate a region
of vector code that ends in a reduction to a scalar integer
if any later arithmetic is done on the scalar integer result.
Currently, if a block acts as an isolated allocation region, the pass
will try to split the block into subregions *between* instructions if
there are no live FPRs or FPR allocnos. In the reduction case described
above, it's convenient to try the same thing *within* instructions.
If a block of vector code ends in a reduction, all FPRs and FPR
allocnos will be dead between the "use phase" and the "def phase"
of the reduction: the vector input will then have died, but the
scalar result will not yet have been born.
If we split the block that way, the problematic reduction result
will be part of the second region, which we can skip allocating,
but the vector work will be part of a separate region, which we
might be able to allocate.
This avoids a MOV in the testcase and also helps a small amount
with x264.
gcc/
* config/aarch64/aarch64-early-ra.cc
(early_ra::IGNORE_REG): New flag.
(early_ra::fpr_preference): Handle it.
(early_ra::record_constraints): Fail the allocation if an
IGNORE_REG output operand is not independent of the inputs.
(defines_multi_def_pseudo): New function.
(early_ra::could_split_region_here): New member function, split
out from...
(early_ra::process_block): ...here. Try splitting a block into
multiple regions between the definition and use phases of an
instruction. Set IGNORE_REG on the output registers if we do so.
gcc/testsuite/
* gcc.target/aarch64/early_ra_1.c: New test.
When early-ra treats a block as an isolated allocation region,
it opportunistically splits the block into smaller regions
at points where no FPRs or FPR allocnos are live. Previously
it only did this if m_allocation_successful, since the contrary
included cases in which the live range information wasn't trustworthy.
After earlier patches, we should now be able to trust the live range
information whenever m_accurate_live_ranges is true. This means that
we can split the block into regions even if allocation failed for the
current (sub)region.
This is just something I noticed by inspection. I don't have
a particular test case for it.
gcc/
* config/aarch64/aarch64-early-ra.cc
(early_ra::process_block): Check m_accurate_live_ranges
rather than m_allocation_successful when deciding whether
to split a block into multiple regions. Skip over subregions
that we decide not to allocate.
At least on aarch64, modes_tieable_p is a stricter condition than
can_change_mode_class. can_change_mode_class tells us whether the
subreg rules produce a sensible result for a particular mode change.
modes_tieable_p in addition tells us whether a mode change is
reasonable for optimisation purposes.
A false return from either hook should (and does) prevent early_ra
from attempting an allocation. But only a false return from
can_change_mode_class should invalidate the liveness tracking;
we can still analyse subregs for which can_change_mode_class is
true and modes_tieable_p is false.
This doesn't make a difference on its own, but it helps later
patches.
gcc/
* config/aarch64/aarch64-early-ra.cc
(early_ra::get_allocno_subgroup): Split can_change_mode_class test
out from modes_tieable_p test and only invalidate the live range
information for the former.
The early-ra pass often didn't print a dump message when aborting the
allocation. This patch uses a similar helper to the previous patch.
gcc/
* config/aarch64/aarch64-early-ra.cc
(early_ra::record_allocation_failure): New member function.
(early_ra::get_allocno_subgroup): Use it instead of setting
m_allocation_successful directly.
(early_ra::record_constraints): Likewise.
(early_ra::allocate_colors): Likewise.
So far, early_ra has used a single m_allocation_successful bool
to record whether the current region is still being allocated.
But there are (at least) two reasons why we might pull out of
attempting an allocation:
(1) We can't track the liveness of individual FP allocnos,
due to some awkward subregs.
(2) We're afraid of doing a worse job than the proper allocator.
A later patch needs to distinguish (1) from other reasons, since
(1) means that the liveness information is not trustworthy.
(Currently we assume it is not trustworthy whenever
m_allocation_successful is false, but that's too conservative.)
gcc/
* config/aarch64/aarch64-early-ra.cc
(early_ra::record_live_range_failure): New member function.
(early_ra::m_accurate_live_ranges): New member variable.
(early_ra::start_new_region): Set m_accurate_live_ranges to true.
(early_ra::get_allocno_subgroup): Use record_live_range_failure
to abort the allocation on invalid subregs.
record_insn_refs has three distinct phases: model the definitions,
model any call, and model the uses. This patch splits each phase
out into its own function.
This isn't beneficial on its own, but it helps with later patches.
gcc/
* config/aarch64/aarch64-early-ra.cc
(early_ra::record_insn_refs): Split into...
(early_ra::record_insn_defs, early_ra::record_insn_call)
(early_ra::record_insn_uses): ...this new functions.
(early_ra::process_block): Update accordingly.
Previously the diagnostic subsystem supported a one-deep
hierarchy via auto_diagnostic_group, for associating
notes with the warning/error they annotate; this only
affects SARIF output, not text output.
This patch adds support to the diagnostics subsystem for
capturing arbitrarily deep nesting structure within
diagnostic messages.
This patch:
* adds the ability to express nesting internally when
building diagnostics
* captures the nesting in SARIF output in the form documented
in SG15's P3358R0 ("SARIF for Structured Diagnostics") via
a "nestingLevel" property
* adds a new experimental mode to text output to see the
hierarchy, via:
-fdiagnostics-set-output=text:experimental-nesting=yes
* adds test coverage via a plugin, which with the above
option emits:
• note: child 0
• note: grandchild 0 0
• note: grandchild 0 1
• note: grandchild 0 2
• note: child 1
• note: grandchild 1 0
• note: grandchild 1 1
• note: grandchild 1 2
• note: child 2
• note: grandchild 2 0
• note: grandchild 2 1
• note: grandchild 2 2
using '*' rather than '•' if the text_art::theme is ascii-only.
My hope is to eventually:
(a) use this to improve C++'s template diagnostics
(b) remove the "experimental" caveat from the the text output mode
but this patch doesn't touch the C++ frontend, leaving both of these
to followup work.
gcc/c-family/ChangeLog:
PR other/116253
* c-opts.cc (c_diagnostic_text_finalizer): Use
text_output.build_indent_prefix for prefix to
diagnostic_show_locus.
gcc/ChangeLog:
PR other/116253
* diagnostic-core.h (class auto_diagnostic_nesting_level): New.
* diagnostic-format-sarif.cc (class sarif_builder): Update leading
comment re nesting of diagnostics.
(sarif_result::on_nested_diagnostic): Add nestingLevel property.
* diagnostic-format-text.cc (on_report_diagnostic): If we're
showing nested diagnostics, then print changes of location on a
new line, indented, and update m_last_location.
(diagnostic_text_output_format::build_prefix): If m_show_nesting,
then potentially add indentation and a bullet point.
(get_bullet_point_unichar): New.
(use_unicode_p): New.
(diagnostic_text_output_format::build_indent_prefix): New.
* diagnostic-format-text.h
(diagnostic_text_output_format::diagnostic_text_output_format):
Initialize m_show_nesting and m_show_nesting_levels.
(diagnostic_text_output_format::build_indent_prefix): New decl.
(diagnostic_text_output_format::show_nesting_p): New accessor
(diagnostic_text_output_format::show_locations_in_nesting_p):
Likewise.
(diagnostic_text_output_format::set_show_nesting): New.
(diagnostic_text_output_format::set_show_locations_in_nesting):
New.
(diagnostic_text_output_format::set_show_nesting_levels): New.
(diagnostic_text_output_format::m_show_nesting): New field.
(diagnostic_text_output_format::m_show_locations_in_nesting): New
field.
(diagnostic_text_output_format::m_show_nesting_levels): New field.
* diagnostic-global-context.cc
(auto_diagnostic_nesting_level::auto_diagnostic_nesting_level):
New.
(auto_diagnostic_nesting_level::~auto_diagnostic_nesting_level):
New.
* diagnostic-show-locus.cc (layout_printer::print): Temporarily
set DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE.
* diagnostic.cc (diagnostic_context::initialize): Update for
renaming of m_nesting_depth to m_group_nesting_depth and
initialize m_diagnostic_nesting_level.
(diagnostic_context::finish): Update for renaming of
m_nesting_depth to m_group_nesting_depth.
(diagnostic_context::report_diagnostic): Likewise.
(diagnostic_context::begin_group): Likewise.
(diagnostic_context::end_group): Likewise.
(diagnostic_context::push_nesting_level): New.
(diagnostic_context::pop_nesting_level): New.
(diagnostic_context::set_diagnostic_buffer): Update for renaming
of m_nesting_depth to m_group_nesting_depth. Assert that we don't
have nested diagnostics.
* diagnostic.h (diagnostic_context::push_nesting_level): New decl.
(diagnostic_context::pop_nesting_level): New decl.
(diagnostic_context::get_diagnostic_nesting_level): New accessor.
(diagnostic_context::build_indent_prefix): New decl.
(diagnostic_context::m_diagnostic_groups): Rename m_nesting_depth
to m_group_nesting_depth and add field m_diagnostic_nesting_level.
* doc/invoke.texi (fdiagnostics-add-output): Add note about
"experimental" schemes, keys, and values. Add keys
"experimental-nesting", "experimental-nesting-show-locations",
and "experimental-nesting-show-levels" to text scheme.
* opts-diagnostic.cc (text_scheme_handler::make_sink): Add keys
"experimental-nesting", "experimental-nesting-show-locations",
and "experimental-nesting-show-levels".
gcc/testsuite/ChangeLog:
PR other/116253
* gcc.dg/plugin/diagnostic-test-nesting-sarif.c: New test.
* gcc.dg/plugin/diagnostic-test-nesting-sarif.py: New test.
* gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c:
New test.
* gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c:
New test.
* gcc.dg/plugin/diagnostic-test-nesting-text-indented.c: New test.
* gcc.dg/plugin/diagnostic-test-nesting-text-plain.c: New test.
* gcc.dg/plugin/diagnostic_plugin_test_nesting.c: New test plugin.
* gcc.dg/plugin/plugin.exp: Add the above.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Fix a rejects-(potentially)-valid code for ALLOCATE of CHARACTER with
type-spec, and implement a string-length check for -fcheck=bounds.
Implement more detailed errors or warnings when character function
declarations and references do not match.
PR fortran/53357
gcc/fortran/ChangeLog:
* dependency.cc (gfc_dep_compare_expr): Return correct result if
relationship of expressions could not be determined.
* interface.cc (gfc_check_result_characteristics): Implement error
messages if character function declations and references do not
agree, else emit warning in cases where a mismatch is suspected.
* trans-stmt.cc (gfc_trans_allocate): Implement a string length
check for -fcheck=bounds.
gcc/testsuite/ChangeLog:
* gfortran.dg/auto_char_len_4.f90: Adjust patterns.
* gfortran.dg/typebound_override_1.f90: Likewise.
* gfortran.dg/bounds_check_strlen_10.f90: New test.
The code was passing factor == 0 to vect_get_loop_len which always
returns an unmodified length, even if the number of scalar elements
doesn't agree. It also failed to insert the eventually generated
code.
PR tree-optimization/117594
* tree-vect-loop.cc (vectorizable_live_operation_1): Pass
factor == 1 to vect_get_loop_len, insert generated stmts.
* gcc.dg/vect/pr117594.c: New testcase.
And stage3 begins...
Zdenek's fuzzer caught this one. Essentially using simplify_gen_subreg
directly with an offset of 0 when we just needed a lowpart.
The offset of 0 works for little endian, but for big endian it's simply wrong.
simplify_gen_subreg will return NULL_RTX because the case isn't representable.
We then embed that NULL_RTX into an insn that's later scanned during
mark_jump_label.
Scanning the port I see a couple more instances of this incorrect idiom. One
is pretty obvious to fix. The others look a bit goofy and I'll probably need
to sync with Patrick on them.
Anyway tested on riscv64-elf and riscv32-elf with no regressions. Pushing to
the trunk.
PR target/117595
gcc/
* config/riscv/sync.md (atomic_compare_and_swap<mode>): Use gen_lowpart
rather than simplify_gen_subreg.
* config/riscv/riscv.cc (riscv_legitimize_move): Similarly.
gcc/testsuite/
* gcc.target/riscv/pr117595.c: New test.
This patch ensures that the tokens defining the full declaration of an
ARRAY type is stored in the symbol table and used during production of
error messages.
gcc/m2/ChangeLog:
PR modula2/117660
* gm2-compiler/P2Build.bnf (ArrayType): Update tok with the
composite token produced during array type declaration.
* gm2-compiler/P2SymBuild.mod (EndBuildArray): Create the
combinedtok and store it into the symbol table.
Also ensure combinedtok is pushed to the quad stack.
(BuildFieldArray): Preserve typetok.
* gm2-compiler/SymbolTable.def (PutArray): Rename parameters.
* gm2-compiler/SymbolTable.mod (PutArray): Rename parameters.
gcc/testsuite/ChangeLog:
PR modula2/117660
* gm2/iso/fail/arraymismatch.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
While these haven't shown up in my tester (not configs I test) and I think
we're likely going to be deprecating the nds32 target. we might as well go
ahead and fix them.
I'm going to include this under the pr117628 umbrella.
PR target/117628
libgcc/
* config/arm/freebsd-atomic.c (bool): Remove unnecessary typedef.
* config/arm/linux-atomic-64bit.c: Likewise.
* config/arm/linux-atomic.c: Likewise.
* config/nds32/linux-atomic.c: Likewise.
* config/nios2/linux-atomic.c: Likewise.
csky fails to build libgcc after the c23 changes because it has a typedef for
bool. AFAICT it's internal to the file, so removing the typedef isn't an ABI
change.
Similiarly for c6x which includes unwind-arm-common.inc. I suspect most, if
not all of the arm-v7 and older targets are failing to build right now.
I've built and regression tested both csky-linux-gnu and c6x-elf with this
change. OK for the trunk?
PR target/117628
libgcc/
* config/csky/linux-atomic.c (bool): Remove unnecessary typedef.
* unwind-arm-common.inc (bool): Similarly.
This patch is a follow on from PR modula2/117371 which could include
a check to enforce the ISO restriction on a zero for loop step.
gcc/m2/ChangeLog:
PR modula2/117371
* gm2-compiler/M2GenGCC.mod (PerformLastForIterator):
Add check for zero step value and issue an error message.
gcc/testsuite/ChangeLog:
PR modula2/117371
* gm2/iso/fail/forloopbyzero.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
The semantics of the GNAT-specific Predicate aspect should be equivalent
to those of the Static_Predicate aspect when the predicate expression is
static, but that is not correctly implemented for static case expressions.
gcc/ada/ChangeLog:
* exp_ch4.adb (Expand_N_Case_Expression): Remove the test on
enclosing predicate function for the return optimization.
Rewrite it in the general case to catch all nondynamic predicates.
(Expand_N_If_Expression): Remove the test on enclosing predicate
function for the return optimization.
Remove all user-level documentation of the check name
"Atomic_Synchronization". The documentation was confusing because
this check should never be used in source code, and because it
raises the question of whether All_Checks applies to it (it does
not).
Change the name Atomic_Synchronization to be _Atomic_Synchronization
(with a leading underscore) so that it cannot be used in source code.
This "check" is not really a check at all; it is used only internally in
the implementation of Disable/Enable_Atomic_Synchronization, because the
placement and scope of these pragmas match pragma Suppress.
gcc/ada/ChangeLog:
* doc/gnat_rm/implementation_defined_characteristics.rst:
Remove Atomic_Synchronization.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Likewise.
* doc/gnat_rm/implementation_defined_pragmas.rst: DRY.
Consolidate documentation of Disable/Enable_Atomic_Synchronization.
* checks.adb: Comment fix.
* exp_util.ads: Likewise.
* targparm.ads: Likewise.
* types.ads: Likewise.
* gnat1drv.adb: Likewise. DRY.
* sem_prag.adb (Process_Disable_Enable_Atomic_Sync):
Change name of Atomic_Synchronization to start with
underscore.
(Process_Suppress_Unsuppress): No need to check Comes_From_Source for
Atomic_Synchronization anymore; _Atomic_Synchronization can never
come from source. (Anyway, it shouldn't be ignored; it should be
an error.)
* snames.ads-tmpl (Atomic_Synchronization):
Change name to start with underscore.
* switch-c.adb (Scan_Front_End_Switches):
Minor cleanup: Use 'in'.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.
In addition to Resolve_Indexed_Component, Eval_Indexed_Component can also
set the Do_Range_Check flag on the expressions of an N_Indexed_Component
node through the call on Check_Non_Static_Context, so this also needs to
be blocked by the Kill_Range_Check flag.
gcc/ada/ChangeLog:
* sem_eval.adb (Eval_Indexed_Component): Clear Do_Range_Check on
the expressions if Kill_Range_Check is set on the node.
This is another glitch associated with Initialization_Statements.
gcc/ada/ChangeLog:
* exp_util.adb (Remove_Init_Call): Rewrite a compound statement in
the Initialization_Statements of the variable as a null statement
instead of removing it.
* freeze.adb (Explode_Initialization_Compound_Statement): Small
comment tweaks.
The processing of static array aggregates in Exp_Aggr requires that their
bounds be representable as Int(eger) values for practical purposes, and
the previous changes have exposed another path where this is not checked.
This introduces a UI_Are_In_Int_Range local predicate for convenience.
gcc/ada/ChangeLog:
* exp_aggr.adb (UI_Are_In_Int_Range): New predicate.
(Aggr_Size_OK): Use it.
(Flatten): Likewise.
(Packed_Array_Aggregate_Handled): Likewise.
(Static_Array_Aggregate): Likewise.
The problem occurs for an anonymous array object declared with an aspect and
when pragma {Initialize,Normalize}_Scalars is in effect: in this case, the
synthesized aggregate is attached to the Initialization_Statements field by
Convert_Aggr_In_Object_Decl, but Explode_Initialization_Compound_Statement
puts it back at the point of declaration instead of the freeze point, thus
voiding the effects of the mechanism.
This was previously hidden because of a bypass in Freeze_Entity which drops
the freeze node on the floor in this case, so the change fixes the issue and
removes the bypass in the process.
gcc/ada/ChangeLog:
* freeze.ads (Explode_Initialization_Compound_Statement): Adjust the
description.
* freeze.adb (Explode_Initialization_Compound_Statement): If the
entity has its freezing delayed, append the initialization actions
to its freeze actions.
(Freeze_Object_Declaration): Remove commented out code.
(Freeze_Entity): Remove bypass for object of anonymous array type.
The exception handler that catches Abort_Signal does nothing nowadays.
This refactors the code to use Build_Abort_Block more consistently and
also makes it simpler by dropping the identifier on the abort block.
No functional changes.
gcc/ada/ChangeLog:
* exp_sel.ads (Build_Abort_Block): Remove second parameter and
rename the third.
(Build_Abort_Block_Handler): Fix description.
* exp_sel.adb (Build_Abort_Block): Remove second parameter, rename
the third and adjust accordingly.
* exp_ch9.adb (Expand_N_Asynchronous_Select): Fix the description
of the exception handler throughout. Remove Abort_Block_Ent and
Hdle local variables. Call Build_Abort_Block consistently to build
the abort block and adjust existing calls.
In some cases an array aggregate with statically known bounds and at least
one bound outside of the range of a 32-bit signed integer causes
a bugbox.
gcc/ada/ChangeLog:
* exp_aggr.adb (Convert_To_Positional.Flatten): Avoid raising
Constraint_Error in UI_To_Int by testing UI_Is_In_Int_Range first.
This mainly decouples the handling of the declaration case from that of the
assignment case in Expand_Array_Aggregate, as well as moves the expansion
in the case of an aggregate that can be processed by the back end to the
Build_Array_Aggr_Code routine.
gcc/ada/ChangeLog:
* exp_aggr.adb (Build_Array_Aggr_Code): Build the simple assignment
for the case of an aggregate that can be handled by the back end.
(Expand_Array_Aggregate): Adjust description of the processing.
Move handling of declaration case to STEP 4 and remove handling of
the case of an aggregate that can be processed by the back end.
(Late_Expansion): Likewise for the second part.
* exp_ch3.adb (Expand_N_Object_Declaration): Deal with a delayed
aggregate synthesized for the default initialization, if any.
* sem_eval.adb (Eval_Indexed_Component): Bail out for the name of
an assignment statement.
This mainly decouples the handling of the allocator case from that of the
assignment case in Expand_Array_Aggregate and also makes Must_Slide a bit
more forgiving.
gcc/ada/ChangeLog:
* exp_aggr.adb (In_Place_Assign_OK): Remove handling of allocators
and call Must_Slide instead of implementing the check manually.
(Convert_To_Assignments): Adjust outdated comment.
(Expand_Array_Aggregate): Move handling of allocator case to STEP 3
and call Must_Slide directly for it.
(Must_Slide): Replace tests based on Is_OK_Static_Expression with
tests based on Compile_Time_Known_Value.
Convert_Array_Aggr_In_Allocator does nothing that Late_Expansion cannot do,
so this deletes the former and moves its support code for Storage_Model to
the latter. No functional changes.
gcc/ada/ChangeLog:
* exp_aggr.adb (Convert_Array_Aggr_In_Allocator): Delete.
(Convert_Aggr_In_Allocator): Do not call above procedure.
(Late_Expansion): Deal with a target that is the dereference of a
prefix with a Storage_Model. Remove an useless actual parameter
in the call to Build_Array_Aggr_Code.
Reverse the meaning of switch -gnatd_P; that is, enable by default
the generating of a runtime check when the prefix of the call is
an access-to-subprogram type with a null value.
gcc/ada/ChangeLog:
* sem_res.adb (Resolve_Actuals): Add by default a null-exclusion
check on the prefix of the call when it is an access-type; it can
be disabled using -gnatd_P.
* debug.adb (gnatd_P): Update documentation.
This patch fixes a crash in the compiler when the actual for an anonymous
access type formal is an 'Access of a Sream_Element_Array object during
the calculation of said actual's accessibility level.
gcc/ada/ChangeLog:
* accessibility.adb (Accessibility_Level): Handle the Input attribute
case
This change is part of an effort to reduce usage of
Is_Predefined_Filename.
gcc/ada/ChangeLog:
* frontend.adb (Frontend): tweak test for predefined main unit.