]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 years agopreprocessor: C++ module-directives
Nathan Sidwell [Wed, 18 Nov 2020 18:24:12 +0000 (10:24 -0800)] 
preprocessor: C++ module-directives

C++20 modules introduces a new kind of preprocessor directive -- a
module directive.  These are directives but without the leading '#'.
We have to detect them by sniffing the start of a logical line.  When
detected we replace the initial identifiers with unspellable tokens
and pass them through to the language parser the same way deferred
pragmas are.  There's a PRAGMA_EOL at the logical end of line too.

One additional complication is that we have to do header-name lexing
after the initial tokens, and that requires changes in the macro-aware
piece of the preprocessor.  The above sniffer sets a counter in the
lexer state, and that triggers at the appropriate point.  We then do
the same header-name lexing that occurs on a #include directive or
has_include pseudo-macro.  Except that the header name ends up in the
token stream.

A couple of token emitters need to deal with the new token possibility.

gcc/c-family/
* c-lex.c (c_lex_with_flags): CPP_HEADER_NAMEs can now be seen.
libcpp/
* include/cpplib.h (struct cpp_options): Add module_directives
option.
(NODE_MODULE): New node flag.
(struct cpp_hashnode): Make rid-code a bitfield, increase bits in
flags and swap with type field.
* init.c (post_options): Create module-directive identifier nodes.
* internal.h (struct lexer_state): Add directive_file_token &
n_modules fields.  Add module node enumerator.
* lex.c (cpp_maybe_module_directive): New.
(_cpp_lex_token): Call it.
(cpp_output_token): Add '"' around CPP_HEADER_NAME token.
(do_peek_ident, do_peek_module): New.
(cpp_directives_only): Detect module-directive lines.
* macro.c (cpp_get_token_1): Deal with directive_file_token
triggering.

3 years agopreprocessor: Add support for header unit translation
Nathan Sidwell [Wed, 18 Nov 2020 16:27:16 +0000 (08:27 -0800)] 
preprocessor: Add support for header unit translation

libcpp/
* files.c (struct _cpp_file): Add header_unit field.
(_cpp_stack_file): Add header unit support.
(cpp_find_header_unit): New.
* include/cpplib.h (cpp_find_header_unit): Declare.

3 years agopreprocessor: Update mkdeps for modules
Nathan Sidwell [Wed, 18 Nov 2020 14:44:38 +0000 (06:44 -0800)] 
preprocessor: Update mkdeps for modules

This is slightly different to the original patch I posted.  This adds
separate module target and dependency functions (rather than a single
bi-modal function).

libcpp/
* include/cpplib.h (struct cpp_options): Add modules to
dep-options.
* include/mkdeps.h (deps_add_module_target): Declare.
(deps_add_module_dep): Declare.
* mkdeps.c (class mkdeps): Add modules, module_name, cmi_name,
is_header_unit fields.  Adjust cdtors.
(deps_add_module_target, deps_add_module_dep): New.
(make_write): Write module dependencies, if enabled.

3 years agolibstdc++: Fix ranges::join_view::_Iterator::operator-> [LWG 3500]
Patrick Palka [Wed, 18 Nov 2020 15:23:57 +0000 (10:23 -0500)] 
libstdc++: Fix ranges::join_view::_Iterator::operator-> [LWG 3500]

This applies the proposed resolution of LWG 3500, which corrects the
return type and constraints of this member function to use the right
iterator type.  Additionally, a nearby local variable is uglified.

libstdc++-v3/ChangeLog:

* include/std/ranges (join_view::_Iterator::_M_satisfy): Uglify
local variable inner.
(join_view::_Iterator::operator->): Use _Inner_iter instead of
_Outer_iter in the function signature as per LWG 3500.
* testsuite/std/ranges/adaptors/join.cc (test08): Test it.

3 years ago[PR97870] LRA: don't remove asm goto, just nullify it.
Vladimir N. Makarov [Wed, 18 Nov 2020 15:07:56 +0000 (10:07 -0500)] 
[PR97870] LRA: don't remove asm goto, just nullify it.

gcc/

2020-11-18  Vladimir Makarov  <vmakarov@redhat.com>

PR target/97870
* lra-constraints.c (curr_insn_transform): Do not delete asm goto
with wrong constraints.  Nullify it saving CFG.

3 years agotestsuite/libgomp.c/usleep.h: Use sleep-loop also for GCN
Tobias Burnus [Wed, 18 Nov 2020 13:11:27 +0000 (14:11 +0100)] 
testsuite/libgomp.c/usleep.h: Use sleep-loop also for GCN

As typically configured, newlib's libc.a does not build 'posix' and,
hence, usleep is not available. Thus, use the same fallback as for nvptx.

libgomp/
* testsuite/libgomp.c/usleep.h (fallback_usleep): Renamed from
nvptx_usleep; use also for device={arch(gcn)}.

3 years agoFix PR ada/97859, building ada cross compiler targeting powerpc64le-linux-gnu
Matthias Klose [Wed, 18 Nov 2020 12:24:33 +0000 (13:24 +0100)] 
Fix PR ada/97859, building ada cross compiler targeting powerpc64le-linux-gnu

2020-11-18  Matthias Klose  <doko@ubuntu.com>

PR ada/97859
* Makefile.rtl (powerpc% linux%): Also match powerpc64le cpu.

3 years agoMSP430: Add 64-bit hardware multiply support
Jozef Lawrynowicz [Sun, 15 Nov 2020 21:03:14 +0000 (21:03 +0000)] 
MSP430: Add 64-bit hardware multiply support

Hardware multipliers that support widening 32-bit multiplication can
be used to perform a 64-bit * 64-bit multiplication more efficiently
than a software implementation.

The following equation is used to perform 64-bit multiplication for
devices with "32bit" or "f5series" hardware multiply versions:

  64bit_result = (low32_op0 * lop32_op1)
    + ((low32_op0 * high32_op1) << 32)
       + ((high32_op0 * low32_op1) << 32)

libgcc/ChangeLog:

* config/msp430/lib2hw_mul.S (mult64_hw): New.
(if MUL_32): Use mult64_hw for __muldi3.
(if MUL_F5): Use mult64_hw for __muldi3.
* config/msp430/lib2mul.c (__muldi3): New.
* config/msp430/t-msp430 (LIB2FUNCS_EXCLUDE): Define.

3 years agoMSP430: Add mul{hi,si} and {u,}mulsidi3 expanders
Jozef Lawrynowicz [Sun, 15 Nov 2020 21:03:10 +0000 (21:03 +0000)] 
MSP430: Add mul{hi,si} and {u,}mulsidi3 expanders

GCC generates better code when multiplication operations, which require
library functions to perform, are caught in early in RTL, rather than
leaving the operation to be mapped to a library function later on.

When there is hardware multiply support, it is more efficient to perform
widening multiplication using the hardware multiplier instead of letting
GCC widen the arguments before calling the multiplication routine in the
wider mode.

gcc/ChangeLog:

* config/msp430/msp430.md (mulhi3): New.
(mulsi3): New.
(mulsidi3): Rename to *mulsidi3_inline.
(umulsidi3): Rename to *umulsidi3_inline.
(mulsidi3): New define_expand.
(umulsidi3): New define_expand.

3 years agotree-optimization/97886 - deal with strange LC PHI nodes
Richard Biener [Wed, 18 Nov 2020 09:32:29 +0000 (10:32 +0100)] 
tree-optimization/97886 - deal with strange LC PHI nodes

This makes vectorization properly assign vector types to PHI
nodes that copy from externals on loop exit edges.

2020-11-18  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97886
* tree-vect-loop.c (vectorizable_lc_phi): Properly assign
vector types to invariants for SLP.

3 years agod: Fix LHS of array concatentation evaluated before the RHS.
Iain Buclaw [Tue, 17 Nov 2020 12:11:33 +0000 (13:11 +0100)] 
d: Fix LHS of array concatentation evaluated before the RHS.

In an array append expression:

    array ~= fun(array);

The array in the left hand side of the expression was extended before
evaluating the result of the right hand side, which resulted in the
newly uninitialized array index being used before set.

This fixes that so that the result of the right hand side is always
saved in a reusable temporary before assigning to the destination.

gcc/d/ChangeLog:

PR d/97843
* d-codegen.cc (build_assign): Evaluate TARGET_EXPR before use in
the right hand side of an assignment.
* expr.cc (ExprVisitor::visit (CatAssignExp *)): Force a TARGET_EXPR
on the element to append if it is a CALL_EXPR.

gcc/testsuite/ChangeLog:

PR d/97843
* gdc.dg/torture/pr97843.d: New test.

3 years agod: Fix a couple of ICEs found in the dmd front-end (PR97842)
Iain Buclaw [Tue, 17 Nov 2020 09:48:41 +0000 (10:48 +0100)] 
d: Fix a couple of ICEs found in the dmd front-end (PR97842)

- Segmentation fault on incomplete static if.
- Segmentation fault resolving typeof() expression when gagging is on.

Reviewed-on: https://github.com/dlang/dmd/pull/11971

gcc/d/ChangeLog:

PR d/97842
* dmd/MERGE: Merge upstream dmd b6a779e49

3 years agod: Add dragonflybsd support for D compiler and runtime
Iain Buclaw [Thu, 29 Oct 2020 13:07:02 +0000 (14:07 +0100)] 
d: Add dragonflybsd support for D compiler and runtime

gcc/ChangeLog:

* config.gcc (*-*-dragonfly*): Add dragonfly-d.o and t-dragonfly.
* config/dragonfly-d.c: New file.
* config/t-dragonfly: New file.

libphobos/ChangeLog:

* configure.tgt: Add *-*-dragonfly* as a supported target.
* configure: Regenerate.
* m4/druntime/os.m4 (DRUNTIME_OS_SOURCES): Add dragonfly* as a posix
target.

3 years agolibphobos: Merge upstream phobos 7948e0967.
Iain Buclaw [Fri, 13 Nov 2020 15:56:29 +0000 (16:56 +0100)] 
libphobos: Merge upstream phobos 7948e0967.

Removes deprecated functions from std.string module.

Reviewed-on: https://github.com/dlang/phobos/pull/7694

libphobos/ChangeLog:

* src/MERGE: Merge upstream phobos 7948e0967.

3 years agoopenmp: Fix ICE on non-rectangular loop with known 0 iterations
Jakub Jelinek [Wed, 18 Nov 2020 08:40:45 +0000 (09:40 +0100)] 
openmp: Fix ICE on non-rectangular loop with known 0 iterations

The loops in the testcase are non-rectangular and have 0 iterations
(the outer loop iterates, but the inner one never).  In this case we
just have the overall number of iterations computed (0), and don't have
factor and other values computed.  We never need to map logical iterations
to the individual iterations in that case, and we were crashing during
expansion of that code.

2020-11-18  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/97862
* omp-expand.c (expand_omp_for_init_vars): Don't use the sqrt path
if number of iterations is constant 0.

* c-c++-common/gomp/pr97862.c: New test.

3 years agoRISC-V: Support version controling for ISA standard extensions
Kito Cheng [Wed, 11 Nov 2020 08:33:57 +0000 (16:33 +0800)] 
RISC-V: Support version controling for ISA standard extensions

 - New option -misa-spec support: -misa-spec=[2.2|20190608|20191213] and
   corresponding configuration option --with-isa-spec.

 - Current default ISA spec set to 2.2, but we intend to bump this to
   20191213 or later in next release.

