platform/upstream/gcc.git
21 months agoIBM zSystems: Fix TARGET_D_CPU_VERSIONS
Stefan Schulze Frielinghaus [Tue, 24 Jan 2023 19:23:07 +0000 (20:23 +0100)]
IBM zSystems: Fix TARGET_D_CPU_VERSIONS

In the context of D the interpretation of S390, S390X, and SystemZ is a
bit fuzzy.  The wording S390X was wrongly deprecated in favour of
SystemZ by commit
https://github.com/dlang/dlang.org/commit/3b50a4c3faf01c32234d0ef8be5f82915a61c23f
Thus, SystemZ is used for 64-bit targets, now, and S390 for 31-bit
targets.  However, in TARGET_D_CPU_VERSIONS depending on TARGET_ZARCH we
set the CPU version to SystemZ.  This is also the case if compiled for
31-bit targets leading to the following error:

libphobos/libdruntime/core/sys/posix/sys/stat.d:967:13: error: static assert:  '96u == 144u' is false
  967 |             static assert(stat_t.sizeof == 144);
      |             ^

Thus in order to keep this patch simple I went for keeping SystemZ for
64-bit targets and S390, as usual, for 31-bit targets and dropped the
distinction between ESA and z/Architecture.

gcc/ChangeLog:

* config/s390/s390-d.cc (s390_d_target_versions): Fix detection
of CPU version.

21 months agoChange m2 lexical analysis to optionally consume C comments.
Gaius Mulley [Tue, 24 Jan 2023 19:21:20 +0000 (19:21 +0000)]
Change m2 lexical analysis to optionally consume C comments.

This patch allows a subsequent patch to turn on/off the consuming
of C comments.

gcc/m2/ChangeLog:

* m2.flex (cpreprocessor): Add temporary variable
which is initialized to 0.
(commentCLevel): New variable.
(endOfCComment): New function.
(splitSlashStar): New function to split /* into / and *
tokens.
(COMMENTC): New flex state.
("/*"): New rule to test whether we should treat /*
as a single token or as two tokens.
(<COMMENTC>.): New rule to skip a character.
(<COMMENTC>\n.*): New rule to consume the line.
(<COMMENTC>"*/"): New rule to call endOfCComment.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
21 months agoBugfix ensure RTentity is a dependent of RTco.cc
Gaius Mulley [Tue, 24 Jan 2023 17:33:18 +0000 (17:33 +0000)]
Bugfix ensure RTentity is a dependent of RTco.cc

RTco is a definition for C module and therefore there is no
RTco.mod.  The RTco.cc uses RTentity and the import in RTco.def
ensures that cc1gm2 can build a graph of all dependencies
should -fscaffold-static be used.

gcc/m2/ChangeLog:

* gm2-libs-iso/RTco.def: Import RTentity.
Declare RTco as a definition for C module.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
21 months agoarm: Make MVE masked stores read memory operand [PR 108177]
Andre Vieira [Tue, 24 Jan 2023 16:59:23 +0000 (16:59 +0000)]
arm: Make MVE masked stores read memory operand [PR 108177]

This patch adds the memory operand of MVE masked stores as input operands to
mimic the 'partial' writes, to prevent erroneous write-after-write
optimizations as described in the PR.

gcc/ChangeLog:

PR target/108177
* config/arm/mve.md (mve_vstrbq_p_<supf><mode>, mve_vstrhq_p_fv8hf,
mve_vstrhq_p_<supf><mode>, mve_vstrwq_p_<supf>v4si): Add memory operand
as input operand.

gcc/testsuite/ChangeLog:

* gcc.target/arm/mve/pr108177-1-run.c: New test.
* gcc.target/arm/mve/pr108177-1.c: New test.
* gcc.target/arm/mve/pr108177-10-run.c: New test.
* gcc.target/arm/mve/pr108177-10.c: New test.
* gcc.target/arm/mve/pr108177-11-run.c: New test.
* gcc.target/arm/mve/pr108177-11.c: New test.
* gcc.target/arm/mve/pr108177-12-run.c: New test.
* gcc.target/arm/mve/pr108177-12.c: New test.
* gcc.target/arm/mve/pr108177-13-run.c: New test.
* gcc.target/arm/mve/pr108177-13.c: New test.
* gcc.target/arm/mve/pr108177-14-run.c: New test.
* gcc.target/arm/mve/pr108177-14.c: New test.
* gcc.target/arm/mve/pr108177-2-run.c: New test.
* gcc.target/arm/mve/pr108177-2.c: New test.
* gcc.target/arm/mve/pr108177-3-run.c: New test.
* gcc.target/arm/mve/pr108177-3.c: New test.
* gcc.target/arm/mve/pr108177-4-run.c: New test.
* gcc.target/arm/mve/pr108177-4.c: New test.
* gcc.target/arm/mve/pr108177-5-run.c: New test.
* gcc.target/arm/mve/pr108177-5.c: New test.
* gcc.target/arm/mve/pr108177-6-run.c: New test.
* gcc.target/arm/mve/pr108177-6.c: New test.
* gcc.target/arm/mve/pr108177-7-run.c: New test.
* gcc.target/arm/mve/pr108177-7.c: New test.
* gcc.target/arm/mve/pr108177-8-run.c: New test.
* gcc.target/arm/mve/pr108177-8.c: New test.
* gcc.target/arm/mve/pr108177-9-run.c: New test.
* gcc.target/arm/mve/pr108177-9.c: New test.
* gcc.target/arm/mve/pr108177-main.x: New test include.
* gcc.target/arm/mve/pr108177.x: New test include.

21 months agoC-SKY: Fix wrong sysroot suffix when disable multilib.
Xianmiao Qu [Tue, 24 Jan 2023 16:14:46 +0000 (00:14 +0800)]
C-SKY: Fix wrong sysroot suffix when disable multilib.

The SYSROOT_SUFFIX_SPEC works even when multilib is disabled.
So when build no-multilib glibc toolchain and the options are
not same as MULTILIB_DEFAULTS, the sysroot will specify wrong
because the libc will not be installed as such.
This bug causes glibc regression test error:
  https://sourceware.org/pipermail/libc-testresults/2023q1/010706.html
The error is:
  /scratch/jmyers/glibc-bot/install/compilers/csky-linux-gnuabiv2/csky-glibc-linux-gnuabiv2/bin/ld: cannot find -lc: No such file or directory

gcc/
* config.gcc(csky-*-linux*): Define CSKY_ENABLE_MULTILIB
and only include 'csky/t-csky-linux' when enable multilib.
* config/csky/csky-linux-elf.h(SYSROOT_SUFFIX_SPEC): Don't
define it when disable multilib.

21 months agotree-optimization/108500 - avoid useless fast-query compute in CFG cleanup
Richard Biener [Tue, 24 Jan 2023 09:49:18 +0000 (10:49 +0100)]
tree-optimization/108500 - avoid useless fast-query compute in CFG cleanup

CFG cleanup computes dominators before the loop over blocks looking
for merging opportunities.  That computes also the fast-query DFS
numbers but that's a bit pointless since any CFG cleanup will invalidate
them immediately (they are re-computed before fixing up loops).
The following avoids this and fixes the SIGSEGV due to the deep
recursion in assign_dfs_numbers after inlining very many small
functions.

PR tree-optimization/108500
* dominance.h (calculate_dominance_info): Add parameter
to indicate fast-query compute, defaulted to true.
* dominance.cc (calculate_dominance_info): Honor
fast-query compute parameter.
* tree-cfgcleanup.cc (cleanup_tree_cfg_noloop): Do
not compute the dominator fast-query DFS numbers.

21 months agooptions: fix cl_target_option_print_diff() with strings
Eric Biggers [Tue, 24 Jan 2023 10:54:41 +0000 (11:54 +0100)]
options: fix cl_target_option_print_diff() with strings

Fix an obvious copy-and-paste error where ptr1 was used instead of ptr2.
This bug caused the dump file produced by -fdump-ipa-inline-details to
not correctly show the difference in target options when a function
could not be inlined due to a target option mismatch.

gcc/ChangeLog:
PR bootstrap/90543
* optc-save-gen.awk: Fix copy-and-paste error.

Signed-off-by: Eric Biggers <ebiggers@google.com>
21 months agoc++: Handle structured bindings like anon unions in initializers [PR108474]
Jakub Jelinek [Tue, 24 Jan 2023 10:28:00 +0000 (11:28 +0100)]
c++: Handle structured bindings like anon unions in initializers [PR108474]

As reported by Andrew Pinski, structured bindings (with the exception
of the ones using std::tuple_{size,element} and get which are really
standalone variables in addition to the binding one) also use
DECL_VALUE_EXPR and needs the same treatment in static initializers.

On Sun, Jan 22, 2023 at 07:19:07PM -0500, Jason Merrill wrote:
> Though, actually, why not instead fix expand_expr_real_1 (and staticp) to
> look through DECL_VALUE_EXPR?

Doing it when emitting the initializers seems to be too late to me,
we in various spots try to put parts of the static var DECL_INITIAL expressions
into the IL, or e.g. for varpool purposes remember which vars are referenced
there.

