gcc.git
3 years agomake svp64 mutually exclusive with vsx and altivec lxo/WIP-svp64-gcc
Alexandre Oliva [Mon, 22 Feb 2021 01:50:12 +0000 (22:50 -0300)]
make svp64 mutually exclusive with vsx and altivec

3 years agointroduce -msvp64 for libre-soc vector extensions
Alexandre Oliva [Tue, 2 Feb 2021 03:31:44 +0000 (00:31 -0300)]
introduce -msvp64 for libre-soc vector extensions

3 years agoprepare EH machinery for reg renumbering
Alexandre Oliva [Sat, 20 Feb 2021 17:07:48 +0000 (14:07 -0300)]
prepare EH machinery for reg renumbering

3 years agoprepare to renumber ppc fp and vec regs
Alexandre Oliva [Tue, 2 Feb 2021 03:31:40 +0000 (00:31 -0300)]
prepare to renumber ppc fp and vec regs

3 years agolibiberty: autogenerate aclocal.m4
Mike Frysinger [Sun, 14 Feb 2021 02:25:28 +0000 (21:25 -0500)]
libiberty: autogenerate aclocal.m4

Move custom macros to acinclude.m4 so we can autogenerate aclocal.m4
with aclocal.  This matches every other project in the tree.

libiberty/ChangeLog:

* Makefile.in (ACLOCAL, ACLOCAL_AMFLAGS, $(srcdir)/aclocal.m4): Define.
(configure_deps): Rename to ...
(aclocal_deps): ... this.  Replace aclocal.m4 with acinclude.m4.
($(srcdir)/configure): Replace $(configure_deps) with
$(srcdir)/aclocal.m4.
* aclocal.m4: Move libiberty macros to acinclude.m4, then regenerate.
* acinclude.m4: New file.
* configure: Regenerate.

3 years agotestsuite: skip attr-retain-?.c on AIX
David Edelsohn [Fri, 19 Feb 2021 23:38:18 +0000 (18:38 -0500)]
testsuite: skip attr-retain-?.c on AIX

The attr-retain-?.c tests assume ELF file syntax / semantics.  Some of the
tests skip AIX because of other requirements, and some explicitly skip
Darwin.  This patch adds AIX to the explicit skip list.

gcc/testsuite/ChangeLog:

* c-c++-common/attr-retain-5.c: Skip on AIX.
* c-c++-common/attr-retain-6.c: Same.
* c-c++-common/attr-retain-7.c: Same.
* c-c++-common/attr-retain-8.c: Same.
* c-c++-common/attr-retain-9.c: Same.

3 years agoIBM Z: Fix long double <-> DFP conversions
Ilya Leoshkevich [Wed, 17 Feb 2021 13:40:03 +0000 (14:40 +0100)]
IBM Z: Fix long double <-> DFP conversions

When switching the s390 backend to store long doubles in vector
registers, the patterns for long double <-> DFP conversions were
forgotten.  This did not cause observable problems so far, because
libdfp calls are emitted instead of pfpo.  However, when building
libdfp itself, this leads to infinite recursion.

gcc/ChangeLog:

PR target/99134
* config/s390/vector.md (trunctf<DFP_ALL:mode>2_vr): New
pattern.
(trunctf<DFP_ALL:mode>2): Likewise.
(trunctdtf2_vr): Likewise.
(trunctdtf2): Likewise.
(extend<DFP_ALL:mode>tf2_vr): Likewise.
(extend<DFP_ALL:mode>tf2): Likewise.
(extendtftd2_vr): Likewise.
(extendtftd2): Likewise.

gcc/testsuite/ChangeLog:

PR target/99134
* gcc.target/s390/vector/long-double-from-decimal128.c: New test.
* gcc.target/s390/vector/long-double-from-decimal32.c: New test.
* gcc.target/s390/vector/long-double-from-decimal64.c: New test.
* gcc.target/s390/vector/long-double-to-decimal128.c: New test.
* gcc.target/s390/vector/long-double-to-decimal32.c: New test.
* gcc.target/s390/vector/long-double-to-decimal64.c: New test.

3 years agoIBM Z: Improve FPRX2 <-> TF conversions
Ilya Leoshkevich [Wed, 17 Feb 2021 15:15:42 +0000 (16:15 +0100)]
IBM Z: Improve FPRX2 <-> TF conversions

gcc/ChangeLog:

* config/s390/vector.md (*fprx2_to_tf): Rename to fprx2_to_tf,
add memory alternative.
(tf_to_fprx2): New pattern.

3 years agoDaily bump.
GCC Administrator [Sat, 20 Feb 2021 00:16:26 +0000 (00:16 +0000)]
Daily bump.

3 years agoc++: Incorrect module-number ordering [PR 98741]
Nathan Sidwell [Fri, 19 Feb 2021 21:10:27 +0000 (13:10 -0800)]
c++: Incorrect module-number ordering [PR 98741]

One of the very strong invariants in modules is that module numbers
are allocated such that (other than the current TU), all imports have
lesser module numbers, and also that the binding vector is only
appended to with increasing module numbers.   This broke down when
module-directives became a thing and the preprocessing became entirely
decoupled from parsing.  We'd load header units and their macros (but
not symbols of course) during preprocessing.  Then we'd load named
modules during parsing.  This could lead to the situation where a
header unit appearing after a named import had a lower module number
than the import.  Consequently, if they both bound the same
identifier, the binding vector would be misorderd and bad things
happen.

This patch restores a pending import queue I previously had, but in
simpler form (hurrah).  During preprocessing we queue all
module-directives and when we meet one for a header unit we do the
minimal loading for all of the queue, so they get appropriate
numbering.  Then we load the preprocessor state for the header unit.

PR c++/98741
gcc/cp/
* module.cc (pending_imports): New.
(declare_module): Adjust test condition.
(name_pending_imports): New.
(preprocess_module): Reimplement using pending_imports.
(preprocessed_module): Move name-getting to name_pending_imports.
* name-lookup.c (append_imported_binding_slot): Assert module
ordering is increasing.
gcc/testsuite/
* g++.dg/modules/pr98741_a.H: New.
* g++.dg/modules/pr98741_b.H: New.
* g++.dg/modules/pr98741_c.C: New.
* g++.dg/modules/pr98741_d.C: New.

3 years agofortran: Object types should be declared before use in NAMELIST.
Jerry DeLisle [Fri, 19 Feb 2021 20:47:54 +0000 (12:47 -0800)]
fortran: Object types should be declared before use in NAMELIST.

gcc/fortran/ChangeLog:

PR fortran/98686
* match.c (gfc_match_namelist): If BT_UNKNOWN, check for
IMPLICIT NONE and and issue an error, otherwise set the type
to its IMPLICIT type so that any subsequent use of objects will
will confirm their types.

gcc/testsuite/ChangeLog:

PR fortran/98686
* gfortran.dg/namelist_4.f90: Modify.
* gfortran.dg/namelist_98.f90: New test.

3 years agoUpdate gcc fr.po.
Joseph Myers [Fri, 19 Feb 2021 20:45:43 +0000 (20:45 +0000)]
Update gcc fr.po.

* fr.po: Update.

3 years agolibgo: update to Go1.16 release
Ian Lance Taylor [Fri, 19 Feb 2021 02:54:38 +0000 (18:54 -0800)]
libgo: update to Go1.16 release

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

3 years agoPR fortran/99147 - Sanitizer detects heap-use-after-free in gfc_add_flavor
Harald Anlauf [Fri, 19 Feb 2021 19:21:27 +0000 (20:21 +0100)]
PR fortran/99147 - Sanitizer detects heap-use-after-free in gfc_add_flavor

Reverse order of conditions to avoid invalid read.

gcc/fortran/ChangeLog:

* symbol.c (gfc_add_flavor): Reverse order of conditions.

3 years agoUpdate .po files.
Joseph Myers [Fri, 19 Feb 2021 18:23:36 +0000 (18:23 +0000)]
Update .po files.

gcc/po/
* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
ja.po, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po,
zh_TW.po: Update.

libcpp/po/
* be.po, ca.po, da.po, de.po, el.po, eo.po, es.po, fi.po, fr.po,
id.po, ja.po, nl.po, pt_BR.po, ru.po, sr.po, sv.po, tr.po, uk.po,
vi.po, zh_CN.po, zh_TW.po: Update.

3 years agoPR c/97172 - ICE: tree code 'ssa_name' is not supported in LTO streams
Martin Sebor [Fri, 19 Feb 2021 18:06:06 +0000 (11:06 -0700)]
PR c/97172 - ICE: tree code 'ssa_name' is not supported in LTO streams

gcc/ChangeLog:

PR c/97172
* attribs.c (init_attr_rdwr_indices): Guard vblist use.
(attr_access::free_lang_data): Remove a spurious test.

gcc/testsuite/ChangeLog:

PR c/97172
* gcc.dg/pr97172.c: Add test cases.

3 years agoc++: Inform of CMI reads [PR 99166]
Nathan Sidwell [Fri, 19 Feb 2021 17:18:13 +0000 (09:18 -0800)]
c++: Inform of CMI reads [PR 99166]

When successfully reading a module CMI, the user gets no indication of
where that CMI was located.  I originally didn't consider this a
problem -- the read was successful after all.  But it can make it
difficult to interact with build systems, particularly when caching
can be involved.  Grovelling over internal dump files is not really
useful to the user.  Hence this option, which is similar to the
-flang-info-include-translate variants, and allows the user to ask for
all, or specific module read notification.

gcc/c-family/
* c.opt (flang-info-module-read, flang-info-module-read=): New.
gcc/
* doc/invoke.texi (flang-info-module-read): Document.
gcc/cp/
* module.cc (note_cmis): New.
(struct module_state): Add inform_read_p bit.
(module_state::do_import): Inform of CMI location, if enabled.
(init_modules): Canonicalize note_cmis entries.
(handle_module_option): Handle -flang-info-module-read=FOO.
gcc/testsuite/
* g++.dg/modules/pr99166_a.X: New.
* g++.dg/modules/pr99166_b.C: New.
* g++.dg/modules/pr99166_c.C: New.
* g++.dg/modules/pr99166_d.C: New.

3 years agoFortran: Fix coarray handling for gfc_dep_resolver [PR99010]
Tobias Burnus [Fri, 19 Feb 2021 17:07:26 +0000 (18:07 +0100)]
Fortran: Fix coarray handling for gfc_dep_resolver [PR99010]

Check failed if identical = false was requested or for -fcoarray=single
if an array ref was for a coindexed scalar.

gcc/fortran/ChangeLog:

PR fortran/99010
* dependency.c (gfc_dep_resolver): Fix coarray handling.

gcc/testsuite/ChangeLog:

PR fortran/99010
* gfortran.dg/coarray/array_temporary-1.f90: New test.

3 years agoFortran: Fix DTIO with type ICE [PR99146]
Tobias Burnus [Fri, 19 Feb 2021 17:05:31 +0000 (18:05 +0100)]
Fortran: Fix DTIO with type ICE [PR99146]

gcc/fortran/ChangeLog:

PR fortran/99146
* interface.c:

gcc/testsuite/ChangeLog:

PR fortran/99146
* gfortran.dg/dtio_36.f90: New test.

3 years agoFix typo in param description.
Martin Liska [Fri, 19 Feb 2021 16:29:23 +0000 (17:29 +0100)]
Fix typo in param description.

gcc/ChangeLog:

PR translation/99167
* params.opt: Fix typo.

3 years agomiddle-end/99122 - more VLA inlining fixes
Richard Biener [Fri, 19 Feb 2021 08:38:52 +0000 (09:38 +0100)]
middle-end/99122 - more VLA inlining fixes

This avoids declaring a function with VLA arguments or return values
as inlineable.  IPA CP still ICEs, so the testcase has that disabled.

2021-02-19  Richard Biener  <rguenther@suse.de>

PR middle-end/99122
* tree-inline.c (inline_forbidden_p): Do not inline functions
with VLA arguments or return value.

* gcc.dg/pr99122-3.c: New testcase.

3 years agoarm: Fix ICE with -fstack-protector -mpure-code [PR98998]
Jakub Jelinek [Fri, 19 Feb 2021 12:05:47 +0000 (13:05 +0100)]
arm: Fix ICE with -fstack-protector -mpure-code [PR98998]

