platform/upstream/gcc.git
3 years agoc++: Fix attr-lambda3.C
Jason Merrill [Sun, 28 Feb 2021 14:17:10 +0000 (09:17 -0500)]
c++: Fix attr-lambda3.C

Some testcase for a change I was testing had an unnecessary ; at the end of
a line that caused a test failure on the 10 branch, so I mistakenly removed
it from this one.  Oops.

gcc/testsuite/ChangeLog:

* g++.dg/ext/attr-lambda3.C: Add missing ;

3 years agofortran: Fix up wording of 3 OpenMP diagnostic messages [PR99303]
Jakub Jelinek [Sun, 28 Feb 2021 10:16:33 +0000 (11:16 +0100)]
fortran: Fix up wording of 3 OpenMP diagnostic messages [PR99303]

As reported in the PR, some diagnostic messages need wording improvements.

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

PR fortran/99303
* openmp.c (gfc_omp_requires_add_clause): Fix up diagnostic message
wordings.
(resolve_omp_clauses): Likewise.

3 years agofortran: Replace double space in diagnostic with a single one [PR99300]
Jakub Jelinek [Sun, 28 Feb 2021 10:14:24 +0000 (11:14 +0100)]
fortran: Replace double space in diagnostic with a single one [PR99300]

The diagnostic had "  " in it instead of just " ".

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

PR fortran/99300
* frontend-passes.c (doloop_code): Replace double space in diagnostics
with a single space.

3 years agotypos: Fix various typos - mainly misspelled reference* [PR99304]
Jakub Jelinek [Sun, 28 Feb 2021 10:10:44 +0000 (11:10 +0100)]
typos: Fix various typos - mainly misspelled reference* [PR99304]

The PR is about a typo in handle_malloc_attribute diagnostic message,
but grepping around I found many other cases and while fixing those I've
noticed a couple of other typos.

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

PR c/99304
* ipa.c (symbol_table::remove_unreachable_nodes): Fix a comment
typo - referneced -> referenced.
* tree.c (component_ref_size): Fix comment typo -
refernce -> reference.
* tree-ssa-alias.c (access_path_may_continue_p): Fix comment typo -
traling -> trailing.
(aliasing_component_refs_p): Fix comment typos -
refernce -> reference and refernece -> reference and
traling -> trailing.
(nonoverlapping_refs_since_match_p): Fix comment typo -
referneces -> references.
* doc/invoke.texi (--param modref-max-bases): Fix a typo -
referneces -> references.
gcc/c-family/
* c-attribs.c (handle_malloc_attribute): Fix a typo in inform
message - refernced -> referenced.  Remove superfluous space before
closing paren of function calls.
gcc/lto/
* lto-symtab.c (lto_symtab_prevailing_virtual_decl): Fix comment
typos - refernced -> referenced and
devirtualizaiton -> devirtualization.

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

3 years agoc++: Allow GNU attributes before lambda -> [PR90333]
Jason Merrill [Fri, 26 Feb 2021 10:45:02 +0000 (05:45 -0500)]
c++: Allow GNU attributes before lambda -> [PR90333]

In my 9.3/10 patch for 90333 I allowed attributes between [] and (), and
after the trailing return type, but not in the place that GCC 8 expected
them, and we've gotten several bug reports about that.  So let's allow them
there, as well.

gcc/cp/ChangeLog:

PR c++/90333
* parser.c (cp_parser_lambda_declarator_opt): Accept GNU attributes
between () and ->.

gcc/testsuite/ChangeLog:

PR c++/90333
* g++.dg/ext/attr-lambda3.C: New test.

3 years agoDarwin : Update a disgnostic message [NFC].
Iain Sandoe [Sat, 27 Feb 2021 14:48:12 +0000 (14:48 +0000)]
Darwin : Update a disgnostic message [NFC].

The avoids a contraction and a format diagnostic warning.

gcc/ChangeLog:

* config/host-darwin.c (darwin_gt_pch_use_address): Modify
diagnostic message to avoid use of a contraction and format
warning.

3 years agolibgomp, testsuite : Require alias support for PR96390 testcase.
Iain Sandoe [Sat, 27 Feb 2021 14:52:20 +0000 (14:52 +0000)]
libgomp, testsuite : Require alias support for PR96390 testcase.

This fails everywhere on Darwin, which does not have support for
symbol aliases.  Add a dg-require-alias to UNSUPPORT it.

libgomp/ChangeLog:

* testsuite/libgomp.c-c++-common/pr96390.c: Require alias
support from the target.

3 years agolibstdc++: Fix conversions from date types to integers [PR 99301]
Jonathan Wakely [Sat, 27 Feb 2021 12:50:53 +0000 (12:50 +0000)]
libstdc++: Fix conversions from date types to integers [PR 99301]

The conversions to integer types are explicit, so need to use the
correct type. Converting to uint32_t only works if that is the same type
as unsigned.

libstdc++-v3/ChangeLog:

PR libstdc++/99301
* include/std/chrono (year_month_day::_M_days_since_epoch()):
Convert chrono::month and chrono::day to unsigned before
converting to uint32_t.

3 years agogcse, ipa-devirt: Use %wd/%wu instead of HOST_WIDE_INT_PRINT* in diagnostics [PR99288]
Jakub Jelinek [Sat, 27 Feb 2021 09:43:28 +0000 (10:43 +0100)]
gcse, ipa-devirt: Use %wd/%wu instead of HOST_WIDE_INT_PRINT* in diagnostics [PR99288]

HOST_WIDE_INT_PRINT* in the string literals of warning/error/inform etc.
make those messages non-translatable, and we have a perfectly fine
alternative when not using system *printf - %w{d,u}.

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

PR other/99288
* gcse.c (gcse_or_cprop_is_too_expensive): Use %wu instead of
HOST_WIDE_INT_PRINT_UNSIGNED in warning format string.
* ipa-devirt.c (ipa_odr_read_section): Use %wd instead of
HOST_WIDE_INT_PRINT_DEC in inform format string.  Fix comment
typos.

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

3 years agoanalyzer: implement exploded_path copy ctor
David Malcolm [Fri, 26 Feb 2021 21:35:32 +0000 (16:35 -0500)]
analyzer: implement exploded_path copy ctor

gcc/analyzer/ChangeLog:
* engine.cc (exploded_path::exploded_path): New copy-ctor.
* exploded-graph.h (exploded_path::operator=): Drop decl.

3 years agoUpdate gcc de.po.
Joseph Myers [Fri, 26 Feb 2021 19:32:34 +0000 (19:32 +0000)]
Update gcc de.po.

* de.po: Update.

3 years agorevert just-added duplicate fpic target requirement
Alexandre Oliva [Fri, 26 Feb 2021 15:27:55 +0000 (12:27 -0300)]
revert just-added duplicate fpic target requirement

A moment after pushing the previous patch, I noticed the fpic target
requirement markers had already been added to some of the files in the
patch from long ago that I've just contributed.  This patch reverts
the duplicates.

for  gcc/testsuite/ChangeLog

* gcc.target/powerpc/pr67789.c: Revert fpic target requirement
duplication.
* gcc.target/powerpc/pr83629.c: Likewise.
* gcc.target/powerpc/pr84112.c: Likewise.

3 years agoAdd missing dg-require-effective-target fpic directives to powerpc tests
Olivier Hainque [Fri, 26 Feb 2021 15:09:27 +0000 (12:09 -0300)]
Add missing dg-require-effective-target fpic directives to powerpc tests

for  gcc/testsuite/ChangeLog

* gcc.target/powerpc/compress-float-ppc-pic.c: Add
dg-require-effective-target fpic.
* gcc.target/powerpc/ppc-eabi.c: Likewise.
* gcc.target/powerpc/pr26350.c: Likewise.
* gcc.target/powerpc/pr67789.c: Likewise.
* gcc.target/powerpc/pr79439-1.c: Likewise.
* gcc.target/powerpc/pr79439-2.c: Likewise.
* gcc.target/powerpc/pr79439-3.c: Likewise.
* gcc.target/powerpc/pr83629.c: Likewise.
* gcc.target/powerpc/pr84112.c: Likewise.

3 years agomiddle-end/99281 - avoid bitfield stores into addressable types
Richard Biener [Fri, 26 Feb 2021 07:45:36 +0000 (08:45 +0100)]
middle-end/99281 - avoid bitfield stores into addressable types

This avoids doing bitfield stores into the return object of calls
when using return-slot optimization and the type is addressable.
Instead we have to pass down the original target RTX to the call
expansion which otherwise tries to create a new temporary.

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

PR middle-end/99281
* expr.c (store_field): For calls with return-slot optimization
and addressable return type expand the store directly.

* g++.dg/pr99218.C: New testcase.

3 years agoc++: Implement P1102R2 - Down with ()!
Jakub Jelinek [Fri, 26 Feb 2021 09:44:52 +0000 (10:44 +0100)]
c++: Implement P1102R2 - Down with ()!

The following patch implements P1102R2.
For attributes, we have already attribute parsing before the parameter
declarations and so when that is omitted, if the attributes are first we
already accept it.

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

* parser.c (cp_parser_lambda_declarator_opt): Implement
P1102R2 - Down with ()! Make ()s optional before lambda specifiers
for -std={c,gnu}++2b or with pedwarn in earlier versions.

* g++.dg/cpp23/lambda-specifiers1.C: New test.

3 years agoc++: Fix operator() lookup in lambdas [PR95451]
Jakub Jelinek [Fri, 26 Feb 2021 09:43:28 +0000 (10:43 +0100)]
c++: Fix operator() lookup in lambdas [PR95451]

During name lookup, name-lookup.c uses:
            if (!(!iter->type && HIDDEN_TYPE_BINDING_P (iter))
                && (bool (want & LOOK_want::HIDDEN_LAMBDA)
                    || !is_lambda_ignored_entity (iter->value))
                && qualify_lookup (iter->value, want))
              binding = iter->value;
Unfortunately as the following testcase shows, this doesn't work in
generic lambdas, where we on the auto b = ... lambda ICE and on the
auto d = lambda reject it even when it should be valid.  The problem
is that the binding doesn't have a FUNCTION_DECL with
LAMBDA_FUNCTION_P for the operator(), but an OVERLOAD with
TEMPLATE_DECL for such FUNCTION_DECL.

The following patch fixes that in is_lambda_ignored_entity, other
possibility would be to do that before calling is_lambda_ignored_entity
in name-lookup.c.

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

PR c++/95451
* lambda.c (is_lambda_ignored_entity): Before checking for
LAMBDA_FUNCTION_P, use OVL_FIRST.  Drop FUNCTION_DECL check.

* g++.dg/cpp1y/lambda-generic-95451.C: New test.

3 years agoc/99275 - fix missing space in diagnostic
Richard Biener [Fri, 26 Feb 2021 07:50:17 +0000 (08:50 +0100)]
c/99275 - fix missing space in diagnostic

This fixes a missing space as reported by translators.

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

PR c/99275
* builtins.c (warn_string_no_nul): Fix diagnostic formatting.

3 years agoc++: Fix class NTTP constness handling [PR98810]
Jason Merrill [Thu, 25 Feb 2021 21:47:53 +0000 (16:47 -0500)]
c++: Fix class NTTP constness handling [PR98810]

Here, when substituting still-dependent args into an alias template, we see
a non-const type because the default argument is non-const, and is not a
template parm object because it's still dependent.

gcc/cp/ChangeLog:

PR c++/98810
* pt.c (tsubst_copy) [VIEW_CONVERT_EXPR]: Add const
to a class non-type template argument that needs it.

gcc/testsuite/ChangeLog:

PR c++/98810
* g++.dg/cpp2a/nontype-class-defarg1.C: New test.

3 years agors6000: Fix ICE in rs6000_init_builtins when compiling with -mcpu=440 [PR99279]
Peter Bergner [Fri, 26 Feb 2021 03:35:28 +0000 (21:35 -0600)]
rs6000: Fix ICE in rs6000_init_builtins when compiling with -mcpu=440 [PR99279]

The initialization of compat builtins assumes the builtin we are creating
a compatible builtin for exists and ICEs if it doesn't.  However, there are
valid reasons why some builtins are disabled for a particular compile.
In this case, the MMA builtins are disabled for -mcpu=440 (and other cpus),
so instead of ICEing, we should just skip adding the MMA compat builtin.

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

gcc/
PR target/99279
* config/rs6000/rs6000-call.c (rs6000_init_builtins): Replace assert
with an "if" test.

3 years agoOptimize pcrel access of globals
Aaron Sawdey [Wed, 7 Oct 2020 23:27:45 +0000 (18:27 -0500)]
Optimize pcrel access of globals

This patch implements a RTL pass that looks for pc-relative loads of the
address of an external variable using the PCREL_GOT relocation and a
single load or store that uses that external address.

Produced by a cast of thousands:
 * Michael Meissner
 * Peter Bergner
 * Bill Schmidt
 * Alan Modra
 * Segher Boessenkool
 * Aaron Sawdey

gcc/ChangeLog:

* config.gcc: Add rs6000-pcrel-opt.o.
* config/rs6000/rs6000-pcrel-opt.c: New file.
* config/rs6000/pcrel-opt.md: New file.
* config/rs6000/predicates.md: Add d_form_memory predicate.
* config/rs6000/rs6000-cpus.def: Add OPTION_MASK_PCREL_OPT.
* config/rs6000/rs6000-passes.def: Add pass_pcrel_opt.
* config/rs6000/rs6000-protos.h: Add reg_to_non_prefixed(),
pcrel_opt_valid_mem_p(), output_pcrel_opt_reloc(),
and make_pass_pcrel_opt().
* config/rs6000/rs6000.c (reg_to_non_prefixed): Make global.
(rs6000_option_override_internal): Add pcrel-opt.
(rs6000_delegitimize_address): Support pcrel-opt.
(rs6000_opt_masks): Add pcrel-opt.
(pcrel_opt_valid_mem_p): New function.
(reg_to_non_prefixed): Make global.
(rs6000_asm_output_opcode): Reset prepend_p_to_next_insn.
(output_pcrel_opt_reloc): New function.
* config/rs6000/rs6000.md (loads_extern_addr): New attr.
(pcrel_extern_addr): Set loads_extern_addr.
Add include for pcrel-opt.md.
* config/rs6000/rs6000.opt: Add -mpcrel-opt.
* config/rs6000/t-rs6000: Add rules for pcrel-opt.c and
pcrel-opt.md.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pcrel-opt-inc-di.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-df.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-di.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-hi.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-qi.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-sf.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-si.c: New test.
* gcc.target/powerpc/pcrel-opt-ld-vector.c: New test.
* gcc.target/powerpc/pcrel-opt-st-df.c: New test.
* gcc.target/powerpc/pcrel-opt-st-di.c: New test.
* gcc.target/powerpc/pcrel-opt-st-hi.c: New test.
* gcc.target/powerpc/pcrel-opt-st-qi.c: New test.
* gcc.target/powerpc/pcrel-opt-st-sf.c: New test.
* gcc.target/powerpc/pcrel-opt-st-si.c: New test.
* gcc.target/powerpc/pcrel-opt-st-vector.c: New test.

3 years ago[PATCH v4 1/2] MIPS: unaligned load: use SImode for SUBREG if OK (PR98996) [PATCH...
YunQiang Su [Fri, 26 Feb 2021 02:55:10 +0000 (19:55 -0700)]
[PATCH v4 1/2] MIPS: unaligned load: use SImode for SUBREG if OK (PR98996) [PATCH v4 2/2] ada: add 128bit operation for MIPS N32 and N64

gcc/ChangeLog:

PR target/98996
* config/mips/mips.c (mips_expand_ext_as_unaligned_load):
If TARGET_64BIT and dest is SUBREG, we check the width, if it
equal to SImode, we use SImode operation, just like what we are
doing for REG one.

gcc/ada/ChangeLog:

PR ada/98996
* Makefile.rtl: <mips*-*-linux*>
add 128Bit operation file for MIPS N64 and N32 to
LIBGNAT_TARGET_PAIRS and EXTRA_GNATRTL_NONTASKING_OBJS

3 years agobuiltins: Fix typos in warn_for_access [PR99278]
Marek Polacek [Fri, 26 Feb 2021 00:12:52 +0000 (19:12 -0500)]
builtins: Fix typos in warn_for_access [PR99278]

gcc/ChangeLog:

* builtins.c (warn_for_access): Fix typos.

3 years agolibgo: ensure memmove, memset 8 byte atomicity on ppc64x
Lynn Boger [Mon, 22 Feb 2021 15:12:01 +0000 (09:12 -0600)]
libgo: ensure memmove, memset 8 byte atomicity on ppc64x

Go requires that pointer moves are done 8 bytes at a time,
but gccgo uses libc's memmove and memset which does not require
that, and there are some cases where an 8 byte move might be
done as 4+4.

To enforce 8 byte moves for memmove and memset, this adds a
C implementation in libgo/runtime for memmove and memset to be
used on ppc64le and ppc64. Asm implementations were considered
but discarded to avoid different implementations for different
target ISAs.

Fixes golang/go#41428

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

3 years agoanalyzer: eliminate dedupe_candidate [PR96374]
David Malcolm [Fri, 26 Feb 2021 01:00:12 +0000 (20:00 -0500)]
analyzer: eliminate dedupe_candidate [PR96374]

In gcc/analyzer/diagnostic-manager.cc the code partitions
saved_diagnostic instances by dedupe_key, and tries to find the "best"
saved_diagnostic for each dedupe_key.

Ideally we would find the shortest feasible path for each
saved_diagnostic and pick the winner in each deduplication set.

Currently we merely approximate that by finding the shortest path for
each saved_diagnostic, and checking to see if it feasible, rejecting
the saved_diagnostic if it is not.  The "shortest path, or nothing if
it's infeasible" is not the same as the "shortest feasible path", and
this leads to false negatives, where we reject valid diagnostics,
tracked as PR analyzer/96374.

I have been attempting various fixes for this, but in doing so I
found that the existing structure of the code makes things unnecessarily
awkward: each dedupe_set had a a dedupe_candidate which stored the
best epath for that set, creating it from the shortest path when that
dedupe_candidate was constructed.

This patch eliminates the dedupe_candidate, instead storing the best
epath for each saved_diagnostic within the saved_diagnostic itself,
along with any feasibility_problem, and eliminating a redundant "status"
field.  The logic for finding the best epath is moved to a new
epath_finder::get_best_epath subroutine, introducing an epath_finder
class to give a place to cache state.

This patch merely copies over the existing logic to
epath_finder::get_best_epath, so no functional change is intended,
but the patch simplifies the logic and makes it much easier to
experiment with alternate implementations as I try to fix
PR analyzer/96374.

I attempted another version of this patch in which I added a dedupe_set
class and partitioned saved_diagnostics into them as the diagnostics were
added, but in this earlier iteration of the patch there were regressions
e.g. from gcc.dg/analyzer/zlib-4.c where 4 deduplication sets became 3.
The issue was that the deduplication logic needs source locations, which
need gimple statements, and the stmt_finder needs epaths to run.  Finding
the epaths needs the full egraph (as opposed to the egraph in its state
at the time when the diagnostic is saved).  Hence the partitioning needs to
happen after the egraph is fully explored.  I backed up the earlier patch
kit to:
  https://dmalcolm.fedorapeople.org/gcc/2021-02-23/feasibility-v0.3-relative-to-72d78655a91bb2f89ac4432cfd6374380d6f9987/

gcc/analyzer/ChangeLog:
PR analyzer/96374
* diagnostic-manager.cc (class epath_finder): New.
(epath_finder::get_best_epath): New.
(saved_diagnostic::saved_diagnostic): Update for replacement of
m_state and m_epath_length with m_best_epath.
(saved_diagnostic::~saved_diagnostic): Delete m_best_epath.
(saved_diagnostic::to_json): Update "path_length" to be optional.
(saved_diagnostic::calc_best_epath): New, based on
dedupe_winners::add and parts of dedupe_key::dedupe_key.
(saved_diagnostic::get_epath_length): New.
(saved_diagnostic::add_duplicate): New.
(dedupe_key::dedupe_key): Drop epath param.  Move invocation of
stmt_finder to saved_diagnostic::calc_best_epath.
(class dedupe_candidate): Delete.
(class dedupe_hash_map_traits): Update to use saved_diagnotic *
rather than dedupe_candidate * as the value_type/compare_type.
(dedupe_winners::~dedupe_winners): Don't delete the values.
(dedupe_winners::add): Convert param from shortest_exploded_paths to
epath_finder.  Drop "eg" param.  Drop dedupe_candidate, moving
path generation and feasiblity checking to
epath_finder::get_best_epath.  Update winner-selection for move
of epaths from dedupe_candidate to saved_diagnostic.
(dedupe_winners::emit_best):  Update for removal of class
dedupe_candidate.
(dedupe_winners::map_t): Update to use saved_diagnotic * rather
than dedupe_candidate * as the value_type/compare_type.
(diagnostic_manager::emit_saved_diagnostics): Move
shortest_exploded_paths instance into epath_finder and pass that
around instead.
(diagnostic_manager::emit_saved_diagnostic): Drop epath, stmt
and num_dupes params, instead getting these from the
saved_diagnostic.  Use correct location in inform_n call.
* diagnostic-manager.h (class epath_finder): New forward decl.
(saved_diagnostic::status): Drop enum.
(saved_diagnostic::set_feasible): Drop.
(saved_diagnostic::set_infeasible): Drop.
(saved_diagnostic::get_status): Drop.
(saved_diagnostic::calc_best_epath): New decl.
(saved_diagnostic::get_best_epath): New decl.
(saved_diagnostic::get_epath_length): New decl.
(saved_diagnostic::set_epath_length): Drop.
(saved_diagnostic::get_epath_length): Drop inline implementation.
(saved_diagnostic::add_duplicate): New.
(saved_diagnostic::get_num_dupes): New.
(saved_diagnostic::m_d): Document ownership.
(saved_diagnostic::m_trailing_eedge): Make const.
(saved_diagnostic::m_status): Drop field.
(saved_diagnostic::m_epath_length): Drop field.
(saved_diagnostic::m_best_epath): New field.
(saved_diagnostic::m_problem): Document ownership.
(saved_diagnostic::m_duplicates): New field.
(diagnostic_manager::emit_saved_diagnostic): Drop params epath,
stmt, and num_dupes.
* engine.cc (exploded_graph_annotator::print_saved_diagnostic):
Update for changes to saved_diagnostic class.
* exploded-graph.h (exploded_path::feasible_p): Drop unused
overloaded decl.

3 years agoc++: abbreviated function template return type rewriting [PR98990]
Patrick Palka [Fri, 26 Feb 2021 00:55:43 +0000 (19:55 -0500)]
c++: abbreviated function template return type rewriting [PR98990]

When an abbreviated function template has a complex placeholder return
type such auto& or auto**, the level adjustment performed by
splice_late_return_type directly replaces the 'auto' inside the original
return type with the level-adjusted 'auto', but that breaks
TYPE_CANONICAL caching.  Instead, we should rebuild the entire return
type using the adjusted 'auto'.

This patch makes this happen by tsubsting the original return type with
an argument vector that maps the original 'auto' to the adjusted 'auto'.
In passing, this patch also reverts the misguided changes to
find_type_usage in r10-6571 that made find_type_usage return a tree*
instead of a tree so as to discourage this kind of in-place type
modification.

It occurred to me that the constraint also needs to be rebuilt so that
it refers to the adjusted 'auto', but this oversight doesn't seem to
cause any issues at the moment due to how do_auto_deduction "manually"
substitutes the 'auto' inside the constraint before performing
satisfaction.  So this'll be fixed later as part of a rework of
placeholder type constraint checking.

gcc/cp/ChangeLog:

PR c++/98990
* pt.c (splice_late_return_type): Rebuild the entire return type
if we have to adjust the level of an auto within.
(type_uses_auto): Adjust call to find_type_usage.
* type-utils.h (find_type_usage): Revert r10-6571 change that
made this function return a pointer to the auto node.

gcc/testsuite/ChangeLog:

PR c++/98990
* g++.dg/concepts/abbrev8.C: New test.

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

3 years agoopenmp: Fix intermittent hanging of task-detach-6 libgomp tests [PR98738]
Kwok Cheung Yeung [Thu, 21 Jan 2021 13:38:47 +0000 (05:38 -0800)]
openmp: Fix intermittent hanging of task-detach-6 libgomp tests [PR98738]

This adds support for the task detach clause to taskwait and taskgroup, and
simplifies the handling of the detach clause by moving most of the extra
handling required for detach tasks to omp_fulfill_event.

2021-02-25  Kwok Cheung Yeung  <kcy@codesourcery.com>
    Jakub Jelinek  <jakub@redhat.com>

libgomp/

PR libgomp/98738
* libgomp.h (enum gomp_task_kind): Add GOMP_TASK_DETACHED.
(struct gomp_task): Replace detach and completion_sem fields with
union containing completion_sem and detach_team.  Add deferred_p
field.
(struct gomp_team): Remove task_detach_queue.
* task.c: Include assert.h.
(gomp_init_task): Initialize deferred_p and completion_sem fields.
Rearrange initialization order of fields.
(task_fulfilled_p): Delete.
(GOMP_task): Use address of task as the event handle.  Remove
initialization of detach field.  Initialize deferred_p field.
Use automatic local for completion_sem.  Initialize detach_team field
for deferred tasks.
(gomp_barrier_handle_tasks): Remove handling of task_detach_queue.
Set kind of suspended detach task to GOMP_TASK_DETACHED and
decrement task_running_count.  Move finish_cancelled block out of
else branch.  Relocate call to gomp_team_barrier_done.
(GOMP_taskwait): Handle tasks with completion events that have not
been fulfilled.
(GOMP_taskgroup_end): Likewise.
(omp_fulfill_event): Use address of task as event handle.  Post to
completion_sem for undeferred tasks.  Clear detach_team if task
has not finished.  For finished tasks, handle post-execution tasks,
call gomp_team_barrier_wake if necessary, and free task.
* team.c (gomp_new_team): Remove initialization of task_detach_queue.
(free_team): Remove free of task_detach_queue.
* testsuite/libgomp.c-c++-common/task-detach-1.c: Fix formatting.
* testsuite/libgomp.c-c++-common/task-detach-2.c: Fix formatting.
* testsuite/libgomp.c-c++-common/task-detach-3.c: Fix formatting.
* testsuite/libgomp.c-c++-common/task-detach-4.c: Fix formatting.
* testsuite/libgomp.c-c++-common/task-detach-5.c: Fix formatting.
Change data-sharing of detach events on enclosing parallel to private.
* testsuite/libgomp.c-c++-common/task-detach-6.c: Likewise.  Remove
taskwait directive.
* testsuite/libgomp.c-c++-common/task-detach-7.c: New.
* testsuite/libgomp.c-c++-common/task-detach-8.c: New.
* testsuite/libgomp.c-c++-common/task-detach-9.c: New.
* testsuite/libgomp.c-c++-common/task-detach-10.c: New.
* testsuite/libgomp.c-c++-common/task-detach-11.c: New.
* testsuite/libgomp.fortran/task-detach-1.f90: Fix formatting.
* testsuite/libgomp.fortran/task-detach-2.f90: Fix formatting.
* testsuite/libgomp.fortran/task-detach-3.f90: Fix formatting.
* testsuite/libgomp.fortran/task-detach-4.f90: Fix formatting.
* testsuite/libgomp.fortran/task-detach-5.f90: Fix formatting.
Change data-sharing of detach events on enclosing parallel to private.
* testsuite/libgomp.fortran/task-detach-6.f90: Likewise.  Remove
taskwait directive.
* testsuite/libgomp.fortran/task-detach-7.f90: New.
* testsuite/libgomp.fortran/task-detach-8.f90: New.
* testsuite/libgomp.fortran/task-detach-9.f90: New.
* testsuite/libgomp.fortran/task-detach-10.f90: New.
* testsuite/libgomp.fortran/task-detach-11.f90: New.

3 years agoc++: Fix pretty printing the context of local class [PR99213]
Patrick Palka [Thu, 25 Feb 2021 21:44:34 +0000 (16:44 -0500)]
c++: Fix pretty printing the context of local class [PR99213]

My r10-7705 patch for PR94521 made us set TFF_NO_FUNCTION_ARGUMENTS when
pretty printing the function scope of a local class type in order to
eliminate infinite recursion with a function signature that contains
decltype([]{}).  But due to the way dump_function_decl works, this
change regressed our pretty printing of local class types whose context
contains a class template specialization, as in the testcase below, in
which we wrongly pretty print the two local types as 'A<T>::f<char>::S1'
and 'B<T>::f<int>::S2'.

This patch makes dump_scope pass TFF_NO_TEMPLATE_BINDINGS instead of
TFF_NO_FUNCTION_ARGUMENTS when pretty printing a function scope.  It
appears this is the strictly better flag to use: it avoids the infinite
recursion issue, it restores pretty printing of the function parameter
list, and it stops dump_function_decl from trying to print a function
template specialization in its own weird way.

Summary of pretty printing differences for the below testcase:

  r10-7704:   A<T>::f() [with U = char; T = int]::S1
              B<T>::f() [with T = int]::S2

  r10-7705:   A<T>::f<char>::S1
              B<T>::f<int>::S2

  this patch: A<int>::f<char>()::S1
              B<int>::f()::S2

gcc/cp/ChangeLog:

PR c++/99213
PR c++/94521
* error.c (dump_scope): Pass TFF_NO_TEMPLATE_BINDINGS instead of
TFF_NO_FUNCTION_ARGUMENTS when dumping a function scope.

gcc/testsuite/ChangeLog:

PR c++/99213
PR c++/94521
* g++.dg/diagnostic/local1.C: New test.

3 years agoc++: Fix CTAD of single-element initializer list [PR99103]
Patrick Palka [Thu, 25 Feb 2021 21:38:08 +0000 (16:38 -0500)]
c++: Fix CTAD of single-element initializer list [PR99103]

When determining whether to rule out initializer-list constructors
during CTAD with a single-element initializer list (as per P0702), the
element type's cv-qualifiers should be irrelevant.  This patch fixes
this by making is_spec_or_derived strip cv-qualifiers from the supplied
expression type.

In passing, I noticed in maybe_aggr_guide we were calling
is_spec_or_derived with swapped arguments.  This led us to prefer the
aggregate deduction candidate over copying deduction in the second
testcase below with -std=c++20.

gcc/cp/ChangeLog:

PR c++/99103
* pt.c (is_spec_or_derived): Drop cv-qualifiers from 'etype'.
(maybe_aggr_guide): Fix order of arguments to is_spec_or_derived.

gcc/testsuite/ChangeLog:

PR c++/99103
* g++.dg/cpp1z/class-deduction79.C: New test.
* g++.dg/cpp1z/class-deduction80.C: New test.

3 years agoc++: const_cast of null pointer in constant expr [PR99176]
Marek Polacek [Wed, 24 Feb 2021 15:08:44 +0000 (10:08 -0500)]
c++: const_cast of null pointer in constant expr [PR99176]

Here we reject

  constexpr const int *p = nullptr;
  constexpr int *q = const_cast<int*>(p);

with "conversion of 'const int*' null pointer to 'int*' is not a
constant expression", which seems bogus.  This code has been rejected
since r238909 which added the can_convert check when converting a null
pointer.  I'm not finding any standard rule that this check was supposed
to enforce.  The original discussion was here
<https://gcc.gnu.org/legacy-ml/gcc-patches/2016-06/msg01447.html>
and here
<https://gcc.gnu.org/legacy-ml/gcc-patches/2016-07/msg00280.html>.

Since can_convert never assumes a C-style cast, it rejects casting
away constness as in the test above and in:

  constexpr int *q = (int *)(const int *) nullptr;

Removing the check only breaks constexpr-nullptr-2.C by not giving any
diagnostic for line 229:

  constexpr B *pb2 = static_cast<B*>(pa0);  // { dg-error "not a constant expression" }

but the cast seems to be valid: we do [expr.static.cast]/7, and
[expr.const] only says that a reinterpreter_cast and converting from
void* is invalid in constexpr.  The can_convert check rejected convering
from void *, but only when converting from a null pointer, so it's not
good enough.  So I've added a check to catch conversions from cv void*.
I realize it's not a great time to be adding additional checking, but
removing the can_convert check would then technically be a regression.

Let's limit the new check to only trigger for integer_zerop and then remove
it in GCC 12.

gcc/cp/ChangeLog:

DR 1312
PR c++/99176
* constexpr.c (is_std_construct_at): New overload.
(is_std_allocator_allocate): New overload.
(cxx_eval_call_expression): Use the new overloads.
(cxx_eval_constant_expression): Reject casting
from void * as per DR 1312.  Don't check can_convert.

gcc/testsuite/ChangeLog:

DR 1312
PR c++/99176
* g++.dg/cpp0x/constexpr-nullptr-2.C: Adjust dg-error.
* g++.dg/cpp0x/constexpr-cast2.C: New test.
* g++.dg/cpp0x/constexpr-cast3.C: New test.

3 years agocoroutines : Call promise CTOR with parm copies [PR97587].
Iain Sandoe [Mon, 15 Feb 2021 16:13:36 +0000 (16:13 +0000)]
coroutines : Call promise CTOR with parm copies [PR97587].

As the PR notes, we were calling the promise CTOR with the original
function parameters, not the copy (as pointed, a previous wording of
the section was unambiguous).  Fixed thus.

gcc/cp/ChangeLog:

PR c++/97587
* coroutines.cc (struct param_info): Track rvalue refs.
(morph_fn_to_coro): Track rvalue refs, and call the promise
CTOR with the frame copy of passed parms.

gcc/testsuite/ChangeLog:

PR c++/97587
* g++.dg/coroutines/coro1-refs-and-ctors.h: Add a CTOR with two
reference parms, to distinguish the rvalue ref. variant.
* g++.dg/coroutines/pr97587.C: New test.

3 years agocoroutines : Remove throwing_cleanup marks from the ramp [PR95822].
Iain Sandoe [Tue, 16 Feb 2021 09:07:32 +0000 (09:07 +0000)]
coroutines : Remove throwing_cleanup marks from the ramp [PR95822].

The FE contains a mechanism for cleaning up return expressions if a
function throws during the execution of cleanups prior to the return.

If the original function has a return value with a non-trivial DTOR
and the body contains a var with a DTOR that might throw, the function
decl is marked "throwing_cleanup".

However, we do not [in the coroutine ramp function, which is
synthesised], use any body var types with DTORs that might throw.

The original body [which will then contain the type with the throwing
DTOR] is transformed into the actor function which only contains void
returns, and is also wrapped in a try-catch block.

So (a) the 'throwing_cleanup' is no longer correct for the ramp and
   (b) we do not need to transfer it to the actor which only contains
       void returns.

gcc/cp/ChangeLog:

PR c++/95822
* coroutines.cc (morph_fn_to_coro): Unconditionally remove any
set throwing_cleanup marker.

gcc/testsuite/ChangeLog:

PR c++/95822
* g++.dg/coroutines/pr95822.C: New test.

3 years agoaarch64 : Mark rotate immediates with '#' as per DDI0487iFc.
Iain Sandoe [Tue, 25 Aug 2020 20:20:12 +0000 (21:20 +0100)]
aarch64 : Mark rotate immediates with '#' as per DDI0487iFc.

The armv8_arm manual [C6.2.226, ROR (immediate)] uses a # in front
of the immediate rotation quantity.

Although, it seems, GAS is able to infer the # (or is leninent about
its absence) assemblers based on the LLVM back end expect it.