This patch moves it to record_reference, which is called from varpool_node::analyze
and so about the same time as gimplification of the bodies which also
replaces DECL_VALUE_EXPRs.

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

PR c++/108474
* cgraphbuild.cc: Include gimplify.h.
(record_reference): Replace VAR_DECLs with DECL_HAS_VALUE_EXPR_P with
their corresponding DECL_VALUE_EXPR expressions after unsharing.

* cp-gimplify.cc (cp_fold_r): Revert 2023-01-19 changes.

* g++.dg/cpp1z/decomp57.C: New test.
* g++.dg/cpp1z/decomp58.C: New test.

21 months agoarm: Fix inclusion of arm-mlib.h header more than once (pr108505).
Srinath Parvathaneni [Tue, 24 Jan 2023 09:57:52 +0000 (09:57 +0000)]
arm: Fix inclusion of arm-mlib.h header more than once (pr108505).

The patch fixes the build issue for arm-none-eabi target configured with
--with-multilib-list=aprofile,rmprofile, in which case the header file
arm/arm-mlib.h is being included more than once and the toolchain build
is failing (PR108505).

gcc/ChangeLog:

2023-01-24  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

PR target/108505
* config.gcc (tm_file): Move the variable out of loop.

21 months agotestsuite: Fix gcc.dg/vect/vect-bitfield-write-[23].c on SPARC [PR107808]
Rainer Orth [Tue, 24 Jan 2023 07:49:44 +0000 (08:49 +0100)]
testsuite: Fix gcc.dg/vect/vect-bitfield-write-[23].c on SPARC [PR107808]

The gcc.dg/vect/vect-bitfield-write-[23].c tests FAIL on 32 and 64-bit
SPARC:

FAIL: gcc.dg/vect/vect-bitfield-write-2.c -flto -ffat-lto-objects
scan-tree-dump-times vect "vectorized 1 loops" 1
FAIL: gcc.dg/vect/vect-bitfield-write-2.c scan-tree-dump-times vect
"vectorized 1 loops" 1
FAIL: gcc.dg/vect/vect-bitfield-write-3.c -flto -ffat-lto-objects
scan-tree-dump-times vect "vectorized 1 loops" 1
FAIL: gcc.dg/vect/vect-bitfield-write-3.c scan-tree-dump-times vect
"vectorized 1 loops" 1

As discussed in the PR, they require vect_long_long support, but fail
to require that.

This patch fixes this.

Tested on sparc-sun-solaris2.11 and i386-pc-solaris2.11.

2023-01-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
PR testsuite/107808
* gcc.dg/vect/vect-bitfield-write-2.c: Require vect_long_long.
* gcc.dg/vect/vect-bitfield-write-3.c: Likewise.

21 months agotestsuite: Fix gcc.dg/vect/vect-fmax-1.c etc. on SPARC [PR104756]
Rainer Orth [Tue, 24 Jan 2023 07:48:11 +0000 (08:48 +0100)]
testsuite: Fix gcc.dg/vect/vect-fmax-1.c etc. on SPARC [PR104756]

The gcc.dg/vect/vect-fmax-?.c etc. tests FAIL on 32 and 64-bit SPARC:

FAIL: gcc.dg/vect/vect-fmax-1.c -flto -ffat-lto-objects scan-tree-dump vect
"Detected reduction"
FAIL: gcc.dg/vect/vect-fmax-1.c scan-tree-dump vect "Detected reduction"
FAIL: gcc.dg/vect/vect-fmax-2.c -flto -ffat-lto-objects scan-tree-dump vect
"Detected reduction"
FAIL: gcc.dg/vect/vect-fmax-2.c scan-tree-dump vect "Detected reduction"
FAIL: gcc.dg/vect/vect-fmax-3.c -flto -ffat-lto-objects scan-tree-dump vect
"Detected reduction"
FAIL: gcc.dg/vect/vect-fmax-3.c scan-tree-dump vect "Detected reduction"
FAIL: gcc.dg/vect/vect-fmin-1.c -flto -ffat-lto-objects scan-tree-dump vect
"Detected reduction"
FAIL: gcc.dg/vect/vect-fmin-1.c -flto -ffat-lto-objects scan-tree-dump vect
"Detected reduction"
FAIL: gcc.dg/vect/vect-fmin-1.c scan-tree-dump vect "Detected reduction"
FAIL: gcc.dg/vect/vect-fmin-1.c scan-tree-dump vect "Detected reduction"
FAIL: gcc.dg/vect/vect-fmin-2.c -flto -ffat-lto-objects scan-tree-dump vect
"Detected reduction"
FAIL: gcc.dg/vect/vect-fmin-2.c scan-tree-dump vect "Detected reduction"
FAIL: gcc.dg/vect/vect-fmin-3.c -flto -ffat-lto-objects scan-tree-dump vect
"Detected reduction"
FAIL: gcc.dg/vect/vect-fmin-3.c scan-tree-dump vect "Detected reduction"

As discussed in the PR, they require vect_float support, but the tests
don't declare it.

This patch fixes this.

Tested on sparc-sun-solaris2.11 and i386-pc-solaris2.11.

2023-01-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
PR testsuite/104756
* gcc.dg/vect/vect-fmax-1.c: Require vect_float.
* gcc.dg/vect/vect-fmax-2.c: Likewise.
* gcc.dg/vect/vect-fmax-3.c: Likewise.
* gcc.dg/vect/vect-fmin-1.c: Likewise.
* gcc.dg/vect/vect-fmin-2.c: Likewise.
* gcc.dg/vect/vect-fmin-3.c: Likewise.

21 months agoLoongArch: Fixed a compilation failure with '%c' in inline assembly [PR107731].
Lulu Cheng [Wed, 18 Jan 2023 03:06:56 +0000 (11:06 +0800)]
LoongArch: Fixed a compilation failure with '%c' in inline assembly [PR107731].

Co-authored-by: Yang Yujie <yangyujie@loongson.cn>
PR target/107731

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_classify_address):
Add precessint for CONST_INT.
(loongarch_print_operand_reloc): Operand modifier 'c' is supported.
(loongarch_print_operand): Increase the processing of '%c'.
* doc/extend.texi: Adds documents for LoongArch operand modifiers.
And port the public operand modifiers information to this document.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/tst-asm-const.c: Moved to...
* gcc.target/loongarch/pr107731.c: ...here.

21 months agoc++: TARGET_EXPR collapsing [PR107303]
Jason Merrill [Mon, 23 Jan 2023 21:25:07 +0000 (16:25 -0500)]
c++: TARGET_EXPR collapsing [PR107303]

In r13-2978 I tried to eliminate TARGET_EXPR around TARGET_EXPR by
discarding the outer one, but as in this testcase that breaks if the
TARGET_EXPR_SLOT of the outer one is used elsewhere.  But it should always
be safe to strip the inner one; if its slot were reused, there would be a
COMPOUND_EXPR around the TARGET_EXPR.

For 107329, if we're setting *walk_subtrees, we also need to fold
TARGET_EXPR_CLEANUP.

PR c++/107303
PR c++/107329

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fold_r) [TARGET_EXPR]: In case of double
TARGET_EXPR, keep the outer one instead of the inner one.
(maybe_replace_decl): New.

gcc/testsuite/ChangeLog:

* g++.dg/ext/builtin-shufflevector-5.C: New test.
* g++.dg/init/new51.C: New test.

21 months agoDaily bump.
GCC Administrator [Tue, 24 Jan 2023 00:17:23 +0000 (00:17 +0000)]
Daily bump.

21 months agoc++: TARGET_EXPR_ELIDING_P and std::move [PR107267]
Jason Merrill [Mon, 23 Jan 2023 22:14:11 +0000 (17:14 -0500)]
c++: TARGET_EXPR_ELIDING_P and std::move [PR107267]

With -ffold-simple-inlines, we turn calls to std::move into the static_cast
equivalent.  In this testcase, this exposes the FindResult temporary to copy
elision which is not specified by the standard, through an optimization in
gimplify_modify_expr_rhs.  Since the type is not TREE_ADDRESSABLE, this is
not detectable by the user, so we just need to soften the assert.

PR c++/107267

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_gimplify_init_expr): Allow unexpected elision
of trivial types.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/move2.C: New test.

21 months agoFortran: fix NULL pointer dereference in gfc_check_dependency [PR108502]
Harald Anlauf [Mon, 23 Jan 2023 21:13:44 +0000 (22:13 +0100)]
Fortran: fix NULL pointer dereference in gfc_check_dependency [PR108502]

gcc/fortran/ChangeLog:

PR fortran/108502
* dependency.cc (gfc_check_dependency): Prevent NULL pointer
dereference while recursively checking expressions.

gcc/testsuite/ChangeLog:

PR fortran/108502
* gfortran.dg/pr108502.f90: New test.

21 months agoc++: Quash bogus -Wunused-value with new [PR107797]
Marek Polacek [Thu, 19 Jan 2023 22:12:34 +0000 (17:12 -0500)]
c++: Quash bogus -Wunused-value with new [PR107797]

