gcc.git
4 years agolibstdc++: Fix documentation for return values of copy algos
Jonathan Wakely [Mon, 12 Oct 2020 17:14:01 +0000 (18:14 +0100)]
libstdc++: Fix documentation for return values of copy algos

The doxygen comments for these algos all incorrectly claim to use
(first - last) as the difference from the start of the output range to
the return value. As reported on the mailing list by Johannes Choo, it
should be (last - first).

libstdc++-v3/ChangeLog:

* include/bits/stl_algobase.h (copy, move, copy_backward)
(move_backward): Fix documentation for returned iterator.

4 years agooperator_trunc_mod::wi_fold: Return VARYING for mod by zero.
Aldy Hernandez [Mon, 12 Oct 2020 14:41:21 +0000 (10:41 -0400)]
operator_trunc_mod::wi_fold: Return VARYING for mod by zero.

gcc/ChangeLog:

PR tree-optimization/97378
* range-op.cc (operator_trunc_mod::wi_fold): Return VARYING for mod by zero.

gcc/testsuite/ChangeLog:

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

4 years agoanalyzer: add warnings about writes to constant regions [PR95007]
David Malcolm [Wed, 7 Oct 2020 22:34:09 +0000 (18:34 -0400)]
analyzer: add warnings about writes to constant regions [PR95007]

This patch adds two new warnings:
  -Wanalyzer-write-to-const
  -Wanalyzer-write-to-string-literal
for code paths where the analyzer detects a write to a constant region.

As noted in the documentation part of the patch, the analyzer doesn't
prioritize detection of such writes, in that the state-merging logic
will blithely lose the distinction between const and non-const regions.
Hence false negatives are likely to arise due to state-merging.

However, if the analyzer does happen to spot such a write, it seems worth
reporting, hence this patch.

gcc/analyzer/ChangeLog:
* analyzer.opt (Wanalyzer-write-to-const): New.
(Wanalyzer-write-to-string-literal): New.
* region-model-impl-calls.cc (region_model::impl_call_memcpy):
Call check_for_writable_region.
(region_model::impl_call_memset): Likewise.
(region_model::impl_call_strcpy): Likewise.
* region-model.cc (class write_to_const_diagnostic): New.
(class write_to_string_literal_diagnostic): New.
(region_model::check_for_writable_region): New.
(region_model::set_value): Call check_for_writable_region.
* region-model.h (region_model::check_for_writable_region): New
decl.

gcc/ChangeLog:
* doc/invoke.texi: Document -Wanalyzer-write-to-const and
-Wanalyzer-write-to-string-literal.

gcc/testsuite/ChangeLog:
PR c/83347
PR middle-end/90404
PR analyzer/95007
* gcc.dg/analyzer/write-to-const-1.c: New test.
* gcc.dg/analyzer/write-to-string-literal-1.c: New test.

4 years agoPR c++/97201 - ICE in -Warray-bounds writing to result of operator new(0)
Martin Sebor [Mon, 12 Oct 2020 15:35:02 +0000 (09:35 -0600)]
PR c++/97201 - ICE in -Warray-bounds writing to result of operator new(0)

gcc/cp/ChangeLog:

PR c++/97201
* error.c (dump_type_suffix): Handle both the C and C++ forms of
zero-length arrays.

libstdc++-v3/ChangeLog:

PR c++/97201
* libsupc++/new (operator new): Add attribute alloc_size and malloc.

gcc/testsuite/ChangeLog:

PR c++/97201
* g++.dg/warn/Wplacement-new-size-8.C: Adjust expected message.
* g++.dg/warn/Warray-bounds-10.C: New test.
* g++.dg/warn/Warray-bounds-11.C: New test.
* g++.dg/warn/Warray-bounds-12.C: New test.
* g++.dg/warn/Warray-bounds-13.C: New test.

4 years agoGeneralize compute_objsize to return maximum size/offset instead of failing (PR middl...
Martin Sebor [Fri, 9 Oct 2020 20:48:43 +0000 (14:48 -0600)]
Generalize compute_objsize to return maximum size/offset instead of failing (PR middle-end/97023).

Also resolves:
PR middle-end/97342 - bogus -Wstringop-overflow with nonzero signed and unsigned offsets
PR middle-end/97023 - missing warning on buffer overflow in chained mempcpy
PR middle-end/96384 - bogus -Wstringop-overflow= storing into multidimensional array with index in range

gcc/ChangeLog:

PR middle-end/97342
PR middle-end/97023
PR middle-end/96384
* builtins.c (access_ref::access_ref): Initialize new member.  Use
new enum.
(access_ref::size_remaining): Define new member function.
(inform_access): Handle expressions referencing objects.
(gimple_call_alloc_size): Call get_size_range instead of get_range.
(gimple_call_return_array): New function.
(get_range): Rename...
(get_offset_range): ...to this.  Improve detection of ranges from
types of expressions.
(gimple_call_return_array): Adjust calls to get_range per above.
(compute_objsize): Same.  Set maximum size or offset instead of
failing for unknown objects and handle more kinds of expressions.
(compute_objsize): Call access_ref::size_remaining.
(compute_objsize): Have transitional wrapper fail for pointers
into unknown objects.
(expand_builtin_strncmp): Call access_ref::size_remaining and
handle new cases.
* builtins.h (access_ref::size_remaining): Declare new member function.
(access_ref::set_max_size_range): Define new member function.
(access_ref::add_ofset, access_ref::add_max_ofset): Same.
(access_ref::add_base0): New data member.
* calls.c (get_size_range): Change argument type.  Handle new
condition.
* calls.h (get_size_range): Adjust signature.
(enum size_range_flags): Define new type.
* gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Correct
argument to get_size_range.
* tree-ssa-strlen.c (get_range): Handle anti-ranges.
(maybe_warn_overflow): Check DECL_P before assuming it's one.

gcc/testsuite/ChangeLog:

PR middle-end/97342
PR middle-end/97023
PR middle-end/96384
* c-c++-common/Wrestrict.c: Adjust comment.
* gcc.dg/Wstringop-overflow-34.c: Remove xfail.
* gcc.dg/Wstringop-overflow-43.c: Remove xfails.  Adjust regex patterns.
* gcc.dg/pr51683.c: Prune out expected warning.
* gcc.target/i386/pr60693.c: Same.
* g++.dg/warn/Wplacement-new-size-8.C: New test.
* gcc.dg/Wstringop-overflow-41.c: New test.
* gcc.dg/Wstringop-overflow-44.s: New test.
* gcc.dg/Wstringop-overflow-45.c: New test.
* gcc.dg/Wstringop-overflow-46.c: New test.
* gcc.dg/Wstringop-overflow-47.c: New test.
* gcc.dg/Wstringop-overflow-49.c: New test.
* gcc.dg/Wstringop-overflow-50.c: New test.
* gcc.dg/Wstringop-overflow-51.c: New test.
* gcc.dg/Wstringop-overflow-52.c: New test.
* gcc.dg/Wstringop-overflow-53.c: New test.
* gcc.dg/Wstringop-overflow-54.c: New test.
* gcc.dg/Wstringop-overflow-55.c: New test.
* gcc.dg/Wstringop-overread-5.c: New test.

4 years agoCorrect handling of indices into arrays with elements larger than 1 (PR c++/96511)
Martin Sebor [Fri, 9 Oct 2020 19:56:53 +0000 (13:56 -0600)]
Correct handling of indices into arrays with elements larger than 1 (PR c++/96511)

Resolves:
PR c++/96511 - Incorrect -Wplacement-new on POINTER_PLUS into an array with 4-byte elements
PR middle-end/96384 - bogus -Wstringop-overflow= storing into multidimensional array with index in range

gcc/ChangeLog:

PR c++/96511
PR middle-end/96384
* builtins.c (get_range): Return full range of type when neither
value nor its range is available.  Fail for ranges inverted due
to the signedness of offsets.
(compute_objsize): Handle more special array members.  Handle
POINTER_PLUS_EXPR and VIEW_CONVERT_EXPR that come up in front end
code.
(access_ref::offset_bounded): Define new member function.
* builtins.h (access_ref::eval): New data member.
(access_ref::offset_bounded): New member function.
(access_ref::offset_zero): New member function.
(compute_objsize): Declare a new overload.
* gimple-array-bounds.cc (array_bounds_checker::check_array_ref): Use
enum special_array_member.
* tree.c (component_ref_size): Use special_array_member.
* tree.h (special_array_member): Define a new type.
(component_ref_size): Change signature.

gcc/cp/ChangeLog:

PR c++/96511
PR middle-end/96384
* init.c (warn_placement_new_too_small): Call builtin_objsize instead
of duplicating what it does.

gcc/testsuite/ChangeLog:

PR c++/96511
PR middle-end/96384
* g++.dg/init/strlen.C: Add expected warning.
* g++.dg/warn/Wplacement-new-size-1.C: Relax warnings.
* g++.dg/warn/Wplacement-new-size-2.C: Same.
* g++.dg/warn/Wplacement-new-size-6.C: Same.
* gcc.dg/Warray-bounds-58.c: Adjust
* gcc.dg/Wstringop-overflow-37.c: Same.
* g++.dg/warn/Wplacement-new-size-7.C: New test.

4 years agoCleanup ipa-modref
Jan Hubicka [Mon, 12 Oct 2020 14:17:10 +0000 (16:17 +0200)]
Cleanup ipa-modref

this is largely mechanical patch fixing some suboptimal datastructure decision
in modref.  It records three different things
 1) optimization_summaries that are used by tree-ssa-alias to disambiguate
    (computed by local passes or ipa execute)
 2) summaries produced by local analysis and used by the ipa execute
 3) summaries_lto produced by analysis when streaming is expected,
    streamed, used by ipa execute

All three items are stored in "summaries" datastructure where 1 dn 2
are mixed and differentiated by "finished" flags.

This use extra memory and also makes it impossible to use modref while producing
other IPA summaries (by ipa-prop and ipa-devirt).  This patch separates the
summaries into three special purpose datastructures.

There is one fix to propagation in ipa_merge_modref_summary_after_inlining
where check to ignore stores was placed incorrectly. This seems to lead
to increased clobber disambiguations:

Alias oracle query stats:
  refs_may_alias_p: 64267006 disambiguations, 74475486 queries
  ref_maybe_used_by_call_p: 142119 disambiguations, 65169365 queries
  call_may_clobber_ref_p: 22975 disambiguations, 28762 queries
  nonoverlapping_component_refs_p: 0 disambiguations, 36803 queries
  nonoverlapping_refs_since_match_p: 19401 disambiguations, 55550 must overlaps, 75722 queries
  aliasing_component_refs_p: 54714 disambiguations, 759027 queries
  TBAA oracle: 23636760 disambiguations 56001742 queries
               16112157 are in alias set 0
               10614737 queries asked about the same object
               125 queries asked about the same alias set
               0 access volatile
               3994423 are dependent in the DAG
               1643540 are aritificially in conflict with void *

