platform/upstream/gcc.git
3 years agolibstdc++: Fix division by zero in std::sample
Patrick Palka [Tue, 22 Sep 2020 00:48:23 +0000 (20:48 -0400)]
libstdc++: Fix division by zero in std::sample

This fixes a division by zero in the selection-sampling std::__sample
overload when the input range is empty (and hence __unsampled_sz is 0).

libstdc++-v3/ChangeLog:

* include/bits/stl_algo.h (__sample): Exit early when the
input range is empty.
* testsuite/25_algorithms/sample/3.cc: New test.

3 years agolibstdc++: Mark some more algorithms constexpr for C++20
Patrick Palka [Tue, 22 Sep 2020 00:48:17 +0000 (20:48 -0400)]
libstdc++: Mark some more algorithms constexpr for C++20

As per P0202.

libstdc++-v3/ChangeLog:

* include/bits/stl_algo.h (for_each_n): Mark constexpr for C++20.
(search): Likewise for the overload that takes a searcher.
* testsuite/25_algorithms/for_each/constexpr.cc: Test constexpr
std::for_each_n.
* testsuite/25_algorithms/search/constexpr.cc: Test constexpr
std::search overload that takes a searcher.

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

3 years agocompiler: finalize methods for type aliases of struct types
Ian Lance Taylor [Fri, 28 Aug 2020 05:18:45 +0000 (22:18 -0700)]
compiler: finalize methods for type aliases of struct types

Previously we would finalize the methods of the alias type itself, but
since its a type alias we really need to finalize the methods of the
aliased type.

Also, handle method expressions of unnamed struct types.

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

Fixes golang/go#38125

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

3 years agoanalyzer: fix ICE on bogus decl of memset [PR97130]
David Malcolm [Mon, 21 Sep 2020 15:59:26 +0000 (11:59 -0400)]
analyzer: fix ICE on bogus decl of memset [PR97130]

Verify that arguments are pointers before calling handling code
that calls deref_rvalue on them.

gcc/analyzer/ChangeLog:
PR analyzer/97130
* region-model-impl-calls.cc (call_details::get_arg_type): New.
* region-model.cc (region_model::on_call_pre): Check that the
initial arg is a pointer before calling impl_call_memset and
impl_call_strlen.
* region-model.h (call_details::get_arg_type): New decl.

gcc/testsuite/ChangeLog:
PR analyzer/97130
* gcc.dg/analyzer/pr97130.c: New test.

3 years agoanalyzer: decls are not on the heap
David Malcolm [Fri, 18 Sep 2020 21:34:50 +0000 (17:34 -0400)]
analyzer: decls are not on the heap

Whilst debugging the remaining state explosion in PR analyzer/93355
I noticed that half of the states at an exploding program point had:
  'malloc': {'&buf': 'non-heap'}
whereas the other half didn't, presumably depending on whether the path
to each enode had used this local buffer:
  char buf[400];

This patch tweaks malloc_state_machine::get_default_state to be smarter
about this, so that we can implicitly treat pointers to decls as
non-heap, preventing pointless differences between sm_state_map
instances.  With that, all of the states in question have equal (empty)
malloc sm-state - though the state explosion continues for other reasons.

gcc/analyzer/ChangeLog:
PR analyzer/93355
* sm-malloc.cc (malloc_state_machine::get_default_state): Look at
the base region when considering pointers.  Treat pointers to
decls as being non-heap.

3 years agolibstdc++: Use __builtin_expect in __glibcxx_assert
Jonathan Wakely [Mon, 21 Sep 2020 22:43:25 +0000 (23:43 +0100)]
libstdc++: Use __builtin_expect in __glibcxx_assert

libstdc++-v3/ChangeLog:

* include/bits/c++config (__replacement_assert): Add noreturn
attribute.
(__glibcxx_assert_impl): Use __builtin_expect to hint that the
assertion is expected to pass.

3 years agolibstdc++: Fix constraints for drop_view::begin() const [LWG 3482]
Jonathan Wakely [Mon, 21 Sep 2020 22:43:25 +0000 (23:43 +0100)]
libstdc++: Fix constraints for drop_view::begin() const [LWG 3482]

libstdc++-v3/ChangeLog:

* include/std/ranges (drop_view::begin()): Adjust constraints
to match the correct condition for O(1) ranges::next (LWG 3482).
* testsuite/std/ranges/adaptors/drop.cc: Check that iterator is
cached for non-sized_range.

3 years agogo/internal/gccgoimporter: recognize aixbigafMagic archives
Clément Chigot [Wed, 16 Sep 2020 11:58:17 +0000 (13:58 +0200)]
go/internal/gccgoimporter: recognize aixbigafMagic archives

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

3 years agoc++: DR 1722: Make lambda to function pointer conv noexcept [PR90583]
Marek Polacek [Mon, 21 Sep 2020 17:24:25 +0000 (13:24 -0400)]
c++: DR 1722: Make lambda to function pointer conv noexcept [PR90583]

DR 1722 clarifies that the conversion function from lambda to pointer to
function should be noexcept(true).

gcc/cp/ChangeLog:

PR c++/90583
DR 1722
* lambda.c (maybe_add_lambda_conv_op): Mark the conversion function
as noexcept.

gcc/testsuite/ChangeLog:

PR c++/90583
DR 1722
* g++.dg/cpp0x/lambda/lambda-conv14.C: New test.

3 years agoc++: Implement -Wctad-maybe-unsupported.
Marek Polacek [Sat, 19 Sep 2020 20:17:42 +0000 (16:17 -0400)]
c++: Implement -Wctad-maybe-unsupported.

I noticed that clang++ has this CTAD warning and thought that it might
be useful to have it.  From clang++: "Some style guides want to allow
using CTAD only on types that "opt-in"; i.e. on types that are designed
to support it and not just types that *happen* to work with it."

So this warning warns when CTAD deduced a type, but the type does not
define any deduction guides.  In that case CTAD worked only because the
compiler synthesized the implicit deduction guides.  That might not be
intended.

It can be suppressed by adding a deduction guide that will never be
considered:

  struct allow_ctad_t;
  template <typename T> struct S { S(T) {} };
  S(allow_ctad_t) -> S<void>;

This warning is off by default.  It doesn't warn when the type comes
from a system header unless -Wsystem-headers.

gcc/c-family/ChangeLog:

* c.opt (Wctad-maybe-unsupported): New option.

gcc/cp/ChangeLog:

* pt.c (deduction_guides_for): Add a bool parameter.  Set it.
(do_class_deduction): Warn when CTAD succeeds but the type doesn't
have any explicit deduction guides.

gcc/ChangeLog:

* doc/invoke.texi: Document -Wctad-maybe-unsupported.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wctad-maybe-unsupported.C: New test.
* g++.dg/warn/Wctad-maybe-unsupported2.C: New test.
* g++.dg/warn/Wctad-maybe-unsupported3.C: New test.
* g++.dg/warn/Wctad-maybe-unsupported.h: New file.

3 years agolibgo: don't put golang.org packages in zstdpkglist.go
Ian Lance Taylor [Mon, 21 Sep 2020 19:45:43 +0000 (12:45 -0700)]
libgo: don't put golang.org packages in zstdpkglist.go

This ensures that internal/goroot.IsStandardPackage does not treat
golang.org packages as being in the standard library.

For golang/go#41368
Fixes golang/go#41499

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

3 years agoAvoid incidental failures due to implicit attribute access.
Martin Sebor [Mon, 21 Sep 2020 20:33:29 +0000 (14:33 -0600)]
Avoid incidental failures due to implicit attribute access.

gcc/testsuite/ChangeLog:

PR c/50584
* gcc.dg/ipa/ipa-sra-1.c: Use a plain pointer for argv instead of array.
* gcc.dg/ipa/ipa-sra-12.c: Same.
* gcc.dg/ipa/ipa-sra-13.c: Same.
* gcc.dg/ipa/ipa-sra-14.c: Same.
* gcc.dg/ipa/ipa-sra-15.c: Same.

3 years agoPR fortran/90903 [part2] - Add runtime checking for the MVBITS intrinsic
Harald Anlauf [Mon, 21 Sep 2020 19:50:36 +0000 (21:50 +0200)]
PR fortran/90903 [part2] - Add runtime checking for the MVBITS intrinsic

Implement inline expansion of the intrinsic elemental subroutine MVBITS
with optional runtime checks for valid argument range.

gcc/fortran/ChangeLog:

* iresolve.c (gfc_resolve_mvbits): Remove unneeded conversion of
FROMPOS, LEN and TOPOS arguments to fit a C int.
* trans-intrinsic.c (gfc_conv_intrinsic_mvbits): Add inline
expansion of MVBITS intrinsic elemental subroutine and add code
for runtime argument checking.
(gfc_conv_intrinsic_subroutine): Recognise MVBITS intrinsic, but
defer handling to gfc_trans_call.
* trans-stmt.c (replace_ss):
(gfc_trans_call): Adjust to handle inline expansion, scalarization
of intrinsic subroutine MVBITS in gfc_conv_intrinsic_mvbits.
* trans.h (gfc_conv_intrinsic_mvbits): Add prototype for
gfc_conv_intrinsic_mvbits.

gcc/testsuite/ChangeLog:

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

Co-authored-by: Paul Thomas <pault@gcc.gnu.org>
3 years agolibsanitizer: rename new libbacktrace symbols
Ian Lance Taylor [Mon, 21 Sep 2020 19:02:59 +0000 (12:02 -0700)]
libsanitizer: rename new libbacktrace symbols

* libbacktrace/backtrace-rename.h (backtrace_uncompress_lzma):
Define.
(backtrace_syminfo_to_full_callback): Define.
(backtrace_syminfo_to_full_error_callback): Define.

3 years agoc++: ts_lambda is not needed
Nathan Sidwell [Mon, 21 Sep 2020 15:55:15 +0000 (08:55 -0700)]
c++: ts_lambda is not needed

We don't need ts_lambda, as IDENTIFIER_LAMBDA_P is sufficient.  Killed thusly.