gcc/ChangeLog:

* config/aarch64/aarch64.md (<optab>_rol<mode>3): Add a '#'
mark in front of the immediate quantity.
(<optab>_rolsi3_uxtw): Likewise.

3 years agoarm: force use of r4 for __gnu_cmse_nonsecure_call when !FPCXT [PR99271]
Richard Earnshaw [Mon, 22 Feb 2021 15:00:53 +0000 (15:00 +0000)]
arm: force use of r4 for __gnu_cmse_nonsecure_call when !FPCXT [PR99271]

Commit r10-6017 relaxed the constraint on thumb2 calls to
__gnu_cmse_nonsecure_call to allow any register for the call address.
Although the initial code expansion continues to use r4 with the FPCXT
extension is not enabled, the change was unsafe because subsequent
optimizations could use the additional freedom to change which
register was being used.

To fix this we need to split the output patterns in the machine
description to use distinct recognizers: one with the additional
freedom when FPCXT is enabled an another that retains the original
restrictions when the extension is not available.

gcc:
PR target/99271
* config/arm/thumb2.md (nonsecure_call_reg_thumb2_fpcxt): New pattern.
(nonsecure_call_value_reg_thumb2_fpcxt): Likewise.
(nonsecure_call_reg_thumb2): Restrict to using r4 for the callee
address and disable when the FPCXT is not available.
(nonsecure_call_value_reg_thumb2): Likewise.

gcc/testsuite:
* gcc.target/arm/cmse/cmse-18.c: New test.

3 years agoc++: Rename new -flang-note-module-read option [PR 99166]
Nathan Sidwell [Thu, 25 Feb 2021 16:33:05 +0000 (08:33 -0800)]
c++: Rename new -flang-note-module-read option [PR 99166]

I realized that the just-added flang-note-module-read option should
also cover module writes, and was therefore misnamed.  This addresses
that, replacing it with a -flang-note-module-cmi pair of options.  As
this was such a recent addition, I didn't leave the old option
available.

PR c++/99166
gcc/c-family/
* c.opt (-flang-info-module-cmi): Renamed option.
gcc/
* doc/invoke.texi (flang-info-module-cmi): Renamed option.
gcc/cp/
* module.cc (module_state::inform_cmi_p): Renamed field.
(module_state::do_import): Adjust.
(init_modules, finish_module_processing): Likewise.
(handle_module_option): Likewise.
gcc/testsuite/
* g++.dg/modules/pr99166_a.X: Adjust.
* g++.dg/modules/pr99166_b.C: Adjust.
* g++.dg/modules/pr99166_c.C: Adjust.
* g++.dg/modules/pr99166_d.C: Adjust.

3 years agoc++tools: Make NETWORKING define check consistent [PR 98318]
Nathan Sidwell [Thu, 25 Feb 2021 16:30:17 +0000 (08:30 -0800)]
c++tools: Make NETWORKING define check consistent [PR 98318]

PR98318 also pointed out that the NETWORKING #define was being checked
with both #if and #ifdef.  Let's consistently use one form.

c++tools/
* server.cc: Use #if NETWORKING not #ifdef, to be consistent
with elsewhere.

3 years agolibstdc++: Use uint32_t for all year_month_day::_S_from_days arithmetic
Jonathan Wakely [Thu, 25 Feb 2021 16:57:20 +0000 (16:57 +0000)]
libstdc++: Use uint32_t for all year_month_day::_S_from_days arithmetic

libstdc++-v3/ChangeLog:

* include/std/chrono (year_month_day::_S_from_days): Perform
all calculations with type uint32_t.

3 years agopr95690.f90: move error line for CRIS.
Hans-Peter Nilsson [Thu, 25 Feb 2021 16:20:16 +0000 (17:20 +0100)]
pr95690.f90: move error line for CRIS.