Modref stats:
  modref use: 11667 disambiguations, 40207 queries
  modref clobber: 1508990 disambiguations, 1829697 queries
  3916688 tbaa queries (2.140621 per modref query)
  623504 base compares (0.340769 per modref query)

PTA query stats:
  pt_solution_includes: 967354 disambiguations, 13605701 queries
  pt_solutions_intersect: 1032982 disambiguations, 13121107 queries

Bootstrapped/regtested x86_64-linux. I plan to commit it tomorrow if there are
no complains.

gcc/ChangeLog:

2020-10-11  Jan Hubicka  <hubicka@ucw.cz>

* ipa-modref.c (modref_summaries): Remove field IPA.
(class modref_summary_lto): New global variable.
(class modref_summaries_lto): New.
(modref_summary::modref_summary): Remove loads_lto and stores_lto.
(modref_summary::~modref_summary): Remove loads_lto and stores_lto.
(modref_summary::useful_p): Do not use lto_useful.
(modref_records_lto): New typedef.
(struct modref_summary_lto): New type.
(modref_summary_lto::modref_summary_lto): New member function.
(modref_summary_lto::~modref_summary_lto): New member function.
(modref_summary_lto::useful_p): New member function.
(modref_summary::dump): Do not handle lto.
(modref_summary_lto::dump): New member function.
(get_modref_function_summary): Use optimization_summary.
(merge_call_side_effects): Use optimization_summary.
(analyze_call): Use optimization_summary.
(struct summary_ptrs): New struture.
(analyze_load): Update to handle separate lto and non-lto summaries.
(analyze_store): Likewise.
(analyze_stmt): Likewise.
(remove_summary): Break out from ...
(analyze_function): ... here; update to handle seprated summaries.
(modref_summaries::insert): Do not handle lto summary.
(modref_summaries_lto::insert): New member function.
(modref_summaries::duplicate): Do not handle lto summary.
(modref_summaries_lto::duplicate): New member function.
(read_modref_records): Expect nolto_ret or lto_ret to be NULL>
(modref_write): Write lto summary.
(read_section): Handle separated summaries.
(modref_read): Initialize separated summaries.
(modref_transform): Handle separated summaries.
(pass_modref::execute): Turn summary to optimization_summary; handle
separate summaries.
(ignore_edge): Handle separate summaries.
(ipa_merge_modref_summary_after_inlining): Likewise.
(collapse_loads): Likewise.
(modref_propagate_in_scc): Likewise.
(pass_ipa_modref::execute): Likewise.
(ipa_modref_c_finalize): Likewise.
* ipa-modref.h (modref_records_lto): Remove typedef.
(struct modref_summary): Remove stores_lto, loads_lto and finished
fields; remove lto_useful_p member function.

4 years agotree-optimization/97357: Fix testcase
Christophe Lyon [Mon, 12 Oct 2020 14:04:06 +0000 (14:04 +0000)]
tree-optimization/97357: Fix testcase

Calling _setjmp causing a warning when targeting newlib.

2020-10-12  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/testsuite/
PR tree-optimization/97357
* gcc.dg/pr97357.c: Call setjmp instead of _setjmp.

4 years agooptimize permutes in SLP, remove vect_attempt_slp_rearrange_stmts
Richard Biener [Wed, 30 Sep 2020 15:08:01 +0000 (17:08 +0200)]
optimize permutes in SLP, remove vect_attempt_slp_rearrange_stmts

This introduces a permute optimization phase for SLP which is
intended to cover the existing permute eliding for SLP reductions
plus handling commonizing the easy cases.

It currently uses graphds to compute a postorder on the reverse
SLP graph and it handles all cases vect_attempt_slp_rearrange_stmts
did (hopefully - I've adjusted most testcases that triggered it
a few days ago).  It restricts itself to move around bijective
permutations to simplify things for now, mainly around constant nodes.

As a prerequesite it makes the SLP graph cyclic (ugh).  It looks
like it would pay off to compute a PRE/POST order visit array
once and elide all the recursive SLP graph walks and their
visited hash-set.  At least for the time where we do not change
the SLP graph during such walk.

I do not like using graphds too much but at least I don't have to
re-implement yet another RPO walk, so maybe it isn't too bad.

It now computes permute placement during iteration and thus should
get cycles more obviously correct.

Richard.

2020-10-06  Richard Biener  <rguenther@suse.de>

* tree-vect-data-refs.c (vect_slp_analyze_instance_dependence):
Use SLP_TREE_REPRESENTATIVE.
* tree-vectorizer.h (_slp_tree::vertex): New member used
for graphds interfacing.
* tree-vect-slp.c (vect_build_slp_tree_2): Allocate space
for PHI SLP children.
(vect_analyze_slp_backedges): New function filling in SLP
node children for PHIs that correspond to backedge values.
(vect_analyze_slp): Call vect_analyze_slp_backedges for the
graph.
(vect_slp_analyze_node_operations): Deal with a cyclic graph.
(vect_schedule_slp_instance): Likewise.
(vect_schedule_slp): Likewise.
(slp_copy_subtree): Remove.
(vect_slp_rearrange_stmts): Likewise.
(vect_attempt_slp_rearrange_stmts): Likewise.
(vect_slp_build_vertices): New functions.
(vect_slp_permute): Likewise.
(vect_slp_perms_eq): Likewise.
(vect_optimize_slp): Remove special code to elide
permutations with SLP reductions.  Implement generic
permute optimization.

* gcc.dg/vect/bb-slp-50.c: New testcase.
* gcc.dg/vect/bb-slp-51.c: Likewise.

4 years agoarm: Use E_FOOmode instead of FOOmode in arm_preferred_simd_mode
Christophe Lyon [Mon, 12 Oct 2020 13:28:20 +0000 (13:28 +0000)]
arm: Use E_FOOmode instead of FOOmode in arm_preferred_simd_mode

gcc-4.8.5 does not accept case clauses with non-literal type, which
happens for "QImode" as it expands to (scalar_int_mode
((scalar_int_mode::from_int) E_QImode)).

Use E_QImode instead in arm_preferred_simd_mode, to fix the
build. Same for HImode, SImode, HFmode and SFmode as introduced by a
recent patch.

2020-10-12  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/
* config/arm/arm.c (arm_preferred_simd_mode): Use E_FOOmode
instead of FOOmode.

4 years agoSLP: fix SVE issues
Martin Liska [Mon, 12 Oct 2020 10:54:31 +0000 (12:54 +0200)]
SLP: fix SVE issues

The patch fixes the following 2 issues:

  .MASK_STORE_LANES (&a, 4B, max_mask_34, vect_array.12);

here we miss to return the last argument as stored value.

ivtmp_32 = ivtmp_31 + POLY_INT_CST [4, 4];

here we miss a bail out in vect_recog_over_widening_pattern.

gcc/ChangeLog:

PR tree-optimization/97079
* internal-fn.c (internal_fn_stored_value_index): Handle also
.MASK_STORE_LANES.
* tree-vect-patterns.c (vect_recog_over_widening_pattern): Bail
out for unsupported TREE_TYPE.

gcc/testsuite/ChangeLog:

PR tree-optimization/97079
* gcc.target/aarch64/sve/pr97079.c: New test.

4 years agofix SLP subgraph detection wrt fully shared lanes
Richard Biener [Mon, 12 Oct 2020 12:29:35 +0000 (14:29 +0200)]
fix SLP subgraph detection wrt fully shared lanes

When a VEC_PERM SLP node just permutes existing lanes this confuses
the SLP subgraph detection where I tried to elide a node-based
visited hash-map in a way that doesn't work.  Fixed by adding such.

2020-10-12  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (vect_bb_partition_graph_r): Use visited
hash-map.
(vect_bb_partition_graph): Likewise.

4 years agovect: Fix an ICE in vect_recog_mask_conversion_pattern
Duan bo [Mon, 12 Oct 2020 11:32:57 +0000 (12:32 +0100)]
vect: Fix an ICE in vect_recog_mask_conversion_pattern

When processing the cond expression, vect_recog_mask_conversion_pattern
doesn't consider the situation that two operands of rhs1 are different
vectypes, leading to a vect ICE. This patch adds the identification and
handling of the situation to fix the problem.

gcc/ChangeLog:

PR target/96757
* tree-vect-patterns.c (vect_recog_mask_conversion_pattern): Add
the identification and handling of the dropped situation in the
cond expression processing phase.

gcc/testsuite/ChangeLog:

PR target/96757
* gcc.target/aarch64/pr96757.c: New test.

4 years agonvptx - invoke.texi: Update default of -misa
Tobias Burnus [Mon, 12 Oct 2020 11:13:20 +0000 (13:13 +0200)]
nvptx - invoke.texi: Update default of -misa

Followup to commit 383400a6078d75bbfa1216c9af2c37f7e88740c9