gcc/cp/
* decl.c (xref_tag_1): Use IDENTIFIER_LAMBDA_P to detect lambdas.
* lambda.c (begin_lambda_type): Use ts_current to push the tag.
* name-lookup.h (enum tag_scope): Drop ts_lambda.

3 years agoDarwin, testsuite : Skip a test that requires ELF.
Iain Sandoe [Sat, 19 Sep 2020 13:35:58 +0000 (14:35 +0100)]
Darwin, testsuite : Skip a test that requires ELF.

The symver support is only available to ELF targets.

gcc/testsuite/ChangeLog:

* gcc.dg/ipa/symver1.c: Skip for Darwin.

3 years ago[arm] gcc.target/arm/cs*: Use dg-add-options arm_arch_v8_1m_main
Christophe Lyon [Mon, 21 Sep 2020 15:51:48 +0000 (15:51 +0000)]
[arm] gcc.target/arm/cs*: Use dg-add-options arm_arch_v8_1m_main

These testcases need thumb mode, which may not be the default.

Using dg-add-options arm_arch_v8_1m_main ensures that -mthumb is used
and makes the test pass in more configurations.

2020-09-21  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/testsuite/
* gcc.target/arm/csinc-1.c: Use dg-add-options
arm_arch_v8_1m_main.
* gcc.target/arm/csinv-1.c: Likewise.
* gcc.target/arm/csneg.c: Likewise.

3 years agotree-optimization/97139 - fix BB SLP live lane extraction
Richard Biener [Mon, 21 Sep 2020 14:51:33 +0000 (16:51 +0200)]
tree-optimization/97139 - fix BB SLP live lane extraction

This fixes SLP live lane extraction with pattern stmts.

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

PR tree-optimization/97139
* tree-vect-slp.c (vect_bb_slp_mark_live_stmts): Only mark the
pattern root, track visited vectorized stmts.

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

3 years agoc++: Detect deduction guide redeclaration [PR97099]
Marek Polacek [Fri, 18 Sep 2020 23:37:05 +0000 (19:37 -0400)]
c++: Detect deduction guide redeclaration [PR97099]

[temp.deduct.guide]p3: Two deduction guide declarations in the same
translation unit for the same class template shall not have equivalent
parameter-declaration-clauses.

So let's detect that.

gcc/cp/ChangeLog:

PR c++/97099
* decl.c (redeclaration_error_message): Detect a redeclaration of
deduction guides.

gcc/testsuite/ChangeLog:

PR c++/97099
* g++.dg/cpp1z/class-deduction74.C: New test.

3 years agolibstdc++: Relax constraints on transform_view and elements_view iterators
Jonathan Wakely [Mon, 21 Sep 2020 13:30:38 +0000 (14:30 +0100)]
libstdc++: Relax constraints on transform_view and elements_view iterators

libstdc++-v3/ChangeLog:

* include/std/ranges (transform_view, elements_view): Relax
constraints on operator- for iterators, as per LWG 3483.
* testsuite/std/ranges/adaptors/elements.cc: Check that we
can take the difference of two iterators from a non-random
access range.
* testsuite/std/ranges/adaptors/transform.cc: Likewise.

3 years agolibstdc++: Make std::assume_aligned a constexpr function [PR 97132]
Jonathan Wakely [Mon, 21 Sep 2020 13:28:58 +0000 (14:28 +0100)]
libstdc++: Make std::assume_aligned a constexpr function [PR 97132]

The cast from void* to T* in std::assume_aligned is not valid in a
constexpr function. The optimization hint is redundant during constant
evaluation anyway (the compiler can see the object and knows its
alignment). Simply return the original pointer without applying the
__builtin_assume_aligned hint to it when doing constant evaluation.

This change also removes the preprocessor branch that works around
uintptr_t not being available. We already assume that type is present
elsewhere in the library.

libstdc++-v3/ChangeLog:

PR libstdc++/97132
* include/bits/align.h (align) [!_GLIBCXX_USE_C99_STDINT_TR1]:
Remove unused code.
(assume_aligned): Do not use __builtin_assume_aligned during
constant evaluation.
* testsuite/20_util/assume_aligned/1.cc: Improve test.
* testsuite/20_util/assume_aligned/97132.cc: New test.

3 years agoFix fallout from Support new mallinfo2 function.
Jakub Jelinek [Mon, 21 Sep 2020 12:20:05 +0000 (14:20 +0200)]
Fix fallout from Support new mallinfo2 function.

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

* configure.ac: Use mallinfo mallinfo2 as first operand of
gcc_AC_CHECK_DECLS rather than [mallinfo, mallinfo2].
* configure: Regenerated.
* config.in: Regenerated.

3 years agoaarch64: Do not alter value on a force_reg returned rtx expanding __jcvt
Andrea Corallo [Thu, 17 Sep 2020 16:17:52 +0000 (17:17 +0100)]
aarch64: Do not alter value on a force_reg returned rtx expanding __jcvt

2020-09-17  Andrea Corallo  <andrea.corallo@arm.com>

* config/aarch64/aarch64-builtins.c
(aarch64_general_expand_builtin): Use expand machinery not to
alter the value of an rtx returned by force_reg.

3 years agotree-optimization/97135 - fix dependence check in store-motion
Richard Biener [Mon, 21 Sep 2020 12:04:25 +0000 (14:04 +0200)]
tree-optimization/97135 - fix dependence check in store-motion

The following fixes a dependence check where in the particular place
we cannot ignore self-dependences.

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

PR tree-optimization/97135
* tree-ssa-loop-im.c (sm_seq_push_down): Do not ignore
self-dependences.

* gcc.dg/torture/pr97135.c: New testcase.

3 years agoFix ICE in tree-switch-conversion.
Martin Liska [Mon, 21 Sep 2020 10:50:37 +0000 (12:50 +0200)]
Fix ICE in tree-switch-conversion.

With SVE we can end up with:
switch (POLY_INT_CST [2, 2]) <default: <L2> [INV], case 2: <L3> [INV], case 4: <L3> [INV]>
which is fine to expand and we can remove the assert.

gcc/ChangeLog:

PR tree-optimization/96915
* tree-switch-conversion.c (switch_conversion::expand): Accept
also integer constants.

gcc/testsuite/ChangeLog:

PR tree-optimization/96915
* gcc.target/aarch64/sve/pr96915.c: New test.

3 years agoPOLY_INT_CST: remove extra space in dump
Martin Liska [Mon, 21 Sep 2020 10:46:00 +0000 (12:46 +0200)]
POLY_INT_CST: remove extra space in dump

gcc/ChangeLog:

* print-tree.c (print_node): Remove extra space.

3 years agomklog.py: Parse first 10 lines for PR/DR number
Tobias Burnus [Mon, 21 Sep 2020 09:22:49 +0000 (11:22 +0200)]
mklog.py: Parse first 10 lines for PR/DR number

contrib/ChangeLog:

* mklog.py: Parse first 10 lines for PR/DR number
not only the first line.

3 years agoaarch64: Fix ICE on fpsr fpcr getters [PR96968]
Andrea Corallo [Mon, 14 Sep 2020 13:47:24 +0000 (14:47 +0100)]
aarch64: Fix ICE on fpsr fpcr getters [PR96968]

gcc/ChangeLog

2020-09-14  Andrea Corallo  <andrea.corallo@arm.com>

PR target/96968
* config/aarch64/aarch64-builtins.c
(aarch64_expand_fpsr_fpcr_setter): Fix comment nit.
(aarch64_expand_fpsr_fpcr_getter): New function, expand these
getters using expand_insn machinery.
(aarch64_general_expand_builtin): Make use of.

gcc/testsuite/ChangeLog

2020-09-14  Andrea Corallo  <andrea.corallo@arm.com>

PR target/96968
* gcc.target/aarch64/pr96968.c: New test.

3 years agoUse ONE_? macros.
Martin Liska [Wed, 2 Sep 2020 12:34:21 +0000 (14:34 +0200)]
Use ONE_? macros.

gcc/ChangeLog:

* ggc-common.c (ggc_rlimit_bound): Use ONE_? macro.
(ggc_min_expand_heuristic): Likewise.
(ggc_min_heapsize_heuristic): Likewise.
* ggc-page.c (ggc_collect): Likewise.
* system.h (ONE_G): Likewise.

3 years agoUse SIZE_AMOUNT macro for GGC memory allocation numbers.
Martin Liska [Wed, 2 Sep 2020 12:30:16 +0000 (14:30 +0200)]
Use SIZE_AMOUNT macro for GGC memory allocation numbers.

gcc/ChangeLog:

* ggc-common.c (ggc_prune_overhead_list): Use SIZE_AMOUNT.
* ggc-page.c (release_pages): Likewise.
(ggc_collect): Likewise.
(ggc_trim): Likewise.
(ggc_grow): Likewise.
* timevar.c (timer::print): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/timevar1.C: Prune more possible number values.
* g++.dg/ext/timevar2.C: Likewise.

3 years agoSupport new mallinfo2 function.
Martin Liska [Tue, 1 Sep 2020 12:14:45 +0000 (14:14 +0200)]
Support new mallinfo2 function.

gcc/ChangeLog:

* config.in: Regenerate.
* configure: Likewise.
* configure.ac: Detect for mallinfo2.
* ggc-common.c (defined): Use it.
* system.h: Handle also HAVE_MALLINFO2.

3 years agoDaily bump.
GCC Administrator [Mon, 21 Sep 2020 00:16:24 +0000 (00:16 +0000)]
Daily bump.

3 years agolibstdc++: Fix noexcept-specifier for std::bind_front [PR 97101]
Jonathan Wakely [Sun, 20 Sep 2020 23:17:02 +0000 (00:17 +0100)]
libstdc++: Fix noexcept-specifier for std::bind_front [PR 97101]

libstdc++-v3/ChangeLog:

PR libstdc++/97101
* include/std/functional (bind_front): Fix order of parameters
in is_nothrow_constructible_v specialization.
* testsuite/20_util/function_objects/bind_front/97101.cc: New test.

3 years agoFix linkage with -nodefaultlibs option.
John David Anglin [Sun, 20 Sep 2020 19:37:17 +0000 (19:37 +0000)]
Fix linkage with -nodefaultlibs option.

