platform/upstream/gcc.git
2 years ago[Ada] Return a valid value when handling Constraint_Error
Etienne Servais [Tue, 26 Oct 2021 16:08:47 +0000 (18:08 +0200)]
[Ada] Return a valid value when handling Constraint_Error

gcc/ada/

* scng.adb (Set_Start_Column): Return Column_Number'Last when
handling Constraint_Error. Plus reformat a strangely 7 level if
loop.

2 years ago[Ada] Simplify expansion of array equality
Piotr Trojanek [Tue, 26 Oct 2021 16:05:43 +0000 (18:05 +0200)]
[Ada] Simplify expansion of array equality

gcc/ada/

* exp_ch4.adb (Test_Empty_Arrays): Simplify with Evolve_Or_Else;
remove unnecessary call to Relocate_Node.
(Test_Lengths_Correspond): Likewise.

2 years ago[Ada] Reference in Unbounded_String is almost never null
Piotr Trojanek [Wed, 27 Oct 2021 08:33:32 +0000 (10:33 +0200)]
[Ada] Reference in Unbounded_String is almost never null

gcc/ada/

* libgnat/a-strunb.adb (Deallocate): Rename Reference_Copy to
Old, to make the code similar to other routines in this package.
(Realloc_For_Chunk): Use a temporary, deallocate the previous
string using a null-allowing copy of the string reference.

2 years ago[Ada] sem_util.adb: fix typos in Accessibility_Level docs
Ghjuvan Lacambre [Wed, 27 Oct 2021 08:26:00 +0000 (10:26 +0200)]
[Ada] sem_util.adb: fix typos in Accessibility_Level docs

gcc/ada/

* sem_util.adb (Accessibility_Level): Fix typos.

2 years ago[Ada] Document the SuSE kernel bug
Tom Tromey [Wed, 6 Oct 2021 20:11:24 +0000 (14:11 -0600)]
[Ada] Document the SuSE kernel bug

gcc/ada/

* doc/gnat_ugn/platform_specific_information.rst: Document the
SuSE kernel bug.
* gnat_ugn.texi: Regenerate.

2 years ago[Ada] Errors on globals in expressions of predicate aspects in generic bodies
Gary Dismukes [Tue, 26 Oct 2021 00:45:50 +0000 (20:45 -0400)]
[Ada] Errors on globals in expressions of predicate aspects in generic bodies

gcc/ada/

* sem_ch13.adb (Freeze_Entity_Checks): Analyze the expression of
a pragma Predicate associated with an aspect at the freeze point
of the type, to ensure that references to globals get saved when
the aspect occurs within a generic body. Also, add
Aspect_Static_Predicate to the choices of the membership test of
the enclosing guard.

2 years ago[Ada] Tune comment about expansion of array equality
Piotr Trojanek [Tue, 26 Oct 2021 15:57:59 +0000 (17:57 +0200)]
[Ada] Tune comment about expansion of array equality

gcc/ada/

* exp_ch4.adb (Arr_Attr): Refine type of the parameter from Int
to Pos; refine name of the parameter from Num to Dim; fix
reference to "Expr" in comment.

2 years ago[Ada] Add missing regular expression syntax error check
Steve Baird [Thu, 21 Oct 2021 17:47:06 +0000 (10:47 -0700)]
[Ada] Add missing regular expression syntax error check

gcc/ada/

* libgnat/s-regexp.adb (Compile.Check_Well_Formed_Patern): When
a "|" operator is encountered in a pattern, check that it is not
the last character of the pattern.

2 years ago[Ada] Complete support for prefixed call on subtypes/derived types
Yannick Moy [Tue, 26 Oct 2021 10:21:40 +0000 (12:21 +0200)]
[Ada] Complete support for prefixed call on subtypes/derived types

gcc/ada/

* sem_ch3.adb (Analyze_Subtype_Declaration,
Derived_Type_Declaration): Initialize list of primitive
operations when Extensions_Allowed.

2 years ago[Ada] Fix detection of array aggregates with single others associations
Piotr Trojanek [Mon, 25 Oct 2021 19:15:58 +0000 (21:15 +0200)]
[Ada] Fix detection of array aggregates with single others associations

gcc/ada/

* checks.adb (Apply_Constraint_Check): Guard against calling
Choices when the first association in an array aggregate is a
N_Iterated_Component_Association node.

2 years ago[Ada] Fix support for prefixed call with incomplete type declarations
Yannick Moy [Mon, 25 Oct 2021 10:48:22 +0000 (12:48 +0200)]
[Ada] Fix support for prefixed call with incomplete type declarations

gcc/ada/

* sem_ch3.adb (Analyze_Incomplete_Type_Decl): Add the missing
initialization.

2 years ago[Ada] Guard against illegal items in Global but not Depends
Piotr Trojanek [Mon, 25 Oct 2021 14:33:24 +0000 (16:33 +0200)]
[Ada] Guard against illegal items in Global but not Depends

gcc/ada/

* sem_prag.adb (Check_Usage): Guard against calling Usage_Error
with illegal Item_Id. The intention to do this was already
described in the comment but not implemented.

2 years ago[Ada] Build activation chain for BIP only when needed
Etienne Servais [Wed, 22 Sep 2021 15:20:27 +0000 (17:20 +0200)]
[Ada] Build activation chain for BIP only when needed

gcc/ada/

* exp_ch6.adb (Expand_Actuals): Add a condition to check for the
possibility of task.

2 years agoConvert strlen pass from evrp to ranger.
Aldy Hernandez [Fri, 8 Oct 2021 13:54:23 +0000 (15:54 +0200)]
Convert strlen pass from evrp to ranger.

The following patch converts the strlen pass from evrp to ranger,
leaving DOM as the last remaining user.

No additional cleanups have been done.  For example, the strlen pass
still has uses of VR_ANTI_RANGE, and the sprintf still passes around
pairs of integers instead of using a proper range.  Fixing this
could further improve these passes.

Basically the entire patch is just adjusting the calls to range_of_expr
to include context.  The previous context of si->stmt was mostly
empty, so not really useful ;-).

With ranger we are now able to remove the range calculation from
before_dom_children entirely.  Just working with the ranger on-demand
catches all the strlen and sprintf testcases with the exception of
builtin-sprintf-warn-22.c which is due to a limitation of the sprintf
code.  I have XFAILed the test and documented what the problem is.

On a positive note, these changes found two possible sprintf overflow
bugs in the C++ and Fortran front-ends which I have fixed below.

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-ssa-strlen.c (compare_nonzero_chars): Pass statement
context to ranger.
(get_addr_stridx): Same.
(get_stridx): Same.
(get_range_strlen_dynamic): Same.
(handle_builtin_strlen): Same.
(handle_builtin_strchr): Same.
(handle_builtin_strcpy): Same.
(maybe_diag_stxncpy_trunc): Same.
(handle_builtin_stxncpy_strncat): Same.
(handle_builtin_memcpy): Same.
(handle_builtin_strcat): Same.
(handle_alloc_call): Same.
(handle_builtin_memset): Same.
(handle_builtin_string_cmp): Same.
(handle_pointer_plus): Same.
(count_nonzero_bytes_addr): Same.
(count_nonzero_bytes): Same.
(handle_store): Same.
(fold_strstr_to_strncmp): Same.
(handle_integral_assign): Same.
(check_and_optimize_stmt): Same.
(class strlen_dom_walker): Replace evrp with ranger.
(strlen_dom_walker::before_dom_children): Remove evrp.
(strlen_dom_walker::after_dom_children): Remove evrp.
* gimple-ssa-warn-access.cc (maybe_check_access_sizes):
Restrict sprintf output.

gcc/cp/ChangeLog:

* ptree.c (cxx_print_xnode): Add more space to pfx array.

gcc/fortran/ChangeLog:

* misc.c (gfc_dummy_typename): Make sure ts->kind is
non-negative.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/builtin-sprintf-warn-22.c: XFAIL.

2 years agolibstdc++: only define _GLIBCXX_HAVE_TLS for VxWorks >= 6.6
Rasmus Villemoes [Fri, 5 Nov 2021 14:37:33 +0000 (15:37 +0100)]
libstdc++: only define _GLIBCXX_HAVE_TLS for VxWorks >= 6.6

According to
https://gcc.gnu.org/legacy-ml/gcc-patches/2008-03/msg01698.html, the
TLS support, including the __tls_lookup function, was added to VxWorks
in 6.6.

It certainly doesn't exist on our VxWorks 5 platform, but the fallback
code in eh_globals.cc using __gthread_key_create() etc. used to work
just fine.

libstdc++-v3/ChangeLog:

* config/os/vxworks/os_defines.h (_GLIBCXX_HAVE_TLS): Only
define for VxWorks >= 6.6.

2 years agoFix clang -Wcast-qual warning.
Martin Liska [Tue, 9 Nov 2021 08:46:09 +0000 (09:46 +0100)]
Fix clang -Wcast-qual warning.

gcc/ChangeLog:

* genconditions.c (write_one_condition): Add const qualifier
to pointer casting.

2 years agoMinor optimization of variable bit testing
Jeff Law [Tue, 9 Nov 2021 04:23:34 +0000 (23:23 -0500)]
Minor optimization of variable bit testing

gcc/
* match.pd: New pattern to simplify (1 << n) & M ==/!= 0 for M
being a power of 2.

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

2 years agoDaily bump.
GCC Administrator [Tue, 9 Nov 2021 00:16:21 +0000 (00:16 +0000)]
Daily bump.

2 years agors6000: Add escape-newline support for builtins files
Bill Schmidt [Mon, 8 Nov 2021 21:08:59 +0000 (15:08 -0600)]
rs6000: Add escape-newline support for builtins files