I don't know what it is that ix86, x86_64, Solaris and
apparently CRIS has in common here.

According to
https://gcc.gnu.org/pipermail/gcc-testresults/2021-February/652763.html
m68k-unknown-linux-gnu is also in that bunch, but since
there's a *-*-solaris* in the target specifier and also m68k
vs. m68k*, I'm leaving the adjustment to a maintainer.

gcc/testsuite:
* gfortran.dg/pr95690.f90: CRIS error appears on line 5.

3 years agoslp: Don't traverse tree on (nil) nodes.
Tamar Christina [Thu, 25 Feb 2021 16:26:37 +0000 (16:26 +0000)]
slp: Don't traverse tree on (nil) nodes.

The given testcase shows that one of the children of the complex MUL contains a
PHI node.  This results in the vectorizer having a child that's (nil).

The pattern matcher handles this correctly, but optimize_load_redistribution_1
needs to not traverse/inspect the NULL nodes.

This however does high-light a missed opportunity.  This testcase seems to
result in a different canonicalization than normally.

Normally the expressions are right leaning.  But sometimes, especially when type
casts are introduced the trees suddenly become left leaning. For instance this
testcase (even without type casts) won't detect the FMA form because the addition
gets the MUL node in the left and not right node as it expects.

Checking all forms would be quite expensive so for GCC 12 it probably makes sense to make
forms with type casts in them have the same form as those without?

gcc/ChangeLog:

* tree-vect-slp.c (optimize_load_redistribution_1): Abort on NULL nodes.

gcc/testsuite/ChangeLog:

* g++.dg/vect/simd-complex-num-null-node.cc: New test.

3 years ago[PR99233] tesstsuite: Run test pr96264.c only for little endian
Vladimir N. Makarov [Thu, 25 Feb 2021 16:20:32 +0000 (11:20 -0500)]
[PR99233] tesstsuite: Run test pr96264.c only for little endian

The test in question is assumed to work only for little endian target.

gcc/testsuite/ChangeLog:

PR testsuite/99233
* gcc.target/powerpc/pr96264.c: Run it only for powerpc64le.

3 years agoPR middle-end/97172 - ICE: tree code 'ssa_name' is not supported in LTO streams
Christophe Lyon [Thu, 25 Feb 2021 15:55:28 +0000 (15:55 +0000)]
PR middle-end/97172 - ICE: tree code 'ssa_name' is not supported in LTO streams

Skip test when -shared is not supported.

2021-02-25  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/testsuite/
PR middle-end/97172
* gcc.dg/pr97172-2.c: Add dg-require-effective-target shared.

3 years agolibstdc++: Document library versioning for GCC 11
Jonathan Wakely [Thu, 25 Feb 2021 14:09:40 +0000 (14:09 +0000)]
libstdc++: Document library versioning for GCC 11

libstdc++-v3/ChangeLog:

* doc/xml/manual/abi.xml: Document versioning for GCC 11.
* doc/html/manual/abi.html: Regenerate.

3 years agolibstdc++: Do not assume std::FILE is complete [PR 99270]
Jonathan Wakely [Thu, 25 Feb 2021 15:31:19 +0000 (15:31 +0000)]
libstdc++: Do not assume std::FILE is complete [PR 99270]

libstdc++-v3/ChangeLog:

PR libstdc++/99270
* testsuite/27_io/headers/cstdio/types_std.cc: Use pointer to
FILE instead of FILE.

3 years agolibstdc++: Update baseline symbols for {aarch64,ia64,m68k,riscv64}-linux
Andreas Schwab [Wed, 10 Feb 2021 10:43:35 +0000 (11:43 +0100)]
libstdc++: Update baseline symbols for {aarch64,ia64,m68k,riscv64}-linux

libstdc++-v3/
* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/ia64-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt: Update.

3 years agoc++: Fix typo in module-mapper [PR 98318]
Nathan Sidwell [Thu, 25 Feb 2021 12:57:09 +0000 (04:57 -0800)]
c++:  Fix typo in module-mapper [PR 98318]

User reported this typo: '0' and '-' are right next to each other, and
as it happened I always had networking, so it went unnoticed.

PR c++/98318
gcc/cp/
* mapper-client.cc (module_client::open_module_client): Fix typo
of fd init.

3 years agolibstdc++: Fix narrowing conversion in year_month_day [PR 99265]
Jonathan Wakely [Thu, 25 Feb 2021 11:48:18 +0000 (11:48 +0000)]
libstdc++: Fix narrowing conversion in year_month_day [PR 99265]

libstdc++-v3/ChangeLog:

PR libstdc++/99265
* include/std/chrono (year_month_day::_S_from_days): Cast long
to int explicitly.

3 years agolibstdc++: Add std::to_underlying for C++23
Jonathan Wakely [Thu, 25 Feb 2021 11:20:17 +0000 (11:20 +0000)]
libstdc++: Add std::to_underlying for C++23

Implement P1682R2 as just approved for C++23.

libstdc++-v3/ChangeLog:

* include/std/utility (to_underlying): Define.
* include/std/version (__cpp_lib_to_underlying): Define.
* testsuite/20_util/to_underlying/1.cc: New test.
* testsuite/20_util/to_underlying/version.cc: New test.

3 years agoBump gcc/BASE-VER to 11.0.1 now that we are in stage4.
Jakub Jelinek [Thu, 25 Feb 2021 10:16:29 +0000 (11:16 +0100)]
Bump gcc/BASE-VER to 11.0.1 now that we are in stage4.

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

* BASE-VER: Bump to 11.0.1.

3 years agotree-optimization/99253 - fix reduction path check
Richard Biener [Thu, 25 Feb 2021 08:36:33 +0000 (09:36 +0100)]
tree-optimization/99253 - fix reduction path check

This fixes an ordering problem with verifying that no intermediate
computations in a reduction path are used outside of the chain.  The
check was disabled for value-preserving conversions at the tail
but whether a stmt was a conversion or not was only computed after
the first use.  The following fixes this by re-ordering things
accordingly.

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

PR tree-optimization/99253
* tree-vect-loop.c (check_reduction_path): First compute
code, then verify out-of-loop uses.

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

3 years agomatch.pd: Use :s for (T)(A) + CST -> (T)(A + CST) [PR95798]
Jakub Jelinek [Thu, 25 Feb 2021 09:22:53 +0000 (10:22 +0100)]
match.pd: Use :s for (T)(A) + CST -> (T)(A + CST) [PR95798]

The r10-2806 change regressed following testcases, instead of doing
int -> unsigned long sign-extension once and then add 8, 16, ... 56 to it
for each of the memory access, it adds 8, 16, ... 56 in int mode and then
sign extends each.  So that means:
+       movq    $0, (%rsp,%rax,8)
+       leal    1(%rdx), %eax
+       cltq
+       movq    $1, (%rsp,%rax,8)
+       leal    2(%rdx), %eax
+       cltq
+       movq    $2, (%rsp,%rax,8)
+       leal    3(%rdx), %eax
+       cltq
+       movq    $3, (%rsp,%rax,8)
+       leal    4(%rdx), %eax
+       cltq
+       movq    $4, (%rsp,%rax,8)
+       leal    5(%rdx), %eax
+       cltq
+       movq    $5, (%rsp,%rax,8)
+       leal    6(%rdx), %eax
+       addl    $7, %edx
+       cltq
+       movslq  %edx, %rdx
+       movq    $6, (%rsp,%rax,8)
+       movq    $7, (%rsp,%rdx,8)
-       movq    $0, (%rsp,%rdx,8)
-       movq    $1, 8(%rsp,%rdx,8)
-       movq    $2, 16(%rsp,%rdx,8)
-       movq    $3, 24(%rsp,%rdx,8)
-       movq    $4, 32(%rsp,%rdx,8)
-       movq    $5, 40(%rsp,%rdx,8)
-       movq    $6, 48(%rsp,%rdx,8)
-       movq    $7, 56(%rsp,%rdx,8)
GCC 9 -> 10 change or:
-       movq    $0, (%rsp,%rdx,8)
-       movq    $1, 8(%rsp,%rdx,8)
-       movq    $2, 16(%rsp,%rdx,8)
-       movq    $3, 24(%rsp,%rdx,8)
-       movq    $4, 32(%rsp,%rdx,8)
-       movq    $5, 40(%rsp,%rdx,8)
-       movq    $6, 48(%rsp,%rdx,8)
-       movq    $7, 56(%rsp,%rdx,8)
+       movq    $0, (%rsp,%rax,8)
+       leal    1(%rdx), %eax
+       movq    $1, (%rsp,%rax,8)
+       leal    2(%rdx), %eax
+       movq    $2, (%rsp,%rax,8)
+       leal    3(%rdx), %eax
+       movq    $3, (%rsp,%rax,8)
+       leal    4(%rdx), %eax
+       movq    $4, (%rsp,%rax,8)
+       leal    5(%rdx), %eax
+       movq    $5, (%rsp,%rax,8)
+       leal    6(%rdx), %eax
+       movq    $6, (%rsp,%rax,8)
+       leal    7(%rdx), %eax
+       movq    $7, (%rsp,%rax,8)
change on the other test.  While for the former case of
int there is due to signed integer overflow (unless -fwrapv)
the possibility to undo it e.g. during expansion, for the unsigned
case information is unfortunately lost.

The following patch adds :s to the convert which restores these
testcases but keeps the testcases the patch meant to improve as is.

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

PR target/95798
* match.pd ((T)(A) + CST -> (T)(A + CST)): Add :s to convert.

* gcc.target/i386/pr95798-1.c: New test.
* gcc.target/i386/pr95798-2.c: New test.

3 years agovrp: Handle VCE in vrp_simplify_cond_using_ranges [PR80635]
Jakub Jelinek [Thu, 25 Feb 2021 09:16:55 +0000 (10:16 +0100)]
vrp: Handle VCE in vrp_simplify_cond_using_ranges [PR80635]

> So I wonder what other optimizations are prevented here?

> Why does uninit warn with VCE but not with NOP_EXPR?  Or does the
> warning disappear because of those other optimizations you mention?

The optimization that it prevents is in this particular case in tree-vrp.c
(vrp_simplify_cond_using_ranges):

      if (!is_gimple_assign (def_stmt)
          || !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt)))
        return;
so it punts on VIEW_CONVERT_EXPR, with NOP_EXPR it optimizes that:
  _9 = (bool) maybe_a$4_7;
  if (_9 != 0)
into:
  _9 = (bool) maybe_a$4_7;
  if (maybe_a$4_7 != 0)

Now, if I apply my patch but manually disable this
vrp_simplify_cond_using_ranges optimization, then the uninit warning is
back, so on the uninit side it is not about VIEW_CONVERT_EXPR vs. NOP_EXPR,
both are bad there, uninit wants the guarding condition to be
that SSA_NAME and not some demotion cast thereof.
We have:
  # maybe_a$m_6 = PHI <_5(4), maybe_a$m_4(D)(6)>
  # maybe_a$4_7 = PHI <1(4), 0(6)>
...
One of:
  _9 = VIEW_CONVERT_EXPR<bool>(maybe_a$4_7);
  if (_9 != 0)
or:
  _9 = (bool) maybe_a$4_7;
  if (_9 != 0)
or:
  if (maybe_a$4_7 != 0)
followed by:
    goto <bb 11>; [0.00%]
  else
    goto <bb 14>; [0.00%]
...
  <bb 11> [count: 0]:
  set (maybe_a$m_6);
and uninit wants to see that maybe_a$m_4(D) is not used if
bb 11 is encountered.

This patch fixes it by teaching vrp_simplify_cond_using_ranges
to handle VCE (when from an integral type) in addition to
NOP_EXPR/CONVERT_EXPR, of course as long as the VCE or demotion
doesn't change any values, i.e. when the range of the VCE or
conversion operand fits into the target type.

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

PR tree-optimization/80635
* tree-vrp.c (vrp_simplify_cond_using_ranges): Also handle
VIEW_CONVERT_EXPR if modes are the same, innerop is integral and
has mode precision.

* g++.dg/warn/pr80635-1.C: New test.
* g++.dg/warn/pr80635-2.C: New test.

3 years agoMake the PR99220 fix more robust
Richard Biener [Thu, 25 Feb 2021 07:37:36 +0000 (08:37 +0100)]
Make the PR99220 fix more robust

This avoids interleaving pattern recognition and load redistribution
optimization since the load_map used in the latter is fragile with
respect to release and reuse of SLP nodes, something which can also
occur within the pattern recognition machinery.

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

* tree-vect-slp.c (optimize_load_redistribution_1): Delay
load_map population.
(vect_match_slp_patterns_2): Revert part of last change.
(vect_analyze_slp): Do not interleave optimize_load_redistribution
with pattern detection but do it afterwards.  Dump the
whole SLP graph after pattern recognition and load
redistribution optimization finished.

3 years agoanalyzer: fix false positive on realloc [PR99193]
David Malcolm [Thu, 25 Feb 2021 00:55:40 +0000 (19:55 -0500)]
analyzer: fix false positive on realloc [PR99193]