2020-09-20  John David Anglin  < danglin@gcc.gnu.org>

gcc/ChangeLog
* config/pa/pa-hpux11.h (LINK_GCC_C_SEQUENCE_SPEC): Delete.
* config/pa/pa64-hpux.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise.
(ENDFILE_SPEC): Link with libgcc_stub.a and mill.a.
* config/pa/pa32-linux.h (ENDFILE_SPEC): Link with libgcc.a.

3 years agoc++: Add test for PR90199.
Marek Polacek [Sun, 20 Sep 2020 19:25:55 +0000 (15:25 -0400)]
c++: Add test for PR90199.

Fixed by r11-2998, which fixed this ICE too.

gcc/testsuite/ChangeLog:

PR c++/90199
* g++.dg/cpp1y/constexpr-90199.C: New test.

3 years agoFix ICE during dumping in ipa-modref.
Jan Hubicka [Sun, 20 Sep 2020 06:19:56 +0000 (08:19 +0200)]
Fix ICE during dumping in ipa-modref.

2020-09-20  Jan Hubicka  <hubicka@ucw.cz>

* ipa-modref.c (dump_lto_records): Fix ICE.

3 years agoNew modref/ipa_modref optimization passes
Jan Hubicka [Sun, 20 Sep 2020 05:25:16 +0000 (07:25 +0200)]
New modref/ipa_modref optimization passes

2020-09-19  David Cepelik  <d@dcepelik.cz>
    Jan Hubicka  <hubicka@ucw.cz>

* Makefile.in: Add ipa-modref.c and ipa-modref-tree.c.
* alias.c: (reference_alias_ptr_type_1): Export.
* alias.h (reference_alias_ptr_type_1): Declare.
* common.opt (fipa-modref): New.
* gengtype.c (open_base_files): Add ipa-modref-tree.h and ipa-modref.h
* ipa-modref-tree.c: New file.
* ipa-modref-tree.h: New file.
* ipa-modref.c: New file.
* ipa-modref.h: New file.
* lto-section-in.c (lto_section_name): Add ipa_modref.
* lto-streamer.h (enum lto_section_type): Add LTO_section_ipa_modref.
* opts.c (default_options_table): Enable ipa-modref at -O1+.
* params.opt (-param=modref-max-bases, -param=modref-max-refs,
-param=modref-max-tests): New params.
* passes.def: Schedule pass_modref and pass_ipa_modref.
* timevar.def (TV_IPA_MODREF): New timevar.
(TV_TREE_MODREF): New timevar.
* tree-pass.h (make_pass_modref): Declare.
(make_pass_ipa_modref): Declare.
* tree-ssa-alias.c (dump_alias_stats): Include ipa-modref-tree.h
and ipa-modref.h
(alias_stats): Add modref_use_may_alias, modref_use_no_alias,
modref_clobber_may_alias, modref_clobber_no_alias, modref_tests.
(dump_alias_stats): Dump new stats.
(nonoverlapping_array_refs_p): Fix formating.
(modref_may_conflict): New function.
(ref_maybe_used_by_call_p_1): Use it.
(call_may_clobber_ref_p_1): Use it.
(call_may_clobber_ref_p): Update.
(stmt_may_clobber_ref_p_1): Update.
* tree-ssa-alias.h (call_may_clobber_ref_p_1): Update.

3 years agoDaily bump.
GCC Administrator [Sun, 20 Sep 2020 00:16:23 +0000 (00:16 +0000)]
Daily bump.

3 years agoExtend -Warray-bounds to detect out-of-bounds accesses to array parameters.
Martin Sebor [Sat, 19 Sep 2020 23:47:29 +0000 (17:47 -0600)]
Extend -Warray-bounds to detect out-of-bounds accesses to array parameters.

gcc/ChangeLog:

PR middle-end/82608
PR middle-end/94195
PR c/50584
PR middle-end/84051
* gimple-array-bounds.cc (get_base_decl): New function.
(get_ref_size): New function.
(trailing_array): New function.
(array_bounds_checker::check_array_ref): Call them.  Handle arrays
declared in function parameters.
(array_bounds_checker::check_mem_ref):  Same.  Handle references to
dynamically allocated arrays.

gcc/testsuite/ChangeLog:

PR middle-end/82608
PR middle-end/94195
PR c/50584
PR middle-end/84051
* c-c++-common/Warray-bounds.c: Adjust.
* gcc.dg/Wbuiltin-declaration-mismatch-9.c: Adjust.
* gcc.dg/Warray-bounds-63.c: New test.
* gcc.dg/Warray-bounds-64.c: New test.
* gcc.dg/Warray-bounds-65.c: New test.
* gcc.dg/Warray-bounds-66.c: New test.
* gcc.dg/Warray-bounds-67.c: New test.

3 years agoExtend -Wstringop-overflow to detect out-of-bounds accesses to array parameters.
Martin Sebor [Sat, 19 Sep 2020 23:37:05 +0000 (17:37 -0600)]
Extend -Wstringop-overflow to detect out-of-bounds accesses to array parameters.

gcc/ChangeLog:

PR c/50584
* builtins.c (warn_for_access): Add argument.  Distinguish between
reads and writes.
(check_access): Add argument.  Distinguish between reads and writes.
(gimple_call_alloc_size): Set range even on failure.
(gimple_parm_array_size): New function.
(compute_objsize): Call it.
(check_memop_access): Pass check_access an additional argument.
(expand_builtin_memchr, expand_builtin_strcat): Same.
(expand_builtin_strcpy, expand_builtin_stpcpy_1): Same.
(expand_builtin_stpncpy, check_strncat_sizes): Same.
(expand_builtin_strncat, expand_builtin_strncpy): Same.
(expand_builtin_memcmp): Same.
* builtins.h (compute_objsize): Declare a new overload.
(gimple_parm_array_size): Declare.
(check_access): Add argument.
* calls.c (append_attrname): Simplify.
(maybe_warn_rdwr_sizes): Handle internal attribute access.
* tree-ssa-uninit.c (maybe_warn_pass_by_reference): Avoid adding
quotes.

gcc/testsuite/ChangeLog:

PR c/50584
* c-c++-common/Wsizeof-pointer-memaccess1.c: Disable new expected
warnings.
* g++.dg/ext/attr-access.C: Update text of expected warnings.
* gcc.dg/Wstringop-overflow-23.c: Same.
* gcc.dg/Wstringop-overflow-24.c: Same.
* gcc.dg/attr-access-none.c: Same.
* gcc.dg/dfp/composite-type.c: Prune expected warnings.
* gcc.dg/torture/pr57147-1.c: Add a member to an otherwise empty
struct to avoid a warning.
* gcc.dg/torture/pr57147-3.c: Same.
* gcc.dg/Warray-bounds-30.c: Adjust.
* gcc.dg/attr-access-none.c: Same.
* gcc.dg/Wstringop-overflow-40.c: New test.
* gcc.dg/attr-access-2.c: New test.

3 years agoMake use of new attribute access infrastructure in -Wuninitialized (PR 50584).
Martin Sebor [Sat, 19 Sep 2020 23:30:32 +0000 (17:30 -0600)]
Make use of new attribute access infrastructure in -Wuninitialized (PR 50584).

gcc/ChangeLog:

* tree-ssa-uninit.c (maybe_warn_pass_by_reference): Handle attribute
access internal representation of arrays.

gcc/testsuite/ChangeLog:

* gcc.dg/uninit-37.c: New test.

3 years agoInfrastructure & C front end changes for array parameter checking (PR c/50584).
Martin Sebor [Sat, 19 Sep 2020 23:21:52 +0000 (17:21 -0600)]
Infrastructure & C front end changes for array parameter checking (PR c/50584).

gcc/ChangeLog:

PR c/50584
* attribs.c (decl_attributes): Also pass decl along with type
attributes to handlers.
(init_attr_rdwr_indices): Change second argument to attribute chain.
Handle internal attribute representation in addition to external.
(get_parm_access): New function.
(attr_access::to_internal_string): Define new member function.
(attr_access::to_external_string): Define new member function.
(attr_access::vla_bounds): Define new member function.
* attribs.h (struct attr_access): Declare new members.
(attr_access::from_mode_char): Define new member function.
(get_parm_access): Declare new function.
* calls.c (initialize_argument_information): Pass function type
attributes to init_attr_rdwr_indices.
* doc/invoke.texi (-Warray-parameter, -Wvla-parameter): Document.
* tree-pretty-print.c (dump_generic_node): Correct handling of
qualifiers.
* tree-ssa-uninit.c (maybe_warn_pass_by_reference): Same.
* tree.h (access_mode): Add new enumerator.

gcc/c-family/ChangeLog:

PR c/50584
* c-attribs.c (c_common_attribute_table): Add "arg spec" attribute.
(handle_argspec_attribute): New function.
(get_argument, get_argument_type): New functions.
(append_access_attrs): Add overload.  Handle internal attribute
representation in addition to external.
(handle_access_attribute): Handle internal attribute representation
in addition to external.
(build_attr_access_from_parms): New function.

gcc/c-family/ChangeLog:

PR c/50584
* c-common.h (warn_parm_array_mismatch): Declare new function.
(has_attribute): Move declaration of an existing function.
(build_attr_access_from_parms): Declare new function.
* c-warn.c (parm_array_as_string): Define new function.
(plus_one):  Define new function.
(warn_parm_ptrarray_mismatch): Define new function.
(warn_parm_array_mismatch):  Define new function.
(vla_bound_parm_decl): New function.
* c.opt (-Warray-parameter, -Wvla-parameter): New options.
* c-pretty-print.c (pp_c_type_qualifier_list): Don't print array type
qualifiers here...
(c_pretty_printer::direct_abstract_declarator): ...but instead print
them in brackets here.  Also print [static].  Strip extraneous
expressions from VLA bounds.

gcc/c/ChangeLog:

PR c/50584
* c-decl.c (lookup_last_decl): Define new function.
(c_decl_attributes): Call it.
(start_decl): Add argument and use it.
(finish_decl): Call build_attr_access_from_parms and decl_attributes.
(get_parm_array_spec): Define new function.
(push_parm_decl): Call get_parm_array_spec.
(start_function): Call warn_parm_array_mismatch.  Build attribute
access and add it to current function.
* c-parser.c (c_parser_declaration_or_fndef): Diagnose mismatches
in forms of array parameters.
* c-tree.h (start_decl): Add argument.