The vla15.C testcase ICEs with
-mcpu=cortex-m1 -mpure-code -fstack-protector -mthumb
as what force_const_mem returns (a SYMBOL_REF) is not a valid
memory address.
Previously the code was moving the address of the force_const_mem
into a register rather than the content of that MEM, so that instruction
must have been supported and loading from a MEM with a single REG base ought
to be valid too.

2021-02-19  Jakub Jelinek  <jakub@redhat.com>

PR target/98998
* config/arm/arm.md (*stack_protect_combined_set_insn,
*stack_protect_combined_test_insn): If force_const_mem result
is not valid general operand, force its address into the destination
register first.

* gcc.target/arm/pure-code/pr98998.c: New test.

3 years agotree-cfg: Fix up gimple_merge_blocks FORCED_LABEL handling [PR99034]
Jakub Jelinek [Fri, 19 Feb 2021 11:14:39 +0000 (12:14 +0100)]
tree-cfg: Fix up gimple_merge_blocks FORCED_LABEL handling [PR99034]

The verifiers require that DECL_NONLOCAL or EH_LANDING_PAD_NR
labels are always the first label if there is more than one label.

When merging blocks, we don't honor that though.
On the following testcase, we try to merge blocks:
<bb 13> [count: 0]:
<L2>:
S::~S (&s);

and
<bb 15> [count: 0]:
<L0>:
resx 1

where <L2> is landing pad and <L0> is FORCED_LABEL.  And the code puts
the FORCED_LABEL before the landing pad label, violating the verification
requirements.

The following patch fixes it by moving the FORCED_LABEL after the
DECL_NONLOCAL or EH_LANDING_PAD_NR label if it is the first label.

2021-02-19  Jakub Jelinek  <jakub@redhat.com>

PR ipa/99034
* tree-cfg.c (gimple_merge_blocks): If bb a starts with eh landing
pad or non-local label, put FORCED_LABELs from bb b after that label
rather than before it.

* g++.dg/opt/pr99034.C: New test.

3 years agolibstdc++: Fix __thread_relax for non-gthreads non-x86 targets
Jonathan Wakely [Fri, 19 Feb 2021 09:54:04 +0000 (09:54 +0000)]
libstdc++: Fix __thread_relax for non-gthreads non-x86 targets

My recent change to the preprocessor conditions in __thread_relax() was
supposed to also change the __gthread_yield() call to __thread_yield(),
which has the right preprocessor checks. Instead I just removed the
check for _GLIBCXX_USE_SCHED_YIELD which means the __gthread_yield()
call will be ill-formed for non-gthreads targets, and targets without
sched_yield(). This fixes it properly.

libstdc++-v3/ChangeLog:

* include/bits/atomic_wait.h (__thread_relax()): Call
__thread_yield() not __gthread_yield().

3 years agoFortran: Fix ubound simplifcation [PR99027]
Tobias Burnus [Fri, 19 Feb 2021 09:42:15 +0000 (10:42 +0100)]
Fortran: Fix ubound simplifcation [PR99027]

gcc/fortran/ChangeLog:

PR fortran/99027
* simplify.c (simplify_bound_dim): Honor DIMEN_ELEMENT
when using dim=.

gcc/testsuite/ChangeLog:

PR fortran/99027
* gfortran.dg/ubound_1.f90: New test.

3 years agoaarch64: Check predicate when using gen_vec_duplicate [PR98657]
Andre Vieira [Fri, 19 Feb 2021 09:13:02 +0000 (09:13 +0000)]
aarch64: Check predicate when using gen_vec_duplicate [PR98657]

Prevents generation of a vec_duplicate with illegal predicate in
<ASHIFT:optab><mode>3.

gcc/ChangeLog:
2021-02-19  Andre Vieira  <andre.simoesdiasvieira@arm.com>

PR target/98657
* config/aarch64/aarch64-sve.md (<ASHIFT:optab><mode>3): Use
expand_vector_broadcast' to emit the vec_duplicate operand.

gcc/testsuite/ChangeLog:
2021-02-19  Andre Vieira  <andre.simoesdiasvieira@arm.com>

PR target/98657
* gcc.target/aarch64/sve/pr98657.c: New test.

3 years ago[PATCH v2] libiberty(argv.c): Fix memory leak in expandargv
Ayush Mittal [Fri, 19 Feb 2021 04:59:03 +0000 (21:59 -0700)]
[PATCH v2] libiberty(argv.c): Fix memory leak in expandargv

libiberty:
* argv.c (expandargv): free allocated buffer if read fails.

3 years agoc++: Tweak PR969626 patch
Jason Merrill [Fri, 19 Feb 2021 02:27:37 +0000 (21:27 -0500)]
c++: Tweak PR969626 patch

It occurred to me that other types of conversions use rvaluedness_matches_p,
but those uses don't affect overload resolution, so we shouldn't look at the
flag for them.  Fixing that made decltype64.C compile successfully, because
the non-template candidate was a perfect match, so we now wouldn't consider
the broken template.  Changing the argument to const& makes it no longer a
perfect match (because of the added const), so we again get the infinite
recursion.

This illustrates the limited nature of this optimization/recursion break; it
works for most copy/move constructors because the constructor we're looking
for is almost always a perfect match.  If it happens to help improve compile
time for other calls, that's just a bonus.

gcc/cp/ChangeLog:

PR c++/96926
* call.c (perfect_conversion_p): Limit rvalueness
test to reference bindings.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/decltype64.C: Change argument to const&.

3 years agojit: fix ICE on BUILT_IN_TRAP [PR99126]
David Malcolm [Fri, 19 Feb 2021 02:28:26 +0000 (21:28 -0500)]
jit: fix ICE on BUILT_IN_TRAP [PR99126]

gcc/jit/ChangeLog:
PR jit/99126
* jit-builtins.c
(gcc::jit::builtins_manager::get_builtin_function_by_id):
Update assertion to reject BUILT_IN_NONE.
(gcc::jit::builtins_manager::ensure_optimization_builtins_exist):
New.
* jit-builtins.h
(gcc::jit::builtins_manager::ensure_optimization_builtins_exist):
New decl.
* jit-playback.c (gcc::jit::playback::context::replay): Call it.
Remove redundant conditional on bm.

gcc/testsuite/ChangeLog:
PR jit/99126
* jit.dg/test-trap.c: New test.

3 years agoc++: Tuple of self-dependent classes [PR96926]
Jason Merrill [Sat, 13 Feb 2021 05:40:11 +0000 (00:40 -0500)]
c++: Tuple of self-dependent classes [PR96926]

When compiling this testcase, trying to resolve the initialization for the
tuple member ends up recursively considering the same set of tuple
constructor overloads, and since two of them separately depend on
is_constructible, the one we try second fails to instantiate
is_constructible because we're still in the middle of instantiating it the
first time.

Fixed by implementing an optimization that someone suggested we were already
doing: if we see a non-template candidate that is a perfect match for all
arguments, we can skip considering template candidates at all.  It would be
enough to do this only when LOOKUP_DEFAULTED, but it shouldn't hurt in other
cases.

gcc/cp/ChangeLog:

PR c++/96926
* call.c (perfect_conversion_p): New.
(perfect_candidate_p): New.
(add_candidates): Ignore templates after a perfect non-template.

gcc/testsuite/ChangeLog:

PR c++/96926
* g++.dg/cpp0x/overload4.C: New test.

3 years agoDaily bump.
GCC Administrator [Fri, 19 Feb 2021 00:16:21 +0000 (00:16 +0000)]
Daily bump.

3 years ago[PR96264] LRA: Check output insn hard regs when updating available rematerialization...
Vladimir N. Makarov [Thu, 18 Feb 2021 22:49:26 +0000 (17:49 -0500)]
[PR96264] LRA: Check output insn hard regs when updating available rematerialization after the insn

 Insn for rematerialization can contain a clobbered hard register.  We
can not move such insn through another insn setting up the same hard
register.  The patch adds such check.

gcc/ChangeLog:

PR rtl-optimization/96264
* lra-remat.c (reg_overlap_for_remat_p): Check also output insn
hard regs.

gcc/testsuite/ChangeLog:

PR rtl-optimization/96264
* gcc.target/powerpc/pr96264.c: New.

3 years agoAdd retain attribute to place symbols in SHF_GNU_RETAIN section
H.J. Lu [Mon, 15 Feb 2021 19:31:12 +0000 (11:31 -0800)]
Add retain attribute to place symbols in SHF_GNU_RETAIN section

When building Linux kernel, ld in bninutils 2.36 with GCC 11 generates
thousands of

ld: warning: orphan section `.data.event_initcall_finish' from `init/main.o' being placed in section `.data.event_initcall_finish'
ld: warning: orphan section `.data.event_initcall_start' from `init/main.o' being placed in section `.data.event_initcall_start'
ld: warning: orphan section `.data.event_initcall_level' from `init/main.o' being placed in section `.data.event_initcall_level'

Since these sections are marked with SHF_GNU_RETAIN, they are placed in
separate sections.  They become orphan sections since they aren't expected
in the Linux kernel linker script. But orphan sections normally don't work
well with the Linux kernel linker script and the resulting kernel crashed.

Add the "retain" attribute to place symbols in separate SHF_GNU_RETAIN
sections.  Issue a warning if the configured assembler/linker doesn't
support SHF_GNU_RETAIN.

gcc/

PR target/99113
* varasm.c (get_section): Replace SUPPORTS_SHF_GNU_RETAIN with
looking up the retain attribute.
(resolve_unique_section): Likewise.
(get_variable_section): Likewise.
(switch_to_section): Likewise.  Warn when a symbol without the
retain attribute and a symbol with the retain attribute are
placed in the section with the same name, instead of the used
attribute.
* doc/extend.texi: Document the "retain" attribute.

gcc/c-family/

PR target/99113
* c-attribs.c (c_common_attribute_table): Add the "retain"
attribute.
(handle_retain_attribute): New function.

gcc/testsuite/

PR target/99113
* c-c++-common/attr-retain-1.c: New test.
* c-c++-common/attr-retain-2.c: Likewise.
* c-c++-common/attr-retain-3.c: Likewise.
* c-c++-common/attr-retain-4.c: Likewise.
* c-c++-common/attr-retain-5.c: Likewise.
* c-c++-common/attr-retain-6.c: Likewise.
* c-c++-common/attr-retain-7.c: Likewise.
* c-c++-common/attr-retain-8.c: Likewise.
* c-c++-common/attr-retain-9.c: Likewise.
* c-c++-common/pr99113.c: Likewise.
* gcc.c-torture/compile/attr-retain-1.c: Likewise.
* gcc.c-torture/compile/attr-retain-2.c: Likewise.
* c-c++-common/attr-used.c: Don't expect SHF_GNU_RETAIN section.
* c-c++-common/attr-used-2.c: Likewise.
* c-c++-common/attr-used-3.c: Likewise.
* c-c++-common/attr-used-4.c: Likewise.
* c-c++-common/attr-used-9.c: Likewise.
* gcc.c-torture/compile/attr-used-retain-1.c: Likewise.
* gcc.c-torture/compile/attr-used-retain-2.c: Likewise.
* c-c++-common/attr-used-5.c: Don't expect warning for the used
attribute nor SHF_GNU_RETAIN section.
* c-c++-common/attr-used-6.c: Likewise.
* c-c++-common/attr-used-7.c: Likewise.
* c-c++-common/attr-used-8.c: Likewise.

3 years agoc++: header-unit build capability [PR 99023]
Nathan Sidwell [Thu, 18 Feb 2021 20:46:25 +0000 (12:46 -0800)]
c++: header-unit build capability [PR 99023]

This defect really required building header-units and include translation
of pieces of the standard library.  This adds smarts to the modules
test harness to do that -- accept .X files as the source file, but
provide '-x c++-system-header $HDR' in the options.  The .X file will
be considered by the driver to be a linker script and ignored (with a
warning).

Using this we can add 2 tests that end up building list_initializer
and iostream, along with a test that iostream's build
include-translates list_initializer's #include.  That discovered a set
of issues with the -flang-info-include-translate=HDR handling, also
fixed and documented here.