PR analyzer/99193 describes various false positives from
-Wanalyzer-mismatching-deallocation on realloc(3) calls
of the form:

    |   31 |   void *p = malloc (1024);
    |      |             ^~~~~~~~~~~~~
    |      |             |
    |      |             (1) allocated here (expects deallocation with â€˜free’)
    |   32 |   void *q = realloc (p, 4096);
    |      |             ~~~~~~~~~~~~~~~~~
    |      |             |
    |      |             (2) deallocated with â€˜realloc’ here; allocation at (1) expects deallocation with â€˜free’
    |

The underlying issue is that the analyzer has no knowledge of
realloc(3), and realloc has awkward semantics.

Unfortunately, the analyzer is currently structured so that each call
statement can only have at most one successor state; there is no
way to "bifurcate" the state, or have N-way splits into multiple
outcomes.  The existing "on_stmt" code works on a copy of the next
state, updating it in place, rather than copying it and making any
necessary changes.  I did this as an optimization to avoid unnecessary
copying of state objects, but it makes it hard to support multiple
outcomes.  (ideally our state objects would be immutable and thus
support trivial copying, alternatively, C++11 move semantics may
help here)

I attempted a few approaches to implementing bifurcation within the
existing state-update framework, but they were messy and thus likely
buggy; a proper implementation would rework state-updating to
generate copies, but this would be a major change, and seems too
late for GCC 11.

As a workaround, this patch implements enough of realloc(3) to
suppress the false positives.

This fixes the false positives in PR analyzer/99193.
I've filed PR analyzer/99260 to track "properly" implementing realloc(3).

gcc/analyzer/ChangeLog:
PR analyzer/99193
* region-model-impl-calls.cc (region_model::impl_call_realloc): New.
* region-model.cc (region_model::on_call_pre): Call it.
* region-model.h (region_model::impl_call_realloc): New decl.
* sm-malloc.cc (enum wording): Add WORDING_REALLOCATED.
(malloc_state_machine::m_realloc): New field.
(use_after_free::describe_state_change): Add case for
WORDING_REALLOCATED.
(use_after_free::describe_final_event): Likewise.
(malloc_state_machine::malloc_state_machine): Initialize
m_realloc.
(malloc_state_machine::on_stmt): Handle realloc by calling...
(malloc_state_machine::on_realloc_call): New.

gcc/testsuite/ChangeLog:
PR analyzer/99193
* gcc.dg/analyzer/pr99193-1.c: New test.
* gcc.dg/analyzer/pr99193-2.c: New test.
* gcc.dg/analyzer/pr99193-3.c: New test.
* gcc.dg/analyzer/realloc-1.c: New test.

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

3 years agolibstdc++: Fix order of arguments to sprintf [PR 99261]
Jonathan Wakely [Wed, 24 Feb 2021 22:25:31 +0000 (22:25 +0000)]
libstdc++: Fix order of arguments to sprintf [PR 99261]

libstdc++-v3/ChangeLog:

PR libstdc++/99261
* src/c++17/floating_to_chars.cc (sprintf_ld): Add extra args
before value to be printed.

3 years agolibstdc++: Fix __floating_to_chars_precision for __float128
Patrick Palka [Wed, 24 Feb 2021 22:31:04 +0000 (17:31 -0500)]
libstdc++: Fix __floating_to_chars_precision for __float128

The code path in __floating_to_chars_precision for handling long double
by going through printf now also handles __float128, so the condition
that guards this code path needs to get updated accordingly.

libstdc++-v3/ChangeLog:

* src/c++17/floating_to_chars.cc (__floating_to_chars_precision):
Relax the condition that guards the printf code path to accept
F128_type as well as long double.

3 years agoc++: Macro location fixes [PR 98718]
Nathan Sidwell [Wed, 24 Feb 2021 20:32:23 +0000 (12:32 -0800)]
c++: Macro location fixes [PR 98718]

This fixes some issues with macro maps.  We were incorrectly
calculating the number of macro expansions in a location span, and I
had a workaround that partially covered that up.  Further, while macro
location spans are monotonic, that is not true of ordinary location
spans.  Thus we need to insert an indirection array when binary
searching the latter. (We load ordinary locations before loading
imports, but macro locations afterwards.  We make sure an import
location is de-macrofied, if needed.)

PR c++/98718
gcc/cp/
* module.cc (ool): New indirection vector.
(loc_spans::maybe_propagate): Location is not optional.
(loc_spans::open): Likewise.  Assert monotonically advancing.
(module_for_ordinary_loc): Use ool indirection vector.
(module_state::write_prepare_maps): Do not count empty macro
expansions.  Elide empty spans.
(module_state::write_macro_maps): Skip empty expansions.
(ool_cmp): New qsort comparator.
(module_state::write): Create and destroy ool vector.
(name_pending_imports): Fix dump push/pop.
(preprocess_module): Likewise.  Add more dumping.
(preprocessed_module): Likewise.
libcpp/
* include/line-map.h
* line-map.c
gcc/testsuite/
* g++.dg/modules/pr98718_a.C: New.
* g++.dg/modules/pr98718_b.C: New.

3 years agotestsuite, coroutines : Make final_suspend calls noexcept.
Iain Sandoe [Mon, 15 Feb 2021 16:56:52 +0000 (16:56 +0000)]
testsuite, coroutines : Make final_suspend calls noexcept.

The wording of [dcl.fct.def.coroutine]/15 states:
The expression co_await promise.final_suspend() shall not be
potentially-throwing.  A fair number of testcases are not correctly
marked. Fixed here.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/co-await-void_type.C: Mark promise
final_suspend call as noexcept.
* g++.dg/coroutines/co-return-syntax-08-bad-return.C: Likewise.
* g++.dg/coroutines/co-return-syntax-10-movable.C: Likewise.
* g++.dg/coroutines/co-return-warning-1.C: Likewise.
* g++.dg/coroutines/co-yield-syntax-08-needs-expr.C: Likewise.
* g++.dg/coroutines/coro-bad-gro-00-class-gro-scalar-return.C: Likewise.
* g++.dg/coroutines/coro-bad-gro-01-void-gro-non-class-coro.C: Likewise.
* g++.dg/coroutines/coro-missing-gro.C: Likewise.
* g++.dg/coroutines/coro-missing-promise-yield.C: Likewise.
* g++.dg/coroutines/coro-missing-ret-value.C: Likewise.
* g++.dg/coroutines/coro-missing-ret-void.C: Likewise.
* g++.dg/coroutines/coro-missing-ueh.h: Likewise.
* g++.dg/coroutines/coro1-allocators.h: Likewise.
* g++.dg/coroutines/coro1-refs-and-ctors.h: Likewise.
* g++.dg/coroutines/coro1-ret-int-yield-int.h: Likewise.
* g++.dg/coroutines/pr94682-preview-this.C: Likewise.
* g++.dg/coroutines/pr94752.C: Likewise.
* g++.dg/coroutines/pr94760-mismatched-traits-and-promise-prev.C: Likewise.
* g++.dg/coroutines/pr94879-folly-1.C: Likewise.
* g++.dg/coroutines/pr94883-folly-2.C: Likewise.
* g++.dg/coroutines/pr95050.C: Likewise.
* g++.dg/coroutines/pr95345.C: Likewise.
* g++.dg/coroutines/pr95440.C: Likewise.
* g++.dg/coroutines/pr95591.C: Likewise.
* g++.dg/coroutines/pr95711.C: Likewise.
* g++.dg/coroutines/pr95813.C: Likewise.
* g++.dg/coroutines/symmetric-transfer-00-basic.C: Likewise.
* g++.dg/coroutines/torture/co-await-07-tmpl.C: Likewise.
* g++.dg/coroutines/torture/co-await-17-capture-comp-ref.C: Likewise.
* g++.dg/coroutines/torture/co-ret-00-void-return-is-ready.C: Likewise.
* g++.dg/coroutines/torture/co-ret-01-void-return-is-suspend.C: Likewise.
* g++.dg/coroutines/torture/co-ret-03-different-GRO-type.C: Likewise.
* g++.dg/coroutines/torture/co-ret-04-GRO-nontriv.C: Likewise.
* g++.dg/coroutines/torture/co-ret-06-template-promise-val-1.C: Likewise.
* g++.dg/coroutines/torture/co-ret-08-template-cast-ret.C: Likewise.
* g++.dg/coroutines/torture/co-ret-09-bool-await-susp.C: Likewise.
* g++.dg/coroutines/torture/co-ret-15-default-return_void.C: Likewise.
* g++.dg/coroutines/torture/co-ret-17-void-ret-coro.C: Likewise.
* g++.dg/coroutines/torture/co-yield-00-triv.C: Likewise.
* g++.dg/coroutines/torture/co-yield-03-tmpl.C: Likewise.
* g++.dg/coroutines/torture/co-yield-04-complex-local-state.C: Likewise.
* g++.dg/coroutines/torture/exceptions-test-0.C: Likewise.
* g++.dg/coroutines/torture/exceptions-test-01-n4849-a.C: Likewise.
* g++.dg/coroutines/torture/func-params-04.C: Likewise.
* g++.dg/coroutines/torture/local-var-06-structured-binding.C: Likewise.
* g++.dg/coroutines/torture/mid-suspend-destruction-0.C: Likewise.

3 years agoopenmp: Diagnose invalid teams nested in target construct [PR99226]
Jakub Jelinek [Wed, 24 Feb 2021 19:11:11 +0000 (20:11 +0100)]
openmp: Diagnose invalid teams nested in target construct [PR99226]

The OpenMP standard says:
"A teams region can only be strictly nested within the implicit parallel region
or a target region. If a teams construct is nested within a target construct,
that target construct must contain no statements, declarations or directives
outside of the teams construct."
We weren't diagnosing that restriction, because we need to allow e.g.
 #pragma omp target
 {{{{{{
   #pragma omp teams
   ;
 }}}}}}
and as target doesn't need to have teams nested in it, using some special
parser of the target body didn't feel right.  And after the parsing,
the question is if e.g. already parsing of the clauses doesn't add some
statements before the teams statement (gimplification certainly will).

As we now have a bugreport where we ICE on the invalid code, this just
diagnoses a subset of the invalid programs, in particular those where
nest to the teams strictly nested in targets the target region contains
some other OpenMP construct.

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

PR fortran/99226
* omp-low.c (struct omp_context): Add teams_nested_p and
nonteams_nested_p members.
(scan_omp_target): Diagnose teams nested inside of target with other
directives strictly nested inside of the same target.
(check_omp_nesting_restrictions): Set ctx->teams_nested_p or
ctx->nonteams_nested_p as needed.

* c-c++-common/gomp/pr99226.c: New test.
* gfortran.dg/gomp/pr99226.f90: New test.

3 years agolibgcc: Avoid signed negation overflow in __powi?f2 [PR99236]
Jakub Jelinek [Wed, 24 Feb 2021 19:07:38 +0000 (20:07 +0100)]
libgcc: Avoid signed negation overflow in __powi?f2 [PR99236]

When these functions are called with integer minimum, there is UB on the libgcc
side.  Fixed in the obvious way, the code in the end wants ABSU_EXPR behavior.

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

PR libgcc/99236
* libgcc2.c (__powisf2, __powidf2, __powitf2, __powixf2): Perform
negation of m in unsigned type.

3 years ago[PR99123] inline-asm: Don't use decompose_mem_address to find used hard regs
Vladimir N. Makarov [Wed, 24 Feb 2021 18:54:10 +0000 (13:54 -0500)]
[PR99123] inline-asm: Don't use decompose_mem_address to find used hard regs

Inline asm in question has empty constraint which means anything
including memory with invalid address.  To check used hard regs we
used decompose_mem_address which assumes memory with valid address.
The patch implements the same semantics without assuming valid
addresses.

gcc/ChangeLog:

PR inline-asm/99123
* lra-constraints.c (uses_hard_regs_p): Don't use decompose_mem_address.

gcc/testsuite/ChangeLog:

PR inline-asm/99123
* gcc.target/i386/pr99123.c: New.

3 years agolibstdc++: More efficient last day of month
Cassio Neri [Wed, 24 Feb 2021 18:12:47 +0000 (18:12 +0000)]
libstdc++: More efficient last day of month

This patch reimplements std::chrono::year_month_day_last:day() which yields the
last day of a particular month.  The current implementation uses a look-up table
implemented as an unsigned[12] array.  The new implementation instead
is based on
the fact that a month m in [1, 12], except for m == 2 (February), is
either 31 or
30 days long and m's length depends on two things: m's parity and whether m >= 8
or not. These two conditions are determined by the 0th and 3th bit of m and,
therefore, cheap and straightforward bit-twiddling can provide the right result.

Measurements in x86_64 [1] suggest a 10% performance boost.  Although this does
not seem to be huge, notice that measurements are done in hot L1 cache
conditions which might not be very representative of production runs. Also
freeing L1 cache from holding the look-up table might allow performance
improvements elsewhere.

References:
[1] https://github.com/cassioneri/calendar

libstdc++-v3/ChangeLog:

* include/std/chrono (year_month_day_last:day): New
implementation.

3 years agolibstdc++: More efficient is_leap
Cassio Neri [Wed, 24 Feb 2021 17:37:36 +0000 (17:37 +0000)]
libstdc++: More efficient is_leap

This patch reimplements std::chrono::year::is_leap().  Leap year check is
ubiquitously implemented (including here) as:

    y % 4 == 0 && (y % 100 != 0 || y % 400 == 0).