gcc/testsuite/ChangeLog:

PR c/50584
* gcc.dg/attr-access-read-write-2.c: Adjust text of expected message.
* c-c++-common/Warray-bounds-6.c: Correct C++ declaration, adjust
text of expected diagnostics.
* gcc.dg/Wbuiltin-declaration-mismatch-9.c: Prune expected warning.
* gcc.dg/Warray-parameter-2.c: New test.
* gcc.dg/Warray-parameter-3.c: New test.
* gcc.dg/Warray-parameter-4.c: New test.
* gcc.dg/Warray-parameter-5.c: New test.
* gcc.dg/Warray-parameter.c: New test.
* gcc.dg/Wvla-parameter-2.c: New test.
* gcc.dg/Wvla-parameter-3.c: New test.
* gcc.dg/Wvla-parameter.c: New test.

3 years agoChange C front end to emit structured loop and switch tree nodes.
Sandra Loosemore [Sat, 19 Sep 2020 14:32:35 +0000 (07:32 -0700)]
Change C front end to emit structured loop and switch tree nodes.

2020-08-12  Sandra Loosemore  <sandra@codesourcery.com>

gcc/c
* c-decl.c (c_break_label, c_cont_label): Delete, and replace
with...
(in_statement): New.
(start_function): Adjust for above change.
(c_push_function_context, c_pop_function_context): Likewise.
* c-lang.h (struct language_function): Likewise.
* c-objc-common.h (LANG_HOOKS_BLOCK_MAY_FALLTHRU): Define.
* c-parser.c (objc_foreach_break_label, objc_foreach_continue_label):
New.
(c_parser_statement_after_labels): Adjust calls to c_finish_bc_stmt.
(c_parser_switch_statement): Adjust break/switch context handling
and calls to renamed functions.
(c_parser_while_statement): Adjust break/switch context handling and
build a WHILE_STMT.
(c_parser_do_statement): Ditto, with DO_STMT respectively.
(c_parser_for_statement): Ditto, with FOR_STMT respectively.
(c_parser_omp_for_loop): Adjust break/switch context handling.
* c-tree.h (c_break_label, c_cont_label): Delete.
(IN_SWITCH_STMT, IN_ITERATION_STMT): Define.
(IN_OMP_BLOCK, IN_OMP_FOR, IN_OBJC_FOREACH): Define.
(in_statement, switch_statement_break_seen_p): Declare.
(c_start_case, c_finish_case): Renamed to...
(c_start_switch, c_finish_switch).
(c_finish_bc_stmt): Adjust arguments.
* c-typeck.c (build_function_call_vec): Don't try to print
statements with %qE format.
(struct c_switch):  Rename switch_expr field to switch_stmt.
Add break_stmt_seen_p field.
(c_start_case): Rename to c_start_switch.  Build a SWITCH_STMT
instead of a SWITCH_EXPR.  Update for changes to struct c_switch.
(do_case): Update for changes to struct c_switch.
(c_finish_case): Rename to c_finish_switch.  Update for changes to
struct c_switch and change of representation from SWITCH_EXPR to
SWITCH_STMT.
(c_finish_loop): Delete.
(c_finish_bc_stmt): Update to reflect changes to break/continue
state representation.  Build a BREAK_STMT or CONTINUE_STMT instead
of a GOTO_EXPR except for objc foreach loops.

gcc/objc
* objc-act.c (objc_start_method_definition): Update to reflect
changes to break/continue state bookkeeping in C front end.

gcc/testsuite/
* gcc.dg/gomp/block-7.c: Update expected error message wording.

3 years agoWork around bootstrap failure in Fortran front end.
Sandra Loosemore [Sat, 19 Sep 2020 14:32:35 +0000 (07:32 -0700)]
Work around bootstrap failure in Fortran front end.

Switching the C++ front end to lower loops the same was as the C front
end triggered this error when bootstrapping the Fortran front end:

/path/to/gcc/fortran/interface.c:3546:12: error: '*new_arg' may be used uninitialized [-Werror=maybe-uninitialized]
 3546 |   new_arg[i]->next = NULL;
      |   ~~~~~~~~~^

Work around this by adding an assertion, which seems appropriate for
documentation and good coding practices anyway.

2020-08-12  Sandra Loosemore  <sandra@codesourcery.com>

gcc/fortran/
* interface.c (gfc_compare_actual_formal): Add assertion after
main processing loop to silence maybe-uninitialized error.

3 years agoUse C-style loop lowering instead of C++-style.
Sandra Loosemore [Sat, 19 Sep 2020 14:32:35 +0000 (07:32 -0700)]
Use C-style loop lowering instead of C++-style.

The C and C++ front ends used to use the same strategy of lowering
loops to gotos with the end test canonicalized to the bottom of the
loop.  In 2014 the C++ front end was changed to emit LOOP_EXPRs
instead (commit 1a45860e7757ee054f6bf98bee4ebe5c661dfb90).

As part of the unification of the C and C++ loop handling, it's
desirable to use the same lowering strategy for both languages.
Applying the C++ strategy to C caused a number of regressions in C
optimization tests, related to flipping the sense of the COND_EXPR for
the exit test and changes in block ordering in the output code.  Many
of these regressions just require updating regexps in the test cases
but a few appear to be genuine optimization failures.  Since it
appears the optimizers handle the C code better than C++ code, let's
go back to using the C strategy for both languages.  The rationale for
the 2014 C++ patch (support for constexpr evaluation) has been solved
in other ways meanwhile.

2020-08-12  Sandra Loosemore  <sandra@codesourcery.com>

gcc/c-family/
* c-gimplify.c (genericize_c_loop): Rewrite to match
c_finish_loop in c-typeck.c.

3 years agoMove loop and switch tree data structures from cp/ to c-family/.
Sandra Loosemore [Sat, 19 Sep 2020 14:32:35 +0000 (07:32 -0700)]
Move loop and switch tree data structures from cp/ to c-family/.

This patch moves the definitions for DO_STMT, FOR_STMT, WHILE_STMT,
SWITCH_STMT, BREAK_STMT, and CONTINUE_STMT from the C++ front end to
c-family.  This includes the genericizers, pretty-printers, and dump
support as well as the tree definitions and accessors.  Some related
code for OMP_FOR and similar OMP constructs is also moved.

2020-08-12  Sandra Loosemore  <sandra@codesourcery.com>

gcc/c-family/
* c-common.c (c_block_may_fallthrough): New, split from
cxx_block_may_fallthrough in the cp front end.
(c_common_init_ts): Move handling of loop and switch-related
statements here from the cp front end.
* c-common.def (FOR_STMT, WHILE_STMT, DO_STMT): Move here from
cp front end.
(BREAK_STMT, CONTINUE_STMT, SWITCH_STMT): Likewise.
* c-common.h (c_block_may_fallthru): Declare.
(bc_state_t): Move here from cp front end.
(save_bc_state, restore_bc_state): Declare.
(c_genericize_control_stmt): Declare.
(WHILE_COND, WHILE_BODY): Likewise.
(DO_COND, DO_BODY): Likewise.
(FOR_INIT_STMT, FOR_COND, FOR_EXPR, FOR_BODY, FOR_SCOPE): Likewise.
(SWITCH_STMT_COND, SWITCH_STMT_BODY): Likewise.
(SWITCH_STMT_TYPE, SWITCH_STMT_SCOPE): Likewise.
(SWITCH_STMT_ALL_CASES_P, SWITCH_STMT_NO_BREAK_P): Likewise.
(LABEL_DECL_BREAK, LABEL_DECL_CONTINUE): Likewise.
* c-dump.c (dump_stmt): Copy from cp front end.
(c_dump_tree): Move code to handle structured loop and switch
tree nodes here from cp front end.
* c-gimplify.c: Adjust includes.
(enum bc_t, bc_label, begin_bc_block, finish_bc_block): Move from
cp front end.
(save_bc_state, restore_bc_state): New functions using old code
from cp front end.
(get_bc_label, expr_loc_or_loc): Move from cp front end.
(genericize_c_loop): Move from cp front end.
(genericize_for_stmt, genericize_while_stmt): Likewise.
(genericize_do_stmt, genericize_switch_stmt): Likewise.
(genericize_continue_stmt, genericize_break_stmt): Likewise.
(genericize_omp_for_stmt): Likewise.
(c_genericize_control_stmt): New function using code split from
cp front end.
(c_genericize_control_r): New.
(c_genericize): Call walk_tree with c_genericize_control_r.
* c-pretty-print.c (c_pretty_printer::statement): Move code to handle
structured loop and switch tree nodes here from cp front end.

gcc/cp/
* cp-gimplify.c (enum bc_t, bc_label): Move to c-family.
(begin_bc_block, finish_bc_block, get_bc_label): Likewise.
(genericize_cp_loop): Likewise.
(genericize_for_stmt, genericize_while_stmt): Likewise.
(genericize_do_stmt, genericize_switch_stmt): Likewise.
(genericize_continue_stmt, genericize_break_stmt): Likewise.
(genericize_omp_for_stmt): Likewise.
(cp_genericize_r): Call c_genericize_control_stmt instead of
above functions directly.
(cp_genericize): Call save_bc_state and restore_bc_state instead
of manipulating bc_label directly.
* cp-objcp-common.c (cxx_block_may_fallthru): Defer to
c_block_may_fallthru instead of handling SWITCH_STMT here.
(cp_common_init_ts): Move handling of loop and switch-related
statements to c-family.
* cp-tree.def (FOR_STMT, WHILE_STMT, DO_STMT): Move to c-family.
(BREAK_STMT, CONTINUE_STMT, SWITCH_STMT): Likewise.
* cp-tree.h (LABEL_DECL_BREAK, LABEL_DECL_CONTINUE): Likewise.
(WHILE_COND, WHILE_BODY): Likewise.
(DO_COND, DO_BODY): Likewise.
(FOR_INIT_STMT, FOR_COND, FOR_EXPR, FOR_BODY, FOR_SCOPE): Likewise.
(SWITCH_STMT_COND, SWITCH_STMT_BODY): Likewise.
(SWITCH_STMT_TYPE, SWITCH_STMT_SCOPE): Likewise.
(SWITCH_STMT_ALL_CASES_P, SWITCH_STMT_NO_BREAK_P): Likewise.
* cxx-pretty-print.c (cxx_pretty_printer::statement): Move code
to handle structured loop and switch tree nodes to c-family.
* dump.c (cp_dump_tree): Likewise.

