Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diagnostic Output for AFMV (#19) #40

Open
wants to merge 114 commits into
base: master
Choose a base branch
from

Conversation

Anatolii-developer
Copy link

  • Create test.cc for test-dump
  • Added test pass to tree-pass.h
  • Updated make test pass in tree-pass.h
  • Added test pass to passes.def
  • Updated test pass name in passes.def
  • Fixed the code to follow coding convention
  • Added test file to Makefile.in for diagnostic output

Thanks for taking the time to contribute to GCC! Please be advised that if you are
viewing this on github.com, that the mirror there is unofficial and unmonitored.
The GCC community does not use github.com for their contributions. Instead, we use
a mailing list ([email protected]) for code submissions, code reviews, and
bug reports. Please send patches there instead.

avieira-arm and others added 30 commits June 19, 2024 17:05
This patch adds support in the target agnostic doloop pass for the detection of
predicated vectorized hardware loops.  Arm is currently the only target that
will make use of this feature.

gcc/ChangeLog:

	* df-core.cc (df_bb_regno_only_def_find): New helper function.
	* df.h (df_bb_regno_only_def_find): Declare new function.
	* loop-doloop.cc (doloop_condition_get): Add support for detecting
	predicated vectorized hardware loops.
	(doloop_modify): Add support for GTU condition checks.
	(doloop_optimize): Update costing computation to support alterations to
	desc->niter_expr by the backend.

Co-authored-by: Stam Markianos-Wright <[email protected]>
This patch adds support for MVE Tail-Predicated Low Overhead Loops by using the
doloop funcitonality added to support predicated vectorized hardware loops.

gcc/ChangeLog:

	* config/arm/arm-protos.h (arm_target_bb_ok_for_lob): Change
	declaration to pass basic_block.
	(arm_attempt_dlstp_transform): New declaration.
	* config/arm/arm.cc (TARGET_LOOP_UNROLL_ADJUST): Define targethook.
	(TARGET_PREDICT_DOLOOP_P): Likewise.
	(arm_target_bb_ok_for_lob): Adapt condition.
	(arm_mve_get_vctp_lanes): New function.
	(arm_dl_usage_type): New internal enum.
	(arm_get_required_vpr_reg): New function.
	(arm_get_required_vpr_reg_param): New function.
	(arm_get_required_vpr_reg_ret_val): New function.
	(arm_mve_get_loop_vctp): New function.
	(arm_mve_insn_predicated_by): New function.
	(arm_mve_across_lane_insn_p): New function.
	(arm_mve_load_store_insn_p): New function.
	(arm_mve_impl_pred_on_outputs_p): New function.
	(arm_mve_impl_pred_on_inputs_p): New function.
	(arm_last_vect_def_insn): New function.
	(arm_mve_impl_predicated_p): New function.
	(arm_mve_check_reg_origin_is_num_elems): New function.
	(arm_mve_dlstp_check_inc_counter): New function.
	(arm_mve_dlstp_check_dec_counter): New function.
	(arm_mve_loop_valid_for_dlstp): New function.
	(arm_predict_doloop_p): New function.
	(arm_loop_unroll_adjust): New function.
	(arm_emit_mve_unpredicated_insn_to_seq): New function.
	(arm_attempt_dlstp_transform): New function.
	* config/arm/arm.opt (mdlstp): New option.
	* config/arm/iterators.md (dlstp_elemsize, letp_num_lanes,
	letp_num_lanes_neg, letp_num_lanes_minus_1): New attributes.
	(DLSTP, LETP): New iterators.
	* config/arm/mve.md (predicated_doloop_end_internal<letp_num_lanes>,
	dlstp<dlstp_elemsize>_insn): New insn patterns.
	* config/arm/thumb2.md (doloop_end): Adapt to support tail-predicated
	loops.
	(doloop_begin): Likewise.
	* config/arm/types.md (mve_misc): New mve type to represent
	predicated_loop_end insn sequences.
	* config/arm/unspecs.md:
	(DLSTP8, DLSTP16, DLSTP32, DSLTP64,
	LETP8, LETP16, LETP32, LETP64): New unspecs for DLSTP and LETP.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/lob.h: Add new helpers.
	* gcc.target/arm/lob1.c: Use new helpers.
	* gcc.target/arm/lob6.c: Likewise.
	* gcc.target/arm/mve/dlstp-compile-asm-1.c: New test.
	* gcc.target/arm/mve/dlstp-compile-asm-2.c: New test.
	* gcc.target/arm/mve/dlstp-compile-asm-3.c: New test.
	* gcc.target/arm/mve/dlstp-int8x16.c: New test.
	* gcc.target/arm/mve/dlstp-int8x16-run.c: New test.
	* gcc.target/arm/mve/dlstp-int16x8.c: New test.
	* gcc.target/arm/mve/dlstp-int16x8-run.c: New test.
	* gcc.target/arm/mve/dlstp-int32x4.c: New test.
	* gcc.target/arm/mve/dlstp-int32x4-run.c: New test.
	* gcc.target/arm/mve/dlstp-int64x2.c: New test.
	* gcc.target/arm/mve/dlstp-int64x2-run.c: New test.
	* gcc.target/arm/mve/dlstp-invalid-asm.c: New test.

Co-authored-by: Stam Markianos-Wright <[email protected]>
gcc/fortran/ChangeLog:

	PR fortran/115390
	* trans-decl.cc (gfc_conv_cfi_to_gfc): Move derivation of type sizes
	for character via gfc_trans_vla_type_sizes to after character length
	has been set.

gcc/testsuite/ChangeLog:

	PR fortran/115390
	* gfortran.dg/bind_c_char_11.f90: New test.
Most of std::pair constructors implemented using C++20 concepts have a
conditional noexcept-specifier, but the default constructor doesn't.
This fixes that.

libstdc++-v3/ChangeLog:

	* include/bits/stl_pair.h [__cpp_lib_concepts] (pair()): Add
	conditional noexcept.
Making the state ready for a std::promise<void> only needs to move a
unique_ptr, which cannot throw. Make its call operator noexcept.
Similarly, making the state ready by storing an exception_ptr also can't
throw, so make that call operator noexcept too.

libstdc++-v3/ChangeLog:

	* include/std/future (_State_baseV2::_Setter<R, void>): Add
	noexcept to call operator.
	(_State_baseV2::_Setter<R, __exception_ptr_tag>): Likewise.
libstdc++-v3/ChangeLog:

	* include/std/future: Adjust whitespace to use tabs for
	indentation.
This patch makes avoid inserting a MEMW instruction before a load/store
nstruction with volatile memory reference if there is already a MEMW
immediately before it.

gcc/ChangeLog:

	* config/xtensa/xtensa.cc (print_operand):
	When outputting MEMW before the instruction, check if the previous
	instruction is already that.
This patch enables -march/-mtune=shijidadao, costs and tunings are set
according to the characteristics of the processor.

gcc/ChangeLog:

	* common/config/i386/cpuinfo.h (get_zhaoxin_cpu): Recognize shijidadao.
	* common/config/i386/i386-common.cc: Add shijidadao.
	* common/config/i386/i386-cpuinfo.h (enum processor_subtypes):
	Add ZHAOXIN_FAM7H_SHIJIDADAO.
	* config.gcc: Add shijidadao.
	* config/i386/driver-i386.cc (host_detect_local_cpu):
	Let -march=native recognize shijidadao processors.
	* config/i386/i386-c.cc (ix86_target_macros_internal): Add shijidadao.
	* config/i386/i386-options.cc (m_ZHAOXIN): Add m_SHIJIDADAO.
	(m_SHIJIDADAO): New definition.
	* config/i386/i386.h (enum processor_type): Add PROCESSOR_SHIJIDADAO.
	* config/i386/x86-tune-costs.h (struct processor_costs):
	Add shijidadao_cost.
	* config/i386/x86-tune-sched.cc (ix86_issue_rate): Add shijidadao.
	(ix86_adjust_cost): Ditto.
	* config/i386/x86-tune.def (X86_TUNE_USE_GATHER_2PARTS): Add m_SHIJIDADAO.
	(X86_TUNE_USE_GATHER_4PARTS): Ditto.
	(X86_TUNE_USE_GATHER_8PARTS): Ditto.
	(X86_TUNE_AVOID_128FMA_CHAINS): Ditto.
	* doc/extend.texi: Add details about shijidadao.
	* doc/invoke.texi: Ditto.

gcc/testsuite/ChangeLog:

	* g++.target/i386/mv32.C: Handle new -march
	* gcc.target/i386/funcspec-56.inc: Ditto.
We don't really support _Complex _BitInt(N), the only place we use
bitint complex types is for the .{ADD,SUB,MUL}_OVERFLOW internal function
results and COMPLEX_EXPR in the usual case should be either not present
yet because the ifns weren't folded and will be lowered, or optimized
into something simpler, because normally the complex bitint should be
used just for extracting the 2 subparts from it.
Still, with disabled optimizations it can occassionally happen that it
appears in the IL and that is why there is support for lowering those,
but it doesn't handle optimizing those too much, so if it uses SSA_NAME,
it relies on them having a backing VAR_DECL during the lowering.
This is normally achieves through the
                      && ((is_gimple_assign (use_stmt)
                           && (gimple_assign_rhs_code (use_stmt)
                               != COMPLEX_EXPR))
                          || gimple_code (use_stmt) == GIMPLE_COND)
hunk in gimple_lower_bitint, but as the following testcase shows, there
is one thing I've missed, the load optimization isn't guarded by the
above stuff.  So, either we'd need to add support for loads to
lower_complexexpr_stmt, or because they should be really rare, this
patch just disables the load optimization if at least one load use is
a COMPLEX_EXPR (like we do already for PHIs, calls, asm).

2024-06-19  Jakub Jelinek  <[email protected]>

	PR tree-optimization/115544
	* gimple-lower-bitint.cc (gimple_lower_bitint): Disable optimizing
	loads used by COMPLEX_EXPR operands.

	* gcc.dg/bitint-107.c: New test.
Binutils 2.42 and before don't support Zaamo/Zalrsc. When users specify
both Zaamo and Zalrsc, promote them to 'a' in the -march string.

This does not affect testsuite results for users with old versions of binutils.
Testcases that failed due to 'call'/isa string continue to fail after this PATCH
when using an old version of binutils.

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc: Add 'a' extension to
	riscv_combine_info.

Signed-off-by: Patrick O'Neill <[email protected]>
We can unify eqne and other comparison operations.

Tested on RV32 and RV64

gcc/ChangeLog:

	* config/riscv/riscv-vector-builtins-bases.cc: Remove eqne cond
	* config/riscv/vector.md (@pred_eqne<mode>_scalar): Remove patterns
	(*pred_eqne<mode>_scalar_merge_tie_mask): Ditto
	(*pred_eqne<mode>_scalar): Ditto
	(*pred_eqne<mode>_scalar_narrow): Ditto

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/float-point-cmp-eqne.c: New test.
Add a utility function to check if a statement is lane-reducing operation,
which could simplify some existing code.

2024-06-16 Feng Xue <[email protected]>

gcc/
	* tree-vectorizer.h (lane_reducing_stmt_p): New function.
	* tree-vect-slp.cc (vect_analyze_slp): Use new function
	lane_reducing_stmt_p to check statement.
In vectorizable_reduction, one check on a reduction operand via index could be
contained by another one check via pointer, so remove the former.

2024-06-16 Feng Xue <[email protected]>

gcc/
	* tree-vect-loop.cc (vectorizable_reduction): Remove the duplicated
	check.
Two local variables were defined to refer same STMT_VINFO_REDUC_TYPE, better
to keep only one.

2024-06-16 Feng Xue <[email protected]>

gcc/
	* tree-vect-loop.cc (vectorizable_reduction): Remove v_reduc_type, and
	replace it to another local variable reduction_type.
It's better to place 3 relevant independent variables into array, since we
have requirement to access them via an index in the following patch. At the
same time, this change may get some duplicated code be more compact.

2024-06-16 Feng Xue <[email protected]>

gcc/
	* tree-vect-loop.cc (vect_transform_reduction): Replace vec_oprnds0/1/2
	with one new array variable vec_oprnds[3].
According to logic of code nearby the assertion, all lane-reducing operations
should not appear, not just DOT_PROD_EXPR. Since "use_mask_by_cond_expr_p"
treats SAD_EXPR same as DOT_PROD_EXPR, and WIDEN_SUM_EXPR should not be allowed
by the following assertion "gcc_assert (commutative_binary_op_p (...))", so
tighten the assertion.

2024-06-16 Feng Xue <[email protected]>

gcc/
	* tree-vect-loop.cc (vect_transform_reduction): Change assertion to
	cover all lane-reducing ops.
When dlopen and pthread_create are in libc the variable is
set to "none required", therefore running configure will show
the following errors:

./configure: line 8997: test: too many arguments
./configure: line 8999: test: too many arguments
./configure: line 9003: test: too many arguments
./configure: line 9005: test: =: unary operator expected

ChangeLog:

	PR bootstrap/115453
	* configure.ac: Quote variable result of AC_SEARCH_LIBS.  Fix
	typo ac_cv_search_pthread_crate.
	* configure: Regenerate.

Signed-off-by: Collin Funk <[email protected]>
We currently fail to re-CSE SLP nodes after optimizing permutes
which results in off cost estimates.  For gcc.dg/vect/bb-slp-32.c
this shows in not re-using the SLP node with the load and arithmetic
for both the store and the reduction.  The following implements
CSE by re-bst-mapping nodes as finalization part of vect_optimize_slp.

I've tried to make the CSE part of permute materialization but it
isn't a very good fit there.  I've not bothered to implement something
more complete, also handling external defs or defs without
SLP_TREE_SCALAR_STMTS.

I realize this might result in more BB SLP which in turn might slow
down code given costing for BB SLP is difficult (even that we now
vectorize gcc.dg/vect/bb-slp-32.c on x86_64 might be not a good idea).
This is nevertheless feeding more accurate info to costing which is
good.

	PR tree-optimization/114413
	* tree-vect-slp.cc (release_scalar_stmts_to_slp_tree_map):
	New function, split out from ...
	(vect_analyze_slp): ... here.  Call it.
	(vect_cse_slp_nodes): New function.
	(vect_optimize_slp): Call it.

	* gcc.dg/vect/bb-slp-32.c: Expect CSE and vectorization on x86.
2024-06-20  Paul Thomas  <[email protected]>

gcc/fortran
	PR fortran/59104
	* dependency.cc (dependency_fcn, gfc_function_dependency): New
	functions to detect dependency in array bounds and character
	lengths on old style function results.
	* dependency.h : Add prototype for gfc_function_dependency.
	* error.cc (error_print): Remove trailing space.
	* gfortran.h : Remove dummy_order and add fn_result_spec.
	* symbol.cc : Remove declaration of next_dummy_order..
	(gfc_set_sym_referenced): remove setting of symbol dummy order.
	* trans-array.cc (gfc_trans_auto_array_allocation): Detect
	non-dummy symbols with function dependencies and put the
	allocation at the end of the initialization code.
	* trans-decl.cc : Include dependency.h.
	(decl_order): New function that determines uses the location
	field of the symbol 'declared_at' to determine the order of two
	declarations.
	(gfc_defer_symbol_init): Call gfc_function_dependency to put
	dependent symbols in the right part of the tlink chain. Use
	the location field of the symbol declared_at to determine the
	order of declarations.
	(gfc_trans_auto_character_variable): Put character length
	initialization of dependent symbols at the end of the chain.
	* trans.cc (gfc_add_init_cleanup): Add boolean argument with
	default false that determines whther an expression is placed at
	the back or the front of the initialization chain.
	* trans.h : Update the prototype for gfc_add_init_cleanup.

gcc/testsuite/
	PR fortran/59104
	* gfortran.dg/dependent_decls_2.f90: New test.
Adjust several new feature check in ix86_option_override_interal that
directly use TARGET_* instead of TARGET_*_P (opts->ix86_isa_flags)
to avoid cmdline option overrides target_attribute isa flag.

gcc/ChangeLog:

	* config/i386/i386-options.cc (ix86_option_override_internal):
	Use TARGET_*_P (opts->x_ix86_isa_flags*) instead of TARGET_*
	for UINTR, LAM and APX_F.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/apx-ccmp-2.c: Remove -mno-apxf in option.
	* gcc.target/i386/funcspec-56.inc: Drop uintr tests.
	* gcc.target/i386/funcspec-6.c: Add uintr tests.
Recognize references to attributes Put_Image and Object_Size as
language-defined in Ada 2022 and implementation-defined in earlier
versions of Ada. Other attributes listed in Ada 2022 RM, K.2 and
currently implemented in GNAT are correctly categorized.

This change only affects code with restriction
No_Implementation_Attributes.

gcc/ada/

	* sem_attr.adb (Attribute_22): Add Put_Image and Object_Size.
	* sem_attr.ads (Attribute_Impl_Def): Remove Object_Size.
In some cases, gnatprep would correctly emit an error message and then
incorrectly exit with a return code of zero, indicating success.
In some cases, a correct message about an error detected by the integrated
preprocessor would be accompanied by an incorrect message indicating that
a source file could not be found.

gcc/ada/

	* gprep.adb (Process_Files.Process_One_File): When calling OS_Exit in an error
	path, pass in a Status parameter of 1 instead of 0 (because 0
	indicates success).
	* lib-load.adb (Load_Main_Source): Do not emit a message about a missing source file
	if other error messages were generated by calling Load_Source_File;
	the file isn't missing - it failed preprocessing.
This patch moves the documentation for 'Super from gnat language extensions to
experimental language extensions.

gcc/ada/

	* doc/gnat_rm/gnat_language_extensions.rst: Add entry for 'Super.
	* doc/gnat_rm/implementation_defined_attributes.rst: Remove entry
	for 'Super.
	* gnat_rm.texi: Regenerate.
	* gnat_ugn.texi: Regenerate.
There was a general concept of info messages being a subset of
warnings. However that is no longer the case. Messages with an
info insertion character should be treated just as info messages.

gcc/ada/

	* atree.ads: Remove Warning_Info_Messages.
	* errout.adb: Remove various places where Warning_Info_Messages
	was used.
	* erroutc.adb: Remove various places where Warning_Info_Messages
	was used. Create Error_Msg_Object objects with only an info
	attribute if the message contained both info and warning insertion
	characters. New method Has_Switch_Tag for detecting if a message
	should have an error tag.
	* errutil.adb: Create Error_Msg_Object objects with only an info
	attribute if the message contained both info and warning insertion
	characters.
Add a separate switch -gnatis to suppress info messages
separately from warning messages that are controlled by
-gnatws.

gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add
	entry for -gnatis.
	* errout.adb (Error_Msg_Internal): Stop printing info messages if
	-gnatis was used.
	* opt.ads: Add Info_Suppressed flag to track whether info messages
	should be suppressed.
	* switch-c.adb: Add parsing for -gnatis.
	* gnat_ugn.texi: Regenerate.
Previously the messages produced by this warning switch
were info messages that were suppressed with the same
methods as regular warnings. Since info messages are now
separated as a completely different class of messages then
these messages should be converted back to warnings in order
for the previous pragma based suppression methods to work.

gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Update
	documentation for -gnatw.n switch.
	* exp_util.adb: Convert info messages into warnings.
	* gnat_ugn.texi: Regenerate.
Previously this switch was emitting only info messages
which was both confusing in terms of the name of the
switch that was used internally and externally.

gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Update
	documentation for -gnatw.v.
	* sem_ch13.adb: Convert all -gnatw.v related messages to warnings.
	* gnat_ugn.texi: Regenerate.
rsandifo-arm and others added 30 commits June 21, 2024 09:52
*minus_plus_one had no constraints, which meant that it could be
matched after RA with operands 0, 1 and 2 all being different.
The associated split instead requires operand 0 to be tied to
operand 1.

gcc/
	* config/sh/sh.md (*minus_plus_one): Add constraints.
This fixes a warning from one of the test allocators:
warning: base class 'class std::allocator<__gnu_test::copy_tracker>' should be explicitly initialized in the copy constructor [-Wextra]

libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_allocator.h (tracker_allocator):
	Initialize base class in copy constructor.
Due to PR c++/85723 the std::is_trivial trait is true for types with a
deleted default constructor, so the use of std::is_trivial in
std::to_array is not sufficient to ensure the type can be trivially
default constructed then filled using memcpy.

I also forgot that a type with a deleted assignment operator can still
be trivial, so we also need to check that it's assignable because the
is_constant_evaluated() path can't use memcpy.

Replace the uses of std::is_trivial with std::is_trivially_copyable
(needed for memcpy), std::is_trivially_default_constructible (needed so
that the default construction is valid and does no work) and
std::is_copy_assignable (needed for the constant evaluation case).

libstdc++-v3/ChangeLog:

	PR libstdc++/115522
	* include/std/array (to_array): Workaround the fact that
	std::is_trivial is not sufficient to check that a type is
	trivially default constructible and assignable.
	* testsuite/23_containers/array/creation/115522.cc: New test.
The <chrono> header is incomplete for the old std::string ABI, because
std::chrono::tzdb is only defined for the new ABI. The feature test
macro advertising full C++20 support should not be defined for the old
ABI.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (chrono): Add cxx11abi = yes.
	* include/bits/version.h: Regenerate.
	* testsuite/std/time/syn_c++20.cc: Adjust expected value for
	the feature test macro.
…r_convert

These were deprecated in C++17 and std::wstring_convert is planned for
removal in C++26.

libstdc++-v3/ChangeLog:

	* include/bits/locale_conv.h (wstring_convert): Add deprecated
	attribute for C++17 and later.
	(wbuffer_convert): Likewise.
	* testsuite/22_locale/codecvt/codecvt_utf16/79980.cc: Disable
	deprecated warnings.
	* testsuite/22_locale/codecvt/codecvt_utf8/79980.cc: Likewise.
	* testsuite/22_locale/codecvt/codecvt_utf8_utf16/79511.cc:
	Likewise.
	* testsuite/22_locale/conversions/buffer/1.cc: Add dg-warning.
	* testsuite/22_locale/conversions/buffer/2.cc: Likewise.
	* testsuite/22_locale/conversions/buffer/3.cc: Likewise.
	* testsuite/22_locale/conversions/buffer/requirements/typedefs.cc:
	Likewise.
	* testsuite/22_locale/conversions/string/1.cc: Likewise.
	* testsuite/22_locale/conversions/string/2.cc: Likewise.
	* testsuite/22_locale/conversions/string/3.cc: Likewise.
	* testsuite/22_locale/conversions/string/66441.cc: Likewise.
	* testsuite/22_locale/conversions/string/requirements/typedefs-2.cc:
	Likewise.
	* testsuite/22_locale/conversions/string/requirements/typedefs.cc:
	Likewise.
libstdc++-v3/ChangeLog:

	* include/backward/backward_warning.h: Adjust comments to
	suggest <spanstream> as another alternative to <strstream>.
	* include/backward/strstream (strstreambuf, istrstream)
	(ostrstream, strstream): Add deprecated attribute.
…5R4)