PR c++/99023
gcc/cp/
* module.cc (canonicalize_header_name): Use
cpp_probe_header_unit.
(maybe_translate_include): Fix note_includes comparison.
(init_modules): Fix note_includes string termination.
libcpp/
* include/cpplib.h (cpp_find_header_unit): Rename to ...
(cpp_probe_header_unit): ... this.
* internal.h (_cp_find_header_unit): Declare.
* files.c (cpp_find_header_unit): Break apart to ..
(test_header_unit): ... this, and ...
(_cpp_find_header_unit): ... and, or and ...
(cpp_probe_header_unit): ... this.
* macro.c (cpp_get_token_1): Call _cpp_find_header_unit.
gcc/
* doc/invoke.texi (flang-info-include-translate): Document header
lookup behaviour.
gcc/testsuite/
* g++.dg/modules/modules.exp: Bail on cross-testing.  Add support
for .X files.
* g++.dg/modules/pr99023_a.X: New.
* g++.dg/modules/pr99023_b.X: New.

3 years agoc: Fix ICE with -fexcess-precision=standard [PR99136]
Jakub Jelinek [Thu, 18 Feb 2021 21:17:52 +0000 (22:17 +0100)]
c: Fix ICE with -fexcess-precision=standard [PR99136]

The following testcase ICEs on i686-linux, because c_finish_return wraps
c_fully_folded retval back into EXCESS_PRECISION_EXPR, but when the function
return type is void, we don't call convert_for_assignment on it that would
then be fully folded again, but just put the retval into RETURN_EXPR's
operand, so nothing removes it anymore and during gimplification we
ICE as EXCESS_PRECISION_EXPR is not handled.

This patch fixes it by not adding that EXCESS_PRECISION_EXPR in functions
returning void, the return value is ignored and all we need is evaluate any
side-effects of the expression.

2021-02-18  Jakub Jelinek  <jakub@redhat.com>

PR c/99136
* c-typeck.c (c_finish_return): Don't wrap retval into
EXCESS_PRECISION_EXPR in functions that return void.

* gcc.dg/pr99136.c: New test.

3 years agoc++: Remove obsolete dg-module-headers [PR 99023]
Nathan Sidwell [Thu, 18 Feb 2021 15:33:12 +0000 (07:33 -0800)]
c++: Remove obsolete dg-module-headers [PR 99023]

PR99023's testcase is highlighting some missing functionality of the
modules test harness.  I did have some partial support, but it's only
use in one place for a now-obsolete test.  This patch expunges that
support so I can add better functionality now I understand better what
is necessary.

PR c++/99023
gcc/testsuite/
* g++.dg/modules/modules.exp: Remove dg-module-headers support
* g++.dg/modules/alias-2_a.H: Delete.
* g++.dg/modules/sys/alias-2_a.H: Delete.

3 years agoc++: Remove large abi-specific tests [PR 99150]
Nathan Sidwell [Thu, 18 Feb 2021 18:31:02 +0000 (10:31 -0800)]
c++: Remove large abi-specific tests [PR 99150]

Remove the two large and incorrectly abi-specific testcases I added.
Replacement tests will be forthcoming.

PR c++/99150
gcc/testsuite/
* g++.dg/modules/pr99023_a.H: Delete.
* g++.dg/modules/pr99023_b.H: Delete.

3 years agoc++: Fix -std=c++20 ICE on virtual method call [PR99132]
Jakub Jelinek [Thu, 18 Feb 2021 15:21:52 +0000 (16:21 +0100)]
c++: Fix -std=c++20 ICE on virtual method call [PR99132]

On the following testcase we ICE in C++20 mode during cp_get_callee_fndecl
-> constexpr evaluation.
It is only in C++20 mode on this testcase because virtual methods can't
be constexpr in C++17 and earlier and so potential_constant_expression_1
rejects it earlier.
And the ICE is caused by genericization changing the h PARM_DECL from having
B<C *> type to B<C *> & DECL_BY_REFERENCE and the constexpr evaluation
not being able to deal with that.
I think this just shows that we shouldn't do the constexpr evaluation during
genericization and later, and other spots e.g. during gimplification
also don't call cp_get_callee_fndecl but cp_get_callee_fndecl_nofold.
After all, cp_fold has already been run and it did the folding if there
was any opportunity to do so.  And furthermore, what that cp_genericize_r
spot does is check for any left-over immediate function calls (which can be
ATM just std::source_location::current() call) and immediate functions
outside of immediate functions can't have addresses leaked into the IL,
so it will be always a direct call anyway.  And immediate functions
themselves don't make it into genericization/gimplification.

2021-02-18  Jakub Jelinek  <jakub@redhat.com>

PR c++/99132
* cp-gimplify.c (cp_genericize_r) <case CALL_EXPR>: Use
cp_get_callee_fndecl_nofold instead of cp_get_callee_fndecl to check
for immediate function calls.

* g++.dg/cpp2a/constexpr-virtual18.C: New test.

3 years agomiddle-end/99122 - Issues with VLA parameter inlining
Richard Biener [Thu, 18 Feb 2021 11:28:26 +0000 (12:28 +0100)]
middle-end/99122 - Issues with VLA parameter inlining

The following instructs IPA not to inline calls with VLA parameters
and adjusts inlining not to create invalid view-converted VLA
parameters on mismatch and makes the error_mark paths with debug
stmts actually work.

The first part avoids the ICEs with the testcases already.

2021-02-18  Richard Biener  <rguenther@suse.de>

PR middle-end/99122
* ipa-fnsummary.c (analyze_function_body): Set
CIF_FUNCTION_NOT_INLINABLE for VLA parameter calls.
* tree-inline.c (insert_init_debug_bind): Pass NULL for
error_mark_node values.
(force_value_to_type): Do not build V_C_Es for WITH_SIZE_EXPR
values.
(setup_one_parameter): Delay force_value_to_type until when
it's needed.

* gcc.dg/pr99122-1.c: New testcase.
* gcc.dg/pr99122-2.c: Likewise.

3 years agomatch.pd: Restrict clz cmp 0 replacement by single_use, PR99142
Hans-Peter Nilsson [Tue, 16 Feb 2021 21:27:53 +0000 (22:27 +0100)]
match.pd: Restrict clz cmp 0 replacement by single_use, PR99142

If we're not going to eliminate the clz, it's better for the
comparison to use that result than its input, so we don't
extend the lifetime of the input.  Also, an additional use
of the result is more likely cheaper than a compare of the
input, in particular considering that the clz may have made
available a non-zero condition matching the original use.
The "s" modifier doesn't stop this situation, as the
transformation wouldn't result in "an expression with more
than one operator"; a gating single_use condition on the
result is necessary.

gcc:
PR tree-optimization/99142
* match.pd (clz cmp 0): Gate replacement on single_use of clz result.

gcc/testsuite:
PR tree-optimization/99142
* gcc.dg/tree-ssa/pr99142.c: New test.

3 years agoi386: Avoid C++ global constructors in every object that includes i386.h
Jakub Jelinek [Thu, 18 Feb 2021 09:32:57 +0000 (10:32 +0100)]
i386: Avoid C++ global constructors in every object that includes i386.h

When looking at recog.o when working on the recog.[ch] changes to make sure
I have not introduced runtime construction of recog_data variable, I have
noticed that at least in unoptimized build, every single *.o file that
included i386.h has lots of runtime constructors for all the PTA_*
variables.

As we now require C++11, the following patch makes those constexpr so that
they don't need runtime initialization.
I've verified that ~ 8276 bytes long _Z41__static_initialization_and_destruction_0ii
at -O0 is gone from every *.o that included i386.h (and doesn't really need
any global ctors anymore).

2021-02-18  Jakub Jelinek  <jakub@redhat.com>

* wide-int-bitmask.h (wide_int_bitmask::wide_int_bitmask (),
wide_int_bitmask::wide_int_bitmask (uint64_t),
wide_int_bitmask::wide_int_bitmask (uint64_t, uint64_t),
wide_int_bitmask::operator ~ () const,
wide_int_bitmask::operator | (wide_int_bitmask) const,
wide_int_bitmask::operator & (wide_int_bitmask) const): Use constexpr
instead of inline.
* config/i386/i386.h (PTA_3DNOW, PTA_3DNOW_A, PTA_64BIT, PTA_ABM,
PTA_AES, PTA_AVX, PTA_BMI, PTA_CX16, PTA_F16C, PTA_FMA, PTA_FMA4,
PTA_FSGSBASE, PTA_LWP, PTA_LZCNT, PTA_MMX, PTA_MOVBE, PTA_NO_SAHF,
PTA_PCLMUL, PTA_POPCNT, PTA_PREFETCH_SSE, PTA_RDRND, PTA_SSE, PTA_SSE2,
PTA_SSE3, PTA_SSE4_1, PTA_SSE4_2, PTA_SSE4A, PTA_SSSE3, PTA_TBM,
PTA_XOP, PTA_AVX2, PTA_BMI2, PTA_RTM, PTA_HLE, PTA_PRFCHW, PTA_RDSEED,
PTA_ADX, PTA_FXSR, PTA_XSAVE, PTA_XSAVEOPT, PTA_AVX512F, PTA_AVX512ER,
PTA_AVX512PF, PTA_AVX512CD, PTA_NO_TUNE, PTA_SHA, PTA_PREFETCHWT1,
PTA_CLFLUSHOPT, PTA_XSAVEC, PTA_XSAVES, PTA_AVX512DQ, PTA_AVX512BW,
PTA_AVX512VL, PTA_AVX512IFMA, PTA_AVX512VBMI, PTA_CLWB, PTA_MWAITX,
PTA_CLZERO, PTA_NO_80387, PTA_PKU, PTA_AVX5124VNNIW, PTA_AVX5124FMAPS,
PTA_AVX512VPOPCNTDQ, PTA_SGX, PTA_AVX512VNNI, PTA_GFNI, PTA_VAES,
PTA_AVX512VBMI2, PTA_VPCLMULQDQ, PTA_AVX512BITALG, PTA_RDPID,
PTA_PCONFIG, PTA_WBNOINVD, PTA_AVX512VP2INTERSECT, PTA_PTWRITE,
PTA_AVX512BF16, PTA_WAITPKG, PTA_MOVDIRI, PTA_MOVDIR64B, PTA_ENQCMD,
PTA_CLDEMOTE, PTA_SERIALIZE, PTA_TSXLDTRK, PTA_AMX_TILE, PTA_AMX_INT8,
PTA_AMX_BF16, PTA_UINTR, PTA_HRESET, PTA_KL, PTA_WIDEKL, PTA_AVXVNNI,
PTA_X86_64_BASELINE, PTA_X86_64_V2, PTA_X86_64_V3, PTA_X86_64_V4,
PTA_CORE2, PTA_NEHALEM, PTA_WESTMERE, PTA_SANDYBRIDGE, PTA_IVYBRIDGE,
PTA_HASWELL, PTA_BROADWELL, PTA_SKYLAKE, PTA_SKYLAKE_AVX512,
PTA_CASCADELAKE, PTA_COOPERLAKE, PTA_CANNONLAKE, PTA_ICELAKE_CLIENT,
PTA_ICELAKE_SERVER, PTA_TIGERLAKE, PTA_SAPPHIRERAPIDS, PTA_ALDERLAKE,
PTA_KNL, PTA_BONNELL, PTA_SILVERMONT, PTA_GOLDMONT, PTA_GOLDMONT_PLUS,
PTA_TREMONT, PTA_KNM): Use constexpr instead of const.

3 years agoarray-bounds: Fix up ICE on overaligned variables [PR99109]
Jakub Jelinek [Thu, 18 Feb 2021 08:45:19 +0000 (09:45 +0100)]
array-bounds: Fix up ICE on overaligned variables [PR99109]

check_mem_ref builds artificial arrays for variables that don't have
array type.
The C standard says:
"For the purposes of these operators, a pointer to an object that is not an element of an
array behaves the same as a pointer to the first element of an array of length one with the
type of the object as its element type."
so it isn't completely wrong and does simplify the function.
But, layout_type can fail if the size of the element type is not a multiple
of its alignment (i.e. overaligned types) and we then ICE because of that.

The following patch uses TYPE_MAIN_VARIANT in those cases instead, but only
for the types that need it, as for the diagnostics it is better to use the
typedef names etc. that were really used in the source if possible.