gcc/
* doc/generic.texi (Basic Statements): Document SWITCH_EXPR here,
not SWITCH_STMT.
(Statements for C and C++): Rename node to reflect what
the introduction already says about sharing between C and C++
front ends.  Copy-edit and correct documentation for structured
loops and switch.

3 years agoPR fortran/97036 - [F2018] Allow ELEMENTAL RECURSIVE procedure prefix
Harald Anlauf [Sat, 19 Sep 2020 18:46:38 +0000 (20:46 +0200)]
PR fortran/97036 - [F2018] Allow ELEMENTAL RECURSIVE procedure prefix

gcc/fortran/ChangeLog:

* symbol.c (gfc_check_conflict): Allow ELEMENTAL RECURSIVE
procedure prefix for -std=f2018.

gcc/testsuite/ChangeLog:

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

3 years agox86: Add a testcase for PR target/96861
H.J. Lu [Sat, 19 Sep 2020 16:57:16 +0000 (09:57 -0700)]
x86: Add a testcase for PR target/96861

Add a testcase to verify that -march=skylake-avx512 -mtune=skylake-avx512
generates desired code sequence.

PR target/96861
* gcc.target/i386/pr96861.c: New test.

3 years agoc++: Fix self-mapping in map_arguments [PR96531, PR97103]
Patrick Palka [Sat, 19 Sep 2020 15:02:46 +0000 (11:02 -0400)]
c++: Fix self-mapping in map_arguments [PR96531, PR97103]

With r10-8077 we stopped passing the argified current_template_parms to
normalize_constraint_expression from finish_nested_requirement, and
instead made map_arguments perform a self-mapping of parameters when
args is NULL.  But we're currently not handling parameter packs and
BOUND_TEMPLATE_TEMPLATE_PARMs properly during this self-mapping, which
leads to ICEs later during satisfaction.

To properly handle self-mapping of a parameter pack, this patch
extends template_parm_to_arg to handle TEMPLATE_PARM_P nodes, and
makes map_arguments use it.  (This change revealed that the call to
template_parm_to_arg in convert_generic_types_to_packs was a no-op
because the argument 't' is never a TREE_LIST, so this patch
additionally removes this call.)

As for bound ttps, map_arguments before r10-8077 would map a
BOUND_TEMPLATE_TEMPLATE_PARM not to itself but to its underlying
TEMPLATE_TEMPLATE_PARM.  We could restore this behavior in
map_arguments, but since a bound ttp is not really a template parameter
it seems better to make keep_template_parm not give us a bound ttp in
the first place.  So this patch makes keep_template_parm return the
underlying ttp when it sees a bound ttp.

gcc/cp/ChangeLog:

PR c++/96531
PR c++/97103
* constraint.cc (map_arguments): Call template_parm_to_arg
in the self-mapping case.
(finish_shorthand_constraint): No need to build a TREE_LIST
before calling template_parm_to_arg.
* pt.c (template_parm_to_arg): Rewrite to handle TEMPLATE_PARM_P
nodes as well as DECL_TEMPLATE_PARM_P nodes, and to make the
overlying TREE_LIST node optional.
(keep_template_parm): Don't record a BOUND_TEMPLATE_TEMPLATE_PARM,
instead record its corresponding TEMPLATE_TEMPLATE_PARM.
(convert_generic_types_to_packs): Don't call
template_parm_to_arg.

gcc/testsuite/ChangeLog:

PR c++/96531
PR c++/97103
* g++.dg/cpp2a/concepts-ttp2.C: New test.
* g++.dg/cpp2a/concepts-variadic1.C: New test.

3 years agoc++: std::is_constant_evaluated inside constraint [PR97051]
Patrick Palka [Sat, 19 Sep 2020 15:17:41 +0000 (11:17 -0400)]
c++: std::is_constant_evaluated inside constraint [PR97051]

According to [expr.const]/14, the result of substitution into an atomic
constraint is manifestly constant-evaluated; this patch adjusts the call
to maybe_constant_value in satisfy_atom to that effect.

gcc/cp/ChangeLog:

PR c++/97051
* constraint.cc (satisfy_atom): Pass true as the
manifestly_const_eval argument to maybe_constant_value.

gcc/testsuite/ChangeLog:

PR c++/97051
* g++.dg/cpp2a/is-constant-evaluated11.C: New test.

3 years agoIncrease rtx cost of sse_to_integer in skylake_cost.
liuhongt [Wed, 16 Sep 2020 02:53:52 +0000 (10:53 +0800)]
Increase rtx cost of sse_to_integer in skylake_cost.

As https://gcc.gnu.org/pipermail/gcc-patches/2019-August/528839.html
indicates, movement between SSE and gpr should be much expensive than
movement inside gpr(which is 2 as default).

gcc/ChangeLog

PR target/96861
* config/i386/x86-tune-costs.h (skylake_cost): increase rtx
cost of sse_to_integer from 2 to 6.

gcc/testsuite

* gcc.target/i386/pr95021-3.c: Add -mtune=generic.

3 years agoDaily bump.
GCC Administrator [Sat, 19 Sep 2020 00:16:29 +0000 (00:16 +0000)]
Daily bump.

3 years agoc++: Add testcase for already fixed PR97105
Jakub Jelinek [Fri, 18 Sep 2020 22:09:11 +0000 (00:09 +0200)]
c++: Add testcase for already fixed PR97105

This has been fixed by the PR bootstrap/97118 fix.

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

PR c++/97105
* g++.dg/template/pr97105.C: New test.

3 years agoanalyzer: fix warning_event::get_desc for global state changes
David Malcolm [Thu, 17 Sep 2020 13:41:29 +0000 (09:41 -0400)]
analyzer: fix warning_event::get_desc for global state changes

When experimenting the a new state_machine with global state I noticed
that the fallback handling in warning_event::get_desc assumes we have
per-value states, and ICEs on global states.  Fixed thusly.

gcc/analyzer/ChangeLog:
* checker-path.cc (warning_event::get_desc): Handle global state
changes.

3 years agoanalyzer: handle strdup and strndup
David Malcolm [Wed, 16 Sep 2020 21:21:32 +0000 (17:21 -0400)]
analyzer: handle strdup and strndup

gcc/analyzer/ChangeLog:
* sm-malloc.cc (malloc_state_machine::on_stmt): Handle strdup and
strndup as being malloc-like allocators.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/strdup-1.c: New test.
* gcc.dg/analyzer/strndup-1.c: New test.

3 years agoc++: Fix bootstrap failure. [PR97118]
Jason Merrill [Fri, 18 Sep 2020 19:34:24 +0000 (15:34 -0400)]
c++: Fix bootstrap failure.  [PR97118]

gcc/cp/ChangeLog:

PR bootstrap/97118
* decl.c (complete_vars): Only call layout_var_decl if completing
the type succeeded.

3 years ago[PATCH 4/5][Arm] New pattern for CSNEG instructions
Sudi Das [Fri, 18 Sep 2020 15:31:12 +0000 (16:31 +0100)]
[PATCH 4/5][Arm] New pattern for CSNEG instructions

This patch adds a new pattern, *thumb2_csneg, for generating CSNEG
instructions. It also restricts *if_neg_move and *thumb2_negscc to only match
if !TARGET_COND_ARITH which prevents undesirable matches during ifcvt.

gcc/ChangeLog:

* config/arm/thumb2.md (*thumb2_csneg): New.
(*thumb2_negscc): Don't match if TARGET_COND_ARITH.
* config/arm/arm.md (*if_neg_move): Don't match if TARGET_COND_ARITH.

gcc/testsuite/ChangeLog:

* gcc.target/arm/csneg.c: New test.

Co-authored-by: Omar Tahir <omar.tahir@arm.com>
3 years ago[PATCH 3/5][Arm] New pattern for CSINC instructions
Sudi Das [Fri, 18 Sep 2020 15:30:11 +0000 (16:30 +0100)]
[PATCH 3/5][Arm] New pattern for CSINC instructions

This patch adds a new pattern, *thumb2_csinc, for generating CSINC
instructions. It also modifies an existing pattern, *thumb2_cond_arith, to
output CINC when the operation is an addition and TARGET_COND_ARITH is true.

gcc/ChangeLog:

* config/arm/thumb2.md (*thumb2_csinc): New.
(*thumb2_cond_arith): Generate CINC where possible.

gcc/testsuite/ChangeLog:

* gcc.target/arm/csinc-1.c: New test.

Co-authored-by: Omar Tahir <omar.tahir@arm.com>
3 years ago[PATCH 2/5][Arm] New pattern for CSINV instructions
Sudi Das [Fri, 18 Sep 2020 14:47:46 +0000 (15:47 +0100)]
[PATCH 2/5][Arm] New pattern for CSINV instructions

This patch adds a new pattern, *thumb2_csinv, for generating CSINV nstructions.

This pattern relies on a few general changes that will be used throughout
the following patches:
- A new macro, TARGET_COND_ARITH, which is only true on 8.1-M Mainline
  and represents the existence of these conditional instructions.
- A change to the cond exec hook, arm_have_conditional_execution, which
  now returns false if TARGET_COND_ARITH before reload. This allows for
  some ifcvt transformations when they would usually be disabled. I've
  written a rather verbose comment (with the risk of over-explaining)
  as it's a bit of a confusing change.
- One new predicate.
- *thumb2_movcond has been restricted to only match if !TARGET_COND_ARITH,
  otherwise it triggers undesirable combines.

gcc/ChangeLog:

* config/arm/arm.h (TARGET_COND_ARITH): New macro.
* config/arm/arm.c (arm_have_conditional_execution): Return false if
TARGET_COND_ARITH before reload.
* config/arm/predicates.md (arm_comparison_operation): Returns true if
comparing CC_REGNUM with constant zero.
* config/arm/thumb2.md (*thumb2_csinv): New.
(*thumb2_movcond): Don't match if TARGET_COND_ARITH.

gcc/testsuite/ChangeLog:

* gcc.target/arm/csinv-1.c: New test.

Co-authored-by: Omar Tahir <omar.tahir@arm.com>
3 years agoira: Fix elimination for global hard FPs [PR91957]
Richard Sandiford [Fri, 18 Sep 2020 15:55:45 +0000 (16:55 +0100)]
ira: Fix elimination for global hard FPs [PR91957]

If the hard frame pointer is being used as a global register,
we should skip the usual handling for eliminations.  As the
comment says, the register cannot in that case be eliminated
(or eliminated to) and is already marked live where appropriate.

Doing this removes the duplicate error for gcc.target/i386/pr82673.c.
The “cannot be used in 'asm' here” message is meant to be for asm
statements rather than register asms, and the function that the
error is reported against doesn't use asm.

gcc/
2020-09-18  Richard Sandiford  <richard.sandiford@arm.com>

PR middle-end/91957
* ira.c (ira_setup_eliminable_regset): Skip the special elimination
handling of the hard frame pointer if the hard frame pointer is fixed.

gcc/testsuite/
2020-09-18  H.J. Lu  <hjl.tools@gmail.com>
    Richard Sandiford  <richard.sandiford@arm.com>

PR middle-end/91957
* g++.target/i386/pr97054.C: New test.
* gcc.target/i386/pr82673.c: Remove redundant extra message.

3 years agoMAINTAINERS: Add myself for write after approval.
Omar Tahir [Fri, 18 Sep 2020 14:30:42 +0000 (15:30 +0100)]
MAINTAINERS: Add myself for write after approval.

ChangeLog:

2020-09-18  Omar Tahir  <omar.tahir@arm.com>

* MAINTAINERS (Write After Approval): Add myself.

3 years agotestsuite: add another test for the rotate vectorization miscompilation
Jakub Jelinek [Fri, 18 Sep 2020 13:05:53 +0000 (15:05 +0200)]
testsuite: add another test for the rotate vectorization miscompilation

This time with short and char where the used mask used to be larger
than it should have been.

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

PR tree-optimization/97081
* gcc.dg/vect/pr97081-2.c: New test.

3 years agotree-optimization/97081 - fix wrong-code with vectorized shift
Richard Biener [Fri, 18 Sep 2020 11:36:24 +0000 (13:36 +0200)]
tree-optimization/97081 - fix wrong-code with vectorized shift

This corrects the mask for creation of x << s | x >> (-x & mask)
from a rotate x <<r s to use the precision of x.

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

PR tree-optimization/97081
* tree-vect-patterns.c (vect_recog_rotate_pattern): Use the
precision of the shifted operand to determine the mask.

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

3 years agoMSP430: Add 'd', 'e', 'f' and 'g' asm operand modifiers
Jozef Lawrynowicz [Fri, 18 Sep 2020 12:07:19 +0000 (13:07 +0100)]
MSP430: Add 'd', 'e', 'f' and 'g' asm operand modifiers

The new operand modifiers can be used to select odd-numbered bytes of a memory
reference or constant value.

gcc/ChangeLog:

* config/msp430/msp430.c (msp430_print_operand): Update comment.
Cast to long when printing values formatted as long.
Support 'd', 'e', 'f' and 'g' modifiers.
Extract operand value with a single operation for all modifiers.
* doc/extend.texi (msp430Operandmodifiers): New.

gcc/testsuite/ChangeLog:

* gcc.target/msp430/operand-modifiers.c: Extend test to handle new
modifiers.
* gcc.target/msp430/operand-modifiers-bad.c: New test.

3 years agoMSP430: Fix CFA generation during function epilogues
Jozef Lawrynowicz [Fri, 18 Sep 2020 12:03:13 +0000 (13:03 +0100)]
MSP430: Fix CFA generation during function epilogues

There is no CFA information generated for instructions that manipulate the
stack during function epilogues. This means a debugger cannot determine the
position of variables on the stack whilst the epilogue is in progress.

This can cause the debugger to give erroneous information when printing a
backtrace whilst stepping through the epilogue, or cause software watchpoints
set on stack variables to become invalidated after a function epilogue
is executed.

The patch fixes this by marking stack manipulation insns as
frame_related, and adding reg_note RTXs to stack pop instructions in the
epilogue.

gcc/ChangeLog:

* config/msp430/msp430.c (increment_stack): Mark insns which increment
the stack as frame_related.
(msp430_expand_prologue): Add comments.
(msp430_expand_epilogue): Mark insns which decrement
the stack as frame_related.
Add reg_note to stack pop insns describing position of register
variables on the stack.

3 years agoamdgcn: Remove omp_gcn pass
Andrew Stubbs [Thu, 17 Sep 2020 11:48:21 +0000 (12:48 +0100)]
amdgcn: Remove omp_gcn pass

This pass only had an optimization for obtaining team/thread numbers in it,
and that turns out to be invalid in the presence of nested parallel regions,
so we can simply delete the whole thing.

Of course, it would be nice to apply the optimization where it is valid, but
that will take more effort than I have to spend right now.

gcc/ChangeLog:

* config/gcn/gcn-tree.c (execute_omp_gcn): Delete.
(make_pass_omp_gcn): Delete.
* config/gcn/t-gcn-hsa (PASSES_EXTRA): Delete.
* config/gcn/gcn-passes.def: Removed.

3 years agocfgloop.h: Reword comment describing is_exit flag
Alex Coplan [Fri, 18 Sep 2020 09:43:53 +0000 (10:43 +0100)]
cfgloop.h: Reword comment describing is_exit flag

This simple change rewords a comment in cfgloop.h to improve the grammar
and readability.

gcc/ChangeLog:

* cfgloop.h (nb_iter_bound): Reword comment describing is_exit.

3 years agotree-optimization/97095 - fix typo in vectorizable_live_operation
Richard Biener [Fri, 18 Sep 2020 09:34:31 +0000 (11:34 +0200)]
tree-optimization/97095 - fix typo in vectorizable_live_operation

This fixes a typo introduced with the last change and not noticed
because those vectorizer access macros are not type safe ...

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

PR tree-optimization/97095
* tree-vect-loop.c (vectorizable_live_operation): Get
the SLP vector type from the correct object.

* gfortran.dg/pr97095.f: New testcase.

3 years agotree-optimization/97089 - fix bogus unsigned division replacement
Richard Biener [Fri, 18 Sep 2020 07:22:57 +0000 (09:22 +0200)]
tree-optimization/97089 - fix bogus unsigned division replacement

This fixes bogus replacing of an unsigned (-x)/y division by
-(x/y).

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

PR tree-optimization/97089
* tree-ssa-sccvn.c (visit_nary_op): Do not replace unsigned
divisions.

3 years agotree-optimization/97098 - fix compile-time hog in SLP live
Richard Biener [Fri, 18 Sep 2020 07:00:12 +0000 (09:00 +0200)]
tree-optimization/97098 - fix compile-time hog in SLP live

This fixes a missed early-out in SLP live stmt marking when
all scalar stmts were already visited (oops).

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

PR tree-optimization/97098
* tree-vect-slp.c (vect_bb_slp_mark_live_stmts): Do not
recurse to children when all stmts were already visited.

3 years agoc++: Layout decls with newly-complete type.
Jason Merrill [Fri, 4 Sep 2020 16:14:19 +0000 (12:14 -0400)]
c++: Layout decls with newly-complete type.

Martin's -Wplacement-new patch ran into a problem with DECL_SIZE not being
set on an extern variable for which the type was not complete until after
its declaration.  complete_vars was deliberately not calling layout_decl for
some reason, instead leaving that for expand_expr_real_1 much later in the
compilation.  But if we layout decls at declaration time, I don't see any
reason we shouldn't lay them out here, when their type is newly complete.

gcc/cp/ChangeLog:

* decl.c (complete_vars): Call layout_var_decl.

3 years agoDaily bump.
GCC Administrator [Fri, 18 Sep 2020 00:16:24 +0000 (00:16 +0000)]
Daily bump.

3 years ago[testsuite] Introduce effective target non_strict_prototype
Tom de Vries [Thu, 10 Sep 2020 11:23:43 +0000 (13:23 +0200)]
[testsuite] Introduce effective target non_strict_prototype

Consider test-case gcc.c-torture/compile/pr71109.c.

It contains a prototype-less declaration of foo:
...
static void foo ();
...
followed by a call to foo
...
      foo (bar, a);
...
followed by the definition of foo:
...
static inline void
foo (int x, struct S y, struct T z)
...

The test-case has undefined behaviour, but for the nvptx target it doesn't even
assemble:
...
$ gcc src/gcc/testsuite/gcc.c-torture/compile/pr71109.c -c
ptxas pr71109.o, line 196; error   : Type of argument does not match \
  formal parameter '%in_ar0'
ptxas pr71109.o, line 196; error   : Alignment of argument does not match \
  formal parameter '%in_ar0'
ptxas pr71109.o, line 196; error   : Call has wrong number of parameters
ptxas fatal   : Ptx assembly aborted due to errors
nvptx-as: ptxas returned 255 exit status
...

The problem is that this call:
...
   191  {
   192  .param .u64 %out_arg1;
   193  st.param.u64 [%out_arg1],%r23;
   194  .param .u64 %out_arg2;
   195  st.param.u64 [%out_arg2],%r32;
   196  call foo,(%out_arg1,%out_arg2);
   197  }
...
does not match the preceding declaration:
...
     6  // BEGIN FUNCTION DECL: foo
     7  .func foo (.param .u32 %in_ar0, .param .u64 %in_ar1, .param .u64 %in_ar2);
...
which is a PTX error.

Introduce an effective target non_strict_prototype that returns 0 for nvptx,
and use it in this and similar test-cases.

