Commit Graph

198000 Commits

Author SHA1 Message Date
Iain Sandoe
e4703bd0e1 Darwin, libffi, testsuite: Ensure we pick up the convenience lib.
For several Darwin linker versions, the link paths are first traversed
looking for shared libraries, and then again looking for archives.

We want the paths to be searched for both shared and archives in order
so that we will find the non-shared libffi in the testsuite (otherwise
the installed version in the system will be found instead).

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

libffi/ChangeLog:

	* testsuite/lib/libffi.exp: Search for both shared and archive
	in each path in turn.
2023-01-22 09:32:50 +00:00
GCC Administrator
d5717e7f6f Daily bump. 2023-01-22 00:17:27 +00:00
Jerry DeLisle
48f544ad5c fortran: [PR102595]
PR fortran/102595

gcc/fortran/ChangeLog:

	* data.cc (gfc_assign_data_value): Remove check for PARAMETER in DATA.
	* primary.cc (match_variable): Add check for PARAMETER in DATA.

gcc/testsuite/ChangeLog:

	* gfortran.dg/pr88048.f90: Adjust for changed error message.
	* gfortran.dg/parameter_data0.f90: New test.
2023-01-21 15:23:19 -08:00
Iain Sandoe
046dc9d0d4 Darwin, fixincludes: Handle Apple Blocks in objc/runtime.h.
The macOS 13 SDK has unguarded Apple Blocks use in objc/runtime.h which
causes most of the objective-c tests to fail.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

fixincludes/ChangeLog:

	* fixincl.x: Regenerate.
	* inclhack.def (darwin_objc_runtime_1): New hack.
	* tests/base/objc/runtime.h: New file.
2023-01-21 17:08:30 +00:00
Iain Sandoe
442d2bdc1d Darwin, fixincludes: Handle MacOS13 SDK Apple-specific deprecations [PR107568].
The SDK for MacOS13 includes Apple-specific deprecations of some functions that
are not deprecated in Posix, C or C++ and widely used in GCC.

The fix makes the deprecation conditional on __APPLE_LOCAL_DEPRECATIONS so that
end users may still observe them but they are hidden from normal compilations.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

	PR target/107568

fixincludes/ChangeLog:

	* fixincl.x: Regenerate.
	* inclhack.def: Add a fix for MacOS13 SDK function deprecations
	in stdio.h.
	* tests/base/stdio.h (__deprecated_msg): New test.
2023-01-21 17:07:07 +00:00
GCC Administrator
1bdb1768bf Daily bump. 2023-01-21 00:16:20 +00:00
Gaius Mulley
5c4122be85 PR-108136 modula-2 meets cppcheck part 2
R-108136 modula-2 meets cppcheck part 2

This patch addresses the style warnings mentioned in the PR.
The array high style fixes to mc/keyc.mod and
gm2-libs/M2Dependent.mod provoke a rebuild of pge and mc.

gcc/m2/ChangeLog:

	* gm2-libs/Args.mod (GetArg): Check index before
	accessing array.
	* gm2-libs/M2Dependent.mod (toCString): Check index
	before accessing array.
	* mc-boot/GArgs.c: Rebuilt.
	* mc-boot/GM2Dependent.c: Rebuilt.
	* mc-boot/Gkeyc.c: Rebuilt.
	* mc/keyc.mod (seenUIntMin): Initialize once.
	(seenUIntMax): Initialize once.
	(checkLimits): Only test seenUIntMin and seenUIntMax
	once.
	* pge-boot/GArgs.c:  Rebuilt.
	* pge-boot/GM2Dependent.c: Rebuilt.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-01-20 23:39:35 +00:00
Ian Lance Taylor
0c193cabe1 libbacktrace: change PC variables from uint64_t to uintptr_t
Change variables holding PC values from uint64_t to uintptr_t.
	Patch by Björn Schäpers.
	* dwarf.c (struct function_addrs): Change low and high fields to
	uintptr_t.
	(struct unit_addrs): Likewise.
	(resolve_addr_index): Change address parameter to uintptr_t*.
	(add_unit_addr): Change lowpc and highpc parameters to uintptr_t.
	(add_function_range): Likewise.
	(struct pcrange): Change lowpc and highpc fields to uintptr_t.
	(add_low_high_range): Change add_range lowpc and highpc parameters
	to uintptr_t.
	(add_ranges_from_ranges): Likewise.
	(add_ranges_from_rnglists): Likewise.
	(add_low_high_range): Chnage lowpc and highpc variables to
	uintpr_t.
	(add_ranges_from_rnglists): Change some local variables to
	uintptr_t.
	(add_ranges_from_ranges): Change base parameter to uintptr_t.
	(add_ranges_from_rnglists): Likewise.
	(read_function_entry): Likewise.
	(resolve_addr_index): Add explicit casts to uintptr_t.
	(update_pcrange): Likewise.
	(add_ranges_from_ranges): Likewise.
	(add_ranges_from_rnglists): Likewise.
	(read_function_entry): Likewise.
2023-01-20 14:24:13 -08:00
Gaius Mulley
f71354f7b9 PR-108135 Modula2 meets clang (remove dead code and bugfix m2.flex)
These patches fix warnings (and a bug) discovered by clang. The
patch set looks longer than the changes as pge and mc needed to be
rebuilt (due to a change in the gcc/m2/gm2-libs/DynamicString.mod
library).