This member function was previously deprecated, but that was reverted by
P2875R4, approved earlier this year in Tokyo. Since it's not going to be
deprecated in C++26, and so presumably not removed, there is no point in
giving deprecated warnings for C++23 mode.

libstdc++-v3/ChangeLog:

	* include/bits/memory_resource.h (polymorphic_allocator::destroy):
	Remove deprecated attribute.
LWG 3305 was approved earlier this year in Tokyo. We need to give an
error if using std::any_cast<void>, but std::any_cast<void()> is valid
(but always returns null).

libstdc++-v3/ChangeLog:

	* include/std/any (any_cast(any*), any_cast(const any*)): Add
	static assertion to reject void types, as per LWG 3305.
	* testsuite/20_util/any/misc/lwg3305.cc: New test.
libstdc++-v3/ChangeLog:

	* include/bits/stl_uninitialized.h (uninitialized_default_construct)
	(uninitialized_default_construct_n, uninitialized_value_construct)
	(uninitialized_value_construct_n): Qualify calls to prevent ADL.
When adding validation of .sarif files against the schema
(PR testsuite/109360) I discovered various issues where we were
generating invalid .sarif files.

Specifically, in
  c-c++-common/diagnostic-format-sarif-file-bad-utf8-pr109098-1.c
the relatedLocations for the "note" diagnostics were missing column
numbers, leading to validation failure due to non-unique elements,
such as multiple:
	"message": {"text": "invalid UTF-8 character <bf>"}},