Tested on nvptx.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_non_strict_prototype):
New proc.
* gcc.c-torture/compile/pr71109.c: Require effective target
non_strict_prototype.
* gcc.c-torture/compile/pr83051-2.c: Same.
* gcc.c-torture/compile/pr89663-1.c: Same.
* gcc.c-torture/compile/pr89663-2.c: Same.
* gcc.c-torture/compile/pr96796.c: Same.

3 years agoprofile: clarify comment around histogram format
Sergei Trofimovich [Fri, 4 Sep 2020 21:20:57 +0000 (22:20 +0100)]
profile: clarify comment around histogram format

gcc/ChangeLog:

* profile.c (sort_hist_values): Clarify hist format:
start with a value, not counter.

3 years agoRISC-V: fix a typo in riscv.h
Yeting Kuo [Thu, 17 Sep 2020 21:29:27 +0000 (15:29 -0600)]
RISC-V: fix a typo in riscv.h

gcc/ChangeLog:
* config/riscv/riscv.h (CSW_MAX_OFFSET): Fix typo.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/shorten-memrefs-8.c: New test.

3 years agoAutodetect C++ dialect in use for clang-format
Dimitrij Mojoski [Thu, 17 Sep 2020 21:22:33 +0000 (15:22 -0600)]
Autodetect C++ dialect in use for clang-format

PR other//97076
* clang-format: Autodetect C++ standard in use rather than
forcing C++03.

3 years agoc++: Add tests for fixed PRs.
Marek Polacek [Thu, 17 Sep 2020 19:31:50 +0000 (15:31 -0400)]
c++: Add tests for fixed PRs.

Bugzilla inspection turned up a bunch of old(er) PRs that have been
fixed.  Let's include them not to regress in the future.

gcc/testsuite/ChangeLog:

PR c++/87530
PR c++/58156
PR c++/68828
PR c++/86002
PR c++/91525
PR c++/96223
PR c++/87032
PR c++/35098
* g++.dg/cpp0x/move-return4.C: New test.
* g++.dg/cpp0x/vt-58156.C: New test.
* g++.dg/cpp2a/concepts-pr68828.C: New test.
* g++.dg/cpp2a/concepts-pr86002.C: New test.
* g++.dg/cpp2a/concepts-pr91525.C: New test.
* g++.dg/cpp2a/constexpr-indeterminate1.C: New test.
* g++.dg/cpp2a/desig17.C: New test.
* g++.dg/ext/attrib62.C: New test.

3 years agolibgo: fix ptrace syscall hooks into glibc
Paul E. Murphy [Tue, 15 Sep 2020 19:18:28 +0000 (14:18 -0500)]
libgo: fix ptrace syscall hooks into glibc

ptrace is actually declared as a variadic function.  On ppc64le
the ABI requires to the caller to allocate space for the parameters
and allows the caller to modify them.

On ppc64le, depending on how and what version of GCC is used,
it will save to parameter save area.  This happened to clobber
a saved LR, and caused syscall.TestExecPtrace to fail with a timeout
when the tracee segfaults, and waits for the parent process to inspect.

Wrap this function to avoid directly calling glibc's ptrace from go.

Fixes golang/go#36698
Fixes go/92567

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

3 years agoc-family: Macro support in -Wmisleading-indentation [PR80076]
Patrick Palka [Thu, 17 Sep 2020 18:27:22 +0000 (14:27 -0400)]
c-family: Macro support in -Wmisleading-indentation [PR80076]

Currently the -Wmisleading-indentation warning doesn't do any analysis
when the guarded statement or the statement after it is produced by a
macro.  This means we warn for:

  if (flag)
    foo ();
    bar ();

but not for:

  #define BAR bar
  if (flag)
    foo ();
    BAR ();

This patch extends the -Wmisleading-indentation implementation to
support analyzing such statements and their tokens.  This is done in the
"natural" way by resolving the location of each of the three tokens to
the token's macro expansion point.  (Additionally, if the tokens all
resolve to the same macro expansion point then we instead use their
locations within the macro definition.)  When these resolved locations
are all different, then we can proceed with applying the warning
heuristics to them as if no macros were involved.

gcc/c-family/ChangeLog:

PR c/80076
* c-indentation.c (should_warn_for_misleading_indentation): Move
declarations of local variables closer to their first use.
Handle virtual token locations by resolving them to their
respective macro expansion points.  If all three tokens are
produced from the same macro expansion, then instead use their
loci within the macro definition.

gcc/objc/ChangeLog:

PR c/80076
* objc-gnu-runtime-abi-01.c
(gnu_runtime_abi_01_get_class_super_ref): Reduce indentation of
misleadingly indented return statements.
* objc-next-runtime-abi-01.c
(next_runtime_abi_01_get_class_super_ref): Likewise.

gcc/ChangeLog:

PR c/80076
* gensupport.c (alter_attrs_for_subst_insn) <case SET_ATTR>:
Reduce indentation of misleadingly indented code fragment.
* lra-constraints.c (multi_block_pseudo_p): Likewise.
* sel-sched-ir.c (merge_fences): Likewise.

libcpp/ChangeLog:

PR c/80076
* include/line-map.h (first_map_in_common): Declare.
* line-map.c (first_map_in_common): Remove static.

gcc/testsuite/ChangeLog:

PR c/80076
* c-c++-common/Wmisleading-indentation-5.c: New test.

3 years agoAdd DWARF5 variants of assembly scan tests that use DW_FORM_implicit_const
Mark Wielaard [Sun, 23 Aug 2020 14:21:08 +0000 (16:21 +0200)]
Add DWARF5 variants of assembly scan tests that use DW_FORM_implicit_const

Some DWARF tests scan the assembly output looking for constant values.
When using DWARF5 those constants might use DW_FORM_implicit_const,
which are output (in the comments) after the attribute instead of
before. To make sure these tests work introduce a -gdwarf-5 variant
of these tests and explicitly use -gdwarf-2 for the original.

gcc/testsuite/ChangeLog:

* gcc.dg/debug/dwarf2/inline2.c: Add -gdwarf-2.
* g++.dg/debug/dwarf2/inline-var-1.C: Likewise.
* gcc.dg/debug/dwarf2/pr41445-5.c: Likewise.
* gcc.dg/debug/dwarf2/pr41445-6.c: Likewise.
* gcc.dg/debug/dwarf2/inline6.c: New variant with -gdwarf-5.
* g++.dg/debug/dwarf2/inline-var-3.C: Likewise.
* gcc.dg/debug/dwarf2/pr41445-7.c: Likewise.
* gcc.dg/debug/dwarf2/pr41445-8.c: Likewise.

3 years agoaarch64: Fix dejaGNU directive in clastb_8.c testcase
Andrea Corallo [Thu, 17 Sep 2020 13:36:22 +0000 (15:36 +0200)]
aarch64: Fix dejaGNU directive in clastb_8.c testcase

gcc/testsuite/ChangeLog

2020-09-17  Andre Corallo  <andrea.corallo@arm.com>

* gcc.target/aarch64/sve/clastb_8.c: Fix a dg-final scan
directive.

3 years agoDocument -Wuninitialized for allocated objects.
Martin Sebor [Thu, 17 Sep 2020 15:07:09 +0000 (09:07 -0600)]
Document -Wuninitialized for allocated objects.

gcc/ChangeLog:

* doc/invoke.texi (-Wuninitialized): Document -Wuninitialized for
allocated objects.
 (-Wmaybe-uninitialized): Same.

3 years agoaix: apply socket.h extern "C++" more narrowly.
David Edelsohn [Wed, 16 Sep 2020 18:56:00 +0000 (18:56 +0000)]
aix: apply socket.h extern "C++" more narrowly.

Recent Technology Levels of AIX 7.2 have made sys/socket.h more C++-aware,
which causes the fix to be applied in too many locations.  This patch adds
more context for the selection to apply the fix more narrowly.

fixincludes/ChangeLog:

2020-09-17  David Edelsohn  <dje.gcc@gmail.com>

* inclhack.def (aix_externcpp1): Add more context to select.
(aix_externcpp2): Same.
* fixincl.x: Regenerate.
* tests/base/sys/socket.h: Update expected results.

3 years agoc++: requires-expressions and partial instantiation [PR96410]
Patrick Palka [Thu, 17 Sep 2020 13:16:02 +0000 (09:16 -0400)]
c++: requires-expressions and partial instantiation [PR96410]

This patch makes tsubst_requires_expr avoid substituting into a
requires-expression when partially instantiating a generic lambda.
This is necessary in general to ensure that we always check requirements
in lexical order (as in the first testcase below).  A mechanism similar
to PACK_EXPANSION_EXTRA_ARGS is added to remember template arguments and
defer substitution of requires-expressions.

Incidentally, this change also fixes the two mentioned PRs -- the
problem there is that tsubst_requires_expr was performing semantic
checks on template trees, and some of the checks are not prepared to
handle such trees.  With this patch, tsubst_requires_expr no longer
does any semantic checking at all when processing_template_decl.

gcc/cp/ChangeLog:

PR c++/96409
PR c++/96410
* constraint.cc (tsubst_requires_expr): Use REQUIRES_EXPR_PARMS
and REQUIRES_EXPR_REQS.  Use REQUIRES_EXPR_EXTRA_ARGS,
add_extra_args and build_extra_args to defer substitution until
we have all the template arguments.
(finish_requires_expr): Adjust the call to build_min so that
REQUIRES_EXPR_EXTRA_ARGS gets set to NULL_TREE.
* cp-tree.def (REQUIRES_EXPR): Give it a third operand.
* cp-tree.h (REQUIRES_EXPR_PARMS, REQUIRES_EXPR_REQS,
REQUIRES_EXPR_EXTRA_ARGS): Define.
(add_extra_args, build_extra_args): Declare.

gcc/testsuite/ChangeLog:

PR c++/96409
PR c++/96410
* g++.dg/cpp2a/concepts-lambda13.C: New test.
* g++.dg/cpp2a/concepts-lambda14.C: New test.

3 years agolibgcc/config/arm/fp16.c: Make _internal functions static inline
Christophe Lyon [Fri, 11 Sep 2020 11:43:56 +0000 (11:43 +0000)]
libgcc/config/arm/fp16.c: Make _internal functions static inline