gcc/ChangeLog:

* common/config/riscv/riscv-common.c (riscv_ext_version): New.
(riscv_ext_version_table): Ditto.
(get_default_version): Ditto.
(riscv_subset_t::implied_p): New field.
(riscv_subset_t::riscv_subset_t): Init implied_p.
(riscv_subset_list::add): New.
(riscv_subset_list::handle_implied_ext): Pass riscv_subset_t
instead of separated argument.
(riscv_subset_list::to_string): Handle zifencei and zicsr, and
omit version if version is unknown.
(riscv_subset_list::parsing_subset_version): New argument `ext`,
remove default_major_version and default_minor_version, get
default version info via get_default_version.
(riscv_subset_list::parse_std_ext): Update argument for
parsing_subset_version calls.
Handle 2.2 ISA spec, always enable zicsr and zifencei, they are
included in baseline ISA in that time.
(riscv_subset_list::parse_multiletter_ext): Update argument for
`parsing_subset_version` and `add` calls.
(riscv_subset_list::parse): Adjust argument for
riscv_subset_list::handle_implied_ext call.
* config.gcc (riscv*-*-*): Handle --with-isa-spec=.
* config.in (HAVE_AS_MISA_SPEC): New.
(HAVE_AS_MARCH_ZIFENCEI): Ditto.
* config/riscv/riscv-opts.h (riscv_isa_spec_class): New.
(riscv_isa_spec): Ditto.
* config/riscv/riscv.h (HAVE_AS_MISA_SPEC): New.
(ASM_SPEC): Pass -misa-spec if gas supported.
* config/riscv/riscv.opt (riscv_isa_spec_class) New.
* configure.ac (HAVE_AS_MARCH_ZIFENCEI): New test.
(HAVE_AS_MISA_SPEC): Ditto.
* configure: Regen.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-9.c: New.
* gcc.target/riscv/arch-10.c: Ditto.
* gcc.target/riscv/arch-11.c: Ditto.
* gcc.target/riscv/attribute-6.c: Remove, we don't support G
with version anymore.
* gcc.target/riscv/attribute-8.c: Reorder arch string to fit canonical
ordering.
* gcc.target/riscv/attribute-9.c: We don't emit version for
unknown extensions now.
* gcc.target/riscv/attribute-11.c: Add -misa-spec=2.2 flags.
* gcc.target/riscv/attribute-12.c: Ditto.
* gcc.target/riscv/attribute-13.c: Ditto.
* gcc.target/riscv/attribute-14.c: Ditto.
* gcc.target/riscv/attribute-15.c: New.
* gcc.target/riscv/attribute-16.c: Ditto.
* gcc.target/riscv/attribute-17.c: Ditto.

3 years agoRISC-V: Support zicsr and zifencei extension for -march.
Kito Cheng [Wed, 11 Nov 2020 06:04:34 +0000 (14:04 +0800)] 
RISC-V: Support zicsr and zifencei extension for -march.

 - CSR related instructions and fence instructions has to be splitted from
   baseline ISA, zicsr and zifencei are corresponding sub-extension.

gcc/ChangeLog:

* common/config/riscv/riscv-common.c (riscv_implied_info):
d and f implied zicsr.
(riscv_ext_flag_table): Handle zicsr and zifencei.
* config/riscv/riscv-opts.h (MASK_ZICSR): New.
(MASK_ZIFENCEI): Ditto.
(TARGET_ZICSR): Ditto.
(TARGET_ZIFENCEI): Ditto.
* config/riscv/riscv.md (clear_cache): Check TARGET_ZIFENCEI.
(fence_i): Ditto.
* config/riscv/riscv.opt (riscv_zi_subext): New.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-8.c: New.
* gcc.target/riscv/attribute-14.c: Ditto.

3 years agoRISC-V: Handle implied extension in canonical ordering.
Kito Cheng [Mon, 3 Aug 2020 06:01:39 +0000 (14:01 +0800)] 
RISC-V: Handle implied extension in canonical ordering.

 - ISA spec has specify the order between multi-letter extensions, implied
   extension also need to follow store in canonical ordering, so
   most easy way is we keep that in-order during insertion.

gcc/ChangeLog:

* common/config/riscv/riscv-common.c (single_letter_subset_rank): New.
(multi_letter_subset_rank): Ditto.
(subset_cmp): Ditto.
(riscv_subset_list::add): Insert subext in canonical ordering.
(riscv_subset_list::parse_std_ext): Move handle_implied_ext to ...
(riscv_subset_list::parse): ... here.

3 years agoClean up loop-closed PHIs after loop finalize
guojiufu [Tue, 17 Nov 2020 11:49:03 +0000 (19:49 +0800)] 
Clean up loop-closed PHIs after loop finalize

This patch propagates loop-closed PHIs them out at
loop_optimizer_finalize.  For some cases, to clean up loop-closed PHIs
would save efforts of optimization passes after loopdone.

Thanks,
Jiufu Guo.

gcc/ChangeLog:
2020-10-18  Jiufu Guo   <guojiufu@linux.ibm.com>

* cfgloop.h (loop_optimizer_finalize): Add flag argument.
* loop-init.c (loop_optimizer_finalize): Call clean_up_loop_closed_phi.
* tree-cfgcleanup.h (clean_up_loop_closed_phi): New declare.
* tree-ssa-loop.c (tree_ssa_loop_done): Call loop_optimizer_finalize
with flag argument.
* tree-ssa-propagate.c (clean_up_loop_closed_phi): New function.

gcc/testsuite/ChangeLog:
2020-10-18  Jiufu Guo   <guojiufu@linux.ibm.com>

* gcc.dg/tree-ssa/loopclosedphi.c: New test.

3 years agocmd/go, cmd/cgo: update gofrontend mangling checks
Ian Lance Taylor [Fri, 2 Oct 2020 23:03:37 +0000 (16:03 -0700)] 
cmd/go, cmd/cgo: update gofrontend mangling checks

This is a port of two patches in the master repository.

https://golang.org/cl/259298

    cmd/cgo: split gofrontend mangling checks into cmd/internal/pkgpath

    This is a step toward porting https://golang.org/cl/219817 from the
    gofrontend repo to the main repo.

    Note that this also corrects the implementation of the v2 mangling
    scheme to use ..u and ..U where appropriate.

https://golang.org/cl/259299

    cmd/go: use cmd/internal/pkgpath for gccgo pkgpath symbol

For golang/go#37272
For golang/go#41862

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/270637

3 years agoDaily bump.
GCC Administrator [Wed, 18 Nov 2020 00:16:34 +0000 (00:16 +0000)] 
Daily bump.

3 years agolibstdc++: Revert changes for SYS_clock_gettime64 [PR 93421]
Jonathan Wakely [Tue, 17 Nov 2020 16:13:02 +0000 (16:13 +0000)] 
libstdc++: Revert changes for SYS_clock_gettime64 [PR 93421]

As discussed in the PR, it's incredibly unlikely that a system that
needs to use the SYS_clock_gettime syscall (e.g. glibc 2.16 or older) is
going to define the SYS_clock_gettime64 macro. Ancient systems that need
to use the syscall aren't going to have time64 support.

This reverts the recent changes to try and make clock_gettime syscalls
be compatible with systems that have been updated for time64 (those
changes were wrong anyway as they misspelled the SYS_clock_gettime64
macro). The changes for futex syscalls are retained, because we still
use them on modern systems that might be using time64.

To ensure that the clock_gettime syscalls are safe, configure will fail
if SYS_clock_gettime is needed, and SYS_clock_gettime64 is also defined
(but to a distinct value from SYS_clock_gettime), and the tv_sec member
of timespec is larger than long. This means we will be unable to build
on a hypothetical system where we need the time32 version of
SYS_clock_gettime but where userspace is using a time64 struct timespec.
In the unlikely event that this failure is triggered on any real
systems, we can fix it later. But we probably won't need to.

libstdc++-v3/ChangeLog:

PR libstdc++/93421
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Fail if struct
timespec isn't compatible with SYS_clock_gettime.
* configure: Regenerate.
* src/c++11/chrono.cc: Revert changes for time64 compatibility.
Add static_assert instead.
* src/c++11/futex.cc (_M_futex_wait_until_steady): Assume
SYS_clock_gettime can use struct timespec.

3 years agoadd --with-{cpu,arch,tune}-{32,64} as alias flags for --with-{cpu,arch,tune}
Sebastian Pop [Tue, 17 Nov 2020 18:56:15 +0000 (18:56 +0000)] 
add --with-{cpu,arch,tune}-{32,64} as alias flags for --with-{cpu,arch,tune}

gcc/
* config.gcc: add configure flags --with-{cpu,arch,tune}-{32,64}
as alias flags for --with-{cpu,arch,tune} on AArch64.
* doc/install.texi: Document new flags for aarch64.

3 years agoadd --with-tune configure flag
Sebastian Pop [Tue, 17 Nov 2020 16:00:51 +0000 (16:00 +0000)] 
add --with-tune configure flag

fixes a configure error on Arm64 when passing --with-tune=... to configure:
```
This target does not support --with-tune.
Valid --with options are: abi cpu arch
```
The missing flag sets target tuning to a different value than generic tuning.

gcc/
* config.gcc: Add --with-tune to AArch64 configure flags.

3 years agorecognize implied ranges for modulo.
Andrew MacLeod [Tue, 17 Nov 2020 19:47:58 +0000 (14:47 -0500)] 
recognize implied ranges for modulo.

implement op1_range for modulo with implied positive and negative ranges.

gcc/
PR tree-optimization/91029
* range-op.cc (operator_trunc_mod::op1_range): New.
gcc/testsuite/
* gcc.dg/pr91029.c: New.

3 years agoFix ipa-icf ICE on variadic types
Jan Hubicka [Tue, 17 Nov 2020 21:55:42 +0000 (22:55 +0100)] 
Fix ipa-icf ICE on variadic types

* ipa-icf.c (sem_function::hash_stmt): Fix conditional on
variably_modified_type_p.

3 years agoextend cache_integer_cst
Nathan Sidwell [Tue, 17 Nov 2020 21:23:32 +0000 (13:23 -0800)] 
extend cache_integer_cst

This modules-related patch extends cache_integer_cst.  Currently, when
given a small cst, that cst is added to the type's small and /must
not/ already be there.  Large values are fine if they are already in
the large cache.  This adds a parameter to indicate small duplicates
are ok, and it returns the cached value -- either what was already
tehre, or the newly inserted const.

gcc/
* tree.h (cache_integer_cst): Add defaulted might_duplicate parm.
* tree.c (cache_integer_cst): Return the integer cst, add
might_duplicate parm to permit finding a small duplicate.

3 years agoc++: duplicate block-scope extern [PR 97877]
Nathan Sidwell [Tue, 17 Nov 2020 21:16:47 +0000 (13:16 -0800)] 
c++: duplicate block-scope extern [PR 97877]

We ICED with a duplicated block-scope extern, as duplicate_decls was
dropping the decl_lang_specific of olddecl.  Simplys adding
appropriate retrofitting and copying turned out to be insufficient
because you can get a block-scope using decl also matching the extern.
The latter seems a little suspicious and I have asked CWG for advice.
While there robustified the assert about releasing olddecls'
lang-specific -- if it had one, the new decl better have one.

PR c++/97877
gcc/cp/
* decl.c (duplicate_decls): Deal with duplicated DECL_LOCAL_DECL_P
decls.  Extend decl_lang_specific checking assert.
gcc/testsuite/
* g++.dg/lookup/pr97877.C: New.