on line 25 with no column information.

Root cause is that for some diagnostics in libcpp we have a location_t
representing the line as a whole, setting a column_override on the
rich_location (since the line hasn't been fully read yet).  We were
handling this column override for plain text output, but not for .sarif
output.

Similarly, in diagnostic-format-sarif-file-pr111700.c there is a warning
emitted on "line 0" of the file, whereas SARIF requires line numbers to
be positive.

We also use column == 0 internally to mean "the line as a whole",
whereas SARIF required column numbers to be positive.

This patch fixes these various issues.

gcc/ChangeLog:
	PR testsuite/109360
	* diagnostic-format-sarif.cc
	(sarif_builder::make_location_object): Pass any column override
	from rich_loc to maybe_make_physical_location_object.
	(sarif_builder::maybe_make_physical_location_object): Add
	"column_override" param and pass it to maybe_make_region_object.
	(sarif_builder::maybe_make_region_object): Add "column_override"
	param and use it when the location has 0 for a column.  Don't
	add "startLine", "startColumn", "endLine", or "endColumn" if
	the values aren't positive.
	(sarif_builder::maybe_make_region_object_for_context): Don't
	add "startLine" or "endLine" if the values aren't positive.

libcpp/ChangeLog:
	PR testsuite/109360
	* include/rich-location.h (rich_location::get_column_override):
	New accessor.

Signed-off-by: David Malcolm <[email protected]>
…IF schema [PR109360]

This patch extends the dg directive verify-sarif-file so that if
the "jsonschema" tool is available, it will be used to validate the
generated .sarif file.

Tested with jsonschema 3.2 with Python 3.8

gcc/ChangeLog:
	PR testsuite/109360
	* doc/install.texi: Mention optional usage of "jsonschema" tool.

gcc/testsuite/ChangeLog:
	PR testsuite/109360
	* lib/sarif-schema-2.1.0.json: New file, downloaded from
	https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/schemas/sarif-schema-2.1.0.json
	Licensing information can be seen at
	oasis-tcs/sarif-spec#583
	which states "They are free to incorporate it into their
	implementation. No need for special permission or paperwork from
	OASIS."
	* lib/scansarif.exp (verify-sarif-file): If "jsonschema" is
	available, use it to verify that the .sarif file complies with the
	SARIF schema.
	* lib/target-supports.exp (check_effective_target_jsonschema):
	New.

Signed-off-by: David Malcolm <[email protected]>
Add a remove_unreachable object to fast vrp, and honor the final_p flag.

	* tree-vrp.cc (remove_unreachable::remove): Export global range
	if builtin_unreachable dominates all uses.
	(remove_unreachable::remove_and_update_globals): Do not reset SCEV.
	(execute_ranger_vrp): Reset SCEV here instead.
	(fvrp_folder::fvrp_folder): Take final pass flag
	and create a remove_unreachable object when specified.
	(fvrp_folder::pre_fold_stmt): Register GIMPLE_CONDs with
	the remove_unreachcable object.
	(fvrp_folder::m_unreachable): New.
	(execute_fast_vrp): Process remove_unreachable object.
	(pass_vrp::execute): Add final_p flag to execute_fast_vrp.
Change the fast VRP algorithm to track contextual ranges active within
each basic block.

	* gimple-range.cc (dom_ranger::dom_ranger): Create a block
	vector.
	(dom_ranger::~dom_ranger): Dispose of the block vector.
	(dom_ranger::edge_range): Delete.
	(dom_ranger::range_on_edge): Combine range in src BB with any
	range gori_nme_on_edge returns.
	(dom_ranger::range_in_bb): Combine global range with any active
	contextual range for an ssa-name.
	(dom_ranger::range_of_stmt): Fix non-ssa LHS case, use
	fur_depend for folding so relations can be registered.
	(dom_ranger::maybe_push_edge): Delete.
	(dom_ranger::pre_bb): Create incoming contextual range vector.
	(dom_ranger::post_bb): Free contextual range vector.
	* gimple-range.h (dom_ranger::edge_range): Delete.
	(dom_ranger::m_e0): Delete.
	(dom_ranger::m_e1): Delete.
	(dom_ranger::m_bb): New.
	(dom_ranger::m_pop_list): Delete.
	* tree-vrp.cc (execute_fast_vrp): Enable relation oracle.
	* gimple-range.cc (gimple_ranger::register_inferred_ranges): Do not
	dump global range info after set_range_info.
	(gimple_ranger::register_transitive_inferred_ranges): Likewise.
	(dom_ranger::range_of_stmt): Likewise.
	* tree-ssanames.cc (set_range_info): If global range info
	changes, maybe print new range to dump_file.
	* tree-vrp.cc (remove_unreachable::handle_early): Do not
	dump global range info after set_range_info.
	(remove_unreachable::remove): Likewise.
	(remove_unreachable::remove_and_update_globals): Likewise.
	(pass_assumptions::execute): Likewise.
No-op moves are given the code NOOP_MOVE_INSN_CODE if we plan
to delete them later.  Such insns shouldn't be costed, partly
because they're going to disappear, and partly because targets
won't recognise the insn code.

gcc/
	* rtl-ssa/changes.cc (rtl_ssa::changes_are_worthwhile): Don't
	cost no-op moves.
	* rtl-ssa/insns.cc (insn_info::calculate_cost): Likewise.
The iq2000 test and branch instructions had patterns like:

  [(set (pc)
	(if_then_else
	 (eq (and:SI (match_operand:SI 0 "register_operand" "r")
		     (match_operand:SI 1 "power_of_2_operand" "I"))
	      (const_int 0))
	 (match_operand 2 "pc_or_label_operand" "")
	 (match_operand 3 "pc_or_label_operand" "")))]

power_of_2_operand allows any 32-bit power of 2, whereas "I" only
accepts 16-bit signed constants.  This meant that any power of 2
greater than 32768 would cause an "insn does not satisfy its
constraints" ICE.

Also, the %p operand modifier barfed on 1<<31, which is sign-
rather than zero-extended to 64 bits.  The code is inherently
limited to 32-bit operands -- power_of_2_operand contains a test
involving "unsigned" -- so this patch just ands with 0xffffffff.

gcc/
	* config/iq2000/iq2000.cc (iq2000_print_operand): Make %p handle 1<<31.
	* config/iq2000/iq2000.md: Remove "I" constraints on
	power_of_2_operands.
All uses of xs_hi_nonmemory_operand allow constraint "i",
which means that they allow consts, symbol_refs and label_refs.
The definition of xs_hi_nonmemory_operand accounted for consts,
but not for symbol_refs and label_refs.

gcc/
	* config/stormy16/predicates.md (xs_hi_nonmemory_operand): Handle
	symbol_ref and label_ref.
* Running a test compiled with AVX512 instructions requires
avx512f_runtime not just avx512f.

* The 'reduce2' test violated an invariant of fixed_size_simd_mask and
thus failed on all targets without 16-Byte vector builtins enabled (in
bits/simd.h).

Signed-off-by: Matthias Kretz <[email protected]>

libstdc++-v3/ChangeLog:

	PR libstdc++/115575
	* testsuite/experimental/simd/pr115454_find_last_set.cc: Require
	avx512f_runtime. Don't memcpy fixed_size masks.
As noted in the PR, the optimization used for scalar types in std::fill
and std::fill_n is non-conforming, because it doesn't consider that
assigning a scalar type might have non-trivial side effects which are
affected by the optimization.

By changing the condition under which the optimization is done we ensure
it's only performed when safe to do so, and we also enable it for
additional types, which was the original subject of the PR.

Instead of two overloads using __enable_if<__is_scalar<T>::__value, R>
we can combine them into one and create a local variable which is either
a local copy of __value or another reference to it, depending on whether
the optimization is allowed.

This removes a use of std::__is_scalar, which is a step towards fixing
PR 115497 by removing std::__is_pointer from <bits/cpp_type_traits.h>

libstdc++-v3/ChangeLog:

	PR libstdc++/109150
	* include/bits/stl_algobase.h (__fill_a1): Combine the
	!__is_scalar and __is_scalar overloads into one and rewrite the
	condition used to decide whether to perform the load outside the
	loop.
	* testsuite/25_algorithms/fill/109150.cc: New test.
	* testsuite/25_algorithms/fill_n/109150.cc: New test.
… [PR115497]

This removes the use of the std::__is_scalar trait from <valarray>,
where it can be replaced by __is_trivial. It's used to decide whether we
can use memset to value-initialize valarray elements, but memset is
suitable for any trivial types, because value-initializing them is
equivalent to filling them with zeros.

This is another step towards removing the class templates in
<bits/cpp_type_traits.h> that conflict with Clang built-in names.

libstdc++-v3/ChangeLog:

	PR libstdc++/115497
	* include/bits/valarray_array.h (__valarray_default_construct):
	Use __is_trivial(_Tp). instead of __is_scalar<_Tp>.
…R115497]