2021-02-18  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/99109
* gimple-array-bounds.cc (build_zero_elt_array_type): Rename to ...
(build_printable_array_type): ... this.  Add nelts argument.  For
overaligned eltype, use TYPE_MAIN_VARIANT (eltype) instead.  If
nelts, call build_array_type_nelts.
(array_bounds_checker::check_mem_ref): Use build_printable_array_type
instead of build_zero_elt_array_type and build_array_type_nelts.

* g++.dg/warn/Warray-bounds-17.C: New test.

3 years agoi386: Fix up df uses in i386 splitters [PR99104]
Jakub Jelinek [Thu, 18 Feb 2021 08:16:28 +0000 (09:16 +0100)]
i386: Fix up df uses in i386 splitters [PR99104]

The following testcase started ICEing with my recent changes to enable
split4 after sel-sched, but it seems the bug is more general.
Some of the i386 splitter condition functions use and rely on df, but
the split passes don't really df_analyze/df_finish_pass, so the DF info
may be stale or not computed at all - the particular ICE is because
there is a new bb and df_get_live_out (bb) returns NULL on it as the
live or lr problem has not been computed yet.

This patch fixes it by not calling ix86_ok_to_clobber_flags from
ix86_avoid_lea_for_add where it wasn't ever needed because the splitters
using that function as condition have (clobber FLAGS) in their pattern.
And, changes the ix86_avoid_lea_for_addr using splitter from normal splitter
to peephole2 splitter that uses peep2_regno_dead_p infrastructure to
determine if FLAGS is dead.  Also, it saves and restores recog_data
variable around the call to distance_non_agu_define and doesn't call
extract_insn_data there, because split_insns or peephole2_insns just
clear recog_data.insn and then fill in recog_data.operand array, and so
might not match what extract_insn will do on the insn at all.

2021-02-18  Jakub Jelinek  <jakub@redhat.com>

PR target/99104
* config/i386/i386.c (distance_non_agu_define): Don't call
extract_insn_cached here.
(ix86_lea_outperforms): Save and restore recog_data around call
to distance_non_agu_define and distance_agu_use.
(ix86_ok_to_clobber_flags): Remove.
(ix86_avoid_lea_for_add): Don't call ix86_ok_to_clobber_flags.
(ix86_avoid_lea_for_addr): Likewise.  Adjust function comment.
* config/i386/i386.md (*lea<mode>): Change from define_insn_and_split
into define_insn.  Move the splitting to define_peephole2 and
check there using peep2_regno_dead_p if FLAGS_REG is dead.

* gcc.dg/pr99104.c: New test.

3 years agoDaily bump.
GCC Administrator [Thu, 18 Feb 2021 00:16:29 +0000 (00:16 +0000)]
Daily bump.

3 years agotestsuite: add regression test for PR analyzer/94596
David Malcolm [Wed, 17 Feb 2021 22:50:52 +0000 (17:50 -0500)]
testsuite: add regression test for PR analyzer/94596

This use-after-free false positive affected GCC 10, but seems to be
fixed in trunk for GCC 11; adding a reduced version as a regression
test.

gcc/testsuite/ChangeLog:
PR analyzer/94596
* gcc.dg/analyzer/pr94596.c: New test.

3 years agoc++: Macros need to be GTY-reachable [PR 99023]
Nathan Sidwell [Wed, 17 Feb 2021 18:43:21 +0000 (10:43 -0800)]
c++: Macros need to be GTY-reachable [PR 99023]

I'd missed that macros were allocated from GC storage, and that they can
become unattached from an identifier, and therefore not GC-reachable.
And then bad things happen.   Fixed by making the module machinery's
reference vector a GC root.

PR c++/99023
gcc/cp/
* module.cc (struct macro_export): Add GTY markers.
(macro_exports): Likewise, us a va_gc Vector.
gcc/testsuite/
* g++.dg/modules/pr99023_a.H: New.
* g++.dg/modules/pr99023_b.H: New.

3 years agoanalyzer: fix false leak involving params [PR98969]
David Malcolm [Wed, 17 Feb 2021 15:37:16 +0000 (10:37 -0500)]
analyzer: fix false leak involving params [PR98969]

This patch updates the svalue liveness code so that the initial value
of parameters at top-level functions to the analysis are treated as
live (since the values are presumably still live within the
outside-of-the-analysis calling code).

This fixes the false leak in PR analyzer/98969 seen on:

void
test (long int i)
{
  struct foo *f = (struct foo *)i;
  f->expr = __builtin_malloc (1024);
}

since the calling code can presumably still access the allocated
buffer via:
  ((struct foo *)i)->expr

The patch also removes the expected leak warnings from
g++.dg/analyzer/pr99064.C and gcc.dg/analyzer/pr96841.c, which now
appear to me to be false positives.

gcc/analyzer/ChangeLog:
PR analyzer/98969
* constraint-manager.cc (dead_svalue_purger::should_purge_p):
Update for change to svalue::live_p.
* program-state.cc (sm_state_map::on_liveness_change): Likewise.
(program_state::detect_leaks): Likewise.
* region-model-reachability.cc (reachable_regions::init_cluster):
When dealing with a symbolic region, if the underlying pointer is
implicitly live, add the region to the reachable regions.
* region-model.cc (region_model::compare_initial_and_pointer):
Move logic for detecting initial values of params to
initial_svalue::initial_value_of_param_p.
* svalue.cc (svalue::live_p): Convert "live_svalues" from a
reference to a pointer; support it being NULL.
(svalue::implicitly_live_p): Convert first param from a
refererence to a pointer.
(region_svalue::implicitly_live_p): Likewise.
(constant_svalue::implicitly_live_p): Likewise.
(initial_svalue::implicitly_live_p): Likewise.  Treat the initial
values of params for the top level frame as still live.
(initial_svalue::initial_value_of_param_p): New function, taken
from a test in region_model::compare_initial_and_pointer.
(unaryop_svalue::implicitly_live_p): Convert first param from a
refererence to a pointer.
(binop_svalue::implicitly_live_p): Likewise.
(sub_svalue::implicitly_live_p): Likewise.
(unmergeable_svalue::implicitly_live_p): Likewise.
* svalue.h (svalue::live_p): Likewise.
(svalue::implicitly_live_p): Likewise.
(region_svalue::implicitly_live_p): Likewise.
(constant_svalue::implicitly_live_p): Likewise.
(initial_svalue::implicitly_live_p): Likewise.
(initial_svalue::initial_value_of_param_p): New decl.
(unaryop_svalue::implicitly_live_p): Convert first param from a
refererence to a pointer.
(binop_svalue::implicitly_live_p): Likewise.
(sub_svalue::implicitly_live_p): Likewise.
(unmergeable_svalue::implicitly_live_p): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/98969
* g++.dg/analyzer/pr99064.C: Convert dg-bogus to dg-warning.
* gcc.dg/analyzer/pr96841.c: Add -Wno-analyzer-too-complex to
options.  Remove false leak directive.
* gcc.dg/analyzer/pr98969.c (test_1): Remove xfail from leak
false positive.
(test_3): New.

3 years agoopenacc: Strided array sections and components of derived-type arrays
Julian Brown [Wed, 10 Feb 2021 19:18:13 +0000 (11:18 -0800)]
openacc: Strided array sections and components of derived-type arrays

This patch disallows selecting components of array sections in update
directives for OpenACC, as specified in OpenACC 3.0, "2.14.4. Update
Directive":

  In Fortran, members of variables of derived type may appear, including
  a subarray of a member. Members of subarrays of derived type may
  not appear.

The diagnostic for attempting to use the same construct on other
directives has also been improved.

gcc/fortran/
* openmp.c (resolve_omp_clauses): Disallow selecting components
of arrays of derived type.

gcc/testsuite/
* gfortran.dg/goacc/array-with-dt-2.f90: Remove expected errors.
* gfortran.dg/goacc/array-with-dt-6.f90: New test.
* gfortran.dg/goacc/mapping-tests-2.f90: Update expected error.
* gfortran.dg/goacc/ref_inquiry.f90: Update expected errors.
* gfortran.dg/gomp/ref_inquiry.f90: Likewise.

libgomp/
* testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90: Remove
expected errors.

3 years agoopenacc: Fix lowering for derived-type mappings through array elements
Julian Brown [Thu, 21 Jan 2021 14:54:54 +0000 (06:54 -0800)]
openacc: Fix lowering for derived-type mappings through array elements

This patch fixes lowering of derived-type mappings which select elements
of arrays of derived types, and similar. These would previously lead
to ICEs.

With this change, OpenACC directives can pass through constructs that
are no longer recognized by the gimplifier, hence alterations are needed
there also.

gcc/fortran/
* trans-openmp.c (gfc_trans_omp_clauses): Handle element selection
for arrays of derived types.

gcc/
* gimplify.c (gimplify_scan_omp_clauses): Handle ATTACH_DETACH
for non-decls.

gcc/testsuite/
* gfortran.dg/goacc/array-with-dt-1.f90: New test.
* gfortran.dg/goacc/array-with-dt-3.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-4.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-5.f90: Likewise.
* gfortran.dg/goacc/derived-chartypes-1.f90: Re-enable test.
* gfortran.dg/goacc/derived-chartypes-2.f90: Likewise.
* gfortran.dg/goacc/derived-classtypes-1.f95: Uncomment
previously-broken directives.

libgomp/
* testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90: New test.
* testsuite/libgomp.oacc-fortran/update-dt-array.f90: Likewise.

3 years agoc++: Fix up build_zero_init_1 once more [PR99106]
Jakub Jelinek [Wed, 17 Feb 2021 14:03:25 +0000 (15:03 +0100)]
c++: Fix up build_zero_init_1 once more [PR99106]

My earlier build_zero_init_1 patch for flexible array members created
an empty CONSTRUCTOR.  As the following testcase shows, that doesn't work
very well because the middle-end doesn't expect CONSTRUCTOR elements with
incomplete type (that the empty CONSTRUCTOR at the end of outer CONSTRUCTOR
had).

The following patch just doesn't add any CONSTRUCTOR for the flexible array
members, it doesn't seem to be needed.

2021-02-17  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/99106
* init.c (build_zero_init_1): For flexible array members just return
NULL_TREE instead of returning empty CONSTRUCTOR with non-complete
ARRAY_TYPE.

* g++.dg/ubsan/pr99106.C: New test.

3 years agoc++: More set_identifier_type_value fixing [PR 99116]
Nathan Sidwell [Wed, 17 Feb 2021 13:33:45 +0000 (05:33 -0800)]
c++: More set_identifier_type_value fixing [PR 99116]

My recent change looked under template_parms in two places, but that
was covering up a separate problem.  We were attempting to set the
identifier_type_value of a template_parm into the template_parm
scope.  The peeking stopped us doing that, but confused poplevel,
leaving an identifier value lying around.  This fixes the underlying
problem in do_pushtag -- we only need to set the identifier_type_value
directly when we're in a template_parm scope (a later pushdecl will
push the actual template_decl).  for non-class non-template-parm
bindings do_pushdecl already ends up manipulating
identifier_type_value correctly.

PR c++/99116
gcc/cp/
* name-lookup.c (do_pushdecl): Don't peek under template_parm
bindings here ...
(set_identifier_type_value_with_scope): ... or here.
(do_pushtag): Only set_identifier_type_value_with_scope at
non-class template parm scope, and use parent scope.
gcc/testsuite/
* g++.dg/lookup/pr99116-1.C: New.
* g++.dg/lookup/pr99116-2.C: New.

3 years agoc++: ICE with header-units [PR 99071]
Nathan Sidwell [Wed, 17 Feb 2021 13:28:09 +0000 (05:28 -0800)]
c++: ICE with header-units [PR 99071]

This ICE was caused by dereferencing the wrong pointer and not finding the
expected thing there.  Pointers are like that.

PR c++/99071
gcc/cp/
* name-lookup.c (maybe_record_mergeable_decl): Deref the correct
pointer.
gcc/testsuite/
* g++.dg/modules/pr99071_a.H: New.
* g++.dg/modules/pr99071_b.H: New.