The rationale being that testing divisibility by 4 first implies an earlier
return for 75% of the cases, therefore, avoiding the needless calculations of
y % 100 and y % 400. Although this fact is true, it does not take into account
the cost of branching.  This patch, instead, tests divisibility by 100 first:

    (y % 100 != 0 || y % 400 == 0) && y % 4 == 0.

It is certainly counterintuitive that this could be more efficient since among
the three divisibility tests (4, 100 and 400) the one by 100 is the only one
that can never provide a definitive answer and a second divisibility test (by 4
or 400) is always required. However, measurements [1] in x86_64 suggest this is
3x more efficient!  A possible explanation is that checking divisibility by 100
first implies a split in the execution path with probabilities of (1%, 99%)
rather than (25%, 75%) when divisibility by 4 is checked first.  This decreases
the entropy of the branching distribution which seems to help prediction.

Given that y belongs to [-32767, 32767] [time.cal.year.members], a more
efficient algorithm [2] to check divisibility by 100 is used (instead of
y % 100 != 0).  Measurements suggest that this optimization improves performance
by 20%.

The patch adds a test that exhaustively compares the result of this
implementation with the ubiquitous one for all y in [-32767, 32767]. Although
its completeness, the test completes in a matter of seconds.

References:
[1] https://stackoverflow.com/a/60646967/1137388
[2] https://accu.org/journals/overload/28/155/overload155.pdf#page=16

libstdc++-v3/ChangeLog:

* include/std/chrono (year::is_leap): New implementation.
* testsuite/std/time/year/2.cc: New test.

3 years agolibstdc++: More efficient days from date
Cassio Neri [Wed, 24 Feb 2021 17:33:45 +0000 (17:33 +0000)]
libstdc++: More efficient days from date

This patch reimplements std::chrono::year_month_day::_M_days_since_epoch()
which calculates the number of elapsed days since 1970/01/01.  The new
implementation is based on Proposition 6.2 of Neri and Schneider, "Euclidean
Affine Functions and Applications to Calendar Algorithms" available at
https://arxiv.org/abs/2102.06959.

The aforementioned paper benchmarks the implementation against several
counterparts, including libc++'s (which is identical to the current
implementation).  The results, shown in Figure 3, indicate the new algorithm is
1.7 times faster than the current one.

The patch adds a test which loops through all dates in [-32767/01/01,
32767/12/31], and for each of them, gets the number of days and compares the
result against its expected value. The latter is calculated using a much
simpler and easy to understand algorithm but which is also much slower.

The dates used in the test covers the full range of possible values
[time.cal.year.members].  Despite its completeness the test runs in matter of
seconds.

libstdc++-v3/ChangeLog:

* include/std/chrono (year_month_day::_M_days_since_epoch):
New implementation.
* testsuite/std/time/year_month_day/4.cc: New test.

3 years agolibstdc++: More efficient date from days
Cassio Neri [Wed, 24 Feb 2021 17:23:56 +0000 (17:23 +0000)]
libstdc++: More efficient date from days

This patch reimplements std::chrono::year_month_day::_S_from_days() which
retrieves a date from the number of elapsed days since 1970/01/01.  The new
implementation is based on Proposition 6.3 of Neri and Schneider, "Euclidean
Affine Functions and Applications to Calendar Algorithms" available at
https://arxiv.org/abs/2102.06959.

The aforementioned paper benchmarks the implementation against several
counterparts, including libc++'s (which is identical to the current
implementation).  The results, shown in Figure 4, indicate the new algorithm is
2.2 times faster than the current one.

The patch adds a test which loops through all integers in [-1268742811248737],
and for each of them, gets the corresponding date and compares the result
against its expected value.  The latter is calculated using a much simpler and
easy to understand algorithm but which is also much slower.

The interval used in the test covers the full range of values for which a
roundtrip must work [time.cal.ymd.members].  Despite its completeness the test
runs in a matter of seconds.

libstdc++-v3/ChangeLog:

* include/std/chrono (year_month_day::_S_from_days): New
implementation.
* testsuite/std/time/year_month_day/3.cc: New test.

3 years agocris: support -fstack-usage
Hans-Peter Nilsson [Wed, 24 Feb 2021 01:22:58 +0000 (02:22 +0100)]
cris: support -fstack-usage

All the bits were there, used with a pre-existing
-mmax-stackframe=SIZE which unfortunately seems to lack
test-cases.

Note that the early-return for -mno-prologue-epilogue (what
some targets call -mnaked) is deliberately not clearing
current_function_static_stack_size, as I consider that
erroneous usage but don't really care to emit a better error
message.

For stack-usage-1.c, like most ILP32 targets, CRIS (at -O0)
needs 4 bytes for the return-address.  The default size of
256 seems ill chosen but not worth fixing.

gcc:
* config/cris/cris.c (cris_expand_prologue): Set
current_function_static_stack_size, if flag_stack_usage_info.

gcc/testsuite:
* gcc.dg/stack-usage-1.c: Adjust for CRIS.

3 years agolibstdc++: Robustify long double std::to_chars testcase [PR98384]
Patrick Palka [Wed, 24 Feb 2021 17:24:43 +0000 (12:24 -0500)]
libstdc++: Robustify long double std::to_chars testcase [PR98384]

The long double std::to_chars testcase currently verifies the
correctness of its output by comparing it to that of printf, so if
there's a mismatch between to_chars and printf, the test FAILs.  This
works well for the scientific, fixed and general formatting modes,
because the corresponding printf conversion specifiers (%e, %f and %g)
are rigidly specified.

But this doesn't work well for the hex formatting mode because the
corresponding printf conversion specifier %a is more flexibly specified.
For instance, the hexadecimal forms 0x1p+0, 0x2p-1, 0x4p-2 and 0x8p-3
are all equivalent and valid outputs of the %a specifier for the number 1.
The apparent freedom here is the choice of leading hex digit -- the
standard just requires that the leading hex digit is nonzero for
normalized numbers.

Currently, our hexadecimal formatting implementation uses 0/1/2 as the
leading hex digit for floating point types that have an implicit leading
mantissa bit which in practice means all supported floating point types
except x86 long double.  The latter type has a 64 bit mantissa with an
explicit leading mantissa bit, and for this type our implementation uses
the most significant four bits of the mantissa as leading hex digit.
This seems to be consistent with most printf implementations, but not
all, as PR98384 illustrates.

In order to avoid false-positive FAILs due to arbitrary disagreement
between to_chars and printf about the choice of leading hex digit, this
patch makes the testcase's verification via printf conditional on the
leading hex digits first agreeing.  An additional verification step is
also added: round-tripping the output of to_chars through from_chars
should recover the value exactly.

libstdc++-v3/ChangeLog:

PR libstdc++/98384
* testsuite/20_util/to_chars/long_double.cc: Include <optional>.
(test01): Simplify verifying the nearby values by using a
2-iteration loop and a dedicated output buffer to check that the
nearby values are different.  Factor out the printf-based
verification into a local function, and check that the leading
hex digits agree before comparing to the output of printf.  Also
verify the output by round-tripping it through from_chars.

3 years agoc++: modules & -fpreprocessed [PR 99072]
Nathan Sidwell [Wed, 24 Feb 2021 13:50:12 +0000 (05:50 -0800)]
c++: modules & -fpreprocessed [PR 99072]

When we read preprocessed source, we deal with a couple of special
location lines at the start of the file.  These provide information
about the original filename of the source and the current directory,
so we can process the source in the same manner.  When updating that
code, I had a somewhat philosophical question: Should the line table
contain evidence of the filename the user provided to the compiler?  I
figured to leave it there, as it did no harm.  But this defect shows
an issue.  It's in the line table and our (non optimizing) line table
serializer emits that filename.  Which means if one re-preprocesses
the original source to a differently-named intermediate file, the
resultant CMI is different.  Boo.  That's a difference that doesn't
matter, except the CRC matching then fails.  We should elide the
filename, so that one can preprocess to mktemp intermediate filenames
for whatever reason.

This patch takes the approach of expunging it from the line table --
so the line table will end up with exactly the same form.  That seems
a better bet than trying to fix up mismatching line tables in CMI
emission.

PR c++/99072
libcpp/
* init.c (read_original_filename): Expunge all evidence of the
original filename.
gcc/testsuite/
* g++.dg/modules/pr99072.H: New.

3 years agolibstdc++: Define std::to_chars overloads for __ieee128 [PR 98389]
Jonathan Wakely [Fri, 19 Feb 2021 13:36:41 +0000 (13:36 +0000)]
libstdc++: Define std::to_chars overloads for __ieee128 [PR 98389]

This adds overloads of std::to_chars for powerpc64's __ieee128, so that
std::to_chars can be used for long double when -mabi=ieeelongdouble is
in used.

Eventually we'll want to extend these new overloads to work for
__float128 on all targets that support that type. For now, we're only
doing it for powerpc64 when the new long double type is supported in
parallel to the old long double type.

Additionally the existing std::to_chars overloads for long double
are given the right symbol version, resolving PR libstdc++/98389.

libstdc++-v3/ChangeLog:

PR libstdc++/98389
* config/abi/pre/gnu.ver (GLIBCXX_3.4.29): Do not match to_chars
symbols for long double arguments mangled as 'g'.
* config/os/gnu-linux/ldbl-extra.ver: Likewise.
* config/os/gnu-linux/ldbl-ieee128-extra.ver: Likewise.
* src/c++17/Makefile.am [GLIBCXX_LDBL_ALT128_COMPAT_TRUE]:
Use -mabi=ibmlongdouble for floating_to_chars.cc.
* src/c++17/Makefile.in: Regenerate.
* src/c++17/floating_to_chars.cc (floating_type_traits_binary128):
New type defining type traits of IEEE binary128 format.
(floating_type_traits<__float128>): Define specialization.
(floating_type_traits<long double>): Define in terms of
floating_type_traits_binary128 when appropriate.
(floating_to_shortest_scientific): Handle __float128.
(sprintf_ld): New function template for printing a long double
or __ieee128 value using sprintf.
(__floating_to_chars_shortest, __floating_to_chars_precision):
Use sprintf_ld.
(to_chars): Define overloads for __float128.

3 years agolibstdc++: Fix failing tests due to 'u' identifier in kernel header
Jonathan Wakely [Wed, 24 Feb 2021 16:24:34 +0000 (16:24 +0000)]
libstdc++: Fix failing tests due to 'u' identifier in kernel header

libstdc++-v3/ChangeLog:

* testsuite/17_intro/names.cc: Undefine 'u' on powerpc*-linux*.

3 years agoRename next_insn_prefixed_p for improved clarity.
Pat Haugen [Wed, 24 Feb 2021 16:10:46 +0000 (10:10 -0600)]
Rename next_insn_prefixed_p for improved clarity.

2021-02-24  Pat Haugen  <pthaugen@linux.ibm.com>

gcc/
* config/rs6000/rs6000.c (next_insn_prefixed_p): Rename.
(rs6000_final_prescan_insn): Adjust.
(rs6000_asm_output_opcode): Likewise.

3 years agoFortran: Fix memory problems with assumed rank formal args [PR98342].
Paul Thomas [Wed, 24 Feb 2021 16:00:51 +0000 (16:00 +0000)]
Fortran: Fix memory problems with assumed rank formal args [PR98342].

2021-02-24  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/98342
* trans-expr.c (gfc_conv_derived_to_class): Add optional arg.
'derived_array' to hold the fixed, parmse expr in the case of
assumed rank formal arguments. Deal with optional arguments.
(gfc_conv_procedure_call): Null 'derived' array for each actual
argument. Add its address to the call to gfc_conv_derived_to_
class. Access the 'data' field of scalar descriptors before
deallocating allocatable components. Also strip NOPs before the
calls to gfc_deallocate_alloc_comp. Use 'derived' array as the
input to gfc_deallocate_alloc_comp if it is available.
* trans.h : Include the optional argument 'derived_array' to
the prototype of gfc_conv_derived_to_class. The default value
is NULL_TREE.

gcc/testsuite/
PR fortran/98342
* gfortran.dg/assumed_rank_21.f90 : New test.

3 years agoarm: Fix CMSE support detection in libgcc (PR target/99157)
Christophe Lyon [Wed, 24 Feb 2021 15:51:52 +0000 (15:51 +0000)]
arm: Fix CMSE support detection in libgcc (PR target/99157)

As discussed in the PR, the Makefile fragment lacks a double '$' to
get the return-code from GCC invocation, resulting is CMSE support
missing from multilibs.

I checked that the simple patch proposed in the PR fixes the problem.

2021-02-23  Christophe Lyon  <christophe.lyon@linaro.org>
    Hau Hsu  <hsuhau617@gmail.com>

PR target/99157
libgcc/
* config/arm/t-arm: Fix cmse support detection.

3 years agoPR middle-end/97172 - ICE: tree code 'ssa_name' is not supported in LTO streams
Martin Sebor [Wed, 24 Feb 2021 15:57:59 +0000 (08:57 -0700)]
PR middle-end/97172 - ICE: tree code 'ssa_name' is not supported in LTO streams

gcc/ChangeLog:
PR middle-end/97172
* attribs.c (attr_access::free_lang_data): Clear attribute arg spec
from function arguments.