gcc/m2/ChangeLog:

	* gm2-gcc/m2statement.cc (gm2_gimplify_function_node):
	Remove.
	* gm2-libs/DynamicStrings.mod (Equal): Remove dead code.
	* m2.flex (<COMMENT>"<*"): Add {} for else statement.
	* m2pp.cc (hextree): Add conditional #ifdef DEBUGGING.
	* mc-boot/GDynamicStrings.c: Rebuild.
	* pge-boot/GDynamicStrings.c: Rebuild.
	* pge-boot/GFIO.c: Rebuild.
	* pge-boot/GIndexing.c: Rebuild.
	* pge-boot/GM2EXCEPTION.c: Rebuild.
	* pge-boot/GM2RTS.c: Rebuild.
	* pge-boot/GNameKey.c: Rebuild.
	* pge-boot/GPushBackInput.c: Rebuild.
	* pge-boot/GRTExceptions.c: Rebuild.
	* pge-boot/GStdIO.c: Rebuild.
	* pge-boot/GSymbolKey.c: Rebuild.
	* pge-boot/GSysStorage.c: Rebuild.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-01-20 17:51:52 +00:00
Tejas Belagod
99ea0d7611 AArch64: Gate various crypto intrinsics availability based on features
The 64-bit variant of PMULL{2} and AES instructions are available if FEAT_AES
is implemented according to the Arm ARM [1].  Similarly FEAT_SHA1 and
FEAT_SHA256 enable the use of SHA1 and SHA256 instruction variants.
This patch fixes arm_neon.h to correctly reflect the feature availability based
on '+aes' and '+sha2' as opposed to the ambiguous catch-all '+crypto'.

[1] Section D17.2.61, C7.2.215

2022-01-11  Tejas Belagod  <tejas.belagod@arm.com>

gcc/ChangeLog:

	* config/aarch64/arm_neon.h (vmull_p64, vmull_high_p64, vaeseq_u8,
	vaesdq_u8, vaesmcq_u8, vaesimcq_u8): Gate under "nothing+aes".
	(vsha1*_u32, vsha256*_u32): Gate under "nothing+sha2".

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/acle/pmull64.c: New.
	* gcc.target/aarch64/aes-fuse-1.c: Replace '+crypto' with corresponding
	feature flag based on the intrinsic.
	* gcc.target/aarch64/aes-fuse-2.c: Likewise.
	* gcc.target/aarch64/aes_1.c: Likewise.
	* gcc.target/aarch64/aes_2.c: Likewise.
	* gcc.target/aarch64/aes_xor_combine.c: Likewise.
	* gcc.target/aarch64/sha1_1.c: Likewise.
	* gcc.target/aarch64/sha256_1.c: Likewise.
	* gcc.target/aarch64/target_attr_crypto_ice_1.c: Likewise.
2023-01-20 09:43:24 +00:00
Jakub Jelinek
16bd9e14f2 niter: Fix up unused var warning [PR108457]
tree-ssa-loop-niter.cc (build_cltz_expr) gets unused variable mode
warning on some architectures where C[LT]Z_DEFINED_VALUE_AT_ZERO
macro(s) don't use the first argument (which includes the
defaults.h definitions of:
 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  0
 #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  0
Other uses of this macro avoid this problem by avoiding temporaries
which are only used as argument to those macros, the following patch
does it the same way for consistency.  Plus some formatting fixes
while at it.

2023-01-20  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/108457
	* tree-ssa-loop-niter.cc (build_cltz_expr): Use
	SCALAR_INT_TYPE_MODE (utype) directly as C[LT]Z_DEFINED_VALUE_AT_ZERO
	argument instead of a temporary.  Formatting fixes.
2023-01-20 10:23:49 +01:00
GCC Administrator
0846336de5 Daily bump. 2023-01-20 00:17:40 +00:00
Jakub Jelinek
86caab6c5d c++: Fix up handling of non-dependent subscript with static operator[] [PR108437]
As the following testcases shows, when adding static operator[]
support I've missed that the 2 build_min_non_dep_op_overload functions
need to be adjusted.  The first one we only use for the single index
case, but as cp_tree_code_length (ARRAY_REF) is 2, we were running
into an assertion there which compared nargs and expected_nargs.
For ARRAY_REF, the operator[] is either a non-static member or newly
static member, never out of class and for the static member case
if user uses single index the operator[] needs to have a single
argument as well, but the function is called with 2 - the object
it is invoked on and the index.  We need to evaluate side-effects
of the object and use just a single argument in the call - the index.
The other build_min_non_dep_op_overload overload has been added
solely for ARRAY_REF - CALL_EXPR is the other operator that accepts
variable number of operands but that one goes through different
routines.  There we asserted it is a METHOD_TYPE, so again
we shouldn't assert that but handle the case when it is not one
by making sure object's side-effects are evaluated if needed and
passing all the index arguments to the static operator[].

2023-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR c++/108437
	* cp-tree.h (keep_unused_object_arg): Declare.
	* call.cc (keep_unused_object_arg): No longer static.
	* tree.cc (build_min_non_dep_op_overload): Handle ARRAY_REF
	with overload being static member function.

	* g++.dg/cpp23/subscript12.C: New test.
	* g++.dg/cpp23/subscript13.C: New test.
2023-01-19 23:31:15 +01:00
Jakub Jelinek
9b9a989adc c++: Fix up handling of references to anon union members in initializers [PR53932]
For anonymous union members we create artificial VAR_DECLs which
have DECL_VALUE_EXPR for the actual COMPONENT_REF.  That works
just fine inside of functions (including global dynamic constructors),
because during gimplification such VAR_DECLs are gimplified as
their DECL_VALUE_EXPR.  This is also done during regimplification.

But references to these artificial vars in DECL_INITIAL expressions
aren't ever replaced by the DECL_VALUE_EXPRs, so we end up either
with link failures like on the testcase below, or worse ICEs with
LTO.