We shouldn't emit "right operand of comma operator has no effect"
when that comma operator was created by the compiler for "new int{}".
convert_to_void/COMPOUND_EXPR already checks warning_suppressed_p so
we can just suppress -Wunused-value.

PR c++/107797

gcc/cp/ChangeLog:

* cvt.cc (ocp_convert): copy_warning when creating a new
COMPOUND_EXPR.
* init.cc (build_new_1): Suppress -Wunused-value on
compiler-generated COMPOUND_EXPRs.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wunused-value-1.C: New test.

21 months agoc++: vector of class with bool ctor [PR108195]
Jason Merrill [Mon, 23 Jan 2023 20:03:47 +0000 (15:03 -0500)]
c++: vector of class with bool ctor [PR108195]

The transformation done by r13-4564 to use the iterator constructor instead
of the initializer-list constructor breaks if the iterator pointers are
themselves treated as elements of an initializer-list, so check for that.

PR c++/108195

gcc/cp/ChangeLog:

* call.cc (build_user_type_conversion_1): Check whether the
iterators also find a list ctor.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist-vect2.C: New test.

21 months agoFortran: avoid ICE on invalid array subscript triplets [PR108501]
Harald Anlauf [Mon, 23 Jan 2023 20:19:03 +0000 (21:19 +0100)]
Fortran: avoid ICE on invalid array subscript triplets [PR108501]

gcc/fortran/ChangeLog:

PR fortran/108501
* interface.cc (get_expr_storage_size): Check array subscript triplets
that we actually have integer values before trying to extract with
mpz_get_si.

gcc/testsuite/ChangeLog:

PR fortran/108501
* gfortran.dg/pr108501.f90: New test.

21 months agoFortran: fix ICE in check_charlen_present [PR108420]
Harald Anlauf [Mon, 16 Jan 2023 20:41:09 +0000 (21:41 +0100)]
Fortran: fix ICE in check_charlen_present [PR108420]

gcc/fortran/ChangeLog:

PR fortran/108420
* iresolve.cc (check_charlen_present): Preserve character length if
there is no array constructor.

gcc/testsuite/ChangeLog:

PR fortran/108420
* gfortran.dg/pr108420.f90: New test.

21 months agoc++: result location and explicit inst [PR108496]
Jason Merrill [Mon, 23 Jan 2023 18:33:07 +0000 (13:33 -0500)]
c++: result location and explicit inst [PR108496]

In r13-4469 we started to build the RESULT_DECL in grokdeclarator, while we
still know the location of the return type.  But in this testcase, we hit
that code again when parsing the explicit instantiation, and clobber the
DECL_RESULT that was previously used in parsing the function.  So, only set
DECL_RESULT if it isn't already set.

PR c++/108496

gcc/cp/ChangeLog:

* decl.cc (grokdeclarator): Check whether DECL_RESULT is already
set.

gcc/testsuite/ChangeLog:

* g++.dg/template/explicit-instantiation5.C: New test.

21 months agolibstdc++: [_GLIBCXX_DEBUG] Remove useless constructor checks
François Dumont [Mon, 23 Jan 2023 05:26:34 +0000 (06:26 +0100)]
libstdc++: [_GLIBCXX_DEBUG] Remove useless constructor checks

Creating a safe iterator from a normal iterator is done within the library where we
already know that it is done correctly. The rare situation where a user would use safe
iterators for his own purpose is non-Standard code so outside _GLIBCXX_DEBUG scope. For
those reasons the __msg_init_singular is useless and can be removed.

Additionally in the copy constructor used for post-increment and post-decrement operators
the __msg_init_copy_singular check can also be ommitted because of the preliminary
__msg_bad_incr and __msg_bad_decr checks.

libstdc++-v3/ChangeLog:

* include/debug/safe_iterator.h (_Safe_iterator<>::_Unchecked): New.
(_Safe_iterator(const _Safe_iterator&, _Unchecked)): New.
(_Safe_iterator::operator++(int)): Use latter.
(_Safe_iterator::operator--(int)): Likewise.
(_Safe_iterator(_Iterator, const _Safe_sequence_base*)): Remove !_M_insular()
check.
* include/debug/safe_local_iterator.h (_Safe_local_iterator<>::_Unchecked):
New.
(_Safe_local_iterator(const _Safe_local_iterator&, _Unchecked)): New.
(_Safe_local_iterator::operator++(int)): Use latter.
* src/c++11/debug.cc (_S_debug_messages): Add as comment the _Debug_msg_id
entry associated to the array entry.

21 months agomodula-2, driver, Front end: Revise handling of I and L paths [PR108182].
Iain Sandoe [Wed, 11 Jan 2023 10:22:34 +0000 (10:22 +0000)]
modula-2, driver, Front end: Revise handling of I and L paths [PR108182].

The adds the includes in the FE as done in other GCC languages.
It also revises the library handling to avoid additional -L options
from hiding LIBDIR.

For the include/import paths as presented to the front end initialisation,
we capture them and then arrange to emit the 'standard library' paths in
the same order as specified for C.

The specs are tidied up.

The use of the internal prefix also fixes searching in a relocated compiler.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR modula2/108182
PR modula2/108480

gcc/m2/ChangeLog:

* Make-lang.in: Pass libsubdir to the language init
build.
* gm2-lang.cc (INCLUDE_VECTOR): Define.
(add_one_import_path): New.
(add_m2_import_paths): New.
(gm2_langhook_post_options): Arrange to add the include
paths (and add the system ones) in the same order as C
uses.
* gm2spec.cc (build_archive_path): Remove.
(add_default_combination): Remove.
(add_default_archives): Remove.
(add_default_libs): We no longer need a '-L' option, just
emit the -l and each library in use.
(build_include_path): Remove.
(add_include): Remove.
(add_default_includes): Remove.
(library_installed): Remove.
(check_valid_library): Remove.
(check_valid_list): Remove.
(convert_abbreviation): Diagnose unhandled cases.
(lang_specific_driver): Skip options where we will add back
a validated version.
* lang-specs.h (M2CPP): Reformat, append %I when -fcpp is not
in use.  Revise the cc1gm2 spec to omit mentioning options that
are handled in the c pre-processor line.
* lang.opt: Allow preprocessing and path options as input to the
cc1gm2 invocation, so that they can be passed to the preprocessor
invocation.

21 months agomodula-2: Fix stack size request in initPreemptive [PR108405]
Iain Sandoe [Sat, 14 Jan 2023 10:20:47 +0000 (10:20 +0000)]
modula-2: Fix stack size request in initPreemptive [PR108405]

As noted in the PR, the problem is that we make a request for additional
stack that violates the constraints on some systems.

This patch chooses a value that is divisible by common OS page sizes.

TODO: the user value should be checked and then an exception thrown if it
is not suitable.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR modula2/108405

gcc/m2/ChangeLog:

* gm2-libs-iso/Preemptive.mod (initPreemptive): Use a value for
extra space that is divisible by common OS pagesizes.

21 months agoarm: Documentation fix for -mbranch-protection option.
Srinath Parvathaneni [Mon, 23 Jan 2023 13:37:07 +0000 (13:37 +0000)]
arm: Documentation fix for -mbranch-protection option.

This patch fixes the documentation for -mbranch-protection command line option.

gcc/ChangeLog:

2023-01-23  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

* doc/invoke.texi (-mbranch-protection): Update documentation.

21 months agosparc: Don't add crtfastmath.o for -shared
Richard Biener [Fri, 13 Jan 2023 07:54:33 +0000 (08:54 +0100)]
sparc: Don't add crtfastmath.o for -shared

Don't add crtfastmath.o for -shared to avoid altering the FP
environment when loading a shared library.

PR target/55522
* config/sparc/freebsd.h (ENDFILE_SPEC): Don't add crtfastmath.o
for -shared.
* config/sparc/linux.h (ENDFILE_SPEC): Likewise.
* config/sparc/linux64.h (ENDFILE_SPEC): Likewise.
* config/sparc/sp-elf.h (ENDFILE_SPEC): Likewise.
* config/sparc/sp64-elf.h (ENDFILE_SPEC): Likewise.

21 months agoarm: Add support for new frame unwinding instruction "0xb5".
Srinath Parvathaneni [Mon, 23 Jan 2023 11:13:18 +0000 (11:13 +0000)]
arm: Add support for new frame unwinding instruction "0xb5".

This patch adds support for Arm frame unwinding instruction "0xb5" [1]. When
an exception is taken and "0xb5" instruction is encounter during runtime
stack-unwinding, we use effective vsp as modifier in pointer authentication.
On completion of stack unwinding if "0xb5" instruction is not encountered
then CFA will be used as modifier in pointer authentication.

[1] https://github.com/ARM-software/abi-aa/releases/download/2022Q3/ehabi32.pdf

libgcc/ChangeLog:

2022-11-09  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

* config/arm/pr-support.c (__gnu_unwind_execute): Decode opcode
"0xb5".