gcc/ChangeLog
* doc/invoke.texi (nvptx's -misa): Update default to sm_35.

4 years agoPR target/97349 AArch64: Incorrect types for some Neon vdupq_n_<...> intrinsics
Kyrylo Tkachov [Fri, 9 Oct 2020 09:34:15 +0000 (10:34 +0100)]
PR target/97349 AArch64: Incorrect types for some Neon vdupq_n_<...> intrinsics

This patch fixes the PR by adjusting the input types of the intrinsic
prototypes to the ones mandated by ACLE
Turns out the tests in the testsuite were already using the correct
ones, but implicit conversions hid the bug...

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/
PR target/97349
* config/aarch64/arm_neon.h (vdupq_n_p8, vdupq_n_p16,
vdupq_n_p64, vdupq_n_s8, vdupq_n_s16, vdupq_n_u8, vdupq_n_u16):
Fix argument type.

gcc/testsuite/
PR target/97349
* gcc.target/aarch64/simd/pr97349.c: New test.

4 years agoIBM Z: Change vector copysign to use bitwise operations
Ilya Leoshkevich [Wed, 7 Oct 2020 14:51:21 +0000 (16:51 +0200)]
IBM Z: Change vector copysign to use bitwise operations

The vector copysign pattern incorrectly assumes that vector
if_then_else operates on bits, not on elements.  This can theoretically
mislead the optimizers.  Fix by changing it to use bitwise operations,
like commit 2930bb321794 ("PR94613: Fix vec_sel builtin for IBM Z") did
for vec_sel builtin.

gcc/ChangeLog:

2020-10-07  Ilya Leoshkevich  <iii@linux.ibm.com>

* config/s390/s390-protos.h (s390_build_signbit_mask): New
function.
* config/s390/s390.c (s390_contiguous_bitmask_vector_p):
Bitcast the argument to an integral mode.
(s390_expand_vec_init): Do not call
s390_contiguous_bitmask_vector_p with a scalar argument.
(s390_build_signbit_mask): New function.
* config/s390/vector.md (copysign<mode>3): Use bitwise
operations.

4 years agolibphobos: Override tool_timeout value in testsuite
Iain Buclaw [Mon, 12 Oct 2020 08:11:44 +0000 (10:11 +0200)]
libphobos: Override tool_timeout value in testsuite

Some of the larger tests in the phobos testsuite on occasion trigger the
default timeout limit.  Increasing the limit to 10 minutes should give
compilation enough time to finish.

libphobos/ChangeLog:

* testsuite/lib/libphobos.exp: Define tool_timeout, set to 600.

4 years agod: Merge upstream dmd 70aabfb51
Iain Buclaw [Sun, 11 Oct 2020 20:20:43 +0000 (22:20 +0200)]
d: Merge upstream dmd 70aabfb51

Fixes a symbol resolver bug where a private alias becomes public if used
before its declaration.

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

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 70aabfb51

4 years agod: Merge upstream dmd 3a9790525
Iain Buclaw [Sun, 11 Oct 2020 20:27:00 +0000 (22:27 +0200)]
d: Merge upstream dmd 3a9790525

Fixes the return codes to match the documentation of
Target::isVectorTypeSupported.

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

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 3a9790525
* d-target.cc (Target::isVectorTypeSupported): Adjust return codes for
invalid size and invalid base type.

4 years agoIgnore shifts larger than precision in operator_rshift::op1_range.
Aldy Hernandez [Mon, 12 Oct 2020 08:08:28 +0000 (04:08 -0400)]
Ignore shifts larger than precision in operator_rshift::op1_range.

gcc/ChangeLog:

PR tree-optimization/97371
* range-op.cc (operator_rshift::op1_range): Ignore shifts larger than
or equal to type precision.

gcc/testsuite/ChangeLog:

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

4 years agoIPA: prevent an UBSAN error
Martin Liska [Mon, 12 Oct 2020 08:13:46 +0000 (10:13 +0200)]
IPA: prevent an UBSAN error

Prevents the following UBSAN error:

./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/torture/pr49770.C -O2 -c
/home/marxin/Programming/gcc2/gcc/ipa-modref-tree.h:482:22: runtime error: load of value 2, which is not a valid value for type 'bool'
    #0 0x1fdb4d1 in modref_tree<int>::merge(modref_tree<int>*, vec<modref_parm_map, va_heap, vl_ptr>*) /home/marxin/Programming/gcc2/gcc/ipa-modref-tree.h:482
    #1 0x1fcadaa in merge_call_side_effects(modref_summary*, gimple*, modref_summary*, bool) /home/marxin/Programming/gcc2/gcc/ipa-modref.c:511
    #2 0x1fcbadd in analyze_call /home/marxin/Programming/gcc2/gcc/ipa-modref.c:642
    #3 0x1fcc061 in analyze_stmt /home/marxin/Programming/gcc2/gcc/ipa-modref.c:732
    #4 0x1fccf31 in analyze_function /home/marxin/Programming/gcc2/gcc/ipa-modref.c:823
    #5 0x1fd17e5 in execute /home/marxin/Programming/gcc2/gcc/ipa-modref.c:1441
    #6 0x25cca6e in execute_one_pass(opt_pass*) /home/marxin/Programming/gcc2/gcc/passes.c:2509
    #7 0x25cd39b in execute_pass_list_1 /home/marxin/Programming/gcc2/gcc/passes.c:2597
    #8 0x25cd450 in execute_pass_list_1 /home/marxin/Programming/gcc2/gcc/passes.c:2598
    #9 0x25cd4ee in execute_pass_list(function*, opt_pass*) /home/marxin/Programming/gcc2/gcc/passes.c:2608
    #10 0x25c7a5a in do_per_function_toporder(void (*)(function*, void*), void*) /home/marxin/Programming/gcc2/gcc/passes.c:1726
    #11 0x25cfa3f in execute_ipa_pass_list(opt_pass*) /home/marxin/Programming/gcc2/gcc/passes.c:2941
    #12 0x173572d in ipa_passes /home/marxin/Programming/gcc2/gcc/cgraphunit.c:2642
    #13 0x17364ee in symbol_table::compile() /home/marxin/Programming/gcc2/gcc/cgraphunit.c:2777
    #14 0x17372d9 in symbol_table::finalize_compilation_unit() /home/marxin/Programming/gcc2/gcc/cgraphunit.c:3022
    #15 0x2a1f00a in compile_file /home/marxin/Programming/gcc2/gcc/toplev.c:485
    #16 0x2a27dc8 in do_compile /home/marxin/Programming/gcc2/gcc/toplev.c:2321
    #17 0x2a283cc in toplev::main(int, char**) /home/marxin/Programming/gcc2/gcc/toplev.c:2460
    #18 0x54f21cd in main /home/marxin/Programming/gcc2/gcc/main.c:39
    #19 0x7ffff6f0de09 in __libc_start_main ../csu/libc-start.c:314
    #20 0x9eac09 in _start (/home/marxin/Programming/gcc2/objdir/gcc/cc1plus+0x9eac09)

gcc/ChangeLog:

* ipa-modref.c (merge_call_side_effects): Clear modref_parm_map
fields in the vector.

4 years agoMore consistently split SLP groups
Richard Biener [Mon, 12 Oct 2020 07:31:16 +0000 (09:31 +0200)]
More consistently split SLP groups

This appropriately makes matches all true after successful SLP discovery
to reliably succeed splitting.  We were picking up an eventual all
false built-up from scalars state in some cases.

2020-10-12  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (vect_analyze_slp_instance): Set matches to true
after successful discovery but forced split.

4 years ago[nvptx] Fix -msoft-stack-reserve-local format
Tom de Vries [Mon, 12 Oct 2020 08:14:13 +0000 (10:14 +0200)]
[nvptx] Fix -msoft-stack-reserve-local format

Currently, in order to use the switch -msoft-stack-reserve-local with the
default arg 128, you have to specify '-msoft-stack-reserve-local128'.

Fix the switch format such that you specify '-msoft-stack-reserve-local=128'
instead.

Tested on nvptx.

gcc/ChangeLog:

2020-10-12  Tom de Vries  <tdevries@suse.de>

* config/nvptx/nvptx.opt (-msoft-stack-reserve-local): Rename to ...
(-msoft-stack-reserve-local=): ... this.

4 years agotree-optimization/97357 - avoid abnormals in loop splitting conditions
Richard Biener [Mon, 12 Oct 2020 06:51:05 +0000 (08:51 +0200)]
tree-optimization/97357 - avoid abnormals in loop splitting conditions

This avoids abnormals in another place.

2020-10-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97357
* tree-ssa-loop-split.c (ssa_semi_invariant_p): Abnormal
SSA names are not semi invariant.

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

4 years agoFortran : ICE in gfc_validate_kind PR96099
Mark Eggleston [Thu, 1 Oct 2020 10:14:09 +0000 (11:14 +0100)]
Fortran  : ICE in gfc_validate_kind PR96099

Only check for kind if the type supports kind.

2020-10-12  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/fortran/ChangeLog:

PR fortran/96099
* decl.c (gfc_match_implicit): Check for numeric and logical
types.

2020-10-12  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite/ChangeLog:

PR fortran/96099
* gfortran.dg/pr96099_1.f90: New test.
* gfortran.dg/pr96099_2.f90: New test.

4 years agoDaily bump.
GCC Administrator [Mon, 12 Oct 2020 00:16:25 +0000 (00:16 +0000)]
Daily bump.

4 years agoimport elementary functions as intrinsics
Alexandre Oliva [Sun, 11 Oct 2020 23:27:27 +0000 (20:27 -0300)]
import elementary functions as intrinsics

Importing them as intrinsics enables GCC to treat them as builtins
whose behavior is known by GCC.

Specifically, if they aren't intrinsics, calls to Sin and Cos won't be
combined into sincos.

We still need to make Sin and Cos wrappers inline in user-exposed
interfaces to get users the benefit of this transformation.
That is forthcoming in a separate patch.

for  gcc/ada/ChangeLog

* libgnat/a-numaux.ads: Make all imports Intrinsic.
* libgnat/a-numaux__darwin.ads: Likewise.
* libgnat/a-numaux__libc-x86.ads: Likewise.
* libgnat/a-numaux__vxworks.ads: Likewise.

4 years agoaix: remove libgomp and libatomic archives before creating FAT archives
Clément Chigot [Tue, 1 Sep 2020 09:32:09 +0000 (11:32 +0200)]
aix: remove libgomp and libatomic archives before creating FAT archives

AIX caches shared objects in archives with read-other permission.
libgomp and libatomic might be in use during the build or testing, which
may cause archiver operations on them to fail.  This patch adjusts the
Makefile fragments to delete the library archives before creating fresh
archives containing both the 32 bit and 64 bit shared objects.

libatomic/ChangeLog:

2020-10-11  Clement Chigot  <clement.chigot@atos.net>

* config/t-aix: Delete and recreate libatomic before creating
FAT library.

libgomp/ChangeLog:

2020-10-11  Clement Chigot  <clement.chigot@atos.net>

* config/t-aix: Delete and recreate libgomp before creating
FAT library.

4 years agoObjective-C, Darwin : Make protocols private extern and weak.
Iain Sandoe [Sat, 3 Oct 2020 19:49:53 +0000 (20:49 +0100)]
Objective-C, Darwin : Make protocols private extern and weak.

Newer linkers want protocols to be private-extern and weak.
This is conditional on the runtime version.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c
(create_global_decl): Update to allow the caller to
specify declaration or definition.
(create_hidden_decl): Likewise.
(next_runtime_abi_02_protocol_decl): Make the symbol
weak and hidden for later OS runtime versions.
(build_v2_protocol_list_address_table): Likewise.

4 years agolibobjc, Darwin : Fix powerpc encoding regression.
Iain Sandoe [Sun, 11 Oct 2020 14:36:13 +0000 (15:36 +0100)]
libobjc, Darwin : Fix powerpc encoding regression.

This corrects a typo in the recipe for the special type alignment
rules that are used for 32bit powerpc Darwin platforms.

libobjc/ChangeLog:

* encoding.c (_darwin_rs6000_special_round_type_align):
Use DFMode in the emulation of the special round type.

4 years agoObjective-C++ : Fix bitfield ivars.
Iain Sandoe [Sat, 10 Oct 2020 10:14:47 +0000 (11:14 +0100)]
Objective-C++ : Fix bitfield ivars.

This fixes a regression present from 8.x;  It used to be OK
to test for a DECL_INITIAL value to flag that an ivar was a
bitfield (the initial value was the width).  This still works
on C / Objective-C, but no longer on C++.  Replace the test
with DECL_C_BIT_FIELD() which is set for both C and C++.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c (objc_v2_build_ivar_ref): Test
DECL_C_BIT_FIELD to detect that an ivar is a bitfield.

4 years agotestsuite, Objective-c++ : Update diagnostic plugin test.
Iain Sandoe [Wed, 7 Oct 2020 18:41:45 +0000 (19:41 +0100)]
testsuite, Objective-c++ : Update diagnostic plugin test.

The @selector() and @protocol() operators produce var decls
these do not work with the example plugin.  Unfortunatetely,
unlike the ObjC front end, it is not so easy to construct a
substitute expression that works reliably.  Where it does not
work we xfail for now.

gcc/testsuite/ChangeLog:

* obj-c++.dg/plugin/diagnostic-test-expressions-1.mm:
Adjust testcase to include expressions for @selector and
@protocol. XFAIL where this is still not sufficient to obtain
a disgnostic range.

4 years agotestsuite, objective-c++ : Add a dummy retain/release to testuite object.
Iain Sandoe [Wed, 7 Oct 2020 15:24:14 +0000 (16:24 +0100)]
testsuite, objective-c++ : Add a dummy retain/release to testuite object.

On newer systems, the throw/catch process sends retain and release
messages to thrown objects.  While these are not needed in the testsuite
cases, they cause the tests to fail because the selector is not handled.
Add dummy methods to the testsuite object.

gcc/testsuite/ChangeLog:

* objc-obj-c++-shared/TestsuiteObject.h: Add dummy retain and
release method declarations.
* objc-obj-c++-shared/TestsuiteObject.m: Add dummy retain and
release implementations.

4 years agotestsuite, objective-c++ : GC is not available from Darwin16.
Iain Sandoe [Wed, 7 Oct 2020 15:21:52 +0000 (16:21 +0100)]
testsuite, objective-c++ : GC is not available from Darwin16.

Update the dg-skip to cover newer systems.

gcc/testsuite/ChangeLog:

* obj-c++.dg/objc-gc-3.mm:i Skip for Darwin >= 16.

4 years agoaix: add FAT library support for libstdc++fs.a
Clément Chigot [Tue, 1 Sep 2020 09:07:16 +0000 (11:07 +0200)]
aix: add FAT library support for libstdc++fs.a

Make libstdc++fs.a a 32/64 bit FAT library.

It is too complicated for the FAT library Makefile fragment to determine if
--enable-libstdcxx-filesystem-ts has been enabled.  This patch checks the
existence of libstdc++fs.a at build time and adds the complementary object
file if it was built.

libstdc++-v3/Changelog:

2020-10-11  Clement Chigot  <clement.chigot@atos.net>

* config/os/aix/t-aix: Add complementary mode object file to
libstdc++fs.a

4 years agotestsuite, Objective-C++ : Skip an ancient test on newer systems.
Iain Sandoe [Wed, 7 Oct 2020 15:20:48 +0000 (16:20 +0100)]
testsuite, Objective-C++ : Skip an ancient test on newer systems.

This test contains elements incompatible with modern Objective-C
headers, it is only of relevance to Darwin8 or potentially on systems
with SDKs that could target Darwin8, so skip it on newer systems.

gcc/testsuite/ChangeLog:

* obj-c++.dg/cxx-ivars-3.mm: Skip for macOS >= 10.7.

4 years agotestsuite, Objective-c++ : Fix GNU API tests to work with NeXT where possible.
Iain Sandoe [Wed, 7 Oct 2020 15:19:09 +0000 (16:19 +0100)]
testsuite, Objective-c++ : Fix GNU API tests to work with NeXT where possible.

The version 2 GNU Objective C API is mostly compatible with the NeXT one.
However, there are a few testsuite tweaks needed (and one test fails for NeXT
without considerable increase in complexity).

gcc/testsuite/ChangeLog:

* obj-c++.dg/gnu-api-2-class-meta.mm: Add a flag to cause NeXT
headers to expose prototypes for messaging.
* obj-c++.dg/gnu-api-2-class.mm: Likewise.
* obj-c++.dg/gnu-api-2-objc.mm: Skip this because of the extra
protocols pulled in by system headers.

4 years agotestsuite, Objective-C : Fix two plugin diagnostics tests for Darwin.
Iain Sandoe [Wed, 7 Oct 2020 08:12:36 +0000 (09:12 +0100)]
testsuite, Objective-C : Fix two plugin diagnostics tests for Darwin.

The @selector and @protocol keywords produce a var decl without
useful location information. The current diagnostics plugin does not
look at VAR_DECLs (and it would not be helpful if it did in this
case, since a single decl is shared across all the users).

However, ee can, in this case, make expressions that produce useful
information.

gcc/testsuite/ChangeLog:

* objc.dg/plugin/diagnostic-test-expressions-1.m: Use assignment
expressions for @selector and @protocol to obtain a useful
diagnostic range.

4 years agotestsuite, Objective-C : Fix call-super-2.m for newer NeXT headers.
Iain Sandoe [Thu, 8 Oct 2020 07:00:08 +0000 (08:00 +0100)]
testsuite, Objective-C : Fix call-super-2.m for newer NeXT headers.

We were using a callout to runtime.h which, eventually brings in the system
runtime.h.  One newer versions of the Darwin/NeXT headers this declares the
objc_getClass() function as returning Class, rather than the internal
representation of that.  This breaks a fragile assumption in objc-act that
the use of these internal functions can be deduced by looking at the function
type.  Ultimately, the fragility should be fixed - but this fixes up the test
so that it only uses the compiler's forward declaration of the function.

gcc/testsuite/ChangeLog:

* objc.dg/call-super-2.m: Remove inclusion of runtime.h.
Add a FIXME about the test portability.

4 years agotestsuite, Objective-C : Update forward-1.m.
Iain Sandoe [Tue, 6 Oct 2020 20:30:17 +0000 (21:30 +0100)]
testsuite, Objective-C : Update forward-1.m.

Newer versions of the runtime / NSObject don't respond to forward:.
This uses the replacement.

gcc/testsuite/ChangeLog:

* objc.dg/torture/forward-1.m: Implement forwarding using the
native NeXT (NSInvocation) method for Darwin.

4 years agotestsuite, Objective-C : Add initialize method to root class.
Iain Sandoe [Mon, 5 Oct 2020 10:38:12 +0000 (11:38 +0100)]
testsuite, Objective-C : Add initialize method to root class.

Older versions of the runtime don't like it when the root class
has a missing initialize method.  They try to forward to an non-
existent super class resulting in a crash.

TODO: maybe we can diagnose this.

gcc/testsuite/ChangeLog:

* objc.dg/ivar-scope-4.m: Add inititialize method to the
root class.

4 years agotestsuite, Objective-C : Adjust gnu-api tests for Darwin.
Iain Sandoe [Mon, 5 Oct 2020 10:36:36 +0000 (11:36 +0100)]
testsuite, Objective-C : Adjust gnu-api tests for Darwin.

The GNU v2 API matches the next v2 API in most respects.

However, some of the tests depend on access to items that the
later NeXT headers consider to be 'internal implementation details'
and are not exposed (we arrange that with a DEFINE).

One test is skipped here because, although it works internally, the
number of objects returned is larger for the NeXT runtime in some
cases (where the headers have been updated to bring in more of the
system details).

gcc/testsuite/ChangeLog:

* objc.dg/gnu-api-2-class-meta.m: Add a flag to cause NeXT
headers to expose prototypes for messaging. Mark the root
class if the objc_root_class attribute is available. Use
char ** as the second arg to main.
* objc.dg/gnu-api-2-class.m: Use dispatch prototype.
* objc.dg/gnu-api-2-objc.m: Skip on NeXT because of extra
prototypes pulled in by headers.

4 years agotestsuite, Objective-C : Update a test for newer OS versions.
Iain Sandoe [Sat, 3 Oct 2020 23:05:17 +0000 (00:05 +0100)]
testsuite, Objective-C : Update a test for newer OS versions.

Objective-C GC is not available for any recent Darwin version, nor
is it available for the upcoming release of Darwin20.

gcc/testsuite/ChangeLog:

* objc.dg/objc-gc-4.m: Disable for macOS 10.15 and 11.x.

4 years agotestsuite, Objective-C : Compatibility fixes.
Iain Sandoe [Sat, 3 Oct 2020 23:03:54 +0000 (00:03 +0100)]
testsuite, Objective-C : Compatibility fixes.

Changes to deal with warnings and/or errors seen when compiling the
tests with clang.

gcc/testsuite/ChangeLog:

* objc-obj-c++-shared/TestsuiteObject.h: If the compiler
supports objc_root_object attributes, then mark the testsuite
object accordingly.
* objc-obj-c++-shared/TestsuiteObject.m: Avoid direct access
to isa, which is an error for modern Objective-C.
* objc/execute/class-tests-1.h: Declare a string function we
use locally (avoid pulling in the whole of string.h).

4 years agoDarwin, Objective-C : Adjust objective-c symbol linkage with version.
Iain Sandoe [Sun, 4 Oct 2020 09:09:57 +0000 (10:09 +0100)]
Darwin, Objective-C : Adjust objective-c symbol linkage with version.

Earlier linkers cannot handle publicly-visible (or linker-visible)
metadata, so we need to make the output of these conditional on version.

gcc/ChangeLog:

* config/darwin.c (darwin_globalize_label): Make a subset of
metadate symbols global.
(darwin_label_is_anonymous_local_objc_name): Make a subset of
metadata symbols linker-visible.
(darwin_override_options): Track more target OS versions, make
the next_runtime version track this (unless it's set to 0 for
GNU runtime).

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c (FIXUP_NEEDED): Rename ...
(USE_FIXUP_BEFORE): ... to this.
(next_runtime_02_initialize): Likewise.
(next_runtime_abi_02_get_arg_type_list_base): Likewise.
(next_runtime_abi_02_build_objc_method_call): Likewise.

4 years agoDarwin, Objective-C : Update meta-data linkage.
Iain Sandoe [Sat, 3 Oct 2020 13:34:27 +0000 (14:34 +0100)]
Darwin, Objective-C : Update meta-data linkage.

Newer versions of ld64 require that some meta-data symbols are
global, and that a larger set are linker-visible.

gcc/ChangeLog:

* config/darwin.c (darwin_globalize_label): Add protocol
meta-data labels to the set that are global.
(darwin_label_is_anonymous_local_objc_name): Arrange for meta-
data start labels to be linker-visible.

4 years agoObjective-C, Darwin : Update message call codegen.
Iain Sandoe [Tue, 29 Sep 2020 18:16:12 +0000 (19:16 +0100)]
Objective-C, Darwin : Update message call codegen.

Platform compilers based on LLVM do not use the objc_sendMsg_fixit
and friends for newer editions of the OS (runtimes for Arm64 do not even
have those entries).

We need to arrange to allow for this codegen on modern Darwin.

The _fixit versions are needed for some OS versions (at least, up to
10.6) since the super2 call is not implemented there.  It does not
seem worth making the codegen more fine-grained at present.

Other parts of the codegen need to be made conditional on either the
runtime version or the linker capabilities.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c (TAG_MSGSENDSUPER): Revised
spelling.
(TAG_MSGSENDID): Likewise.
(TAG_MSGSENDSUPER_STRET): Likewise.
(TAG_MSGSENDID_STRET): Likewise.
(FIXUP_NEEDED): Likewise.
(TAG_FIXUP): New.
(next_runtime_02_initialize): Adjust message calls to use
fixup variants only when required.
(next_runtime_abi_02_get_arg_type_list_base): Correct
indent.
(build_v2_build_objc_method_call): New.
(build_v2_objc_method_fixup_call): Split out from ...
(next_runtime_abi_02_build_objc_method_call): ... here.
Arrange to adjust the call on the basis of the target
runtime.

4 years agoObjective-C, Darwin : Revise the runtime selection options.
Iain Sandoe [Fri, 9 Oct 2020 14:17:34 +0000 (15:17 +0100)]
Objective-C, Darwin : Revise the runtime selection options.

For the NeXT/Darwin runtime as installed on macOS, we now
need to deal with changes in ABI and APIs over the range
of system versions supported.

For the first phase of these changes, we will make the
existing flag_next_runtime carry a value that represents
the target OS version.  It might be necessary to extend the
value to represent the ABI ('fragile', V1/V2) or the linker
capabilities (some changes to the linker-visible and public
symbols are dependent on linker version).

TODO: arrange to set the default NEXT_OBJC_RUNTIME on the
basis of the configured target version.

gcc/ChangeLog:

* config/darwin.c (darwin_objc2_section): Allow for
values > 1 to represent the next runtime.
(darwin_objc1_section): Likewise.
* config/darwin.h (NEXT_OBJC_RUNTIME): Set the default
next runtime value to be 10.5.8.

4 years agoObjective-C++, Darwin : Make metadata 'extern "C"'.
Iain Sandoe [Tue, 6 Oct 2020 17:50:22 +0000 (18:50 +0100)]
Objective-C++, Darwin : Make metadata 'extern "C"'.

For current system toolchains NeXT runtime metadata symbols are not
mangled for Objective-C++ (i.e. they are considered to be
'extern "C"').

This change becomes essential when we start to emit metadata refs
as hidden and weak which is required by later editions of the runtime
and linkers.

gcc/objc/ChangeLog:

* objc-runtime-shared-support.c (start_var_decl): Make the
decl_assembler_name follow the metadata name for C++ on NeXT
runtime platforms.

4 years agoOjective-C, Darwin : Adjust category superclass ref names (NFC).
Iain Sandoe [Sat, 10 Oct 2020 21:21:05 +0000 (22:21 +0100)]
Ojective-C, Darwin : Adjust category superclass ref names (NFC).

Make the order of the class and superclass match the metadata
order from clang.  Makes it easier to compare produced meta-
data between implementations.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c
(next_runtime_abi_02_category_decl): Adjust category
superclass name ordering.

4 years agoObjective-C, Darwin : Update protocol metadata to current version.
Iain Sandoe [Sat, 3 Oct 2020 13:41:23 +0000 (14:41 +0100)]
Objective-C, Darwin : Update protocol metadata to current version.

Later versions of the NeXT runtime protocol metadata contain additional
fields.  This patch adds these fields and populates a new list of
method types.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c (build_v2_super_template): Add new
fields to the template.
(build_v2_protocol_template): Build new field entries.
(generate_v2_meth_descriptor_table): Adjust to allow recording all
method types.
(generate_v2_meth_type_list): New.
(build_v2_protocol_initializer): Initialize the additional fields.
(generate_v2_protocols): Record method types for all entries and
generate the additional method type table.

4 years agoDaily bump.
GCC Administrator [Sun, 11 Oct 2020 00:16:25 +0000 (00:16 +0000)]
Daily bump.

4 years agoFix parameter map computation in ipa-modref
Jan Hubicka [Sat, 10 Oct 2020 22:07:11 +0000 (00:07 +0200)]
Fix parameter map computation in ipa-modref

* ipa-modref.c (modref_transform): Fix parameter map computation.

4 years ago[nvptx] Replace dots in function names
Tom de Vries [Sat, 10 Oct 2020 15:22:01 +0000 (17:22 +0200)]
[nvptx] Replace dots in function names

When function splitting clones a function sinf in the host compiler, the clone
is callled sinf.part.0.  However, ptx does not allows dots in identifiers, so
we run into:
...
ptxas test.o, line 23; fatal   : Parsing error near '.part': syntax error
ptxas fatal   : Ptx assembly aborted due to errors
nvptx-as: ptxas returned 255 exit status
...

Rename such functions by replacing the dots with dollar signs.

Tested check-gcc on nvptx.

Tested libgomp on x86_64-linux with nvptx accelerator.

gcc/ChangeLog:

2020-10-10  Tom de Vries  <tdevries@suse.de>

PR target/97318
* config/nvptx/nvptx.c (nvptx_replace_dot): New function.
(write_fn_proto, write_fn_proto_from_insn, nvptx_output_call_insn):
Use nvptx_replace_dot.

4 years ago[nvptx] Factor out write_fn_proto_1
Tom de Vries [Sat, 10 Oct 2020 15:08:04 +0000 (17:08 +0200)]
[nvptx] Factor out write_fn_proto_1

Factor out write_fn_proto_1 from write_fn_proto.

Tested check-gcc on nvptx.

Tested libgomp on x86_64-linux with nvptx accelerator.

gcc/ChangeLog:

2020-10-10  Tom de Vries  <tdevries@suse.de>

* config/nvptx/nvptx.c (write_fn_proto_1): New function, factored out
of ...
(write_fn_proto): ... here.  Return void.

4 years agolibstdc++: Replace use of reserved name that clashes [PR 97362]
Jonathan Wakely [Sat, 10 Oct 2020 20:22:12 +0000 (21:22 +0100)]
libstdc++: Replace use of reserved name that clashes [PR 97362]

The name __deref is defined as a macro by Windows headers.

This renames the __deref() helper function to __ref. It doesn't actually
dereference an iterator. it just has the same type as the iterator's
reference type.

libstdc++-v3/ChangeLog:

PR libstdc++/97362
* doc/html/manual/source_code_style.html: Regenerate.
* doc/xml/manual/appendix_contributing.xml: Add __deref to
BADNAMES.
* include/debug/functions.h (_Irreflexive_checker::__deref):
Rename to __ref.
* testsuite/17_intro/badnames.cc: Check __deref.

4 years agoFix ICE in remap_arguments with removed parameters.
Jan Hubicka [Sat, 10 Oct 2020 20:16:59 +0000 (22:16 +0200)]
Fix ICE in remap_arguments with removed parameters.

* ipa-modref.c (remap_arguments): Check range in map access.

4 years agoFix modref_transform ICE with more than 32 parameters.
Jan Hubicka [Sat, 10 Oct 2020 20:01:17 +0000 (22:01 +0200)]
Fix modref_transform ICE with more than 32 parameters.

* ipa-modref.c (modref_transform): Use reserve instead of safe_grow.

4 years agoFix ipa-modref ICE with not allocated summaries.
Jan Hubicka [Sat, 10 Oct 2020 19:22:52 +0000 (21:22 +0200)]
Fix ipa-modref ICE with not allocated summaries.

* ipa-modref.c (modref_transform): Check that summaries are allocated.

4 years agoFix modref handling of parameter adjustments and jump functions.
Jan Hubicka [Sat, 10 Oct 2020 18:55:37 +0000 (20:55 +0200)]
Fix modref handling of parameter adjustments and jump functions.

* ipa-modref-tree.h (struct modref_tree): Revert prevoius change.
* ipa-modref.c (analyze_function): Dump original summary.
(modref_read): Only set IPA if streaming summary (not optimization
summary).
(remap_arguments): New function.
(modref_transform): New function.
(compute_parm_map): Fix offset calculation.
(ipa_merge_modref_summary_after_inlining): Do not merge stores when
they can be ignored.

4 years agoImprove tree-ssa-alias dump files.
Jan Hubicka [Sat, 10 Oct 2020 17:36:03 +0000 (19:36 +0200)]
Improve tree-ssa-alias dump files.

* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Improve debug dumps.
(call_may_clobber_ref_p_1): Improve debug dumps.

4 years agoObjective-C, Darwin : Pick up super refs directly.
Iain Sandoe [Tue, 6 Oct 2020 17:47:26 +0000 (18:47 +0100)]
Objective-C, Darwin : Pick up super refs directly.

The current code assumed that super refs could be computed
indirectly, i.e. that the metadata generated by the compiler
was immutable by the runtime. This does not always hold
(it depends on the NeXT runtime version).  So, compute super
refs directly.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c
(objc_get_superclass_ref_decl): Split this code out.
(next_runtime_abi_02_get_class_super_ref): Compute
super refs using the objc_get_superclass_ref_decl().
(next_runtime_abi_02_get_category_super_ref): Likewise.

4 years agoDarwin : Only emit Objective-C section switches for older linkers.
Iain Sandoe [Sat, 3 Oct 2020 12:51:29 +0000 (13:51 +0100)]
Darwin : Only emit Objective-C section switches for older linkers.

At one time, the system linkers needed to have at least a dummy
entry for every Objective-C section in use.  This removes the extra
emitted code when it is not needed by the linker.

gcc/ChangeLog:

* config/darwin.c (output_objc_section_asm_op): Avoid extra
objective-c section switches unless the linker needs them.

4 years agoObjective-C, Darwin : Update metadata section uses.
Iain Sandoe [Sat, 3 Oct 2020 12:40:03 +0000 (13:40 +0100)]
Objective-C, Darwin : Update metadata section uses.

Newer versions of ld64 are more picky about adherence to placement
rules for objective c metadata.  This adds protocol refs and uses
the ivar refs for all targets.

gcc/ChangeLog:

* config/darwin-sections.def (objc2_data_section): New.
(objc2_ivar_section): New.
* config/darwin.c (darwin_objc2_section): Act on Protocol and
ivar refs.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c
(next_runtime_abi_02_init_metadata_attributes): Make protocol
refs a distinct section.

4 years agoObjective-C, Darwin : Use special string sections for V2 NeXT runtime.
Iain Sandoe [Sat, 26 Sep 2020 09:15:28 +0000 (10:15 +0100)]
Objective-C, Darwin : Use special string sections for V2 NeXT runtime.

Newer versions of the runtime expect to find strings for class, method
and method types in set-aside sections rather than the general c_strings
one.

gcc/ChangeLog:

* config/darwin-sections.def (objc2_class_names_section,
objc2_method_names_section, objc2_method_types_section): New
* config/darwin.c (output_objc_section_asm_op): Output new
sections.  (darwin_objc2_section): Select new sections where
used.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c
(next_runtime_abi_02_init_metadata_attributes): Attach metadata
for the special string sections to class, method and method type
string sections.

4 years agoObjective-C: Addess a FIXME (NFC).
Iain Sandoe [Thu, 1 Oct 2020 09:58:58 +0000 (10:58 +0100)]
Objective-C: Addess a FIXME (NFC).

This removes references to the next runtime from the gnu runtime
implementation.

gcc/objc/ChangeLog:

* objc-gnu-runtime-abi-01.c
(build_shared_structure_initializer): Remove references to
the NeXT runtime.
(generate_static_references): Likewise.

4 years agoDarwin : Begin rework of zero-fill sections.
Iain Sandoe [Sat, 22 Aug 2020 16:40:20 +0000 (17:40 +0100)]
Darwin : Begin rework of zero-fill sections.

Much of the existing work in the Darwin BSS and common sections
was to accommodate the PowerPC section anchors.  We want to segregate
this, since it might become desirable to support section anchors for
arm64.

First revision (here) is to use the same section conventions as the Xcode
toochains for BSS and COMMON.

We also drop the constraint about putting small items into data/static data
that was a work-around for Java issues (irrelevant for several editions).

gcc/ChangeLog:

* config/darwin.c (darwin_emit_local_bss): Amend section names to
match system tools. (darwin_output_aligned_bss): Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/darwin-sections.c: Adjust test for renamed BSS and common
sections.  Cater for 64 and 128 bit long doubles.

4 years agox86-64: Check CMPXCHG16B for x86-64-v[234]
H.J. Lu [Fri, 9 Oct 2020 13:12:17 +0000 (06:12 -0700)]
x86-64: Check CMPXCHG16B for x86-64-v[234]

x86-64-v2 includes CMPXCHG16B.  Since -mcx16 enables CMPXCHG16B and
defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16, check it in x86-64-v[234]
tests.

PR target/97250
* gcc.target/i386/x86-64-v2.c: Verify that
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 is defined.
* gcc.target/i386/x86-64-v3.c: Likewise.
* gcc.target/i386/x86-64-v4.c: Likewise.

4 years agolibstdc++: Fix variant build on 32-bit targets [PR95904]
Ville Voutilainen [Sat, 10 Oct 2020 10:57:17 +0000 (13:57 +0300)]
libstdc++: Fix variant build on 32-bit targets [PR95904]

    libstdc++-v3/ChangeLog:

* include/std/variant (__check_visitor_result):
Use size_t for indexes.
(__check_visitor_results): Likewise.

4 years agoPR97359: Do not cache relops in GORI cache.
Aldy Hernandez [Sat, 10 Oct 2020 06:28:52 +0000 (08:28 +0200)]
PR97359: Do not cache relops in GORI cache.

logical_stmt_cache::cacheable_p() returns true for relops, but
logical_combine (which does the caching) doesn't handle them and ICEs.
This patch fixes the inconsistency by returning false for relops.

This was working before because even though logical_combine doesn't
handle relops, statements with only one SSA are handled in cache_stmt,
which seems like the only statement we've ever encountered (even through
a full Fedora build).