3 years agoglobal trees
Nathan Sidwell [Tue, 17 Nov 2020 18:07:25 +0000 (10:07 -0800)] 
global trees

This reorders the common and c++ global tree arrays.  It introduces a
module-specific High Water Mark, below which are the immutable slots
initialized at startup and beyond which are the lazily filled slots
(and a few immutables we need to locate by name lookup anyway).

gcc/c-family/
* c-common.h (enum c_tree_index): Reorder to place lazy fields
after newly-added CTI_MODULE_HWM.
gcc/cp/
* cp-tree.h (enum cp_tree_index): Reorder to place lazy fields
after newly-added CPTI_MODULE_HWM.

3 years agoFortran texi: Fix description of GFC_RTCHECK_* macros.
Harald Anlauf [Tue, 17 Nov 2020 21:26:26 +0000 (22:26 +0100)] 
Fortran texi: Fix description of GFC_RTCHECK_* macros.

gcc/fortran/ChangeLog:

* gfortran.texi: Fix description of GFC_RTCHECK_* to match actual
code.

3 years agoIOR with nonzero, range cannot contain 0.
Andrew MacLeod [Tue, 17 Nov 2020 15:04:38 +0000 (10:04 -0500)] 
IOR with nonzero, range cannot contain 0.

Remove zero from IOR ranges with non-zero masks.

gcc/
PR tree-optimization/83072
* range-op.cc (wi_optimize_and_or): Remove zero from IOR range when
mask is non-zero.
gcc/testsuite/
* gcc.dg/pr83072.c: New.

3 years agoC++ : Remove an overzealous checking assert [PR97871]
Iain Sandoe [Tue, 17 Nov 2020 16:28:30 +0000 (16:28 +0000)] 
C++ : Remove an overzealous checking assert [PR97871]

It seems we accept __attribute__(()) without any diagnostic at present,
so my added checking assert fires for something like:

__attribute__ (()) int a;

Fixed by removing the assert; in the case that the user enters something
like:

__attribute__ (()) extern "C" int foo;

The diagnostic about attributes before linkage specs will fire and show
the empty attributes.

gcc/cp/ChangeLog:

PR c++/97871
* parser.c (cp_parser_declaration): Remove checking assert.

3 years agofloat.h: Handle C2x __STDC_WANT_IEC_60559_EXT__
Joseph Myers [Tue, 17 Nov 2020 16:30:35 +0000 (16:30 +0000)] 
float.h: Handle C2x __STDC_WANT_IEC_60559_EXT__

TS 18661-1 and 18661-2 have various definitions conditional on
__STDC_WANT_IEC_60559_BFP_EXT__ and __STDC_WANT_IEC_60559_DFP_EXT__
macros.  When those TSes were integrated into C2x, most of the feature
test macro conditionals were removed (with declarations for decimal FP
becoming conditional only on whether decimal FP is supported by the
implementation and those for binary FP becoming unconditionally
required).

A few tests of those feature test macros remained for declarations
that appeared only in Annex F and not in the main part of the
standard.  A change accepted for C2x at the last WG14 meeting (but not
yet added to the working draft in git) was to replace both those
macros by __STDC_WANT_IEC_60559_EXT__; if __STDC_WANT_IEC_60559_EXT__
is defined, the specific declarations in the headers will then depend
on which features are supported by the implementation, as for
declarations not controlled by a feature test macro at all.

Thus, add a check of __STDC_WANT_IEC_60559_EXT__ for CR_DECIMAL_DIG in
float.h, the only case of this change relevant to GCC.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

* ginclude/float.h (CR_DECIMAL_DIG): Also define for
[__STDC_WANT_IEC_60559_EXT__].

gcc/testsuite/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

* gcc.dg/cr-decimal-dig-3.c: New test.

3 years agofloat.h: C2x *_IS_IEC_60559 macros
Joseph Myers [Tue, 17 Nov 2020 16:25:45 +0000 (16:25 +0000)] 
float.h: C2x *_IS_IEC_60559 macros

C2x adds float.h macros that say whether float, double and long double
match an IEC 60559 (IEEE 754) format and operations.  Add these
macros to GCC's float.h.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c-family/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

* c-cppbuiltin.c (builtin_define_float_constants): Define
"*_IS_IEC_60559__" macros.

gcc/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

* ginclude/float.h [__STDC_VERSION__ > 201710L] (FLT_IS_IEC_60559,
DBL_IS_IEC_60559, LDBL_IS_IEC_60559): New macros.

gcc/testsuite/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

* gcc.dg/c11-float-6.c, gcc.dg/c2x-float-10.c: New tests.

3 years agotestsuite: allow opd section
David Edelsohn [Tue, 17 Nov 2020 16:14:13 +0000 (11:14 -0500)] 
testsuite: allow opd section

PPC64 Linux ELFv1 uses function descriptors with the descriptor
placed in the .opd section.  This patch expands the pattern in the testcase
to accept .opd section name associated with the function name.

gcc/testsuite/ChangeLog:

* gcc.dg/pr25376.c: Allow .opd section.

3 years agopreprocessor: new callbacks
Nathan Sidwell [Tue, 17 Nov 2020 16:16:50 +0000 (08:16 -0800)] 
preprocessor: new callbacks

These two callbacks are needed for C++ modules.  The first is for
handling macros from header-units.  These are resolved lazily.  The
second is for include-translation -- whether a #include gets turned
into a header-unit import.

libcpp/
* include/cpplib.h (struct cpp_callbacks): Add
user_deferred_macro & translate_include.

3 years agolibstdc++: Fix unconditional definition of __cpp_lib_span in <version> [PR 97869}
Jonathan Wakely [Tue, 17 Nov 2020 15:26:29 +0000 (15:26 +0000)] 
libstdc++: Fix unconditional definition of __cpp_lib_span in <version> [PR 97869}

The <span> header is empty unless Concepts are supported, but <version>
defines the __cpp_lib_span feature test macro unconditionally. It should
be guarded by the same conditions as in <span>.

libstdc++-v3/ChangeLog:

PR libstdc++/97869
* include/precompiled/stdc++.h: Include <coroutine>.
* include/std/version (__cpp_lib_span): Check __cpp_lib_concepts
before defining.

3 years agopreprocessor: module line maps
Nathan Sidwell [Tue, 17 Nov 2020 16:01:50 +0000 (08:01 -0800)] 
preprocessor: module line maps

This patch adds LC_MODULE as a map kind, used to indicate a c++
module.  Unlike a regular source file, it only contains a single
location, and the source locations in that module are represented by
ordinary locations whose 'included_from' location is the module.

It also exposes some entry points that modules will use to create
blocks of line maps.

In the original posting, I'd missed the deletion of the
linemap_enter_macro from internal.h.  That's included here.

libcpp/
* include/line-map.h (enum lc_reason): Add LC_MODULE.
(MAP_MODULE_P): New.
(line_map_new_raw): Declare.
(linemap_enter_macro): Move declaration from internal.h
(linemap_module_loc, linemap_module_reparent)
(linemap_module_restore): Declare.
(linemap_lookup_macro_indec): Declare.
* internal.h (linemap_enter_macro): Moved to line-map.h.
* line-map.c (linemap_new_raw): New, broken out of ...
(new_linemap): ... here.  Call it.
(LAST_SOURCE_LINE_LOCATION): New.
(liemap_module_loc, linemap_module_reparent)
(linemap_module_restore): New.
(linemap_lookup_macro_index): New, broken out of ...
(linemap_macro_map_lookup): ... here.  Call it.
(linemap_dump): Add module dump.

3 years agoAdd MODE_OPAQUE
Aaron Sawdey [Wed, 4 Nov 2020 19:54:25 +0000 (13:54 -0600)] 
Add MODE_OPAQUE

After discussion with Richard Sandiford on IRC, he suggested adding a
new mode class MODE_OPAQUE to deal with the problems (PR 96791) we had
been having with POImode/PXImode in powerpc target. This patch is the
accumulation of changes I needed to make to add this and make it useable
for the purposes of what power10 MMA needed.

MODE_OPAQUE modes allow you to have modes for which you can just
define loads and stores. By design, optimization does not expect to
know how to do arithmetic or subregs on these modes. This allows us to
have modes for multi-register vector operations where we don't want to
open Pandora's Box and define general arithmetic operations.

This patch will be followed by a target specific patch to change the
powerpc power10 MMA builtins to use opaque modes, and will also let use
use the vector pair loads/stores defined with that in the inline expansion
of memcpy/memmove, allowing me to fix PR 96791.

gcc/ChangeLog
PR target/96791
* mode-classes.def: Add MODE_OPAQUE.
* machmode.def: Add OPAQUE_MODE.
* tree.def: Add OPAQUE_TYPE for types that will use
MODE_OPAQUE.
* doc/generic.texi: Document OPAQUE_TYPE.
* doc/rtl.texi: Document MODE_OPAQUE.
* machmode.h: Add OPAQUE_MODE_P().
* genmodes.c (complete_mode): Add MODE_OPAQUE.
(opaque_mode): New function.
* tree.c (tree_code_size): Add OPAQUE_TYPE.
* tree.h: Add OPAQUE_TYPE_P().
* stor-layout.c (int_mode_for_mode): Treat MODE_OPAQUE modes
like BLKmode.
* ira.c (find_moveable_pseudos): Treat MODE_OPAQUE modes more
like integer/float modes here.
* dbxout.c (dbxout_type): Treat OPAQUE_TYPE like VOID_TYPE.
* tree-pretty-print.c (dump_generic_node): Treat OPAQUE_TYPE
like like other types.

3 years agolibstdc++: Fix ranges::search_n for random access iterators [PR97828]
Patrick Palka [Tue, 17 Nov 2020 15:28:20 +0000 (10:28 -0500)] 
libstdc++: Fix ranges::search_n for random access iterators [PR97828]

My ranges transcription of the std::search_n implementation for random
access iterators missed a crucial part of the algorithm which the
existing tests didn't exercise.  When __remainder is less than __count
at the start of an iteration of the outer while loop, it means we're
continuing a partial match of __count - __remainder elements from the
previous iteration.  If at the end of the iteration we don't complete
this partial match, we need to reset __remainder so that it's only
offset by the size of the most recent partial match before starting the
next iteration.

This patch fixes this appropriately, mirroring how it's done in the
corresponding std::search_n implementation.

libstdc++-v3/ChangeLog:

PR libstdc++/97828
* include/bits/ranges_algo.h (__search_n_fn::operator()): Check
random_access_iterator before using the backtracking
implementation.  When the backwards scan fails prematurely,
reset __remainder appropriately.
* testsuite/25_algorithms/search_n/97828.cc: New test.

3 years agopreprocessor: Fix profiled bootstrap warning [pr97858]
Nathan Sidwell [Tue, 17 Nov 2020 14:45:18 +0000 (06:45 -0800)] 
preprocessor: Fix profiled bootstrap warning [pr97858]

As Jakub points out, we only ever pass a single variadic parm (if at
all), so just an optional arg is fine.

PR preprocessor/97858
libcpp/
* mkdeps.c (munge): Drop varadic args, we only ever use one.

3 years agoImprove handling of memory operands in ipa-icf 3/4
Jan Hubicka [Tue, 17 Nov 2020 14:41:06 +0000 (15:41 +0100)] 
Improve handling of memory operands in ipa-icf 3/4