21 months agoarm: Add support for dwarf debug directives and pseudo hard-register for PAC feature.
Srinath Parvathaneni [Mon, 23 Jan 2023 11:07:29 +0000 (11:07 +0000)]
arm: Add support for dwarf debug directives and pseudo hard-register for PAC feature.

This patch teaches the DWARF support in gcc about RA_AUTH_CODE pseudo hard-register and also
updates the ".save", ".cfi_register", ".cfi_offset", ".cfi_restore" directives accordingly.
This patch also adds support to emit ".pacspval" directive when "pac ip, lr, sp" instruction
in generated in the assembly.

RA_AUTH_CODE register number is 107 and it's dwarf register number is 143.

Applying this patch on top of PACBTI series posted here
https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599658.html and when compiling the following
test.c with "-march=armv8.1-m.main+mve+pacbti -mbranch-protection=pac-ret -mthumb -mfloat-abi=hard
fasynchronous-unwind-tables -g -O0 -S" command line options, the assembly output after this patch
looks like below:

$cat test.c

void fun1(int a);
void fun(int a,...)
{
  fun1(a);
}

int main()
{
  fun (10);
  return 0;
}

$ arm-none-eabi-gcc -march=armv8.1-m.main+mve+pacbti -mbranch-protection=pac-ret -mthumb -mfloat-abi=hard
-fasynchronous-unwind-tables -g -O0 -S test.s

Assembly output:
...
fun:
...
        .pacspval
        pac     ip, lr, sp
        .cfi_register 143, 12
        push    {r3, r7, ip, lr}
        .save {r3, r7, ra_auth_code, lr}
...
        .cfi_offset 143, -24
...
        .cfi_restore 143
...
        aut     ip, lr, sp
        bx      lr
...
main:
...
        .pacspval
        pac     ip, lr, sp
        .cfi_register 143, 12
        push    {r3, r7, ip, lr}
        .save {r3, r7, ra_auth_code, lr}
...
        .cfi_offset 143, -8
...
        .cfi_restore 143
...
        aut     ip, lr, sp
        bx      lr
...

gcc/ChangeLog:

2023-01-11  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

* config/arm/aout.h (ra_auth_code): Add entry in enum.
* config/arm/arm.cc (emit_multi_reg_push): Add RA_AUTH_CODE register
to dwarf frame expression.
(arm_emit_multi_reg_pop): Restore RA_AUTH_CODE register.
(arm_expand_prologue): Update frame related information and reg notes
for pac/pacbit insn.
(arm_regno_class): Check for pac pseudo reigster.
(arm_dbx_register_number): Assign ra_auth_code register number in dwarf.
(arm_init_machine_status): Set pacspval_needed to zero.
(arm_debugger_regno): Check for PAC register.
(arm_unwind_emit_sequence): Print .save directive with ra_auth_code
register.
(arm_unwind_emit_set): Add entry for IP_REGNUM in switch case.
(arm_unwind_emit): Update REG_CFA_REGISTER case._
* config/arm/arm.h (FIRST_PSEUDO_REGISTER): Modify.
(DWARF_PAC_REGNUM): Define.
(IS_PAC_REGNUM): Likewise.
(enum reg_class): Add PAC_REG entry.
(machine_function): Add pacbti_needed state to structure.
* config/arm/arm.md (RA_AUTH_CODE): Define.

gcc/testsuite/ChangeLog:

2023-01-11  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

* g++.target/arm/pac-1.C: New test.
* gcc.target/arm/pac-15.c: Likewise.

21 months agoarm: Add pacbti related multilib support for armv8.1-m.main.
Srinath Parvathaneni [Mon, 23 Jan 2023 11:04:19 +0000 (11:04 +0000)]
arm: Add pacbti related multilib support for armv8.1-m.main.

This patch adds the support for pacbti multlilib linking by making
"-mbranch-protection=none" as default multilib option for arm-none-eabi
target.

Eg 1.

If the passed command line flags are (without mbranch-protection):
a) -march=armv8.1-m.main+mve -mfloat-abi=hard -mfpu=auto

"-mbranch-protection=none" will be used in the multilib matching.

Eg 2.

If the passed command line flags are (with mbranch-protection):
a) -march=armv8.1-m.main+mve+pacbti -mfloat-abi=hard -mfpu=auto  -mbranch-protection=pac-ret

"-mbranch-protection=standard" will be used in the multilib matching.

gcc/ChangeLog:

2023-01-11  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

* config.gcc ($tm_file): Update variable.
* config/arm/arm-mlib.h: Create new header file.
* config/arm/t-rmprofile (MULTI_ARCH_DIRS_RM): Rename mbranch-protection
multilib arch directory.
(MULTILIB_REUSE): Add multilib reuse rules.
(MULTILIB_MATCHES): Add multilib match rules.

gcc/testsuite/ChangeLog:

2023-01-11  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

* gcc.target/arm/multilib.exp (multilib_config "rmprofile"): Update
tests.
* gcc.target/arm/pac-12.c: New test.
* gcc.target/arm/pac-13.c: Likewise.
* gcc.target/arm/pac-14.c: Likewise.

21 months agoarm: Add support for Arm Cortex-M85 CPU.
Srinath Parvathaneni [Mon, 23 Jan 2023 11:00:26 +0000 (11:00 +0000)]
arm: Add support for Arm Cortex-M85 CPU.

This patch adds the -mcpu support for the Arm Cortex-M85 CPU which is
an Armv8.1-M Mainline CPU supporting MVE and PACBTI by default.

-mpcu=cortex-m85 switch by default matches to -march=armv8.1-m.main+pacbti+mve.fp+fp.dp.

Also following options are provided to disable default features.
+nomve.fp (disables MVE Floating point)
+nomve (disables MVE Integer and MVE Floating point)
+nodsp (disables dsp, MVE Integer and MVE Floating point)
+nopacbti (disables pacbti)
+nofp (disables floating point and MVE floating point)

gcc/ChangeLog:

2022-08-12  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

* config/arm/arm-cpus.in (cortex-m85): Define new CPU.
* config/arm/arm-tables.opt: Regenerate.
* config/arm/arm-tune.md: Likewise.
* doc/invoke.texi (Arm Options): Document -mcpu=cortex-m85.
* (-mfix-cmse-cve-2021-35465): Likewise.

gcc/testsuite/ChangeLog:

2022-08-12  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

* gcc.target/arm/multilib.exp: Add tests for cortex-m85.

21 months agotree-optimization/108482 - remove stray .LOOP_DIST_ALIAS calls
Richard Biener [Mon, 23 Jan 2023 09:22:38 +0000 (10:22 +0100)]
tree-optimization/108482 - remove stray .LOOP_DIST_ALIAS calls

The following deals with .LOOP_DIST_ALIAS surviving vectorization
because any of the loops involved were elided between loop distribution
and vectorization.  As opposed to .LOOP_VECTORIZED which exists only
between if-conversion and vectorization with no intermediate passes
this is more difficult to deal with in advance and thus cleaning
up after vectorization looks better.  There's the unconditional
vector lowering pass which looks like a good place for this (for
SIMD uid we have pass_simduid_cleanup).

PR tree-optimization/108482
* tree-vect-generic.cc (expand_vector_operations): Fold remaining
.LOOP_DIST_ALIAS calls.

* gcc.dg/torture/pr108482.c: New testcase.

21 months ago[PATCH 12/15] arm: implement bti injection
Andrea Corallo [Thu, 7 Apr 2022 09:51:56 +0000 (11:51 +0200)]
[PATCH 12/15] arm: implement bti injection

Hi all,

this patch enables Branch Target Identification Armv8.1-M Mechanism
[1].

This is achieved by using the bti pass made common with Aarch64.

The pass iterates through the instructions and adds the necessary BTI
instructions at the beginning of every function and at every landing
pads targeted by indirect jumps.

Best Regards

  Andrea

[1]
<https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension>

gcc/ChangeLog

2022-04-07  Andrea Corallo  <andrea.corallo@arm.com>

* config.gcc (arm*-*-*): Add 'aarch-bti-insert.o' object.
* config/arm/arm-protos.h: Update.
* config/arm/aarch-common-protos.h: Declare
'aarch_bti_arch_check'.
* config/arm/arm.cc (aarch_bti_enabled) Update.
(aarch_bti_j_insn_p, aarch_pac_insn_p, aarch_gen_bti_c)
(aarch_gen_bti_j, aarch_bti_arch_check): New functions.
* config/arm/arm.md (bti_nop): New insn.
* config/arm/t-arm (PASSES_EXTRA): Add 'arm-passes.def'.
(aarch-bti-insert.o): New target.
* config/arm/unspecs.md (VUNSPEC_BTI_NOP): New unspec.
* config/arm/aarch-bti-insert.cc (rest_of_insert_bti): Verify arch
compatibility.
(gate): Make use of 'aarch_bti_arch_check'.
* config/arm/arm-passes.def: New file.
* config/aarch64/aarch64.cc (aarch_bti_arch_check): New function.