lhs = s_5 > 999;

However, with two SSA operands we ICE because logical_combine doesn't
handle them:

lhs = s_5 > y_8;

We can either return false for relops in cacheable_p, or fix
logical_combine to handle them.  The original idea was to only cache
ANDs and ORs, so I've done the former to unbreak trunk.

We can decide later if there was ever any benefit in caching relops.

gcc/ChangeLog:

PR tree-optimization/97359
* gimple-range-gori.cc (logical_stmt_cache::cacheable_p): Only
handle ANDs and ORs.
(gori_compute_cache::cache_stmt): Adjust comment.

gcc/testsuite/ChangeLog:

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

4 years agoDaily bump.
GCC Administrator [Sat, 10 Oct 2020 00:16:26 +0000 (00:16 +0000)]
Daily bump.

4 years agolibstdc++: Diagnose visitors with different return types [PR95904]
Ville Voutilainen [Fri, 9 Oct 2020 17:47:01 +0000 (20:47 +0300)]
libstdc++: Diagnose visitors with different return types [PR95904]

libstdc++-v3/ChangeLog:

PR libstdc++/95904
* include/std/variant (__deduce_visit_result): Add a nested ::type.
(__gen_vtable_impl</*base case*/>::_S_apply):
Check the visitor return type.
(__same_types): New.
(__check_visitor_result): Likewise.
(__check_visitor_results): Likewise.
(visit(_Visitor&&, _Variants&&...)): Use __check_visitor_results
in case we're visiting just one variant.
* testsuite/20_util/variant/visit_neg.cc: Adjust.