This patch makes the *_internal functions 'static inline' to avoid these warnings during the build:
/libgcc/config/arm/fp16.c:169:1: warning: no previous prototype for '__gnu_h2f_internal' [-Wmissing-prototypes]
/libgcc/config/arm/fp16.c:194:1: warning: no previous prototype for '__gnu_f2h_ieee' [-Wmissing-prototypes]
/libgcc/config/arm/fp16.c:200:1: warning: no previous prototype for '__gnu_h2f_ieee' [-Wmissing-prototypes]
/libgcc/config/arm/fp16.c:206:1: warning: no previous prototype for '__gnu_f2h_alternative' [-Wmissing-prototypes]
/libgcc/config/arm/fp16.c:212:1: warning: no previous prototype for '__gnu_h2f_alternative' [-Wmissing-prototypes]
/libgcc/config/arm/fp16.c:218:1: warning: no previous prototype for '__gnu_d2h_ieee' [-Wmissing-prototypes]
/libgcc/config/arm/fp16.c:224:1: warning: no previous prototype for '__gnu_d2h_alternative' [-Wmissing-prototypes]

2020-09-11  Torbjörn SVENSSON  <torbjorn.svensson@st.com>
    Christophe Lyon  <christophe.lyon@linaro.org>

libgcc/
* config/arm/fp16.c (__gnu_h2f_internal): Add 'static inline'
qualifier.
(__gnu_f2h_ieee, __gnu_h2f_ieee, __gnu_f2h_alternative)
(__gnu_h2f_alternative,__gnu_d2h_ieee, __gnu_d2h_alternative): Add
missing prototypes.

3 years agoFortran: Avoid double-free with parse error (PR96041, PR93423)
Tobias Burnus [Thu, 17 Sep 2020 12:01:09 +0000 (14:01 +0200)]
Fortran: Avoid double-free with parse error (PR96041, PR93423)

gcc/fortran/

PR fortran/96041
PR fortran/93423
* decl.c (gfc_match_submod_proc): Avoid later double-free
in the error case.

3 years agoCSE negated multiplications and divisions
Richard Biener [Thu, 17 Sep 2020 09:48:36 +0000 (11:48 +0200)]
CSE negated multiplications and divisions

This adds the capability to look for available negated multiplications
and divisions, replacing them with cheaper negates.

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

* tree-ssa-sccvn.c (visit_nary_op): Value-number multiplications
and divisions to negates of available negated forms.

* gcc.dg/tree-ssa/ssa-fre-88.c: New testcase.

3 years agoFix assertion checking failure with tail call
Eric Botcazou [Thu, 17 Sep 2020 10:58:02 +0000 (12:58 +0200)]
Fix assertion checking failure with tail call

gcc/ChangeLog:
PR middle-end/97078
* function.c (use_register_for_decl): Test cfun->tail_call_marked
for a parameter here instead of...
(assign_parm_setup_reg): ...here.

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

3 years agoAllow copying of symbolic ranges to an irange.
Aldy Hernandez [Tue, 15 Sep 2020 15:33:48 +0000 (17:33 +0200)]
Allow copying of symbolic ranges to an irange.

This fixes an ICE when trying to copy a legacy value_range containing
a symbolic to a multi-range:

min = make_ssa_name (type);
max = build_int_cst (type, 55);
value_range vv (min, max);
int_range<2> vr = vv;

gcc/ChangeLog:

* range-op.cc (multi_precision_range_tests): Normalize symbolics when copying to a
multi-range.
* value-range.cc (irange::copy_legacy_range): Add test.

3 years agoFix availability of functions in other partitions
Jan Hubicka [Thu, 17 Sep 2020 10:41:07 +0000 (12:41 +0200)]
Fix availability of functions in other partitions

* cgraph.c (cgraph_node::get_availability): Fix availability of
functions in other partitions
* varpool.c (varpool_node::get_availability): Likewise.

3 years agoaarch64: Fixed unused variable warning in aarch64-unwind.h
Wei Wentao [Thu, 17 Sep 2020 09:40:23 +0000 (10:40 +0100)]
aarch64: Fixed unused variable warning in aarch64-unwind.h

libgcc/
* config/aarch64/aarch64-unwind.h (aarch64_demangle_return_addr): Fix
unused variable warning.

3 years agofixincludes/fixfixes.c: Fix 'set but not used' warning.
Christophe Lyon [Fri, 11 Sep 2020 11:58:59 +0000 (11:58 +0000)]
fixincludes/fixfixes.c: Fix 'set but not used' warning.

pz_tmp_base and pz_tmp_dot are always set, but used only when
_PC_NAME_MAX is defined.

This patch moves their declaration and definition undef #ifdef
_PC_NAME_MAX to avoid this warning.

2020-09-11  Torbjörn SVENSSON  <torbjorn.svensson@st.com>
    Christophe Lyon  <christophe.lyon@linaro.org>

fixincludes/
* fixfixes.c (pz_tmp_base, pz_tmp_dot): Define only with
_PC_NAME_MAX.

3 years agoC-SKY: Add -msim option
Jojo R [Wed, 16 Sep 2020 11:47:41 +0000 (19:47 +0800)]
C-SKY: Add -msim option

gcc/ChangeLog:

* config/csky/csky.opt (msim): New.
* doc/invoke.texi (C-SKY Options): Document -msim.
* config/csky/csky-elf.h (LIB_SPEC): Add simulator runtime.

3 years agodoc: use @code{} instead of @samp{@command{}} around 'date %s'
Sergei Trofimovich [Fri, 11 Sep 2020 22:33:01 +0000 (23:33 +0100)]
doc: use @code{} instead of @samp{@command{}} around 'date %s'

Before the change 'man gcc' rendered "SOURCE_DATE_EPOCH" section as:
    ... the output of @command{date +%s} on GNU/Linux ...
After the change it renders as:
    ... the output of "date +%s" on GNU/Linux ...

gcc/ChangeLog:

* doc/cppenv.texi: Use @code{} instead of @samp{@command{}}
around 'date %s'.

3 years agoIf -mavx implies -mxsave, then -mno-xsave should imply -mno-avx.
liuhongt [Wed, 16 Sep 2020 05:56:30 +0000 (13:56 +0800)]
If -mavx implies -mxsave, then -mno-xsave should imply -mno-avx.

Current status is -mno-avx implies -mno-xsave which should be wrong.

gcc/ChangeLog

* common/config/i386/i386-common.c
(OPTION_MASK_ISA_AVX_UNSET): Remove OPTION_MASK_ISA_XSAVE_UNSET.
(OPTION_MASK_ISA_XSAVE_UNSET): Add OPTION_MASK_ISA_AVX_UNSET.

gcc/testsuite/ChangeLog

* gcc.target/i386/xsave-avx-1.c: New test.

3 years agoDaily bump.
GCC Administrator [Thu, 17 Sep 2020 00:16:31 +0000 (00:16 +0000)]
Daily bump.

3 years agolibbacktrace: use ELF symbol table if no debug info available
Ian Lance Taylor [Thu, 17 Sep 2020 00:03:52 +0000 (17:03 -0700)]
libbacktrace: use ELF symbol table if no debug info available

PR libbacktrace/97080
* fileline.c (backtrace_syminfo_to_full_callback): New function.
(backtrace_syminfo_to_full_error_callback): New function.
* elf.c (elf_nodebug): Call syminfo_fn if possible.
* internal.h (struct backtrace_call_full): Define.
(backtrace_syminfo_to_full_callback): Declare.
(backtrace_syminfo_to_full_error_callback): Declare.
* mtest.c (f3): Only check all[i] if data.index permits.

3 years agoanalyzer: fix state explosions due to SCC bug
David Malcolm [Wed, 16 Sep 2020 13:22:06 +0000 (09:22 -0400)]
analyzer: fix state explosions due to SCC bug

Debugging the state explosion of the very large switch statement in
gcc.dg/analyzer/pr96653.c showed that the worklist was failing to
order the exploded nodes correctly; the in-edges at the join point
after the switch were not getting processed together, but were instead
being rocessed in smaller batches, bloating the exploded graph until the
per-point limit was reached.

The root cause turned out to be a bug in creating the strongly-connected
components for the supergraph: the code was considering interprocedural
edges as well as intraprocedural edges, leading to unpredictable
misorderings of the SCC and worklist, leading to bloating of the
exploded graph.

This patch fixes the SCC creation so it only considers intraprocedural
edges within the supergraph.  It also tweaks worklist::key_t::cmp to
give higher precedence to call_string over differences within a
supernode, since enodes with different call_strings can't be merges.
In practise, none of my test cases were affected by this latter change,
though it seems to be the right thing to do.

With this patch, the very large switch statement in
gcc.dg/analyzer/pr96653.c is handled in a single call to
exploded_graph::maybe_process_run_of_before_supernode_enodes:
   merged 358 in-enodes into 2 out-enode(s) at SN: 402
and that testcase no longer hits the per-program-point limits.

gcc/analyzer/ChangeLog:
* engine.cc (strongly_connected_components::strong_connect): Only
consider intraprocedural edges when creating SCCs.
(worklist::key_t::cmp): Add comment.  Treat call_string
differences as more important than differences of program_point
within a supernode.

gcc/testsuite/ChangeLog:
PR analyzer/96653
* gcc.dg/analyzer/loop-0-up-to-n-by-1-with-iter-obj.c: Update
expected number of exploded nodes.
* gcc.dg/analyzer/malloc-vs-local-1a.c: Update expected number
of exploded nodes.
* gcc.dg/analyzer/pr96653.c: Remove -Wno-analyzer-too-complex.

3 years agoanalyzer: show SCC ids in .dot dumps
David Malcolm [Wed, 16 Sep 2020 13:12:45 +0000 (09:12 -0400)]
analyzer: show SCC ids in .dot dumps

gcc/analyzer/ChangeLog:
* engine.cc (supernode_cluster::dump_dot): Show the SCC id
in the per-supernode clusters in FILENAME.eg.dot output.
(exploded_graph_annotator::add_node_annotations):
Show the SCC of the supernode in FILENAME.supernode.eg.dot output.
* exploded-graph.h (worklist::scc_id): New.
(exploded_graph::get_scc_id): New.