gcc/testsuite/ChangeLog

2022-04-07  Andrea Corallo  <andrea.corallo@arm.com>

* gcc.target/arm/bti-1.c: New testcase.
* gcc.target/arm/bti-2.c: Likewise.

21 months ago[PATCH 11/15] aarch64: Make bti pass generic so it can be used by the arm backend
Andrea Corallo [Thu, 7 Apr 2022 09:50:03 +0000 (11:50 +0200)]
[PATCH 11/15] aarch64: Make bti pass generic so it can be used by the arm backend

Hi all,

this patch splits and restructures the aarch64 bti pass code in order
to have it usable by the arm backend as well.  These changes have no
functional impact.

Best Regards

  Andrea

gcc/Changelog

* config.gcc (aarch64*-*-*): Rename 'aarch64-bti-insert.o' into
'aarch-bti-insert.o'.
* config/aarch64/aarch64-protos.h: Remove 'aarch64_bti_enabled'
proto.
* config/aarch64/aarch64.cc (aarch_bti_enabled): Rename.
(aarch_bti_j_insn_p, aarch_pac_insn_p): New functions.
(aarch64_output_mi_thunk)
(aarch64_print_patchable_function_entry)
(aarch64_file_end_indicate_exec_stack): Update renamed function
calls to renamed functions.
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Likewise.
* config/aarch64/t-aarch64 (aarch-bti-insert.o): Update
target.
* config/aarch64/aarch64-bti-insert.cc: Delete.
* config/arm/aarch-bti-insert.cc: New file including and
generalizing code from aarch64-bti-insert.cc.
* config/arm/aarch-common-protos.h: Update.

21 months ago[PATCH 10/15] arm: Implement cortex-M return signing address codegen
Andrea Corallo [Thu, 20 Jan 2022 14:36:23 +0000 (15:36 +0100)]
[PATCH 10/15] arm: Implement cortex-M return signing address codegen

Hi all,

this patch enables address return signature and verification based on
Armv8.1-M Pointer Authentication [1].

To sign the return address, we use the PAC R12, LR, SP instruction
upon function entry.  This is signing LR using SP and storing the
result in R12.  R12 will be pushed into the stack.

During function epilogue R12 will be popped and AUT R12, LR, SP will
be used to verify that the content of LR is still valid before return.

Here an example of PAC instrumented function prologue and epilogue:

void foo (void);

int main()
{
  foo ();
  return 0;
}

Compiled with '-march=armv8.1-m.main -mbranch-protection=pac-ret
-mthumb' translates into:

main:
pac ip, lr, sp
push {r3, r7, ip, lr}
add r7, sp, #0
bl foo
movs r3, #0
mov r0, r3
pop {r3, r7, ip, lr}
aut ip, lr, sp
bx lr

The patch also takes care of generating a PACBTI instruction in place
of the sequence BTI+PAC when Branch Target Identification is enabled
contextually.

Ex. the previous example compiled with '-march=armv8.1-m.main
-mbranch-protection=pac-ret+bti -mthumb' translates into:

main:
pacbti ip, lr, sp
push {r3, r7, ip, lr}
add r7, sp, #0
bl foo
movs r3, #0
mov r0, r3
pop {r3, r7, ip, lr}
aut ip, lr, sp
bx lr

As part of previous upstream suggestions a test for varargs has been
added and '-mtpcs-frame' is deemed being incompatible with this return
signing address feature being introduced.

[1] <https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension>

gcc/
* config/arm/arm.h (arm_arch8m_main): Declare it.
* config/arm/arm-protos.h (arm_current_function_pac_enabled_p):
Declare it.
* config/arm/arm.cc (arm_arch8m_main): Define it.
(arm_option_reconfigure_globals): Set arm_arch8m_main.
(arm_compute_frame_layout, arm_expand_prologue)
(thumb2_expand_return, arm_expand_epilogue)
(arm_conditional_register_usage): Update for pac codegen.
(arm_current_function_pac_enabled_p): New function.
(aarch_bti_enabled) New function.
(use_return_insn): Return zero when pac is enabled.
* config/arm/arm.md (pac_ip_lr_sp, pacbti_ip_lr_sp, aut_ip_lr_sp):
Add new patterns.
* config/arm/unspecs.md (UNSPEC_PAC_NOP)
(VUNSPEC_PACBTI_NOP, VUNSPEC_AUT_NOP): Add unspecs.

gcc/testsuite/

* gcc.target/arm/pac.h : New file.
* gcc.target/arm/pac-1.c : New test case.
* gcc.target/arm/pac-2.c : Likewise.
* gcc.target/arm/pac-3.c : Likewise.
* gcc.target/arm/pac-4.c : Likewise.
* gcc.target/arm/pac-5.c : Likewise.
* gcc.target/arm/pac-6.c : Likewise.
* gcc.target/arm/pac-7.c : Likewise.
* gcc.target/arm/pac-8.c : Likewise.
* gcc.target/arm/pac-9.c : Likewise.
* gcc.target/arm/pac-10.c : Likewise.
* gcc.target/arm/pac-11.c : Likewise.

21 months ago[PATCH 8/15] arm: Introduce multilibs for PACBTI target feature
Andrea Corallo [Mon, 6 Dec 2021 10:42:59 +0000 (11:42 +0100)]
[PATCH 8/15] arm: Introduce multilibs for PACBTI target feature

This patch add the following new multilibs.

thumb/v8.1-m.main+pacbti/mbranch-protection/nofp
thumb/v8.1-m.main+pacbti+dp/mbranch-protection/soft
thumb/v8.1-m.main+pacbti+dp/mbranch-protection/hard
thumb/v8.1-m.main+pacbti+fp/mbranch-protection/soft
thumb/v8.1-m.main+pacbti+fp/mbranch-protection/hard
thumb/v8.1-m.main+pacbti+mve/mbranch-protection/hard

Triggering the following compiler flags:

-mthumb -march=armv8.1-m.main+pacbti -mbranch-protection=standard -mfloat-abi=soft
-mthumb -march=armv8.1-m.main+pacbti+fp -mbranch-protection=standard -mfloat-abi=softfp
-mthumb -march=armv8.1-m.main+pacbti+fp -mbranch-protection=standard -mfloat-abi=hard
-mthumb -march=armv8.1-m.main+pacbti+fp.dp -mbranch-protection=standard -mfloat-abi=softfp
-mthumb -march=armv8.1-m.main+pacbti+fp.dp -mbranch-protection=standard -mfloat-abi=hard
-mthumb -march=armv8.1-m.main+pacbti+mve -mbranch-protection=standard -mfloat-abi=hard

gcc/

* config/arm/t-rmprofile: Add multilib rules for march +pacbti and
mbranch-protection.

gcc/testsuite/

* gcc.target/arm/multilib.exp: Add pacbti related entries.

21 months ago[PATCH 7/15] arm: Emit build attributes for PACBTI target feature
Andrea Corallo [Mon, 6 Dec 2021 10:42:24 +0000 (11:42 +0100)]
[PATCH 7/15] arm: Emit build attributes for PACBTI target feature

This patch emits assembler directives for PACBTI build attributes as
defined by the
ABI.

<https://github.com/ARM-software/abi-aa/releases/download/2021Q1/addenda32.pdf>

gcc/ChangeLog:

* config/arm/arm.cc (arm_file_start): Emit EABI attributes for
Tag_PAC_extension, Tag_BTI_extension, TAG_BTI_use, TAG_PACRET_use.

gcc/testsuite/ChangeLog:

* gcc.target/arm/acle/pacbti-m-predef-1.c: New test.
* gcc.target/arm/acle/pacbti-m-predef-3.c: Likewise.
* gcc.target/arm/acle/pacbti-m-predef-6.c: Likewise.
* gcc.target/arm/acle/pacbti-m-predef-7.c: Likewise.

Co-Authored-By: Tejas Belagod <tbelagod@arm.com>
21 months ago[PATCH 6/15] arm: Add pointer authentication for stack-unwinding runtime
Andrea Corallo [Mon, 6 Dec 2021 10:42:11 +0000 (11:42 +0100)]
[PATCH 6/15] arm: Add pointer authentication for stack-unwinding runtime

This patch adds authentication for when the stack is unwound when an
exception is taken.  All the changes here are done to the runtime code
in libgcc's unwinder code for Arm target. All the changes are guarded
under defined (__ARM_FEATURE_PAC_DEFAULT) and activated only if the
+pacbti feature is switched on for the architecture. This means that
switching on the target feature via -march or -mcpu is sufficient and
-mbranch-protection need not be enabled. This ensures that the
unwinder is authenticated only if the PACBTI instructions are
available in the non-NOP space as it uses AUTG.  Just generating
PAC/AUT instructions using -mbranch-protection will not enable
authentication on the unwinder.

Pre-approved with the requested changes here
<https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586555.html>.

gcc/ChangeLog:

* ginclude/unwind-arm-common.h (_Unwind_VRS_RegClass): Introduce
new pseudo register class _UVRSC_PAC.