4 years agolibstdc++: Fix incorrect results in std::seed_seq::generate [PR 97311]
Jonathan Wakely [Fri, 9 Oct 2020 15:10:31 +0000 (16:10 +0100)]
libstdc++: Fix incorrect results in std::seed_seq::generate [PR 97311]

This ensures that intermediate results are done in uint32_t values,
meeting the requirement for operations to be done modulo 2^32.

If the target doesn't define __UINT32_TYPE__ then substitute uint32_t
with a class type that uses uint_least32_t and masks the value to
UINT32_MAX.

I've also split the first loop that goes from k=0 to k<m into three
loops, for k=0, [1,s] and [s+1,m). This avoids branching for those three
cases in the body of the loop, and also avoids the concerns in PR 94823
regarding the k-1 index when k==0.

libstdc++-v3/ChangeLog:

PR libstdc++/97311
* include/bits/random.tcc (seed_seq::generate): Use uint32_t for
calculations. Also split the first loop into three loops to
avoid branching on k on every iteration, resolving PR 94823.
* testsuite/26_numerics/random/seed_seq/97311.cc: New test.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-erro
line number.

4 years agoDon't keep strict_low_part in reloads for non-registers. [PR97313]
Vladimir N. Makarov [Fri, 9 Oct 2020 14:01:13 +0000 (10:01 -0400)]
Don't keep strict_low_part in reloads for non-registers. [PR97313]