3 years agomips: Avoid out-of-bounds access in mips_symbol_insns [PR98491]
Xi Ruoyao [Wed, 17 Feb 2021 11:57:13 +0000 (11:57 +0000)]
mips: Avoid out-of-bounds access in mips_symbol_insns [PR98491]

An invalid use of MSA_SUPPORTED_MODE_P was causing an ICE on
mips64el with -mmsa.  The detailed analysis is posted on bugzilla.

gcc/ChangeLog:

2021-02-17  Xi Ruoyao  <xry111@mengyan1223.wang>

PR target/98491
* config/mips/mips.c (mips_symbol_insns): Do not use
MSA_SUPPORTED_MODE_P if mode is MAX_MACHINE_MODE.

3 years agoc++: Revert EXPR_LOCATION change to build_aggr_init_expr [PR96997]
Patrick Palka [Wed, 17 Feb 2021 01:49:12 +0000 (20:49 -0500)]
c++: Revert EXPR_LOCATION change to build_aggr_init_expr [PR96997]

My change in r10-7718 to make build_aggr_init_expr set EXPR_LOCATION
(mimicking build_target_expr) causes the debuginfo regression PR96997.
Given that this change is mostly independent of the rest of the commit,
and that the only fallout of reverting it is a less accurate error
message location in a testcase introduced in the same commit, it seems
the best way forward is to just revert this part of the commit.

gcc/cp/ChangeLog:

PR debug/96997
PR c++/94034
* tree.c (build_aggr_init_expr): Revert r10-7718 change.

gcc/testsuite/ChangeLog:

PR debug/96997
PR c++/94034
* g++.dg/cpp1y/constexpr-nsdmi7b.C:  Adjust expected location of
"call to non-'constexpr' function" error message.

3 years agoDaily bump.
GCC Administrator [Wed, 17 Feb 2021 00:16:20 +0000 (00:16 +0000)]
Daily bump.

3 years agocompiler: unalias receiver type in export data
Ian Lance Taylor [Mon, 15 Feb 2021 02:59:07 +0000 (18:59 -0800)]
compiler: unalias receiver type in export data

Test case is https://golang.org/cl/292009.

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

3 years agoc++: directives-only preprocessing and include translation [PR 99050]
Nathan Sidwell [Tue, 16 Feb 2021 20:23:12 +0000 (12:23 -0800)]
c++: directives-only preprocessing and include translation [PR 99050]

We make sure files end in \n by placing one at the limit of the buffer
(just past the end of what is read).  We need to do the same for
buffers generated via include-translation.  Fortunately they have
space.

libcpp/
* files.c (_cpp_stack_file): Make buffers end in unread \n.
gcc/testsuite/
* g++.dg/modules/pr99050_a.H: New.
* g++.dg/modules/pr99050_b.C: New.

3 years agoc-family: ICE with assume_aligned attribute [PR99062]
Marek Polacek [Wed, 10 Feb 2021 20:24:25 +0000 (15:24 -0500)]
c-family: ICE with assume_aligned attribute [PR99062]

We ICE in handle_assume_aligned_attribute since r271338 which added

@@ -2935,8 +2936,8 @@ handle_assume_aligned_attribute (tree *node, tree name, tree args, int,
          /* The misalignment specified by the second argument
             must be non-negative and less than the alignment.  */
          warning (OPT_Wattributes,
-                  "%qE attribute argument %E is not in the range [0, %E)",
-                  name, val, align);
+                  "%qE attribute argument %E is not in the range [0, %wu]",
+                  name, val, tree_to_uhwi (align) - 1);
          *no_add_attrs = true;
          return NULL_TREE;
        }
because align is INT_MIN and tree_to_uhwi asserts tree_fits_uhwi_p -- which
ALIGN does not and the prior tree_fits_shwi_p check is fine with it, as
well as the integer_pow2p check.

Since neither of the arguments to assume_aligned can be negative, I've
hoisted the tree_int_cst_sgn check.  And add the missing "argument"
word to an existing warning.

gcc/c-family/ChangeLog:

PR c++/99062
* c-attribs.c (handle_assume_aligned_attribute): Check that the
alignment argument is non-negative.  Tweak a warning message.

gcc/testsuite/ChangeLog:

PR c++/99062
* gcc.dg/attr-assume_aligned-4.c: Adjust dg-warning.
* g++.dg/ext/attr-assume-aligned.C: New test.

3 years ago[PATCH 3/3] MIPS: fix compact-branches test FAIL for PIC default configuration
YunQiang Su [Tue, 16 Feb 2021 18:37:21 +0000 (11:37 -0700)]
[PATCH 3/3] MIPS: fix compact-branches test FAIL for PIC default configuration

gcc/testsuite

* gcc.target/mips/compact-branches-5.c: Force -fno-PIC.
* gcc.target/mips/compact-branches-6.c: Force -fno-PIC.

3 years agoFortran: %re/%im fixes for OpenMP/OpenACC + gfc_is_simplify_contiguous
Tobias Burnus [Tue, 16 Feb 2021 16:39:49 +0000 (17:39 +0100)]
Fortran: %re/%im fixes for OpenMP/OpenACC + gfc_is_simplify_contiguous

gcc/fortran/ChangeLog:

* expr.c (gfc_is_simplify_contiguous): Handle REF_INQUIRY, i.e.
%im and %re which are EXPR_VARIABLE.
* openmp.c (resolve_omp_clauses): Diagnose %re/%im explicitly.

gcc/testsuite/ChangeLog:

* gfortran.dg/goacc/ref_inquiry.f90: New test.
* gfortran.dg/gomp/ref_inquiry.f90: New test.

3 years ago[PR98096] inline-asm: Take inout operands into account for access to labels by names.
Vladimir N. Makarov [Tue, 16 Feb 2021 15:27:56 +0000 (10:27 -0500)]
[PR98096] inline-asm: Take inout operands into account for access to labels by names.

GCC splits inout operands into output and new matched input operands
during gimplfication.  Addressing operands by name or number is not
problem as the new input operands are added at the end of existing
input operands.  However it became a problem for labels in asm goto
with output reloads.  Addressing labels should take into account the
new input operands.  The patch solves the problem.

gcc/ChangeLog:

PR inline-asm/98096
* stmt.c (resolve_operand_name_1): Take inout operands into account
for access to labels by names.
* doc/extend.texi: Describe counting operands for accessing labels.

gcc/testsuite/ChangeLog:

PR inline-asm/98096
* gcc.c-torture/compile/pr98096.c: New.

3 years agoFortran: Reject DT as fmt in I/O statments [PR99111]
Tobias Burnus [Tue, 16 Feb 2021 13:17:35 +0000 (14:17 +0100)]
Fortran: Reject DT as fmt in I/O statments [PR99111]

gcc/fortran/ChangeLog:

PR fortran/99111
* io.c (resolve_tag_format): Reject BT_DERIVED/CLASS/VOID
as (array-valued) FORMAT tag.

gcc/testsuite/ChangeLog:

PR fortran/99111
* gfortran.dg/fmt_nonchar_1.f90: New test.
* gfortran.dg/fmt_nonchar_2.f90: New test.

3 years agotree-optimization/38474 - improve PTA varinfo sorting
Richard Biener [Tue, 16 Feb 2021 11:42:26 +0000 (12:42 +0100)]
tree-optimization/38474 - improve PTA varinfo sorting