The following patch fixes those during cp_fully_fold_init where we
already walk all the trees (!data->genericize means that
function rather than cp_fold_function).

2023-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR c++/53932
	* cp-gimplify.cc (cp_fold_r): During cp_fully_fold_init replace
	DECL_ANON_UNION_VAR_P VAR_DECLs with their corresponding
	DECL_VALUE_EXPR.

	* g++.dg/init/pr53932.C: New test.
2023-01-19 23:27:34 +01:00
Jakub Jelinek
c81e68a9cd value-relation: Fix up relation_union [PR108447]
While looking at the PR, I've noticed one row in rr_union_table
is wrong.  relation_union should be commutative, but due to that
bug is not.  The following patch adds a self-test for that
property (fails without the first hunk) and fixes that line.

The actual floating point relation problem isn't fixed by this patch
though.

2023-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/108447
	* value-relation.cc (rr_union_table): Fix VREL_UNDEFINED row order.
	(relation_tests): Add self-tests for relation_{intersect,union}
	commutativity.
	* selftest.h (relation_tests): Declare.
	* function-tests.cc (test_ranges): Call it.
2023-01-19 23:26:35 +01:00
H.J. Lu
77a67e3a92 x86: Check invalid third argument to __builtin_ia32_prefetch
Check invalid third argument to __builtin_ia32_prefetch when expaning
__builtin_ia32_prefetch to avoid ICE later.

gcc/

	PR target/108436
	* config/i386/i386-expand.cc (ix86_expand_builtin): Check
	invalid third argument to __builtin_ia32_prefetch.

gcc/testsuite/

	* gcc.target/i386/pr108436.c: New test.
2023-01-19 13:40:55 -08:00
Jakub Jelinek
46644ec99c openmp: Fix up OpenMP expansion of non-rectangular loops [PR108459]
expand_omp_for_init_counts was using for the case where collapse(2)
inner loop has init expression dependent on non-constant multiple of
the outer iterator and the condition upper bound expression doesn't
depend on the outer iterator fold_unary (NEGATE_EXPR, ...).  This
will just return NULL if it can't be folded, we need fold_build1
instead.

2023-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/108459
	* omp-expand.cc (expand_omp_for_init_counts): Use fold_build1 rather
	than fold_unary for NEGATE_EXPR.

	* testsuite/libgomp.c/pr108459.c: New test.
2023-01-19 21:00:08 +01:00
David Malcolm
0d6f7b1dd6 analyzer: use dominator info in -Wanalyzer-deref-before-check [PR108455]
My integration testing [1] of -fanalyzer in GCC 13 is showing a lot of
diagnostics from the new -Wanalyzer-deref-before-check warning on
real-world C projects, and most of these seem to be false positives.

This patch updates the warning to make it much less likely to fire:
- only intraprocedural cases are now reported
- reject cases in which there are control flow paths to the check
  that didn't come through the dereference, by looking at BB dominator
  information.  This fixes a false positive seen in git-2.39.0's
  pack-revindex.c: load_revindex_from_disk (PR analyzer/108455), in
  which a shared "cleanup:" section checks "data" for NULL, and
  depending on how much of the function is executed "data" might or
  might not have already been dereferenced.

The counts of -Wanalyzer-deref-before-check diagnostics in [1]
before/after this patch show this improvement:
  Known false positives:    6 ->  0  (-6)
  Known true positives:     1 ->  1
  Unclassified positives: 123 -> 63 (-60)

[1] https://github.com/davidmalcolm/gcc-analyzer-integration-tests

gcc/analyzer/ChangeLog:
	PR analyzer/108455
	* analyzer.h (class checker_event): New forward decl.
	(class state_change_event): Indent.
	(class warning_event): New forward decl.
	* checker-event.cc (state_change_event::state_change_event): Add
	"enode" param.
	(warning_event::get_desc): Update for new param of
	evdesc::final_event ctor.
	* checker-event.h (state_change_event::state_change_event): Add
	"enode" param.
	(state_change_event::get_exploded_node): New accessor.
	(state_change_event::m_enode): New field.
	(warning_event::warning_event): New "enode" param.
	(warning_event::get_exploded_node): New accessor.
	(warning_event::m_enode): New field.
	* diagnostic-manager.cc
	(state_change_event_creator::on_global_state_change): Pass
	src_node to state_change_event ctor.
	(state_change_event_creator::on_state_change): Likewise.
	(null_assignment_sm_context::set_next_state): Pass NULL for
	new param of state_change_event ctor.
	* infinite-recursion.cc
	(infinite_recursion_diagnostic::add_final_event): Update for new
	param of warning_event ctor.
	* pending-diagnostic.cc (pending_diagnostic::add_final_event):
	Pass enode to warning_event ctor.
	* pending-diagnostic.h (evdesc::final_event): Add reference to
	warning_event.
	* sm-malloc.cc: Include "analyzer/checker-event.h" and
	"analyzer/exploded-graph.h".
	(deref_before_check::deref_before_check): Initialize new fields.
	(deref_before_check::emit): Reject warnings in which we were
	unable to determine the enodes of the dereference and the check.
	Reject warnings interprocedural warnings. Reject warnings in which
	the dereference doesn't dominate the check.
	(deref_before_check::describe_state_change): Set m_deref_enode.
	(deref_before_check::describe_final_event): Set m_check_enode.
	(deref_before_check::m_deref_enode): New field.
	(deref_before_check::m_check_enode): New field.