libgcc/ChangeLog:
* config/arm/pr-support.c (__gnu_unwind_execute): Decode
exception opcode (0xb4) for saving RA_AUTH_CODE and authenticate
with AUTG if found.
* config/arm/unwind-arm.c (struct pseudo_regs): New.
(phase1_vrs): Introduce new field to store pseudo-reg state.
(phase2_vrs): Likewise.
(_Unwind_VRS_Get): Load pseudo register state from virtual reg set.
(_Unwind_VRS_Set): Store pseudo register state to virtual reg set.
(_Unwind_VRS_Pop): Load pseudo register value from stack into VRS.

Co-Authored-By: Tejas Belagod <tbelagod@arm.com>
Co-Authored-By: Srinath Parvathaneni <srinath.parvathaneni@arm.com>
21 months ago[PATCH 5/15] arm: Implement target feature macros for PACBTI
Andrea Corallo [Mon, 6 Dec 2021 10:39:59 +0000 (11:39 +0100)]
[PATCH 5/15] arm: Implement target feature macros for PACBTI

This patch implements target feature macros when PACBTI is enabled
through the -march option or -mbranch-protection.  The target feature
macros __ARM_FEATURE_PAC_DEFAULT and __ARM_FEATURE_BTI_DEFAULT are
specified in ARM ACLE
<https://developer.arm.com/documentation/101028/0012/5--Feature-test-macros?lang=en>
__ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI are specified in the
pull-request <https://github.com/ARM-software/acle/pull/55>.

Approved here
<https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586334.html>.

gcc/

* config/arm/arm-c.cc (arm_cpu_builtins): Define
__ARM_FEATURE_BTI_DEFAULT, __ARM_FEATURE_PAC_DEFAULT,
__ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI.

gcc/testsuite/

* lib/target-supports.exp
(check_effective_target_mbranch_protection_ok): New function.
* gcc.target/arm/acle/pacbti-m-predef-2.c: New test.
* gcc.target/arm/acle/pacbti-m-predef-4.c: Likewise.
* gcc.target/arm/acle/pacbti-m-predef-5.c: Likewise.
* gcc.target/arm/acle/pacbti-m-predef-8.c: Likewise.
* gcc.target/arm/acle/pacbti-m-predef-9.c: Likewise.
* gcc.target/arm/acle/pacbti-m-predef-10.c: Likewise.
* gcc.target/arm/acle/pacbti-m-predef-11.c: Likewise.
* gcc.target/arm/acle/pacbti-m-predef-12.c: Likewise.

Co-Authored-By: Tejas Belagod <tbelagod@arm.com>
21 months ago[PATCH 4/15] arm: Add testsuite library support for PACBTI target
Andrea Corallo [Mon, 6 Dec 2021 10:39:35 +0000 (11:39 +0100)]
[PATCH 4/15] arm: Add testsuite library support for PACBTI target

Add targeting-checking entities for PACBTI in testsuite
framework.

Pre-approved with the requested changes here
<https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586331.html>.

gcc/testsuite/ChangeLog

* lib/target-supports.exp:
(check_effective_target_arm_pacbti_hw): New.

gcc/ChangeLog:
* doc/sourcebuild.texi: Document arm_pacbti_hw.

Co-Authored-By: Tejas Belagod <tbelagod@arm.com>
21 months ago[PATCH 3/15] arm: Add option -mbranch-protection
Andrea Corallo [Mon, 6 Dec 2021 10:39:03 +0000 (11:39 +0100)]
[PATCH 3/15] arm: Add option -mbranch-protection

Add -mbranch-protection option.  This option enables the
code-generation of pointer signing and authentication instructions in
function prologues and epilogues.

gcc/ChangeLog:

* config/arm/arm.cc (arm_configure_build_target): Parse and validate
-mbranch-protection option and initialize appropriate data structures.
* config/arm/arm.opt (-mbranch-protection): New option.
* doc/invoke.texi (Arm Options): Document it.

Co-Authored-By: Tejas Belagod <tbelagod@arm.com>
Co-Authored-By: Richard Earnshaw <Richard.Earnshaw@arm.com>
21 months ago[PATCH 2/15] arm: Add Armv8.1-M Mainline target feature +pacbti
Andrea Corallo [Mon, 6 Dec 2021 10:38:32 +0000 (11:38 +0100)]
[PATCH 2/15] arm: Add Armv8.1-M Mainline target feature +pacbti

This patch adds the -march feature +pacbti to Armv8.1-M Mainline.
This feature enables pointer signing and authentication instructions
on M-class architectures.

Pre-approved here
<https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586144.html>.

gcc/Changelog:

* config/arm/arm.h (TARGET_HAVE_PACBTI): New macro.
* config/arm/arm-cpus.in (pacbti): New feature.
* doc/invoke.texi (Arm Options): Document it.

Co-Authored-By: Tejas Belagod <tbelagod@arm.com>
21 months ago[PATCH 1/15] arm: Make mbranch-protection opts parsing common to AArch32/64
Andrea Corallo [Mon, 6 Dec 2021 10:34:35 +0000 (11:34 +0100)]
[PATCH 1/15] arm: Make mbranch-protection opts parsing common to AArch32/64

Hi all,

This change refactors all the mbranch-protection option parsing code and
types to make it common to both AArch32 and AArch64 backends.

This change also pulls in some supporting types from AArch64 to make
it common (aarch_parse_opt_result).

The significant changes in this patch are the movement of all branch
protection parsing routines from aarch64.c to aarch-common.c and
supporting data types and static data structures.

This patch also pre-declares variables and types required in the
aarch32 back-end for moved variables for function sign scope and key
to prepare for the impending series of patches that support parsing
the feature mbranch-protection in the aarch32 back-end.

gcc/ChangeLog:

* common/config/aarch64/aarch64-common.cc: Include aarch-common.h.
(all_architectures): Fix comment.
(aarch64_parse_extension): Rename return type, enum value names.
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Rename
factored out aarch_ra_sign_scope and aarch_ra_sign_key variables.
Also rename corresponding enum values.
* config/aarch64/aarch64-opts.h (aarch64_function_type): Factor
out aarch64_function_type and move it to common code as
aarch_function_type in aarch-common.h.
* config/aarch64/aarch64-protos.h: Include common types header,
move out types aarch64_parse_opt_result and aarch64_key_type to
aarch-common.h
* config/aarch64/aarch64.cc: Move mbranch-protection parsing types
and functions out into aarch-common.h and aarch-common.cc.  Fix up
all the name changes resulting from the move.
* config/aarch64/aarch64.md: Fix up aarch64_ra_sign_key type name change
and enum value.
* config/aarch64/aarch64.opt: Include aarch-common.h to import
type move.  Fix up name changes from factoring out common code and
data.
* config/arm/aarch-common-protos.h: Export factored out routines to both
backends.
* config/arm/aarch-common.cc: Include newly factored out types.
Move all mbranch-protection code and data structures from
aarch64.cc.
* config/arm/aarch-common.h: New header that declares types shared
between aarch32 and aarch64 backends.
* config/arm/arm-protos.h: Declare types and variables that are
made common to aarch64 and aarch32 backends - aarch_ra_sign_key,
aarch_ra_sign_scope and aarch_enable_bti.
* config/arm/arm.opt (config/arm/aarch-common.h): Include header.
(aarch_ra_sign_scope, aarch_enable_bti): Declare variable.
* config/arm/arm.cc: Add missing includes.

Co-Authored-By: Tejas Belagod <tbelagod@arm.com>
21 months agomodula2/108144 - fix mistake in previous change
Richard Biener [Mon, 23 Jan 2023 10:14:05 +0000 (11:14 +0100)]
modula2/108144 - fix mistake in previous change

The previous change to avoid a duplicate multi directory
caused the m2/m2{cor,iso,log,min,pim} installs to happen
relative to the main library directory when not using
--enable-version-specific-runtime-libs which doesn't match
the drivers expectation where to find them.  The following
fixes the original issue by simply dropping the duplicate
multi directory since the one in the $(inst_libdir) variable
now works.

Tested by building and installing with and without
--enable-version-specific-runtime-libs and compiling and
linking a modula-2 testcase successfully with the installed
compilers.

PR modula2/108144
libgm2/
* libm2cor/Makefile.am: Revert previous change, instead
drop the redundant $(MULTIDIR).
* libm2iso/Makefile.am: Likewise.
* libm2log/Makefile.am: Likewise.
* libm2min/Makefile.am: Likewise.
* libm2pim/Makefile.am: Likewise.
* libm2cor/Makefile.in: Regenerate.
* libm2iso/Makefile.in: Likewise.
* libm2log/Makefile.in: Likewise.
* libm2min/Makefile.in: Likewise.
* libm2pim/Makefile.in: Likewise.

21 months agolibgomp.texi: Impl. status - non-rect loop nest only partial
Tobias Burnus [Mon, 23 Jan 2023 08:40:41 +0000 (09:40 +0100)]
libgomp.texi: Impl. status - non-rect loop nest only partial

libgomp/
* libgomp.texi (OpenMP 5.0): Set non-rectangular
loop nest back to 'P' as Fortran support is incomplete.