2021-11-08  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/rs6000-builtin-new.def (VEC_INIT_V16QI): Use
escape-newline support.
(VEC_INIT_V4SI): Likewise.
(VEC_INIT_V8HI): Likewise.
(PACK_V1TI): Likewise.
(DIVDEU): Likewise.
(VFIRSTMISMATCHOREOSINDEX_V16QI): Likewise.
(VFIRSTMISMATCHOREOSINDEX_V8HI): Likewise.
(VFIRSTMISMATCHOREOSINDEX_V4SI): Likewise.
(CMPRB2): Likewise.
(VSTDCP): Likewise.
(VSIEDP): Likewise.
(FMAF128_ODD): Likewise.
(VSCEQPUO): Likewise.
(VSIEQP): Likewise.
(VSIEQPF): Likewise.
(VSTDCQP): Likewise.
(PACK_TD): Likewise.
(TABORTDC): Likewise.
(TABORTDCI): Likewise.
(SE_LXVRBX): Likewise.
(SE_LXVRHX): Likewise.
(SE_LXVRWX): Likewise.
(SE_LXVRDX): Likewise.
(VREPLACE_UN_UV2DI): Likewise.
(VREPLACE_UN_UV4SI): Likewise.
(VREPLACE_UN_V2DI): Likewise.
(VREPLACE_ELT_UV2DI): Likewise.
(VREPLACE_ELT_V2DI): Likewise.
(ZE_LXVRBX): Likewise.
(ZE_LXVRHX): Likewise.
(ZE_LXVRWX): Likewise.
(ZE_LXVRDX): Likewise.
(CFUGED): Likewise.
(CNTLZDM): Likewise.
(CNTTZDM): Likewise.
(PDEPD): Likewise.
(PEXTD): Likewise.
(PMXVBF16GER2): Likewise.
(PMXVBF16GER2_INTERNAL): Likewise.
(PMXVBF16GER2NN): Likewise.
(PMXVBF16GER2NN_INTERNAL): Likewise.
(PMXVBF16GER2NP): Likewise.
(PMXVBF16GER2NP_INTERNAL): Likewise.
(PMXVBF16GER2PN): Likewise.
(PMXVBF16GER2PN_INTERNAL): Likewise.
(PMXVBF16GER2PP): Likewise.
(PMXVBF16GER2PP_INTERNAL): Likewise.
(PMXVF16GER2): Likewise.
(PMXVF16GER2_INTERNAL): Likewise.
(PMXVF16GER2NN): Likewise.
(PMXVF16GER2NN_INTERNAL): Likewise.
(PMXVF16GER2NP): Likewise.
(PMXVF16GER2NP_INTERNAL): Likewise.
(PMXVF16GER2PN): Likewise.
(PMXVF16GER2PN_INTERNAL): Likewise.
(PMXVF16GER2PP): Likewise.
(PMXVF16GER2PP_INTERNAL): Likewise.
(PMXVF32GER_INTERNAL): Likewise.
(PMXVF32GERNN): Likewise.
(PMXVF32GERNN_INTERNAL): Likewise.
(PMXVF32GERNP): Likewise.
(PMXVF32GERNP_INTERNAL): Likewise.
(PMXVF32GERPN): Likewise.
(PMXVF32GERPN_INTERNAL): Likewise.
(PMXVF32GERPP): Likewise.
(PMXVF32GERPP_INTERNAL): Likewise.
(PMXVF64GER): Likewise.
(PMXVF64GER_INTERNAL): Likewise.
(PMXVF64GERNN): Likewise.
(PMXVF64GERNN_INTERNAL): Likewise.
(PMXVF64GERNP): Likewise.
(PMXVF64GERNP_INTERNAL): Likewise.
(PMXVF64GERPN): Likewise.
(PMXVF64GERPN_INTERNAL): Likewise.
(PMXVF64GERPP): Likewise.
(PMXVF64GERPP_INTERNAL): Likewise.
(PMXVI16GER2): Likewise.
(PMXVI16GER2_INTERNAL): Likewise.
(PMXVI16GER2PP): Likewise.
(PMXVI16GER2PP_INTERNAL): Likewise.
(PMXVI16GER2S): Likewise.
(PMXVI16GER2S_INTERNAL): Likewise.
(PMXVI16GER2SPP): Likewise.
(PMXVI16GER2SPP_INTERNAL): Likewise.
(PMXVI4GER8): Likewise.
(PMXVI4GER8_INTERNAL): Likewise.
(PMXVI4GER8PP): Likewise.
(PMXVI4GER8PP_INTERNAL): Likewise.
(PMXVI8GER4): Likewise.
(PMXVI8GER4_INTERNAL): Likewise.
(PMXVI8GER4PP): Likewise.
(PMXVI8GER4PP_INTERNAL): Likewise.
(PMXVI8GER4SPP): Likewise.
(PMXVI8GER4SPP_INTERNAL): Likewise.
* config/rs6000/rs6000-gen-builtins.c (MAXLINES): New macro.
(linebuf): Increase size.
(lines): New variable.
(lastline): Likewise.
(real_line_pos): New function.
(diag): Change signature.
(bif_diag): Change signature; support escape-newline handling.
(ovld_diag): Likewise.
(fatal): Move earlier.
(consume_whitespace): Adjust diag call.
(advance_line): Add escape-newline handling; call fatal.
(safe_inc_pos): Adjust diag call.
(match_identifier): Likewise.
(match_integer): Likewise.
(match_to_right_bracket): Call fatal instead of diag; adjust diag
call.
(match_basetype): Adjust diag calls.
(match_bracketed_pair): Likewise.
(match_const_restriction): Likewise.
(match_type): Likewise.
(parse_args): Likewise.
(parse_bif_attrs): Likewise.
(complete_vector_type): Likewise.
(complete_base_type): Likewise.
(parse_prototype): Likewise.
(parse_bif_entry): Likewise.
(parse_bif_stanza): Likewise.
(parse_ovld_entry): Likewise.
(parse_ovld_stanza): Likewise.
(main): Allocate buffers for lines[].

2 years agoFix couple of issues in large PIC model on x86-64/VxWorks
Eric Botcazou [Mon, 8 Nov 2021 21:09:16 +0000 (22:09 +0100)]
Fix couple of issues in large PIC model on x86-64/VxWorks

The first issue is that the !gotoff_operand path of legitimize_pic_address
in the large PIC model does not make use of REG when it is available, which
breaks for thunks because new pseudo-registers can no longer be created.
And the second issue is that the system compiler (LLVM) generates @GOTOFF
in large model even for RTP, so we do the same.

gcc/
* config/i386/i386.c (legitimize_pic_address): Adjust comment and
use the REG argument on the CM_LARGE_PIC code path as well.
* config/i386/predicates.md (gotoff_operand): Do not treat VxWorks
specially with the large code models.

2 years agoRemove workaround allowing interposition of nested functions.
Jan Hubicka [Mon, 8 Nov 2021 17:58:03 +0000 (18:58 +0100)]
Remove workaround allowing interposition of nested functions.

* gimple.c (gimple_call_static_chain_flags): Revert the workaround
allowing interposition since issues with binds_to_local_def were
hopefully solved.

2 years agoDon't calculate new values when using the private context callback.
Andrew MacLeod [Mon, 8 Nov 2021 14:32:42 +0000 (09:32 -0500)]
Don't calculate new values when using the private context callback.

When using rangers private callback mechanism to provide context
to fold_stmt calls, we are only suppose to be using the cache in read
only mode, never calculate new values.

gcc/
PR tree-optimization/103122
* gimple-range.cc (gimple_ranger::range_of_expr): Request the cache
entry with "calulate new values" set to false.

gcc/testsuite/
* g++.dg/pr103122.C: New.

2 years agoImprove handling of some builtins.
Jan Hubicka [Mon, 8 Nov 2021 17:40:17 +0000 (18:40 +0100)]
Improve handling of some builtins.

For nested functions we output call to builtin_dwarf_cfa which
initializes frame entry used only for debugging.  This however
prevents us from detecting functions containing nested functions
as const/pure or analyze side effects in modref.

builtin_dwarf_cfa is not documented and I wonder if it should be turned to
internal function. But I think we could consider functions using it const even
if in theory one can do things like test the return address and see the
difference between different frame addreses.

While doing so I also noticed that special_buitin_state handles quite few
builtins that are not special cased by ipa-modref.  They do not make
user visible loads/stores and thus I think they shoul dbe annotated by
".c" to make this explicit for both modref and PTA.

Finally I aded dwarf_cfa and similar return_address to list of simple
bulitins since it compiles to simple stack frame load (and we consider
simple other builtins doing so).

* builtins.c (is_simple_builtin): Add builitin_dwarf_cfa
and builtin_return_address.
(builtin_fnspec): Annotate builtin_return,
bulitin_eh_pointer, builtin_eh_filter, builtin_unwind_resume,
builtin_cxa_end_cleanup, builtin_eh_copy_values,
builtin_frame_address, builtin_apply_args,
builtin_asan_before_dynamic_init, builtin_asan_after_dynamic_init,
builtin_prefetch, builtin_dwarf_cfa, builtin_return_addrss
as ".c"
* ipa-pure-const.c (special_builtin_state): Add builtin_dwarf_cfa
and builtin_return_address.

2 years agoMove uncprop after modref
Jan Hubicka [Mon, 8 Nov 2021 17:38:09 +0000 (18:38 +0100)]
Move uncprop after modref

moveS uncprop after modref and pure/const pass and adds a comment that
this pass should alwasy be last since it is only supposed to help PHI lowering.
The pass replaces constant by SSA names that are known to be constant at the
place which hardly helps other passes.

gcc/ChangeLog:

PR tree-optimization/103177
* passes.def: Move uncprop after pure/const and modref.