gcc/testsuite/ChangeLog:
	PR analyzer/108455
	* gcc.dg/analyzer/deref-before-check-1.c: Add test coverage
	involving dominance.
	* gcc.dg/analyzer/deref-before-check-pr108455-1.c: New test.
	* gcc.dg/analyzer/deref-before-check-pr108455-git-pack-revindex.c:
	New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-01-19 13:51:16 -05:00
Harald Anlauf
117848f425 Fortran: error recovery for invalid CLASS component [PR108434]
gcc/fortran/ChangeLog:

	PR fortran/108434
	* expr.cc (class_allocatable): Prevent NULL pointer dereference
	or invalid read.
	(class_pointer): Likewise.

gcc/testsuite/ChangeLog:

	PR fortran/108434
	* gfortran.dg/pr108434.f90: New test.
2023-01-19 19:12:55 +01:00
Iain Sandoe
f8cb07a7a4 modula-2, testsuite: Make libs and interfaces consistent.
In some case the libraries list was being set before gm2_init_xxx was
called.  In some cases it was omitted - this could lead to a difference
between the link libs and the interfaces (the effect of this would be
dependent on the order in which the .exps were run, which makes it also
depend on the -j and the system).

To avoid a mismatch between the module include paths and the added libs
we now make sure that they are both added in the gm_init_xxxx functions
(if finer control over granularity is needed, then we should as a TODO
add a generic gm_init_xxx that takes a library list and ensures that the
imports and libs are matched in the same order).

Also we cannot use a default variable in tcl if the source for that
variable could be absent, but something else follows, there is no way
to put an empty placeholder in.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/testsuite/ChangeLog:

	* gm2/complex/run/pass/complex-run-pass.exp: Remove gm2_link_lib.
	* gm2/iso/run/pass/iso-run-pass.exp: Likewise.
	* gm2/link/externalscaffold/pass/link-externalscaffold-pass.exp:
	* gm2/pimlib/logitech/run/pass/pimlib-logitech-run-pass.exp: Likewise.
	* gm2/pimlib/run/pass/pimlib-run-pass.exp: Likewise.
	* gm2/projects/iso/run/pass/halma/projects-iso-run-pass-halma.exp:
	Likewise.
	* gm2/projects/iso/run/pass/hello/projects-iso-run-pass-hello.exp:
	Likewise.
	* gm2/projects/pim/run/pass/hello/projects-pim-run-pass-hello.exp:
	Likewise.
	* gm2/sets/run/pass/sets-run-pass.exp: Likewise.
	* gm2/switches/none/run/pass/gm2-none.exp: Likewise.
	* gm2/switches/pic/run/pass/switches-pic-run-pass.exp: Likewise.
	* gm2/projects/pim/run/pass/random/projects-pim-run-pass-random.exp:
	Likewise, and also ensure that the -g option is appended to avoid it
	being taken as a path.
	* lib/gm2.exp: Ensure for each gm2_init_xxxx function that the set of
	libraries added matches the set of -I and -L options.
2023-01-19 17:08:47 +00:00
Gaius Mulley
5115508919 PR-108373 Update contrib/gcc_update:files_and_dependencies for Modula-2
This patch adds the dependencies for automatically generated files used
by the Modula-2 front end.

contrib/ChangeLog:

	* gcc_update (files_and_dependencies): Add dependencies for
	gcc/m2/gm2config.h.in, gcc/m2/configure,
	gcc/m2/gm2-libs/config-host, libgm2/Makefile.in,
	libgm2/aclocal.m4, libgm2/libm2cor/Makefile.in,
	libgm2/libm2pim/Makefile.in, libgm2/libm2iso/Makefile.in,
	libgm2/libm2log/Makefile.in and libgm2/libm2min/Makefile.in.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-01-19 15:00:19 +00:00
Christophe Lyon
74833b3165 aarch64: add -fno-stack-protector to some tests [PR108411]
As discussed in the PR, these recently added tests fail when the
testsuite is executed with -fstack-protector-strong.  To avoid this,
this patch adds -fno-stack-protector to dg-options.

	PR target/108411
	gcc/testsuite
	* g++.target/aarch64/bitfield-abi-warning-align16-O2-extra.C: Add
	-fno-stack-protector.
	* g++.target/aarch64/bitfield-abi-warning-align16-O2.C: Likewise.
	* g++.target/aarch64/bitfield-abi-warning-align32-O2-extra.C: Likewise.
	* g++.target/aarch64/bitfield-abi-warning-align32-O2.C: Likewise.
	* g++.target/aarch64/bitfield-abi-warning-align8-O2.C: Likewise.
	* gcc.target/aarch64/bitfield-abi-warning-align16-O2-extra.c: Likewise.
	* gcc.target/aarch64/bitfield-abi-warning-align16-O2.c: Likewise.
	* gcc.target/aarch64/bitfield-abi-warning-align32-O2-extra.c: Likewise.
	* gcc.target/aarch64/bitfield-abi-warning-align32-O2.c: Likewise.
	* gcc.target/aarch64/bitfield-abi-warning-align8-O2.c: Likewise.
2023-01-19 14:18:14 +00:00
Christophe Lyon
a38c079248 aarch64: fix ICE in aarch64_layout_arg [PR108411]
The previous patch added an assert which should not be applied to PST
types (Pure Scalable Types) because alignment does not matter in this
case.  This patch moves the assert after the PST case is handled to
avoid the ICE.

	PR target/108411
	gcc/
	* config/aarch64/aarch64.cc (aarch64_layout_arg): Improve
	comment. Move assert about alignment a bit later.