This improves a previous heuristic to sort address-taken variables
first (because those appear in points-to bitmaps) by tracking which
variables appear in ADDRESSOF constraints (there's also
graph->address_taken but that's computed only later).

This shaves off 30s worth of compile-time for the full testcase in
PR38474 (which then still takes 965s to compile at -O2).

2021-02-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/38474
* tree-ssa-structalias.c (variable_info::address_taken): New.
(new_var_info): Initialize address_taken.
(process_constraint): Set address_taken.
(solve_constraints): Use the new address_taken flag rather
than is_reg_var for sorting variables.
(dump_constraint): Dump the variable number if the name
is just NULL.

3 years agoopenmp: Fix up vectorization simd call badness computation [PR99100]
Jakub Jelinek [Tue, 16 Feb 2021 07:59:03 +0000 (08:59 +0100)]
openmp: Fix up vectorization simd call badness computation [PR99100]

As mentioned in the PR, ix86_simd_clone_usable didn't make it more desirable
to use 'e' mangled AVX512F entrypoints over 'd' mangled ones (AVX2) with the
same simdlen.  This patch fixes that.  I have tweaked the generic code too
to make more room for these target specific badness factors.

2021-02-16  Jakub Jelinek  <jakub@redhat.com>

PR target/99100
* tree-vect-stmts.c (vectorizable_simd_clone_call): For num_calls != 1
multiply by 4096 and for inbranch by 8192.
* config/i386/i386.c (ix86_simd_clone_usable): For TARGET_AVX512F,
return 3, 2 or 1 for mangle letters 'b', 'c' or 'd'.

* gcc.target/i386/pr99100.c: New test.

3 years agogcc.misc-tests/outputs.exp (outest): Fix typo "is_target".
Hans-Peter Nilsson [Mon, 15 Feb 2021 23:37:28 +0000 (00:37 +0100)]
gcc.misc-tests/outputs.exp (outest): Fix typo "is_target".

Fix typo for istarget in "is_target hppa*-*-hpux*", yielding
an error running the test-suite for any target not matching
powerpc*-*-aix* (presumably, by code inspection), aborting
the check-gcc (check-gcc-c) regression test run some 3000
tests before the last one, missing e.g. all gcc.target
tests like so:

-----
...
Running /x/gcc/gcc/testsuite/gcc.misc-tests/outputs.exp ...
ERROR: (DejaGnu) proc "is_target hppa*-*-hpux*" does not exist.
The error code is TCL LOOKUP COMMAND is_target
The info on the error is:
invalid command name "is_target"
    while executing
"::tcl_unknown is_target hppa*-*-hpux*"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 ::tcl_unknown $args"

=== gcc Summary ===
...
-----

gcc/testsuite:
* gcc.misc-tests/outputs.exp (outest): Fix typo "is_target".

3 years agoDaily bump.
GCC Administrator [Tue, 16 Feb 2021 00:16:22 +0000 (00:16 +0000)]
Daily bump.

3 years agoaarch64: Run SUBTARGET_INIT_BUILTINS if it exists
Maya Rashish [Mon, 15 Feb 2021 18:38:55 +0000 (18:38 +0000)]
aarch64: Run SUBTARGET_INIT_BUILTINS if it exists

Some subtargets don't provide the canonical function names as
the symbol name in C libraries, and libcalls will only work if
the builtins are patched to emit the correct library name.

For example, on NetBSD, cabsl has the symbol name __c99_cabsl,
and the patching is done via netbsd_patch_builtin.

With this change, libgfortran.so is correctly built with a
reference to __c99_cabsl, instead of "cabsl" which is not defined.

gcc/ChangeLog:
* config/aarch64/aarch64.c (aarch64_init_builtins):
Call SUBTARGET_INIT_BUILTINS.

3 years agortl-optimization: Fix uninitialized use of opaque mode variable ICE [PR98872]
Peter Bergner [Mon, 15 Feb 2021 16:38:33 +0000 (10:38 -0600)]
rtl-optimization: Fix uninitialized use of opaque mode variable ICE [PR98872]

The initialize_uninitialized_regs function emits (set (reg:) (CONST0_RTX))
for all uninitialized pseudo uses.  However, some modes (eg, opaque modes)
may not have a CONST0_RTX defined, leading to an ICE when we try and create
the initialization insn.  The fix is to skip emitting the initialization
if there is no CONST0_RTX defined for the mode.

2021-02-15  Peter Bergner  <bergner@linux.ibm.com>

gcc/
PR rtl-optimization/98872
* init-regs.c (initialize_uninitialized_regs): Skip initialization
if CONST0_RTX is NULL.

gcc/testsuite/
PR rtl-optimization/98872
* gcc.target/powerpc/pr98872.c: New test.

3 years agolibstdc++: Fix __thread_yield for non-gthreads targets
Jonathan Wakely [Mon, 15 Feb 2021 15:35:55 +0000 (15:35 +0000)]
libstdc++: Fix __thread_yield for non-gthreads targets

The __gthread_yield() function is only defined for gthreads targets, so
check _GLIBCXX_HAS_GTHREADS before using it.

Also reorder __thread_relax and __thread_yield so that the former can
use the latter instead of repeating the same preprocessor checks.

libstdc++-v3/ChangeLog:

* include/bits/atomic_wait.h (__thread_yield()): Check
_GLIBCXX_HAS_GTHREADS before using __gthread_yield.
(__thread_relax()): Use __thread_yield() instead of repeating
the preprocessor checks for __gthread_yield.

3 years agolibstdc++: Add missing return and use reserved name
Jonathan Wakely [Mon, 15 Feb 2021 14:00:36 +0000 (14:00 +0000)]
libstdc++: Add missing return and use reserved name

The once_flag::_M_activate() function is only ever called immediately
after a call to once_flag::_M_passive(), and so in the non-gthreads case
it is impossible for _M_passive() to be true in the body of
_M_activate(). Add a check for it anyway, to avoid warnings about
missing return.

Also replace a non-reserved name with a reserved one.

libstdc++-v3/ChangeLog:

* include/std/mutex (once_flag::_M_activate()): Add explicit
return statement for passive case.
(once_flag::_M_finish(bool)): Use reserved name for parameter.

3 years agortl-ssa: Reduce the amount of temporary memory needed [PR98863]
Richard Sandiford [Mon, 15 Feb 2021 15:05:22 +0000 (15:05 +0000)]
rtl-ssa: Reduce the amount of temporary memory needed [PR98863]

The rtl-ssa code uses an on-the-side IL and needs to build that IL
for each block and RTL insn.  I'd originally not used the classical
dominance frontier method for placing phis on the basis that it seemed
like more work in this context: we're having to visit everything in
an RPO walk anyway, so for non-backedge cases we can tell immediately
whether a phi node is needed.  We then speculatively created phis for
registers that are live across backedges and simplified them later.
This avoided having to walk most of the IL twice (once to build the
initial IL, and once to link uses to phis).

However, as shown in PR98863, this leads to excessive temporary
memory in extreme cases, since we had to record the value of
every live register on exit from every block.  In that PR,
there were many registers that were live (but unused) across
a large region of code.

This patch does use the classical approach to placing phis, but tries
to use the existing DF defs information to avoid two walks of the IL.
We still use the previous approach for memory, since there is no
up-front information to indicate whether a block defines memory or not.
However, since memory is just treated as a single unified thing
(like for gimple vops), memory doesn't suffer from the same
scalability problems as registers.

With this change, fwprop no longer seems to be a memory-hog outlier
in the PR: the maximum RSS is similar with and without fwprop.

The PR also shows the problems inherent in using bitmap operations
involving the live-in and live-out sets, which in the testcase are
very large.  I've therefore tried to reduce those operations to the
bare minimum.

The patch also includes other compile-time optimisations motivated
by the PR; see the changelog for details.

I tried adding:

    for (int i = 0; i < 200; ++i)
      {
crtl->ssa = new rtl_ssa::function_info (cfun);
delete crtl->ssa;
      }

to fwprop.c to stress the code.  fwprop then took 35% of the compile
time for the problematic partition in the PR (measured on a release
build).  fwprop takes less than .5% of the compile time when running
normally.

The command:

  git diff 0b76990a9d75d97b84014e37519086b81824c307~ gcc/fwprop.c | \
    patch -p1 -R

still gives a working compiler that uses the old fwprop.c.  The compile
time with that version is very similar.

For a more reasonable testcase like optabs.ii at -O, I saw a 6.7%
compile time regression with the loop above added (i.e. creating
the info 201 times per pass instead of once per pass).  That goes
down to 4.8% with -O -g.  I can't measure a significant difference
with a normal compiler (no 200-iteration loop).

So I think that (as expected) the patch does make things a bit
slower in the normal case.  But like Richi says, peak memory usage
is harder for users to work around than slighter slower compile times.

gcc/
PR rtl-optimization/98863
* rtl-ssa/functions.h (function_info::bb_live_out_info): Delete.
(function_info::build_info): Turn into a declaration, moving the
definition to internals.h.
(function_info::bb_walker): Declare.
(function_info::create_reg_use): Likewise.
(function_info::calculate_potential_phi_regs): Take a build_info
parameter.
(function_info::place_phis, function_info::create_ebbs): Declare.
(function_info::calculate_ebb_live_in_for_debug): Likewise.
(function_info::populate_backedge_phis): Delete.
(function_info::start_block, function_info::end_block): Declare.
(function_info::populate_phi_inputs): Delete.
(function_info::m_potential_phi_regs): Move information to build_info.
* rtl-ssa/internals.h: New file.
(function_info::bb_phi_info): New class.
(function_info::build_info): Moved from functions.h.
Add a constructor and destructor.
(function_info::build_info::ebb_use): Delete.
(function_info::build_info::ebb_def): Likewise.
(function_info::build_info::bb_live_out): Likewise.
(function_info::build_info::tmp_ebb_live_in_for_debug): New variable.
(function_info::build_info::potential_phi_regs): Likewise.
(function_info::build_info::potential_phi_regs_for_debug): Likewise.
(function_info::build_info::ebb_def_regs): Likewise.
(function_info::build_info::bb_phis): Likewise.
(function_info::build_info::bb_mem_live_out): Likewise.
(function_info::build_info::bb_to_rpo): Likewise.
(function_info::build_info::def_stack): Likewise.
(function_info::build_info::old_def_stack_limit): Likewise.
* rtl-ssa/internals.inl (function_info::build_info::record_reg_def):
Remove the regno argument.  Push the previous definition onto the
definition stack where necessary.
* rtl-ssa/accesses.cc: Include internals.h.
* rtl-ssa/changes.cc: Likewise.
* rtl-ssa/blocks.cc: Likewise.
(function_info::build_info::build_info): Define.
(function_info::build_info::~build_info): Likewise.
(function_info::bb_walker): New class.
(function_info::bb_walker::bb_walker): Define.
(function_info::add_live_out_use): Convert a logarithmic-complexity
test into a linear one.  Allow the same definition to be passed
multiple times.
(function_info::calculate_potential_phi_regs): Moved from
functions.cc.  Take a build_info parameter and store the
information there instead.
(function_info::place_phis): New function.
(function_info::add_entry_block_defs): Update call to record_reg_def.
(function_info::calculate_ebb_live_in_for_debug): New function.
(function_info::add_phi_nodes): Use bb_phis to decide which
registers need phi nodes and initialize ebb_def_regs accordingly.
Do not add degenerate phis here.
(function_info::add_artificial_accesses): Use create_reg_use.
Assert that all definitions are listed in the DF LR sets.
Update call to record_reg_def.
(function_info::record_block_live_out): Record live-out register
values in the phis of successor blocks.  Use the live-out set
when processing the last block in an EBB, instead of always
using the live-in sets of successor blocks.  AND the live sets
with the set of registers that have been defined in the EBB,
rather than with all potential phi registers.  Cope correctly
with branches back to the start of the current EBB.
(function_info::start_block): New function.
(function_info::end_block): Likewise.
(function_info::populate_phi_inputs): Likewise.
(function_info::create_ebbs): Likewise.
(function_info::process_all_blocks): Rewrite into a multi-phase
process.
* rtl-ssa/functions.cc: Include internals.h.
(function_info::calculate_potential_phi_regs): Move to blocks.cc.
(function_info::init_function_data): Remove caller.
* rtl-ssa/insns.cc: Include internals.h
(function_info::create_reg_use): New function.  Lazily any
degenerate phis needed by the linear RPO view.
(function_info::record_use): Use create_reg_use.  When processing
debug uses, use potential_phi_regs and test it before checking
whether the register is live on entry to the current EBB.  Lazily
calculate ebb_live_in_for_debug.
(function_info::record_call_clobbers): Update call to record_reg_def.
(function_info::record_def): Likewise.

3 years agoFix 2 more leaks related to gen_command_line_string.
Martin Liska [Mon, 15 Feb 2021 10:28:19 +0000 (11:28 +0100)]
Fix 2 more leaks related to gen_command_line_string.

gcc/ChangeLog:

* toplev.c (init_asm_output): Free output of
gen_command_line_string function.
(process_options): Likewise.

3 years agoAdd 2 missing Param keywords.
Martin Liska [Mon, 15 Feb 2021 14:09:04 +0000 (15:09 +0100)]
Add 2 missing Param keywords.

gcc/ChangeLog:

* params.opt: Add 2 missing Param keywords.

3 years agoFix cast in df_worklist_dataflow_doublequeue
Eric Botcazou [Mon, 15 Feb 2021 09:41:44 +0000 (10:41 +0100)]
Fix cast in df_worklist_dataflow_doublequeue

The existing cast to float gives weird results in the RTL dump files
on x86 when the compiler is configured -with-fpmath=sse.

gcc/
* df-core.c (df_worklist_dataflow_doublequeue): Use proper cast.

3 years agomatch.pd: Fix up A % (cast) (pow2cst << B) simplification [PR99079]
Jakub Jelinek [Mon, 15 Feb 2021 08:16:06 +0000 (09:16 +0100)]
match.pd: Fix up A % (cast) (pow2cst << B) simplification [PR99079]

The (mod @0 (convert?@3 (power_of_two_cand@1 @2))) simplification
uses tree_nop_conversion_p (type, TREE_TYPE (@3)) condition, but I believe
it doesn't check what it was meant to check.  On convert?@3
TREE_TYPE (@3) is not the type of what it has been converted from, but
what it has been converted to, which needs to be (because it is operand
of normal binary operation) equal or compatible to type of the modulo
result and first operand - type.
I could fix that by using && tree_nop_conversion_p (type, TREE_TYPE (@1))
and be done with it, but actually most of the non-nop conversions are IMHO
ok and so we would regress those optimizations.
In particular, if we have say narrowing conversions (foo5 and foo6 in
the new testcase), I think we are fine, either the shift of the power of two
constant after narrowing conversion is still that power of two (or negation
of that) and then it will still work, or the result of narrowing conversion
is 0 and then we would have UB which we can ignore.
Similarly, widening conversions where the shift result is unsigned are fine,
or even widening conversions where the shift result is signed, but we sign
extend to a signed wider divisor, the problematic case of INT_MIN will
become x % (long long) INT_MIN and we can still optimize that to
x & (long long) INT_MAX.
What doesn't work is the case in the pr99079.c testcase, widening conversion
of a signed shift result to wider unsigned divisor, where if the shift
is negative, we end up with x % (unsigned long long) INT_MIN which is
x % 0xffffffff80000000ULL where the divisor is not a power of two and
we can't optimize that to x & 0x7fffffffULL.

So, the patch rejects only the single problematic case.

Furthermore, when the shift result is signed, we were introducing UB into
a program which previously didn't have one (well, left shift into the sign
bit is UB in some language/version pairs, but it is definitely valid in
C++20 - wonder if I shouldn't move the gcc.c-torture/execute/pr99079.c
testcase to g++.dg/torture/pr99079.C and use -std=c++20), by adding that
subtraction of 1, x % (1 << 31) in C++20 is well defined, but
x & ((1 << 31) - 1) triggers UB on the subtraction.
So, the patch performs the subtraction in the unsigned type if it isn't
wrapping.

2021-02-15  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/99079
* match.pd (A % (pow2pcst << N) -> A & ((pow2pcst << N) - 1)): Remove
useless tree_nop_conversion_p (type, TREE_TYPE (@3)) check.  Instead
require both type and TREE_TYPE (@1) to be integral types and either
type having smaller or equal precision, or TREE_TYPE (@1) being
unsigned type, or type being signed type.  If TREE_TYPE (@1)
doesn't have wrapping overflow, perform the subtraction of one in
unsigned type.

* gcc.dg/fold-modpow2-2.c: New test.
* gcc.c-torture/execute/pr99079.c: New test.

3 years agoDaily bump.
GCC Administrator [Mon, 15 Feb 2021 00:16:18 +0000 (00:16 +0000)]
Daily bump.

3 years agoFix memory leak in ipa-refernece
Jan Hubicka [Sun, 14 Feb 2021 22:24:44 +0000 (23:24 +0100)]
Fix memory leak in ipa-refernece

2021-02-14  Jan Hubicka  <hubicka@ucw.cz>
    Richard Biener  <rguether@suse.de>