2 years agoipa: Unshare expresseions before putting them into debug statements (PR 103099, PR...
Martin Jambor [Mon, 8 Nov 2021 16:49:54 +0000 (17:49 +0100)]
ipa: Unshare expresseions before putting them into debug statements (PR 103099, PR 103107)

My recent patch to improve debug experience when there are removed
parameters (by ipa-sra or ipa-split) was not careful to unshare the
expressions that were then put into debug statements, which manifests
itself as PR 103099.  This patch adds unsharing them using
unshare_expr_without_location which is a bit more careful with stripping
locations than what we were doing manually and so also fixes PR 103107.

gcc/ChangeLog:

2021-11-08  Martin Jambor  <mjambor@suse.cz>

PR ipa/103099
PR ipa/103107
* tree-inline.c (remap_gimple_stmt): Unshare the expression without
location before invoking remap_with_debug_expressions on it.
* ipa-param-manipulation.c
(ipa_param_body_adjustments::prepare_debug_expressions): Likewise.

gcc/testsuite/ChangeLog:

2021-11-08  Martin Jambor  <mjambor@suse.cz>

PR ipa/103099
PR ipa/103107
* g++.dg/ipa/pr103099.C: New test.
* gcc.dg/ipa/pr103107.c: Likewise.

2 years agopowerpc: Fix vsx_splat_v4si_di breakage on Power8.
David Edelsohn [Mon, 8 Nov 2021 16:46:47 +0000 (11:46 -0500)]
powerpc: Fix vsx_splat_v4si_di breakage on Power8.

The vsx_splat_v4si_di pattern uses a Power8 and a Power9 instruction.
The final condition of TARGET_DIRECT_MODE_64BIT implicitly requires Power8.
The "we" constraint requires Power9, but also requires 64 bit. Because
the DImode pattern already requires 64 bit mode, this isn't horrible,
but it would be best to remove all uses of "we" constraint.  The
mtvsrws instruction itself does not require 64 bit mode.

This patch reverts the previous change to fix the breakage.

gcc/ChangeLog:

* config/rs6000/vsx.md (vsx_splat_v4si_di): Revert "wa"
constraint to "we".

2 years agoFix spurious valgrind errors in irred loop verification
Richard Biener [Mon, 8 Nov 2021 14:21:08 +0000 (15:21 +0100)]
Fix spurious valgrind errors in irred loop verification

The sbitmap bitmap_{set,clear}_bit changes trigger spurious
uninit value use reportings from valgrind since we now
read the old value before setting/clearing a bit so
verify_loop_structures optimization to not clear the sbitmap is reported.

Fixed by using a temporary BB flag which should also be more
efficient in terms of cache re-use.

2021-11-08  Richard Biener  <rguenther@suse.de>

* cfgloop.c (verify_loop_structure): Use a temporary BB flag
instead of an sbitmap to cache irreducible state.

2 years agopath solver: Avoid recalculating ranges already in the cache.
Aldy Hernandez [Mon, 8 Nov 2021 11:13:33 +0000 (12:13 +0100)]
path solver: Avoid recalculating ranges already in the cache.

The problem here is an ordering issue with a path that starts
with 19->3:

 <bb 3> [local count: 916928331]:
  # value_20 = PHI <value_17(19), value_7(D)(17)>
  # n_27 = PHI <n_16(19), 1(17)>
  n_16 = n_27 + 4;
  value_17 = value_20 / 10000;
  if (value_20 > 42949672959999)
    goto <bb 19>; [89.00%]
  else
    goto <bb 4>; [11.00%]

The problem here is that both value_17 and value_20 are in the set of
imports we must pre-calculate.  The value_17 name occurs first in the
bitmap, so we try to resolve it first, which causes us to recursively
solve the value_20 range.  We do so correctly and put them both in the
cache.  However, when we try to solve value_20 from the bitmap, we
ignore that it already has a cached entry and try to resolve the PHI
with the wrong value of value_17:

  # value_20 = PHI <value_17(19), value_7(D)(17)>

The right thing to do is to avoid recalculating definitions already
solved.

Regstrapped and checked for # threads before and after on x86-64 Linux.

gcc/ChangeLog:

PR tree-optimization/103120
* gimple-range-path.cc (path_range_query::range_defined_in_block):
Bail if there's a cache entry.

gcc/testsuite/ChangeLog:

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

2 years agors6000: Miscellaneous uses of rs6000_builtins_decl_x
Bill Schmidt [Mon, 8 Nov 2021 14:34:03 +0000 (08:34 -0600)]
rs6000: Miscellaneous uses of rs6000_builtins_decl_x

There are a few leftover places where we use the old rs6000_builtins_decl
array, but we need to use rs6000_builtins_decl_x instead when the new
builtins infrastructure is in play.

2021-11-08  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/rs6000.c (rs6000_builtin_reciprocal): Use
rs6000_builtin_decls_x when appropriate.
(add_condition_to_bb): Likewise.
(rs6000_atomic_assign_expand_fenv): Likewise.

2 years agors6000: Update rs6000_builtin_decl
Bill Schmidt [Mon, 8 Nov 2021 14:17:53 +0000 (08:17 -0600)]
rs6000: Update rs6000_builtin_decl

Create a new version of this function that uses the new infrastructure,
and particularly checks for supported builtins the new way.

2021-11-08  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/rs6000-call.c (rs6000_new_builtin_decl): New function.
(rs6000_builtin_decl): Call it.

2 years agoFix static chain dump.
Martin Liska [Mon, 8 Nov 2021 11:57:08 +0000 (12:57 +0100)]
Fix static chain dump.

gcc/ChangeLog:

* cgraph.c (cgraph_node::dump): Dump it from decl.

2 years agogcov-profile: Fix -fcompare-debug with -fprofile-generate [PR100520]
Martin Liska [Fri, 5 Nov 2021 15:50:06 +0000 (16:50 +0100)]
gcov-profile: Fix -fcompare-debug with -fprofile-generate [PR100520]

PR gcov-profile/100520

gcc/ChangeLog:

* coverage.c (coverage_compute_profile_id): Strip .gk when
compare debug is used.
* system.h (endswith): New function.

gcc/testsuite/ChangeLog:

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

2 years agoDump static chain for cgraph_node.
Martin Liska [Mon, 8 Nov 2021 09:27:47 +0000 (10:27 +0100)]
Dump static chain for cgraph_node.

gcc/ChangeLog:

* cgraph.c (cgraph_node::dump): Dump static_chain_decl.

2 years agoFix 'Copyright (C) 2020-21' into '2020-2021'
Thomas Schwinge [Fri, 22 Oct 2021 14:01:54 +0000 (16:01 +0200)]
Fix 'Copyright (C) 2020-21' into '2020-2021'

'contrib/update-copyright.py' currently complains:

    gcc/config/rs6000/rs6000-gen-builtins.c: unrecognised year: 21
    gcc/config/rs6000/rs6000-overload.def: unrecognised year: 21
    gcc/config/rs6000/rbtree.h: unrecognised year: 21
    gcc/config/rs6000/rbtree.c: unrecognised year: 21
    gcc/config/rs6000/rs6000-builtin-new.def: unrecognised year: 21

Fix up files added in commit fa5f8b49e55caf5bb341f5eb6b5ab828b9286425
"rs6000: Red-black tree implementation for balanced tree search",
commit 4a720a9547320699aceda7d2e0b08de5ab40132f
"rs6000: Add initial input files",
commit bd5b625228d545d5ecb35df24f9f094edc95e3fa
"rs6000: Initial create of rs6000-gen-builtins.c".

gcc/
* config/rs6000/rbtree.c: Fix 'Copyright (C) 2020-21' into '2020-2021'
* config/rs6000/rbtree.h: Likewise.
* config/rs6000/rs6000-builtin-new.def: Likewise.
* config/rs6000/rs6000-gen-builtins.c: Likewise.
* config/rs6000/rs6000-overload.def: Likewise.

2 years agoFix 'contrib/update-copyright.py': 'TypeError: exceptions must derive from BaseException'
Thomas Schwinge [Fri, 22 Oct 2021 13:54:42 +0000 (15:54 +0200)]
Fix 'contrib/update-copyright.py': 'TypeError: exceptions must derive from BaseException'

Running 'contrib/update-copyright.py' currently fails:

    [...]
    Traceback (most recent call last):
      File "contrib/update-copyright.py", line 365, in update_copyright
        canon_form = self.canonicalise_years (dir, filename, filter, years)
      File "contrib/update-copyright.py", line 270, in canonicalise_years
        (min_year, max_year) = self.year_range (years)
      File "contrib/update-copyright.py", line 253, in year_range
        year_list = [self.parse_year (year)
      File "contrib/update-copyright.py", line 253, in <listcomp>
        year_list = [self.parse_year (year)
      File "contrib/update-copyright.py", line 250, in parse_year
        raise self.BadYear (string)
    TypeError: exceptions must derive from BaseException

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "contrib/update-copyright.py", line 796, in <module>
        GCCCmdLine().main()
      File "contrib/update-copyright.py", line 527, in main
        self.copyright.process_tree (dir, filter)
      File "contrib/update-copyright.py", line 458, in process_tree
        self.process_file (dir, filename, filter)
      File "contrib/update-copyright.py", line 421, in process_file
        res = self.update_copyright (dir, filename, filter,
      File "contrib/update-copyright.py", line 366, in update_copyright
        except self.BadYear as e:
    TypeError: catching classes that do not inherit from BaseException is not allowed

Fix up for commit 3b25e83536bcd1b2977659a2c6d9f0f9bf2a3152
"Port update-copyright.py to Python3".

contrib/
* update-copyright.py (class BadYear): Derive from 'Exception'.

2 years agoaarch64: LD3/LD4 post-modify costs for struct modes
Richard Sandiford [Mon, 8 Nov 2021 10:36:25 +0000 (10:36 +0000)]
aarch64: LD3/LD4 post-modify costs for struct modes

The LD3/ST3 and LD4/ST4 address cost code had no test coverage (oops).
This patch fixes that and updates it for the new structure modes.
The test only covers Advanced SIMD because SVE doesn't have
post-increment forms.

gcc/
* config/aarch64/aarch64.c (aarch64_ldn_stn_vectors): New function.
(aarch64_address_cost): Use it instead of testing for CImode and
XImode directly.

gcc/testsuite/
* gcc.target/aarch64/neoverse_v1_1.c: New test.

2 years agogenmodes: Define NUM_MODE_* macros
Richard Sandiford [Mon, 8 Nov 2021 10:36:25 +0000 (10:36 +0000)]
genmodes: Define NUM_MODE_* macros

I was working on a patch that needed to calculate the number of
modes in a particular class.  It seemed better to have genmodes
generate this directly rather than do the kind of dance that
expmed.h had.

gcc/
* genmodes.c (emit_insn_modes_h): Define NUM_MODE_* macros.
* expmed.h (NUM_MODE_INT): Delete in favor of genmodes definitions.
(NUM_MODE_PARTIAL_INT, NUM_MODE_VECTOR_INT): Likewise.
* real.h (real_format_for_mode): Use NUM_MODE_FLOAT and
NUM_MODE_DECIMAL_FLOAT.
(REAL_MODE_FORMAT): Likewise.

2 years ago[vect] Consider outside costs earlier for epilogue loops
Andre Vieira [Mon, 8 Nov 2021 09:35:45 +0000 (09:35 +0000)]
[vect] Consider outside costs earlier for epilogue loops

gcc/ChangeLog:

* tree-vect-loop.c (vect_better_loop_vinfo_p): Change how epilogue loop
costs are compared.

2 years agotree-optimization/103102 - fix error in vectorizer refactoring
Richard Biener [Mon, 8 Nov 2021 08:08:12 +0000 (09:08 +0100)]
tree-optimization/103102 - fix error in vectorizer refactoring

This fixes an oversight that caused vectorized epilogues to have
versioning for niters applied.

2021-11-08  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (vect_create_loop_vinfo): Add main_loop_info
parameter.
* tree-vect-loop.c (vect_create_loop_vinfo): Likewise.  Set
LOOP_VINFO_ORIG_LOOP_INFO and conditionalize set of
LOOP_VINFO_NITERS_ASSUMPTIONS.
(vect_analyze_loop_1): Adjust.
(vect_analyze_loop): Move loop constraint setting and
SCEV/niter reset here from vect_create_loop_vinfo to perform
it only once.
(vect_analyze_loop_form): Move dumping of symbolic niters
here from vect_create_loop_vinfo.

2 years agoAdd loads/stores relative to static chain in ipa-modref
Jan Hubicka [Mon, 8 Nov 2021 06:52:45 +0000 (07:52 +0100)]
Add loads/stores relative to static chain in ipa-modref

Adds tracking of accesses relative to static chain into modref
load/stores analysis.  This helps some Fortran benchmarks however it is still
quite limited.  One problem is that we never discover functions with nested
functions as const, pure or not accessing global memory because it contains
__builtin_dward_cfa call which we believe to be non-pure.

Bootstrapped/regtested x86_64-linux.  Plan to commit it tomorrow if there are
no complains and once periodic testers picks today modref changes.

Honza

gcc/ChangeLog:

* ipa-modref-tree.h (enum modref_special_parms): New enum.
(struct modref_access_node): update for special parms.
(struct modref_ref_node): Likewise.
(struct modref_parm_map): Likewise.
(struct modref_tree): Likewise.
* ipa-modref.c (dump_access): Likewise.
(get_access): Detect static chain.
(parm_map_for_arg): Take tree as arg instead of
stmt and index.
(merge_call_side_effects): Compute map for static chain.
(process_fnspec): Update.
(struct escape_point): Remove retslot_arg and static_chain_arg.
(analyze_parms): Update.
(compute_parm_map): Update.
(propagate_unknown_call): Update.
(modref_propagate_in_scc): Update.
(modref_merge_call_site_flags): Update.
(ipa_merge_modref_summary_after_inlining): Update.
* tree-ssa-alias.c (modref_may_conflict): Handle static chain.
* ipa-modref-tree.c (test_merge): Update.

gcc/testsuite/ChangeLog:

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

2 years agoDisables gimple folding for VSX_BUILTIN_XVMINDP, VSX_BUILTIN_XVMAXDP,ALTIVEC_BUILTIN_...
Haochen Gui [Tue, 2 Nov 2021 06:09:32 +0000 (14:09 +0800)]
Disables gimple folding for VSX_BUILTIN_XVMINDP, VSX_BUILTIN_XVMAXDP,ALTIVEC_BUILTIN_VMINFP and ALTIVEC_BUILTIN_VMAXFP when fast-math is not set.

gcc/
* config/rs6000/rs6000-call.c (rs6000_gimple_fold_builtin): Disable
gimple fold for VSX_BUILTIN_XVMINDP, ALTIVEC_BUILTIN_VMINFP,
VSX_BUILTIN_XVMAXDP, ALTIVEC_BUILTIN_VMAXFP when fast-math is not
set.

gcc/testsuite/
* gcc.target/powerpc/vec-minmax-1.c: New test.
* gcc.target/powerpc/vec-minmax-2.c: Likewise.

2 years agoUpdate documentation for -ftree-loop-vectorize and -ftree-slp-vectorize which are...
liuhongt [Fri, 5 Nov 2021 02:41:22 +0000 (10:41 +0800)]
Update documentation for -ftree-loop-vectorize and -ftree-slp-vectorize which are enabled by default at -02.

gcc/ChangeLog:

PR tree-optimization/103077
* doc/invoke.texi (Options That Control Optimization):
Update documentation for -ftree-loop-vectorize and
-ftree-slp-vectorize which are enabled by default at -02.

2 years agoAdd !HONOR_SNANS to simplifcation: (trunc)copysign((extend)a, (extend)b) to copysign...
liuhongt [Mon, 8 Nov 2021 01:32:17 +0000 (09:32 +0800)]
Add !HONOR_SNANS to simplifcation: (trunc)copysign((extend)a, (extend)b) to copysign (a, b).

> Note that this is not safe with -fsignaling-nans, so needs to be disabled
> for that option (if there isn't already logic somewhere with that effect),
> because the extend will convert a signaling NaN to quiet (raising
> "invalid"), but copysign won't, so this transformation could result in a
> signaling NaN being wrongly returned when the original code would never
> have returned a signaling NaN.
>
> --
> Joseph S. Myers
> joseph@codesourcery.com

gcc/ChangeLog

PR target/102464
* match.pd (Simplifcation (trunc)copysign((extend)a, (extend)b)
to .COPYSIGN (a, b)): Add !HONOR_SNANS.

2 years ago[Gimple] Simplify (trunc)fma ((extend)a, (extend)b, (extend)c) to IFN_FMA (a,b, c).
liuhongt [Mon, 8 Nov 2021 01:19:29 +0000 (09:19 +0800)]
[Gimple] Simplify (trunc)fma ((extend)a, (extend)b, (extend)c) to IFN_FMA (a,b, c).

a, b, c are same type as truncation type and has less precision than
extend type, the optimization is guarded under
flag_unsafe_math_optimizations.

gcc/ChangeLog:
PR target/102464
* match.pd: Simplify
(trunc)fma ((extend)a, (extend)b, (extend)c) to IFN_FMA (a, b,
c) under flag_unsafe_math_optimizations.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr102464-fma.c: New test.

2 years agoDaily bump.
GCC Administrator [Mon, 8 Nov 2021 00:16:17 +0000 (00:16 +0000)]
Daily bump.

2 years agoFix keyword name for co_reduce.
Thomas Koenig [Sun, 7 Nov 2021 14:38:35 +0000 (15:38 +0100)]
Fix keyword name for co_reduce.

gcc/fortran/ChangeLog:

* intrinsic.c (add_subroutines): Change keyword "operator"
to the correct one, "operation".
* check.c (gfc_check_co_reduce): Change OPERATOR to
OPERATION in error messages.
* intrinsic.texi: Change OPERATOR to OPERATION in
documentation.

gcc/testsuite/ChangeLog:

* gfortran.dg/co_reduce_2.f90: New test.
* gfortran.dg/coarray_collectives_14.f90: Change OPERATOR
to OPERATION.
* gfortran.dg/coarray_collectives_16.f90: Likewise.
* gfortran.dg/coarray_collectives_9.f90: Likewise.

Co-authored by: Steve Kargl <steve@gcc.gnu.org>

2 years agoLimit range of modref-max-depth
Jan Hubicka [Sun, 7 Nov 2021 21:58:19 +0000 (22:58 +0100)]
Limit range of modref-max-depth

gcc/ChangeLog:

PR ipa/103055
* params.opt (modref-max-depth): Add range.
(modref-max-adjustments): Fix range.

2 years agoRemove VRP threader.
Aldy Hernandez [Mon, 1 Nov 2021 14:50:38 +0000 (15:50 +0100)]
Remove VRP threader.

Now that things have stabilized, we can remove the old code.

I have left the hybrid threader in tree-ssa-threadedge, even though the
VRP threader was the only user, because we may need it as an interim
step for DOM threading removal.

Tested on x86-64 Linux.

gcc/ChangeLog:

* tree-pass.h (make_pass_vrp_threader): Remove.
* tree-ssa-threadbackward.c
(back_threader_profitability::profitable_path_p): Remove
ASSERT_EXPR references.
* tree-ssa-threadedge.c (jt_state::register_equivs_stmt): Same.
* tree-vrp.c (vrp_folder::simplify_casted_conds): Same.
(execute_vrp): Same.
(class hybrid_threader): Remove.
(hybrid_threader::hybrid_threader): Remove.
(hybrid_threader::~hybrid_threader): Remove.
(hybrid_threader::before_dom_children): Remove.
(hybrid_threader::after_dom_children): Remove.
(execute_vrp_threader): Remove.
(class pass_vrp_threader): Remove.
(make_pass_vrp_threader): Remove.

2 years agoFortran: Diagnose all operands/arguments with constraint violations
Sandra Loosemore [Thu, 4 Nov 2021 22:43:29 +0000 (15:43 -0700)]
Fortran: Diagnose all operands/arguments with constraint violations

04-Nov-2021  Sandra Loosemore <sandra@codesourcery.com>
     Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

 PR fortran/101337

gcc/fortran/ChangeLog:
* interface.c (gfc_compare_actual_formal): Continue checking
all arguments after encountering an error.
* intrinsic.c (do_ts29113_check): Likewise.
* resolve.c (resolve_operator): Continue resolving on op2 error.

gcc/testsuite/ChangeLog:
* gfortran.dg/bessel_3.f90: Expect additional diagnostics from
multiple bad arguments in the call.
* gfortran.dg/pr24823.f: Likewise.
* gfortran.dg/pr39937.f: Likewise.
* gfortran.dg/pr41011.f: Likewise.
* gfortran.dg/pr61318.f90: Likewise.
* gfortran.dg/c-interop/c407b-2.f90: Remove xfails.
* gfortran.dg/c-interop/c535b-2.f90: Likewise.

2 years agoFix inter-procedural EAF flags propagation with respect to !binds_to_current_def_p
Jan Hubicka [Sun, 7 Nov 2021 17:20:45 +0000 (18:20 +0100)]
Fix inter-procedural EAF flags propagation with respect to !binds_to_current_def_p

While proofreading the code for handling EAF flags of !binds_to_current_def_p I
noticed that the interprocedural dataflow actually ignores the flag possibly
introducing wrong code on quite complex interposable functions in non-trivial
recursion cycles (or at ltrans partition boundary).

This patch unifies the flags changes to single place (remove_useless_eaf_flags)
and does extend modref_merge_call_site_flags to do the right thing.

lto-bootstrapped/regtested x86_64-linux.  Plan to commit it today after bit
more testing (firefox/clang build).

gcc/ChangeLog:

* gimple.c (gimple_call_arg_flags): Use interposable_eaf_flags.
(gimple_call_retslot_flags): Likewise.
(gimple_call_static_chain_flags): Likewise.
* ipa-modref.c (remove_useless_eaf_flags): Do not remove everything for
NOVOPS.
(modref_summary::useful_p): Likewise.
(modref_summary_lto::useful_p): Likewise.
(analyze_parms): Do not give up on NOVOPS.
(analyze_function): When dumping report chnages in EAF flags
between IPA and local pass.
(modref_merge_call_site_flags): Compute implicit eaf flags
based on callee ecf_flags and fnspec; if the function does not
bind to current defs use interposable_eaf_flags.
(modref_propagate_flags_in_scc): Update.
* ipa-modref.h (interposable_eaf_flags): New function.

2 years agors6000: Replace the builtin expansion machinery
Bill Schmidt [Sun, 7 Nov 2021 13:56:07 +0000 (07:56 -0600)]
rs6000: Replace the builtin expansion machinery

This patch forms the meat of the improvements for this patch series.
We develop a replacement for rs6000_expand_builtin and its supporting
functions, which are inefficient and difficult to maintain.

Differences between the old and new support in this patch include:
 - Make use of the new builtin data structures, directly looking up
   a function's information rather than searching for the function
   multiple times;
 - Test for enablement of builtins at expand time, to support #pragma
   target changes within a compilation unit;
 - Use the builtin function attributes (e.g., bif_is_cpu) to control
   special handling;
 - Refactor common code into one place; and
 - Provide common error handling in one place for operands that are
   restricted to specific values or ranges.

2021-11-07  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/rs6000-call.c (rs6000_expand_new_builtin): New
forward decl.
(rs6000_invalid_new_builtin): New function.
(rs6000_expand_builtin): Call rs6000_expand_new_builtin.
(rs6000_expand_ldst_mask): New function.
(new_cpu_expand_builtin): Likewise.
(elemrev_icode): Likewise.
(ldv_expand_builtin): Likewise.
(lxvrse_expand_builtin): Likewise.
(lxvrze_expand_builtin): Likewise.
(stv_expand_builtin): Likewise.
(new_mma_expand_builtin): Likewise.
(new_htm_spr_num): Likewise.
(new_htm_expand_builtin): Likewise.
(rs6000_expand_new_builtin): Likewise.
(rs6000_init_builtins): Initialize altivec_builtin_mask_for_load.

2 years agoImplement intra-procedural dataflow in ipa-modref flags propagation.
Jan Hubicka [Sun, 7 Nov 2021 08:35:16 +0000 (09:35 +0100)]
Implement intra-procedural dataflow in ipa-modref flags propagation.

implement the (long promised) intraprocedural dataflow for
propagating eaf flags, so we can handle parameters that participate
in loops in SSA graphs. Typical example are acessors that walk linked
lists, for example.

I implemented dataflow using the standard iteration over BBs in RPO some time
ago, but did not like it becuase it had measurable compile time impact with
very small code quality effect. This is why I kept mainline to do the DFS walk
instead. The reason is that we care about flags of SSA names that corresponds
to parameters and those can be often determined from a small fraction of the
SSA graph so solving dataflow for all SSA names in a function is a waste.

This patch implements dataflow more carefully.  The DFS walk is kept in place to
solve acyclic cases and discover the relevat part of SSA graph into new graph
(which is similar to one used for inter-procedrual dataflow - we only need to
know the edges and if the access is direct or derefernced).  The RPO iterative
dataflow then works on this simplified graph.

This seems to be fast in practice. For GCC linktime we do dataflow for 4881
functions. Out of that 4726 finishes in one iteration, 144 in two and 10 in 3.

Overall 31979 functions are analysed, so we do dataflow only for bit over of
10% of cases.  131123 edges are visited by the solver.  I measured no compile
time impact of this.

gcc/ChangeLog:

* ipa-modref.c (modref_lattice): Add do_dataflow,
changed and propagate_to fields.
(modref_lattice::release): Free propagate_to
(modref_lattice::merge): Do not give up early on unknown
lattice values.
(modref_lattice::merge_deref): Likewise.
(modref_eaf_analysis): Update toplevel comment.
(modref_eaf_analysis::analyze_ssa_name): Record postponned ssa names;
do optimistic dataflow initialization.
(modref_eaf_analysis::merge_with_ssa_name): Build dataflow graph.
(modref_eaf_analysis::propagate): New member function.
(analyze_parms): Update to new API of modref_eaf_analysis.

2 years agoDaily bump.
GCC Administrator [Sun, 7 Nov 2021 00:16:19 +0000 (00:16 +0000)]
Daily bump.

2 years agoFix can_be_discarded_p wrt partitioned functions.
Jan Hubicka [Sat, 6 Nov 2021 22:36:08 +0000 (23:36 +0100)]
Fix can_be_discarded_p wrt partitioned functions.

gcc/ChangeLog:

* cgraph.h (cgraph_node::can_be_discarded_p): Do not
return true on functions from other partition.

gcc/lto/ChangeLog:

PR ipa/103070
PR ipa/103058
* lto-partition.c (must_not_rename): Update comment.
(promote_symbol): Set resolution to LDPR_PREVAILING_DEF_IRONLY.

2 years agoFortran: error recovery on rank mismatch of array and its initializer
Harald Anlauf [Sat, 6 Nov 2021 18:42:01 +0000 (19:42 +0100)]
Fortran: error recovery on rank mismatch of array and its initializer

gcc/fortran/ChangeLog:

PR fortran/102715
* decl.c (add_init_expr_to_sym): Reject rank mismatch between
array and its initializer.

gcc/testsuite/ChangeLog:

PR fortran/102715
* gfortran.dg/pr68019.f90: Adjust error message.
* gfortran.dg/pr102715.f90: New test.

2 years agopowerpc: Fix vsx_splat_v4si in 32 bit mode
David Edelsohn [Sat, 6 Nov 2021 00:33:45 +0000 (20:33 -0400)]
powerpc: Fix vsx_splat_v4si in 32 bit mode

Tamar's recent patch to teach CSE to perform vector extract exercises
VSX splat more frequently, which exposed a constraint error for the
vsx_splat patterns.  The pattern could be created for Power9, but
the "we constraint only provided alternatives in 64 bit mode. The
instructions are valid in 32 bit mode and SImode is allowed in VSX
registers.  This patch updates the constraints from "we" to "wa" to
allow the pattern and fix the failing testcases.

gcc/ChangeLog:

* config/rs6000/vsx.md (vsx_splat_v4si): Change constraints to "wa".
(vsx_splat_v4si_di): Change constraint to "wa".

2 years agopath oracle: Do not look at root oracle for killed defs.
Aldy Hernandez [Fri, 5 Nov 2021 21:25:19 +0000 (22:25 +0100)]
path oracle: Do not look at root oracle for killed defs.

The problem here is that we are incorrectly threading 41->20->21 here:

  <bb 35> [local count: 56063504182]:
  _134 = M.10_120 + 1;
  if (_71 <= _134)
    goto <bb 19>; [11.00%]
  else
    goto <bb 41>; [89.00%]
...
...
...
  <bb 41> [local count: 49896518755]:

  <bb 20> [local count: 56063503181]:
  # lb_75 = PHI <_134(41), 1(18)>
  _117 = mstep_49 + lb_75;
  _118 = _117 + -1;
  _119 = mstep_49 + _118;
  M.10_120 = MIN_EXPR <_119, _71>;
  if (lb_75 > M.10_120)
    goto <bb 21>; [11.00%]
  else
    goto <bb 22>; [89.00%]

First, lb_17 == _134 because of the PHI.
Second, _134 > M.10_120 because of _134 = M.10_120 + 1.

We then assume that lb_75 > M.10_120, but this is incorrect because
M.10_120 was killed along the path.

This incorrect thread causes the miscompilation in 527.cam4_r.

Tested on x86-64 and ppc64le Linux.

gcc/ChangeLog:

PR tree-optimization/103061
* value-relation.cc (path_oracle::path_oracle): Initialize
m_killed_defs.
(path_oracle::killing_def): Set m_killed_defs.
(path_oracle::query_relation): Do not look at the root oracle for
killed defs.
* value-relation.h (class path_oracle): Add m_killed_defs.

2 years agotestsuite: Use posix_memalign on AIX for tsvc
David Edelsohn [Sat, 6 Nov 2021 15:24:08 +0000 (11:24 -0400)]
testsuite: Use posix_memalign on AIX for tsvc

AIX does not provide memalign, so the testcases much use
posix_memalign for portability on AIX.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/tsvc/tsvc.h (init): Use posix_memalign on AIX.

2 years agoCleanup back_threader::find_path_to_names.
Aldy Hernandez [Thu, 4 Nov 2021 18:44:15 +0000 (19:44 +0100)]
Cleanup back_threader::find_path_to_names.

The main path discovery function was due for a cleanup.  First,
there's a nagging goto and second, my bitmap use was sloppy.  Hopefully
this makes the code easier for others to read.

Regstrapped on x86-64 Linux.  I also made sure there were no difference
in the number of threads with this patch.

No functional changes.

gcc/ChangeLog:

* tree-ssa-threadbackward.c (back_threader::find_paths_to_names):
Remove gotos and other cleanups.

2 years agoDaily bump.
GCC Administrator [Sat, 6 Nov 2021 00:16:24 +0000 (00:16 +0000)]
Daily bump.

2 years agoFortran: fix simplification of array-valued parameter expressions
Harald Anlauf [Fri, 5 Nov 2021 22:48:20 +0000 (23:48 +0100)]
Fortran: fix simplification of array-valued parameter expressions

gcc/fortran/ChangeLog:

PR fortran/102817
* expr.c (simplify_parameter_variable): Copy shape of referenced
subobject when simplifying.

gcc/testsuite/ChangeLog:

PR fortran/102817
* gfortran.dg/pr102817.f90: New test.

2 years agoFix ice in insert_access
Jan Hubicka [Fri, 5 Nov 2021 22:32:55 +0000 (23:32 +0100)]
Fix ice in insert_access

gcc/ChangeLog:

PR ipa/103073
* ipa-modref-tree.h (modref_tree::insert): Do nothing for
paradoxical and zero sized accesses.

gcc/testsuite/ChangeLog:

PR ipa/103073
* g++.dg/torture/pr103073.C: New test.
* gcc.dg/tree-ssa/modref-11.c: New test.

2 years agoAvoid left shift of negative value in ipa-modref-tree.h
Jan Hubicka [Fri, 5 Nov 2021 22:17:50 +0000 (23:17 +0100)]
Avoid left shift of negative value in ipa-modref-tree.h

gcc/ChangeLog:

PR ipa/103082
* ipa-modref-tree.h (struct modref_access_node): Avoid left shift
of negative value

2 years agoFortran: a symbol in a COMMON cannot be a coarray
Harald Anlauf [Fri, 5 Nov 2021 22:13:57 +0000 (23:13 +0100)]
Fortran: a symbol in a COMMON cannot be a coarray

gcc/fortran/ChangeLog:

PR fortran/69419
* match.c (gfc_match_common): Check array spec of a symbol in a
COMMON object list and reject it if it is a coarray.

gcc/testsuite/ChangeLog:

PR fortran/69419
* gfortran.dg/pr69419.f90: New test.

2 years agolibstdc++: Fix inconsistent noexcept-specific for valarray begin/end
Jonathan Wakely [Fri, 5 Nov 2021 21:42:20 +0000 (21:42 +0000)]
libstdc++: Fix inconsistent noexcept-specific for valarray begin/end

These declarations should be noexcept after I added it to the
definitions in <valarray>.

libstdc++-v3/ChangeLog:

* include/bits/range_access.h (begin(valarray), end(valarray)):
Add noexcept.

2 years agolibstdc++: Fix pack expansions in tuple_size_v specializations
Jonathan Wakely [Fri, 5 Nov 2021 21:40:58 +0000 (21:40 +0000)]
libstdc++: Fix pack expansions in tuple_size_v specializations

libstdc++-v3/ChangeLog:

* include/std/tuple (tuple_size_v): Fix pack expansion.

2 years agoFortran: Missing error with IMPLICIT none (external) [PR100972]
Bernhard Reutner-Fischer [Sun, 31 Oct 2021 16:44:45 +0000 (17:44 +0100)]
Fortran: Missing error with IMPLICIT none (external) [PR100972]

gcc/fortran/ChangeLog:

PR fortran/100972
* decl.c (gfc_match_implicit_none): Fix typo in warning.
* resolve.c (resolve_unknown_f): Reject external procedures
without explicit EXTERNAL attribute whe IMPLICIT none (external)
is in effect.

gcc/testsuite/ChangeLog:

PR fortran/100972
* gfortran.dg/implicit_14.f90: Adjust error.
* gfortran.dg/external_implicit_none_3.f08: New test.

2 years agoFortran: Delete unused decl in gfortran.h
Bernhard Reutner-Fischer [Wed, 27 Oct 2021 21:01:21 +0000 (23:01 +0200)]
Fortran: Delete unused decl in gfortran.h

gcc/fortran/ChangeLog:

* decl.c (gfc_insert_kind_parameter_exprs): Make static.
* expr.c (gfc_build_init_expr): Make static
(gfc_build_default_init_expr): Move below its static helper.
* gfortran.h (gfc_insert_kind_parameter_exprs, gfc_add_saved_common,
gfc_add_common, gfc_use_derived_tree, gfc_free_charlen,
gfc_get_ultimate_derived_super_type,
gfc_resolve_oacc_parallel_loop_blocks, gfc_build_init_expr,
gfc_iso_c_sub_interface): Delete.
* symbol.c (gfc_new_charlen, gfc_get_derived_super_type): Make
static.

2 years agoFortran: Add more documentation for mixed-language programming [PR35276]
Sandra Loosemore [Fri, 5 Nov 2021 21:01:03 +0000 (14:01 -0700)]
Fortran: Add more documentation for mixed-language programming [PR35276]

2021-11-05  Sandra Loosemore  <sandra@codesourcery.com>

PR fortran/35276

gcc/fortran/
* gfortran.texi (Mixed-Language Programming): Talk about C++,
and how to link.

2 years agotestsuite, Darwin : Fix tsvc test build on Darwin.
Iain Sandoe [Fri, 5 Nov 2021 19:19:53 +0000 (19:19 +0000)]
testsuite, Darwin : Fix tsvc test build on Darwin.

Currently all the tsvc tests fail to build on Darwin because
they assume that <malloc.h> and memalign() are available.

For Darwin, <stdlib.h> is sufficient to obtain the declarations
for malloc and the port has posix_memalign () but not memalign.

Fixed as below.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/ChangeLog:

* gcc.dg/vect/tsvc/tsvc.h: Do not try to include malloc.h
on Darwin also use posix_memalign ().

2 years agoDarwin : Make trampoline templates linker-visible.
Iain Sandoe [Wed, 2 Sep 2020 19:33:00 +0000 (20:33 +0100)]
Darwin : Make trampoline templates linker-visible.

For aarch64, the alignment of the LTRAMPn symbols matters.

Actually, the LTRAMPn  symbols _are_ 8 byte aligned, but because
they are Local, the linker doesn't know that this guarantee can be met.
It assumes that they are not necessarily more aligned than the
containing section (ld64 atoms strike again).

The fix is to publish the trampoline symbol for the linker to access
directly - it can then see that the atom is suitably aligned.

Fixes issue #11 on the development branch.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* config/darwin.h (ASM_GENERATE_INTERNAL_LABEL): Add LTRAMP
to the list of symbol prefixes that must be made linker-
visible.

2 years agoDarwin, aarch64 : Ada fixes for hosted tools.
Iain Sandoe [Fri, 28 Aug 2020 18:09:45 +0000 (19:09 +0100)]
Darwin, aarch64 : Ada fixes for hosted tools.

This will allow someone (with an existing Ada compiler on the
platform - which can be provided by the experimental aarch64-darwin
branch) - to build the host tools (gnatmake and friends) for a
non-native cross.

The existing provisions for iOS are OK for cross-compilation from
an x86-64-darwin platform, but we need some adjustments so that these
host tools can be built to run on aarch64-darwin.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ada/

* gcc-interface/Make-lang.in: Use iOS signal trampoline code
for hosted Ada tools.
* sigtramp-ios.c: Wrap the declarations in extern "C" when
the code is built by a C++ compiler.

2 years agoDarwin, aarch64 : Initial support for the self-host driver.
Iain Sandoe [Tue, 18 Aug 2020 21:29:51 +0000 (22:29 +0100)]
Darwin, aarch64 : Initial support for the self-host driver.

At present, there is no special action needed for aarch64-darwin
this just pulls in generic Darwin code.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* config.host: Add support for aarch64-*-darwin.
* config/aarch64/host-aarch64-darwin.c: New file.
* config/aarch64/x-darwin: New file.

2 years agoDarwin, crts: Fix a build warning.
Iain Sandoe [Mon, 1 Nov 2021 16:58:20 +0000 (16:58 +0000)]
Darwin, crts: Fix a build warning.

We have a shim crt for Darwin10 that implements functionality
missing in libSystem. Provide this with a prototype to silence the
warning about this.

libgcc/ChangeLog:

* config/darwin10-unwind-find-enc-func.c: Include libgcc_tm.h.
* config/i386/darwin-lib.h: Declare Darwin10 crt function.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2 years agolibstdc++: Add [[unlikely]] attributes to std::random_device routines
Jonathan Wakely [Fri, 5 Nov 2021 12:18:52 +0000 (12:18 +0000)]
libstdc++: Add [[unlikely]] attributes to std::random_device routines

libstdc++-v3/ChangeLog:

* src/c++11/random.cc (__x86_rdrand, __x86_rdseed): Add
[[unlikely]] attribute.

2 years agolibstdc++: Add support for POWER9 DARN instruction to std::random_device
Jonathan Wakely [Wed, 20 Oct 2021 08:25:24 +0000 (09:25 +0100)]
libstdc++: Add support for POWER9 DARN instruction to std::random_device

The ISA-3.0 instruction set includes DARN ("deliver a random number")
which can be used similarly to the existing support for RDRAND and RDSEED.

libstdc++-v3/ChangeLog:

* src/c++11/random.cc [__powerpc__] (USE_DARN): Define.
(__ppc_darn): New function to use POWER9 DARN instruction.
(Which): Add 'darn' enumerator.
(which_source): Check for __ppc_darn.
(random_device::_M_init): Support "darn" and "hw" tokens.
(random_device::_M_getentropy): Add darn to switch.
* testsuite/26_numerics/random/random_device/cons/token.cc:
Check "darn" token.
* testsuite/26_numerics/random/random_device/entropy.cc:
Likewise.

2 years agolibsanitizer: update LOCAL_PATCHES.
Martin Liska [Fri, 5 Nov 2021 17:21:42 +0000 (18:21 +0100)]
libsanitizer: update LOCAL_PATCHES.

2 years agolibsanitizer: Apply local patches
H.J. Lu [Tue, 20 Jul 2021 17:46:51 +0000 (10:46 -0700)]
libsanitizer: Apply local patches

2 years agolibsanitizer: merge from master (78d3e0a4f1406b17cdecc77540e09210670fe9a9).
Martin Liska [Fri, 5 Nov 2021 17:11:23 +0000 (18:11 +0100)]
libsanitizer: merge from master (78d3e0a4f1406b17cdecc77540e09210670fe9a9).

2 years agoRemove def chain import assert from GORI.
Andrew MacLeod [Fri, 5 Nov 2021 15:25:09 +0000 (11:25 -0400)]
Remove def chain import assert from GORI.

When the IL has changed, any new ssa-names import calculations may not jive
with existing ssa-names, so just remove the assert.

gcc/
PR tree-optimization/103093
* gimple-range-gori.cc (range_def_chain::get_imports): Remove assert.

gcc/testsuite/
* gcc.dg/pr103093.c: New.

2 years agoAbstract ranger cache update list.
Andrew MacLeod [Thu, 4 Nov 2021 19:08:06 +0000 (15:08 -0400)]
Abstract ranger cache update list.

Make it more efficient by removing the call to vec::contains.

PR tree-optimization/102943
* gimple-range-cache.cc (class update_list): New.
(update_list::add): Replace add_to_update.
(update_list::pop): New.
(ranger_cache::ranger_cache): Adjust.
(ranger_cache::~ranger_cache): Adjust.
(ranger_cache::add_to_update): Delete.
(ranger_cache::propagate_cache): Adjust to new class.
(ranger_cache::propagate_updated_value): Ditto.
(ranger_cache::fill_block_cache): Ditto.
* gimple-range-cache.h (class ranger_cache): Adjust to update class.

2 years agoAmend split vector loop analysis into main and epilogue analysis
Richard Biener [Fri, 5 Nov 2021 14:01:49 +0000 (15:01 +0100)]
Amend split vector loop analysis into main and epilogue analysis

I forgot to commit the changes done as response to Richards review
before committing.

2021-11-05  Richard Biener  <rguenther@suse.de>

* tree-vect-loop.c (vect_analyze_loop): Remove obsolete
comment and expand on another one.  Combine nested if.

2 years agoSupport TI mode and soft float on PA64
John David Anglin [Fri, 5 Nov 2021 16:07:35 +0000 (16:07 +0000)]
Support TI mode and soft float on PA64

This change implements TI mode on PA64.  Various new patterns are
added to pa.md.  The libgcc build needed modification to build both
DI and TI routines.  We also need various softfp routines to
convert to and from TImode.

I added full softfp for the -msoft-float option.  At the moment,
this doesn't completely eliminate all use of the floating-point
co-processor.  For this, libgcc needs to be built with -msoft-mult.
The floating-point exception support also needs a soft option.

2021-11-05  John David Anglin  <danglin@gcc.gnu.org>

PR libgomp/96661

gcc/ChangeLog:

* config/pa/pa-modes.def: Add OImode integer type.
* config/pa/pa.c (pa_scalar_mode_supported_p): Allow TImode
for TARGET_64BIT.
* config/pa/pa.h (MIN_UNITS_PER_WORD) Define to MIN_UNITS_PER_WORD
to UNITS_PER_WORD if IN_LIBGCC2.
* config/pa/pa.md (addti3, addvti3, subti3, subvti3, negti2,
negvti2, ashlti3, shrpd_internal): New patterns.
Change some multi instruction types to multi.

libgcc/ChangeLog:

* config.host (hppa*64*-*-linux*): Revise tmake_file.
(hppa*64*-*-hpux11*): Likewise.
* config/pa/sfp-exceptions.c: New.
* config/pa/sfp-machine.h: New.
* config/pa/t-dimode: New.
* config/pa/t-softfp-sfdftf: New.

2 years agox86: Make stringop_algs::stringop_strategy ctor constexpr [PR100246]
Jakub Jelinek [Fri, 5 Nov 2021 15:39:14 +0000 (16:39 +0100)]
x86: Make stringop_algs::stringop_strategy ctor constexpr [PR100246]

> Several older compilers fail to build modern GCC because of missing
> or incomplete C++11 support.
>
>       * config/i386/i386.h (struct stringop_algs): Define a CTOR for
>       this type.

Unfortunately, as mentioned in my
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583289.html
mail, without the new dyninit pass this causes dynamic initialization of
many variables, 6.5KB _GLOBAL__sub_I_* on x86_64 and 12.5KB on i686.

The following patch makes the ctor constexpr so that already the FE
is able to statically initialize all those.

I have tested on godbolt a reduced testcase without a constructor,
with constructor and with constexpr constructor.
clang before 3.3 is unhappy about all the 3 cases, clang 3.3 and 3.4
is ok with ctor and ctor with constexpr and optimizes it into static
initialization, clang 3.5+ is ok with all 3 versions and optimizes,
gcc 4.8 and 5+ is ok with all 3 versions and no ctor and ctor with constexpr
is optimized, gcc 4.9 is unhappy about the no ctor case and happy with the
other two.

2021-11-05  Jakub Jelinek  <jakub@redhat.com>

PR bootstrap/100246
* config/i386/i386.h
(stringop_algs::stringop_strategy::stringop_strategy): Make the ctor
constexpr.

2 years agocontrib: testsuite-management: Update to be python3 compatible
Bernhard Reutner-Fischer [Sun, 31 Oct 2021 22:58:44 +0000 (23:58 +0100)]
contrib: testsuite-management: Update to be python3 compatible

contrib/ChangeLog:

* testsuite-management/validate_failures.py: 2to3

2 years agoAArch64: Fix PR103085
Wilco Dijkstra [Fri, 5 Nov 2021 15:05:15 +0000 (15:05 +0000)]
AArch64: Fix PR103085

The stack protector implementation hides symbols in a const unspec, which means
movdi/movsi patterns must always support const on symbol operands and
explicitly strip away the unspec. Do this for the recently added GOT
alternatives. Add a test to ensure stack-protector tests GOT accesses as well.

2021-11-05  Wilco Dijkstra  <wdijkstr@arm.com>

PR target/103085
* config/aarch64/aarch64.c (aarch64_mov_operand_p): Strip the salt
first.
* config/aarch64/constraints.md: Support const in Usw.

gcc/testsuite/
PR target/103085
* gcc.target/aarch64/pr103085.c: New test

2 years agoMove PREFERRED_DEBUGGING_TYPE define in pa64-hpux.h to pa.h
John David Anglin [Fri, 5 Nov 2021 15:05:15 +0000 (15:05 +0000)]
Move PREFERRED_DEBUGGING_TYPE define in pa64-hpux.h to pa.h

This fixes D language build on hppa64-hpux11.

2021-11-05  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.h (PREFERRED_DEBUGGING_TYPE): Define to DWARF2_DEBUG.
* config/pa/pa64-hpux.h (PREFERRED_DEBUGGING_TYPE): Remove define.

2 years agogcov-profile: Filter test only for some targets [PR102945]
Martin Liska [Fri, 5 Nov 2021 14:39:53 +0000 (15:39 +0100)]
gcov-profile: Filter test only for some targets [PR102945]

PR gcov-profile/102945

gcc/testsuite/ChangeLog:

* gcc.dg/gcov-info-to-gcda.c: Filter supported targets.

2 years agoSplit vector loop analysis into main and epilogue analysis
Richard Biener [Fri, 5 Nov 2021 09:10:46 +0000 (10:10 +0100)]
Split vector loop analysis into main and epilogue analysis

As discussed this splits the analysis loop into two, first settling
on a vector mode used for the main loop and only then analyzing
the epilogue of that for possible vectorization.  That makes it
easier to put in support for unrolled main loops.

On the way I've realized some cleanup opportunities, namely caching
n_stmts in vec_info_shared (it's computed by dataref analysis)
avoiding to pass that around and setting/clearing loop->aux
during analysis - try_vectorize_loop_1 will ultimatively set it
on those we vectorize.

This also gets rid of the previously introduced callback in
vect_analyze_loop_1 in favor of making that advance the mode iterator.
I'm now pushing VOIDmode explicitely into the vector_modes array
which makes the re-start on the epilogue side a bit more
straight-forward.  Note that will now use auto-detection of the
vector mode in case the main loop used it and we want to try
LOOP_VINFO_EPIL_USING_PARTIAL_VECTORS_P and the first mode from
the target array if not.  I've added a comment that says we may
want to make sure we don't try vectorizing the epilogue with a
bigger vector size than the main loop but the situation isn't
very likely to appear in practice I guess (and it was also present
before this change).

In principle this change should not change vectorization decisions
but the way we handled re-analyzing epilogues as main loops makes
me only 99% sure that it does.

2021-11-05  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (vec_info_shared::n_stmts): Add.
(LOOP_VINFO_N_STMTS): Likewise.
(vec_info_for_bb): Remove unused function.
* tree-vectorizer.c (vec_info_shared::vec_info_shared):
Initialize n_stmts member.
* tree-vect-loop.c: Remove INCLUDE_FUNCTIONAL.
(vect_create_loop_vinfo): Do not set loop->aux.
(vect_analyze_loop_2): Do not get n_stmts as argument,
instead use LOOP_VINFO_N_STMTS.  Set LOOP_VINFO_VECTORIZABLE_P
here.
(vect_analyze_loop_1): Remove callback, get the mode iterator
and autodetected_vector_mode as argument, advancing the
iterator and initializing autodetected_vector_mode here.
(vect_analyze_loop): Split analysis loop into two, first
processing main loops only and then epilogues.

2 years agoipa: Do not require RECORD_TYPE for ancestor jump functions
Martin Jambor [Fri, 5 Nov 2021 13:04:42 +0000 (14:04 +0100)]
ipa: Do not require RECORD_TYPE for ancestor jump functions

The check this patch removes has remained from times when ancestor
jump functions have been only used for devirtualization and also
contained BINFOs.  It is not necessary now and should have been
removed long time ago.

gcc/ChangeLog:

2021-11-04  Martin Jambor  <mjambor@suse.cz>

* ipa-prop.c (compute_complex_assign_jump_func): Remove
unnecessary check for RECORD_TYPE.

2 years agolibstdc++: Add xfail to pretty printer tests that fail in C++20
Jonathan Wakely [Fri, 5 Nov 2021 11:25:27 +0000 (11:25 +0000)]
libstdc++: Add xfail to pretty printer tests that fail in C++20

For some reason the type printer for std::string doesn't work in C++20
mode, so std::basic_string<char, char_traits<char>, allocator<char> is
printed out in full rather than being shown as std::string. It's
probably related to the fact that the extern template declarations are
disabled for C++20, but I don't know why that affects GDB.

For now I'm just marking the relevant tests as XFAIL. That requires
adding support for target selectors to individual GDB directives such as
note-test and whatis-regexp-test.

libstdc++-v3/ChangeLog:

* testsuite/lib/gdb-test.exp: Add target selector support to the
dg-final directives.
* testsuite/libstdc++-prettyprinters/80276.cc: Add xfail for
C++20.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
* testsuite/libstdc++-prettyprinters/prettyprinters.exp: Tweak
comment.

2 years agoinclude: Allow for our md5.h to defer to the system header
Gerald Pfeifer [Fri, 5 Nov 2021 11:56:07 +0000 (12:56 +0100)]
include: Allow for our md5.h to defer to the system header

This came up in the context of libsanitizer, where platform-specific
support for FreeBSD relies on aspects provided by FreeBSD's own md5.h.

Address this by allowing GCC's md5.h to pull in the system header
instead, controlled by a new macro USE_SYSTEM_MD5.

2021-11-05  Gerald Pfeifer  <gerald@pfeifer.com>
    Jakub Jelinek  <jakub@redhat.com>

include/
* md5.h (USE_SYSTEM_MD5): Introduce.

2 years agodoc: No longer generate old.html
Gerald Pfeifer [Sun, 24 Oct 2021 09:48:29 +0000 (11:48 +0200)]
doc: No longer generate old.html

Commit 431d26e1dd18c1146d3d4dcd3b45a3b04f7f7d59 removed
doc/install-old.texi, alas we still tried to generate the
associated web page old.html - which then turned out empty.

Simplify remove this from the list of pages to be generated.

gcc:
* doc/install.texi2html: Do not generate old.html any longer.

2 years agoReset when -gtoggle is used in gcc_options.
Martin Liska [Mon, 1 Nov 2021 15:28:34 +0000 (16:28 +0100)]
Reset when -gtoggle is used in gcc_options.

PR debug/102955

gcc/ChangeLog:

* opts.c (finish_options): Reset flag_gtoggle when it is used.

gcc/testsuite/ChangeLog:

* g++.dg/pr102955.C: New test.

2 years agodwarf2out: Fix up CONST_WIDE_INT handling once more [PR103046]
Jakub Jelinek [Fri, 5 Nov 2021 09:20:10 +0000 (10:20 +0100)]
dwarf2out: Fix up CONST_WIDE_INT handling once more [PR103046]

My last change to CONST_WIDE_INT handling in add_const_value_attribute broke
handling of CONST_WIDE_INT constants like ((__uint128_t) 1 << 120).
wi::min_precision (w1, UNSIGNED) in that case 121, but wide_int::from
creates a wide_int that has 0 and 0xff00000000000000ULL in its elts and
precision 121.  When we output that, we output both elements and thus emit
0, 0xff00000000000000 instead of the desired 0, 0x0100000000000000.

IMHO we should actually pass machine_mode to add_const_value_attribute from
callers, so that we know exactly what precision we want.  Because
hypothetically, if say mode is OImode and the CONST_WIDE_INT value fits into
128 bits or 192 bits, we'd emit just those 128 or 192 bits but debug info
users would expect 256 bits.

On
typedef unsigned __int128 U;

int
main ()
{
  U a = (U) 1 << 120;
  U b = 0xffffffffffffffffULL;
  U c = ((U) 0xffffffff00000000ULL) << 64;
  return 0;
}
vanilla gcc incorrectly emits 0, 0xff00000000000000 for a,
0xffffffffffffffff alone (DW_FORM_data8) for b and 0, 0xffffffff00000000
for c.  gcc with the previously posted PR103046 patch emits
0, 0x0100000000000000 for a, 0xffffffffffffffff alone for b and
0, 0xffffffff00000000 for c.  And with this patch we emit
0, 0x0100000000000000 for a, 0xffffffffffffffff, 0 for b and
0, 0xffffffff00000000 for c.
So, the patch below certainly causes larger debug info (well, 128-bit
integers are pretty rare), but in this case the question is if it isn't
more correct, as debug info consumers generally will not know if they
should sign or zero extend the value in DW_AT_const_value.
The previous code assumes they will always zero extend it...

2021-11-05  Jakub Jelinek  <jakub@redhat.com>

PR debug/103046
* dwarf2out.c (add_const_value_attribute): Add MODE argument, use it
in CONST_WIDE_INT handling.  Adjust recursive calls.
(add_location_or_const_value_attribute): Pass DECL_MODE (decl) to
new add_const_value_attribute argument.
(tree_add_const_value_attribute): Pass TYPE_MODE (type) to new
add_const_value_attribute argument.

2 years agogcc: vx-common.h: fix test for VxWorks7
Rasmus Villemoes [Tue, 2 Nov 2021 10:43:57 +0000 (11:43 +0100)]
gcc: vx-common.h: fix test for VxWorks7

The macro TARGET_VXWORKS7 is always defined (see vxworks-dummy.h).
Thus we need to test its value, not its definedness.

Fixes aca124df (define NO_DOT_IN_LABEL only in vxworks6).

gcc/ChangeLog:

* config/vx-common.h: Test value of TARGET_VXWORKS7 rather
than definedness.

2 years agoFirst refactor of vect_analyze_loop
Richard Biener [Wed, 27 Oct 2021 11:14:41 +0000 (13:14 +0200)]
First refactor of vect_analyze_loop

This refactors the main loop analysis part in vect_analyze_loop,
re-purposing the existing vect_reanalyze_as_main_loop for this
to reduce code duplication.  Failure flow is a bit tricky since
we want to extract info from the analyzed loop but I wanted to
share the destruction part.  Thus I add some std::function and
lambda to funnel post-analysis for the case we want that
(when analyzing from the main iteration but not when re-analyzing
an epilogue as main).

In addition I split vect_analyze_loop_form into analysis and
vinfo creation so we can do the analysis only once, simplifying
the new vect_analyze_loop_1.

As discussed we probably want to change the loop over vector
modes to first only analyze things as the main loop, picking
the best (or simd VF) mode for the main loop and then analyze
for a vectorized epilogue.  The unroll would then integrate
with the main loop vectorization.  I think that currently
we may fail to analyze the epilogue with the same mode as
the main loop when using partial vectors since we increment
mode_i before doing that.

2021-11-04  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (struct vect_loop_form_info): New.
(vect_analyze_loop_form): Adjust.
(vect_create_loop_vinfo): New.
* tree-parloops.c (gather_scalar_reductions): Adjust for
vect_analyze_loop_form API change.
* tree-vect-loop.c: Include <functional>.
(vect_analyze_loop_form_1): Rename to vect_analyze_loop_form,
take struct vect_loop_form_info as output parameter and adjust.
(vect_analyze_loop_form): Rename to vect_create_loop_vinfo and
split out call to the original vect_analyze_loop_form_1.
(vect_reanalyze_as_main_loop): Rename to...
(vect_analyze_loop_1): ... this, factor out the call to
vect_analyze_loop_form and generalize to be able to use it twice ...
(vect_analyze_loop): ... here.  Perform vect_analyze_loop_form
once only and here.

2 years agors6000: Fix incorrect fusion constraint [PR102991]
Xionghu Luo [Thu, 4 Nov 2021 01:23:03 +0000 (20:23 -0500)]
rs6000: Fix incorrect fusion constraint [PR102991]

gcc/ChangeLog:

2021-11-05  Xionghu Luo  <luoxhu@linux.ibm.com>

PR target/102991
* config/rs6000/fusion.md: Regenerate.
* config/rs6000/genfusion.pl: Fix incorrect clobber constraint.

2 years agoDaily bump.
GCC Administrator [Fri, 5 Nov 2021 00:16:36 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Fix pretty printing of std::unique_ptr [PR103086]
Jonathan Wakely [Thu, 4 Nov 2021 22:50:02 +0000 (22:50 +0000)]
libstdc++: Fix pretty printing of std::unique_ptr [PR103086]

Since std::tuple started using [[no_unique_address]] the tuple<T*, D>
member of std::unique_ptr<T, D> has two _M_head_impl subobjects, in
different base classes. That means this printer code is ambiguous:

    tuple_head_type = tuple_impl_type.fields()[1].type   # _Head_base
    head_field = tuple_head_type.fields()[0]
    if head_field.name == '_M_head_impl':
        self.pointer = tuple_member['_M_head_impl']

In older versions of GDB it happened to work by chance, because GDB
returned the last _M_head_impl member and std::tuple's base classes are
stored in reverse order, so the last one was the T* element of the
tuple. Since GDB 11 it returns the first _M_head_impl, which is the
deleter element.

The fix is for the printer to stop using an ambiguous field name and
cast the tuple to the correct base class before accessing the
_M_head_impl member.

Instead of fixing this in both UniquePointerPrinter and StdPathPrinter a
new unique_ptr_get function is defined to do it correctly. That is
defined in terms of new tuple_get and _tuple_impl_get functions.

It would be possible to reuse _tuple_impl_get to access each element in
StdTuplePrinter._iterator.__next__, but that already does the correct
casting, and wouldn't be much simpler anyway.

libstdc++-v3/ChangeLog:

PR libstdc++/103086
* python/libstdcxx/v6/printers.py (_tuple_impl_get): New helper
for accessing the tuple element stored in a _Tuple_impl node.
(tuple_get): New function for accessing a tuple element.
(unique_ptr_get): New function for accessing a unique_ptr.
(UniquePointerPrinter, StdPathPrinter): Use unique_ptr_get.
* python/libstdcxx/v6/xmethods.py (UniquePtrGetWorker): Cast
tuple to its base class before accessing _M_head_impl.