2023-01-19 14:18:14 +00:00
Richard Biener
1cfaaa4229 modula2/108144 - fix --enable-version-specific-runtime-libs
The following fixes --enable-version-specific-runtime-libs for
the modula2 target libraries.  The issue is that the install
happens via for example

toolexeclib_LTLIBRARIES = libm2cor.la

and toolexeclibdir is set to $(toolexecdir)/$(gcc_version)$(MULTISUBDIR)
but the Makefile.am do not define $(gcc_version) but instead
$(version) which is used locally to define libsubdir.  The fix
is to consistently define and use $(gcc_version), also properly
supporting --with-gcc-major-version-only

	PR modula2/108144
libgm2/
	* configure.ac: Add GCC_BASE_VER.
	* configure: Re-generate.
	* Makefile.am: Use @get_gcc_base_ver@ for gcc_version.
	* libm2cor/Makefile.am: Likewise.  Use gcc_version instead
	of version.
	* libm2iso/Makefile.am: Likewise.
	* libm2log/Makefile.am: Likewise.
	* libm2min/Makefile.am: Likewise.
	* libm2pim/Makefile.am: Likewise.
	* Makefile.in: Re-generate.
	* libm2cor/Makefile.in: Likewise.
	* libm2iso/Makefile.in: Likewise.
	* libm2log/Makefile.in: Likewise.
	* libm2min/Makefile.in: Likewise.
	* libm2pim/Makefile.in: Likewise.
2023-01-19 14:47:59 +01:00
Jakub Jelinek
05b9868b18 forwprop: Further fixes for simplify_rotate [PR108440]
As mentioned in the simplify_rotate comment, for e.g.
   ((T) ((T2) X << (Y & (B - 1)))) | ((T) ((T2) X >> ((-Y) & (B - 1))))
we already emit
   X r<< (Y & (B - 1))
as replacement.  This PR is about the
   ((T) ((T2) X << Y)) OP ((T) ((T2) X >> (B - Y)))
   ((T) ((T2) X << (int) Y)) OP ((T) ((T2) X >> (int) (B - Y)))
forms if T2 is wider than T.  Unlike e.g.
   (X << Y) OP (X >> (B - Y))
which is valid just for Y in [1, B - 1], the above 2 forms are actually
valid and do the rotates for Y in [0, B] - for Y 0 the X value is preserved
by the left shift and right logical shift by B adds just zeros (but because
the shift is in wider precision B is still valid shift count), while for
Y equal to B X is preserved through the latter shift and the former adds
just zeros.
Now, it is unclear if we in the middle-end treat rotates with rotate count
equal or larger than precision as UB or not, unlike shifts there are less
reasons to do so, but e.g. expansion of X r<< Y if there is no rotate optab
for the mode is emitted as (X << Y) | (((unsigned) X) >> ((-Y) & (B - 1)))
and so with UB on Y == B.

The following patch does multiple things:
1) for the above 2, asks the ranger if Y could be equal to B and if so,
   instead of using X r<< Y uses X r<< (Y & (B - 1))
2) for the
   ((T) ((T2) X << Y)) | ((T) ((T2) X >> ((-Y) & (B - 1))))
   ((T) ((T2) X << (int) Y)) | ((T) ((T2) X >> (int) ((-Y) & (B - 1))))
   forms that were fixed 2 days ago it only punts if Y might be in the
   [B,B2-1] range but isn't known to be in the
   [0,B][2*B,2*B][3*B,3*B]... range.  Because for Y which is a multiple
   of B but smaller than B2 it acts as a rotate too, left shift provides
   0 and (-Y) & (B - 1) is 0 and so preserves X.  Though, for the cases
   where Y is not known to be in [0,B-1] the patch also uses
   X r<< (Y & (B - 1)) rather than X r<< Y
3) as discussed with Aldy, instead of using global ranger it uses a pass
   specific copy but lazily created on first simplify_rotate that needs it;
   this e.g. handles rotate inside of if body where the guarding condition
   limits the shift count to some range which will not work with the
   global ranger (unless there is some SSA_NAME to attach the range to).

Note, e.g. on x86 X r<< (Y & (B - 1)) and X r<< Y actually emit the
same assembly because rotates work the same even for larger rotate counts,
but that is handled only during combine.

2023-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/108440
	* tree-ssa-forwprop.cc: Include gimple-range.h.
	(simplify_rotate): For the forms with T2 wider than T and shift counts of
	Y and B - Y add & (B - 1) masking for the rotate count if Y could be equal
	to B.  For the forms with T2 wider than T and shift counts of
	Y and (-Y) & (B - 1), don't punt if range could be [B, B2], but only if
	range doesn't guarantee Y < B or Y = N * B.  If range doesn't guarantee
	Y < B, also add & (B - 1) masking for the rotate count.  Use lazily created
	pass specific ranger instead of get_global_range_query.
	(pass_forwprop::execute): Disable that ranger at the end of pass if it has
	been created.

	* c-c++-common/rotate-10.c: New test.
	* c-c++-common/rotate-11.c: New test.
2023-01-19 10:00:51 +01:00
Prathamesh Kulkarni
22c75b4ed9 [aarch64] Use exact_log2 (INTVAL (operands[2])) >= 0 to gate for vec_merge patterns.
gcc/ChangeLog:
	* config/aarch64/aarch64-simd.md (aarch64_simd_vec_set<mode>): Use
	exact_log2 (INTVAL (operands[2])) >= 0 as condition for gating
	the pattern.
	(aarch64_simd_vec_copy_lane<mode>): Likewise.
	(aarch64_simd_vec_copy_lane_<vswap_width_name><mode>): Likewise.