gcc/ChangeLog:

2020-10-09  Vladimir Makarov  <vmakarov@redhat.com>

PR rtl-optimization/97313
* lra-constraints.c (match_reload): Don't keep strict_low_part in
reloads for non-registers.

gcc/testsuite/ChangeLog:

2020-10-09  Vladimir Makarov  <vmakarov@redhat.com>

PR rtl-optimization/97313
* gcc.target/i386/pr97313.c: New.

4 years agolibstdc++: Optimize uniform_int_distribution using Lemire's algorithm
Daniel Lemire [Fri, 9 Oct 2020 13:09:36 +0000 (14:09 +0100)]
libstdc++: Optimize uniform_int_distribution using Lemire's algorithm

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/uniform_int_dist.h (uniform_int_distribution::_S_nd):
New member function implementing Lemire's "nearly divisionless"
algorithm.
(uniform_int_distribution::operator()): Use _S_nd when the range
of the URBG is the full width of the result type.

4 years agolibstdc++: Adjust variable export in makefile
Jonathan Wakely [Fri, 9 Oct 2020 13:07:22 +0000 (14:07 +0100)]
libstdc++: Adjust variable export in makefile

We usually export variables in recipes this way. I'm not sure it's
necessary, but it's consistent.

libstdc++-v3/ChangeLog:

* testsuite/Makefile.am: Set and export variable separately.
* testsuite/Makefile.in: Regenerate.

4 years agolibstdc++: Pass CXXFLAGS to check_performance script
Jonathan Wakely [Fri, 9 Oct 2020 12:59:27 +0000 (13:59 +0100)]
libstdc++: Pass CXXFLAGS to check_performance script

It looks like our check-performance target runs completely unoptimized,
which is a bit silly. This exports the CXXFLAGS from the parent make
process to the check_performance script.

libstdc++-v3/ChangeLog:

* scripts/check_performance: Use gnu++11 instead of gnu++0x.
* testsuite/Makefile.am (check-performance): Export CXXFLAGS to
child process.
* testsuite/Makefile.in: Regenerate.

4 years agolibstdc++: Add performance test for <random>
Jonathan Wakely [Fri, 9 Oct 2020 11:07:36 +0000 (12:07 +0100)]
libstdc++: Add performance test for <random>

This tests std::uniform_int_distribution with various parameters and
engines.

libstdc++-v3/ChangeLog:

* testsuite/performance/26_numerics/random_dist.cc: New test.

4 years agox86: Add <x86gprintrin.h>
H.J. Lu [Mon, 21 Sep 2020 19:17:01 +0000 (12:17 -0700)]
x86: Add <x86gprintrin.h>

For sources which can't use any vector instructions, <x86intrin.h> and
<immintrin.h> cannot be included for compiler intrinsics:

$ echo "#include <x86intrin.h>" | gcc -S -O2 -mno-sse -mno-mmx -x c -
In file included from /usr/include/stdlib.h:1013,
                 from /usr/lib/gcc/x86_64-redhat-linux/10/include/mm_malloc.h:27,
                 from /usr/lib/gcc/x86_64-redhat-linux/10/include/xmmintrin.h:34,
                 from /usr/lib/gcc/x86_64-redhat-linux/10/include/immintrin.h:29,
                 from /usr/lib/gcc/x86_64-redhat-linux/10/include/x86intrin.h:32,
                 from <stdin>:1:
/usr/include/bits/stdlib-float.h: In function ‘atof’:
/usr/include/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
$

libgcc/config/i386/shadow-stack-unwind.h has a workaround:

/* NB: We need _get_ssp and _inc_ssp from <cetintrin.h>.  But we can't
   include <x86intrin.h> which ends up including <mm_malloc.h>, which
   includes <stdlib.h> and <errno.h> unconditionally.  But we can't
   include any libc system headers unconditionally from libgcc.  Avoid
   including <mm_malloc.h> here by defining _IMMINTRIN_H_INCLUDED.  */
 #define _IMMINTRIN_H_INCLUDED
 #include <cetintrin.h>
 #undef _IMMINTRIN_H_INCLUDED

Add a standalone intrinsic header file, <x86gprintrin.h>, to provide
integer only intrinsics.  All integer only intrinsics are placed in
<x86gprintrin.h>.  <x86intrin.h> and <immintrin.h> simply include
<x86gprintrin.h>.

gcc/

PR target/97148
* config.gcc (extra_headers): Add x86gprintrin.h.
* config/i386/adxintrin.h: Check _X86GPRINTRIN_H_INCLUDED for
<x86gprintrin.h>.
* config/i386/bmi2intrin.h: Likewise.
* config/i386/bmiintrin.h: Likewise.
* config/i386/cetintrin.h: Likewise.
* config/i386/cldemoteintrin.h: Likewise.
* config/i386/clflushoptintrin.h: Likewise.
* config/i386/clwbintrin.h: Likewise.
* config/i386/enqcmdintrin.h: Likewise.
* config/i386/fxsrintrin.h: Likewise.
* config/i386/ia32intrin.h: Likewise.
* config/i386/lwpintrin.h: Likewise.
* config/i386/lzcntintrin.h: Likewise.
* config/i386/movdirintrin.h: Likewise.
* config/i386/pconfigintrin.h: Likewise.
* config/i386/pkuintrin.h: Likewise.
* config/i386/rdseedintrin.h: Likewise.
* config/i386/rtmintrin.h: Likewise.
* config/i386/serializeintrin.h: Likewise.
* config/i386/tbmintrin.h: Likewise.
* config/i386/tsxldtrkintrin.h: Likewise.
* config/i386/waitpkgintrin.h: Likewise.
* config/i386/wbnoinvdintrin.h: Likewise.
* config/i386/xsavecintrin.h: Likewise.
* config/i386/xsaveintrin.h: Likewise.
* config/i386/xsaveoptintrin.h: Likewise.
* config/i386/xsavesintrin.h: Likewise.
* config/i386/xtestintrin.h: Likewise.
* config/i386/immintrin.h: Include <x86gprintrin.h> instead of
<fxsrintrin.h>, <xsaveintrin.h>, <xsaveoptintrin.h>,
<xsavesintrin.h>, <xsavecintrin.h>, <lzcntintrin.h>,
<bmiintrin.h>, <bmi2intrin.h>, <xtestintrin.h>, <cetintrin.h>,
<movdirintrin.h>, <sgxintrin.h, <pconfigintrin.h>,
<waitpkgintrin.h>, <cldemoteintrin.h>, <enqcmdintrin.h>,
<serializeintrin.h>, <tsxldtrkintrin.h>, <adxintrin.h>,
<clwbintrin.h>, <clflushoptintrin.h>, <wbnoinvdintrin.h> and
<pkuintrin.h>.
(_wbinvd): Moved to config/i386/x86gprintrin.h.
(_rdrand16_step): Likewise.
(_rdrand32_step): Likewise.
(_rdpid_u32): Likewise.
(_readfsbase_u32): Likewise.
(_readfsbase_u64): Likewise.
(_readgsbase_u32): Likewise.
(_readgsbase_u64): Likewise.
(_writefsbase_u32): Likewise.
(_writefsbase_u64): Likewise.
(_writegsbase_u32): Likewise.
(_writegsbase_u64): Likewise.
(_rdrand64_step): Likewise.
(_ptwrite64): Likewise.
(_ptwrite32): Likewise.
* config/i386/x86gprintrin.h: New file.
* config/i386/x86intrin.h: Include <x86gprintrin.h>.  Don't
include <ia32intrin.h>, <lwpintrin.h>, <tbmintrin.h>,
<popcntintrin.h>, <mwaitxintrin.h> and <clzerointrin.h>.

gcc/testsuite/

* gcc.target/i386/avx-1.c (__builtin_ia32_lwpval32): New to
support <lwpintrin.h> included in <x86gprintrin.h>.
(__builtin_ia32_lwpval64): Likewise.
(__builtin_ia32_lwpins32): Likewise.
(__builtin_ia32_lwpins64): Likewise.
(__builtin_ia32_bextri_u32): New to support <tbmintrin.h>
included in <x86gprintrin.h>.
(__builtin_ia32_bextri_u64): Likewise.
* gcc.target/i386/x86gprintrin-1.c: New test.
* gcc.target/i386/x86gprintrin-2.c: Likewise.
* gcc.target/i386/x86gprintrin-3.c: Likewise.
* gcc.target/i386/x86gprintrin-4.c: Likewise.
* gcc.target/i386/x86gprintrin-4a.c: Likewise.
* gcc.target/i386/x86gprintrin-5.c: Likewise.
* gcc.target/i386/x86gprintrin-5a.c: Likewise.
* gcc.target/i386/x86gprintrin-5b.c: Likewise.
* gcc.target/i386/x86gprintrin-6.c: Likewise.

libgcc/

PR target/97148
* config/i386/shadow-stack-unwind.h: Include <x86gprintrin.h>
instead of <cetintrin.h>.

4 years ago[nvptx] Set -misa=sm_35 by default
Tom de Vries [Fri, 9 Oct 2020 09:36:10 +0000 (11:36 +0200)]
[nvptx] Set -misa=sm_35 by default

The nvptx-as assembler verifies the ptx code using ptxas, if there's any
in the PATH.

The default in the nvptx port for -misa=sm_xx is sm_30, but the ptxas of the
latest cuda release (11.1) no longer supports sm_30.

Consequently we cannot build gcc against that release (although we should
still be able to build without any cuda release).

Fix this by setting -misa=sm_35 by default.

Tested check-gcc on nvptx.

Tested libgomp on x86_64-linux with nvpx accelerator.

Both build again cuda 9.1.

gcc/ChangeLog:

2020-10-09  Tom de Vries  <tdevries@suse.de>

PR target/97348
* config/nvptx/nvptx.h (ASM_SPEC): Also pass -m to nvptx-as if
default is used.
* config/nvptx/nvptx.opt (misa): Init with PTX_ISA_SM35.

4 years agoFixup gcc.dg/vect/pr65947-3.c when masked loads are available
Richard Biener [Fri, 9 Oct 2020 11:15:42 +0000 (13:15 +0200)]
Fixup gcc.dg/vect/pr65947-3.c when masked loads are available

The following adds a effective target to properly allow
the gcc.dg/vect/pr65947-3.c expected vectorization to be adjusted
when run with, say, -march=cascadelake.

2020-10-09  Richard Biener  <rguenther@suse.de>

gcc/
* doc/sourcebuild.texi (vect_masked_load): Document.

gcc/testsuite
* lib/target-supports.exp (check_effective_target_vect_masked_load):
New effective target.
* gcc.dg/vect/pr65947-3.c: Update.

4 years agotree-optimization/97334 - improve BB SLP discovery
Richard Biener [Fri, 9 Oct 2020 10:24:46 +0000 (12:24 +0200)]
tree-optimization/97334 - improve BB SLP discovery

We're running into a multiplication with one unvectorizable
operand we expect to build from scalars but SLP discovery
fatally fails the build of both since one stmt is commutated:

  _60 = _58 * _59;
  _63 = _59 * _62;
  _66 = _59 * _65;
...

where _59 is the "bad" operand.  The following patch makes the
case work where the first stmt has a good operand by not fatally
failing the SLP build for the operand but communicating upwards
how to commutate.

2020-10-09  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97334
* tree-vect-slp.c (vect_build_slp_tree_1): Do not fatally
fail lanes other than zero when BB vectorizing.

* gcc.dg/vect/bb-slp-pr65935.c: Amend.

4 years agolibstdc++: Fix unused variable warning
Jonathan Wakely [Fri, 9 Oct 2020 10:52:56 +0000 (11:52 +0100)]
libstdc++: Fix unused variable warning

libstdc++-v3/ChangeLog:

* testsuite/util/testsuite_performance.h (report_header): Remove
unused variable.

4 years agoIPA modref: fix miscompilation in clone when IPA modref is used
Jan Hubicka [Fri, 9 Oct 2020 09:29:58 +0000 (11:29 +0200)]
IPA modref: fix miscompilation in clone when IPA modref is used

gcc/ChangeLog:

PR ipa/97292
PR ipa/97335
* ipa-modref-tree.h (copy_from): Drop summary in a
clone.

4 years agotree-optimization/97347 - fix another SLP constant insertion issue
Richard Biener [Fri, 9 Oct 2020 08:19:38 +0000 (10:19 +0200)]
tree-optimization/97347 - fix another SLP constant insertion issue

Just use edge insertion which will appropriately handle the situation
from botan.

2020-10-09  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97347
* tree-vect-slp.c (vect_create_constant_vectors): Use
edge insertion when inserting on the fallthru edge,
appropriately insert at the start of BBs when inserting
after PHIs.

* g++.dg/vect/pr97347.cc: New testcase.

4 years agoFix for PR97317.
Andrew MacLeod [Fri, 9 Oct 2020 08:46:50 +0000 (10:46 +0200)]
Fix for PR97317.

gcc/ChangeLog:

PR tree-optimization/97317
* range-op.cc (operator_cast::op1_range): Handle casts where the precision
of the RHS is only 1 greater than the precision of the LHS.

gcc/testsuite/ChangeLog:
* gcc.dg/pr97317.c: New test.

4 years agorandom memory leak fixes
Richard Biener [Fri, 9 Oct 2020 07:47:44 +0000 (09:47 +0200)]
random memory leak fixes

This fixes leaks discovered checking whether I introduced new ones
with the last vectorizer changes.

2020-10-09  Richard Biener  <rguenther@suse.de>

* cgraphunit.c (expand_all_functions): Free tp_first_run_order.
* ipa-modref.c (pass_ipa_modref::execute): Free order.
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations): Free
loop body.
* tree-vect-data-refs.c (vect_find_stmt_data_reference): Free
data references upon failure.
* tree-vect-loop.c (update_epilogue_loop_vinfo): Free BBs
array of the original loop.
* tree-vect-slp.c (vect_slp_bbs): Use an auto_vec for
dataref_groups to release its memory.

4 years agovrp: Fix up gcc.target/aarch64/pr90838.c [PR97312, PR94801]
Jakub Jelinek [Fri, 9 Oct 2020 08:19:16 +0000 (10:19 +0200)]
vrp: Fix up gcc.target/aarch64/pr90838.c [PR97312, PR94801]

