Bin Cheng [Thu, 30 Jan 2020 04:33:47 +0000 (12:33 +0800)]
Use promise in coroutine frame in actor function.
By standard, coroutine body should be encapsulated in try-catch block
as following:
try {
// coroutine body
} catch(...) {
promise.unhandled_exception();
}
Given above try-catch block is implemented in the coroutine actor
function called by coroutine ramp function, so the promise should
be accessed via actor function's coroutine frame pointer argument,
rather than the ramp function's coroutine frame variable.
This patch cleans code a bit to make fix easy.
gcc/cp
* coroutines.cc (act_des_fn): New.
(morph_fn_to_coro): Call act_des_fn to build actor/destroy decls.
Access promise via actor function's frame pointer argument.
(build_actor_fn, build_destroy_fn): Use frame pointer argument.
Bin Cheng [Thu, 30 Jan 2020 04:10:36 +0000 (12:10 +0800)]
Handle CO_AWAIT_EXPR in conversion in co_await_expander.
Function co_await_expander expands CO_AWAIT_EXPR and inserts expanded
code before result of co_await is used, however, it doesn't cover the
type conversion case and leads to gimplify ICE. This patch fixes it.
gcc/cp
* coroutines.cc (co_await_expander): Handle type conversion case.
gcc/testsuite
* g++.dg/coroutines/co-await-syntax-09-convert.C: New test.
Ian Lance Taylor [Thu, 30 Jan 2020 00:42:01 +0000 (16:42 -0800)]
runtime, syscall: add a couple of hurd build tags
Patch by Svante Signell.
Updates PR go/93468
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/216959
Ian Lance Taylor [Thu, 30 Jan 2020 00:36:25 +0000 (16:36 -0800)]
runtime: update netpoll_hurd.go for go1.14beta1 changes
Patch from Svante Signell.
Updates PR go/93468
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/216958
Jason Merrill [Wed, 29 Jan 2020 22:16:12 +0000 (17:16 -0500)]
c++: Drop alignas restriction for stack variables.
Since expand_stack_vars and such know how to deal with variables aligned
beyond MAX_SUPPORTED_STACK_ALIGNMENT, we shouldn't reject alignas of large
alignments. And if we don't do that, there's no point in having
check_cxx_fundamental_alignment_constraints at all, since
check_user_alignment already enforces MAX_OFILE_ALIGNMENT.
PR c++/89357
* c-attribs.c (check_cxx_fundamental_alignment_constraints): Remove.
GCC Administrator [Thu, 30 Jan 2020 00:16:31 +0000 (00:16 +0000)]
Daily bump.
Jakub Jelinek [Thu, 30 Jan 2020 00:01:55 +0000 (01:01 +0100)]
testsuite: Fix up tree-ssa/pr92706-1.c on 32-bit targets.
The test uses __int128_t, so won't work on targets that don't support it.
2020-01-30 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/92706
* gcc.dg/tree-ssa/pr92706-1.c: Require int128 effective target.
Jason Merrill [Tue, 28 Jan 2020 22:41:05 +0000 (17:41 -0500)]
c++: Fix attributes with lambda and trailing return type.
My fix for 60503 fixed handling of C++11 attributes following the
lambda-declarator. My patch for 89640 re-added support for GNU attributes,
but attributes after the trailing return type were parsed as applying to the
return type rather than to the function. This patch adjusts parsing of a
trailing-return-type to ignore GNU attributes at the end of the declaration
so that they will be applied to the declaration as a whole.
I also considered parsing the attributes between the closing paren and the
trailing-return-type, and tried a variety of approaches to implementing
that, but I think it's better to stick with the documented rule that "An
attribute specifier list may appear immediately before the comma, '=' or
semicolon terminating the declaration of an identifier...." Anyone
disagree?
Meanwhile, C++ committee discussion about the lack of any way to apply
attributes to a lambda op() seems to have concluded that they should go
between the introducer and declarator, so I've implemented that as well.
PR c++/90333
PR c++/89640
PR c++/60503
* parser.c (cp_parser_type_specifier_seq): Don't parse attributes in
a trailing return type.
(cp_parser_lambda_declarator_opt): Parse C++11 attributes before
parens.
Tobias Burnus [Wed, 29 Jan 2020 22:45:55 +0000 (23:45 +0100)]
GCN – call assembler with -mattr=-code-object-v3 (PR93409)
PR bootstrap/93409
* config/gcn/gcn-hsa.h (ASM_SPEC): Add -mattr=-code-object-v3 as
LLVM's assembler changed the default in version 9.
Marek Polacek [Wed, 29 Jan 2020 20:12:46 +0000 (15:12 -0500)]
c++: Add new test [PR88092]
This test got fixed by
r10-1976-gdaaa6fcc70ffe66bd56f5819ad4ee78fecd54bb6
so let's add it to the testsuite.
PR c++/88092
* g++.dg/cpp2a/nontype-class31.C: New test.
Jeff Law [Wed, 29 Jan 2020 19:23:53 +0000 (12:23 -0700)]
Improve DSE which in turn eliminates the need for jump threading and block duplication for the original testcase in pr89689 which in turn eliminates the false positive -Warray-bounds warning for the original testcase.
PR tree-optimization/89689
* builtins.def (BUILT_IN_OBJECT_SIZE): Make it const rather than pure.
PR tree-optimization/89689
* gcc.dg/pr89689.c: New test.
Richard Sandiford [Wed, 29 Jan 2020 18:56:35 +0000 (18:56 +0000)]
Revert g-
465c7c89e92a6d6d582173e505cb16dcb9873034
The patch caused regressions in gcc.target/sh/pr64345-1.c on
sh3-linux-gnu and gcc.target/m68k/pr39726.c on m68k-linux-gnu.
It didn't look like they would be fixable in an acceptably
non-invasive and unhacky way, so punting till future releases.
2020-01-29 Richard Sandiford <richard.sandiford@arm.com>
gcc/
Revert:
2020-01-28 Richard Sandiford <richard.sandiford@arm.com>
PR rtl-optimization/87763
* simplify-rtx.c (simplify_truncation): Extend sign/zero_extract
simplification to handle subregs as well as bare regs.
* config/i386/i386.md (*testqi_ext_3): Match QI extracts too.
Marek Polacek [Wed, 29 Jan 2020 17:02:14 +0000 (12:02 -0500)]
c++: Fix template arguments comparison with class NTTP [PR91754]
Here we fail to compile the attached test, stating that the use of
T<s> in T<s>::T() {} is "invalid use of incomplete type". It is a
function definition so grokdeclarator checks that the qualifying type
is complete.
When we parsed the class T, finish_struct gave the class a non-null
TYPE_SIZE, making it COMPLETE_TYPE_P. But then we're parsing T<s>,
a TEMPLATE_ID, in
T<s>::T() {}
so try to lookup_template_class T. This failed because we couldn't
find such a class: comp_template_args told us that the argument lists
don't match, because one of the args was wrapped in a VIEW_CONVERT_EXPR
to make it look const. It seems to me that we should see through
these artificial wrappers and consider the args same.
2020-01-29 Marek Polacek <polacek@redhat.com>
PR c++/91754 - Fix template arguments comparison with class NTTP.
* pt.c (class_nttp_const_wrapper_p): New.
(template_args_equal): See through class_nttp_const_wrapper_p
arguments.
* g++.dg/cpp2a/nontype-class30.C: New test.
Marek Polacek [Tue, 28 Jan 2020 22:44:21 +0000 (17:44 -0500)]
c++: Fix class NTTP with template arguments [PR92948]
This PR points out an ICE with an alias template and class NTTP, but I
found that there are more issues. Trouble arise when we use a
(non-type) template parameter as an argument to the template arg list of
a template that accepts a class NTTP and a conversion to a class is
involved, e.g.
struct A { A(int) { } };
template<A a> struct B { };
template<int X> void fn () {
B<X> b;
}
Normally for such a conversion we create a TARGET_EXPR with an
AGGR_INIT_EXPR that calls a __ct_comp with some arguments, but not in
this case: when converting X to type A in convert_nontype_argument we
are in a template and the template parameter 'X' is value-dependent, and
AGGR_INIT_EXPR don't work in templates. So it just creates a TARGET_EXPR
that contains "A::A(*this, X)", but with that overload resolution fails:
error: no matching function for call to 'A::A(A*, int)'
That happens because finish_call_expr for a BASELINK creates a dummy
object, so we have 'this' twice. I thought for the value-dependent case
we could use IMPLICIT_CONV_EXPR, as in the patch below. Note that I
only do this when we convert to a different type than the type of the
expr. The point is to avoid the call to a converting ctor.
The second issue was an ICE in tsubst_copy: when there's a conversion
like the above involved then
/* Wrapper to make a C++20 template parameter object const. */
op = tsubst_copy (op, args, complain, in_decl);
might not produce a _ZT... VAR_DECL with const type, so the assert
gcc_assert (CP_TYPE_CONST_P (TREE_TYPE (op)));
fails. Allowing IMPLICIT_CONV_EXPR there probably makes sense.
And since convert_nontype_argument uses value_dependent_expression_p
a lot, I used a dedicated bool to speed things up.
2020-01-29 Marek Polacek <polacek@redhat.com>
PR c++/92948 - Fix class NTTP with template arguments.
* pt.c (convert_nontype_argument): Use IMPLICIT_CONV_EXPR when
converting a value-dependent expression to a class type.
(tsubst_copy) <case VIEW_CONVERT_EXPR>: Allow IMPLICIT_CONV_EXPR
as the result of the tsubst_copy call.
* g++.dg/cpp2a/nontype-class28.C: New test.
* g++.dg/cpp2a/nontype-class29.C: New test.
Jonathan Wakely [Thu, 23 Jan 2020 16:46:17 +0000 (16:46 +0000)]
libstdc++: Fix conformance issues in <stop_token> (PR92895)
Fix synchronization issues in <stop_token>. Replace shared_ptr with
_Stop_state_ref and a reference count embedded in the shared state.
Replace std::mutex with spinlock using one bit of a std::atomic<> that
also tracks whether a stop request has been made and how many
stop_source objects share ownership of the state.
PR libstdc++/92895
* include/std/stop_token (stop_token::stop_possible()): Call new
_M_stop_possible() function.
(stop_token::stop_requested()): Do not use stop_possible().
(stop_token::binary_semaphore): New class, as temporary stand-in for
std::binary_semaphore.
(stop_token::_Stop_cb::_M_callback): Add noexcept to type.
(stop_token::_Stop_cb::_M_destroyed, stop_token::_Stop_cb::_M_done):
New data members for symchronization with stop_callback destruction.
(stop_token::_Stop_cb::_Stop_cb): Make non-template.
(stop_token::_Stop_cb::_M_linked, stop_token::_Stop_cb::_S_execute):
Remove.
(stop_token::_Stop_cb::_M_run): New member function.
(stop_token::_Stop_state::_M_stopped, stop_token::_Stop_state::_M_mtx):
Remove.
(stop_token::_Stop_state::_M_owners): New data member to track
reference count for ownership.
(stop_token::_Stop_state::_M_value): New data member combining a
spinlock, the stop requested flag, and the reference count for
associated stop_source objects.
(stop_token::_Stop_state::_M_requester): New data member for
synchronization with stop_callback destruction.
(stop_token::_Stop_state::_M_stop_possible()): New member function.
(stop_token::_Stop_state::_M_stop_requested()): Inspect relevant bit
of _M_value.
(stop_token::_Stop_state::_M_add_owner)
(stop_token::_Stop_state::_M_release_ownership)
(stop_token::_Stop_state::_M_add_ssrc)
(stop_token::_Stop_state::_M_sub_ssrc): New member functions for
updating reference counts.
(stop_token::_Stop_state::_M_lock, stop_token::_Stop_state::_M_unlock)
(stop_token::_Stop_state::_M_lock, stop_token::_Stop_state::_M_unlock)
(stop_token::_Stop_state::_M_try_lock)
(stop_token::_Stop_state::_M_try_lock_and_stop)
(stop_token::_Stop_state::_M_do_try_lock): New member functions for
managing spinlock.
(stop_token::_Stop_state::_M_request_stop): Use atomic operations to
read and update state. Release lock while running callbacks. Use new
data members to synchronize with callback destruction.
(stop_token::_Stop_state::_M_remove_callback): Likewise.
(stop_token::_Stop_state::_M_register_callback): Use atomic operations
to read and update state.
(stop_token::_Stop_state_ref): Handle type to manage _Stop_state,
replacing shared_ptr.
(stop_source::stop_source(const stop_source&)): Update reference count.
(stop_source::operator=(const stop_source&)): Likewise.
(stop_source::~stop_source()): Likewise.
(stop_source::stop_source(stop_source&&)): Define as defaulted.
(stop_source::operator=(stop_source&&)): Establish postcondition on
parameter.
(stop_callback): Enforce preconditions on template parameter. Replace
base class with data member of new _Cb_impl type.
(stop_callback::stop_callback(const stop_token&, Cb&&))
(stop_callback::stop_callback(stop_token&&, Cb&&)): Fix TOCTTOU race.
(stop_callback::_Cb_impl): New type wrapping _Callback member and
defining the _S_execute member function.
* testsuite/30_threads/stop_token/stop_callback/deadlock-mt.cc: New
test.
* testsuite/30_threads/stop_token/stop_callback/deadlock.cc: New test.
* testsuite/30_threads/stop_token/stop_callback/destroy.cc: New test.
* testsuite/30_threads/stop_token/stop_callback/destructible_neg.cc:
New test.
* testsuite/30_threads/stop_token/stop_callback/invocable_neg.cc: New
test.
* testsuite/30_threads/stop_token/stop_callback/invoke.cc: New test.
* testsuite/30_threads/stop_token/stop_source/assign.cc: New test.
* testsuite/30_threads/stop_token/stop_token/stop_possible.cc: New
test.
Frederik Harwath [Wed, 29 Jan 2020 14:51:44 +0000 (15:51 +0100)]
Add acc_device_radeon to name_of_acc_device_t function
libgomp/
* oacc-init.c (name_of_acc_device_t): Handle acc_device_radeon.
Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
Andre Vieira [Wed, 29 Jan 2020 14:23:22 +0000 (14:23 +0000)]
IRA: Revert
11b8091fb to fix PR 93221
A previous change to simplify LRA introduced in 11b809 (From-SVN: r279550)
disabled hard register splitting for -O0. This causes a problem on aarch64 in
cases where parameters are passed in multiple registers (in the bug report an OI
passed in 2 V4SI registers). This is mandated by the AAPCS.
gcc/ChangeLog:
2020-01-29 Joel Hutton <Joel.Hutton@arm.com>
PR target/93221
* ira.c (ira): Revert use of simplified LRA algorithm.
gcc/testsuite/ChangeLog:
2020-01-29 Joel Hutton <Joel.Hutton@arm.com>
PR target/93221
* gcc.target/aarch64/pr93221.c: New test.
Jonathan Wakely [Wed, 29 Jan 2020 13:56:49 +0000 (13:56 +0000)]
libstdc++: Simplify constraints on std::compare_three_way
The __3way_builtin_ptr_cmp concept can use three_way_comparable_with to
check whether <=> is valid. Doing that makes it obvious that the
disjunction on compare_three_way::operator() is redundant, because
the second constraint subsumes the first.
The workaround for PR c++/91073 can also be removed as that bug is fixed
now.
* libsupc++/compare (__detail::__3way_builtin_ptr_cmp): Use
three_way_comparable_with.
(__detail::__3way_cmp_with): Remove workaround for fixed bug.
(compare_three_way::operator()): Remove redundant constraint from
requires-clause.
(__detail::_Synth3way::operator()): Use three_way_comparable_with
instead of workaround.
* testsuite/18_support/comparisons/object/93479.cc: Prune extra
output due to simplified constraints on compare_three_way::operator().
Jonathan Wakely [Wed, 29 Jan 2020 13:36:15 +0000 (13:36 +0000)]
libstdc++: Make std::compare_three_way check if <=> is valid (PR 93479)
Currently types that cannot be compared using <=> but which are
convertible to pointers will be compared by converting to pointers
first. They should not be comparable.
PR libstdc++/93479
* libsupc++/compare (__3way_builtin_ptr_cmp): Require <=> to be valid.
* testsuite/18_support/comparisons/object/93479.cc: New test.
Jonathan Wakely [Wed, 29 Jan 2020 13:36:15 +0000 (13:36 +0000)]
libstdc++: Make tests for std::ranges access functions more robust
* testsuite/std/ranges/access/end.cc: Do not assume test_range::end()
returns the same type as test_range::begin(). Add comments.
* testsuite/std/ranges/access/rbegin.cc: Likewise.
* testsuite/std/ranges/access/rend.cc: Likewise.
* testsuite/std/ranges/range.cc: Do not assume the sentinel for
test_range is the same as its iterator type.
* testsuite/util/testsuite_iterators.h (test_range::sentinel): Add
operator- overloads to satisfy sized_sentinel_for when the iterator
satisfies random_access_iterator.
Martin Jambor [Wed, 29 Jan 2020 12:13:13 +0000 (13:13 +0100)]
SRA: Also propagate accesses from LHS to RHS [PR92706]
2020-01-29 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/92706
* tree-sra.c (struct access): Fields first_link, last_link,
next_queued and grp_queued renamed to first_rhs_link, last_rhs_link,
next_rhs_queued and grp_rhs_queued respectively, new fields
first_lhs_link, last_lhs_link, next_lhs_queued and grp_lhs_queued.
(struct assign_link): Field next renamed to next_rhs, new field
next_lhs. Updated comment.
(work_queue_head): Renamed to rhs_work_queue_head.
(lhs_work_queue_head): New variable.
(add_link_to_lhs): New function.
(relink_to_new_repr): Also relink LHS lists.
(add_access_to_work_queue): Renamed to add_access_to_rhs_work_queue.
(add_access_to_lhs_work_queue): New function.
(pop_access_from_work_queue): Renamed to
pop_access_from_rhs_work_queue.
(pop_access_from_lhs_work_queue): New function.
(build_accesses_from_assign): Also add links to LHS lists and to LHS
work_queue.
(child_would_conflict_in_lacc): Renamed to
child_would_conflict_in_acc. Adjusted parameter names.
(create_artificial_child_access): New parameter set_grp_read, use it.
(subtree_mark_written_and_enqueue): Renamed to
subtree_mark_written_and_rhs_enqueue.
(propagate_subaccesses_across_link): Renamed to
propagate_subaccesses_from_rhs.
(propagate_subaccesses_from_lhs): New function.
(propagate_all_subaccesses): Also propagate subaccesses from LHSs to
RHSs.
testsuite/
* gcc.dg/tree-ssa/pr92706-1.c: New test.
Martin Jambor [Wed, 29 Jan 2020 12:13:13 +0000 (13:13 +0100)]
SRA: Total scalarization after access propagation [PR92706]
2020-01-29 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/92706
* tree-sra.c (struct access): Adjust comment of
grp_total_scalarization.
(find_access_in_subtree): Look for single children spanning an entire
access.
(scalarizable_type_p): Allow register accesses, adjust callers.
(completely_scalarize): Remove function.
(scalarize_elem): Likewise.
(create_total_scalarization_access): Likewise.
(sort_and_splice_var_accesses): Do not track total scalarization
flags.
(analyze_access_subtree): New parameter totally, adjust to new meaning
of grp_total_scalarization.
(analyze_access_trees): Pass new parameter to analyze_access_subtree.
(can_totally_scalarize_forest_p): New function.
(create_total_scalarization_access): Likewise.
(create_total_access_and_reshape): Likewise.
(total_should_skip_creating_access): Likewise.
(totally_scalarize_subtree): Likewise.
(analyze_all_variable_accesses): Perform total scalarization after
subaccess propagation using the new functions above.
(initialize_constant_pool_replacements): Output initializers by
traversing the access tree.
testsuite/
* gcc.dg/tree-ssa/pr92706-2.c: New test.
* gcc.dg/guality/pr59776.c: Xfail tests for s2.g.
Martin Jambor [Wed, 29 Jan 2020 12:13:12 +0000 (13:13 +0100)]
SRA: Add verification of accesses
2020-01-29 Martin Jambor <mjambor@suse.cz>
* tree-sra.c (verify_sra_access_forest): New function.
(verify_all_sra_access_forests): Likewise.
(create_artificial_child_access): Set parent.
(analyze_all_variable_accesses): Call the verifier.
Jan Hubicka [Wed, 29 Jan 2020 11:43:10 +0000 (12:43 +0100)]
ipa: Fix removal of multi-target speculation.
* cgraph.c (cgraph_edge::resolve_speculation): Only lookup direct edge
if called on indirect edge.
(cgraph_edge::redirect_call_stmt_to_callee): Lookup indirect edge of
speculative call if needed.
* gcc.dg/tree-prof/indir-call-prof-2.c: New testcase.
Frederik Harwath [Wed, 29 Jan 2020 09:21:18 +0000 (10:21 +0100)]
Adjust formatting of acc_get_property tests
libgomp/
* testsuite/libgomp.oacc-c-c++-common/acc_get_property.c:
Adjust to GNU coding style.
* testsuite/libgomp.oacc-c-c++-common/acc_get_property-aux.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/acc_get_property-gcn.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/acc_get_property-host.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/acc_get_property-nvptx.c: Likewise.
Frederik Harwath [Wed, 29 Jan 2020 09:19:50 +0000 (10:19 +0100)]
Add OpenACC acc_get_property support for AMD GCN
Add full support for the OpenACC 2.6 acc_get_property and
acc_get_property_string functions to the libgomp GCN plugin.
libgomp/
* plugin-gcn.c (struct agent_info): Add fields "name" and
"vendor_name" ...
(GOMP_OFFLOAD_init_device): ... and init from here.
(struct hsa_context_info): Add field "driver_version_s" ...
(init_hsa_contest): ... and init from here.
(GOMP_OFFLOAD_openacc_get_property): Replace stub with a proper
implementation.
* testsuite/libgomp.oacc-c-c++-common/acc_get_property.c:
Enable test execution for amdgcn and host offloading targets.
* testsuite/libgomp.oacc-fortran/acc_get_property.f90: Likewise.
* testsuite/libgomp.oacc-c-c++-common/acc_get_property-aux.c
(expect_device_properties): Split function into ...
(expect_device_string_properties): ... this new function ...
(expect_device_memory): ... and this new function.
* testsuite/libgomp.oacc-c-c++-common/acc_get_property-gcn.c:
Add test.
Richard Sandiford [Tue, 28 Jan 2020 10:05:29 +0000 (10:05 +0000)]
testsuite: XFAIL gcc.dg/torture/pr93133.c for powerpc*-*-* [PR93393]
2020-01-29 Richard Sandiford <richard.sandiford@arm.com>
gcc/testsuite/
PR testsuite/93393
* gcc.dg/torture/pr93133.c: XFAIL for powerpc*-*-*.
Jakub Jelinek [Wed, 29 Jan 2020 08:41:42 +0000 (09:41 +0100)]
openmp: c++: Consider typeinfo decls to be predetermined shared [PR91118]
If the typeinfo decls appear in OpenMP default(none) regions, as we no longer
predetermine const with no mutable members, they are diagnosed as errors,
but it isn't something the users can actually provide explicit sharing for in
the clauses.
2020-01-29 Jakub Jelinek <jakub@redhat.com>
PR c++/91118
* cp-gimplify.c (cxx_omp_predetermined_sharing): Return
OMP_CLAUSE_DEFAULT_SHARED for typeinfo decls.
* g++.dg/gomp/pr91118-1.C: New test.
* g++.dg/gomp/pr91118-2.C: New test.
Jakub Jelinek [Wed, 29 Jan 2020 08:39:16 +0000 (09:39 +0100)]
openmp: Handle rest of EXEC_OACC_* in oacc_code_to_statement [PR93463]
As the testcase shows, some EXEC_OACC_* codes weren't handled in
oacc_code_to_statement. Fixed thusly.
2020-01-29 Jakub Jelinek <jakub@redhat.com>
PR fortran/93463
* openmp.c (oacc_code_to_statement): Handle
EXEC_OACC_{ROUTINE,UPDATE,WAIT,CACHE,{ENTER,EXIT}_DATA,DECLARE}.
* gfortran.dg/goacc/pr93463.f90: New test.
Jakub Jelinek [Wed, 29 Jan 2020 08:36:19 +0000 (09:36 +0100)]
analyzer: fix build with gcc 4.4 (PR 93276)
All that is really needed is make sure you #include "diagnostic-core.h"
before including pretty-print.h. By including
diagnostic-core.h first, you do:
and then pretty-print.h will do:
If instead pretty-print.h is included first, then it will use __gcc_diag__
instead of __gcc_tdiag__ and thus will assume %E/%D etc. can't be handled.
2020-01-29 Jakub Jelinek <jakub@redhat.com>
* analyzer.h (PUSH_IGNORE_WFORMAT, POP_IGNORE_WFORMAT): Remove.
* constraint-manager.cc: Include diagnostic-core.h before graphviz.h.
(range::dump, equiv_class::print): Don't use PUSH_IGNORE_WFORMAT or
POP_IGNORE_WFORMAT.
* state-purge.cc: Include diagnostic-core.h before
gimple-pretty-print.h.
(state_purge_annotator::add_node_annotations, print_vec_of_names):
Don't use PUSH_IGNORE_WFORMAT or POP_IGNORE_WFORMAT.
* region-model.cc: Move diagnostic-core.h include before graphviz.h.
(path_var::dump, svalue::print, constant_svalue::print_details,
region::dump_to_pp, region::dump_child_label, region::print_fields,
map_region::print_fields, map_region::dump_dot_to_pp,
map_region::dump_child_label, array_region::print_fields,
array_region::dump_dot_to_pp): Don't use PUSH_IGNORE_WFORMAT or
POP_IGNORE_WFORMAT.
Richard Biener [Wed, 29 Jan 2020 08:05:05 +0000 (09:05 +0100)]
tree-optimization/93428 - avoid load permutation vector clobbering
With SLP now being a graph with shared nodes across instances we have
to make sure to compute the load permutation of nodes once, not
overwriting the result of earlier analysis.
2020-01-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/93428
* tree-vect-slp.c (vect_build_slp_tree_2): Compute the load
permutation when the load node is created.
(vect_analyze_slp_instance): Re-use it here.
* gcc.dg/torture/pr93428.c: New testcase.
Jan Hubicka [Wed, 29 Jan 2020 07:15:52 +0000 (08:15 +0100)]
Fix bogus Changelog entry.
* ipa-prop.c (update_indirect_edges_after_inlining): Fix warning.
GCC Administrator [Wed, 29 Jan 2020 00:16:37 +0000 (00:16 +0000)]
Daily bump.
Martin Sebor [Tue, 28 Jan 2020 21:48:52 +0000 (14:48 -0700)]
PR middle-end/93437 - bogus -Warray-bounds on protobuf generated code
gcc/testsuite/ChangeLog:
PR middle-end/93437
* g++.dg/warn/Wstringop-overflow-5.C: New test.
Jason Merrill [Tue, 28 Jan 2020 21:06:33 +0000 (16:06 -0500)]
c++: Fix return deduction of lambda in discarded stmt.
A return statement in a discarded statement is not used for return type
deduction, but we still want to do deduction for a return statement in a
lambda in a discarded statement.
PR c++/93442
* parser.c (cp_parser_lambda_expression): Clear in_discarded_stmt.
Jason Merrill [Tue, 28 Jan 2020 20:15:20 +0000 (15:15 -0500)]
c++: Fix guard variable and attribute weak.
My patch for PR 91476 worked for decls that are implicitly comdat/weak due
to C++ linkage rules, but broke variables explicitly marked weak.
PR c++/93477
PR c++/91476
* decl2.c (copy_linkage): Do copy DECL_ONE_ONLY and DECL_WEAK.
Jan Hubicka [Tue, 28 Jan 2020 21:44:36 +0000 (22:44 +0100)]
ipa: fix warning in ipa-prop.c
* ipa-prop.c (update_indirect_edges_after_inlining):
David Malcolm [Tue, 28 Jan 2020 18:06:24 +0000 (10:06 -0800)]
analyzer: fix ICE when longjmp isn't marked 'noreturn' (PR 93316)
Comments 11-16 within PR analyzer/93316 discuss an ICE in some setjmp
tests seen on AIX and powerpc-darwin9.
The issue turned out to be an implicit assumption that longjmp is
marked "noreturn". There are two places in engine.cc where the code
attempted to locate the longjmp GIMPLE_CALL by finding the final stmt
within its supernode, in one place casting it via "as_a <gcall *>",
in the other using it as the location_t of the
"rewinding from longjmp..." event.
When longjmp isn't marked noreturn, its basic block and hence supernode
can have additional stmts after the longjmp; in the setjmp-3.c case
this was a GIMPLE_RETURN, leading to a ICE when casting this to a
GIMPLE_CALL.
This patch fixes the two places in question to use the
rewind_info_t::get_longjmp_call
member function introduced by
342e14ffa30e9163a1a75e0a4fb21b6883d58dbe,
fixing the ICE (and ensuring the correct location_t is used for events).
gcc/analyzer/ChangeLog:
PR analyzer/93316
* engine.cc (rewind_info_t::update_model): Get the longjmp call
stmt via get_longjmp_call () rather than assuming it is the last
stmt in the longjmp's supernode.
(rewind_info_t::add_events_to_path): Get the location_t for the
rewind_from_longjmp_event via get_longjmp_call () rather than from
the supernode's get_end_location ().
Vladimir N. Makarov [Tue, 28 Jan 2020 20:43:44 +0000 (15:43 -0500)]
Fix for PR93272 - LRA: EH reg allocated to hold local variable
2020-01-28 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/93272
* ira-lives.c (process_out_of_region_eh_regs): New function.
(process_bb_node_lives): Call it.
Jan Hubicka [Tue, 28 Jan 2020 20:34:43 +0000 (21:34 +0100)]
diagnostics: make error message lowercase.
* coverage.c (read_counts_file): Make error message lowercase.
Jan Hubicka [Tue, 28 Jan 2020 20:31:26 +0000 (21:31 +0100)]
* profile-count.c (profile_quality_display_names): Fix ordering.
Jan Hubicka [Tue, 28 Jan 2020 20:30:14 +0000 (21:30 +0100)]
ipa: fix handling of multiple speculations (PR93318)
This patch started as work to resole Richard's comment on quadratic lookups
in resolve_speculation. While doing it I however noticed multiple problems
in the new speuclative call code which made the patch quite big. In
particular:
1) Before applying speculation we consider only targets with at lest
probability 1/2.
If profile is sane at most two targets can have probability greater or
equal to 1/2. So the new multi-target speculation code got enabled only
in very special scenario when there ae precisely two target with precise
probability 1/2 (which is tested by the single testcase).
As a conseuqence the multiple target logic got minimal test coverage and
this made us to miss several ICEs.
2) Profile updating in profile merging, tree-inline and indirect call
expansion was wrong which led to inconsistent profiles (as already seen
on the testcase).
3) Code responsible to turn speculative call to direct call was broken for
anything with more than one target.
4) There were multiple cases where call_site_hash went out of sync which
eventually leads to an ICE..
5) Some code expects that all speculative call targets forms a sequence in
the callee linked list but there is no code to maintain that invariant
nor a verifier.
Fixing this it became obvious that the current API of speculative_call_info is
not useful because it really builds on fact tht there are precisely three
components (direct call, ref and indirect call) in every speculative call
sequence. I ended up replacing it with iterator API for direct call
(first_speculative_call_target, next_speculative_call_target) and accessors for
the other coponents updating comment in cgraph.h.
Finally I made the work with call site hash more effetive by updating edge
manipulation to keep them in sequence. So first one can be looked up from the
hash and then they can be iterated by callee.
There are other things that can be improved (for example the speculation should
start with most common target first), but I will try to keep that for next
stage1. This patch is mostly about getting rid of ICE and profile corruption
which is a regression from GCC 9.
Honza
gcc/ChangeLog:
2020-01-28 Jan Hubicka <hubicka@ucw.cz>
PR lto/93318
* cgraph.c (cgraph_add_edge_to_call_site_hash): Update call site
hash only when edge is first within the sequence.
(cgraph_edge::set_call_stmt): Update handling of speculative calls.
(symbol_table::create_edge): Do not set target_prob.
(cgraph_edge::remove_caller): Watch for speculative calls when updating
the call site hash.
(cgraph_edge::make_speculative): Drop target_prob parameter.
(cgraph_edge::speculative_call_info): Remove.
(cgraph_edge::first_speculative_call_target): New member function.
(update_call_stmt_hash_for_removing_direct_edge): New function.
(cgraph_edge::resolve_speculation): Rewrite to new API.
(cgraph_edge::speculative_call_for_target): New member function.
(cgraph_edge::make_direct): Rewrite to new API; fix handling of
multiple speculation targets.
(cgraph_edge::redirect_call_stmt_to_callee): Likewise; fix updating
of profile.
(verify_speculative_call): Verify that targets form an interval.
* cgraph.h (cgraph_edge::speculative_call_info): Remove.
(cgraph_edge::first_speculative_call_target): New member function.
(cgraph_edge::next_speculative_call_target): New member function.
(cgraph_edge::speculative_call_target_ref): New member function.
(cgraph_edge;:speculative_call_indirect_edge): New member funtion.
(cgraph_edge): Remove target_prob.
* cgraphclones.c (cgraph_node::set_call_stmt_including_clones):
Fix handling of speculative calls.
* ipa-devirt.c (ipa_devirt): Fix handling of speculative cals.
* ipa-fnsummary.c (analyze_function_body): Likewise.
* ipa-inline.c (speculation_useful_p): Use new speculative call API.
* ipa-profile.c (dump_histogram): Fix formating.
(ipa_profile_generate_summary): Watch for overflows.
(ipa_profile): Do not require probablity to be 1/2; update to new API.
* ipa-prop.c (ipa_make_edge_direct_to_target): Update to new API.
(update_indirect_edges_after_inlining): Update to new API.
* ipa-utils.c (ipa_merge_profiles): Rewrite merging of speculative call
profiles.
* profile-count.h: (profile_probability::adjusted): New.
* tree-inline.c (copy_bb): Update to new speculative call API; fix
updating of profile.
* value-prof.c (gimple_ic_transform): Rename to ...
(dump_ic_profile): ... this one; update dumping.
(stream_in_histogram_value): Fix formating.
(gimple_value_profile_transformations): Update.
gcc/testsuite/ChangeLog:
2020-01-28 Jan Hubicka <hubicka@ucw.cz>
* g++.dg/tree-prof/indir-call-prof.C: Update template.
* gcc.dg/tree-prof/crossmodule-indircall-1.c: Add more targets.
* gcc.dg/tree-prof/crossmodule-indircall-1a.c: Add more targets.
* gcc.dg/tree-prof/indir-call-prof.c: Update template.
Jason Merrill [Tue, 28 Jan 2020 17:26:10 +0000 (12:26 -0500)]
c++: Allow template rvalue-ref conv to bind to lvalue ref.
When I implemented the [over.match.ref] rule that a reference conversion
function needs to match l/rvalue of the target reference type it changed our
handling of this testcase. It seems to me that our current behavior is what
the standard says, but it doesn't seem desirable, and all the other
compilers have our old behavior. So let's limit the change to non-templates
until there's some clarification from the committee.
PR c++/90546
* call.c (build_user_type_conversion_1): Allow a template conversion
returning an rvalue reference to bind directly to an lvalue.
Jan Hubicka [Tue, 28 Jan 2020 19:34:56 +0000 (20:34 +0100)]
ipa: fix handling of multiple speculations (PR93318)
This patch started as work to resole Richard's comment on quadratic lookups
in resolve_speculation. While doing it I however noticed multiple problems
in the new speuclative call code which made the patch quite big. In
particular:
1) Before applying speculation we consider only targets with at lest
probability 1/2.
If profile is sane at most two targets can have probability greater or
equal to 1/2. So the new multi-target speculation code got enabled only
in very special scenario when there ae precisely two target with precise
probability 1/2 (which is tested by the single testcase).
As a conseuqence the multiple target logic got minimal test coverage and
this made us to miss several ICEs.
2) Profile updating in profile merging, tree-inline and indirect call
expansion was wrong which led to inconsistent profiles (as already seen
on the testcase).
3) Code responsible to turn speculative call to direct call was broken for
anything with more than one target.
4) There were multiple cases where call_site_hash went out of sync which
eventually leads to an ICE..
5) Some code expects that all speculative call targets forms a sequence in
the callee linked list but there is no code to maintain that invariant
nor a verifier.
Fixing this it became obvious that the current API of speculative_call_info is
not useful because it really builds on fact tht there are precisely three
components (direct call, ref and indirect call) in every speculative call
sequence. I ended up replacing it with iterator API for direct call
(first_speculative_call_target, next_speculative_call_target) and accessors for
the other coponents updating comment in cgraph.h.
Finally I made the work with call site hash more effetive by updating edge
manipulation to keep them in sequence. So first one can be looked up from the
hash and then they can be iterated by callee.
There are other things that can be improved (for example the speculation should
start with most common target first), but I will try to keep that for next
stage1. This patch is mostly about getting rid of ICE and profile corruption
which is a regression from GCC 9.
gcc/ChangeLog:
PR lto/93318
* cgraph.c (cgraph_add_edge_to_call_site_hash): Update call site
hash only when edge is first within the sequence.
(cgraph_edge::set_call_stmt): Update handling of speculative calls.
(symbol_table::create_edge): Do not set target_prob.
(cgraph_edge::remove_caller): Watch for speculative calls when updating
the call site hash.
(cgraph_edge::make_speculative): Drop target_prob parameter.
(cgraph_edge::speculative_call_info): Remove.
(cgraph_edge::first_speculative_call_target): New member function.
(update_call_stmt_hash_for_removing_direct_edge): New function.
(cgraph_edge::resolve_speculation): Rewrite to new API.
(cgraph_edge::speculative_call_for_target): New member function.
(cgraph_edge::make_direct): Rewrite to new API; fix handling of
multiple speculation targets.
(cgraph_edge::redirect_call_stmt_to_callee): Likewise; fix updating
of profile.
(verify_speculative_call): Verify that targets form an interval.
* cgraph.h (cgraph_edge::speculative_call_info): Remove.
(cgraph_edge::first_speculative_call_target): New member function.
(cgraph_edge::next_speculative_call_target): New member function.
(cgraph_edge::speculative_call_target_ref): New member function.
(cgraph_edge;:speculative_call_indirect_edge): New member funtion.
(cgraph_edge): Remove target_prob.
* cgraphclones.c (cgraph_node::set_call_stmt_including_clones):
Fix handling of speculative calls.
* ipa-devirt.c (ipa_devirt): Fix handling of speculative cals.
* ipa-fnsummary.c (analyze_function_body): Likewise.
* ipa-inline.c (speculation_useful_p): Use new speculative call API.
* ipa-profile.c (dump_histogram): Fix formating.
(ipa_profile_generate_summary): Watch for overflows.
(ipa_profile): Do not require probablity to be 1/2; update to new API.
* ipa-prop.c (ipa_make_edge_direct_to_target): Update to new API.
(update_indirect_edges_after_inlining): Update to new API.
* ipa-utils.c (ipa_merge_profiles): Rewrite merging of speculative call
profiles.
* profile-count.h: (profile_probability::adjusted): New.
* tree-inline.c (copy_bb): Update to new speculative call API; fix
updating of profile.
* value-prof.c (gimple_ic_transform): Rename to ...
(dump_ic_profile): ... this one; update dumping.
(stream_in_histogram_value): Fix formating.
(gimple_value_profile_transformations): Update.
gcc/testsuite/ChangeLog:
* g++.dg/tree-prof/indir-call-prof.C: Update template.
* gcc.dg/tree-prof/crossmodule-indircall-1.c: Add more targets.
* gcc.dg/tree-prof/crossmodule-indircall-1a.c: Add more targets.
* gcc.dg/tree-prof/indir-call-prof.c: Update template.
H.J. Lu [Tue, 28 Jan 2020 19:32:56 +0000 (11:32 -0800)]
i386: Prefer TARGET_AVX over TARGET_SSE_TYPELESS_STORES
movaps/movups is one byte shorter than movdqa/movdqu. But it isn't the
case for AVX nor AVX512. This patch prefers TARGET_AVX over
TARGET_SSE_TYPELESS_STORES and adjust vmovups checks in assembly ouputs.
gcc/
PR target/91461
* config/i386/i386.md (*movoi_internal_avx): Remove
TARGET_SSE_TYPELESS_STORES check.
(*movti_internal): Prefer TARGET_AVX over
TARGET_SSE_TYPELESS_STORES.
(*movtf_internal): Likewise.
* config/i386/sse.md (mov<mode>_internal): Prefer TARGET_AVX over
TARGET_SSE_TYPELESS_STORES. Remove "<MODE_SIZE> == 16" check
from TARGET_SSE_TYPELESS_STORES.
gcc/testsuite/
PR target/91461
* gcc.target/i386/avx256-unaligned-store-2.c: Don't check
vmovups.
* gcc.target/i386/avx256-unaligned-store-3.c: Likewise.
* gcc.target/i386/pieces-memcpy-4.c: Likewise.
* gcc.target/i386/pieces-memcpy-5.c: Likewise.
* gcc.target/i386/pieces-memcpy-6.c: Likewise.
* gcc.target/i386/pieces-strcpy-2.c: Likewise.
* gcc.target/i386/pr90980-1.c: Likewise.
* gcc.target/i386/pr87317-4.c: Check "\tvmovd\t" instead of
"vmovd" to avoid matching "vmovdqu".
* gcc.target/i386/pr87317-5.c: Likewise.
* gcc.target/i386/pr87317-7.c: Likewise.
* gcc.target/i386/pr91461-1.c: New test.
* gcc.target/i386/pr91461-2.c: Likewise.
* gcc.target/i386/pr91461-3.c: Likewise.
* gcc.target/i386/pr91461-4.c: Likewise.
* gcc.target/i386/pr91461-5.c: Likewise.
David Malcolm [Tue, 28 Jan 2020 14:08:25 +0000 (09:08 -0500)]
diagnostic_metadata: unbreak xgettext (v2)
Changed in v2:
- rename from warning_with_metadata_at to warning_meta
- fix test plugins
While C++ can have overloads, xgettext can't deal with overloads that have
different argument positions, leading to two failures in "make gcc.pot":
emit_diagnostic_valist used incompatibly as both
--keyword=emit_diagnostic_valist:4
--flag=emit_diagnostic_valist:4:gcc-internal-format and
--keyword=emit_diagnostic_valist:5
--flag=emit_diagnostic_valist:5:gcc-internal-format
warning_at used incompatibly as both
--keyword=warning_at:3 --flag=warning_at:3:gcc-internal-format and
--keyword=warning_at:4 --flag=warning_at:4:gcc-internal-format
The emit_diagnostic_valist overload isn't used anywhere (I think it's
a leftover from an earlier iteration of the analyzer patch kit).
The warning_at overload is used throughout the analyzer but nowhere else.
Ideally I'd like to consolidate this argument with something
constructable in various ways:
- from a metadata and an int or
- from an int (or, better an "enum opt_code"),
so that the overload happens when implicitly choosing the ctor, but
that feels like stage 1 material.
In the meantime, fix xgettext by deleting the unused overload and
renaming the used one.
gcc/analyzer/ChangeLog:
* region-model.cc (poisoned_value_diagnostic::emit): Update for
renaming of warning_at overload to warning_meta.
* sm-file.cc (file_leak::emit): Likewise.
* sm-malloc.cc (double_free::emit): Likewise.
(possible_null_deref::emit): Likewise.
(possible_null_arg::emit): Likewise.
(null_deref::emit): Likewise.
(null_arg::emit): Likewise.
(use_after_free::emit): Likewise.
(malloc_leak::emit): Likewise.
(free_of_non_heap::emit): Likewise.
* sm-sensitive.cc (exposure_through_output_file::emit): Likewise.
* sm-signal.cc (signal_unsafe_call::emit): Likewise.
* sm-taint.cc (tainted_array_index::emit): Likewise.
gcc/ChangeLog:
* diagnostic-core.h (warning_at): Rename overload to...
(warning_meta): ...this.
(emit_diagnostic_valist): Delete decl of overload taking
diagnostic_metadata.
* diagnostic.c (emit_diagnostic_valist): Likewise for defn.
(warning_at): Rename overload taking diagnostic_metadata to...
(warning_meta): ...this.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_metadata.c: Update for
renaming of warning_at overload to warning_meta.
* gcc.dg/plugin/diagnostic_plugin_test_paths.c: Likewise.
Andrew Benson [Tue, 28 Jan 2020 18:12:23 +0000 (18:12 +0000)]
Increase GFC_MAX_MANGLED_SYMBOL_LEN to handle submodule names.
PR fortran/93461
* trans.h: Increase GFC_MAX_MANGLED_SYMBOL_LEN to
GFC_MAX_SYMBOL_LEN*3+5 to allow for inclusion of submodule name,
plus the "." between module and submodule names.
* gfortran.dg/pr93461.f90: New test.
Andrew Benson [Tue, 28 Jan 2020 17:58:40 +0000 (17:58 +0000)]
Allow concatenated module+submodule names.
Increase length of char variables "parent1" and "parent2" in
set_syms_host_assoc() to allow them to hold concatenated module +
submodule names.
PR fortran/93473
* parse.c: Increase length of char variables to allow them to hold
a concatenated module + submodule name.
* gfortran.dg/pr93473.f90: New test.
Nathan Sidwell [Tue, 28 Jan 2020 15:58:29 +0000 (07:58 -0800)]
preprocessor: Make __has_include a builtin macro [PR93452]
The clever hack of '#define __has_include __has_include' breaks -dD
and -fdirectives-only, because that emits definitions. This turns
__has_include into a proper builtin macro. Thus it's never emitted
via -dD, and because use outside of directive processing is undefined,
we can just expand it anywhere.
PR preprocessor/93452
* internal.h (struct spec_nodes): Drop n__has_include{,_next}.
* directives.c (lex_macro_node): Don't check __has_include redef.
* expr.c (eval_token): Drop __has_include eval.
(parse_has_include): Move to ...
* macro.c (builtin_has_include): ... here.
(_cpp_builtin_macro_text): Eval __has_include{,_next}.
* include/cpplib.h (enum cpp_builtin_type): Add BT_HAS_INCLUDE{,_NEXT}.
* init.c (builtin_array): Add them.
(cpp_init_builtins): Drop __has_include{,_next} init here ...
* pch.c (cpp_read_state): ... and here.
* traditional.c (enum ls): Drop has_include states ...
(_cpp_scan_out_logical_line): ... and here.
Jonathan Wakely [Tue, 28 Jan 2020 15:20:23 +0000 (15:20 +0000)]
libstdc++: Fix order of changelog entries
Rebasing my last two commits put the changelog entries at the wrong
place in the file. Fixed by this change.
Jason Merrill [Mon, 27 Jan 2020 22:55:14 +0000 (17:55 -0500)]
c++: Function declared with typedef with eh-specification.
We just need to handle the exception specification like other properties of
a function typedef.
PR c++/90731
* decl.c (grokdeclarator): Propagate eh spec from typedef.
Julian Brown [Sat, 4 Jan 2020 01:39:56 +0000 (17:39 -0800)]
Check array contiguity for OpenACC/Fortran
PR fortran/93025
gcc/fortran/
* openmp.c (resolve_omp_clauses): Check array references for contiguity.
gcc/testsuite/
* gfortran.dg/goacc/mapping-tests-2.f90: New test.
* gfortran.dg/goacc/subarrays.f95: Expect rejection of non-contiguous
array.
Julian Brown [Fri, 3 Jan 2020 18:06:15 +0000 (10:06 -0800)]
Don't allow mixed component and non-component accesses for OpenACC/Fortran
gcc/fortran/
* gfortran.h (gfc_symbol): Add comp_mark bitfield.
* openmp.c (resolve_omp_clauses): Disallow mixed component and
full-derived-type accesses to the same variable within a single
directive.
libgomp/
* testsuite/libgomp.oacc-fortran/deep-copy-2.f90: Remove test from here.
* testsuite/libgomp.oacc-fortran/deep-copy-3.f90: Don't use mixed
component/non-component variable refs in a single directive.
* testsuite/libgomp.oacc-fortran/classtypes-1.f95: Likewise.
gcc/testsuite/
* gfortran.dg/goacc/deep-copy-2.f90: Move test here (from libgomp
testsuite). Make a compilation test, and expect rejection of mixed
component/non-component accesses.
* gfortran.dg/goacc/mapping-tests-1.f90: New test.
Julian Brown [Sat, 4 Jan 2020 01:45:24 +0000 (17:45 -0800)]
Add OpenACC test for sub-references being pointer or allocatable variables
gcc/testsuite/
* gfortran.dg/goacc/strided-alloc-ptr.f90: New test.
Jonathan Wakely [Tue, 28 Jan 2020 13:24:09 +0000 (13:24 +0000)]
libstdc++: Avoid using sizeof with function types (PR 93470)
PR libstdc++/93470
* include/bits/refwrap.h (reference_wrapper::operator()): Restrict
static assertion to object types.
Jonathan Wakely [Tue, 28 Jan 2020 13:24:09 +0000 (13:24 +0000)]
libstdc++: Replace glibc-specific check for clock_gettime (PR 93325)
It's wrong to assume that clock_gettime is unavailable on any *-*-linux*
target that doesn't have glibc 2.17 or later. Use a generic test instead
of using __GLIBC_PREREQ. Only do that test when is_hosted=yes so that we
don't get an error for cross targets without a working linker.
This ensures that C library's clock_gettime will be used on non-glibc
targets, instead of an incorrect syscall to SYS_clock_gettime.
PR libstdc++/93325
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Use AC_SEARCH_LIBS for
clock_gettime instead of explicit glibc version check.
* configure: Regenerate.
Richard Biener [Tue, 28 Jan 2020 13:09:12 +0000 (14:09 +0100)]
tree-optimization/93439 move clique bookkeeping to OMP expansion
Autopar was doing clique bookkeeping too early when creating destination
functions but then later introducing new cliques via versioning loops.
The following moves the bookkeeping to the actual outlining process.
2020-01-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/93439
* tree-parloops.c (create_loop_fn): Move clique bookkeeping...
* tree-cfg.c (move_sese_region_to_fn): ... here.
(verify_types_in_gimple_reference): Verify used cliques are
tracked.
* gfortran.dg/graphite/pr93439.f90: New testcase.
H.J. Lu [Tue, 28 Jan 2020 12:43:34 +0000 (04:43 -0800)]
i386: Don't use ix86_tune_ctrl_string in parse_mtune_ctrl_str
There are
static void
parse_mtune_ctrl_str (bool dump)
{
if (!ix86_tune_ctrl_string)
return;
parse_mtune_ctrl_str is only called from set_ix86_tune_features, which
is only called from ix86_function_specific_restore and
ix86_option_override_internal. parse_mtune_ctrl_str shouldn't use
ix86_tune_ctrl_string which is defined with global_options. Instead,
opts should be passed to parse_mtune_ctrl_str.
PR target/91399
* config/i386/i386-options.c (set_ix86_tune_features): Add an
argument of a pointer to struct gcc_options and pass it to
parse_mtune_ctrl_str.
(ix86_function_specific_restore): Pass opts to
set_ix86_tune_features.
(ix86_option_override_internal): Likewise.
(parse_mtune_ctrl_str): Add an argument of a pointer to struct
gcc_options and use it for x_ix86_tune_ctrl_string.
Claudiu Zissulescu [Tue, 28 Jan 2020 11:59:34 +0000 (13:59 +0200)]
[ARC] Pass along -mcode-density flag to the assembler.
This change makes sure that if the driver is invoked with
"-mcode-density" flag, then the assembler will receive it too.
Note Claudiu Zissulescu:
This is an old patch of which I forgot to add the test.
testsuite/
2019-09-03 Sahahb Vahedi <shahab@synopsys.com>
* gcc.target/arc/code-density-flag.c: New test.
Richard Sandiford [Sun, 26 Jan 2020 13:01:48 +0000 (13:01 +0000)]
simplify-rtx: Extend (truncate (*extract ...)) fold [PR87763]
In the gcc.target/aarch64/lsl_asr_sbfiz.c part of this PR, we have:
Failed to match this instruction:
(set (reg:SI 95)
(ashift:SI (subreg:SI (sign_extract:DI (subreg:DI (reg:SI 97) 0)
(const_int 3 [0x3])
(const_int 0 [0])) 0)
(const_int 19 [0x13])))
If we perform the natural simplification to:
(set (reg:SI 95)
(ashift:SI (sign_extract:SI (reg:SI 97)
(const_int 3 [0x3])
(const_int 0 [0])) 0)
(const_int 19 [0x13])))
then the pattern matches. And it turns out that we do have a
simplification like that already, but it would only kick in for
extractions from a reg, not a subreg. E.g.:
(set (reg:SI 95)
(ashift:SI (subreg:SI (sign_extract:DI (reg:DI X)
(const_int 3 [0x3])
(const_int 0 [0])) 0)
(const_int 19 [0x13])))
would simplify to:
(set (reg:SI 95)
(ashift:SI (sign_extract:SI (subreg:SI (reg:DI X) 0)
(const_int 3 [0x3])
(const_int 0 [0])) 0)
(const_int 19 [0x13])))
IMO the subreg case is even more obviously a simplification
than the bare reg case, since the net effect is to remove
either one or two subregs, rather than simply change the
position of a subreg/truncation.
However, doing that regressed gcc.dg/tree-ssa/pr64910-2.c
for -m32 on x86_64-linux-gnu, because we could then simplify
a :HI zero_extract to a :QI one. The associated *testqi_ext_3
pattern did already seem to want to handle QImode extractions:
"ix86_match_ccmode (insn, CCNOmode)
&& ((TARGET_64BIT && GET_MODE (operands[2]) == DImode)
|| GET_MODE (operands[2]) == SImode
|| GET_MODE (operands[2]) == HImode
|| GET_MODE (operands[2]) == QImode)
but I'm not sure how often the QI case would trigger in practice,
since the zero_extract mode was restricted to HI and above. I checked
the other x86 patterns and couldn't see any other instances of this.
2020-01-28 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR rtl-optimization/87763
* simplify-rtx.c (simplify_truncation): Extend sign/zero_extract
simplification to handle subregs as well as bare regs.
* config/i386/i386.md (*testqi_ext_3): Match QI extracts too.
Richard Sandiford [Wed, 22 Jan 2020 18:21:05 +0000 (18:21 +0000)]
vect: Pattern-matched calls in reduction chains
gcc.dg/pr56350.c started ICEing for SVE in GCC 10 because we
pattern-matched a division reduction:
a /= 8;
into a signed shift with division semantics:
... = IFN_SDIV_POW2 (..., 3);
whereas the reduction code expected it still to be a gassign.
One fix would be to check for a reduction in the pattern matcher
(but current patterns don't generally do that). Another would be
to fail gracefully for reductions involving calls. Since we can't
vectorise the reduction either way, and probably have a better shot
with the shift form, this patch goes for the "fail gracefully" approach.
2020-01-28 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* tree-vect-loop.c (vectorizable_reduction): Fail gracefully
for reduction chains that (now) include a call.
Tobias Burnus [Tue, 28 Jan 2020 10:54:57 +0000 (11:54 +0100)]
[Fortran] avoid ICE in gfc_omp_check_optional_argument (PR93464)
PR fortran/93464
* openmp.c (gfc_omp_check_optional_argument): Avoid ICE when
DECL_LANG_SPECIFIC and GFC_DESCRIPTOR_TYPE_P but not
GFC_DECL_SAVED_DESCRIPTOR as for local allocatable character vars.
PR fortran/93464
* gfortran.dg/goacc/pr93464.f90: New.
Richard Sandiford [Sat, 25 Jan 2020 17:18:51 +0000 (17:18 +0000)]
forwprop: Tweak choice of VEC_PERM_EXPR filler [PR92822]
For the 2s failures in the PR, we have a V4SF VEC_PERM_EXPR in
which the first two elements are duplicates of one element and
the other two are don't-care:
v4sf_b = VEC_PERM_EXPR <v4sf_a, v4sf_a, { 1, 1, ?, ? }>;
The heuristic was to extend this with a blend:
v4sf_b = VEC_PERM_EXPR <v4sf_a, v4sf_a, { 1, 1, 2, 3 }>;
but it seems better to extend a partial duplicate to a full duplicate:
v4sf_b = VEC_PERM_EXPR <v4sf_a, v4sf_a, { 1, 1, 1, 1 }>;
Obviously this is still just a heuristic though.
I wondered whether to restrict this to two elements or more
but couldn't find any examples in which it made a difference.
Either way should be fine for the purposes of fixing this PR.
2020-01-28 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR tree-optimization/92822
* tree-ssa-forwprop.c (simplify_vector_constructor): When filling
out the don't-care elements of a vector whose significant elements
are duplicates, make the don't-care elements duplicates too.
Richard Sandiford [Mon, 27 Jan 2020 19:37:55 +0000 (19:37 +0000)]
predcom: Fix invalid store-store commoning [PR93434]
predcom has the following code to stop one rogue load from
interfering with other store-load opportunities:
/* If A is read and B write or vice versa and there is unsuitable
dependence, instead of merging both components into a component
that will certainly not pass suitable_component_p, just put the
read into bad component, perhaps at least the write together with
all the other data refs in it's component will be optimizable. */
But when store-store commoning was added later, this had the effect
of ignoring loads that occur between two candidate stores.
There is code further up to handle loads and stores with unknown
dependences:
/* Don't do store elimination if there is any unknown dependence for
any store data reference. */
if ((DR_IS_WRITE (dra) || DR_IS_WRITE (drb))
&& (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know
|| DDR_NUM_DIST_VECTS (ddr) == 0))
eliminate_store_p = false;
But the store-load code above skips loads for *known* dependences
if (a) the load has already been marked "bad" or (b) the data-ref
machinery knows the dependence distance, but determine_offsets
can't handle the combination.
(a) happens to be the problem in the testcase, but a different
sequence could have given (b) instead. We have writes to individual
fields of a structure and reads from the whole structure. Since
determine_offsets requires the types to be the same, it returns false
for each such read/write combination.
This patch records which components have had loads removed and
prevents store-store commoning for them. It's a bit too pessimistic,
since there shouldn't be a problem if a "bad" load dominates all stores
in a component. But (a) we can't AFAIK use pcom_stmt_dominates_stmt_p
here and (b) the handling for that case would probably need to be
removed again if we handled more exotic cases in future.
2020-01-28 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR tree-optimization/93434
* tree-predcom.c (split_data_refs_to_components): Record which
components have had aliasing loads removed. Prevent store-store
commoning for all such components.
gcc/testsuite/
PR tree-optimization/93434
* gcc.c-torture/execute/pr93434.c: New test.
Richard Sandiford [Tue, 28 Jan 2020 09:59:49 +0000 (09:59 +0000)]
testsuite: Add -Wpsabi to gcc.dg/torture/pr93170.c [PR93460]
2020-01-28 Richard Sandiford <richard.sandiford@arm.com>
gcc/testsuite/
PR testsuite/93460
* gcc.dg/torture/pr93170.c: Add -Wpsabi.
Tobias Burnus [Tue, 28 Jan 2020 09:58:00 +0000 (10:58 +0100)]
[Fortran] gfortran.texi - minor style cleanup
* gfortran.texi (Runtime): Remove tailing '.' in @menu.
Martin Liska [Tue, 28 Jan 2020 09:27:16 +0000 (10:27 +0100)]
Add couple of auto_diagnostic_group in redeclare_class_template.
PR c++/92440
* pt.c (redeclare_class_template): Group couple of
errors and inform messages with auto_diagnostic_group.
Martin Liska [Tue, 28 Jan 2020 09:26:53 +0000 (10:26 +0100)]
Replace one error with inform.
PR c++/92440
* pt.c (redeclare_class_template): Use inform
for the second location.
PR c++/92440
* g++.dg/template/pr92440.C: New test.
* g++.dg/cpp0x/vt-34314.C: Update error to note.
* g++.dg/template/pr59930-2.C: Likewise.
* g++.old-deja/g++.pt/redecl1.C: Likewise.
Martin Liska [Tue, 28 Jan 2020 09:25:30 +0000 (10:25 +0100)]
Fix 2 typos in documentation of libstdc++.
PR libstdc++/93478
* include/std/atomic: Fix typo.
* include/std/optional: Likewise.
Jakub Jelinek [Tue, 28 Jan 2020 07:46:23 +0000 (08:46 +0100)]
i386: Fix ix86_fold_builtin shift folding [PR93418]
The following testcase is miscompiled, because the variable shift left
operand, { -1, -1, -1, -1 } is represented as a VECTOR_CST with
VECTOR_CST_NPATTERNS 1 and VECTOR_CST_NELTS_PER_PATTERN 1, so when
we call builder.new_unary_operation, builder.encoded_nelts () will be just 1
and thus we encode the resulting vector as if all the elements were the
same.
For non-masked is_vshift, we could perhaps call builder.new_binary_operation
(TREE_TYPE (args[0]), args[0], args[1], false), but then there are masked
shifts, for non-is_vshift we could perhaps call it too but with args[2]
instead of args[1], but there is no builder.new_ternary_operation.
All this stuff is primarily for aarch64 anyway, on x86 we don't have any
variable length vectors, and it is not a big deal to compute all elements
and just let builder.finalize () find the most efficient VECTOR_CST
representation of the vector. So, instead of doing too much, this just
keeps using new_unary_operation only if only one VECTOR_CST is involved
(i.e. non-masked shift by constant) and for the rest just compute all elts.
2020-01-28 Jakub Jelinek <jakub@redhat.com>
PR target/93418
* config/i386/i386.c (ix86_fold_builtin) <do_shift>: If mask is not
-1 or is_vshift is true, use new_vector with number of elts npatterns
rather than new_unary_operation.
* gcc.target/i386/avx2-pr93418.c: New test.
Jakub Jelinek [Tue, 28 Jan 2020 07:44:07 +0000 (08:44 +0100)]
gimple-fold: Fix buffer overflow in fold_array_ctor_reference [PR93454]
libgcrypt FAILs to build on aarch64-linux with
*** stack smashing detected ***: terminated
when gcc is compiled with -D_FORTIFY_SOURCE=2. The problem is if
fold_array_ctor_reference is called with size equal to or very close to
MAX_BITSIZE_MODE_ANY_MODE bits and non-zero inner_offset.
The first native_encode_expr is called with that inner_offset and bufoff 0,
the subsequent ones with offset of 0, and bufoff elt_size - inner_offset,
2 * elt_size - inner_offset etc. So, e.g. on the testcase where we start
with inner_offset 1 and size is e.g. 256 bytes and elt_size 4 bytes
we then call native_encode_expr at bufoff 251 and then 255, but that one
overwrites 3 bytes beyond the buf array.
The following patch fixes that. In addition, it avoids calling
elt_size.to_uhwi () all the time, and punts if elt_sz would be too large.
2020-01-28 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/93454
* gimple-fold.c (fold_array_ctor_reference): Perform
elt_size.to_uhwi () just once, instead of calling it in every
iteration. Punt if that value is above size of the temporary
buffer. Decrease third native_encode_expr argument when
bufoff + elt_sz is above size of buf.
* gcc.dg/pr93454.c: New test.
David Malcolm [Mon, 27 Jan 2020 21:23:43 +0000 (16:23 -0500)]
analyzer: fix ICE when canonicalizing NaN (PR 93451)
PR analyzer/93451 reports an ICE when canonicalizing the constants
in a region_model, with a failed qsort_chk when attempting to sort
the constants within the region_model.
The svalues in the model were:
sv0: {poisoned: uninit}
sv1: {type: ‘double’, ‘0.0’}
sv2: {type: ‘double’, ‘1.0e+0’}
sv3: {type: ‘double’, ‘ Nan’}
The qsort_chk of the 3 constants fails due to tree_cmp using the
LT_EXPR ordering of the REAL_CSTs, which doesn't work for NaN.
This patch adjusts tree_cmp to impose an arbitrary ordering during
canonicalization for UNORDERED_EXPR cases w/o relying on the LT_EXPR
ordering, fixing the ICE.
gcc/analyzer/ChangeLog:
PR analyzer/93451
* region-model.cc (tree_cmp): For the REAL_CST case, impose an
arbitrary order on NaNs relative to other NaNs and to non-NaNs;
const-correctness tweak.
(ana::selftests::build_real_cst_from_string): New function.
(ana::selftests::append_interesting_constants): New function.
(ana::selftests::test_tree_cmp_on_constants): New test.
(ana::selftests::test_canonicalization_4): New test.
(ana::selftests::analyzer_region_model_cc_tests): Call the new
tests.
gcc/testsuite/ChangeLog:
PR analyzer/93451
* gcc.dg/analyzer/torture/pr93451.c: New test.
GCC Administrator [Tue, 28 Jan 2020 00:16:34 +0000 (00:16 +0000)]
Daily bump.
Andrew Burgess [Wed, 22 Jan 2020 14:54:26 +0000 (14:54 +0000)]
gcc: Add new configure options to allow static libraries to be selected
The motivation behind this change is to make it easier for a user to
link against static libraries on a target where dynamic libraries are
the default library type (for example GNU/Linux).
Further, my motivation is really for linking libraries into GDB,
however, the binutils-gdb/config/ directory is a copy of gcc/config/
so changes for GDB need to be approved by the GCC project first.
After making this change in the gcc/config/ directory I've run
autoreconf on all of the configure scripts in the GCC tree and a
couple have been updated, so I'll use one of these to describe what my
change does.
Consider libcpp, this library links against libiconv. Currently if
the user builds on a system with both static and dynamic libiconv
installed then autotools will pick up the dynamic libiconv by
default. This is almost certainly the right thing to do.
However, if the user wants to link against static libiconv then things
are a little harder, they could remove the dynamic libiconv from their
system, but this is probably a bad idea (other things might depend on
that library), or the user can build their own version of libiconv,
install it into a unique prefix, and then configure gcc using the
--with-libiconv-prefix=DIR flag. This works fine, but is somewhat
annoying, the static library available, I just can't get autotools to
use it.
My change then adds a new flag --with-libiconv-type=TYPE, where type
is either auto, static, or shared. The default auto, ensures we keep
the existing behaviour unchanged.
If the user configures with --with-libiconv-type=static then the
configure script will ignore any dynamic libiconv it finds, and will
only look for a static libiconv, if no static libiconv is found then
the configure will continue as though there is no libiconv at all
available.
Similarly a user can specify --with-libiconv-type=shared and force the
use of shared libiconv, any static libiconv will be ignored.
As I've implemented this change within the AC_LIB_LINKFLAGS_BODY macro
then only libraries configured using the AC_LIB_LINKFLAGS or
AC_LIB_HAVE_LINKFLAGS macros will gain the new configure flag.
If this is accepted into GCC then there will be follow on patches for
binutils and GDB to regenerate some configure scripts in those
projects.
For GCC only two configure scripts needed updated after this commit,
libcpp and libstdc++-v3, both of which link against libiconv.
config/ChangeLog:
* lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Add new
--with-libXXX-type=... option. Use this to guide the selection of
either a shared library or a static library.
libcpp/ChangeLog:
* configure: Regenerate.
libstdc++-v3/ChangeLog:
* configure: Regenerate.
Joseph Myers [Mon, 27 Jan 2020 22:00:52 +0000 (22:00 +0000)]
Support gnu_unique_object symbols on MIPS.
mips_declare_object_name is missing the support for declaring symbols
as gnu_unique_object that is present in the generic
ASM_DECLARE_OBJECT_NAME in elfos.h. I'm not aware of any
MIPS-specific reason for that support to be absent;
mips_declare_object_name predates the addition of gnu_unique_object
support and as far as I can tell this was simply an oversight when
that support was added. This patch adds the missing support,
following the code in elfos.h.
Tested with no regressions with cross to mips-linux-gnu. In
particular, this fixes the failure of the recently-added glibc test
elf/tst-dlopen-nodelete-reloc, which relies on the compiler generating
such symbols, for MIPS.
* config/mips/mips.c (mips_declare_object_name)
[USE_GNU_UNIQUE_OBJECT]: Support use of gnu_unique_object.
Ian Lance Taylor [Fri, 24 Jan 2020 20:39:23 +0000 (12:39 -0800)]
compiler: cleanups permitted by GCC requirement of MPFR 3.1.0
For MPFR functions, change from GMP_RND* to MPFR_RND*.
Also change mp_exp_t to mpfr_expt_t.
Fixes PR go/92463
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/216417
Jason Merrill [Mon, 27 Jan 2020 03:19:47 +0000 (22:19 -0500)]
c++: Fix array of char typedef in template (PR90966).
Since Martin Sebor's patch for PR 71625 to change braced array initializers
to STRING_CST in some cases, we need to be ready for STRING_CST with types
that are changed by tsubst. fold_convert doesn't know how to deal with
STRING_CST, which is reasonable; we really shouldn't expect it to here. So
let's handle STRING_CST separately.
PR c++/90966
* pt.c (tsubst_copy) [STRING_CST]: Don't use fold_convert.
Iain Sandoe [Mon, 27 Jan 2020 10:13:09 +0000 (10:13 +0000)]
coroutines: Ensure the ramp return object is checked (PR93443).
As the PR shows, there is a pathway through the code where the
no_warning value is not set, which corresponds to a missing check
of the ramp return when it was constructed from the 'get return
object' Fixed by ensuring that the check of the return value is
carried out for both return cases.
gcc/cp/ChangeLog:
2020-01-27 Iain Sandoe <iain@sandoe.co.uk>
PR c++/93443
* coroutines.cc (morph_fn_to_coro): Check the ramp return
value when it is constructed from the 'get return object'.
Stam Markianos-Wright [Mon, 27 Jan 2020 18:21:46 +0000 (18:21 +0000)]
Hi all,
This was committed following offline approval by Kyryl.
One minor intended optimisation introduced by :
https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01237.html
was to set a preference for both __fp16 types and __bf16 types to be
loaded/stored directly into/from the FP/NEON registers (if they are available
and if the vld1.16 is compatible), rather than be passed through the regular
r-registers.
This would convert many observed instances of:
** ldrh r3, [r3] @ __fp16
** vmov.f16 s15, r3 @ __fp16
Into a single:
** vld1.16 {d7[2]}, [r3]
This resulted in a regression of a dg-scan-assembler in a __fp16 test.
This patch updates the test to the same testing standard used by the BFloat
tests (use check-function-bodies to explicitly check for correct assembler
generated by each function) and updates it for the latest optimisation.
Cheers,
Stam
gcc/testsuite/ChangeLog:
2020-01-27 Stam Markianos-Wright <stam.markianos-wright@arm.com>
* gcc.target/arm/armv8_2-fp16-move-1.c: Update following load/store
optimisation.
David Malcolm [Thu, 23 Jan 2020 23:28:54 +0000 (18:28 -0500)]
analyzer: restore input_location (PR 93349)
PR analyzer/93349 reports an ICE in IPA pass: simdclone for
some input files when -fanalyzer is supplied, with:
error: location references block not in block tree
The root cause is that the analyzer touches input_location in some
places (to make it easier to track down which source construct the
analyzer can't handle in the case of an analyzer ICE) and fails to reset
it. For the ICE in question, this sets input_location to a location_t
that references some arbitrary block (specifically, that of the last
statement to be analyzed, within the original CFG of whichever is the
last such function to be analyzed).
Later, within omp-simd-clone.c, input_location is used by gimplify_expr
(called via gimplify_and_add), which has:
14492 if (!gimple_seq_empty_p (*pre_p))
14493 annotate_all_with_location_after (*pre_p, pre_last_gsi, input_location);
thus using whatever the value of input_location is, leading
to statements that reference some arbitrary block in the original CFG.
For the reproducer, this happens to be a block in the CFG for the
original function, rather than that of the clone, but in general it
could be some arbitrary other function in the TU.
This code appears to assume that input_location has some arbitrary
value *not* in the block tree, which is potentially violated by the
analyzer's changes to input_location.
This patch adds a save and restore of input_location at the top-level
function of the analyzer, fixing the ICE.
gcc/analyzer/ChangeLog:
PR analyzer/93349
* engine.cc (run_checkers): Save and restore input_location.
gcc/testsuite/ChangeLog:
PR analyzer/93349
* gcc.dg/analyzer/torture/pr93349.c: New test.
David Malcolm [Fri, 17 Jan 2020 16:03:15 +0000 (11:03 -0500)]
analyzer: fix pattern-test-2.c (PR 93291)
Amongst the inputs to the analyzer state machines that can lead to state
transitions are conditions on CFG edges, such as a test for a pointer
being non-NULL.
These conditionals can be non-trivial to determine in the face of
optimization. For example, at -O2:
if (p == NULL || q == NULL)
is optimized on some targets (e.g. x86_64) to a bitwise-or:
_1 = p_5(D) == 0B;
_2 = q_6(D) == 0B;
_3 = _1 | _2;
if (_3 != 0)
goto <bb 4>; [51.12%]
else
goto <bb 3>; [48.88%]
but on other targets (e.g. powerpc64le) as control flow:
if (p_2(D) == 0B)
goto <bb 5>; [18.09%]
else
goto <bb 3>; [81.91%]
<bb 3> [local count:
879501929]:
if (q_3(D) == 0B)
goto <bb 5>; [30.95%]
else
goto <bb 4>; [69.05%]
region_model::add_any_constraints_from_ssa_def_stmt attempts to walk
SSA def chains to reconstruct the conditions that hold, so that
e.g. in the above case of bitwise-or, the state machine for
"p" can transition to the "known-null" state along the edge leading
to bb 3.
In gcc.dg/analyzer/pattern-test-2.c I attempted to write test coverage
for this, but the test fails on those targets for which the || is
expressed via control flow.
This patch rewrites the test to make explicit use of bitwise-or, and
adds coverage for bitwise-and for good measure.
gcc/testsuite/ChangeLog:
PR analyzer/93291
* gcc.dg/analyzer/pattern-test-2.c: Remove include of stdlib.h.
(test_2): Rewrite to explicitly perform a bitwise-or of two
boolean conditions.
(test_3): New function, to test bitwise-and.
Richard Sandiford [Sun, 26 Jan 2020 12:47:23 +0000 (12:47 +0000)]
aarch64: Fix pr71727.c failure
This test started failing after the switch to -fno-common because we can
now force the array to be aligned to 16 bytes, which in turn lets us use
SIMD accesses. Locally restoring -fcommon seems the most faithful to
the original PR.
2020-01-27 Richard Sandiford <richard.sandiford@arm.com>
gcc/testsuite/
PR testsuite/71727
* gcc.target/aarch64/pr71727.c: Add -fcommon.
Martin Liska [Mon, 27 Jan 2020 15:20:10 +0000 (16:20 +0100)]
Add __gcov_indirect_call_profiler_v4_atomic.
PR gcov-profile/93403
* tree-profile.c (gimple_init_gcov_profiler): Generate
both __gcov_indirect_call_profiler_v4 and
__gcov_indirect_call_profiler_v4_atomic.
PR gcov-profile/93403
* libgcov-profiler.c (__gcov_indirect_call_profiler_v4):
Call __gcov_indirect_call_profiler_body.
(__gcov_indirect_call_profiler_body): New.
(__gcov_indirect_call_profiler_v4_atomic): New.
* libgcov.h (__gcov_indirect_call_profiler_v4_atomic):
New declaration.
David Malcolm [Thu, 23 Jan 2020 21:33:13 +0000 (16:33 -0500)]
analyzer: fixes to tree_cmp and other comparators
region_model.cc's tree_cmp attempted to verify that the ordering
is symmetric by asserting that
tree_cmp (x, y) == -tree_cmp (y, x)
This condition is too strong: it's only required for a comparator that
sign (tree_cmp (x, y)) == -sign (tree_cmp (y, x))
and the incorrect form of the assertion doesn't hold e.g. on s390x where
for certain inputs x, y, tree_cmp (x, y) == 1 and tree_cmp (y, x) == -2,
breaking the build in "make selftest" in stage1.
In any case, these checks are redundant, since qsort_chk performs them.
Additionally, there is a potential lack of transitivity in
worklist::key_t::cmp where hashval_t values are compared by subtraction,
which could fail to be transitive if overflows occur.
This patch eliminates the redundant checks and reimplements the hashval_t
comparisons in terms of < and >, fixing these issues.
gcc/analyzer/ChangeLog:
* call-string.cc (call_string::cmp_1): Delete, moving body to...
(call_string::cmp): ...here.
* call-string.h (call_string::cmp_1): Delete decl.
* engine.cc (worklist::key_t::cmp_1): Delete, moving body to...
(worklist::key_t::cmp): ...here. Implement hash comparisons
via comparison rather than subtraction to avoid overflow issues.
* exploded-graph.h (worklist::key_t::cmp_1): Delete decl.
* region-model.cc (tree_cmp): Eliminate buggy checking for
symmetry.
Richard Sandiford [Sat, 25 Jan 2020 12:43:28 +0000 (12:43 +0000)]
aarch64: Add vector/vector vec_extract patterns [PR92822]
Part of the problem in this PR is that we don't provide patterns
to extract a 64-bit vector from one half of a 128-bit vector.
Adding them fixes:
FAIL: gcc.target/aarch64/fmul_intrinsic_1.c scan-assembler-times fmul\\td[0-9]+, d[0-9]+, d[0-9]+ 1
FAIL: gcc.target/aarch64/fmul_intrinsic_1.c scan-assembler-times fmul\\tv[0-9]+.2d, v[0-9]+.2d, v[0-9]+.d\\[[0-9]+\\] 3
The 2s failures need target-independent changes, after which they rely
on these patterns too.
2020-01-27 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR target/92822
* config/aarch64/aarch64-simd.md (aarch64_get_half<mode>): New
expander.
(@aarch64_split_simd_mov<mode>): Use it.
(aarch64_simd_mov_from_<mode>low): Add a GPR alternative.
Leave the vec_extract patterns to handle 2-element vectors.
(aarch64_simd_mov_from_<mode>high): Likewise.
(vec_extract<VQMOV_NO2E:mode><Vhalf>): New expander.
(vec_extractv2dfv1df): Likewise.
Richard Sandiford [Sat, 25 Jan 2020 10:39:06 +0000 (10:39 +0000)]
aarch64: Fix failure in cmpimm_branch_1.c
gcc.target/aarch64/cmpimm_branch_1.c started failing after Bernd's
fix to make combine take the costs of jumps into account
(g:
391500af1932e696a007). This is because the rtx costs
of *compare_condjump<GPI:mode> were higher than the costs
of the instructions it combines.
2020-01-27 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* config/aarch64/aarch64.c (aarch64_if_then_else_costs): Match
jump conditions for *compare_condjump<GPI:mode>.
David Malcolm [Thu, 23 Jan 2020 17:19:20 +0000 (12:19 -0500)]
analyzer: fix setjmp-detection and support sigsetjmp
This patch removes the hack in is_setjmp_call_p of looking for
"setjmp" and "_setjmp", replacing it with some logic adapted from
special_function_p in calls.c, ignoring up to 2 leading underscores from
the fndecl's name when checking for a function by name.
It also requires that such functions are "extern" and at file scope
for them to be matched.
The patch also generalizes the setjmp/longjmp handling in the analyzer
to also work with sigsetjmp/siglongjmp. Doing so requires generalizing
some hardcoded functions in diagnostics (which were hardcoded to avoid
user-facing messages referring to "_setjmp", which is an implementation
detail) - the patch adds a new function, get_user_facing_name for this,
for use on calls that matched is_named_call_p and
is_specical_named_call_p.
gcc/analyzer/ChangeLog:
* analyzer.cc (is_named_call_p): Check that fndecl is "extern"
and at file scope. Potentially disregard prefix _ or __ in
fndecl's name. Bail if the identifier is NULL.
(is_setjmp_call_p): Expect a gcall rather than plain gimple.
Remove special-case check for leading prefix, and also check for
sigsetjmp.
(is_longjmp_call_p): Also check for siglongjmp.
(get_user_facing_name): New function.
* analyzer.h (is_setjmp_call_p): Expect a gcall rather than plain
gimple.
(get_user_facing_name): New decl.
* checker-path.cc (setjmp_event::get_desc): Use
get_user_facing_name to avoid hardcoding the function name.
(rewind_event::rewind_event): Add rewind_info param, using it to
initialize new m_rewind_info field, and strengthen the assertion.
(rewind_from_longjmp_event::get_desc): Use get_user_facing_name to
avoid hardcoding the function name.
(rewind_to_setjmp_event::get_desc): Likewise.
* checker-path.h (setjmp_event::setjmp_event): Add setjmp_call
param and use it to initialize...
(setjmp_event::m_setjmp_call): New field.
(rewind_event::rewind_event): Add rewind_info param.
(rewind_event::m_rewind_info): New protected field.
(rewind_from_longjmp_event::rewind_from_longjmp_event): Add
rewind_info param.
(class rewind_to_setjmp_event): Move rewind_info field to parent
class.
* diagnostic-manager.cc (diagnostic_manager::add_events_for_eedge):
Update setjmp-handling for is_setjmp_call_p requiring a gcall;
pass the call to the new setjmp_event.
* engine.cc (exploded_node::on_stmt): Update for is_setjmp_call_p
requiring a gcall.
(stale_jmp_buf::emit): Use get_user_facing_name to avoid
hardcoding the function names.
(exploded_node::on_longjmp): Pass the longjmp_call when
constructing rewind_info.
(rewind_info_t::add_events_to_path): Pass the rewind_info_t to the
rewind_from_longjmp_event's ctor.
* exploded-graph.h (rewind_info_t::rewind_info_t): Add
longjmp_call param.
(rewind_info_t::get_longjmp_call): New.
(rewind_info_t::m_longjmp_call): New.
* region-model.cc (region_model::on_setjmp): Update comment to
indicate this is also for sigsetjmp.
* region-model.h (struct setjmp_record): Likewise.
(class setjmp_svalue): Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/sigsetjmp-5.c: New test.
* gcc.dg/analyzer/sigsetjmp-6.c: New test.
Richard Biener [Mon, 27 Jan 2020 14:57:09 +0000 (15:57 +0100)]
testsuite/91171 no longer needed XFAIL
2020-01-27 Richard Biener <rguenther@suse.de>
PR testsuite/91171
* gcc.dg/graphite/scop-21.c: un-XFAIL.
David Malcolm [Fri, 24 Jan 2020 21:31:21 +0000 (21:31 +0000)]
analyzer: fix build with gcc 4.4 (PR 93276)
This patch fixes various build failures seen with gcc 4.4
gcc prior to 4.6 complains about:
error: #pragma GCC diagnostic not allowed inside functions
for various uses of PUSH_IGNORE_WFORMAT and POP_IGNORE_WFORMAT.
This patch makes them a no-op with such compilers.
The patch also fixes various errors with template base initializers
and redundant uses of "typename" that older g++ implementations
can't cope with.
gcc/analyzer/ChangeLog:
PR analyzer/93276
* analyzer.h (PUSH_IGNORE_WFORMAT, POP_IGNORE_WFORMAT): Guard these
macros with GCC_VERSION >= 4006, making them no-op otherwise.
* engine.cc (exploded_edge::exploded_edge): Specify template for
base class initializer.
(exploded_graph::add_edge): Specify template when chaining up to
base class add_edge implementation.
(viz_callgraph_node::dump_dot): Drop redundant "typename".
(viz_callgraph_edge::viz_callgraph_edge): Specify template for
base class initializer.
* program-state.cc (sm_state_map::clone_with_remapping): Drop
redundant "typename".
(sm_state_map::print): Likewise.
(sm_state_map::hash): Likewise.
(sm_state_map::operator==): Likewise.
(sm_state_map::remap_svalue_ids): Likewise.
(sm_state_map::on_svalue_purge): Likewise.
(sm_state_map::validate): Likewise.
* program-state.h (sm_state_map::iterator_t): Likewise.
* supergraph.h (superedge::superedge): Specify template for base
class initializer.
gcc/ChangeLog:
PR analyzer/93276
* digraph.cc (test_edge::test_edge): Specify template for base
class initializer.
Nathan Sidwell [Mon, 27 Jan 2020 13:49:43 +0000 (05:49 -0800)]
c++: Bogus error using namespace alias [PR91826]
My changes to is_nested_namespace broke is_ancestor's use where a namespace
alias might be passed in. This changes is_ancestor to look through the alias.
PR c++/91826
* name-lookup.c (is_ancestor): Allow CHILD to be a namespace alias.
Claudiu Zissulescu [Mon, 27 Jan 2020 12:51:03 +0000 (14:51 +0200)]
[ARC] Update ARC600 multiplication cost.
gcc/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/arc.c (arc_rtx_costs): Update mul64 cost.
Claudiu Zissulescu [Mon, 27 Jan 2020 12:51:03 +0000 (14:51 +0200)]
[ARC] Save mlo/mhi registers when ISR.
ARC600 when configured with mul64 instructions uses mlo and mhi
registers to store the 64 result of the multiplication. In the ARC600
ISA documentation we have the next register configuration when ARC600
is configured only with mul64 extension:
Register | Name | Use
---------+------+------------------------------------
r57 | mlo | Multiply low 32 bits, read only
r58 | mmid | Multiply middle 32 bits, read only
r59 | mhi | Multiply high 32 bits, read only
-----------------------------------------------------
When used for Co-existence configurations we have for mul64 the next
registers used:
Register | Name | Use
---------+------+------------------------------------
r58 | mlo | Multiply low 32 bits, read only
r59 | mhi | Multiply high 32 bits, read only
-----------------------------------------------------
Note that mlo/mhi assignment doesn't swap when bigendian CPU
configuration is used.
The compiler will always use r58 for mlo, regardless of the
configuration choosen to ensure mlo/mhi correct splitting. Fixing mlo
to the right register number is done at assembly time. The dwarf info
is also notified via DBX_... macro. Both mlo/mhi registers needs to
saved when ISR happens using a custom sequence.
gcc/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/arc-protos.h (gen_mlo): Remove.
(gen_mhi): Likewise.
* config/arc/arc.c (AUX_MULHI): Define.
(arc_must_save_reister): Special handling for r58/59.
(arc_compute_frame_size): Consider mlo/mhi registers.
(arc_save_callee_saves): Emit fp/sp move only when emit_move
paramter is true.
(arc_conditional_register_usage): Remove TARGET_BIG_ENDIAN from
mlo/mhi name selection.
(arc_restore_callee_saves): Don't early restore blink when ISR.
(arc_expand_prologue): Add mlo/mhi saving.
(arc_expand_epilogue): Add mlo/mhi restoring.
(gen_mlo): Remove.
(gen_mhi): Remove.
* config/arc/arc.h (DBX_REGISTER_NUMBER): Correct register
numbering when MUL64 option is used.
(DWARF2_FRAME_REG_OUT): Define.
* config/arc/arc.md (arc600_stall): New pattern.
(VUNSPEC_ARC_ARC600_STALL): Define.
(mulsi64): Use correct mlo/mhi registers.
(mulsi_600): Clean it up.
* config/arc/predicates.md (mlo_operand): Remove any dependency on
TARGET_BIG_ENDIAN.
(mhi_operand): Likewise.
testsuite/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* gcc.target/arc/interrupt-6.c: Update test.
Claudiu Zissulescu [Mon, 27 Jan 2020 12:51:03 +0000 (14:51 +0200)]
[ARC] Propagate uncached type attribute to each member of a struct.
Like `packed` type attribute, the ARC's `uncached` type attribute
needs to be propagated to each member of the struct where it is used,
triggering the .di flag for any access of the struct members. However,
any complex CFG manipulation may drop memory pointer type attributes,
leading to the impossibility to discriminate the direct accesses from
normal ones. To solve this issue, we will treat the direct memory
accessed specially via unspecs.
gcc/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
Petro Karashchenko <petro.karashchenko@ring.com>
* config/arc/arc.c (arc_is_uncached_mem_p): Check struct
attributes if needed.
(prepare_move_operands): Generate special
unspec instruction for direct access.
(arc_isuncached_mem_p): Propagate uncached attribute to each
structure member.
* config/arc/arc.md (VUNSPEC_ARC_LDDI): Define.
(VUNSPEC_ARC_STDI): Likewise.
(ALLI): New mode iterator.
(mALLI): New mode attribute.
(lddi): New instruction pattern.
(stdi): Likewise.
(stdidi_split): Split instruction for architectures which are not
supporting ll64 option.
(lddidi_split): Likewise.
testsuite/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
Petro Karashchenko <petro.karashchenko@ring.com>
* gcc.target/arc/uncached-1.c: Update test.
* gcc.target/arc/uncached-2.c: Likewise.
* gcc.target/arc/uncached-3.c: New test.
* gcc.target/arc/uncached-4.c: Likewise.
* gcc.target/arc/uncached-5.c: Likewise.
* gcc.target/arc/uncached-6.c: Likewise.
* gcc.target/arc/uncached-7.c: Likewise.
* gcc.target/arc/uncached-8.c: Likewise.
* gcc.target/arc/arc.exp (ll64): New predicate.
Claudiu Zissulescu [Mon, 27 Jan 2020 12:51:03 +0000 (14:51 +0200)]
[ARC] Make libgcc compatible with ARC's reduced register set config.
ARC processors can work with a reduced register set (i.e. registers
r4-r9 and r16-r25 are not available). This option can be enabled
passing -mrf16 option to the compiler, or by using -mcpu=em_mini CPU
configuration. Using RF16 config requires all the hand-made assembly
files used in libgcc to have the corresponding RF16 object attribute
set.
This patch qualifies the relevant hand-made assembly files to
RF16 config, and also adds generic c-functions for the one which are
not.
libgcc/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/crti.S: Add RF16 object attribute.
* config/arc/crtn.S: Likewise.
* config/arc/crttls.S: Likewise.
* config/arc/lib1funcs.S: Likewise.
* config/arc/fp-hack.h (ARC_OPTFPE): Define.
* config/arc/lib2funcs.c: New file.
* config/arc/t-arc: Add lib2funcs to LIB2ADD.
Jonathan Wakely [Mon, 27 Jan 2020 10:30:03 +0000 (10:30 +0000)]
libstdc++: Fix deduction guide for std::span (PR93426)
The deduction guide from an iterator and sentinel used the wrong alias
template and so didn't work.
PR libstdc++/93426
* include/std/span (span): Fix deduction guide.
* testsuite/23_containers/span/deduction.cc: New test.
Richard Sandiford [Sat, 18 Jan 2020 12:41:48 +0000 (12:41 +0000)]
lra: Stop registers being incorrectly marked live [PR92989]
lra_assign has an assert to make sure that no pseudo is allocated
to a conflicting hard register. It used to be restricted to
!flag_ipa_ra, but in g:
a1e6ee38e708ef2bdef4 I'd enabled it for
flag_ipa_ra too. It then tripped while building libstdc++
for mips-mti-linux.
The failure was due to code at the end of process_bb_lives. For an
abnormal/EH edge, we need to make sure that all pseudos that are live
on entry to the destination conflict with all hard registers that are
clobbered by an abnormal call return. The usual way to do this would
be to simulate a clobber of the hard registers, by making them live and
them making them dead again. Making the registers live creates the
conflict; making them dead again restores the correct live set for
whatever follows.
However, process_bb_lives skips the second step (making the registers
dead again) at the start of a BB, presumably on the basis that there's
no further code that needs a correct live set. The problem for the PR
is that that wasn't quite true in practice. There was code further
down process_bb_lives that updated the live-in set of the BB for some
registers, and this live set was "contaminated" by registers that
weren't live but that created conflicts. This information then got
propagated to other blocks, so that registers that were made live
purely to create a conflict at the start of the EH receiver then became
needlessly live throughout preceding blocks. This in turn created a
fake conflict with pseudos in those blocks, invalidating the choices
made by IRA.
The easiest fix seems to be to update the live-in set *before* adding
the fake live registers. An alternative would be to simulate the full
clobber, but that seems a bit wasteful.
2020-01-27 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR rtl-optimization/92989
* lra-lives.c (process_bb_lives): Update the live-in set before
processing additional clobbers.
Richard Sandiford [Sat, 18 Jan 2020 10:59:10 +0000 (10:59 +0000)]
cselib: Fix handling of multireg values for call insns [PR93170]
g:
3bd2918594dae34ae84f mishandled the case in which only the
tail end of a multireg hard register is invalidated by the call.
Walking all the entries should be both safer and more precise.
Avoiding cselib_invalidate_regno also means that we no longer
walk the same list multiple times (which is something we did
before g:
3bd2918594dae34ae84f too).
2020-01-27 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR rtl-optimization/93170
* cselib.c (cselib_invalidate_regno_val): New function, split out
from...
(cselib_invalidate_regno): ...here.
(cselib_invalidated_by_call_p): New function.
(cselib_process_insn): Iterate over all the hard-register entries in
REG_VALUES and invalidate any that cross call-clobbered registers.
gcc/testsuite/
* gcc.dg/torture/pr93170.c: New test.
Richard Sandiford [Thu, 16 Jan 2020 19:20:18 +0000 (19:20 +0000)]
dojump: Fix gcc.dg/torture/pr91323.c for aarch64 targets
PR91323 was fixed for x86 and sparc in target code, but aarch64
instead relies on the target-independent comparison splitters.
Since LTGT is an unordered-signalling operation, we should split
it into unordered-signalling operations for any input that could
be NaN, not just inputs that could be signalling NaNs.
2020-01-27 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* dojump.c (split_comparison): Use HONOR_NANS rather than
HONOR_SNANS when splitting LTGT.
Martin Liska [Mon, 27 Jan 2020 10:01:26 +0000 (11:01 +0100)]
Filter out language specific options from --help=common.
PR driver/91220
* opts.c (print_filtered_help): Exclude language-specific
options from --help=common unless enabled in all FEs.
Martin Liska [Mon, 27 Jan 2020 10:00:53 +0000 (11:00 +0100)]
Do not print params in --help except --help=param.
* opts.c (print_help): Exclude params from
all except --help=param.