2023-01-19 12:46:08 +05:30
Alexandre Oliva
3c99493bf3 [PR106746] drop cselib addr lookup in debug insn mem
The testcase used to get scheduled differently depending on the
presence of debug insns with MEMs.  It's not clear to me why those
MEMs affected scheduling, but the cselib pre-canonicalization of the
MEM address is not used at all when analyzing debug insns, so the
memory allocation and lookup are pure waste.  Somehow, avoiding that
waste fixes the problem, or makes it go latent.


for  gcc/ChangeLog

	PR debug/106746
	* sched-deps.cc (sched_analyze_2): Skip cselib address lookup
	within debug insns.

for  gcc/testsuite/ChangeLog

	PR debug/106746
	* gcc.target/i386/pr106746.c: New.
2023-01-19 01:09:15 -03:00
GCC Administrator
9f98cfa51b Daily bump. 2023-01-19 00:17:35 +00:00
Tobias Burnus
8e2c6e7b42 libfortran: Fix execute_command_line for Windows
On Windows, 'system' is called - that fails with -1 if the command
interpreter could not be started; on POSIX systems, if the child
process could not be started by the shell, exit(127)/_exit(127) is
called/returned. On Windows, cmd.exe (and also the PowerShell) return
errorlevel 9009.

libgfortran/ChangeLog:

	* intrinsics/execute_command_line.c (execute_command_line): On
	Windows, regard system()'s return value of 9009 as EXEC_INVALIDCOMMAND.
2023-01-18 23:31:41 +01:00
Marek Polacek
0f85ae6591 c: ICE with nullptr as case expression [PR108424]
In this ICE-on-invalid, we crash on

  gcc_assert (INTEGRAL_TYPE_P (type));

in perform_integral_promotions, because a nullptr is an INTEGER_CST,
but not INTEGRAL_TYPE_P, and check_case_value is only checking the
former.  In the test I'm testing other "shall be an integral constant
expression" contexts as well.

	PR c/108424

gcc/c-family/ChangeLog:

	* c-common.cc (check_case_value): Check INTEGRAL_TYPE_P.

gcc/testsuite/ChangeLog:

	* gcc.dg/c2x-nullptr-6.c: New test.
2023-01-18 16:49:57 -05:00
Jonathan Wakely
33237e93d5 libstdc++: Deprecate std::filesystem::u8path for C++20
P0482R6 deprecated these functions for C++20. There was a ballot comment
on the C++23 CD saying to un-deprecate it, but LEWG just rejected that,
so let's add attributes to deprecate them.

libstdc++-v3/ChangeLog:

	* include/bits/fs_path.h (u8path): Add deprecated attribute.
	* testsuite/27_io/filesystem/path/construct/90281.cc: Add
	-Wno-deprecated-declarations for C++20 and later.
	* testsuite/27_io/filesystem/path/factory/u8path-char8_t.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/factory/u8path.cc: Likewise.
	* testsuite/27_io/filesystem/path/native/string.cc: Likewise.
	* testsuite/27_io/filesystem/path/factory/u8path-depr.cc: New test.
2023-01-18 21:47:58 +00:00
Jonathan Wakely
26c68b8c31 libstdc++: Fix std::random_device::entropy() for non-posix targets
Since the r12-4515-g58f339fc5eaae7 change std::random_device::entropy()
returns non-zero for hardware sources such as RDRAND. However, the call
to the underlying _M_getentropy function is conditionally compiled
according to #if _GLIBCXX_USE_DEV_RANDOM which means it only happens for
targets that support /dev/random and /dev/urandom. This means entropy()
always returns zero for x86 Windows, even though the RDRAND and RDSEED
sources work there.

The _M_getentropy() function is always compiled into the library, it
just doesn't get called for targets without /dev/random. We can change
that just by removing the #if conditional. This is not an ABI change,
because new code will just start calling the existing _M_getentropy
function, old code that has inlined entropy() will not call it.

Similarly, the std::random_device destructor doesn't call the underlying
_M_fini function unless _GLIBCXX_USE_DEV_RANDOM is defined. That's less
of a problem because it's still true that the only resources that need
to be freed are when one of /dev/random or /dev/urandom has been opened
for reading, which is only possible when _GLIBCXX_USE_DEV_RANDOM is
defined. The _M_fini function does also destroy a random engine object
if a std::linear_congruential_engine object is used, but that destructor
is trivial and so no resources are leaked if it's not called. Remove the
preprocessor condition in the destructor too, so that we always call the
_M_fini function even if it doesn't have side effects. This makes the
destructor non-trivial for Windows and bare metal targets, but as the
class is non-copyable that shouldn't cause any ABI change in practice.

libstdc++-v3/ChangeLog:

	* include/bits/random.h (random_device) [!_GLIBCXX_USE_DEV_RANDOM]:
	Always call _M_fini and _M_getentropy.
2023-01-18 21:47:58 +00:00
Gerald Pfeifer
af7881e076 libstdc++: Minor updates to Policy Based Data Structures: Biblio
libstdc++-v3/ChangeLog:

2023-01-18  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/xml/manual/policy_data_structures_biblio.xml: Adjust links
	to www.open-std.org to use https.
	(COM: Component Model Object Technologies): Rename from...
	(The Component Object Model): ...to.
	* doc/html/manual/policy_data_structures.html: Regenerate.
2023-01-18 19:59:26 +01:00
Dimitrij Mijoski
7d0cdbbcdd libstdc++: testsuite: Simplify codecvt_unicode
Stop using unique_ptr, create some objects directly.