PR ipa/97346
* ipa-reference.c (ipa_init): Only conditinally initialize
reference_vars_to_consider.
(propagate): Conditionally deninitialize reference_vars_to_consider.
(ipa_reference_write_optimization_summary): Sanity check that
reference_vars_to_consider is not allocated.

3 years agolibstdc++: Restore <unistd.h> in testsuite_fs.h header [PR 99096]
Jonathan Wakely [Sun, 14 Feb 2021 20:38:32 +0000 (20:38 +0000)]
libstdc++: Restore <unistd.h> in testsuite_fs.h header [PR 99096]

libstdc++-v3/ChangeLog:

PR libstdc++/99096
* testsuite/util/testsuite_fs.h: Always include <unistd.h>.

3 years agoDaily bump.
GCC Administrator [Sun, 14 Feb 2021 00:16:34 +0000 (00:16 +0000)]
Daily bump.

3 years agoRISC-V: Avoid zero/sign extend for volatile loads. Fix for 97417.
Levy Hsu [Sat, 13 Feb 2021 20:26:33 +0000 (12:26 -0800)]
RISC-V: Avoid zero/sign extend for volatile loads.  Fix for 97417.

This expands sub-word loads as a zero/sign extended load, followed by
a subreg.  This helps eliminate unnecessary zero/sign extend insns after
the load, particularly for volatiles, but also in some other cases.
Testing shows that it gives consistent code size decreases.

Tested with riscv32-elf rv32imac/ilp32 and riscv64-linux rv64gc/lp064d
builds and checks.  Some -gsplit-stack tests fail with the patch, but
this turns out to be an existing bug with the split-stack support that
I hadn't noticed before.  It isn't a bug in this patch.  Ignoring that
there are no regressions.

Committed.

gcc/
PR target/97417
* config/riscv/riscv-shorten-memrefs.c (pass_shorten_memrefs): Add
extend parameter to get_si_mem_base_reg declaration.
(get_si_mem_base_reg): Add extend parameter.  Set it.
(analyze): Pass extend arg to get_si_mem_base_reg.
(transform): Likewise.  Use it when rewriting mems.
* config/riscv/riscv.c (riscv_legitimize_move): Check for subword
loads and emit sign/zero extending load followed by subreg move.

3 years agoRISC-V: Shorten memrefs improvement, partial fix 97417.
Jim Wilson [Sat, 13 Feb 2021 20:13:08 +0000 (12:13 -0800)]
RISC-V: Shorten memrefs improvement, partial fix 97417.

We already have a check for riscv_shorten_memrefs in riscv_address_cost.
This adds the same check to riscv_rtx_costs.  Making this work also
requires a change to riscv_compressed_lw_address_p to work before reload
by checking the offset and assuming any pseudo reg is OK.  Testing shows
that this consistently gives small code size reductions.

gcc/
PR target/97417
* config/riscv/riscv.c (riscv_compressed_lw_address_p): Drop early
exit when !reload_completed.  Only perform check for compressed reg
if reload_completed.
(riscv_rtx_costs): In MEM case, when optimizing for size and
shorten memrefs, if not compressible, then increase cost.

3 years agopasses: Enable split4 with selective scheduling 2 [PR98439]
Jakub Jelinek [Sat, 13 Feb 2021 15:08:29 +0000 (16:08 +0100)]
passes: Enable split4 with selective scheduling 2 [PR98439]

As mentioned in the PR, we have 5 split passes (+ splitting during final).
split1 is before RA and is unconditional,
split2 is after RA and is gated on optimize > 0,
split3 is before sched2 and is gated on
  defined(INSN_SCHEDULING) && optimize > 0 && flag_schedule_insns_after_reload
split4 is before regstack and is gated on
  HAVE_ATTR_length && defined (STACK_REGS) && !gate (split3)
split5 is before shorten_branches and is gated on
  HAVE_ATTR_length && !defined (STACK_REGS)
and the splitting during final works only when !HAVE_ATTR_length.
STACK_REGS is a macro enabled only on i386/x86_64.

The problem with the following testcase is that split3 before sched2
is the last splitting pass for the target/command line options set,
but selective scheduling unlike normal scheduling can create new
instructions that need to be split, which means we ICE during final as
there are insns that require splitting but nothing split them.

This patch fixes it by doing split4 also when -fselective-scheduling2
is enabled on x86 and split3 has been run.  As that option isn't on
by default, it should slow down compilation only for those that enable
that option.

2021-02-13  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/98439
* recog.c (pass_split_before_regstack::gate): Enable even when
pass_split_before_sched2 is enabled if -fselective-scheduling2 is
on.

* gcc.target/i386/pr98439.c: New test.

3 years agod: Merge upstream dmd 7132b3537
Iain Buclaw [Tue, 9 Feb 2021 14:40:06 +0000 (15:40 +0100)]
d: Merge upstream dmd 7132b3537

Splits out all semantic passes for Dsymbol, Type, and TemplateParameter
nodes into Visitors in separate files, and the copyright years of all
sources have been updated.

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

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 7132b3537.
* Make-lang.in (D_FRONTEND_OBJS): Add d/dsymbolsem.o, d/semantic2.o,
d/semantic3.o, and d/templateparamsem.o.
* d-compiler.cc (Compiler::genCmain): Update calls to semantic
entrypoint functions.
* d-lang.cc (d_parse_file): Likewise.
* typeinfo.cc (make_frontend_typeinfo): Likewise.

3 years agoi386: Add combiner splitter to optimize V2SImode memory rotation [PR96166]
Jakub Jelinek [Sat, 13 Feb 2021 09:32:16 +0000 (10:32 +0100)]
i386: Add combiner splitter to optimize V2SImode memory rotation [PR96166]

Since the x86 backend enabled V2SImode vectorization (with
TARGET_MMX_WITH_SSE), slp vectorization can kick in and emit
        movq    (%rdi), %xmm1
        pshufd  $225, %xmm1, %xmm0
        movq    %xmm0, (%rdi)
instead of
        rolq    $32, (%rdi)
we used to emit (or emit when slp vectorization is disabled).
I think the rotate is both smaller and faster, so this patch adds
a combiner splitter to optimize that back.

2021-02-13  Jakub Jelinek  <jakub@redhat.com>

PR target/96166
* config/i386/mmx.md (*mmx_pshufd_1): Add a combine splitter for
swap of V2SImode elements in memory into DImode memory rotate by 32.

* gcc.target/i386/pr96166.c: New test.

3 years agoDaily bump.
GCC Administrator [Sat, 13 Feb 2021 00:16:38 +0000 (00:16 +0000)]
Daily bump.

3 years agotestsuite: Restrict gcc.dg/rtl/aarch64/multi-subreg-1.c test to aarch64 only
Jakub Jelinek [Fri, 12 Feb 2021 23:02:28 +0000 (00:02 +0100)]
testsuite: Restrict gcc.dg/rtl/aarch64/multi-subreg-1.c test to aarch64 only

2021-02-13  Jakub Jelinek  <jakub@redhat.com>

* gcc.dg/rtl/aarch64/multi-subreg-1.c: Add dg-do compile directive
and restrict the test to aarch64-*-* target only.

3 years agoc++: Seed imported bindings [PR 99039]
Nathan Sidwell [Fri, 12 Feb 2021 16:43:09 +0000 (08:43 -0800)]
c++: Seed imported bindings [PR 99039]

As mentioned in 99040's fix, we can get inter-module using decls.  If the
using decl is the only reference to an import, we'll have failed to
seed our imports leading to an assertion failure.  The fix is
straight-forwards, check binding contents when seeding imports.

gcc/cp/
* module.cc (module_state::write_cluster): Check bindings for
imported using-decls.
gcc/testsuite/
* g++.dg/modules/pr99039_a.C: New.
* g++.dg/modules/pr99039_b.C: New.

3 years agoc++: Register streamed-in decls when new [PR 99040]
Nathan Sidwell [Fri, 12 Feb 2021 14:55:49 +0000 (06:55 -0800)]
c++: Register streamed-in decls when new [PR 99040]

With modules one can have using-decls refering to their own scope.  This
is the way to export things from the GMF or from an import.  The
problem was I was using current_ns == CP_DECL_CONTEXT (decl) to
determine whether a decl should be registered in a namespace level or
not.  But that's an inadequate check and we ended up reregistering
decls and creating a circular list.  We should be registering the decl
when first encountered -- whether we bind it is orthogonal to that.

PR c++/99040
gcc/cp/
* module.cc (trees_in::decl_value): Call add_module_namespace_decl
for new namespace-scope entities.
(module_state::read_cluster): Don't call add_module_decl here.
* name-lookup.h (add_module_decl): Rename to ...
(add_module_namespace_decl): ... this.
* name-lookup.c (newbinding_bookkeeping): Move into ...
(do_pushdecl): ... here.  Its only remaining caller.
(add_module_decl): Rename to ...
(add_module_namespace_decl): ... here.  Add checking-assert for
circularity. Don't call newbinding_bookkeeping, just extern_c
checking and incomplete var checking.
gcc/testsuite/
* g++.dg/modules/pr99040_a.C: New.
* g++.dg/modules/pr99040_b.C: New.
* g++.dg/modules/pr99040_c.C: New.
* g++.dg/modules/pr99040_d.C: New.

3 years agoExpunge namespace-scope IDENTIFIER_TYPE_VALUE & global_type_name [PR 99039]
Nathan Sidwell [Thu, 11 Feb 2021 21:06:03 +0000 (13:06 -0800)]
Expunge namespace-scope IDENTIFIER_TYPE_VALUE & global_type_name [PR 99039]

IDENTIFIER_TYPE_VALUE and friends is a remnant of G++'s C origins.  It
holds elaborated types on identifier-nodes.  While this is fine for C
and for local and class-scopes in C++, it fails badly for namespaces.
In that case a marker 'global_type_node' was used, which essentially
signified 'this is a namespace-scope type *somewhere*', and you'd have
to do a regular name_lookup to find it.  As the parser and
substitution machinery has avanced over the last 25 years or so,
there's not much outside of actual name-lookup that uses that.
Amusingly the IDENTIFIER_HAS_TYPE_VALUE predicate will do an actual
name-lookup and then users would repeat that lookup to find the
now-known to be there type.

Rather late I realized that this interferes with the lazy loading of
module entities, because we were setting IDENTIFIER_TYPE_VALUE to
global_type_node.  But we could be inside some local scope where that
identifier is bound to some local type.  Not good!

Rather than add more cruft to look at an identifier's shadow stack and
alter that as necessary, this takes the approach of removing the
existing cruft.

We nuke the few places outside of name lookup that use
IDENTIFIER_TYPE_VALUE.  Replacing them with either proper name
lookups, alternative sequences, or in some cases asserting that they
(no longer) happen.  Class template instantiation was calling pushtag
after setting IDENTIFIER_TYPE_VALUE in order to stop pushtag creating
an implicit typedef and pushing it, but to get the bookkeeping it
needed.  Let's just do the bookkeeping directly.

Then we can stop having a 'bound at namespace-scope' marker at all,
which means lazy loading won't screw up local shadow stacks.  Also, it
simplifies set_identifier_type_value_with_scope, as it never needs to
inspect the scope stack.  When developing this patch, I discovered a
number of places we'd put an actual namespace-scope type on the
type_value slot, rather than global_type_node.  You might notice this
is killing at least two 'why are we doing this?' comments.

While this doesn't fix the two PRs mentioned, it is a necessary step.