gcc/c/ChangeLog:

PR middle-end/97172
* c-decl.c (free_attr_access_data): Clear attribute arg spec.

gcc/testsuite/ChangeLog:

PR middle-end/97172
* gcc.dg/pr97172-2.c: New test.

3 years agoslp: fix accidental resource re-use of slp_tree (PR99220)
Tamar Christina [Wed, 24 Feb 2021 15:16:23 +0000 (15:16 +0000)]
slp: fix accidental resource re-use of slp_tree (PR99220)

The attached testcase shows a bug where two nodes end up with the same pointer.
During the loop that analyzes all the instances
in optimize_load_redistribution_1 we do

      if (value)
        {
          SLP_TREE_REF_COUNT (value)++;
          SLP_TREE_CHILDREN (root)[i] = value;
          vect_free_slp_tree (node);
        }

when doing a replacement.  When this is done and the refcount for the node
reaches 0, the node is removed, which allows the libc to return the pointer
again in the next call to new, which it does..

First instance

note:   node 0x5325f48 (max_nunits=1, refcnt=2)
note:   op: VEC_PERM_EXPR
note:           { }
note:           lane permutation { 0[0] 1[1] 0[2] 1[3] }
note:           children 0x5325db0 0x5325200

Second instance

note:   node 0x5325f48 (max_nunits=1, refcnt=1)
note:   op: VEC_PERM_EXPR
note:           { }
note:           lane permutation { 0[0] 1[1] }
note:           children 0x53255b8 0x5325530

This will end up with the illegal construction of

note:   node 0x53258e8 (max_nunits=2, refcnt=2)
note:   op template: slp_patt_57 = .COMPLEX_MUL (_16, _16);
note:           stmt 0 _16 = _14 - _15;
note:           stmt 1 _23 = _17 + _22;
note:           children 0x53257d8 0x5325d28
note:   node 0x53257d8 (max_nunits=2, refcnt=3)
note:   op template: l$b_4 = MEM[(const struct a &)_3].b;
note:           stmt 0 l$b_4 = MEM[(const struct a &)_3].b;
note:           stmt 1 l$c_5 = MEM[(const struct a &)_3].c;
note:           load permutation { 0 1 }
note:   node 0x5325d28 (max_nunits=2, refcnt=8)
note:   op template: l$b_4 = MEM[(const struct a &)_3].b;
note:           stmt 0 l$b_4 = MEM[(const struct a &)_3].b;
note:           stmt 1 l$c_5 = MEM[(const struct a &)_3].c;
note:           stmt 2 l$b_4 = MEM[(const struct a &)_3].b;
note:           stmt 3 l$c_5 = MEM[(const struct a &)_3].c;
note:           load permutation { 0 1 0 1 }

To prevent this we remove the node from the load_map if it's
about to be deleted.

gcc/ChangeLog:

PR tree-optimization/99220
* tree-vect-slp.c (optimize_load_redistribution_1): Remove
node from cache when it's about to be deleted.

gcc/testsuite/ChangeLog:

PR tree-optimization/99220
* g++.dg/vect/pr99220.cc: New test.

3 years ago[comitted] Testsuite: Disable PR99149 test on big-endian
Tamar Christina [Wed, 24 Feb 2021 14:57:08 +0000 (14:57 +0000)]
[comitted] Testsuite: Disable PR99149 test on big-endian

This patch disables the test for PR99149 on Big-endian
where for standard AArch64 the patterns are disabled.

gcc/testsuite/ChangeLog:

PR tree-optimization/99149
* g++.dg/vect/pr99149.cc: Disabled on BE.

3 years agocoroutines : Adjust error handling for type-dependent coroutines [PR96251].
Iain Sandoe [Tue, 23 Feb 2021 12:54:26 +0000 (12:54 +0000)]
coroutines : Adjust error handling for type-dependent coroutines [PR96251].

Although coroutines are not permitted to be constexpr, generic lambdas
are implicitly from C++17 and, because of this, a generic coroutine lambda
can be marked as potentially constexpr. As per the PR, this then fails when
type substitution is attempted because the check disallowing constexpr in
the coroutines code was overly restrictive.

This changes the error handing to mark the function  as 'invalid_constexpr'
but suppresses the error in the case that we are instantiating a constexpr.

gcc/cp/ChangeLog:

PR c++/96251
* coroutines.cc (coro_common_keyword_context_valid_p): Suppress
error reporting when instantiating for a constexpr.

gcc/testsuite/ChangeLog:

PR c++/96251
* g++.dg/coroutines/pr96251.C: New test.

3 years agofold-const: Fix up ((1 << x) & y) != 0 folding for vectors [PR99225]
Jakub Jelinek [Wed, 24 Feb 2021 11:10:25 +0000 (12:10 +0100)]
fold-const: Fix up ((1 << x) & y) != 0 folding for vectors [PR99225]

This optimization was written purely with scalar integers in mind,
can work fine even with vectors, but we can't use build_int_cst but
need to use build_one_cst instead.

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

PR tree-optimization/99225
* fold-const.c (fold_binary_loc) <case NE_EXPR>: In (x & (1 << y)) != 0
to ((x >> y) & 1) != 0 simplifications use build_one_cst instead of
build_int_cst (..., 1).  Formatting fixes.

* gcc.c-torture/compile/pr99225.c: New test.

3 years agoslp: fix sharing of SLP only patterns.
Tamar Christina [Wed, 24 Feb 2021 09:43:22 +0000 (09:43 +0000)]
slp: fix sharing of SLP only patterns.

The attached testcase ICEs due to a couple of issues.
In the testcase you have two SLP instances that share the majority of their
definition with each other.  One tree defines a COMPLEX_MUL sequence and the
other tree a COMPLEX_FMA.

The ice happens because:

1. the refcounts are wrong, in particular the FMA case doesn't correctly count
the references for the COMPLEX_MUL that it consumes.

2. when the FMA is created it incorrectly assumes it can just tear apart the MUL
node that it's consuming.  This is wrong and should only be done when there is
no more uses of the node, in which case the vector only pattern is no longer
relevant.

To fix the last part the SLP only pattern reset code was moved into
vect_free_slp_tree which results in cleaner code.  I also think it does belong
there since that function knows when there are no more uses of the node and so
the pattern should be unmarked, so when the the vectorizer is inspecting the BB
it doesn't find the now invalid vector only patterns.

The patch also clears the SLP_TREE_REPRESENTATIVE when stores are removed such
that we don't hit an error later trying to free the stmt_vec_info again.

Lastly it also tweaks the results of whether a pattern has been detected or not
to return true when another SLP instance has created a pattern that is only used
by a different instance (due to the trees being unshared).