21 months agoinstall.texi: Bump newlib version for nvptx + gcn
Tobias Burnus [Mon, 23 Jan 2023 08:31:11 +0000 (09:31 +0100)]
install.texi: Bump newlib version for nvptx + gcn

Before, newlib 3.2 was required for amdgcn and 3.1 for nvptx.
Now recommended is 4.3.0 which was just released on 2023-01-20.

While currently the old versions would work fine, upcoming GCC
changes depend on a newer newlib. Thus, the minimal version is
bumped instead of just recommending the new version.

For GCN, the bump is in preparation for permitting non-threadlocal
stack variables and vectorized math functions - both scheduled for
GCC 13 and added to newlib in 4.3.0.

For nvptx, this includes an emulated clock (commit 6bb96d13a),
a calloc fix (5fca4e0f1) and changes to permit libgfortran to be
compiled with I/O support instead of only in minimal mode.
(Patch approved for GCC 13 but pending on a nvtpx patch,
which for which review is pending.)

gcc/ChangeLog:

* doc/install.texi (amdgcn, nvptx): Require newlib 4.3.0.

21 months agotree-optimization/108449 - keep maybe_special_function_p behavior
Richard Biener [Thu, 19 Jan 2023 07:44:25 +0000 (08:44 +0100)]
tree-optimization/108449 - keep maybe_special_function_p behavior

When we have a static declaration without definition we diagnose
that and turn it into an extern declaration.  That can alter
the outcome of maybe_special_function_p here and there's really
no point in doing that, so don't.

PR tree-optimization/108449
* cgraphunit.cc (check_global_declaration): Do not turn
undefined statics into externs.

* gcc.dg/pr108449.c: New testcase.

21 months agomodula2/108144 - Fix multilib install of libgm2
Richard Biener [Fri, 20 Jan 2023 11:27:50 +0000 (12:27 +0100)]
modula2/108144 - Fix multilib install of libgm2

The following adjusts libgm2 to properly use the multilib build
infrastructure, thereby fixing the install with
--enable-version-specific-runtime-libs

In particular config-ml.pl needs to be applied to generated Makefiles
as documented in the manual and we have to avoid clobbering the
variables via make arguments.  The explicit install rules used different
ways to construct the multilib dir which isn't necessary and breaks
when MUTLIDIR is now finally set correctly.  Instead use
$(toolexeclibdir).

This results in some dead variables in the Makefile.am (and there were
some before), I refrained from doing even more changes here.

Verified with an install with and without --enable-version-specific-runtime-libs
and checking the result.

PR modula2/108144
libgm2/
* configure.ac: Apply config-ml.pl to the generated Makefiles.
Set multilib_arg, use AM_PROG_LIBTOOL.
* configure: Regenerate.
* Makefile.am (AM_MAKEFLAGS): Do not override MULTI* flags.
* Makefile.in: Regenerate.
* libm2cor/Makefile.am: Install to $(toolexeclibdir)$(M2LIBDIR)
rather than $(inst_libdir)/$(MULTIDIR)$(M2LIBDIR).
* libm2iso/Makefile.am: Likewise.
* libm2log/Makefile.am: Likewise.
* libm2min/Makefile.am: Likewise.
* libm2pim/Makefile.am: Likewise.
* libm2cor/Makefile.in: Regenerate.
* libm2iso/Makefile.in: Likewise.
* libm2log/Makefile.in: Likewise.
* libm2min/Makefile.in: Likewise.
* libm2pim/Makefile.in: Likewise.

21 months agoc++: lifetime extension with .* expression [PR53288]
Jason Merrill [Tue, 20 Dec 2022 21:27:43 +0000 (16:27 -0500)]
c++: lifetime extension with .* expression [PR53288]

This PR points out a case where we are not extending the lifetime of a
temporary when the subobject is denoted by a pointer-to-member operation.
These rules were clarified in C++20 by CWG1299.

There are other cases that also need to be handled under CWG1299, but are
not fixed by this patch.

PR c++/53288
DR 1299

gcc/cp/ChangeLog:

* call.cc (extend_ref_init_temps_1): Handle ptrmem expression.

gcc/testsuite/ChangeLog:

* g++.dg/init/lifetime4.C: New test.

21 months agoDaily bump.
GCC Administrator [Mon, 23 Jan 2023 00:16:34 +0000 (00:16 +0000)]
Daily bump.

21 months agoModula-2, testsuite: Remove use of concatenated paths.
Iain Sandoe [Sun, 22 Jan 2023 15:17:13 +0000 (15:17 +0000)]
Modula-2, testsuite: Remove use of concatenated paths.

The original implementation for Modula-2 search paths allows things like
'-I/path/a:/path/b'.  Such paths are not compatible with the rest of the
compiler (in particular, the preprocessor, which Modula-2 uses).  In
preparation for removing that idiom, this patch rewrites the cases in the
testsuite and removes string processing where possible from lists of paths.

TODO: There are some apparent discrepancies and/or extraneous insertions
of partial include paths (especially in gm2_init_log, gm2_init_iso and
gm2_init_pim) - to be handled in some future patch.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/ChangeLog:

* gm2/case/pass/case-pass.exp: Update for removal of concatenated
paths.
* gm2/complex/pass/complex-pass.exp: Likewise.
* gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp: Likewise.
* gm2/iso/analysis/fail/iso-analysis-fail.exp: Likewise.
* gm2/iso/check/fail/iso-check-fail.exp: Likewise.
* gm2/iso/fail/iso-fail.exp: Likewise.
* gm2/iso/pass/iso-pass.exp: Likewise.
* gm2/isolib/run/pass/isolib-run-pass.exp: Likewise.
* gm2/pim/fail/pim-fail.exp: Likewise.
* gm2/pim/pass/pim-pass.exp: Likewise.
* gm2/pimlib/logitech/run/pass/pimlib-logitech-run-pass.exp: Likewise.
* gm2/pimlib/pass/pimlib-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/log/run/pass/hello/projects-log-run-pass-hello.exp: Likewise.
* gm2/projects/pim/run/pass/hello/projects-pim-run-pass-hello.exp: Likewise.
* gm2/recover/pass/recover-pass.exp: Likewise.
* gm2/switches/makeall/fail/switches-makeall-fail.exp: Likewise.
* gm2/switches/makeall/pass/switches-makeall-pass.exp: Likewise.
* gm2/switches/none/run/pass/gm2-none.exp: Likewise.
* gm2/switches/pim2/run/pass/switches-pim2-run-pass.exp: Likewise.
* gm2/ulmlib/pass/ulmlib-pass.exp: Likewise.
* gm2/ulmlib/std/pass/ulmlib-std-pass.exp: Likewise.
* gm2/ulmlib/sys/pass/ulmlib-sys-pass.exp: Likewise.
* lib/gm2.exp: Make the paths list a mandatory entry for each gm2_init_xxx
function. Remove the use of concatenated include and library paths.
Remove string processing where possible.

21 months agopru: Fix CLZ expansion for QI and HI modes
Dimitar Dimitrov [Sat, 21 Jan 2023 16:10:59 +0000 (18:10 +0200)]
pru: Fix CLZ expansion for QI and HI modes

The recent gcc.dg/tree-ssa/clz-char.c test case failed for PRU target,
exposing a wrong code generation bug in the PRU backend.  The "clz"
pattern did not produce correct output for QI and HI input operand
modes.  SI mode is ok.

The "clz" pattern is expanded to an LMBD instruction to get the
left-most bit position having value "1".  In turn, to get the correct
"clz" value, that bit position must be subtracted from the MSB bit
position of the input operand.  The old behaviour of hard-coding 31
for MSB bit position is wrong.

The LMBD instruction returns 32 if input operand is zero, irrespective
of its register mode.  This maps nicely for SI mode, where the "clz"
pattern outputs -1.  It also leads to peculiar (but valid!) output
values from the "clz" pattern for QI and HI zero-valued inputs.

gcc/ChangeLog:

* config/pru/pru.h (CLZ_DEFINED_VALUE_AT_ZERO): Fix value for QI
and HI input modes.
* config/pru/pru.md (clz): Fix generated code for QI and HI
input modes.

gcc/testsuite/ChangeLog:

* gcc.target/pru/clz-hi-2.c: New test.
* gcc.target/pru/clz-hi.c: New test.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
21 months ago[PATCH 1/2] select .rodata for const volatile variables.
Cupertino Miranda [Sun, 22 Jan 2023 18:51:20 +0000 (11:51 -0700)]
[PATCH 1/2] select .rodata for const volatile variables.

gcc/
* config/v850/v850.cc (v850_select_section): Put const volatile
objects into read-only sections.

21 months agoDarwin, libffi, testsuite: Ensure we pick up the convenience lib.
Iain Sandoe [Sat, 21 Jan 2023 19:52:58 +0000 (19:52 +0000)]
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.

21 months agoDaily bump.
GCC Administrator [Sun, 22 Jan 2023 00:17:27 +0000 (00:17 +0000)]
Daily bump.