PR c++/99039
PR c++/99040
gcc/cp/
* cp-tree.h (CPTI_GLOBAL_TYPE): Delete.
(global_type_node): Delete.
(IDENTIFIER_TYPE_VALUE): Delete.
(IDENTIFIER_HAS_TYPE_VALUE): Delete.
(get_type_value): Delete.
* name-lookup.h (identifier_type_value): Delete.
* name-lookup.c (check_module_override): Don't
SET_IDENTIFIER_TYPE_VALUE here.
(do_pushdecl): Nor here.
(identifier_type_value_1, identifier_type_value): Delete.
(set_identifier_type_value_with_scope): Only
SET_IDENTIFIER_TYPE_VALUE for local and class scopes.
(pushdecl_nanmespace_level): Remove shadow stack nadgering.
(do_pushtag): Use REAL_IDENTIFIER_TYPE_VALUE.
* call.c (check_dtor_name): Use lookup_name.
* decl.c (cxx_init_decl_processing): Drop global_type_node.
* decl2.c (cplus_decl_attributes): Don't SET_IDENTIFIER_TYPE_VALUE
here.
* init.c (get_type_value): Delete.
* pt.c (instantiate_class_template_1): Don't call pushtag or
SET_IDENTIFIER_TYPE_VALUE here.
(tsubst): Assert never an identifier.
(dependent_type_p): Drop global_type_node assert.
* typeck.c (error_args_num): Don't use IDENTIFIER_HAS_TYPE_VALUE
to determine ctorness.
gcc/testsuite/
* g++.dg/lookup/pr99039.C: New.

3 years agocompiler: open byte slice and string embeds using the absolute path
Michael Matloob [Fri, 12 Feb 2021 00:28:57 +0000 (19:28 -0500)]
compiler: open byte slice and string embeds using the absolute path

The paths vector contains the names of the files that the embed_files_
map is keyed by. While the code processing embed.FS values looks up
the paths in the embed_files_ map, the code processing string and byte
slice embeds tries opening the files using their names directly. Look
up the full paths in the embed_files_ map when opening them.

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

3 years agoPR c/99055 - memory leak in warn_parm_array_mismatch
Martin Sebor [Fri, 12 Feb 2021 18:18:17 +0000 (11:18 -0700)]
PR c/99055 - memory leak in warn_parm_array_mismatch

gcc/c-family/ChangeLog:

PR c/99055
* c-warn.c (warn_parm_array_mismatch): Free strings returned from
print_generic_expr_to_str.

gcc/ChangeLog:

* tree-pretty-print.c (print_generic_expr_to_str): Update comment.

3 years agolibgfortran: Fix PR95647 by changing the interfaces of operators .eq. and .ne.
Steve Kargl [Fri, 12 Feb 2021 15:58:16 +0000 (07:58 -0800)]
libgfortran: Fix PR95647 by changing the interfaces of operators .eq. and .ne.

The FE converts the old school .eq. to ==,
and then tracks the ==.  The module starts with == and so it does not
properly overload the .eq.  Reversing the interfaces fixes this.

2021-02-12  Steve Kargl <sgk@troutmask.apl.washington.edu>

libgfortran/ChangeLog:

PR libfortran/95647
* ieee/ieee_arithmetic.F90: Flip interfaces of operators .eq. to
== and .ne. to /= .

gcc/testsuite/ChangeLog:

PR libfortran/95647
* gfortran.dg/ieee/ieee_12.f90: New test.

3 years agortl-ssa: Use right obstack for temporary allocation
Richard Sandiford [Fri, 12 Feb 2021 15:54:49 +0000 (15:54 +0000)]
rtl-ssa: Use right obstack for temporary allocation

I noticed while working on PR98863 that we were using the main
obstack to allocate temporary uses.  That was safe, but represents
a kind of local memory leak.

gcc/
* rtl-ssa/accesses.cc (function_info::make_use_available): Use
m_temp_obstack rather than m_obstack to allocate the temporary use.

3 years agodf: Record all definitions in DF_LR_BB_INFO->def [PR98863]
Richard Sandiford [Fri, 12 Feb 2021 15:54:48 +0000 (15:54 +0000)]
df: Record all definitions in DF_LR_BB_INFO->def [PR98863]

df_lr_bb_local_compute has:

      FOR_EACH_INSN_INFO_DEF (def, insn_info)
/* If the def is to only part of the reg, it does
   not kill the other defs that reach here.  */
if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))

However, as noted in the comment in the patch and below, almost all
partial definitions have an associated use.  This means that the
confluence function:

  IN = (OUT & ~DEF) | USE

is unaffected by whether partial definitions are in DEF or not.

Even though the choice doesn't matter for the LR problem itself,
it's IMO much more convenient for consumers if DEF contains all the
definitions in the block.  The only pre-RTL-SSA code that tries to
consume DEF directly is shrink-wrap.c, which already has to work
around the incompleteness of the information:

  /* DF_LR_BB_INFO (bb)->def does not comprise the DF_REF_PARTIAL and
     DF_REF_CONDITIONAL defs.  So if DF_LIVE doesn't exist, i.e.
     at -O1, just give up searching NEXT_BLOCK.  */

I hit the same problem when trying to fix the RTL-SSA part of PR98863.

This patch treats partial definitions as both a def and a use,
just like the df_ref records almost always do.

To show that partial definitions almost always have uses:

  DF_REF_CONDITIONAL:

    Added by:

      case COND_EXEC:
df_defs_record (collection_rec, COND_EXEC_CODE (x),
bb, insn_info, DF_REF_CONDITIONAL);
break;

    Later, df_get_conditional_uses creates uses for all DF_REF_CONDITIONAL
    definitions.

  DF_REF_PARTIAL:

    In total, there are 4 locations at which we add partial definitions.

    Case 1:

      if (GET_CODE (dst) == STRICT_LOW_PART)
{
  flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL | DF_REF_STRICT_LOW_PART;

  loc = &XEXP (dst, 0);
  dst = *loc;
}

    Corresponding use:

      case STRICT_LOW_PART:
{
  rtx *temp = &XEXP (dst, 0);
  /* A strict_low_part uses the whole REG and not just the
   SUBREG.  */
  dst = XEXP (dst, 0);
  df_uses_record (collection_rec,
  (GET_CODE (dst) == SUBREG) ? &SUBREG_REG (dst) : temp,
  DF_REF_REG_USE, bb, insn_info,
  DF_REF_READ_WRITE | DF_REF_STRICT_LOW_PART);
}
break;

    Case 2:

      if (GET_CODE (dst) == ZERO_EXTRACT)
{
  flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL | DF_REF_ZERO_EXTRACT;

  loc = &XEXP (dst, 0);
  dst = *loc;
}

    Corresponding use:

      case ZERO_EXTRACT:
{
  df_uses_record (collection_rec, &XEXP (dst, 1),
  DF_REF_REG_USE, bb, insn_info, flags);
  df_uses_record (collection_rec, &XEXP (dst, 2),
  DF_REF_REG_USE, bb, insn_info, flags);
  if (GET_CODE (XEXP (dst,0)) == MEM)
    df_uses_record (collection_rec, &XEXP (dst, 0),
    DF_REF_REG_USE, bb, insn_info,
    flags);
  else
    df_uses_record (collection_rec, &XEXP (dst, 0),
    DF_REF_REG_USE, bb, insn_info,
    DF_REF_READ_WRITE | DF_REF_ZERO_EXTRACT);
----------------------------^^^^^^^^^^^^^^^^^
}
break;

    Case 3:

      else if (GET_CODE (dst) == SUBREG && REG_P (SUBREG_REG (dst)))
{
  if (read_modify_subreg_p (dst))
    flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL;

  flags |= DF_REF_SUBREG;

  df_ref_record (DF_REF_REGULAR, collection_rec,
 dst, loc, bb, insn_info, DF_REF_REG_DEF, flags);
}

    Corresponding use:

      case SUBREG:
if (read_modify_subreg_p (dst))
  {
    df_uses_record (collection_rec, &SUBREG_REG (dst),
    DF_REF_REG_USE, bb, insn_info,
    flags | DF_REF_READ_WRITE | DF_REF_SUBREG);
    break;
  }

    Case 4:

      /*  If this is a multiword hardreg, we create some extra
  datastructures that will enable us to easily build REG_DEAD
  and REG_UNUSED notes.  */
      if (collection_rec
  && (endregno != regno + 1) && insn_info)
{
  /* Sets to a subreg of a multiword register are partial.
     Sets to a non-subreg of a multiword register are not.  */
  if (GET_CODE (reg) == SUBREG)
    ref_flags |= DF_REF_PARTIAL;
  ref_flags |= DF_REF_MW_HARDREG;

    Corresponding use:

      None.  However, this case should be rare to non-existent on most
      targets, and the current handling seems suspect.  See the comment
      in the patch for more details.

gcc/
* df-problems.c (df_lr_bb_local_compute): Treat partial definitions
as read-modify operations.

gcc/testsuite/
* gcc.dg/rtl/aarch64/multi-subreg-1.c: New test.

3 years agolibstdc++: Re-enable workaround for _wstat64 bug, again [PR 88881]
Jonathan Wakely [Wed, 10 Feb 2021 16:51:34 +0000 (16:51 +0000)]
libstdc++: Re-enable workaround for _wstat64 bug, again [PR 88881]

I forgot that the workaround is present in both filesystem::status and
filesystem::symlink_status. This restores it in the latter.

libstdc++-v3/ChangeLog:

PR libstdc++/88881
* src/c++17/fs_ops.cc (fs::symlink_status): Re-enable workaround.

3 years agolibstdc++: Fix filesystem::rename on Windows [PR 98985]
Jonathan Wakely [Fri, 12 Feb 2021 15:13:02 +0000 (15:13 +0000)]
libstdc++: Fix filesystem::rename on Windows [PR 98985]

The _wrename function won't overwrite an existing file, so use
MoveFileEx instead. That allows renaming directories over files, which
POSIX doesn't allow, so check for that case explicitly and report an
error.

Also document the deviation from the expected behaviour, and add a test
for filesystem::rename which was previously missing.

The Filesystem TS experimental::filesystem::rename doesn't have that
extra code to handle directories correctly, so the relevant parts of the
new test are not run on Windows.

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2014.xml: Document implementation
specific properties of std::experimental::filesystem::rename.
* doc/xml/manual/status_cxx2017.xml: Document implementation
specific properties of std::filesystem::rename.
* doc/html/*: Regenerate.
* src/c++17/fs_ops.cc (fs::rename): Implement correct behaviour
for directories on Windows.
* src/filesystem/ops-common.h (__gnu_posix::rename): Use
MoveFileExW on Windows.
* testsuite/27_io/filesystem/operations/rename.cc: New test.
* testsuite/experimental/filesystem/operations/rename.cc: New test.

3 years agolibstdc++: Make "nonexistent" paths less predictable in filesystem tests
Jonathan Wakely [Fri, 12 Feb 2021 15:13:02 +0000 (15:13 +0000)]
libstdc++: Make "nonexistent" paths less predictable in filesystem tests

The helper function for creating new paths doesn't work well on Windows,
because the PID of a process started by Wine is very consistent and so
the same path gets created each time.

libstdc++-v3/ChangeLog:

* testsuite/util/testsuite_fs.h (nonexistent_path): Add
random number to the path.

3 years agolibstdc++: Include scope ID in net::internet::address_v6::to_string()
Jonathan Wakely [Fri, 12 Feb 2021 15:08:29 +0000 (15:08 +0000)]
libstdc++: Include scope ID in net::internet::address_v6::to_string()

libstdc++-v3/ChangeLog:

* include/experimental/internet (address_v6::to_string): Include
scope ID in string.
* testsuite/experimental/net/internet/address/v6/members.cc:
Test to_string() results.

3 years agolibstdc++: Fix errors in <experimental/internet>
Jonathan Wakely [Fri, 12 Feb 2021 13:01:20 +0000 (13:01 +0000)]
libstdc++: Fix errors in <experimental/internet>

libstdc++-v3/ChangeLog:

* include/experimental/internet (address_v6::any): Avoid using
memcpy in constexpr function.
(address_v6::loopback): Likewise.
(make_address_v6): Fix missing return statements on error paths.
* include/experimental/io_context: Avoid -Wdangling-else
warning.
* testsuite/experimental/net/internet/address/v4/members.cc:
Remove unused variables.
* testsuite/experimental/net/internet/address/v6/members.cc:
New test.

3 years agolibstdc++: Add unused attributes to shared_ptr functions
Jonathan Wakely [Fri, 12 Feb 2021 10:36:18 +0000 (10:36 +0000)]
libstdc++: Add unused attributes to shared_ptr functions

This avoids some warnings when building with -fno-rtti because the
function parameters are only used when RTTI is enabled.

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_base.h (__shared_ptr::_M_get_deleter):
Add unused attribute to parameter.
* src/c++11/shared_ptr.cc (_Sp_make_shared_tag::_S_eq):
Likewise.