This replaces all uses of the std::__is_pointer type trait with uses of
the new __is_pointer built-in. Since the class template was only used to
enable some performance optimizations for algorithms, we can use the
built-in when __has_builtin(__is_pointer) is true (which is the case for
GCC trunk and for current versions of Clang) and just forego the
optimization otherwise.

Removing the uses of std::__is_pointer means it can be removed from
<bits/cpp_type_traits.h>, which is another step towards fixing PR
115497.

libstdc++-v3/ChangeLog:

	PR libstdc++/115497
	* include/bits/deque.tcc (__lex_cmp_dit): Replace __is_pointer
	class template with __is_pointer(T) built-in.
	(__lexicographical_compare_aux1): Likewise.
	* include/bits/stl_algobase.h (__equal_aux1): Likewise.
	(__lexicographical_compare_aux1): Likewise.
This removes the std::__is_void trait, as it conflicts with a Clang
built-in. There is only one use of the trait, which can easily be
replaced by simpler code.

Although Clang has a hack to make the class template work despite using
a reserved name, removing std::__is_void will allow that hack to be
dropped at some future date.

libstdc++-v3/ChangeLog:

	PR libstdc++/115497
	* include/bits/cpp_type_traits.h (__is_void): Remove.
	* include/debug/helper_functions.h (_Distance_traits):
	Adjust partial specialization to match void directly, instead of
	using __is_void<T>::__type and matching __true_type.