this patch is based on Maritn's patch
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-11/msg02633.html
however based on new code that track and compare memory accesses
so it can be implemented correctly.

As shown here
https://gcc.gnu.org/pipermail/gcc-patches/2020-November/558773.html
the most common reason for function body being streamed in but merging to fail
is the mismatch in base alias set.

This patch collect base and ref types ao_alias_ptr types, stream them to WPA
and at WPA time hash is produced. Now we can use alias_sets since these these
are assumed to be same as ltrans time alias sets. This is currently not always
true - but that is pre-existing issue.  I will try to produce a testcase and
make followup patch on this (that will stream out ODR types with TYPE_CANONICAL
that is !ODR as !ODR type). However for this patch this is not a problem since
the real alias sets are finer but definitly not coarser.

We may make it possible to use canonical type hash and save some streaming, but
I think it would be better to wait for next stage1 since it is not completely
trivial WRT ODR types: either we hash ODR type names and then hash values would
be too coarse for cases we got conflict betwen C and C++ type or we do not
stream and will again get into trouble with hash values being too weak. Tried
that - we get a lot of types that are struturally same but distinguished by
ODR names (from template instantiations).

As followup I will add code for merging with mismatched base alias sets.  This
makes the aforementioned problem about ODR names less pronounced but it is
still present on pointer loads/stores which requires REF alias set mismatches.

2020-11-13  Jan Hubicka  <hubicka@ucw.cz>
    Martin Liska  <mliska@suse.cz>

* ipa-icf.c: Include data-streamer.h and alias.h.
(sem_function::sem_function): Initialize memory_access_types
and m_alias_sets_hash.
(sem_function::hash_stmt): For memory accesses and when going to
do lto streaming add base and ref types into memory_access_types.
(sem_item_optimizer::write_summary): Stream memory access types.
(sem_item_optimizer::read_section): Likewise and also iniitalize
m_alias_sets_hash.
(sem_item_optimizer::execute): Call
sem_item_optimizer::update_hash_by_memory_access_type.
(sem_item_optimizer::update_hash_by_memory_access_type): Updat.
* ipa-icf.h (sem_function): Add memory_access_types and
m_alias_sets_hash.

3 years agoMake ltrans type canonicals compatible with WPA ones
Jan Hubicka [Tue, 17 Nov 2020 14:38:13 +0000 (15:38 +0100)] 
Make ltrans type canonicals compatible with WPA ones

This patch fixes profiledbootstrap failure with LTO enabled.
Not refining alias sets from WPA to ltrans time is a good invariant to
maintain and the canonical type hash behaves this way.  However I broke
this with the ODR logic.

Normally we define canonical types for C++ ODR types according to their
type names.  However to make ODR types compatible with C types we check
if structurally equivalent C type exists and if so, we ignore ODR
names giving up on the precision.

This however is not stable between WPA and ltrans since at ltrans the
type merging does not see as many types as WPA does.  To make this
consistent the patch makes WPA ODR_TYPE_P == 0 for ODR types that
conflicted with non-ODR type.