libstdc++-v3/ChangeLog:

	* testsuite/22_locale/codecvt/codecvt_unicode.cc: Simplify.
	* testsuite/22_locale/codecvt/codecvt_unicode.h: Simplify.
	* testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc: Simplify.
2023-01-18 18:53:11 +00:00
David Malcolm
c6a011119b analyzer: add SARD testsuite 81
A 2013 paper [1] proposed 5 simple tests for evaluating the
effectiveness of static analysis tools at detecting
CWE-121 ("Stack-based Buffer Overflow").

The tests can be found in:
  https://samate.nist.gov/SARD/test-suites/81

This patch adds theses 5 tests to -fanalyzer's testsuite, lightly
modified to add DejaGnu directives.

This is for unit-testing; for broader testing of -fanalyzer I'm working
on a separate integration testing suite that builds various real-world C
projects with -fanalyzer, currently here:
  https://github.com/davidmalcolm/gcc-analyzer-integration-tests

[1] Black, P. , Koo, H. and Irish, T. (2013), A Basic CWE-121 Buffer Overflow Effectiveness Test Suite, Proc. 6th Latin-American Symposium on Dependable Computing, Rio de Janeiro, -1, [online], https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=913117 (Accessed January 17, 2023)

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/SARD-tc117-basic-00001-min.c: New test, adapted
	from https://samate.nist.gov/SARD/test-suites/81.
	* gcc.dg/analyzer/SARD-tc1909-stack_overflow_loop.c: Likewise.
	* gcc.dg/analyzer/SARD-tc249-basic-00034-min.c: Likewise.
	* gcc.dg/analyzer/SARD-tc293-basic-00045-min.c: Likewise.
	* gcc.dg/analyzer/SARD-tc841-basic-00182-min.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-01-18 11:41:47 -05:00
Martin Jambor
db959e2500 ipa: Release body more carefully when removing nodes (PR 107944)
The code removing function bodies when the last call graph clone of a
node is removed is too aggressive when there are nodes up the
clone_of chain which still need them.  Fixed by expanding the check.

gcc/ChangeLog:

2023-01-18  Martin Jambor  <mjambor@suse.cz>

	PR ipa/107944
	* cgraph.cc (cgraph_node::remove): Check whether nodes up the
	lcone_of chain also do not need the body.
2023-01-18 15:43:30 +01:00
Richard Biener
d4abe5c456 lto/108445 - avoid LTO decl wrapping being confused by tree sharing
r13-4743 exposed more tree sharing which runs into a latent issue
with LTO decl wrapping during streaming.  The following adds a
testcase triggering the issue.

	PR lto/108445
	* gcc.dg/lto/pr108445_0.c: New testcase.
	* gcc.dg/lto/pr108445_1.c: Likewise.
2023-01-18 14:57:24 +01:00
Richard Biener
ddbe758b17 Revert "middle-end/108086 - avoid unshare_expr when remapping SSA names"
This reverts commit da85bfc750.
2023-01-18 14:57:24 +01:00
Wilco Dijkstra
c98cd1df22 libgcc: Fix uninitialized RA signing on AArch64 [PR107678]
A recent change only initializes the regs.how[] during Dwarf unwinding
which resulted in an uninitialized offset used in return address signing
and random failures during unwinding.  The fix is to encode the return
address signing state in REG_UNSAVED and a new state REG_UNSAVED_ARCHEXT.

libgcc/
	PR target/107678
	* unwind-dw2.h (REG_UNSAVED_ARCHEXT): Add new enum.
	* unwind-dw2.c (uw_update_context_1): Add REG_UNSAVED_ARCHEXT case.
	* unwind-dw2-execute_cfa.h: Use REG_UNSAVED_ARCHEXT/REG_UNSAVED to
	encode the return address signing state.
	* config/aarch64/aarch64-unwind.h (aarch64_demangle_return_addr)
	Check current return address signing state.
	(aarch64_frob_update_contex): Remove.
2023-01-18 12:20:35 +00:00
Murray Steele
f54e31ddef arm: fix __arm_vld1q_z* and __arm_vst1q_p* intrinsics [PR108442]
The MVE ACLE allows for __ARM_MVE_PRESERVE_USER_NAMESPACE to be defined,
which removes definitions for intrinsic functions without the __arm_
prefix. __arm_vld1q_z* and __arm_vst1q_p* are currently implemented via
calls to vldr* and vstr*, which results in several compile-time errors when
__ARM_MVE_PRESERVE_USER_NAMESPACE is defined. This patch replaces these
with calls to their prefixed counterparts, __arm_vldr* and __arm_str*,
and adds a test covering the definition of __ARM_MVE_PRESERVE_USER_NAMESPACE.

gcc/ChangeLog:

	PR target/108442
	* config/arm/arm_mve.h (__arm_vst1q_p_u8): Use prefixed intrinsic
	function.
	(__arm_vst1q_p_s8): Likewise.
	(__arm_vld1q_z_u8): Likewise.
	(__arm_vld1q_z_s8): Likewise.
	(__arm_vst1q_p_u16): Likewise.
	(__arm_vst1q_p_s16): Likewise.
	(__arm_vld1q_z_u16): Likewise.
	(__arm_vld1q_z_s16): Likewise.
	(__arm_vst1q_p_u32): Likewise.
	(__arm_vst1q_p_s32): Likewise.
	(__arm_vld1q_z_u32): Likewise.
	(__arm_vld1q_z_s32): Likewise.
	(__arm_vld1q_z_f16): Likewise.
	(__arm_vst1q_p_f16): Likewise.
	(__arm_vld1q_z_f32): Likewise.
	(__arm_vst1q_p_f32): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/mve/general/preserve_user_namespace_1.c: New test.