Instead of ICEing this code now produces

        adrp    x1, .LANCHOR0
        add     x2, x1, :lo12:.LANCHOR0
        movi    v1.2s, 0
        mov     w0, 0
        ldr     x4, [x1, #:lo12:.LANCHOR0]
        ldrsw   x3, [x2, 16]
        ldr     x1, [x2, 8]
        ldrsw   x2, [x2, 20]
        ldr     d0, [x4]
        ldr     d2, [x1, x3, lsl 3]
        fcmla   v2.2s, v0.2s, v0.2s, #0
        fcmla   v2.2s, v0.2s, v0.2s, #90
        str     d2, [x1, x3, lsl 3]
        fcmla   v1.2s, v0.2s, v0.2s, #0
        fcmla   v1.2s, v0.2s, v0.2s, #90
        str     d1, [x1, x2, lsl 3]
        ret

PS. This testcase actually shows that the codegen we get in these cases is not
optimal. It should generate a MUL + ADD instead MUL + FMA.

But that's for GCC 12.

gcc/ChangeLog:

PR tree-optimization/99149
* tree-vect-slp-patterns.c (vect_detect_pair_op): Don't recreate the
buffer.
(vect_slp_reset_pattern): Remove.
(complex_fma_pattern::matches): Remove call to vect_slp_reset_pattern.
(complex_mul_pattern::build, complex_fma_pattern::build,
complex_fms_pattern::build): Fix ref counts.
* tree-vect-slp.c (vect_free_slp_tree): Undo SLP only pattern relevancy
when node is being deleted.
(vect_match_slp_patterns_2): Correct result of cache hit on patterns.
(vect_schedule_slp): Invalidate SLP_TREE_REPRESENTATIVE of removed
stores.
* tree-vectorizer.c (vec_info::new_stmt_vec_info): Initialize value.

gcc/testsuite/ChangeLog:

PR tree-optimization/99149
* g++.dg/vect/pr99149.cc: New test.

3 years agoRevert: "Don't build insn-extract.o with rtl checking"
Matthias Klose [Wed, 24 Feb 2021 09:39:11 +0000 (09:39 +0000)]
Revert: "Don't build insn-extract.o with rtl checking"

This reverts commit 8441545d4f2afb9e9342e0dac378eafd03f00462.

3 years agoc/99224 - avoid ICEing on invalid __builtin_next_arg
Richard Biener [Wed, 24 Feb 2021 08:18:05 +0000 (09:18 +0100)]
c/99224 - avoid ICEing on invalid __builtin_next_arg

This avoids crashes with __builtin_next_arg on non-parameters.  For
the specific testcase we arrive with an anonymous SSA_NAME so that
SSA_NAME_VAR becomes NULL and we crash.

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

PR c/99224
* builtins.c (fold_builtin_next_arg): Avoid NULL arg.

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

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

3 years agors6000: Add support for compatibility built-ins
Peter Bergner [Tue, 23 Feb 2021 23:16:10 +0000 (17:16 -0600)]
rs6000: Add support for compatibility built-ins

The LLVM and GCC teams agreed to rename the __builtin_mma_assemble_pair and
__builtin_mma_disassemble_pair built-ins to __builtin_vsx_assemble_pair and
__builtin_vsx_disassemble_pair respectively.  It's too late to remove the
old names, so this patch renames the built-ins to the new names and then
adds support for creating compatibility built-ins (ie, multiple built-in
functions generate the same code) and then creates compatibility built-ins
using the old names.

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

gcc/
* config/rs6000/mma.md (mma_assemble_pair): Rename from this...
(vsx_assemble_pair): ...to this.
(*mma_assemble_pair): Rename from this...
(*vsx_assemble_pair): ...to this.
(mma_disassemble_pair): Rename from this...
(vsx_disassemble_pair): ...to this.
(*mma_disassemble_pair): Rename from this...
(*vsx_disassemble_pair): ...to this.
* config/rs6000/rs6000-builtin.def (BU_MMA_V2, BU_MMA_V3,
BU_COMPAT): New macros.
(mma_assemble_pair): Rename from this...
(vsx_assemble_pair): ...to this.
(mma_disassemble_pair): Rename from this...
(vsx_disassemble_pair): ...to this.
(mma_assemble_pair): New compatibility built-in.
(mma_disassemble_pair): Likewise.
* config/rs6000/rs6000-call.c (struct builtin_compatibility): New.
(RS6000_BUILTIN_COMPAT): Define.
(bdesc_compat): New.
(mma_expand_builtin): Use VSX_BUILTIN_DISASSEMBLE_PAIR_INTERNAL.
(rs6000_gimple_fold_mma_builtin): Use MMA_BUILTIN_DISASSEMBLE_PAIR
and VSX_BUILTIN_ASSEMBLE_PAIR.
(rs6000_init_builtins): Register compatibility built-ins.
(mma_init_builtins): Use VSX_BUILTIN_ASSEMBLE_PAIR,
VSX_BUILTIN_ASSEMBLE_PAIR_INTERNAL, VSX_BUILTIN_DISASSEMBLE_PAIR and
VSX_BUILTIN_DISASSEMBLE_PAIR_INTERNAL.
* doc/extend.texi (__builtin_mma_assemble_pair): Rename from this...
(__builtin_vsx_assemble_pair): ...to this.
(__builtin_mma_disassemble_pair): Rename from this...
(__builtin_vsx_disassemble_pair): ...to this.

gcc/testsuite/
* gcc.target/powerpc/mma-builtin-4.c: Add tests for
__builtin_vsx_assemble_pair and __builtin_vsx_disassemble_pair.
Add __has_builtin tests for built-ins.
Update expected instruction counts.

3 years agoPR c++/99074 - crash in dynamic_cast<>() on null pointer
Martin Sebor [Tue, 23 Feb 2021 21:09:00 +0000 (14:09 -0700)]
PR c++/99074 - crash in dynamic_cast<>() on null pointer

libstdc++-v3/ChangeLog:

PR c++/99074
* libsupc++/dyncast.cc (__dynamic_cast): Return null when
first argument is null.

gcc/testsuite/ChangeLog:

PR c++/99074
* g++.dg/warn/Wnonnull11.C: New test.

3 years agoFortran: Fix for class defined operators [PR99124].
Paul Thomas [Tue, 23 Feb 2021 19:29:04 +0000 (19:29 +0000)]
Fortran: Fix for class defined operators [PR99124].

2021-02-23  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/99124
* resolve.c (resolve_fl_procedure): Include class results in
the test for F2018, C15100.
* trans-array.c (get_class_info_from_ss): Do not use the saved
descriptor to obtain the class expression for variables. Use
gfc_get_class_from_expr instead.

gcc/testsuite/
PR fortran/99124
* gfortran.dg/class_defined_operator_2.f03 : New test.
* gfortran.dg/elemental_result_2.f90 : New test.
* gfortran.dg/class_assign_4.f90: Correct the non-conforming
elemental function with an allocatable result with an operator
interface with array dummies and result.

3 years agoPR fortran/99206 - ICE in add_init_expr_to_sym, at fortran/decl.c:1980
Harald Anlauf [Tue, 23 Feb 2021 18:09:14 +0000 (19:09 +0100)]
PR fortran/99206 - ICE in add_init_expr_to_sym, at fortran/decl.c:1980

Make sure that the string length is properly set during simplification
even when the resulting array is zero-sized.

gcc/fortran/ChangeLog:

PR fortran/99206
* simplify.c (gfc_simplify_reshape): Set string length for
character arguments.

gcc/testsuite/ChangeLog:

PR fortran/99206
* gfortran.dg/reshape_zerosize_4.f90: New test.

3 years agoc++: typedef for linkage [PR 99208]
Nathan Sidwell [Tue, 23 Feb 2021 15:08:55 +0000 (07:08 -0800)]
c++: typedef for linkage [PR 99208]

Unnamed types with a typedef name for linkage were always troublesome
in modules.  This is the underlying cause of that trouble -- we were
creating incorrect type structures.  Classes have an implicit
self-reference, and we created that for unnamed classes too.  It turns
out we make use of this member, so just not generating it turned into
a rathole.  This member is created using the anonymous name -- because
we've not yet met the typedef name.  When we retrofit the typedef name
we were checking identifier matching and changing all type variants
with that identifier.  Which meant we ended up with a strange typedef
for the self reference.  This fixes things to check for DECL identity
of the variants, so we don't smash the self-reference -- that
continues to have the anonymous name.

PR c++/99208
gcc/cp/
* decl.c (name_unnamed_type): Check DECL identity, not IDENTIFIER
identity.
gcc/testsuite/
* g++.dg/modules/pr99208_a.C: New.
* g++.dg/modules/pr99208_b.C: New.

3 years agoIPA ICF + ASAN: do not merge vars with different alignment
Martin Liska [Tue, 23 Feb 2021 08:01:53 +0000 (09:01 +0100)]
IPA ICF + ASAN: do not merge vars with different alignment

gcc/ChangeLog:

PR sanitizer/99168
* ipa-icf.c (sem_variable::merge): Do not merge 2 variables
with different alignment. That leads to an invalid red zone
size allocated in runtime.

gcc/testsuite/ChangeLog:

PR sanitizer/99168
* c-c++-common/asan/pr99168.c: New test.

3 years agoc++: Fix folding of non-dependent BASELINKs [PR95468]
Patrick Palka [Tue, 23 Feb 2021 14:40:09 +0000 (09:40 -0500)]
c++: Fix folding of non-dependent BASELINKs [PR95468]

Here, the problem ultimately seems to be that tsubst_copy_and_build,
when called with empty args as we do during non-dependent expression
folding, doesn't touch BASELINKs at all: it delegates to tsubst_copy
which then immediately exits early due to the empty args.  This means
that the CAST_EXPR int(1) in the BASELINK A::condition<int(1)> never
gets folded (as part of folding of the overall CALL_EXPR), which later
causes us to crash when performing overload resolution of the rebuilt
CALL_EXPR (which is still in terms of this templated BASELINK).

This doesn't happen when condition() is a namespace-scope function
because then condition<int(1)> is represented by a TEMPLATE_ID_EXPR
rather than by a BASELINK, which does get handled directly from
tsubst_copy_and_build.

This patch fixes this issue by having tsubst_copy_and_build handle
BASELINK directly rather than delegating to tsubst_copy, so that it
processes BASELINKs even when args is empty.

gcc/cp/ChangeLog:

PR c++/95468
* pt.c (tsubst_copy_and_build) <case BASELINK>: New case, copied
over from tsubst_copy.

gcc/testsuite/ChangeLog:

PR c++/95468
* g++.dg/template/non-dependent15.C: New test.

3 years agoc++: Micro-optimize instantiation_dependent_expression_p
Patrick Palka [Tue, 23 Feb 2021 14:40:03 +0000 (09:40 -0500)]
c++: Micro-optimize instantiation_dependent_expression_p

This makes instantiation_dependent_expression_p avoid calling
potential_constant_expression when processing_template_decl isn't set
(and hence when value_dependent_expression_p is definitely false).

gcc/cp/ChangeLog:

* pt.c (instantiation_dependent_expression_p): Check
processing_template_decl before calling
potential_constant_expression.

3 years agoFix UBSAN in __ubsan::Value::getSIntValue
Martin Liska [Tue, 23 Feb 2021 10:14:03 +0000 (11:14 +0100)]
Fix UBSAN in __ubsan::Value::getSIntValue

/home/marxin/Programming/gcc2/libsanitizer/ubsan/ubsan_value.cpp:77:25: runtime error: left shift of 0x0000000000000000fffffffffffffffb by 96 places cannot be represented in type '__int128'
    #0 0x7ffff754edfe in __ubsan::Value::getSIntValue() const /home/marxin/Programming/gcc2/libsanitizer/ubsan/ubsan_value.cpp:77
    #1 0x7ffff7548719 in __ubsan::Value::isNegative() const /home/marxin/Programming/gcc2/libsanitizer/ubsan/ubsan_value.h:190
    #2 0x7ffff7542a34 in handleShiftOutOfBoundsImpl /home/marxin/Programming/gcc2/libsanitizer/ubsan/ubsan_handlers.cpp:338
    #3 0x7ffff75431b7 in __ubsan_handle_shift_out_of_bounds /home/marxin/Programming/gcc2/libsanitizer/ubsan/ubsan_handlers.cpp:370
    #4 0x40067f in main (/home/marxin/Programming/testcases/a.out+0x40067f)
    #5 0x7ffff72c8b24 in __libc_start_main (/lib64/libc.so.6+0x27b24)
    #6 0x4005bd in _start (/home/marxin/Programming/testcases/a.out+0x4005bd)

Differential Revision: https://reviews.llvm.org/D97263

Cherry-pick from 16ede0956cb1f4b692dfa619ccfa6ab1de28e19b.

3 years agoconfig.sub, config.guess : Import upstream 2021-01-25.
Kito Cheng [Thu, 18 Feb 2021 07:47:05 +0000 (15:47 +0800)]
config.sub, config.guess : Import upstream 2021-01-25.

Hi

Does it update config.sub and config.guess, I know it's already
stage 4, but the config.* stuff update should be harmless things,
and we need this for RISC-V big-endian support, which is already
supported in binutils 2.36.

This imports from:

sha1 6faca61810d335c7837f320733fe8e15a1431fc2

ChangeLog:

* config.guess: Import latest upstream.
* config.sub: Import latest upstream.

3 years agofold-const: Fix ICE in fold_read_from_constant_string on invalid code [PR99204]
Jakub Jelinek [Tue, 23 Feb 2021 08:49:48 +0000 (09:49 +0100)]
fold-const: Fix ICE in fold_read_from_constant_string on invalid code [PR99204]

fold_read_from_constant_string and expand_expr_real_1 have code to optimize
constant reads from string (tree vs. rtl).
If the STRING_CST array type has zero low bound, index is fold converted to
sizetype and so the compare_tree_int works fine, but if it has some other
low bound, it calls size_diffop_loc and that function from 2 sizetype
operands creates a ssizetype difference.  expand_expr_real_1 then uses
tree_fits_uhwi_p + compare_tree_int and so works fine, but fold-const.c
only checked if index is INTEGER_CST and calls compare_tree_int, which means
for negative index it will succeed and result in UB in the compiler.

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

PR tree-optimization/99204
* fold-const.c (fold_read_from_constant_string): Check that
tree_fits_uhwi_p (index) rather than just that index is INTEGER_CST.

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

3 years agolibstdc++: Fix up constexpr std::char_traits<char>::compare [PR99181]
Jakub Jelinek [Tue, 23 Feb 2021 08:30:18 +0000 (09:30 +0100)]
libstdc++: Fix up constexpr std::char_traits<char>::compare [PR99181]

Because of LWG 467, std::char_traits<char>::lt compares the values
cast to unsigned char rather than char, so even when char is signed
we get unsigned comparision.  std::char_traits<char>::compare uses
__builtin_memcmp and that works the same, but during constexpr evaluation
we were calling __gnu_cxx::char_traits<char_type>::compare.  As
char_traits::lt is not virtual, __gnu_cxx::char_traits<char_type>::compare
used __gnu_cxx::char_traits<char_type>::lt rather than
std::char_traits<char>::lt and thus compared chars as signed if char is
signed.
This change fixes it by inlining __gnu_cxx::char_traits<char_type>::compare
into std::char_traits<char>::compare by hand, so that it calls the right
lt method.

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

PR libstdc++/99181
* include/bits/char_traits.h (char_traits<char>::compare): For
constexpr evaluation don't call
__gnu_cxx::char_traits<char_type>::compare but do the comparison loop
directly.

* testsuite/21_strings/char_traits/requirements/char/99181.cc: New
test.

3 years agolibstdc++: Fix up parallel_backend_serial.h [PR97549]
Jakub Jelinek [Tue, 23 Feb 2021 08:26:23 +0000 (09:26 +0100)]
libstdc++: Fix up parallel_backend_serial.h [PR97549]

In GCC 10, parallel_backend.h just included parallel_backend_{serial,tbb}.h and
did nothing beyond that, and parallel_backend_tbb.h provided directly
namespace __pstl { namespace __par_backend { ... } }
and defined everything in there, while parallel_backend_serial.h did:
namespace __pstl { namespace __serial { ... } } and had this
namespace __pstl { namespace __par_backend { using namespace __pstl::__serial; } }
at the end.
In GCC 11, parallel_backend.h does:
namespace __pstl { namespace __par_backend = __serial_backend; }
after including parallel_backend_serial.h or
namespace __pstl { namespace __par_backend = __tbb_backend; }
after including parallel_backend_tbb.h.  The latter then has:
namespace __pstl { namespace __tbb_backend { ... } }
and no using etc. at the end, while parallel_backend_serial.h changed to:
namespace __pstl { namespace __serial_backend { ... } }
but has this leftover block from the GCC 10 times.  Even changing that
using namespace __pstl::__serial;
to
using namespace __pstl::__serial_backend;
doesn't work, as it clashes with
namespace __pstl { namespace __par_backend = __serial_backend; }
in parallel_backend.h.

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

PR libstdc++/97549
* include/pstl/parallel_backend_serial.h: Remove __pstl::__par_backend.

3 years agors6000: Use rldimi for vec init instead of shift + ior
Kewen Lin [Mon, 14 Dec 2020 09:38:49 +0000 (03:38 -0600)]
rs6000: Use rldimi for vec init instead of shift + ior

This patch is to teach unsigned int vector init to use rldimi to
merge two integers instead of shift and ior.  It also adds one
required splitter made by Segher.

An rl*imi is usually written as an IOR of an ASHIFT or similar, and
an AND of a register with a constant mask.  In some cases combine
knows that that AND doesn't do anything (because all zero bits in
that mask correspond to bits known to be already zero), and then no
pattern matches.  This patch adds a define_split for such cases.

It uses nonzero_bits in the condition of the splitter, but does not
need it afterwards for the instruction to be recognised.  This is
necessary because later passes can see fewer nonzero_bits.

Because it is a splitter, combine will only use it when starting with
three insns (or more), even though the result is just one.  This isn't
a huge problem in practice, but some possible combinations still won't
happen.

Bootstrapped/regtested on powerpc64le-linux-gnu P9 and
powerpc64-linux-gnu P8, also SPEC2017 build/run passed on P9.

gcc/ChangeLog:

2020-02-23  Segher Boessenkool  <segher@kernel.crashing.org>
    Kewen Lin  <linkw@gcc.gnu.org>

* config/rs6000/rs6000.md (*rotl<mode>3_insert_3): Renamed to...
(rotl<mode>3_insert_3): ...this.
(plus_ior_xor): New code_iterator.
(define_split for GPR rl*imi): New splitter.
* config/rs6000/vsx.md (vsx_init_v4si): Use gen_rotldi3_insert_3
for integer merging.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/vec-init-10.c: New test.

3 years agolibstdc++: Fix endianness issue with IBM long double [PR98384]
Patrick Palka [Tue, 23 Feb 2021 02:49:25 +0000 (21:49 -0500)]
libstdc++: Fix endianness issue with IBM long double [PR98384]

The code in std::to_chars for extracting the high- and low-order parts
of an IBM long double value does the right thing on powerpc64le, but not
on powerpc64be.  This patch makes the extraction endian-agnostic, which
fixes the execution FAIL of to_chars/long_double.cc on powerpc64be.

libstdc++-v3/ChangeLog:

PR libstdc++/98384
* src/c++17/floating_to_chars.cc (get_ieee_repr): Extract
the high- and low-order parts from an IBM long double value
in an endian-agnostic way.

3 years agoUpdate gcc sv.po.
Joseph Myers [Tue, 23 Feb 2021 00:55:10 +0000 (00:55 +0000)]
Update gcc sv.po.

* sv.po: Update.