I had to drop one sanity check in ipa-utils.h (that I think is not very
important - I added it while introducing CXX_ODR_P machinery) and also
it now may happen that we query odr_based_tbaa_p before registering
first ODR type so we do not want to ICE here.
ODR type registration happens early to produce ODR violation warings.
Those are not done at ltrans, so dropping the registration is safe. The
type will still be added while computing the type inheritance graph if
needed for devirtualization (and late devirtualization is not very
useful anyway since it won't enable inlining).

gcc/ChangeLog:
PR bootstrap/97857
* ipa-devirt.c (odr_based_tbaa_p): Do not ICE when
odr_hash is not initialized
* ipa-utils.h (type_with_linkage_p): Do not sanity check
CXX_ODR_P.
* tree-streamer-out.c (pack_ts_type_common_value_fields): Set
CXX_ODR_P according to the canonical type.

gcc/lto/ChangeLog:
PR bootstrap/97857
* lto-common.c (gimple_register_canonical_type_1): Only
register types with TYPE_CXX_ODR_P flag; sanity check that no
conflict happens at ltrans time.

3 years agolanghooks: preprocessor hooks for c++ modules
Nathan Sidwell [Tue, 17 Nov 2020 14:07:30 +0000 (06:07 -0800)] 
langhooks: preprocessor hooks for c++ modules

This is a slightly modified version of 01-langhooks.def.  I realized I
didn't need the deferred macro langhook -- that can be directly
installed into the preprocessor callbacks via preprocess_options lang
hook.

gcc/
* langhooks-def.h (LANG_HOOKS_PREPROCESS_MAIN_FILE)
(LANG_HOOKS_PREPROCESS_OPTIONS, LANG_HOOKS_PREPROCESS_UNDEF)
(LANG_HOOKS_PREPROCESS_TOKEN): New.
(LANG_HOOKS_INITIALIZER): Add them.
* langhooks.h (struct lang_hooks): Add preprocess_main_file,
preprocess_options, preprocess_undef, preprocess_token hooks.  Add
enum PT_flags.
gcc/c-family/
* c-lex.c: #include "langhooks.h".
(cb_undef): Maybe call preprocess_undef lang hook.
* c-opts.c (c_common_post_options): Maybe call preprocess_options
lang hook.
(push_command_line_include): Maybe call preprocess_main_file lang
hook.
(cb_file_change): Likewise.
* c-ppoutput.c: #include "langhooks.h.
(scan_translation_unit): Maybe call preprocess_token lang hook.
(class do_streamer): New, derive from token_streamer.
(directives_only_cb): Data pointer is do_streamer, call
preprocess_token lang hook.
(scan_translation_unit_directives_only): Use do_streamer.
(print_line_1): Move src_line recording to after string output.
(cb_undef): Maybe call preprocess_undef lang hook.

3 years agoc-family: token streamer
Nathan Sidwell [Tue, 17 Nov 2020 12:43:31 +0000 (04:43 -0800)] 
c-family: token streamer

This is broken out of modules patch 01-langhooks.diff, I realized that
this part is independent, and removes some duplicated code -- migrated
to the token_streamer class.

gcc/c-family/
* c-ppoutput.c (scan_translation_unit): Use token_streamer, remove
code duplicating that functionality.

3 years agox86: Add a testcase for PR target/31799
H.J. Lu [Tue, 17 Nov 2020 14:01:41 +0000 (06:01 -0800)] 
x86: Add a testcase for PR target/31799

Add a testcase for PR target/31799 which was fixed by

commit 4f0473fe89e68bf7c09542ee5c3684da25a5b435
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Fri May 12 21:04:05 2017 +0200

    compare-elim.c (try_eliminate_compare): Canonicalize operation with embedded compare to [(set (reg:CCM) (compare:CCM...

            * compare-elim.c (try_eliminate_compare): Canonicalize
            operation with embedded compare to
            [(set (reg:CCM) (compare:CCM (operation) (immediate)))
             (set (reg) (operation)].

            * config/i386/i386.c (TARGET_FLAGS_REGNUM): New define.

in GCC 8.

PR target/31799
* gcc.target/i386/pr31799.c: New test.

3 years agoaarch64: Remove XFAILs for two SVE tests
Richard Sandiford [Tue, 17 Nov 2020 12:02:50 +0000 (12:02 +0000)] 
aarch64: Remove XFAILs for two SVE tests

These tests started passing a while ago, so remove the XFAILs.

gcc/testsuite/
* gcc.target/aarch64/sve/cond_cnot_1.c: Remove XFAIL.
* gcc.target/aarch64/sve/cond_unary_1.c: Likewise.

3 years agoPR97693: Specify required vectype in vectorizable_call
Richard Sandiford [Tue, 17 Nov 2020 11:51:40 +0000 (11:51 +0000)] 
PR97693: Specify required vectype in vectorizable_call

The vectorizable_call part of r11-1143 dropped the required
vectype when moving from vect_get_vec_def_for_operand to
vect_get_vec_defs_for_operand.  This caused an ICE on the
testcase for SVE, because we ended up with a non-predicate
value being passed to a predicate input.

AFAICT this was the only instance of that happening.  The types
seemed to get carried forward for all the other converted calls.

gcc/
PR tree-optimization/97693
* tree-vect-stmts.c (vectorizable_call): Pass the required vectype
to vect_get_vec_defs_for_operand.

gcc/testsuite/
PR tree-optimization/97693
* gcc.dg/vect/pr97693.c: New test.

3 years agotestsuite: Add a vect_load_lanes guard
Richard Sandiford [Tue, 17 Nov 2020 11:12:54 +0000 (11:12 +0000)] 
testsuite: Add a vect_load_lanes guard

We still fall back to load/store-lanes for slp-46.c, if the target
supports it.

gcc/testsuite/
* gcc.dg/vect/slp-46.c: XFAIL test for SLP on vect_load_lanes targets.

3 years agotestsuite: Add a vect_element_align_preferred guard
Richard Sandiford [Tue, 17 Nov 2020 11:12:53 +0000 (11:12 +0000)] 
testsuite: Add a vect_element_align_preferred guard

We don't try to increase the alignment of decls if
vect_element_align_preferred.

gcc/testsuite/
* gcc.dg/vect/aligned-section-anchors-nest-1.c: XFAIL alignment
test if vect_element_align_preferred.

3 years agotestsuite: Adjust vect/bb-slp-subgroups-3.c for VL vectors
Richard Sandiford [Tue, 17 Nov 2020 11:12:53 +0000 (11:12 +0000)] 
testsuite: Adjust vect/bb-slp-subgroups-3.c for VL vectors

Because we disable the cost model, targets with variable-length
vectors can end up vectorising the store to a[0..7] on its own.
With the cost model we do something sensible.

gcc/testsuite/
* gcc.dg/vect/bb-slp-subgroups-3.c: XFAIL for variable-length vectors.

3 years agotestsuite: Adjust vect/pr65947-8.c for SVE
Richard Sandiford [Tue, 17 Nov 2020 11:12:52 +0000 (11:12 +0000)] 
testsuite: Adjust vect/pr65947-8.c for SVE

We can vectorise vect/pr65947-8.c for SVE, as we can for GCN.

gcc/testsuite/
* gcc.dg/vect/pr65947-8.c: Expect the loop to be vectorized for SVE.

3 years agotestsuite: XFAIL SLP induction tests for VL vectors
Richard Sandiford [Tue, 17 Nov 2020 11:12:51 +0000 (11:12 +0000)] 
testsuite: XFAIL SLP induction tests for VL vectors

We don't yet support SLP inductions for variable-length vectors,
so this patch XFAILs some associated tests.

(Inductions aren't inherently difficult to support.  It just hasn't
been done yet.)

gcc/testsuite/
* gcc.dg/vect/pr97678.c: XFAIL test for SLP vectorization
for variable-length vectors.
* gcc.dg/vect/pr97835.c: Likewise.
* gcc.dg/vect/slp-49.c: Likewise.
* gcc.dg/vect/vect-outer-slp-1.c: Likewise.
* gcc.dg/vect/vect-outer-slp-2.c: Likewise.
* gcc.dg/vect/vect-outer-slp-3.c: Likewise.

3 years agotestsuite: XFAIL some SLP reduction tests for VLA SVE
Richard Sandiford [Tue, 17 Nov 2020 11:12:50 +0000 (11:12 +0000)] 
testsuite: XFAIL some SLP reduction tests for VLA SVE

For variable-length SVE, we can only use SLP for N scalars of type
T if the number of Ts in a vector is a multiple of N.  For ints
this means that N must be 4 or 2, so this patch XFAILs two tests
for N==8.

The exact limit seems inherently target-specific -- variable-length
vectors with a 256-bit granule would work fine -- so I used aarch64_sve
selectors on the XFAILs.

gcc/testsuite/
* gcc.dg/vect/slp-reduc-4.c: XFAIL test for SLP vectorization
for variable-length SVE.
* gcc.dg/vect/slp-reduc-7.c: Likewise.

3 years agotestsuite: Remove XFAIL for variable-length vectors
Richard Sandiford [Tue, 17 Nov 2020 11:12:49 +0000 (11:12 +0000)] 
testsuite: Remove XFAIL for variable-length vectors

The XFAIL for variable-length vectors is no longer needed since
we can't build the required constant vector and so fall back to
fixed-length alternatives.

gcc/testsuite/
* gcc.dg/vect/bb-slp-43.c: Remove XFAIL for vect_variable_length.

3 years agotestsuite: Extend vector() regexp
Richard Sandiford [Tue, 17 Nov 2020 11:12:49 +0000 (11:12 +0000)] 
testsuite: Extend vector() regexp

For variable-length vectors, the N inside “vector(N) T” can
contain the characters ‘[’, ‘]’ and ‘,’.

gcc/testsuite/
* gcc.dg/vect/pr91750.c: Allow "[]," inside a vector(...) lane count.

3 years agogcc: Add `ll` and `L` length modifiers for `ms_printf`
Liu Hao [Thu, 12 Nov 2020 14:20:29 +0000 (22:20 +0800)] 
gcc: Add `ll` and `L` length modifiers for `ms_printf`

Previous code abused `FMT_LEN_L` for the `I` modifier. As `L` is a
valid modifier for `f`, `e`, `g`, etc. and `I` has the same semantics
as the C99 `z` modifier, `FMT_LEN_z` is now used instead.

First, in the Microsoft ABI, type `long double` has the same layout as
type `double`, so `%Lg` behaves identically to `%g`. Users should pass
in `double`s instead of `long double`s, as GCC uses the 10-byte format.

Second, with a CRT that is recent enough (MSVCRT since Vista, MSVCR80,
UCRT, or mingw-w64 8.0), `printf`-family functions can handle the `ll`
length modifier correctly. This ability is assumed to be available
universally. A lot of libraries (such as libgomp) that use the
`format(printf, ...)` attribute used to suffer from warnings about
unknown format specifiers.

Reference: https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008/tcxf1dw6(v=vs.90)
Reference: https://docs.microsoft.com/en-us/cpp/porting/visual-cpp-what-s-new-2003-through-2015#new-crt-features
Signed-off-by: Liu Hao <lh_mouse@126.com>
gcc/ChangeLog:
* config/i386/msformat-c.c: Add more length modifiers.

gcc/testsuite/ChangeLog:
* gcc.dg/format/ms_c99-printf-3.c: Update tests.

3 years agoMingW: Don't add suffix for nul device
Tamar Christina [Tue, 17 Nov 2020 10:14:53 +0000 (10:14 +0000)] 
MingW: Don't add suffix for nul device

This patch fixes an issue where on systems that are
HAVE_TARGET_EXECUTABLE_SUFFIX the driver calls convert_filename in order to
add the suffix to the filename.  However while it excludes `-` it doesn't
exclude the null device.  This patches changes the check to exclude anything
that is not a file by calling not_actual_file_p instead.

This also fixes a bug in not_actual_file_p which was accidentally testing
a the global variable output_file instead of the supplied argument.  This
hasn't been an issue so far because because not_actual_file_p was only used
on output_file till now.

This fixes the adding of an extension to the nul device which is against
the recommendations on msdn[0] and makes it harder for the next tool in line
to detect it.

Bootstrapped Regtested on x86_64-w64-mingw32 and no issues.
Did do a bootstrap on x86_64-pc-linux-gnu but no regtest as it's not a
HAVE_TARGET_EXECUTABLE_SUFFIX system.

[0] https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file

gcc/ChangeLog:

PR driver/97574
* gcc.c (convert_filename): Don't add suffix to things that are
not files.
(not_actual_file_p): Use supplied argument.

3 years agoc: Reject _Atomic type * as last argument to __builtin_*_overflow [PR90628]
Jakub Jelinek [Tue, 17 Nov 2020 08:37:25 +0000 (09:37 +0100)] 
c: Reject _Atomic type * as last argument to __builtin_*_overflow [PR90628]

During the __builtin_clear_padding implementation, I've noticed we don't
diagnose _Atomic whatever * as last argument to __builtin_*_overflow.
As the storing by that builtin isn't atomic in any way, I think we should
reject it.

2020-11-17  Jakub Jelinek  <jakub@redhat.com>

PR c/90628
* c-common.c (check_builtin_function_arguments)
<case BUILT_IN_ADD_OVERFLOW>: Diagnose when last argument is pointer
to _Atomic.  For the TYPE_READONLY case, adjust message to be usable
for more builtins and argument positions.

* gcc.dg/builtin-arith-overflow-4.c: New test.

3 years agoguality: Workaround for guality/pr59776.c testcase
Jakub Jelinek [Tue, 17 Nov 2020 08:35:12 +0000 (09:35 +0100)] 
guality: Workaround for guality/pr59776.c testcase

The test has been added 3 years before noipa attribute has been introduced,
but already at that point I wanted to avoid IPA opts getting into way,
most of the foo function is optimized away and the debug info just points
to the caller\s var.  With the recent modref/aliasing changes the caller's
store to the variable whose address it is passing to the function is
optimized away too.

I think we should just use noipa to avoid this, though perhaps longer term
we should think about some debug info improvements how to deal with that.

The caller had before dse1:
  # DEBUG BEGIN_STMT
  x.f = 5.0e+0;
  x.g = 6.0e+0;
  # DEBUG BEGIN_STMT
  foo (&x);
  # DEBUG BEGIN_STMT
  x ={v} {CLOBBER};
and the x.f and x.g stores are optimized away.  If we had a way to pretend
the memory contains those values anyway...

Tested on x86_64-linux, fixes the guality regressions
+FAIL: gcc.dg/guality/pr59776.c   -O1  -DPREVENT_OPTIMIZATION  line pr59776.c:17 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O1  -DPREVENT_OPTIMIZATION  line pr59776.c:17 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -O1  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O1  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -O1  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s2.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O2  -DPREVENT_OPTIMIZATION  line pr59776.c:17 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O2  -DPREVENT_OPTIMIZATION  line pr59776.c:17 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -O2  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O2  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -O2  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s2.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  -DPREVENT_OPTIMIZATION line pr59776.c:17 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  -DPREVENT_OPTIMIZATION line pr59776.c:17 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  -DPREVENT_OPTIMIZATION line pr59776.c:20 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  -DPREVENT_OPTIMIZATION line pr59776.c:20 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  -DPREVENT_OPTIMIZATION line pr59776.c:20 s2.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line pr59776.c:17 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line pr59776.c:17 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line pr59776.c:20 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line pr59776.c:20 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line pr59776.c:20 s2.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O3 -g  -DPREVENT_OPTIMIZATION  line pr59776.c:17 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O3 -g  -DPREVENT_OPTIMIZATION  line pr59776.c:17 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -O3 -g  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -O3 -g  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -O3 -g  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s2.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -Os  -DPREVENT_OPTIMIZATION  line pr59776.c:17 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -Os  -DPREVENT_OPTIMIZATION  line pr59776.c:17 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -Os  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s1.f == 5.0
+FAIL: gcc.dg/guality/pr59776.c   -Os  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s1.g == 6.0
+FAIL: gcc.dg/guality/pr59776.c   -Os  -DPREVENT_OPTIMIZATION  line pr59776.c:20 s2.f == 5.0
introduced in the last 2 days.

2020-11-17  Jakub Jelinek  <jakub@redhat.com>

* gcc.dg/guality/pr59776.c (foo): Use noipa attribute instead of
noinline, noclone.

3 years agoRelocatable read-only section support for absolute jump table
Haochen Gui [Tue, 17 Nov 2020 19:52:15 +0000 (13:52 -0600)] 
Relocatable read-only section support for absolute jump table

This patch puts absolute jump tables into a relocatable read-only section
if they are on ELF target and relocation is supported.

gcc/ChangeLog:

* final.c (final_scan_insn_1): Set jump table relocatable as the
second argument of targetm.asm_out.function_rodata_section.
* output.h (default_function_rodata_section,
default_no_function_rodata_section): Add the second argument to the
declarations.
* target.def (function_rodata_section): Change the doc and add
the second argument.
* doc/tm.texi: Regenerate.
* varasm.c (jumptable_relocatable): Implement.
(default_function_rodata_section): Add the second argument
and the support for relocatable read only sections.
(default_no_function_rodata_section): Add the second argument.
(function_mergeable_rodata_prefix): Set the second argument to false.
* config/mips/mips.c (mips_function_rodata_section): Add the second
arugment and set it to false.
* config/s390/s390.c (targetm.asm_out.function_rodata_section): Set
the second argument to false.
* config/s390/s390.md: Likewise.

3 years agoSupport variable index vec_set.
liuhongt [Mon, 19 Oct 2020 08:04:39 +0000 (16:04 +0800)] 
Support variable index vec_set.

gcc/ChangeLog:

PR target/97194
* config/i386/i386-expand.c (ix86_expand_vector_set_var): New function.
* config/i386/i386-protos.h (ix86_expand_vector_set_var): New Decl.
* config/i386/predicates.md (vec_setm_operand): New predicate,
true for const_int_operand or register_operand under TARGET_AVX2.
* config/i386/sse.md (vec_set<mode>): Support both constant
and variable index vec_set.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx2-vec-set-1.c: New test.
* gcc.target/i386/avx2-vec-set-2.c: New test.
* gcc.target/i386/avx512bw-vec-set-1.c: New test.
* gcc.target/i386/avx512bw-vec-set-2.c: New test.
* gcc.target/i386/avx512f-vec-set-2.c: New test.
* gcc.target/i386/avx512vl-vec-set-2.c: New test.

3 years agoPR middle-end/97840 - Bogus -Wmaybe-uninitialized passing an empty object to a function
Martin Sebor [Tue, 17 Nov 2020 03:01:10 +0000 (20:01 -0700)] 
PR middle-end/97840 - Bogus -Wmaybe-uninitialized passing an empty object to a function

gcc/ChangeLog:
* tree-ssa-uninit.c (maybe_warn_operand): Call is_empty_type.
* tree.c (default_is_empty_type): Rename...
(is_empty_type): ...to this.
* tree.h (is_empty_type): Declare.

3 years agoPR middle-end/95673 - missing -Wstring-compare for an impossible strncmp test
Martin Sebor [Tue, 17 Nov 2020 02:47:39 +0000 (19:47 -0700)] 
PR middle-end/95673 - missing -Wstring-compare for an impossible strncmp test

gcc/ChangeLog:

PR middle-end/95673
* tree-ssa-strlen.c (used_only_for_zero_equality): Rename...
(use_in_zero_equality): ...to this.  Add a default argument.
(handle_builtin_memcmp): Adjust to the name change above.
(handle_builtin_string_cmp): Same.
(maybe_warn_pointless_strcmp): Same.  Pass in an explicit argument.

gcc/testsuite/ChangeLog:

PR middle-end/95673
* gcc.dg/Wstring-compare-3.c: New test.

3 years agofloat.h: C2x decimal signaling NaN macros
Joseph Myers [Tue, 17 Nov 2020 00:27:06 +0000 (00:27 +0000)] 
float.h: C2x decimal signaling NaN macros

C2x adds macros for decimal floating-point signaling NaNs to
<float.h>.  Add these macros to GCC's <float.h> implementation.

Note that the current C2x draft has these under incorrect names
D32_SNAN, D64_SNAN, D128_SNAN.  The intent was to change the naming
convention to be consistent with other <float.h> macros when they were
moved to <float.h>, so DEC32_SNAN, DEC64_SNAN, DEC128_NAN, which this
patch uses (as does the current draft integration of TS 18661-3 as an
Annex to C2x, for its _Decimal* and _Decimal*x types).

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

* ginclude/float.h (DEC32_SNAN, DEC64_SNAN, DEC128_SNAN): New C2x
macros.

gcc/testsuite/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

* gcc.dg/dfp/c2x-float-dfp-7.c, gcc.dg/dfp/c2x-float-dfp-8.c: New
tests.
* gcc.dg/c2x-float-no-dfp-3.c: Also check that DEC32_SNAN,
DEC64_SNAN and DEC128_SNAN are not defined.

3 years agofloat.h: C2x NaN and Inf macros
Joseph Myers [Tue, 17 Nov 2020 00:25:12 +0000 (00:25 +0000)] 
float.h: C2x NaN and Inf macros

C2x adds macros for NaNs and infinities to <float.h>, some of them
previously in <math.h> (and some still in <math.h> as well in C2x as
an obsolescent feature).  Add these macros to GCC's <float.h>
implementation.

This omits the macros for DFP signaling NaNs, leaving those to be
added in a separate patch.  However, it includes the _FloatN /
_FloatNx macros (conditional on __STDC_WANT_IEC_60559_TYPES_EXT__) in
the current draft version of the integration of TS 18661-3 into C2x as
an Annex.

As GCC allows duplicate macro definitions with different expansions in
system headers, it should be OK if <math.h> defines INFINITY or NAN
with a slightly different expansion (e.g. different choice of whether
there is whitespace between tokens); tests are added including
<float.h> and <math.h> in either order.  Because <float.h> uses #undef
on all macros before defining them, even with -Wsystem-headers there
could only ever be issues when <math.h> is included after <float.h>.

Bootstrapped with no regressions on x86_64-pc-linux-gnu.

gcc/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

* ginclude/float.h (INFINITY, NAN, FLT_SNAN, DBL_SNAN, LDBL_SNAN)
(FLT16_SNAN, FLT32_SNAN, FLT64_SNAN, FLT128_SNAN, FLT32X_SNAN)
(FLT64X_SNAN, FLT128X_SNAN, DEC_INFINITY, DEC_NAN): New C2x
macros.
* doc/sourcebuild.texi (Effective-Target Keywords): Document inff.

gcc/testsuite/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

* lib/target-supports.exp (check_effective_target_inff): New.
* gcc.dg/c11-float-4.c, gcc.dg/c11-float-5.c,
gcc.dg/c11-float-dfp-2.c, gcc.dg/c2x-float-2.c,
gcc.dg/c2x-float-3.c, gcc.dg/c2x-float-4.c, gcc.dg/c2x-float-5.c,
gcc.dg/c2x-float-6.c, gcc.dg/c2x-float-7.c, gcc.dg/c2x-float-8.c,
gcc.dg/c2x-float-9.c, gcc.dg/c2x-float-no-dfp-3.c,
gcc.dg/c2x-float-no-dfp-4.c, gcc.dg/dfp/c2x-float-dfp-4.c,
gcc.dg/dfp/c2x-float-dfp-5.c, gcc.dg/dfp/c2x-float-dfp-6.c,
gcc.dg/torture/float128-nan-floath.c,
gcc.dg/torture/float128x-nan-floath.c,
gcc.dg/torture/float16-nan-floath.c,
gcc.dg/torture/float32-nan-floath.c,
gcc.dg/torture/float32x-nan-floath.c,
gcc.dg/torture/float64-nan-floath.c,
gcc.dg/torture/float64x-nan-floath.c,
gcc.dg/torture/floatn-nan-floath.h: New tests.

3 years agoDaily bump.
GCC Administrator [Tue, 17 Nov 2020 00:16:27 +0000 (00:16 +0000)] 
Daily bump.

3 years agoUpdate documentation for spec files
Armin Brauns via Gcc-patches [Tue, 17 Nov 2020 00:14:31 +0000 (17:14 -0700)] 
Update documentation for spec files

gcc
* gcc.c: Document %T spec file directive.
* doc/invoke.texi: Remove %p, %P spec file directives.
Add %M, %R, %V, %nSTR, %>S, %<S*, %{%:function(args):X}, %@{...} spec
file directives add sanitize, version-compare, include, gt and
debug-level-gt spec functions.

3 years ago[RS6000] Use LIB2_SIDITI_CONV_FUNCS in place of ppc64-fp.c
Alan Modra [Tue, 10 Nov 2020 11:15:58 +0000 (21:45 +1030)] 
[RS6000] Use LIB2_SIDITI_CONV_FUNCS in place of ppc64-fp.c

This patch retires ppc64-fp.c in favour of using
"LIB2_SIDITI_CONV_FUNCS = yes", which is a lot better solution than
having a copy of selected libgcc2.c functions.

* config/rs6000/t-ppc64-fp (LIB2ADD): Delete.
(LIB2_SIDITI_CONV_FUNCS): Define.
* config/rs6000/ppc64-fp.c: Delete file.

3 years agoImprove code generation for x86_64 [PR 92180]
Roger Sayle [Mon, 16 Nov 2020 23:55:29 +0000 (16:55 -0700)] 
Improve code generation for x86_64 [PR 92180]

This patch catches a missed optimization opportunity where GCC currently
generates worse code than LLVM.  The issue, as nicely analyzed in bugzilla,
boils down to the following three insns in combine:

(insn 6 5 7 2 (parallel [
            (set (reg:DI 85)
                (ashift:DI (reg:DI 85)
                    (const_int 32 [0x20])))
            (clobber (reg:CC 17 flags))
        ]) "pr92180.c":4:10 564 {*ashldi3_1}
     (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))
(insn 7 6 14 2 (parallel [
            (set (reg:DI 84)
                (ior:DI (reg:DI 84)
                    (reg:DI 85)))
            (clobber (reg:CC 17 flags))
        ]) "pr92180.c":4:10 454 {*iordi_1}
     (expr_list:REG_DEAD (reg:DI 85)
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))
(insn 14 7 15 2 (set (reg/i:SI 0 ax)
        (subreg:SI (reg:DI 84) 0)) "pr92180.c":5:1 67 {*movsi_internal}
     (expr_list:REG_DEAD (reg:DI 84)
        (nil)))

Normally, combine/simplify-rtx would notice that insns 6 and 7
(which update highpart bits) are unnecessary as the final insn 14
only requires to lowpart bits.  The complication is that insn 14
sets a hard register in targetm.class_likely_spilled_p which
prevents combine from performing its simplifications, and removing
the redundant instructions.

At first glance a fix would appear to require changes to combine,
potentially affecting code generation on all small register class
targets...  An alternate (and I think clever) solution is to spot
that this problematic situation can be avoided by the backend.

At RTL expansion time, the middle-end has a clear separation between
pseudos and hard registers, so the RTL initially contains:

(insn 9 8 10 2 (set (reg:SI 86)
        (subreg:SI (reg:DI 82 [ _1 ]) 0)) "pr92180.c":6:10 -1
     (nil))
(insn 10 9 14 2 (set (reg:SI 83 [ <retval> ])
        (reg:SI 86)) "pr92180.c":6:10 -1
     (nil))
(insn 14 10 15 2 (set (reg/i:SI 0 ax)
        (reg:SI 83 [ <retval> ])) "pr92180.c":7:1 -1
     (nil))

which can be optimized without problems by combine; it is only the
intervening passes (initially fwprop1) that propagate computations
into sets of hard registers, and disable those opportunities.

The solution proposed here is to have the x86 backend/recog prevent
early RTL passes composing instructions (that set likely_spilled hard
registers) that they (combine) can't simplify, until after reload.
We allow sets from pseudo registers, immediate constants and memory
accesses, but anything more complicated is performed via a temporary
pseudo.  Not only does this simplify things for the register allocator,
but any remaining register-to-register moves are easily cleaned up
by the late optimization passes after reload, such as peephole2 and
cprop_hardreg.

This patch has been tested on x86_64-pc-linux-gnu with a
"make bootstrap" and a "make -k check" with no new failures.
Ok for mainline?

gcc
PR rtl-optimization/92180
* config/i386/i386.c (ix86_hardreg_mov_ok): New function to
determine whether (set DST SRC) should be allowed at this point.
* config/i386/i386-protos.h (ix86_hardreg_mov_ok): Prototype here.
* config/i386/i386-expand.c (ix86_expand_move): Check whether
this is a complex set of a likely spilled hard register, and if
so place the value in a pseudo, and load the hard reg from it.
* config/i386/i386.md (*movdi_internal, *movsi_internal)
(*movhi_internal, *movqi_internal): Make these instructions
conditional on ix86_hardreg_mov_ok.
(*lea<mode>): Make this define_insn_and_split conditional on
ix86_hardreg_mov_ok.

gcc/testsuite
PR rtl-optimization/92180
* gcc.target/i386/pr92180.c: New test.

3 years agoC-family : Fix a C++ ODR violation [PR97854].
Iain Sandoe [Mon, 16 Nov 2020 19:33:35 +0000 (19:33 +0000)] 
C-family : Fix a C++ ODR violation [PR97854].

The changes in r11-4799 introduced a dummy enum rid type with
a different initial member name to the actual version (an ODR
violation).  Fixed by including the header declaring the
actual type.

gcc/c-family/ChangeLog:

PR objc/97854
* stub-objc.c: Include c-common.h to declare enum rid.

3 years agoPR fortran/48958 - Add runtime diagnostics for SIZE intrinsic function
Harald Anlauf [Mon, 16 Nov 2020 21:00:58 +0000 (22:00 +0100)] 
PR fortran/48958 - Add runtime diagnostics for SIZE intrinsic function

Add code for runtime checking of status of ALLOCATABLE and POINTER
arguments to the SIZE intrinsic when -fcheck=pointer is specified.

gcc/fortran/ChangeLog:

* trans-intrinsic.c (gfc_conv_intrinsic_size): Generate runtime
checking code for status of argument.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr48958.f90: New test.

3 years agoparam: Add missing dot for param description.
Martin Liska [Mon, 16 Nov 2020 19:43:31 +0000 (20:43 +0100)] 
param: Add missing dot for param description.

gcc/ChangeLog:

* params.opt: Add missing dot.

3 years agomklog: support unidiff 0.5.4
Martin Liska [Mon, 16 Nov 2020 19:26:28 +0000 (20:26 +0100)] 
mklog: support unidiff 0.5.4

contrib/ChangeLog:

* mklog.py: Do not call read on an input stream.
Fix some flake8 issues.

3 years agoIPA tracking of EAF flags in ipa-modref.
Jan Hubicka [Mon, 16 Nov 2020 18:30:45 +0000 (19:30 +0100)] 
IPA tracking of EAF flags in ipa-modref.

this patch implements the IPA propagation part of EAF flags handling in
ipa-modref.  It extends the local analysis to collect lattice consisting of
flags and escape points.  SSA name escapes if it is passed directly or
indirectly to a function call.

If useful flags are found for parameter its escape list is stored into escape
summaries.  This time each call site is annotated with info on which function
parameters escape to what argument of function call.

At IPA time we then perform iterative dataflow and produce final flags.
ipa-modref is still cheaper than pure-const when running on cc1plus (about 2-3%
that is what accounts every non-trivial passs) and the dataflow converges in 1
or 2 iterations.

Local analysis does some work to avoid streaming escape points when they are
not useful to determine final flags (that is, local escape analysis determined
good enough flags). For cc1plus there are 225k calls with useful escape
summary.

* ipa-modref.c (escape_point): New type.
(modref_lattice): New type.
(escape_entry): New type.
(escape_summary): New type.
(escape_summaries_t): New type.
(escape_summaries): New static variable.
(eaf_flags_useful_p): New function.
(modref_summary::useful_p): Add new check_flags
attribute; check eaf_flags for usefulness.
(modref_summary_lto): Add arg_flags.
(modref_summary_lto::useful_p): Add new check_flags
attribute; check eaf_flags for usefulness.
(dump_modref_edge_summaries): New function.
(remove_modref_edge_summaries): New function.
(ignore_retval_p): New predicate.
(ignore_stores_p): Also ignore for const.
(remove_summary): Call remove_modref_edge_summaries.
(modref_lattice::init): New member function.
(modref_lattice::release): New member unction.
(modref_lattice::dump): New member function.
(modref_lattice::add_escape_point): New member function.
(modref_lattice::merge): Two new member functions.
(modref_lattice::merge_deref): New member functions.
(modref_lattice::merge_direct_load): New member function.
(modref_lattice::merge_direct_store): New member function.
(call_lhs_flags): Rename to ...
(merge_call_lhs_flags): ... this one; reimplement using
modreflattice.
(analyze_ssa_name_flags): Replace KNOWN_FLAGS param by LATTICE;
add IPA parametr; use modref_lattice.
(analyze_parms): New parameter IPA and SUMMARY_LTO; update for
modref_lattice; initialize escape_summary.
(analyze_function): Allocate escape_summaries; update uses of useful_p.
(modref_write_escape_summary): New function.
(modref_read_escape_summary): New function.
(modref_write): Write escape summary.
(read_section): Read escape summary.
(modref_read): Initialie escape_summaries.
(remap_arg_flags): New function.
(update_signature): Use it.
(escape_map): New structure.
(update_escape_summary_1, update_escape_summary): New functions.
(ipa_merge_modref_summary_after_inlining): Merge escape summaries.
(propagate_unknown_call): Do not remove useless summaries.
(remove_useless_summaries): Remove them here.
(modref_propagate_in_scc): Update; do not dump scc.
(modref_propagate_dump_scc): New function.
(modref_merge_call_site_flags): New function.
(modref_propagate_flags_in_scc): New function.
(pass_ipa_modref::execute): Use modref_propagate_flags_in_scc
and modref_propagate_dump_scc; delete escape_summaries.
(ipa_modref_c_finalize):  Remove escape_summaries.
* ipa-modref.h (modref_summary): Update prototype of useful_p.
* params.opt (param=modref-max-escape-points): New param.
* doc/invoke.texi (modref-max-escape-points): Document.

3 years agoDisable some bogus -Wmaybe-uninitialized warnings
Jan Hubicka [Mon, 16 Nov 2020 15:31:30 +0000 (16:31 +0100)] 
Disable some bogus -Wmaybe-uninitialized warnings

gcc/ChangeLog:
PR middle-end/97840
* ipa-modref.c (analyze_ssa_name_flags): Skip clobbers if inlining
is done.
* tree-ssa-uninit.c (maybe_warn_pass_by_reference): Make stmt gcall;
skip const calls and unused arguments.
(warn_uninitialized_vars): Update prototype.

gcc/testsuite/ChangeLog:
* g++.dg/warn/uninit-1.C: New test.

3 years agoDelay SLP instance loads gathering
Richard Biener [Mon, 16 Nov 2020 13:26:20 +0000 (14:26 +0100)] 
Delay SLP instance loads gathering

This delays filling SLP_INSTANCE_LOADS.

2020-11-16  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (vect_gather_slp_loads): Declare.
* tree-vect-loop.c (vect_analyze_loop_2): Call
vect_gather_slp_loads.
* tree-vect-slp.c (vect_build_slp_instance): Do not gather
SLP loads here.
(vect_gather_slp_loads): Remove wrapper, new function.
(vect_slp_analyze_bb_1): Call it.

3 years agofurther optimize non-store-motion LIM
Richard Biener [Mon, 16 Nov 2020 13:25:56 +0000 (14:25 +0100)] 
further optimize non-store-motion LIM

This removes useless work from LIM when store-motion is disabled.

2020-11-16   Richard Biener  <rguenther@suse.de>

* tree-ssa-loop-im.c (analyze_memory_references): Add
store_motion parameter and elide unnecessary work.
(tree_ssa_lim_initialize): Likewise.
(loop_invariant_motion_in_fun): Pass down store_motion.

3 years agoIBM Z: Do not run long double tests on old machines
Ilya Leoshkevich [Thu, 12 Nov 2020 14:32:04 +0000 (15:32 +0100)] 
IBM Z: Do not run long double tests on old machines

gcc/testsuite/ChangeLog:

2020-11-12  Ilya Leoshkevich  <iii@linux.ibm.com>

* gcc.target/s390/s390.exp (check_effective_target_s390_z14_hw):
New predicate.
* gcc.target/s390/vector/long-double-caller-abi-run.c: Use the
new predicate.
* gcc.target/s390/vector/long-double-copysign.c: Likewise.
* gcc.target/s390/vector/long-double-from-double.c: Likewise.
* gcc.target/s390/vector/long-double-from-float.c: Likewise.
* gcc.target/s390/vector/long-double-from-i16.c: Likewise.
* gcc.target/s390/vector/long-double-from-i32.c: Likewise.
* gcc.target/s390/vector/long-double-from-i64.c: Likewise.
* gcc.target/s390/vector/long-double-from-i8.c: Likewise.
* gcc.target/s390/vector/long-double-from-u16.c: Likewise.
* gcc.target/s390/vector/long-double-from-u32.c: Likewise.
* gcc.target/s390/vector/long-double-from-u64.c: Likewise.
* gcc.target/s390/vector/long-double-from-u8.c: Likewise.
* gcc.target/s390/vector/long-double-to-double.c: Likewise.
* gcc.target/s390/vector/long-double-to-float.c: Likewise.
* gcc.target/s390/vector/long-double-to-i16.c: Likewise.
* gcc.target/s390/vector/long-double-to-i32.c: Likewise.
* gcc.target/s390/vector/long-double-to-i64.c: Likewise.
* gcc.target/s390/vector/long-double-to-i8.c: Likewise.
* gcc.target/s390/vector/long-double-to-u16.c: Likewise.
* gcc.target/s390/vector/long-double-to-u32.c: Likewise.
* gcc.target/s390/vector/long-double-to-u64.c: Likewise.
* gcc.target/s390/vector/long-double-to-u8.c: Likewise.
* gcc.target/s390/vector/long-double-wfaxb.c: Likewise.
* gcc.target/s390/vector/long-double-wfdxb.c: Likewise.
* gcc.target/s390/vector/long-double-wfsxb-1.c: Likewise.

3 years agomodref: add missing Param Optimization keywords
Martin Liska [Mon, 16 Nov 2020 12:13:40 +0000 (13:13 +0100)] 
modref: add missing Param Optimization keywords

Fixes:

FAIL: compiler driver --help=common option(s): "^ +-.*[^:.]$" absent from output: "  --param=modref-max-depth=   Maximum depth of DFS walk used by modref escape analysis"

gcc/ChangeLog:

* params.opt: All modref parameters miss Optimization and Param
keyword as seen in testsuite failure.

3 years agoFix -param=modref-max-depth in params.opt
Jan Hubicka [Mon, 16 Nov 2020 12:23:16 +0000 (13:23 +0100)] 
Fix -param=modref-max-depth in params.opt

* params.opt (-param=modref-max-depth=): Add missing full stop.

3 years agopointer-compare-1.c: Add __attribute__((used))
H.J. Lu [Wed, 11 Nov 2020 23:54:00 +0000 (15:54 -0800)] 
pointer-compare-1.c: Add __attribute__((used))

c-c++-common/asan/pointer-compare-1.c assumes the certain order for
variable placement.  Add __attribute__((used)) to avoid variable
placement changes due to SHF_GNU_RETAIN.

PR testsuite/97803
* c-c++-common/asan/pointer-compare-1.c (global1): Add
__attribute__((used))
(global2): Likewise.
(small_global): Likewise.
(large_global): Likewise.

3 years agolibstdc++: Fix error shown during Solaris build
Jonathan Wakely [Fri, 13 Nov 2020 19:11:02 +0000 (19:11 +0000)] 
libstdc++: Fix error shown during Solaris build

Currently this is shown when building libstdc++ on Solaris:

-lrt: open: No such file or directory

The error comes from the make_sunver.pl script which tries to open each
of its arguments. The arguments are passed by this make rule:

perl ${glibcxx_srcdir}/scripts/make_exports.pl \
  libstdc++-symbols.ver \
  $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
 `echo $(libstdc___la_LIBADD) | \
    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
 > $@ || (rm -f $@ ; exit 1)

The $(libstdc___la_LIBADD) variable includes $(GLIBCXX_LIBS) which
contains -lrt on Solaris.

This patch adds another sed script to filter -l arguments from the echo
command. In order to reliably match ' -l[^ ]* ' the echo arguments are
quoted and a space added before and after them. This might be overkill
just to remove -lrt from the start of the string, but should be robust
in case other -l arguments are added to $(GLIBCXX_LIBS), or in case the
$(libstdc___la_LIBADD) libraries are reordered.

libstdc++-v3/ChangeLog:

* src/Makefile.am (libstdc++-symbols.ver-sun): Remove -lrt from
arguments passed to make_sunver.pl script.
* src/Makefile.in: Regenerate.

3 years agoAdd .cache to git ignore.
Martin Liska [Mon, 16 Nov 2020 11:52:43 +0000 (12:52 +0100)] 
Add .cache to git ignore.

ChangeLog:

* .gitignore: Add cache as clangd uses it now.

3 years agogcov: Add -fprofile-info-section support
Sebastian Huber [Fri, 13 Nov 2020 16:47:40 +0000 (17:47 +0100)] 
gcov: Add -fprofile-info-section support

Register the profile information in the specified section instead of using a
constructor/destructor.  A pointer to the profile information generated by
-fprofile-arcs or -ftest-coverage is placed in the specified section for each
translation unit.  This option disables the profile information registration
through a constructor and it disables the profile information processing
through a destructor.

I am not sure how I can test this option.  One approach would be to assemble a
test file, then scan it and check that a .gcov_info section is present and no
__gcov_init() and __gcov_exit() calls are present.  Is there an example for
this in the test suite?

gcc/

* common.opt (fprofile-info-section): New.
* coverage.c (build_gcov_info_var_registration): New.
(coverage_obj_init): Evaluate profile_info_section and use
build_gcov_info_var_registration().
* doc/invoke.texi (fprofile-info-section): Document.
* opts.c (common_handle_option): Process fprofile-info-section
option.

gcc/testsuite/ChangeLog:

* gcc.dg/profile-info-section.c: New test.

3 years agotree-optimization/97838 - fix SLP leaf detection
Richard Biener [Mon, 16 Nov 2020 08:28:03 +0000 (09:28 +0100)] 
tree-optimization/97838 - fix SLP leaf detection

This properly handles reduction PHI nodes with unrepresented
initial value as leaf in the SLP graph.

2020-11-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97838
* tree-vect-slp.c (vect_slp_build_vertices): Properly handle
not backwards reachable cycles.
(vect_optimize_slp): Check a node is leaf before marking it
visited.

* gcc.dg/vect/pr97838.c: New testcase.

3 years agoPrefer bit-test over the jump table.
Martin Liska [Mon, 9 Nov 2020 13:26:04 +0000 (14:26 +0100)] 
Prefer bit-test over the jump table.

gcc/ChangeLog:

PR tree-optimization/97736
* tree-switch-conversion.c (switch_decision_tree::analyze_switch_statement):
Prefer bit tests.

gcc/testsuite/ChangeLog:

PR tree-optimization/97736
* gcc.dg/tree-ssa/switch-1.c: Prefer bit tests.
* g++.dg/tree-ssa/pr97736.C: New test.

3 years agotree-optimization/97835 - fix step vector construction for SLP induction
Richard Biener [Mon, 16 Nov 2020 08:06:41 +0000 (09:06 +0100)] 
tree-optimization/97835 - fix step vector construction for SLP induction

We're stripping conversions off access functions of inductions and
thus the step can be of different sign.  Fix bogus step CTORs by
converting the elements rather than the whole vector.

2020-11-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97835
* tree-vect-loop.c (vectorizable_induction): Convert step
scalars rather than step vector.

* gcc.dg/vect/pr97835.c: New testcase.

3 years agotree-optimization/97830 - fix compare of incomplete type size in VN
Richard Biener [Mon, 16 Nov 2020 07:40:47 +0000 (08:40 +0100)] 
tree-optimization/97830 - fix compare of incomplete type size in VN

This avoids passing NULL to expressions_equal_p.

2020-11-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97830
* tree-ssa-sccvn.c (vn_reference_eq): Check for incomplete
types before comparing TYPE_SIZE.

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

3 years agoPut PREFETCHW back to march=broadwell
Cui,Lili [Fri, 13 Nov 2020 06:20:31 +0000 (14:20 +0800)] 
Put PREFETCHW back to march=broadwell

PREFETCHW should be both in march=broadwell and march=silvermont.
I move PREFETCHW from march=broadwell to march=silvermont in previous
patch.

gcc/ChangeLog:

* config/i386/i386.h: Add PREFETCHW to march=broadwell.
* doc/invoke.texi: Put PREFETCHW back to relation arch.

3 years agoDaily bump.
GCC Administrator [Mon, 16 Nov 2020 00:16:31 +0000 (00:16 +0000)] 
Daily bump.

3 years agoMSP430: Fix inconsistent naming of hwmult libfuncs
Jozef Lawrynowicz [Sun, 15 Nov 2020 21:03:06 +0000 (21:03 +0000)] 
MSP430: Fix inconsistent naming of hwmult libfuncs

The naming scheme used by GCC to reference MSP430 hardware multiply
library functions is inconsistent.

Sometimes the "GCC" names (e.g. mulsi2) are used, other times the
"MSPABI" names (e.g. __mspabi_mpyl) are used.

Also, sometimes an identifier for the hardware multiply support is
appended to the GCC name, when the functions are defined, but this is
not required.

This patch fixes those issues, so the names used to refer to the
hardware multiply library functions follow a consistent pattern.

gcc/ChangeLog:

* config/msp430/msp430.c (msp430_output_labelref): Don't process mspabi
hwmult library function names into GCC-style names.

libgcc/ChangeLog:

* config/msp430/lib2hw_mul.S: Omit _hw* suffix from GCC names for
hwmult library functions.

gcc/testsuite/ChangeLog:

* gcc.target/msp430/rtx-cost-Os-f5series.c: Adjust test to use new
hwmult library function name.

3 years agoMSP430: Define function to check 16-bit hwmult support
Jozef Lawrynowicz [Sun, 15 Nov 2020 21:02:58 +0000 (21:02 +0000)] 
MSP430: Define function to check 16-bit hwmult support

gcc/ChangeLog:

* config/msp430/msp430.c (msp430_use_16bit_hwmult): New.
(use_32bit_hwmult): Rename to..
(msp430_use_32bit_hwmult): ..this.
(msp430_muldiv_costs): Use msp430_use_16bit_hwmult and
msp430_use_32bit_hwmult.
(msp430_expand_helper): Use msp430_use_16bit_hwmult and
msp430_use_32bit_hwmult.
(msp430_output_labelref): Use msp430_use_32bit_hwmult.

3 years agotestsuite: fix ipa/modref-2.c on ilp32
David Edelsohn [Sun, 15 Nov 2020 19:56:47 +0000 (14:56 -0500)] 
testsuite: fix ipa/modref-2.c on ilp32

ipa/modref-2.c output for Parm 1 depends on the word size.  This patch
updates the testcase to expect the appropriate result for ilp32 and lp64.

gcc/testsuite/ChangeLog:

* gcc.dg/ipa/modref-2.c: Add ilp32 expected result.

3 years agotestsuite: Update scanning symbol sections to support AIX.
David Edelsohn [Sun, 15 Nov 2020 02:10:25 +0000 (21:10 -0500)] 
testsuite: Update scanning symbol sections to support AIX.

gcc/testsuite:

* lib/scanasm.exp (parse_section_of_symbols): Also look for AIX
XCOFF CSECT notation.
* g++.dg/opt/const4.C: Also look for AIX XCOFF "[RO]".
* gcc.dg/20021029-1.c: Likewise.
* gcc.dg/array-quals-1.c: Likewise and "[RW]".
* g++.dg/gomp/tls-5.C: Also look for AIX XCOFF "[TL]".
* gcc.dg/pr25376.c: Accept AIX decoration around named section
and function descriptor.

3 years agoVAX: Use `rtx_code' to hold the RTL expression code in `vax_rtx_costs'
Maciej W. Rozycki [Sun, 15 Nov 2020 17:41:52 +0000 (17:41 +0000)] 
VAX: Use `rtx_code' to hold the RTL expression code in `vax_rtx_costs'

Use `enum rtx_code' rather than `int' to hold the the RTL expression
code in `vax_rtx_costs', matching the type these codes have been defined
with and making debugging just a tiny little bit easier.

gcc/
* config/vax/vax.c (vax_rtx_costs): Use `rtx_code' rather than
`int' for `code'.

3 years agoVAX/testsuite: Fix compilation options for `bswapdi-1.c'
Maciej W. Rozycki [Sun, 15 Nov 2020 17:41:52 +0000 (17:41 +0000)] 
VAX/testsuite: Fix compilation options for `bswapdi-1.c'

Correct a regression in `vax-netbsdelf' gcc testing:

.../gcc/testsuite/gcc.target/vax/bswapdi-1.c: In function '__bswapdi2':
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:5:19: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:6:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:7:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:8:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:9:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:10:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:11:14: error: use of C99 long long integer constant [-Wlong-long]
.../gcc/testsuite/gcc.target/vax/bswapdi-1.c:12:14: error: use of C99 long long integer constant [-Wlong-long]
compiler exited with status 1
FAIL: gcc.target/vax/bswapdi-1.c (test for excess errors)

which is due to the defaults from `vax.exp':

# If a testcase doesn't have special options, use these.
global DEFAULT_CFLAGS
if ![info exists DEFAULT_CFLAGS] then {
    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
}

Use an empty override then as the options used do not matter for the
objective of this test case.

gcc/testsuite/
* gcc.target/vax/bswapdi-1.c (dg-options): New setting.

3 years agoVAX: Fix a typo in NO_EXTERNAL_INDIRECT_ADDRESS
Maciej W. Rozycki [Sun, 15 Nov 2020 17:41:52 +0000 (17:41 +0000)] 
VAX: Fix a typo in NO_EXTERNAL_INDIRECT_ADDRESS

Fix a typo in a NO_EXTERNAL_INDIRECT_ADDRESS macro check around an
assertion verifying DImode addition operands to be valid for PIC.

gcc/
* config/vax/vax.c (vax_output_int_add) <E_DImode>: Fix a typo
in NO_EXTERNAL_INDIRECT_ADDRESS.

3 years agoVAX: Correct a typo in PIC symbolic addition operand checks
Maciej W. Rozycki [Sun, 15 Nov 2020 17:41:52 +0000 (17:41 +0000)] 
VAX: Correct a typo in PIC symbolic addition operand checks

Fix a typo and check both SImode addition operands for being incorrectly
symbolic in PIC mode before issuing a diagnostic dump of the offending
RTL expression.

gcc/
* config/vax/vax.c (vax_output_int_add) <E_SImode>: Also check
`operands[2]' for being symbolic with PIC rather than checking
`operands[1]' twice.

3 years agoc++: Check abstract type only on object creation. [PR86252]
Jason Merrill [Fri, 13 Nov 2020 21:33:50 +0000 (16:33 -0500)] 
c++: Check abstract type only on object creation. [PR86252]

Abstract checking has been problematic for a while; when I implemented an
earlier issue resolution to do more checking it led to undesirable
instantiations, and so backed some of it out.  During the C++20 process we
decided with P0929R2 that we should go the other way, and only check
abstractness when we're actually creating an object, not when merely forming
an array or function type.  This means that we can remove the machinery for
checking whether a newly complete class makes some earlier declaration
ill-formed.  This change was moved as a DR, so I'm applying it to all
standard levels.  This could be reconsidered if it causes problems, but I
don't expect it to.

The change to the libstdc++ result_of test brings the expected behavior in
line with that for incomplete types, but as in PR97841 I think the libstdc++
handling of incomplete types in this and other type_traits is itself wrong,
so I expect these lines and others to change again before long.

gcc/cp/ChangeLog:

* decl.c (cp_finish_decl): Only check abstractness on definition.
(require_complete_types_for_parms): Check abstractness here.
(create_array_type_for_decl): Not here.
(grokdeclarator, grokparms, complete_vars): Not here.
* pt.c (tsubst, tsubst_arg_types, tsubst_function_type): Not here.
* typeck2.c (struct pending_abstract_type): Remove.
(struct abstract_type_hasher): Remove.
(abstract_pending_vars, complete_type_check_abstract): Remove.
(abstract_virtuals_error_sfinae): Handle arrays.
* call.c (conv_is_prvalue): Split out from...
(conv_binds_ref_to_prvalue): ...here.
(implicit_conversion_1): Rename from implicit_conversion.
(implicit_conversion): An abstract prvalue is bad.
(convert_like_internal): Don't complain if expr is already
error_mark_node.

gcc/testsuite/ChangeLog:

* g++.dg/other/abstract1.C: Adjust.
* g++.dg/other/abstract2.C: Adjust.
* g++.dg/other/abstract4.C: Adjust.
* g++.dg/other/abstract5.C: Adjust.
* g++.dg/other/abstract8.C: New test.
* g++.dg/template/sfinae-dr657.C: Adjust.
* g++.old-deja/g++.other/decl3.C: Adjust.

libstdc++-v3/ChangeLog:

* testsuite/20_util/result_of/sfinae_friendly_1.cc: Adjust.