2023-01-18 11:58:14 +00:00
Takayuki 'January June' Suwa
a4b05944b7 xtensa: Optimize inversion of the MSB
Such operation can be done either bitwise-XOR or addition with -2147483648,
but the latter is one byte less if TARGET_DENSITY.

gcc/ChangeLog:

	* config/xtensa/xtensa.md (xorsi3_internal):
	Rename from the original of "xorsi3".
	(xorsi3): New expansion pattern that emits addition rather than
	bitwise-XOR when the second source is a constant of -2147483648
	if TARGET_DENSITY.
2023-01-18 02:28:13 -08:00
Kewen Lin
aaf29ae6cd rs6000: Fix typo on vec_vsubcuq in rs6000-overload.def [PR108396]
As Andrew pointed out in PR108396, there is one typo in
rs6000-overload.def on built-in function vec_vsubcuq:

  [VEC_VSUBCUQ, vec_vsubcuqP, __builtin_vec_vsubcuq]

"vec_vsubcuqP" should be "vec_vsubcuq", this typo caused
us to define vec_vsubcuqP in rs6000-vecdefines.h instead
of vec_vsubcuq, so that compiler is not able to realize
the built-in function name vec_vsubcuq any more.

Co-authored-By: Andrew Pinski <apinski@marvell.com>

	PR target/108396

gcc/ChangeLog:

	* config/rs6000/rs6000-overload.def (VEC_VSUBCUQ): Fix typo
	vec_vsubcuqP with vec_vsubcuq.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr108396.c: New test.
2023-01-18 02:34:25 -06:00
Kewen Lin
5d9529687d rs6000: Teach rs6000_opaque_type_invalid_use_p about gcall [PR108348]
PR108348 shows one special case that MMA opaque types are
used in function arguments and treated as pass by reference,
it results in one copying from argument to a temp variable,
since this copying happens before rs6000_function_arg check,
it can cause ICE without MMA support then.  This patch is to
teach function rs6000_opaque_type_invalid_use_p to check if
any function argument in a gcall stmt has the invalid use of
MMA opaque types.

btw, I checked the handling on return value, it doesn't have
this kind of issue as its checking and error emission is quite
early, so this doesn't handle function return value.

	PR target/108348

gcc/ChangeLog:

	* config/rs6000/rs6000.cc (rs6000_opaque_type_invalid_use_p): Add the
	support for invalid uses of MMA opaque type in function arguments.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr108348-1.c: New test.
	* gcc.target/powerpc/pr108348-2.c: New test.
2023-01-18 02:34:19 -06:00
liuhongt
159b0f41ad Don't add crtfastmath.o for -shared.
Patches [1] and [2] fixed PR55522 for x86-linux but left all other x86
targets unfixed (x86-cygwin, x86-darwin and x86-mingw32).
This patch applies a similar change to other specs using crtfastmath.o.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608528.html
[2] https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608529.html

gcc/ChangeLog:

	PR target/55522
	* config/i386/cygwin.h (ENDFILE_SPEC): Link crtfastmath.o
	whenever -mdaz-ftz is specified. Don't link crtfastmath.o when
	-share or -mno-daz-ftz is specified.
	* config/i386/darwin.h (ENDFILE_SPEC): Ditto.
	* config/i386/mingw32.h (ENDFILE_SPEC): Ditto.
2023-01-18 10:46:17 +08:00
Jerry DeLisle
04d7cc1653 Fix bug number reference in Changelogs 2023-01-17 17:30:49 -08:00
GCC Administrator
8d07b193d7 Daily bump. 2023-01-18 00:17:21 +00:00
Harald Anlauf
a75760374e Fortran: fix ICE in get_expr_storage_size [PR108421]
gcc/fortran/ChangeLog:

	PR fortran/108421
	* interface.cc (get_expr_storage_size): Check that we actually have
	an integer value before trying to extract it with mpz_get_si.

gcc/testsuite/ChangeLog:

	PR fortran/108421
	* gfortran.dg/pr108421.f90: New test.
2023-01-17 19:35:17 +01:00
Ian Lance Taylor
6d80690132 go: define two builtin functions used by middle-end
PR go/108426
	* go-gcc.cc (Gcc_backend::Gcc_backend): Define __builtin_ctzl and
	__builtin_clzl.  Patch by Andrew Pinski.
2023-01-17 09:05:20 -08:00
Jose E. Marchesi
3b81f5c4d8 bpf: disable -fstack-protector in BPF
The stack protector is not supported in BPF.  This patch disables
-fstack-protector in bpf-* targets, along with the emission of a note
indicating that the feature is not supported in this platform.

Regtested in bpf-unknown-none.

gcc/ChangeLog:

	* config/bpf/bpf.cc (bpf_option_override): Disable
	-fstack-protector.
2023-01-17 17:16:32 +01:00
Gaius Mulley
1fce7d29eb Obfuscate the copyright text in gcc/m2/mc/mcOptions.mod
Obfuscate the copyright text in gcc/m2/mc/mcOptions.mod so that the
year change script does not attempt to modify the text.  The year
is determined at runtime and therefore the text requires
no modification.  The middle printf (C) can be replaced by
a unicode character in the future.

gcc/m2/ChangeLog:

	* mc-boot/GM2RTS.c: Rebuilt.
	* mc-boot/GM2RTS.h: Rebuilt.
	* mc-boot/Gdecl.c: Rebuilt.
	* mc-boot/GmcOptions.c: Rebuilt.
	* mc/mcOptions.mod (displayVersion):
	Split first printf into three components

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-01-17 15:39:59 +00:00