21 months agofortran: [PR102595]
Jerry DeLisle [Sat, 21 Jan 2023 23:19:57 +0000 (15:19 -0800)]
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.

21 months agoDarwin, fixincludes: Handle Apple Blocks in objc/runtime.h.
Iain Sandoe [Wed, 18 Jan 2023 23:25:36 +0000 (23:25 +0000)]
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.

21 months agoDarwin, fixincludes: Handle MacOS13 SDK Apple-specific deprecations [PR107568].
Iain Sandoe [Wed, 18 Jan 2023 19:58:33 +0000 (19:58 +0000)]
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.

21 months agoDaily bump.
GCC Administrator [Sat, 21 Jan 2023 00:16:20 +0000 (00:16 +0000)]
Daily bump.

21 months agoPR-108136 modula-2 meets cppcheck part 2
Gaius Mulley [Fri, 20 Jan 2023 23:39:35 +0000 (23:39 +0000)]
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>
21 months agolibbacktrace: change PC variables from uint64_t to uintptr_t
Ian Lance Taylor [Fri, 20 Jan 2023 22:24:00 +0000 (14:24 -0800)]
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.

21 months agoPR-108135 Modula2 meets clang (remove dead code and bugfix m2.flex)
Gaius Mulley [Fri, 20 Jan 2023 17:51:52 +0000 (17:51 +0000)]
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>
21 months agoAArch64: Gate various crypto intrinsics availability based on features
Tejas Belagod [Thu, 15 Dec 2022 07:57:50 +0000 (07:57 +0000)]
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.

21 months agoniter: Fix up unused var warning [PR108457]
Jakub Jelinek [Fri, 20 Jan 2023 09:23:49 +0000 (10:23 +0100)]
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.

21 months agoDaily bump.
GCC Administrator [Fri, 20 Jan 2023 00:17:40 +0000 (00:17 +0000)]
Daily bump.

21 months agoc++: Fix up handling of non-dependent subscript with static operator[] [PR108437]
Jakub Jelinek [Thu, 19 Jan 2023 22:31:15 +0000 (23:31 +0100)]
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.

21 months agoc++: Fix up handling of references to anon union members in initializers [PR53932]
Jakub Jelinek [Thu, 19 Jan 2023 22:27:34 +0000 (23:27 +0100)]
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.

21 months agovalue-relation: Fix up relation_union [PR108447]
Jakub Jelinek [Thu, 19 Jan 2023 22:26:35 +0000 (23:26 +0100)]
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.

21 months agox86: Check invalid third argument to __builtin_ia32_prefetch
H.J. Lu [Wed, 18 Jan 2023 19:08:14 +0000 (11:08 -0800)]
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.

21 months agoopenmp: Fix up OpenMP expansion of non-rectangular loops [PR108459]
Jakub Jelinek [Thu, 19 Jan 2023 20:00:08 +0000 (21:00 +0100)]
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.

21 months agoanalyzer: use dominator info in -Wanalyzer-deref-before-check [PR108455]
David Malcolm [Thu, 19 Jan 2023 18:51:16 +0000 (13:51 -0500)]
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>
21 months agoFortran: error recovery for invalid CLASS component [PR108434]
Harald Anlauf [Wed, 18 Jan 2023 21:13:29 +0000 (22:13 +0100)]
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.

21 months agomodula-2, testsuite: Make libs and interfaces consistent.
Iain Sandoe [Sat, 14 Jan 2023 19:33:52 +0000 (19:33 +0000)]
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.

21 months agoPR-108373 Update contrib/gcc_update:files_and_dependencies for Modula-2
Gaius Mulley [Thu, 19 Jan 2023 15:00:19 +0000 (15:00 +0000)]
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>
21 months agoaarch64: add -fno-stack-protector to some tests [PR108411]
Christophe Lyon [Tue, 17 Jan 2023 13:10:10 +0000 (13:10 +0000)]
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.

21 months agoaarch64: fix ICE in aarch64_layout_arg [PR108411]
Christophe Lyon [Mon, 16 Jan 2023 17:48:25 +0000 (17:48 +0000)]
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.

21 months agomodula2/108144 - fix --enable-version-specific-runtime-libs
Richard Biener [Thu, 19 Jan 2023 11:15:14 +0000 (12:15 +0100)]
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.

21 months agoforwprop: Further fixes for simplify_rotate [PR108440]
Jakub Jelinek [Thu, 19 Jan 2023 09:00:51 +0000 (10:00 +0100)]
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.

21 months ago[aarch64] Use exact_log2 (INTVAL (operands[2])) >= 0 to gate for vec_merge patterns.
Prathamesh Kulkarni [Thu, 19 Jan 2023 07:13:55 +0000 (12:43 +0530)]
[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.

21 months ago[PR106746] drop cselib addr lookup in debug insn mem
Alexandre Oliva [Thu, 19 Jan 2023 04:09:15 +0000 (01:09 -0300)]
[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.

21 months agoDaily bump.
GCC Administrator [Thu, 19 Jan 2023 00:17:35 +0000 (00:17 +0000)]
Daily bump.

21 months agolibfortran: Fix execute_command_line for Windows
Tobias Burnus [Wed, 18 Jan 2023 22:31:41 +0000 (23:31 +0100)]
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.

21 months agoc: ICE with nullptr as case expression [PR108424]
Marek Polacek [Wed, 18 Jan 2023 19:51:59 +0000 (14:51 -0500)]
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.

21 months agolibstdc++: Deprecate std::filesystem::u8path for C++20
Jonathan Wakely [Wed, 18 Jan 2023 14:27:55 +0000 (14:27 +0000)]
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.

21 months agolibstdc++: Fix std::random_device::entropy() for non-posix targets
Jonathan Wakely [Wed, 18 Jan 2023 13:09:10 +0000 (13:09 +0000)]
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.

21 months agolibstdc++: Minor updates to Policy Based Data Structures: Biblio
Gerald Pfeifer [Wed, 18 Jan 2023 18:59:26 +0000 (19:59 +0100)]
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.

21 months agolibstdc++: testsuite: Simplify codecvt_unicode
Dimitrij Mijoski [Tue, 17 Jan 2023 21:12:12 +0000 (22:12 +0100)]
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.

21 months agoanalyzer: add SARD testsuite 81
David Malcolm [Wed, 18 Jan 2023 16:41:47 +0000 (11:41 -0500)]
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>
21 months agoipa: Release body more carefully when removing nodes (PR 107944)
Martin Jambor [Wed, 18 Jan 2023 14:29:54 +0000 (15:29 +0100)]
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.

21 months agolto/108445 - avoid LTO decl wrapping being confused by tree sharing
Richard Biener [Wed, 18 Jan 2023 13:54:33 +0000 (14:54 +0100)]
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.

21 months agoRevert "middle-end/108086 - avoid unshare_expr when remapping SSA names"
Richard Biener [Wed, 18 Jan 2023 13:54:06 +0000 (14:54 +0100)]
Revert "middle-end/108086 - avoid unshare_expr when remapping SSA names"

This reverts commit da85bfc75024a92b97e60e4436863dd5789786ec.

21 months agolibgcc: Fix uninitialized RA signing on AArch64 [PR107678]
Wilco Dijkstra [Tue, 3 Jan 2023 15:57:46 +0000 (15:57 +0000)]
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.

21 months agoarm: fix __arm_vld1q_z* and __arm_vst1q_p* intrinsics [PR108442]
Murray Steele [Wed, 22 Dec 2021 15:55:58 +0000 (15:55 +0000)]
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.

21 months agoxtensa: Optimize inversion of the MSB
Takayuki 'January June' Suwa [Wed, 18 Jan 2023 05:43:13 +0000 (14:43 +0900)]
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.

21 months agors6000: Fix typo on vec_vsubcuq in rs6000-overload.def [PR108396]
Kewen Lin [Wed, 18 Jan 2023 08:34:25 +0000 (02:34 -0600)]
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.

21 months agors6000: Teach rs6000_opaque_type_invalid_use_p about gcall [PR108348]
Kewen Lin [Wed, 18 Jan 2023 08:34:19 +0000 (02:34 -0600)]
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.

21 months agoDon't add crtfastmath.o for -shared.
liuhongt [Fri, 13 Jan 2023 08:19:47 +0000 (16:19 +0800)]
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.

21 months agoFix bug number reference in Changelogs
Jerry DeLisle [Wed, 18 Jan 2023 01:30:49 +0000 (17:30 -0800)]
Fix bug number reference in Changelogs

21 months agoDaily bump.
GCC Administrator [Wed, 18 Jan 2023 00:17:21 +0000 (00:17 +0000)]
Daily bump.

21 months agoFortran: fix ICE in get_expr_storage_size [PR108421]
Harald Anlauf [Mon, 16 Jan 2023 20:30:56 +0000 (21:30 +0100)]
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.

21 months agogo: define two builtin functions used by middle-end
Ian Lance Taylor [Tue, 17 Jan 2023 17:02:49 +0000 (09:02 -0800)]
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.