This removes the std::__is_pointer and std::__is_scalar traits, as they
conflicts with a Clang built-in.

Although Clang has a hack to make the class templates work despite using
reserved names, removing these class templates will allow that hack to
be dropped at some future date.

libstdc++-v3/ChangeLog:

	PR libstdc++/115497
	* include/bits/cpp_type_traits.h (__is_pointer, __is_scalar):
	Remove.
	(__is_arithmetic): Do not use __is_pointer in the primary
	template. Add partial specialization for pointers.
More minor fallout from the IOR->PLUS change a little while ago.  This time on
xstormy16.

The pattern to swap nibbles actually tries to handle all the cases of IOR, XOR
and PLUS.  But when we generate PLUS earlier in the pipeline, the
simplifications/canonicalizations are slightly different resulting in the
pattern not matching.

This patch adds an alternate pattern which matches what we get now.  Basically
it looks like QImode rotate by 4, zero extended to HI.

Run in my tester to verify the regression was fixed.  Pushing to the trunk.

gcc/
	* config/stormy16/stormy16.md (swpn_zext): New pattern.
…h.cc

No functional change intended.

gcc/ChangeLog:
	* diagnostic-path.cc (diagnostic_event::meaning::dump_to_pp): Move
	here from diagnostic.cc.
	(diagnostic_event::meaning::maybe_get_verb_str): Likewise.
	(diagnostic_event::meaning::maybe_get_noun_str): Likewise.
	(diagnostic_event::meaning::maybe_get_property_str): Likewise.
	(diagnostic_path::get_first_event_in_a_function): Likewise.
	(diagnostic_path::interprocedural_p): Likewise.
	(debug): Likewise for diagnostic_path * overload.
	* diagnostic.cc (diagnostic_event::meaning::dump_to_pp): Move from
	here to diagnostic-path.cc.
	(diagnostic_event::meaning::maybe_get_verb_str): Likewise.
	(diagnostic_event::meaning::maybe_get_noun_str): Likewise.
	(diagnostic_event::meaning::maybe_get_property_str): Likewise.
	(diagnostic_path::get_first_event_in_a_function): Likewise.
	(diagnostic_path::interprocedural_p): Likewise.
	(debug): Likewise for diagnostic_path * overload.

Signed-off-by: David Malcolm <[email protected]>
No functional change intended.

gcc/ChangeLog:
	* diagnostic-format-json.cc
	(json_output_format::on_end_diagnostic): Use
	get_diagnostic_kind_text rather than embedding a duplicate copy of
	the table.
	* diagnostic-format-sarif.cc
	(make_rule_id_for_diagnostic_kind): Likewise.
	* diagnostic.cc (get_diagnostic_kind_text): New.
	* diagnostic.h (get_diagnostic_kind_text): New decl.

Signed-off-by: David Malcolm <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.