> Perhaps another way out of this would be document and enforce that
> __builtin_c[lt]z{,l,ll} etc calls are undefined at zero, but C[TL]Z ifn
> calls are defined there based on *_DEFINED_VALUE_AT_ZERO (*) == 2

The following patch implements that, i.e. __builtin_c?z* now take full
advantage of them being UB at zero, while the ifns are well defined at zero
if *_DEFINED_VALUE_AT_ZERO (*) == 2.  That is what fixes PR94801.

Furthermore, to fix PR97312, if it is well defined at zero and the value at
zero is prec, we don't lower the maximum unless the argument is known to be
non-zero.
For gimple-range.cc I guess we could improve it if needed e.g. by returning
a [0,7][32,32] range for .CTZ of e.g. [0,137], but for now it (roughly)
matches what vr-values.c does.

2020-10-09  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/94801
PR target/97312
* vr-values.c (vr_values::extract_range_basic) <CASE_CFN_CLZ,
CASE_CFN_CTZ>: When stmt is not an internal-fn call or
C?Z_DEFINED_VALUE_AT_ZERO is not 2, assume argument is not zero
and thus use [0, prec-1] range unless it can be further improved.
For CTZ, don't update maxi from upper bound if it was previously prec.
* gimple-range.cc (gimple_ranger::range_of_builtin_call) <CASE_CFN_CLZ,
CASE_CFN_CTZ>: Likewise.

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

4 years agomatch.pd: Fix up FFS -> CTZ + 1 optimization [PR97325]
Jakub Jelinek [Fri, 9 Oct 2020 08:16:57 +0000 (10:16 +0200)]
match.pd: Fix up FFS -> CTZ + 1 optimization [PR97325]

And no testcase was included, I'm including one below.

Anyway, this PR and the other CTZ related discussions led me to discover a
bug I've made earlier, CLZ/CTZ builtins have unsigned arguments and e.g.
both the vr-values.cc and now gimple-range.cc code heavily relies on that,
but __builtin_ffs has a signed operand and this optimization was incorrectly
making the operand signed too, so I guess it would greatly confuse VRP in
some cases.

2020-10-09  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/97325
* match.pd (FFS(nonzero) -> CTZ(nonzero) + 1): Cast argument to
corresponding unsigned type.

* gcc.c-torture/execute/pr97325.c: New test.

4 years agoMove pr97315-1.c test to g++.dg/opt/.
Aldy Hernandez [Fri, 9 Oct 2020 07:31:47 +0000 (09:31 +0200)]
Move pr97315-1.c test to g++.dg/opt/.

gcc/testsuite/ChangeLog:

PR testsuite/97337
* gcc.dg/pr97315-1.c: Moved to...
* g++.dg/opt/pr97315-1.C: ...here.

4 years agofix ICE with BB vectorization of PHIs
Richard Biener [Fri, 9 Oct 2020 06:56:21 +0000 (08:56 +0200)]
fix ICE with BB vectorization of PHIs

This fixes a vector CTOR insertion issue when we try to insert after
a PHI node.

2020-10-09  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (vect_create_constant_vectors): Properly insert
after PHIs.

* gcc.dg/vect/bb-slp-phis-1.c: New testcase.

4 years agoDaily bump.
GCC Administrator [Fri, 9 Oct 2020 00:16:27 +0000 (00:16 +0000)]
Daily bump.

4 years agolibstdc++: Make ranges::construct_at constexpr-friendly [PR95788]
Patrick Palka [Thu, 8 Oct 2020 22:10:05 +0000 (18:10 -0400)]
libstdc++: Make ranges::construct_at constexpr-friendly [PR95788]

This rewrites ranges::construct_at in terms of std::construct_at so
that we can piggyback on the compiler's existing support for
intercepting placement new within std::construct_at during constexpr
evaluation, instead of having to additionally teach the compiler about
ranges::construct_at.

While we're making changes to ranges::construct_at, this patch also
declares it conditionally noexcept and qualifies the calls to declval in
its requires-clause.

libstdc++-v3/ChangeLog:

PR libstdc++/95788
* include/bits/ranges_uninitialized.h:
(__construct_at_fn::operator()): Rewrite in terms of
std::construct_at.  Declare it conditionally noexcept.  Qualify
calls to declval in its requires-clause.
* testsuite/20_util/specialized_algorithms/construct_at/95788.cc:
New test.

4 years agoc++: Fix member alias template in C++17 and up. [PR96805]
Jason Merrill [Thu, 8 Oct 2020 19:43:26 +0000 (15:43 -0400)]
c++: Fix member alias template in C++17 and up. [PR96805]

Here we're trying to push into a<T>::c<N> in order to instantiate t<N>, but
were building a TYPENAME_TYPE for it because a<T> isn't open yet.  Don't
do that when we know we're trying to enter the scope.

gcc/cp/ChangeLog:

PR c++/96805
PR c++/96199
* pt.c (tsubst_aggr_type): Don't build a TYPENAME_TYPE when
entering_scope.
(tsubst_template_decl): Use tsubst_aggr_type.

gcc/testsuite/ChangeLog:

PR c++/96805
* g++.dg/cpp0x/alias-decl-pr96805.C: New test.

4 years agotake type from intrinsic in sincos pass
Alexandre Oliva [Thu, 8 Oct 2020 20:12:18 +0000 (17:12 -0300)]
take type from intrinsic in sincos pass

This is a first step towards enabling the sincos optimization in Ada.

The issue this patch solves is that sincos takes the type to be looked
up with mathfn_built_in from variables or temporaries passed as
arguments to SIN and COS intrinsics.  In Ada, different float types
may be used but, despite their representation equivalence, their
distinctness causes the optimization to be skipped, because they are
not the types that mathfn_built_in expects.

This patch introduces a function that maps intrinsics to the type
they're associated with, and uses that type, obtained from the
intrinsics used in calls to be optimized, to look up the correspoding
CEXPI intrinsic.

For the sake of defensive programming, when using the type obtained
from the intrinsic, it now checks that, if different types are found
for the used argument, or for other calls that use it, that the types
are interchangeable.

for  gcc/ChangeLog

* builtins.c (mathfn_built_in_type): New.
* builtins.h (mathfn_built_in_type): Declare.
* tree-ssa-math-opts.c (execute_cse_sincos_1): Use it to
obtain the type expected by the intrinsic.

4 years agolibcpp: Directly peek for initial line marker
Nathan Sidwell [Thu, 8 Oct 2020 19:11:37 +0000 (12:11 -0700)]
libcpp: Directly peek for initial line marker

Using the tokenizer to sniff for an initial line marker for
preprocessed input is a little brittle, particularly with
-fdirectives-only.  If there is no marker we'll happily munch initial
comments.  This patch directly sniffs the buffer.  This is safe
because the initial line marker was machine generated and must be
right at the beginning of the file.  Anything else is not such a line
marker.  The same is true for the initial directory marker.  For that
tokenizing the string is simplest, but at that point it's either a
regular line marker or a directory marker.  If it's a regular marker,
unwinding tokens is fine.

libcpp/
* internal.h (enum include_type): Rename IT_MAIN_INJECT to
IT_PRE_MAIN.
* init.c (cpp_read_main_file): If there is no line marker, adjust
the initial line marker.
(read_original_filename): Return bool, peek the buffer directly
before trying to tokenize.
(read_original_directory): Likewise.  Directly prod the string
literal.
* files.c (_cpp_stack_file): Adjust for IT_PRE_MAIN change.

4 years ago[PATCH, rs6000] Rename BU_P10_MISC_2 define to BU_P10_POWERPC64_MISC_2
Will Schmidt [Mon, 21 Sep 2020 19:26:43 +0000 (14:26 -0500)]
[PATCH, rs6000] Rename BU_P10_MISC_2 define to BU_P10_POWERPC64_MISC_2

Rename our BU_P10_MISC_2 built-in define macro to be
BU_P10_POWERPC64_MISC_2.   This more accurately reflects
that the macro includes the RS6000_BTM_POWERPC64 entry,
and matches the style we used for the P7 equivalent.

gcc/ChangeLog:
* config/rs6000/rs6000-builtin.def (BU_P10_MISC_2): Rename
to BU_P10_POWERPC64_MISC_2.
CFUGED, CNTLZDM, CNTTZDM, PDEPD, PEXTD): Call renamed macro.

4 years agoDisable TBAA in some uses of call_may_clobber_ref_p
Jan Hubicka [Thu, 8 Oct 2020 15:15:58 +0000 (17:15 +0200)]
Disable TBAA in some uses of call_may_clobber_ref_p

* tree-nrv.c (dest_safe_for_nrv_p): Disable tbaa in
call_may_clobber_ref_p and ref_maybe_used_by_stmt_p.
* tree-tailcall.c (find_tail_calls): Likewise.
* tree-ssa-alias.c (call_may_clobber_ref_p): Add tbaa_p parameter.
* tree-ssa-alias.h (call_may_clobber_ref_p): Update prototype.
* tree-ssa-sccvn.c (vn_reference_lookup_3): Pass data->tbaa_p
to call_may_clobber_ref_p_1.

4 years agodebug: Make sure to output .file 0 when generating DWARF5.
Mark Wielaard [Tue, 6 Oct 2020 15:41:19 +0000 (17:41 +0200)]
debug: Make sure to output .file 0 when generating DWARF5.

When gas outputs DWARF5 .debug_line[_str] then we have to tell it the
comp_dir and main file name for the zero entry line table. Otherwise
gas has to guess at the CU compilation directory and file.

Before a gcc -gdwarf-5 ../src/hello.c line table looked like:

Directory table:
 0     ../src (24)
 1     ../src (24)
 2     /usr/include (31)

File name table:
 0     hello.c (16),  0
 1     hello.c (16),  1
 2     stdio.h (44),  2

With this patch it looks like:

Directory table:
 0     /tmp/obj (0)
 1     ../src (24)
 2     /usr/include (31)

File name table:
 0     ../src/hello.c (9),  0
 1     hello.c (16),  1
 2     stdio.h (44),  2

gcc/ChangeLog:

* dwarf2out.c (dwarf2out_finish): Emit .file 0 entry when
generating DWARF5 .debug_line table through gas.

4 years agoImprove documentation of -fallow-store-data-races
qing zhao [Thu, 8 Oct 2020 15:01:07 +0000 (17:01 +0200)]
Improve documentation of -fallow-store-data-races

2020-10-08  John Henning  <john.henning@oracle.com>

gcc/

PR other/97309
* doc/invoke.texi: Improve documentation of
-fallow-store-data-races.