Jonathan Wakely [Tue, 25 Feb 2020 12:21:44 +0000 (12:21 +0000)]
libstdc++: Fix regression in std::move algorithm (PR 93872)
The std::move and std::move_backward algorithms dispatch to the
std::__memmove helper when appropriate. That function uses a
pointer-to-const for the source values, preventing them from being
moved. The two callers of that function have the same problem.
Rather than altering __memmove and its callers to work with const or
non-const source pointers, this takes a more conservative approach of
casting away the const at the point where we want to do a move
assignment. This relies on the fact that we only use __memmove when the
type is trivially copyable, so we know the move assignment doesn't alter
the source anyway.
PR libstdc++/93872
* include/bits/stl_algobase.h (__memmove): Cast away const before
doing move assignment.
* testsuite/25_algorithms/move/93872.cc: New test.
* testsuite/25_algorithms/move_backward/93872.cc: New test.
Eric Botcazou [Tue, 25 Feb 2020 11:34:00 +0000 (12:34 +0100)]
Fix link failure with debug info in LTO mode
This fixes a regression whereby the program fails to link with debug
info in LTO mode because of an undefined reference to a symbol coming
from the object files containing the early debug info.
* dwarf2out.c (dwarf2out_size_function): Run in early-DWARF mode.
Richard Biener [Tue, 25 Feb 2020 09:31:16 +0000 (10:31 +0100)]
tree-optimization/93868 copy SLP tree before re-arranging stmts
This avoids altering possibly shared SLP subtrees when attempting
to get rid of permutations in SLP reductions by copying the SLP
subtree before re-arranging stmts in it.
2020-02-25 Richard Biener <rguenther@suse.de>
PR tree-optimization/93868
* tree-vect-slp.c (slp_copy_subtree): New function.
(vect_attempt_slp_rearrange_stmts): Copy the SLP tree before
re-arranging stmts in it.
Jakub Jelinek [Tue, 25 Feb 2020 09:21:34 +0000 (10:21 +0100)]
pass_manager: Fix ICE with -fdump-passes -fdisable-tree-* [PR93874]
dump_passes pushes a dummy function for which it evaluates the gates
and checks whether the pass is enabled or disabled.
Unfortunately, if any -fdisable-*-*/-fenable-*-* options were seen,
we ICE during is_pass_explicitly_enabled_or_disabled because slot
is non-NULL then and the code will do:
cgraph_uid = func ? cgraph_node::get (func)->get_uid () : 0;
but the dummy function doesn't have a cgraph node.
So, either we need to create and then remove a cgraph node for the dummy
function like the following patch, or function.c would need to export the
in_dummy_function flag (or have some way to query that flag from other TUs)
and we'd need to check it in is_pass_explicitly_enabled_or_disabled.
2020-02-25 Jakub Jelinek <jakub@redhat.com>
PR middle-end/93874
* passes.c (pass_manager::dump_passes): Create a cgraph node for the
dummy function and remove it at the end.
Seems the test has been badly reduced (if the original doesn't emit
warnings, it is always better in the reduction script avoid introducing new
ones).
Also, the g++.dg/ipa/ test fails with -std=c++98 because it is written in
C++11.
2020-02-25 Jakub Jelinek <jakub@redhat.com>
PR ipa/93763
* gcc.dg/ipa/pr93763.c: Adjust the test so that it compiles without
warnings and still ICEs before the ipa-cp.c fix.
* g++.dg/ipa/pr93763.C: Require c++11 effective target.
Roman Zhuykov [Tue, 25 Feb 2020 07:15:49 +0000 (10:15 +0300)]
doc: properly describe --enable-checking behavior
This patch rewords the whole description to fix minor issues:
- documents 'gimple' and 'types' checks,
- clarifies what happens when option is used without '=list',
- fixes inaccurate wrong wording about release snapshots,
- describes that release checks can only de disabled explicitly.
gcc/ChangeLog:
* doc/install.texi (--enable-checking): Properly document current
behavior.
(--enable-stage1-checking): Minor clarification about bootstrap.
David Malcolm [Fri, 21 Feb 2020 15:50:16 +0000 (10:50 -0500)]
analyzer: disable the "taint" checker by default
PR analyzer/93032 tracks a false negative where we fail to report
FILE * leaks within zlib/contrib/minizip/mztools.c.
The underlying issue is a combinatorial explosion of states within the
exploded graph. In particular, the state of the "taint" checker is
exploding, leading to the analyzer bailing out.
I have a patch kit under construction that fixes the state explosion
issue enough for the "file" checker to report the leaks, but doing so
requires disabling the "taint" checker. Given that the latter is more
of a proof-of-concept, this patch disables it by default, to stop it
breaking the other checkers.
gcc/analyzer/ChangeLog:
PR analyzer/93032
* sm.cc (make_checkers): Require the "taint" checker to be
explicitly enabled.
gcc/ChangeLog:
PR analyzer/93032
* doc/invoke.texi (-Wnanalyzer-tainted-array-index): Note that
-fanalyzer-checker=taint is also required.
(-fanalyzer-checker=): Note that providing this option enables the
given checker, and doing so may be required for checkers that are
disabled by default.
Doing so means that numerous places that create regions now need to have
a context passed to them, so most of the patch is churn involved in
passing a context around to where it's needed.
gcc/analyzer/ChangeLog:
PR analyzer/93899
* engine.cc
(impl_region_model_context::impl_region_model_context): Add logger
param.
* engine.cc (exploded_graph::add_function_entry): Create an
impl_region_model_context and pass it to the push_frame call.
Bail if the resulting state is invalid.
(exploded_graph::build_initial_worklist): Likewise.
(exploded_graph::build_initial_worklist): Handle the case where
add_function_entry fails.
* exploded-graph.h
(impl_region_model_context::impl_region_model_context): Add logger
param.
* region-model.cc (map_region::get_or_create): Add ctxt param and
pass it to add_region_for_type.
(map_region::can_merge_p): Pass NULL as a ctxt to call to
get_or_create.
(array_region::get_element): Pass ctxt to call to get_or_create.
(array_region::get_or_create): Add ctxt param and pass it to
add_region_for_type.
(root_region::push_frame): Pass ctxt to get_or_create calls.
(region_model::get_lvalue_1): Likewise.
(region_model::make_region_for_unexpected_tree_code): Assert that
ctxt is non-NULL.
(region_model::get_rvalue_1): Pass ctxt to get_svalue_for_fndecl
and get_svalue_for_label calls.
(region_model::get_svalue_for_fndecl): Add ctxt param and pass it
to get_region_for_fndecl.
(region_model::get_region_for_fndecl): Add ctxt param and pass it
to get_or_create.
(region_model::get_svalue_for_label): Add ctxt param and pass it
to get_region_for_label.
(region_model::get_region_for_label): Add ctxt param and pass it
to get_region_for_fndecl and get_or_create.
(region_model::get_field_region): Add ctxt param and pass it to
get_or_create_view and get_or_create.
(make_region_for_type): Replace gcc_unreachable with return NULL.
(region_model::add_region_for_type): Add ctxt param. Handle a
return of NULL from make_region_for_type by calling
make_region_for_unexpected_tree_code.
(region_model::get_or_create_mem_ref): Pass ctxt to calls to
get_or_create_view.
(region_model::get_or_create_view): Add ctxt param and pass it to
add_region_for_type.
(selftest::test_state_merging): Pass ctxt to get_or_create_view.
* region-model.h (region_model::get_or_create): Add ctxt param.
(region_model::add_region_for_type): Likewise.
(region_model::get_svalue_for_fndecl): Likewise.
(region_model::get_svalue_for_label): Likewise.
(region_model::get_region_for_fndecl): Likewise.
(region_model::get_region_for_label): Likewise.
(region_model::get_field_region): Likewise.
(region_model::get_or_create_view): Likewise.
gcc/testsuite/ChangeLog:
PR analyzer/93899
* g++.dg/analyzer/pr93899.C: New test.
David Malcolm [Sat, 22 Feb 2020 00:25:40 +0000 (19:25 -0500)]
analyzer: eliminate irrelevant control-flow edges from paths
Paths emitted by the analyzer can be quite verbose at the default of
-fanalyzer-verbosity=2.
Consider the double-free in this example:
#include <stdlib.h>
int foo ();
int bar ();
void test (int a, int b, int c)
{
void *p = malloc (1024);
while (a)
foo ();
if (b)
foo ();
else
bar ();
if (c)
free (p);
free (p);
}
Previously, the analyzer would emit a checker_path containing all
control-flow information on the exploded_path leading to the
double-free:
test.c: In function 'test':
test.c:17:3: warning: double-'free' of 'p' [CWE-415] [-Wanalyzer-double-free]
17 | free (p);
| ^~~~~~~~
'test': events 1-9
|
| 8 | void *p = malloc (1024);
| | ^~~~~~~~~~~~~
| | |
| | (1) allocated here
| 9 | while (a)
| | ~
| | |
| | (2) following 'false' branch (when 'a == 0')...
| 10 | foo ();
| 11 | if (b)
| | ~
| | |
| | (3) ...to here
| | (4) following 'false' branch (when 'b == 0')...
|......
| 14 | bar ();
| | ~~~~~~
| | |
| | (5) ...to here
| 15 | if (c)
| | ~
| | |
| | (6) following 'true' branch (when 'c != 0')...
| 16 | free (p);
| | ~~~~~~~~
| | |
| | (7) ...to here
| | (8) first 'free' here
| 17 | free (p);
| | ~~~~~~~~
| | |
| | (9) second 'free' here; first 'free' was at (8)
|
despite the fact that only the "if (c)" is relevant to triggering the
double-free.
This patch implements pruning of control flow events at
-fanalyzer-verbosity=2, based on reachability information within the
exploded_graph.
The diagnostic_manager pre-computes reachability information about
which exploded_nodes can reach the exploded_node of the diagnostic,
and uses this to prune irrelvent control flow edges.
The patch also adds a -fanalyzer-verbosity=3 to preserve these edges,
so that the "show me everything" debugging level becomes
-fanalyzer-verbosity=4.
With these changes, the "while (a)" and "if (b)" edges are pruned from
the above example, leading to:
test.c: In function 'test':
test.c:17:3: warning: double-'free' of 'p' [CWE-415] [-Wanalyzer-double-free]
17 | free (p);
| ^~~~~~~~
'test': events 1-5
|
| 8 | void *p = malloc (1024);
| | ^~~~~~~~~~~~~
| | |
| | (1) allocated here
|......
| 15 | if (c)
| | ~
| | |
| | (2) following 'true' branch (when 'c != 0')...
| 16 | free (p);
| | ~~~~~~~~
| | |
| | (3) ...to here
| | (4) first 'free' here
| 17 | free (p);
| | ~~~~~~~~
| | |
| | (5) second 'free' here; first 'free' was at (4)
|
The above example is gcc.dg/analyzer/edges-2.c.
gcc/analyzer/ChangeLog:
* checker-path.cc (superedge_event::should_filter_p): Update
filter for empty descriptions to cover verbosity level 3 as well
as 2.
* diagnostic-manager.cc: Include "analyzer/reachability.h".
(class path_builder): New class.
(diagnostic_manager::emit_saved_diagnostic): Create a path_builder
and pass it to build_emission_path, rather passing eg; similarly
for add_events_for_eedge and ext_state.
(diagnostic_manager::build_emission_path): Replace "eg" param
with a path_builder, pass it to add_events_for_eedge.
(diagnostic_manager::add_events_for_eedge): Replace ext_state
param with path_builder; pass it to add_events_for_superedge.
(diagnostic_manager::significant_edge_p): New.
(diagnostic_manager::add_events_for_superedge): Add path_builder
param. Reject insignificant edges at verbosity levels below 3.
(diagnostic_manager::prune_for_sm_diagnostic): Update highest
verbosity level to 4.
* diagnostic-manager.h (class path_builder): New forward decl.
(diagnostic_manager::build_emission_path): Replace "eg" param
with a path_builder.
(diagnostic_manager::add_events_for_eedge): Replace ext_state
param with path_builder.
(diagnostic_manager::significant_edge_p): New.
(diagnostic_manager::add_events_for_superedge): Add path_builder
param.
* reachability.h: New file.
gcc/ChangeLog:
* doc/invoke.texi (-fanalyzer-verbosity=): "2" only shows
significant control flow events; add a "3" which shows all
control flow events; the old "3" becomes "4".
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/analyzer-verbosity-2a.c: New test.
* gcc.dg/analyzer/analyzer-verbosity-3.c: New test, based on
analyzer-verbosity-2.c
* gcc.dg/analyzer/analyzer-verbosity-3a.c: New test.
* gcc.dg/analyzer/edges-1.c: New test.
* gcc.dg/analyzer/edges-2.c: New test.
* gcc.dg/analyzer/file-paths-1.c: Add -fanalyzer-verbosity=3.
Marek Polacek [Fri, 21 Feb 2020 17:58:04 +0000 (12:58 -0500)]
c++: Fix ICE with -Wmismatched-tags [PR93869]
This is a crash in cp_parser_check_class_key:
tree type_decl = TYPE_MAIN_DECL (type);
tree name = DECL_NAME (type_decl); // HERE
because TYPE_MAIN_DECL of type was null as it's not a class type.
Instead of checking CLASS_TYPE_P we should simply check class_key
a bit earlier (in this case it was typename_type).
Mark Eggleston [Mon, 24 Feb 2020 15:40:03 +0000 (15:40 +0000)]
ortran: ICE using SHAPE with FINDLOC PR93835
The expression representing the array returned by SHAPE does not
have its shape defined. An ICE occurs when FINDLOC attempts to
use the shape of the array. Add shape to expression before returning
from SHAPE.
Whitespace issues identified by Steven G. Kargl <kargl@gcc.gnu.org>
have also been fixed.
gcc/fortran/ChangeLog
PR fortran/93835
* simplify.c (simplify_findloc_nodim) : Fix whitespace issues.
(gfc_simplify_shape) : Create and initialise one shape value
for the result expression. Set shape value with the rank of
the source array.
gcc/testsuite/ChangeLog
PR fortran/93835
* gfortran.dg/pr77351.f90 : Check for one error instead of two.
* gfortran.dg/pr93835.f08 : New test.
Marek Polacek [Thu, 13 Feb 2020 19:05:51 +0000 (14:05 -0500)]
c++: Fix ICE with ill-formed array list-initialization [PR93712]
My P0388R4 patch changed build_array_conv to create an identity
conversion at the start of the conversion chain and now we crash
in convert_like_real:
7457 case ck_identity:
7458 if (BRACE_ENCLOSED_INITIALIZER_P (expr))
7459 {
7460 int nelts = CONSTRUCTOR_NELTS (expr);
7461 if (nelts == 0)
7462 expr = build_value_init (totype, complain);
7463 else if (nelts == 1)
7464 expr = CONSTRUCTOR_ELT (expr, 0)->value;
7465 else
7466 gcc_unreachable (); // HERE
7467 }
in a test like this
int f (int const (&)[2])
{ return f({1, "M"}); }
Instead of creating a ck_identity at the start of the conversion chain,
so that conv_get_original_expr can be used with a ck_aggr, let's set
u.expr for a ck_aggr, and adjust next_conversion not to try to see
what's next in the chain if it gets a ck_aggr.
2020-02-24 Marek Polacek <polacek@redhat.com>
PR c++/93712 - ICE with ill-formed array list-initialization.
* call.c (next_conversion): Return NULL for ck_aggr.
(build_aggr_conv): Set u.expr instead of u.next.
(build_array_conv): Likewise.
(build_complex_conv): Likewise.
(conv_get_original_expr): Handle ck_aggr.
Patrick Palka [Mon, 24 Feb 2020 12:59:08 +0000 (07:59 -0500)]
libstdc++: Add missing bits of P0896R4 pertaining to [back|front]_insert_iterator
This adds some missing pieces of the Ranges TS that make back_insert_iterator and
front_insert_iterator conform to the new output_iterator requirements.
It also fixes a bug in ranges::__copy_or_move and
ranges::__copy_or_move_backward in which we were inspecting the iter_value_t of
the output iterator, but output iterators such as back_insert_iterator and
front_insert_iterator whose value_type = void do not have an iter_value_t
according to [readable.traits] p4. The entire __use_memmove condition should
probably be rewritten, but the simplest fix for now is to inspect the
iterator_traits of the output iterator instead.
libstdc++-v3/ChangeLog:
PR libstdc++/93884
* include/bits/ranges_algobase.h (__copy_or_move,
__copy_or_move_backward): Don't inspect the iter_value_t of the output
iterator, instead inspect its iterator_traits directly.
* include/bits/stl_iterator.h (back_insert_iterator::container):
Conditionally initialize.
(back_insert_iterator::difference_type): Conditionally define.
(back_insert_iterator::back_insert_iterator): Conditionally define this
default constructor.
(front_insert_iterator::container): Conditionally initialize.
(front_insert_iterator::difference_type): Conditionally define.
(front_insert_iterator::front_insert_iterator): Conditionally define
this default constructor.
* 24_iterators/back_insert_iterator/pr93884.cc: New test.
* 24_iterators/front_insert_iterator/pr93884.cc: New test.
Patrick Palka [Fri, 21 Feb 2020 18:55:01 +0000 (13:55 -0500)]
libstdc++: P0769R2 Add shift to <algorithm>
This patch adds std::shift_left and std::shift_right as per P0769R2. Alhough
these are STL-style algos, this patch places them in <bits/ranges_algo.h>
because they make use of some functions in the ranges namespace that are more
easily reachable from <bits/ranges_algo.h> than from <bits/stl_algo.h>, namely
ranges::next. In order to place these algos in <bits/stl_algo.h>, we would need
to include <bits/range_access.h> from <bits/stl_algo.h> which would undesirably
increase the size of <bits/stl_algo.h>.
libstdc++-v3/ChangeLog:
P0769R2 Add shift to <algorithm>
* include/bits/ranges_algo.h (shift_left, shift_right): New.
* testsuite/25_algorithms/shift_left/1.cc: New test.
* testsuite/25_algorithms/shift_right/1.cc: New test.
Mark Eggleston [Mon, 24 Feb 2020 14:33:35 +0000 (14:33 +0000)]
fortran: ICE in gfc_conv_constant_to_tree PR93604
Using a BOZ constant in a structure constructor in a data statement
resulted in an ICE. Output a "BOZ literal constant cannot appear in
a structure constructor" error message instead.
Original patch provided by Steven G. Kargl <kargl@gcc.gnu.org>.
Test case added later.
gcc/fortran/ChangeLog
PR fortran/93604
* decl.c (gfc_match_data) : Check whether the data expression
is a derived type and is a constructor. If a BOZ constant
is encountered in the constructor output an error and return
MATCH_ERROR.
gcc/testsuite/ChangeLog
PR fortran/93604
* gfortran.dg/pr93604.f90 : New test.
Jakub Jelinek [Mon, 24 Feb 2020 14:23:23 +0000 (15:23 +0100)]
c++: P1937R2 - Fixing inconsistencies between const{expr,eval} functions
The following patch implements my understanding of P1937R2, though I wonder
if https://eel.is/c++draft/expr.const#14.example-1 shouldn't have been
also either removed or adjusted by the P1937R2 paper.
2020-02-24 Jakub Jelinek <jakub@redhat.com>
P1937R2 - Fixing inconsistencies between const{expr,eval} functions
* call.c (build_over_call): Don't evaluate immediate functions in
unevaluated operands.
* g++.dg/ext/consteval1.C: Change dg-{message,error} into dg-bogus.
* g++.dg/cpp2a/consteval6.C: Likewise.
* g++.dg/cpp2a/consteval3.C: Change dg-error for unevaluated operands
into dg-bogus.
Christophe Lyon [Mon, 24 Feb 2020 13:01:52 +0000 (13:01 +0000)]
PR78353: Fix testcases
Skip the test if arm7a is not supported at link time. This is the case
if the toolchain targets an M-profile CPU by default and does not have
A-profile multilib: the link step fails because it tries to mix
M-profile startup files with A-profile testcase.
Jakub Jelinek [Mon, 24 Feb 2020 11:56:39 +0000 (12:56 +0100)]
sccvn: Handle bitfields in push_partial_def [PR93582]
The following patch adds support for bitfields to push_partial_def.
Previously pd.offset and pd.size were counted in bytes and maxsizei
in bits, now everything is counted in bits.
Not really sure how much of the further code can be outlined and moved, e.g.
the full def and partial def code doesn't have pretty much anything in
common (the partial defs case basically have some load bit range and a set
of store bit ranges that at least partially overlap and we need to handle
all the different cases, like negative pd.offset or non-negative, little vs.
bit endian, size so small that we need to preserve original bits on both
sides of the byte, size that fits or is too large.
Perhaps the storing of some value into a middle of existing buffer (i.e.
what push_partial_def now does in the loop) could, but the candidate for
sharing would be most likely store-merging rather than the other spots in
sccvn, and I think it is better not to touch store-merging at this stage.
Yes, I've thought about trying to do everything in place, but the code is
quite hard to understand and get right already now and if we tried to do the
optimize on the fly, it would need more special cases and would for gcov
coverage need more testcases to cover it. Most of the time the sizes will
be small. Furthermore, for bitfields native_encode_expr stores actually
number of bytes in the mode and not say actual bitsize rounded up to bytes,
so it wouldn't be just a matter of saving/restoring bytes at the start and
end, but we might need even 7 further bytes e.g. for __int128 bitfields.
Perhaps we could have just a fast path for the case where everything is byte
aligned and (for integral types the mode bitsize is equal to the size too)?
2020-02-24 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/93582
* tree-ssa-sccvn.c (vn_walk_cb_data::push_partial_def): Consider
pd.offset and pd.size to be counted in bits rather than bytes, add
support for maxsizei that is not a multiple of BITS_PER_UNIT and
handle bitfield stores and loads.
(vn_reference_lookup_3): Don't call ranges_known_overlap_p with
uncomparable quantities - bytes vs. bits. Allow push_partial_def
on offsets/sizes that aren't multiple of BITS_PER_UNIT and adjust
pd.offset/pd.size to be counted in bits rather than bytes.
Formatting fix. Rename shadowed len variable to buflen.
* gcc.dg/tree-ssa/pr93582-4.c: New test.
* gcc.dg/tree-ssa/pr93582-5.c: New test.
* gcc.dg/tree-ssa/pr93582-6.c: New test.
* gcc.dg/tree-ssa/pr93582-7.c: New test.
* gcc.dg/tree-ssa/pr93582-8.c: New test.
Fix handling of floating-point homogeneous aggregates.
2020-02-21 John David Anglin <danglin@gcc.gnu.org>
* gcc/config/pa/pa.c (pa_function_value): Fix check for word and
double-word size when handling aggregate return values.
* gcc/config/pa/som.h (ASM_DECLARE_FUNCTION_NAME): Fix to indicate
that homogeneous SFmode and DFmode aggregates are passed and returned
in general registers.
Jakub Jelinek [Fri, 21 Feb 2020 21:01:03 +0000 (22:01 +0100)]
i18n: Fix translation of --help [PR93759]
The first two hunks make sure we actually translate what has been marked
for translation, i.e. the cl_options[...].help strings, rather than those
strings ammended in various ways, like:
_("%s Same as %s."), help, ...
or
"%s %s", help, _(use_diagnosed_msg)
The exgettext changes attempt to make sure that the cl_options[...].help
strings are marked as no-c-format, because otherwise if they happen
to contain a % character, such as the 90% substring, they will be marked
as c-format, which they aren't.
2020-02-21 Jakub Jelinek <jakub@redhat.com>
PR translation/93759
* opts.c (print_filtered_help): Translate help before appending
messages to it rather than after that.
* exgettext: For *.opt help texts, use __opt_help_text("...")
rather than _("...") in the $emsg file and pass options that
say that this implies no-c-format.
lra: Stop registers being incorrectly marked live v2 [PR92989]
This PR is about a case in which the clobbers at the start of
an EH receiver can lead to registers becoming unnecessarily
live in predecessor blocks. My first attempt at fixing this
made sure that we update the bb liveness info based on the
real live set:
But it turns out that the clobbered registers were also added to
the "gen" set of LRA's private liveness problem, where "gen" in
this context means "generates a requirement for a live value".
So the clobbered registers could still end up live via that
mechanism instead.
This patch therefore reverts the patch above and takes the other
approach floated in the original patch description: model the full
clobber by making the registers live and then dead again.
There's no specific need to revert the original patch, since the
code should no longer be sensitive to the order of the bb liveness
update and the modelling of the clobber. But given that there's
no specific need to keep the original patch either, it seemed better
to restore the code to the more well-tested order.
Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install?
Richard
2020-02-19 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR rtl-optimization/PR92989
* lra-lives.c (process_bb_lives): Restore the original order
of the bb liveness update. Call make_hard_regno_dead for each
register clobbered at the start of an EH receiver.
Uros Bizjak [Fri, 21 Feb 2020 15:23:30 +0000 (16:23 +0100)]
testsuite: Add -fcommon to gcc.target/i386/pr69052.c
This testcase is susceptible to memory location details and start to fail
with default to -fno-common. Use -fcommon to set expected testing conditions.
Uros Bizjak [Fri, 21 Feb 2020 15:12:57 +0000 (16:12 +0100)]
testsuite: Require vect_mutiple_sizes for scan-tree-dump in vect-epilogues.c
Default testsuite flags do not enable V8QI (MMX) vector mode for
32bit x86 targets. Require vect_multiple_sizes effective target in
scan-tree-dump to avoid "LOOP EPILOGUE VECTORIZED" failure.
Frederik Harwath [Fri, 21 Feb 2020 14:26:02 +0000 (15:26 +0100)]
Adapt libgomp acc_get_property.f90 test
The commit r10-6721-g8d1a1cb1b816381bf60cb1211c93b8eba1fe1472 has changed
the name of the type that is used for the return value of the Fortran
acc_get_property function without adapting the test acc_get_property.f90.
2020-02-21 Frederik Harwath <frederik@codesourcery.com>
* testsuite/libgomp.oacc-fortran/acc_get_property.f90: Adapt to
changes from 2020-02-19, i.e. use integer(c_size_t) instead of
integer(acc_device_property) for the type of the return value of
acc_get_property.
Jan Hubicka [Fri, 21 Feb 2020 14:36:00 +0000 (15:36 +0100)]
tree-optimization: fix access path oracle on mismatched array refs [PR93586]
nonoverlapping_array_refs_p is not supposed to give meaningful results when
bases of ref1 and ref2 are not same or completely disjoint and here it is
called on c[0][j_2][0] and c[0][1] so bases in sence of this functions are
"c[0][j_2]" and "c[0]" which do partially overlap. nonoverlapping_array_refs
however walks pair of array references and in this case it misses to note the
fact that if it walked across first mismatched pair it is no longer safe to
compare rest.
The reason why it continues matching is because it hopes it will
eventually get pair of COMPONENT_REFs from types of same size and use
TBAA to conclude that their addresses must be either same or completely
disjoint.
This patch makes the loop to terminate early but popping all the
remaining pairs so walking can continue. We could re-synchronize on
arrays of same size with TBAA but this is bit fishy (because we try to
support some sort of partial array overlaps) and hard to implement
(because of zero sized arrays and VLAs) so I think it is not worth the
effort.
In addition I notied that the function is not !flag_strict_aliasing safe
and added early exits on places we set seen_unmatched_ref_p since later
we do not check that in:
/* If we skipped array refs on type of different sizes, we can
no longer be sure that there are not partial overlaps. */
if (seen_unmatched_ref_p
&& !operand_equal_p (TYPE_SIZE (type1), TYPE_SIZE (type2), 0))
{
++alias_stats
.nonoverlapping_refs_since_match_p_may_alias;
}
PR tree-optimization/93586
* tree-ssa-alias.c (nonoverlapping_array_refs_p): Finish array walk
after mismatched array refs; do not sure type size information to
recover from unmatched referneces with !flag_strict_aliasing_p.
Andrew Stubbs [Thu, 20 Feb 2020 14:44:04 +0000 (14:44 +0000)]
amdgcn: Use correct offset mode for gather/scatter
The scatter/gather pattern names changed for GCC 10, but I hadn't noticed.
This switches the patterns to the new offset mode scheme.
2020-02-21 Andrew Stubbs <ams@codesourcery.com>
gcc/
* config/gcn/gcn-valu.md (gather_load<mode>): Rename to ...
(gather_load<mode>v64si): ... this and set operand 2 to V64SI.
(scatter_store<mode>): Rename to ...
(scatter_store<mode>v64si): ... this and set operand 1 to V64SI.
(scatter<mode>_exec): Delete. Move contents ...
(mask_scatter_store<mode>): ... here, and rename that to ...
(mask_gather_load<mode>v64si): ... this. Set operand 2 to V64SI.
Remove mode conversion.
(mask_gather_load<mode>): Rename to ...
(mask_scatter_store<mode>v64si): ... this. Set operand 1 to V64SI.
Remove mode conversion.
* config/gcn/gcn.c (gcn_expand_scaled_offsets): Remove mode conversion.
Martin Jambor [Fri, 21 Feb 2020 12:38:22 +0000 (13:38 +0100)]
sra: Only verify sizes of scalar accesses (PR 93845)
the testcase is another example - in addition to recent PR 93516 - where
the SRA access verifier is confused by the fact that get_ref_base_extent
can return different sizes for the same type, depending whether they are
COMPONENT_REF or not. In the previous bug I decided to keep the
verifier check for aggregate type even though it is not really important
and instead avoid easily detectable type-within-the-same-type situation.
This testcase is however a result of a fairly random looking type cast
and so cannot be handled in the same way.
Because the check is not really important for aggregates, this patch
simply disables it for non-register types.
2020-02-21 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/93845
* tree-sra.c (verify_sra_access_forest): Only test access size of
scalar types.
Andrew Stubbs [Fri, 21 Feb 2020 11:07:55 +0000 (11:07 +0000)]
amdgcn: Align VGPR pairs
Aligning the registers is not needed by the architecture, but doing so
allows us to remove the requirement for bug-prone early-clobber
constraints from many split patterns (and avoid adding more in future).
SVE was missing support for -mlow-precision-sqrt, which meant that
-march=armv8.2-a+sve -mlow-precision-sqrt could cause a performance
regression compared to -march=armv8.2-a -mlow-precision-sqrt.
2020-02-21 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* config/aarch64/aarch64.c (aarch64_emit_approx_sqrt): Add SVE
support. Use aarch64_emit_mult instead of emitting multiplication
instructions directly.
* config/aarch64/aarch64-sve.md (sqrt<mode>2, rsqrt<mode>2)
(@aarch64_rsqrte<mode>, @aarch64_rsqrts<mode>): New expanders.
SVE was missing support for -mlow-precision-div, which meant that
-march=armv8.2-a+sve -mlow-precision-div could cause a performance
regression compared to -march=armv8.2-a -mlow-precision-div.
I ended up doing this much later than originally intended, sorry...
2020-02-21 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* config/aarch64/aarch64.c (aarch64_emit_mult): New function.
(aarch64_emit_approx_div): Add SVE support. Use aarch64_emit_mult
instead of emitting multiplication instructions directly.
* config/aarch64/iterators.md (SVE_COND_FP_BINARY_OPTAB): New iterator.
* config/aarch64/aarch64-sve.md (div<mode>3, @aarch64_frecpe<mode>)
(@aarch64_frecps<mode>): New expanders.
We now have more than 32 scalar and vector float modes, so the
32-bit AARCH64_APPROX_MODE would invoke UB for some of them.
Bumping to a 64-bit mask fixes that... for now.
Ideally we'd have a static assert to trap this, but logically
it would go at file scope. I think it would be better to wait
until the switch to C++11, so that we can use static_assert
directly.
2020-02-21 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* config/aarch64/aarch64-protos.h (AARCH64_APPROX_MODE): Operate
on and produce uint64_ts rather than ints.
(AARCH64_APPROX_NONE, AARCH64_APPROX_ALL): Change to uint64_ts.
(cpu_approx_modes): Change the fields from unsigned int to uint64_t.
The fix for PR80530 included an accidental flipping of the
flag_finite_math_only check, so that -ffinite-math-only (and thus
-ffast-math) disabled approximate sqrt rather than enabling it.
This is tested by later patches but seemed worth splitting out.
2020-02-21 Richard Sandiford <richard.sandiford@arm.com>
Palmer Dabbelt [Wed, 30 Oct 2019 04:40:09 +0000 (21:40 -0700)]
MAINTAINERS: Change to my personal email address
I left SiFive a bit more than three months ago, and while I sent out a message
saying I was going to updated my email address I neclected to actually do so.
I'm moving to my personal email address to avoid the need to do this again.
gcc/ChangeLog
2020-02-20 Palmer Dabbelt <palmer@sifive.com>
* MAINTAINERS: Change palmer@sifive.com to palmer@dabbelt.com.
Alexandre Oliva [Fri, 21 Feb 2020 01:09:03 +0000 (22:09 -0300)]
Allow CONFIG_SHELL to override build-time shell in mkheaders
mkheaders.in uses substitutions of @SHELL@ to run fixinc.sh and
mkinstalldirs. Problem is, SHELL comes from CONFIG_SHELL for the
build system, and it needs not match whatever is available at an
unrelated host system after installation, when mkheaders is supposed
to be run.
I considered ditching the hardcoding altogether, but decided to retain
it, but allowing CONFIG_SHELL and SHELL to override it, if any of them
can successfully run mkinstalldirs, and if those and the substituted
@SHELL@ fail, fallback to /bin/sh and to plain execution of the
script, which appears to enable at least one shell on a system that
doesn't typicall have a shell to recognize a script by #!/bin/sh and
reinvoke itself to run it.
If all of these fail, we fail, but only after telling the user to
retry after setting CONFIG_SHELL, that fixincl itself also uses.
for fixincludes/ChangeLog
* mkheaders.in: Don't require build-time shell on host.
Uros Bizjak [Thu, 20 Feb 2020 20:06:18 +0000 (21:06 +0100)]
i386: Fix *vec_extractv2sf_1 and *vec_extractv2sf_1 shufps alternative [PR93828]
shufps moves two of the four packed single-precision floating-point values
from *destination* operand (first operand) into the low quadword of the
destination operand. Match source operand to the destination.
PR target/93828
* config/i386/mmx.md (*vec_extractv2sf_1): Match source operand
to destination operand for shufps alternative.
(*vec_extractv2si_1): Ditto.
testsuite/ChangeLog:
PR target/93828
* g++.target/i386/pr93828.C: New test.
Uros Bizjak [Thu, 20 Feb 2020 20:04:44 +0000 (21:04 +0100)]
i386: Fix *vec_extractv2sf_1 and *vec_extractv2sf_1 shufps alternative [PR93828]
shufps moves two of the four packed single-precision floating-point values
from *destination* operand (first operand) into the low quadword of the
destination operand. Match source operand to the destination.
PR target/93828
* config/i386/mmx.md (*vec_extractv2sf_1): Match source operand
to destination operand for shufps alternative.
(*vec_extractv2si_1): Ditto.
testsuite/ChangeLog:
PR target/93828
* g++.target/i386/pr93828.C: New test.
Patrick Palka [Wed, 19 Feb 2020 19:10:32 +0000 (14:10 -0500)]
libstdc++: Fix capturing of lvalue references in_RangeAdaptor::operator()
This fixes a dangling-reference issue with views::split and other multi-argument
adaptors that may take its extra arguments by reference.
When creating the _RangeAdaptorClosure in _RangeAdaptor::operator(), we
currently capture all provided arguments by value. When we then use the
_RangeAdaptorClosure and call it with a range, as in e.g.
v = views::split(p)(range),
we forward the range and the captures to the underlying adaptor routine. But
then when the temporary _RangeAdaptorClosure goes out of scope, the by-value
captures get destroyed and the references to these captures in the resulting view
become dangling.
This patch fixes this problem by capturing lvalue references by reference in
_RangeAdaptorClosure::operator(), and then forwarding the captures appropriately
to the underlying adaptor routine.
libstdc++-v3/ChangeLog:
* include/std/ranges (views::__adaptor::__maybe_refwrap): New utility
function.
(views::__adaptor::_RangeAdaptor::operator()): Add comments. Use
__maybe_refwrap to capture lvalue references by reference, and then use
unwrap_reference_t to forward the by-reference captures as references.
* testsuite/std/ranges/adaptors/split.cc: Augment test.
* testsuite/std/ranges/adaptors/split_neg.cc: New test.
Patrick Palka [Thu, 20 Feb 2020 04:14:02 +0000 (23:14 -0500)]
libstdc++: Forward second argument of views::iota using the correct type
We are forwarding the second argument of views::iota using the wrong type,
causing compile errors when calling views::iota with a value and bound of
different types, like in the test case below.
libstdc++-v3/ChangeLog:
* include/std/ranges (iota_view): Forward declare _Sentinel.
(iota_view::_Iterator): Befriend _Sentinel.
(iota_view::_Sentinel::_M_equal): New member function.
(iota_view::_Sentinel::operator==): Use it.
(views::_Iota::operator()): Forward __f using the correct type.
* testsuite/std/ranges/access/ssize.cc (test06): Don't call views::iota
with integers of different signedness, to appease iota_view's deduction
guide.
* testsuite/std/ranges/iota/iota_view.cc: Augment test.
Peter Bergner [Thu, 20 Feb 2020 17:08:02 +0000 (11:08 -0600)]
rs6000: Fix infinite loop building ghostscript and icu [PR93658]
Fix rs6000_legitimate_address_p(), which erroneously marks a valid Altivec
address as being invalid, which causes LRA's process_address() to go into
an infinite loop spilling the same address over and over again.
Jonathan Wakely [Thu, 20 Feb 2020 13:20:44 +0000 (13:20 +0000)]
libstdc++: Issues with range access CPOs (P2091R0)
This changes how arrays of unknown bound and/or incomplete element type
are handled.
* include/bits/range_access.h (ranges::begin): Reject array of
incomplete type.
(ranges::end, ranges::size): Require arrays to be bounded.
(ranges::data): Require lvalue or borrowed_range.
(ranges::iterator_t): Remove constraint.
* testsuite/std/ranges/access/begin.cc: Do not check array of
incomplete type.
* testsuite/std/ranges/access/begin_neg.cc: New test.
* testsuite/std/ranges/access/end_neg.cc: Adjust expected error.
* testsuite/std/ranges/access/size_neg.cc: Adjust expected error.
* testsuite/std/ranges/access/ssize.cc: Do not check array of
incomplete type.
Jonathan Wakely [Fri, 7 Feb 2020 20:28:06 +0000 (20:28 +0000)]
libstdc++: Add <=> to thread::id
* include/std/thread (thread::id::operator<=>): Define for C++20.
* testsuite/30_threads/thread/id/70294.cc: Do not take addresses of
functions in namespace std.
* testsuite/30_threads/thread/id/operators_c++20.cc: New test.
Marek Polacek [Wed, 19 Feb 2020 21:36:38 +0000 (16:36 -0500)]
c++: Fix wrong-code with non-constexpr constructor [PR93169]
In order to detect modifying constant objects in constexpr evaluation,
which is UB, in r10-2655 I added code that sets TREE_READONLY on
CONSTRUCTORs of const-qualified objects after they have been fully
constructed. But I never made sure that what we're setting the flag
on actually is a CONSTRUCTOR. Consequently, as this test case shows,
we could set TREE_READONLY on a VAR_DECL that in fact wasn't constant,
causing problems later. Fixed by setting the flag on CONSTRUCTORs
only, and only when the evaluation produced something constant.
2020-02-19 Marek Polacek <polacek@redhat.com>
PR c++/93169 - wrong-code with a non-constexpr constructor.
* constexpr.c (cxx_eval_call_expression): Only set TREE_READONLY
on constant CONSTRUCTORs.
Patrick Palka [Wed, 19 Feb 2020 18:54:21 +0000 (13:54 -0500)]
libstdc++: Add missing call to unused subroutine in split_view test
libstdc++-v3/ChangeLog:
* testsuite/std/ranges/adaptors/split.cc (test03): Don't include the
null terminator of the underlying string as part of the test_range.
(main): Call test03.
This also removes a useless condition that was supposed to be removed by
the P1959R0 changes, but left in when that was implemented.
* libsupc++/compare (three_way_comparable): Remove always-false check
that should have been removed with weak_equality (P1959R0).
(three_way_comparable_with): Likewise. Reorder requirements (LWG 3360).
* include/std/concepts (__detail::__partially_ordered_with): Move here
from <compare>.
(totally_ordered, totally_ordered_with): Use __partially_ordered_with
to simplify definition (LWG 3331).
* libsupc++/compare (__detail::__partially_ordered_with): Move to
<concepts>.