Bill Schmidt [Thu, 11 Nov 2021 22:11:03 +0000 (16:11 -0600)]
rs6000: Better error messages for power8/9 vector builtins
2021-11-11 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-call.c (rs6000_invalid_new_builtin): Change
error messages for ENB_P8V and ENB_P9V.
Bill Schmidt [Tue, 23 Nov 2021 16:15:00 +0000 (10:15 -0600)]
rs6000: Add [power6-64] stanza to new builtin support
2021-11-23 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-builtin-new.def: Add power6-64 stanza. Move
CMPB to power6-64 stanza.
* config/rs6000/rs6000-call.c (rs6000_invalid_new_builtin): Handle
ENB_P6_64 case.
(rs6000_new_builtin_is_supported): Likewise.
(rs6000_expand_new_builtin): Likewise. Clean up formatting.
(rs6000_init_builtins): Handle ENB_P6_64 case.
* config/rs6000/rs6000-gen-builtins.c (bif_stanza): Add BSTZ_P6_64.
(stanza_map): Add entry mapping power6-64 to BSTZ_P6_64.
(enable_string): Add "ENB_P6_64".
(write_decls): Add ENB_P6_64 to bif_enable enum.
Bill Schmidt [Tue, 23 Nov 2021 18:54:50 +0000 (12:54 -0600)]
rs6000: Fix test_mffsl.c effective target check
Paul Clarke pointed out to me that I had wrongly used a compile-time check
instead of a run-time check in this executable test. This patch fixes
that. I also fixed a typo in a string that caught my eye.
2021-11-23 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/testsuite/
* gcc.target/powerpc/test_mffsl.c: Change effective target to
a run-time check. Fix a typo in a debug print statement.
Harald Anlauf [Tue, 23 Nov 2021 16:51:38 +0000 (17:51 +0100)]
Fortran: fix scalarization for intrinsic LEN_TRIM with present KIND argument
gcc/fortran/ChangeLog:
PR fortran/87711
PR fortran/87851
* trans-array.c (arg_evaluated_for_scalarization): Add LEN_TRIM to
list of intrinsics for which an optional KIND argument needs to be
removed before scalarization.
gcc/testsuite/ChangeLog:
PR fortran/87711
PR fortran/87851
* gfortran.dg/len_trim.f90: New test.
Christophe Lyon [Tue, 23 Nov 2021 16:06:42 +0000 (16:06 +0000)]
libcpp: Fix ATTR_LIKELY definition PR preprocessor/103355
Fix the definition of ATTR_LIKELY when __has_cpp_attribute is not
defined, as it is the case with old compilers such as gcc-4.8.5.
libcpp/:
PR preprocessor/103355
* system.h (ATTR_LIKELY): Fix definition.
Jan Hubicka [Tue, 23 Nov 2021 15:36:01 +0000 (16:36 +0100)]
Remove duplicated param valud in modref tree
Modref tree template stores its own copy of param_moderf_max_bases, *_max_refs
and *_max_accesses values. This was done before we had per-function limits and
even back then it was bit dubious, so this patch removes it.
gcc/ChangeLog:
* ipa-modref-tree.h (struct modref_tree): Remove max_bases, max_refs
and max_accesses.
(modref_tree::modref_tree): Remove parametr.
(modref_tree::insert_base): Add max_bases parameter.
(modref_tree::insert): Add max_bases, max_refs, max_accesses
parameters.
(modref_tree::insert): New member function.
(modref_tree::merge): Add max_bases, max_refs, max_accesses
parameters.
(modref_tree::insert): New member function.
* ipa-modref-tree.c (test_insert_search_collapse): Update.
(test_merge): Update.
* ipa-modref.c (dump_records): Don't dump max_refs and max_bases.
(dump_lto_records): Likewise.
(modref_summary::finalize): Fix whitespace.
(get_modref_function_summary): Likewise.
(modref_access_analysis::record_access): Update.
(modref_access_analysis::record_access_lto): Update.
(modref_access_analysis::process_fnspec): Update.
(analyze_function): Update.
(modref_summaries::duplicate): Update.
(modref_summaries_lto::duplicate): Update.
(write_modref_records): Update.
(read_modref_records): Update.
(read_section): Update.
(propagate_unknown_call): Update.
(modref_propagate_in_scc): Update.
(ipa_merge_modref_summary_after_inlining): Update.
Jonathan Wakely [Tue, 23 Nov 2021 12:28:22 +0000 (12:28 +0000)]
libstdc++: Fix circular dependency for bitmap_allocator [PR103381]
<ext/bitmap_allocator.h> includes <function>, and since C++17 that
includes <unordered_map>. If std::allocator is defined in terms of
__gnu_cxx::bitmap_allocator then you get a circular reference and
bootstrap fails when compiling src/c++17/*.cc.
libstdc++-v3/ChangeLog:
PR libstdc++/103381
* include/ext/bitmap_allocator.h: Include <bits/stl_function.h>
instead of <functional>.
Martin Liska [Tue, 23 Nov 2021 10:27:29 +0000 (11:27 +0100)]
docs: Remove 2 more duplicite param descriptions.
gcc/ChangeLog:
* doc/invoke.texi: Remove 2 more duplicite param descriptions.
Richard Biener [Tue, 23 Nov 2021 09:11:41 +0000 (10:11 +0100)]
tree-optimization/103361 - fix unroll-and-jam direction vector handling
This properly uses lambda_int instead of truncating the direction
vector to int which leads to false unexpected negative values.
2021-11-23 Richard Biener <rguenther@suse.de>
PR tree-optimization/103361
* gimple-loop-jam.c (adjust_unroll_factor): Use lambda_int
for the dependence distance.
* tree-data-ref.c (print_lambda_vector): Properly print a lambda_int.
* g++.dg/torture/pr103361.C: New testcase.
Jakub Jelinek [Tue, 23 Nov 2021 10:02:54 +0000 (11:02 +0100)]
inliner: Remove unused transform_lang_insert_block hook
This struct copy_body_data's hook is always NULL since merge
of the tuples branch, before that it has been shortly used by the C++
FE during ctor/dtor cloning to chain the remapped blocks, but only
very shortly, before transform_lang_insert_block was a bool and
the call to insert_block was done through a langhook.
I'd say that for something that hasn't been used since 4.4 there is
zero chance we'll want to use it again in the near future.
2021-11-23 Jakub Jelinek <jakub@redhat.com>
gcc/
* tree-inline.h (struct copy_body_data): Remove
transform_lang_insert_block member.
* tree-inline.c (remap_block): Don't call
id->transform_lang_insert_block.
(optimize_inline_calls, copy_gimple_seq_and_replace_locals,
tree_function_versioning, maybe_inline_call_in_expr,
copy_fn): Don't initialize id.transform_lang_insert_block.
* gimplify.c (gimplify_omp_loop): Likewise.
gcc/c/
* c-typeck.c (c_clone_omp_udr): Don't initialize
id.transform_lang_insert_block.
gcc/cp/
* semantics.c (clone_omp_udr): Don't initialize
id.transform_lang_insert_block.
* optimize.c (clone_body): Likewise.
Jan Hubicka [Tue, 23 Nov 2021 09:55:56 +0000 (10:55 +0100)]
Improve bytewise DSE
testcase modref-dse-4.c and modref-dse-5.c fails on some targets because they
depend on store merging. What really happens is that without store merging
we produce for kill_me combined write that is ao_ref with offset=0, size=32
and max_size=96. We have size != max_size becaue we do ont track the info that
all 3 writes must happen in a group and conider case only some of them are done.
This disables byte-wise DSE which checks that size == max_size. This is
completely unnecesary for store being proved to be dead or load being checked
to not read live bytes. It is only necessary for kill store that is used to
prove that given store is dead.
While looking into this I also noticed that we check that everything is byte
aligned. This is also unnecessary and with access merging in modref may more
commonly fire on accesses that we could otherwise handle.
This patch fixes both also also changes interface to normalize_ref that I found
confusing since it modifies the ref. Instead of that we have get_byte_range
that is computing range in bytes (since that is what we need to maintain the
bitmap) and has additional parameter specifying if the store in question should
be turned into sub-range or super-range depending whether we compute range
for kill or load.
gcc/ChangeLog:
2021-11-23 Jan Hubicka <hubicka@ucw.cz>
PR tree-optimization/103335
* tree-ssa-dse.c (valid_ao_ref_for_dse): Rename to ...
(valid_ao_ref_kill_for_dse): ... this; do not check that boundaries
are divisible by BITS_PER_UNIT.
(get_byte_aligned_range_containing_ref): New function.
(get_byte_aligned_range_contained_in_ref): New function.
(normalize_ref): Rename to ...
(get_byte_range): ... this one; handle accesses not aligned to byte
boundary; return range in bytes rater than updating ao_ref.
(clear_live_bytes_for_ref): Take write ref by reference; simplify using
get_byte_access.
(setup_live_bytes_from_ref): Likewise.
(clear_bytes_written_by): Update.
(live_bytes_read): Update.
(dse_classify_store): Simplify tech before live_bytes_read checks.
gcc/testsuite/ChangeLog:
2021-11-23 Jan Hubicka <hubicka@ucw.cz>
* gcc.dg/tree-ssa/modref-dse-4.c: Update template.
* gcc.dg/tree-ssa/modref-dse-5.c: Update template.
Andrew Pinski [Tue, 23 Nov 2021 01:08:55 +0000 (01:08 +0000)]
Canonicalize &MEM[ssa_n, CST] to ssa_n p+ CST in fold_stmt_1
This is a new version of the patch to fix PR 102216.
Instead of doing the canonicalization inside forwprop, Richi
mentioned we should do it inside fold_stmt_1 and that is what
this patch does.
PR tree-optimization/102216
gcc/ChangeLog:
* gimple-fold.c (fold_stmt_1): Add canonicalization
of "&MEM[ssa_n, CST]" to "ssa_n p+ CST", note this
can only be done if !in_place.
gcc/testsuite/ChangeLog:
* g++.dg/tree-ssa/pr102216-1.C: New test.
* g++.dg/tree-ssa/pr102216-2.C: New test.
Jakub Jelinek [Tue, 23 Nov 2021 09:30:02 +0000 (10:30 +0100)]
openmp: Fix up handling of reduction clauses on the loop construct [PR102431]
We were using unshare_expr and walk_tree_without_duplicate replacement
of the placeholder vars. The OMP_CLAUSE_REDUCTION_{INIT,MERGE} can contain
other trees that need to be duplicated though, e.g. BLOCKs referenced in
BIND_EXPR(s), or local VAR_DECLs. This patch uses the inliner code to copy
all of that. There is a slight complication that those local VAR_DECLs or
placeholders don't have DECL_CONTEXT set, they will get that only when
they are gimplified later on, so this patch sets DECL_CONTEXT for those
temporarily and resets it afterwards.
2021-11-23 Jakub Jelinek <jakub@redhat.com>
PR middle-end/102431
* gimplify.c (replace_reduction_placeholders): Remove.
(note_no_context_vars): New function.
(gimplify_omp_loop): For OMP_PARALLEL's BIND_EXPR create a new
BLOCK. Use copy_tree_body_r with walk_tree instead of unshare_expr
and replace_reduction_placeholders for duplication of
OMP_CLAUSE_REDUCTION_{INIT,MERGE} expressions. Ensure all mentioned
automatic vars have DECL_CONTEXT set to non-NULL before doing so
and reset it afterwards for those vars and their corresponding
vars.
* c-c++-common/gomp/pr102431.c: New test.
* g++.dg/gomp/pr102431.C: New test.
* gfortran.dg/gomp/pr102431.f90: New test.
Haochen Gui [Wed, 17 Nov 2021 08:16:02 +0000 (16:16 +0800)]
rs6000: Optimize code generation of vec_reve [PR100868]
gcc/
PR target/100868
* config/rs6000/altivec.md (altivec_vreve<mode>2 for VEC_K): Use
xxbrq for v16qi, xxbrq + xxbrh for v8hi and xxbrq + xxbrw for v4si
or v4sf when p9_vector is set.
(altivec_vreve<mode>2 for VEC_64): Defined. Implemented by xxswapd.
gcc/testsuite/
PR target/100868
* gcc.target/powerpc/vec_reve_1.c: New test.
* gcc.target/powerpc/vec_reve_2.c: Likewise.
Martin Liska [Tue, 23 Nov 2021 07:36:54 +0000 (08:36 +0100)]
contrib: filter out -Wc++20-extensions
contrib/ChangeLog:
* filter-clang-warnings.py: Filter -Wc++20-extensions as it does
not respect proper attribute detection.
Martin Liska [Tue, 23 Nov 2021 07:26:51 +0000 (08:26 +0100)]
contrib: Support itemx in check-params-in-docs.py.
contrib/ChangeLog:
* check-params-in-docs.py: Support @itemx in param documentation
and support multi-line documentation for parameters.
Navid Rahimi [Tue, 23 Nov 2021 03:07:35 +0000 (22:07 -0500)]
Re: [PATCH] PR tree-optimization/102232 Adding a missing pattern to match.pd
PR tree-optimization/102232
gcc/
* match.pd (x * (1 + y / x) - y) -> (x - y % x): New optimization.
gcc/testsuite/
* gcc.dg/tree-ssa/pr102232.c: Testcase for this optimization.
Marek Polacek [Mon, 22 Nov 2021 16:29:40 +0000 (11:29 -0500)]
libcpp: Use [[likely]] conditionally
Let's hide [[likely]] behind a macro, to suppress warnings if the
compiler doesn't support it.
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
PR preprocessor/103355
libcpp/ChangeLog:
* lex.c: Use ATTR_LIKELY instead of [[likely]].
* system.h (ATTR_LIKELY): Define.
Navid Rahimi [Tue, 23 Nov 2021 00:46:17 +0000 (19:46 -0500)]
Re: [PATCH] PR tree-optimization/96779 Adding a missing pattern to match.pd
PR tree-optimization/96779
gcc/
* match.pd (-x == x) -> (x == 0): New optimization.
gcc/testsuite
* gcc.dg/tree-ssa/pr96779.c: Testcase for this optimization.
* gcc.dg/tree-ssa/pr96779-disabled.c: Testcase for this optimization
when -fwrapv passed.
GCC Administrator [Tue, 23 Nov 2021 00:16:27 +0000 (00:16 +0000)]
Daily bump.
Jason Merrill [Wed, 3 Nov 2021 13:29:47 +0000 (09:29 -0400)]
c++: remember pointer-to-member location
Jakub recently mentioned that a PTRMEM_CST has no location; let's give it a
location wrapper.
gcc/cp/ChangeLog:
* typeck.c (build_x_unary_op): Set address location.
(convert_member_func_to_ptr): Handle location wrapper.
* pt.c (convert_nontype_argument): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/template/crash106.C: Adjust.
* g++.dg/diagnostic/ptrtomem3.C: New test.
Jason Merrill [Fri, 19 Nov 2021 22:01:10 +0000 (17:01 -0500)]
c++: improved return expression location
Stripping the location wrapper from retval meant we didn't have the
necessary location information for any conversion diagnostics. We only need
the stripping for the named return value optimization, let's use the
unstripped expression for everything else.
gcc/cp/ChangeLog:
* typeck.c (check_return_expr): Only strip location wrapper during
NRV handling.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/pr65327.C: Adjust location.
* g++.dg/cpp23/constexpr-nonlit4.C: Likewise.
* g++.dg/cpp23/constexpr-nonlit5.C: Likewise.
* g++.dg/cpp2a/constexpr-init1.C: Likewise.
Jakub Jelinek [Mon, 22 Nov 2021 21:29:20 +0000 (22:29 +0100)]
libcpp: Fix _Pragma stringification [PR103165]
As the testcase show, sometimes _Pragma is turned into CPP_PRAGMA
.. CPP_PRAGMA_EOL tokens, even when it might still need to be
stringized later on. We are then ICEing because we don't handle
stringification of CPP_PRAGMA or CPP_PRAGMA_EOL, but trying to
reconstruct the exact tokens with exact spacing after it has been
lowered is very hard. So, instead this patch ensures we don't
lower _Pragma during expand_arg calls, but only later when
cpp_get_token_1 is called outside of expand_arg.
2021-11-22 Jakub Jelinek <jakub@redhat.com>
Tobias Burnus <tobias@codesourcery.com>
PR preprocessor/103165
libcpp/
* internal.h (struct lexer_state): Add ignore__Pragma field.
* macro.c (builtin_macro): Don't interpret _Pragma if
pfile->state.ignore__Pragma.
(expand_arg): Temporarily set pfile->state.ignore__Pragma to 1.
gcc/testsuite/
* c-c++-common/gomp/pragma-3.c: New test.
* c-c++-common/gomp/pragma-4.c: New test.
* c-c++-common/gomp/pragma-5.c: New test.
Co-Authored-By: Tobias Burnus <tobias@codesourcery.com>
Roger Sayle [Mon, 22 Nov 2021 18:15:36 +0000 (18:15 +0000)]
tree-optimization/103345: Improved load merging.
This patch implements PR tree-optimization/103345 to merge adjacent
loads when combined with addition or bitwise xor. The current code
in gimple-ssa-store-merging.c's find_bswap_or_nop alreay handles ior,
so that all that's required is to treat PLUS_EXPR and BIT_XOR_EXPR in
the same way at BIT_IOR_EXPR. Many thanks to Andrew Pinski for
pointing out that this also resolves PR target/98953.
2021-11-22 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR tree-optimization/98953
PR tree-optimization/103345
* gimple-ssa-store-merging.c (find_bswap_or_nop_1): Handle
BIT_XOR_EXPR and PLUS_EXPR the same as BIT_IOR_EXPR.
(pass_optimize_bswap::execute): Likewise.
gcc/testsuite/ChangeLog
PR tree-optimization/98953
PR tree-optimization/103345
* gcc.dg/tree-ssa/pr98953.c: New test case.
* gcc.dg/tree-ssa/pr103345.c: New test case.
Martin Liska [Mon, 22 Nov 2021 16:37:12 +0000 (17:37 +0100)]
docs: remove duplicate param documentation
gcc/ChangeLog:
* doc/invoke.texi: Remove duplicate documentation for 3 params.
Jakub Jelinek [Mon, 22 Nov 2021 16:06:12 +0000 (17:06 +0100)]
openacc: Fix up C++ #pragma acc routine handling [PR101731]
The following testcase ICEs because two function declarations are nested in
each other and the acc routine handling code isn't prepared to put the
pragma on both.
The fix is similar to what #pragma omp declare {simd,variant} does,
in particular set the fndecl_seen flag already in cp_parser_late_parsing*
when we encounter it rather than only after we finalize it.
In cp_finalize_oacc_routine I had to move the fndecl_seen diagnostics to
non-FUNCTION_DECL block, because for FUNCTION_DECLs the flag is already
known to be set from cp_parser_late_parsing_oacc_routine, but can't be
removed altogether, because that regresses quality of 2 goacc/routine-5.c
diagnostics - we drop "a single " from the
'#pragma acc routine' not immediately followed by a single function declaration or definition
diagnostic say on
#pragma acc routine
int foo (), b;
if we drop it altogether.
2021-11-22 Jakub Jelinek <jakub@redhat.com>
PR c++/101731
* parser.c (cp_parser_late_parsing_oacc_routine): Set
parser->oacc_routine->fndecl_seen here, rather than ...
(cp_finalize_oacc_routine): ... here. Don't error if
parser->oacc_routine->fndecl_seen is set for FUNCTION_DECLs.
* c-c++-common/goacc/routine-6.c: New test.
Jonathan Wakely [Fri, 19 Nov 2021 20:58:31 +0000 (20:58 +0000)]
libstdc++: Fix condition for definition of _GLIBCXX14_DEPRECATED
The check for C++14 was using the wrong date.
libstdc++-v3/ChangeLog:
* include/bits/c++config (_GLIBCXX14_DEPRECATED): Fix condition
checking for C++14.
Florian Weimer [Mon, 22 Nov 2021 12:30:23 +0000 (13:30 +0100)]
libgcc: Remove dbase member from struct unw_eh_callback_data if NULL
Only bfin, frv, i386 and nios2 need this member at present.
libgcc/ChangeLog
* unwind-dw2-fde-dip.c (NEED_DBASE_MEMBER): Define.
(struct unw_eh_callback_data): Make dbase member conditional.
(unw_eh_callback_data_dbase): New function.
(base_from_cb_data): Simplify for the non-dbase case.
(_Unwind_IteratePhdrCallback): Adjust.
(_Unwind_Find_FDE): Likewise.
Florian Weimer [Mon, 22 Nov 2021 12:30:23 +0000 (13:30 +0100)]
libgcc: Remove tbase member from struct unw_eh_callback_data
It is always a null pointer.
libgcc/ChangeLog
* unwind-dw2-fde-dip.c (struct unw_eh_callback_data): Remove
tbase member.
(base_from_cb_data): Adjust.
(_Unwind_IteratePhdrCallback): Likewise.
(_Unwind_Find_FDE): Likewise.
Richard Biener [Mon, 22 Nov 2021 10:23:55 +0000 (11:23 +0100)]
tree-optimization/103351 - avoid compare-debug issue wrt CD-DCE change
This avoids differences in the split edge of a cluster due to different
order of same key PHI args when sorting by sorting after the edge
destination index as second key.
2021-11-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/103351
* tree-ssa-dce.c (sort_phi_args): Sort after e->dest_idx as
second key.
* g++.dg/torture/pr103351.C: New testcase.
Jakub Jelinek [Mon, 22 Nov 2021 09:13:24 +0000 (10:13 +0100)]
openmp: Handle OMP_MASKED in potential_constant_expression_1 [PR103349]
WHen adding OMP_MASKED, I apparently forgot to handle it in
potential_constant_expression_1, which means we can ICE on it.
2021-11-22 Jakub Jelinek <jakub@redhat.com>
PR c++/103349
* constexpr.c (potential_constant_expression_1): Punt on OMP_MASKED.
* g++.dg/gomp/masked-1.C: New test.
liuhongt [Wed, 17 Nov 2021 07:48:37 +0000 (15:48 +0800)]
Don't allow mask/sse/mmx mov in TLS code sequences.
As change in assembler, refer to [1], this patch disallow mask/sse/mmx
mov in TLS code sequences which require integer MOV instructions.
[1] https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=
d7e3e627027fcf37d63e284144fe27ff4eba36b5
gcc/ChangeLog:
PR target/103275
* config/i386/constraints.md (Bk): New
define_memory_constraint.
* config/i386/i386-protos.h (ix86_gpr_tls_address_pattern_p):
Declare.
* config/i386/i386.c (ix86_gpr_tls_address_pattern_p): New
function.
* config/i386/i386.md (*movsi_internal): Don't allow
mask/sse/mmx move in TLS code sequences.
(*movdi_internal): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr103275.c: New test.
Kewen Lin [Mon, 22 Nov 2021 02:18:31 +0000 (20:18 -0600)]
xtensa: Fix non-robust split condition in define_insn_and_split
This patch is to fix some non-robust split conditions in some
define_insn_and_splits, to make each of them applied on top of
the corresponding condition for define_insn part, otherwise the
splitting could perform unexpectedly.
gcc/ChangeLog:
* config/xtensa/xtensa.md (movdi_internal, movdf_internal): Fix split
condition.
GCC Administrator [Mon, 22 Nov 2021 00:16:29 +0000 (00:16 +0000)]
Daily bump.
Jakub Jelinek [Sun, 21 Nov 2021 20:08:04 +0000 (21:08 +0100)]
fortran, debug: Fix up DW_AT_rank [PR103315]
For DW_AT_rank we were emitting
.uleb128 0x4 # DW_AT_rank
.byte 0x97 # DW_OP_push_object_address
.byte 0x23 # DW_OP_plus_uconst
.uleb128 0x1c
.byte 0x6 # DW_OP_deref
on 64-bit and
.uleb128 0x4 # DW_AT_rank
.byte 0x97 # DW_OP_push_object_address
.byte 0x23 # DW_OP_plus_uconst
.uleb128 0x10
.byte 0x6 # DW_OP_deref
on 32-bit. I think this is wrong, as dtype.rank field in the descriptor
has unsigned char type, not pointer type nor pointer sized integral.
E.g. if we have a
REAL :: a(..)
dummy argument, which is passed as a reference to the function descriptor,
we want to evaluate a->dtype.rank. The above DWARF expressions perform
*(uintptr_t *)(a + 0x1c)
and
*(uintptr_t *)(a + 0x10)
respectively. The following patch changes those to:
.uleb128 0x5 # DW_AT_rank
.byte 0x97 # DW_OP_push_object_address
.byte 0x23 # DW_OP_plus_uconst
.uleb128 0x1c
.byte 0x94 # DW_OP_deref_size
.byte 0x1
and
.uleb128 0x5 # DW_AT_rank
.byte 0x97 # DW_OP_push_object_address
.byte 0x23 # DW_OP_plus_uconst
.uleb128 0x10
.byte 0x94 # DW_OP_deref_size
.byte 0x1
which perform
*(unsigned char *)(a + 0x1c)
and
*(unsigned char *)(a + 0x10)
respectively.
2021-11-21 Jakub Jelinek <jakub@redhat.com>
PR debug/103315
* trans-types.c (gfc_get_array_descr_info): Use DW_OP_deref_size 1
instead of DW_OP_deref for DW_AT_rank.
Jakub Jelinek [Sun, 21 Nov 2021 20:06:23 +0000 (21:06 +0100)]
i386: Fix up handling of target attribute [PR101180]
As shown in the testcase below, if a function has multiple target attributes
(rather than a single one with one or more arguments) or if a function
gets one target attribute on one declaration and another one on another
declaration, on x86 their effect is not combined into
DECL_FUNCTION_SPECIFIC_TARGET, but instead only the last processed target
attribute wins. aarch64 handles this right, the following patch follows
what it does, i.e. only start with target_option_default_node if
DECL_FUNCTION_SPECIFIC_TARGET is previously NULL (i.e. the first target
attribute being processed on a function) and otherwise start from the
previous DECL_FUNCTION_SPECIFIC_TARGET.
2021-11-21 Jakub Jelinek <jakub@redhat.com>
PR c++/101180
* config/i386/i386-options.c (ix86_valid_target_attribute_p): If
fndecl already has DECL_FUNCTION_SPECIFIC_TARGET, use that as base
instead of target_option_default_node.
* gcc.target/i386/pr101180.c: New test.
Harald Anlauf [Sun, 21 Nov 2021 18:29:27 +0000 (19:29 +0100)]
Fortran: fix lookup for gfortran builtin math intrinsics used by DEC extensions
gcc/fortran/ChangeLog:
PR fortran/99061
* trans-intrinsic.c (gfc_lookup_intrinsic): Helper function for
looking up gfortran builtin intrinsics.
(gfc_conv_intrinsic_atrigd): Use it.
(gfc_conv_intrinsic_cotan): Likewise.
(gfc_conv_intrinsic_cotand): Likewise.
(gfc_conv_intrinsic_atan2d): Likewise.
gcc/testsuite/ChangeLog:
PR fortran/99061
* gfortran.dg/dec_math_5.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
Jan Hubicka [Sun, 21 Nov 2021 15:15:41 +0000 (16:15 +0100)]
Improve base tracking in ipa-modref
on exchange2 benchamrk we miss some useful propagation because modref gives
up very early on analyzing accesses through pointers. For example in
int test (int *a)
{
int i;
for (i=0; a[i];i++);
return i+a[i];
}
We are not able to determine that a[i] accesses are relative to a.
This is because get_access requires the SSA name that is in MEM_REF to be
PARM_DECL while on other places we use ipa-prop helper to work out the proper
base pointers.
This patch commonizes the code in get_access and parm_map_for_arg so both
use the check properly and extends it to also figure out that newly allocated
memory is not a side effect to caller.
gcc/ChangeLog:
2021-11-21 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103227
* ipa-modref.c (parm_map_for_arg): Rename to ...
(parm_map_for_ptr): .. this one; handle static chain and calls to
malloc functions.
(modref_access_analysis::get_access): Use parm_map_for_ptr.
(modref_access_analysis::process_fnspec): Update.
(modref_access_analysis::analyze_load): Update.
(modref_access_analysis::analyze_store): Update.
gcc/testsuite/ChangeLog:
2021-11-21 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103227
* gcc.dg/tree-ssa/modref-15.c: New test.
Jan Hubicka [Sun, 21 Nov 2021 15:13:40 +0000 (16:13 +0100)]
Fix failure merge_block.c testcase
gcc/testsuite/ChangeLog:
2021-11-21 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103264
* gcc.dg/tree-prof/merge_block.c: Add -fno-ipa-modref
Jan Hubicka [Sun, 21 Nov 2021 12:21:32 +0000 (13:21 +0100)]
Refactor load/store/kill analysis in ipa-modref
Refactor load/store/kill analysis in ipa-modref to a class
modref_access_analysis. This is done in order to avoid some code duplication
and early exits that has turned out to be hard to maintain and there were
multiple bugs we noticed recently.
gcc/ChangeLog:
2021-11-21 Jan Hubicka <hubicka@ucw.cz>
* ipa-modref.c (ignore_nondeterminism_p): Move earlier in source
code.
(ignore_retval_p): Likewise.
(ignore_stores_p): Likewise.
(parm_map_for_arg): Likewise.
(class modref_access_analysis): New class.
(modref_access_analysis::set_side_effects): New member function.
(modref_access_analysis::set_nondeterministic): New member function.
(get_access): Turn to ...
(modref_access_analysis::get_access): ... this one.
(record_access): Turn to ...
(modref_access_analysis::record_access): ... this one.
(record_access_lto): Turn to ...
(modref_access_analysis::record_access_lto): ... This one.
(record_access_p): Turn to ...
(modref_access_analysis::record_access_p): ... This one
(modref_access_analysis::record_unknown_load): New member function.
(modref_access_analysis::record_unknown_store): New member function.
(get_access_for_fnspec): Turn to ...
(modref_access_analysis::get_access_for_fnspec): ... this one.
(merge_call_side_effects): Turn to ...
(moderf_access_analysis::merge_call_side_effects): Turn to ...
(collapse_loads): Move later in source code.
(collapse_stores): Move later in source code.
(process_fnspec): Turn to ...
(modref_access_analysis::process_fnspec): ... this one.
(analyze_call): Turn to ...
(modref_access_analysis::analyze_call): ... this one.
(struct summary_ptrs): Remove.
(analyze_load): Turn to ...
(modref_access_analysis::analyze_load): ... this one.
(analyze_store): Turn to ...
(modref_access_analysis::analyze_store): ... this one.
(analyze_stmt): Turn to ...
(modref_access_analysis::analyze_stmt): ... This one.
(remove_summary): Remove.
(modref_access_analysis::propagate): Break out from ...
(modref_access_analysis::analyze): Break out from ...
(analyze_function): ... here.
Roger Sayle [Sun, 21 Nov 2021 11:40:08 +0000 (11:40 +0000)]
Tweak tree-ssa-math-opts.c to solve PR target/102117.
This patch resolves PR target/102117 on s390. The problem is that
some of the functionality of GCC's RTL expanders is no longer triggered
following the transition to tree SSA form. On s390, unsigned widening
multiplications are converted into WIDEN_MULT_EXPR (aka w* in tree dumps),
but signed widening multiplies are left in their original form, which
alas doesn't benefit from the clever logic in expand_widening_mult.
The fix is to teach convert_mult_to_widen, that RTL expansion can
synthesize a signed widening multiplication if the target provides
a suitable umul_widen_optab.
On s390-linux-gnu with -O2 -m64, the code in the bugzilla PR currently
generates:
imul128:
stmg %r12,%r13,96(%r15)
srag %r0,%r4,63
srag %r1,%r3,63
lgr %r13,%r3
mlgr %r12,%r4
msgr %r1,%r4
msgr %r0,%r3
lgr %r4,%r12
agr %r1,%r0
lgr %r5,%r13
agr %r4,%r1
stmg %r4,%r5,0(%r2)
lmg %r12,%r13,96(%r15)
br %r14
but with this patch should now generate the more efficient:
imul128:
lgr %r1,%r3
mlgr %r0,%r4
srag %r5,%r3,63
ngr %r5,%r4
srag %r4,%r4,63
sgr %r0,%r5
ngr %r4,%r3
sgr %r0,%r4
stmg %r0,%r1,0(%r2)
br %r14
2021-11-21 Roger Sayle <roger@nextmovesoftware.com>
Robin Dapp <rdapp@linux.ibm.com>
gcc/ChangeLog
PR target/102117
* tree-ssa-math-opts.c (convert_mult_to_widen): Recognize
signed WIDEN_MULT_EXPR if the target supports umul_widen_optab.
gcc/testsuite/ChangeLog
PR target/102117
* gcc.target/s390/mul-wide.c: New test case.
* gcc.target/s390/umul-wide.c: New test case.
GCC Administrator [Sun, 21 Nov 2021 00:16:32 +0000 (00:16 +0000)]
Daily bump.
Jan Hubicka [Sat, 20 Nov 2021 23:39:42 +0000 (00:39 +0100)]
Fix ignore_nondeterminism_p in ipa-modref
Improve debug output in ipa-modref and fix ignore_nondeterminism predicate:
looping pures and cont are still deterministic.
gcc/ChangeLog:
2021-11-21 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103052
* ipa-modref.c (ignore_nondeterminism_p): Allow looping pure/cont.
(merge_call_side_effects): Improve debug output.
Jan Hubicka [Sat, 20 Nov 2021 23:35:22 +0000 (00:35 +0100)]
Fix looping flag discovery in ipa-pure-const
The testcase shows situation where there is non-trivial cycle in the callgraph
involving a noreturn call. This cycle is important for const function discovery
but not important for pure. IPA pure const uses same strongly connected
components for both propagations which makes it to get suboptimal result
(does not detect the pure flag). However local pure const gets the situation
right becaue it processes functions in right order. This hits rarely
executed code in propagate_pure_const that merge results with previously
known state that has long standing bug in it that makes it to throw away
the looping flag.
Bootstrapped/regtested x86_64-linux.
gcc/ChangeLog:
2021-11-21 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103052
* ipa-pure-const.c (propagate_pure_const): Fix merging of loping flag.
gcc/testsuite/ChangeLog:
2021-11-21 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103052
* gcc.c-torture/execute/pr103052.c: New test.
Jeff Law [Sat, 20 Nov 2021 16:20:07 +0000 (11:20 -0500)]
Clobber the condition code in the bfin doloop patterns
Per Aldy's excellent, but tough to follow analysis in PR 103226, this patch
fixes the bfin-elf regression.
In simplest terms the doloop patterns on this port may clobber the condition
code register, but they do not expose that until after register allocation.
That would be fine, except that other patterns have exposed CC earlier. As
a result the dataflow, particularly for CC, is incorrect.
This leads the register allocators to assume that a value in CC outside the
loop is still valid inside the loop when in fact, the value has been
clobbered. This is what caused pr80974 to start failing.
With this fix, not only do we fix the pr80974 regression, but we fix ~20
other execution failures in the port. It also reduces test time for the
port from ~90 minutes to ~60 minutes.
PR tree-optimization/103226
gcc/
* config/bfin/bfin.md (doloop pattern, splitter and expander): Clobber
CC.
François Dumont [Tue, 16 Nov 2021 20:51:11 +0000 (21:51 +0100)]
libstdc++: [_GLIBCXX_DEBUG] Reduce performance impact on std::erase_if
Bypass the _GLIBCXX_DEBUG additional checks in std::__detail::__erase_node_if used
by all implementations of std::erase_if for node based containers.
libstdc++-v3/ChangeLog:
* include/bits/erase_if.h (__erase_nodes_if): Add _UnsafeContainer template
parameter. Use it to get iterators to work with.
* include/debug/macros.h (__glibcxx_check_erase2): New.
* include/debug/map.h (map<>::erase(_Base_const_iterator)): New.
(map<>::erase(const_iterator)): Use latter.
* include/debug/multimap.h (multimap<>::erase(_Base_const_iterator)): New.
(multimap<>::erase(const_iterator)): Use latter.
* include/debug/multiset.h (multiset<>::erase(_Base_const_iterator)): New.
(multiset<>::erase(const_iterator)): Use latter.
* include/debug/set.h (set<>::erase(_Base_const_iterator)): New.
(set<>::erase(const_iterator)): Use latter.
* include/debug/unordered_map (unordered_map<>::erase(_Base_const_iterator)): New.
(unordered_multimap<>::erase(const_iterator)): New.
* include/debug/unordered_set (unordered_set<>::erase(_Base_const_iterator)): New.
(unordered_multiset<>::erase(const_iterator)): New.
* include/experimental/map (erase_if): Adapt.
* include/experimental/set (erase_if): Adapt.
* include/experimental/unordered_map (erase_if): Adapt.
* include/experimental/unordered_set (erase_if): Adapt.
* include/std/map (erase_if): Adapt.
* include/std/set (erase_if): Adapt.
* include/std/unordered_map (erase_if): Adapt.
* include/std/unordered_set (erase_if): Adapt.
Andrew Pinski [Sat, 20 Nov 2021 01:37:54 +0000 (01:37 +0000)]
Fix tree-optimization/103220: Another missing folding of (type) X op CST where type is a nop convert
The problem here is that int_fits_type_p will return false if we just
change the sign of things like -2 (or 254) so we should accept the case
where we just change the sign (and not the precision) of the type.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR tree-optimization/103220
gcc/ChangeLog:
* match.pd ((type) X bitop CST): Don't check if CST
fits into the type if only the sign changes.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr103220-1.c: New test.
* gcc.dg/tree-ssa/pr103220-2.c: New test.
* gcc.dg/pr25530.c: Update test to check for
4294967294 in the case -2 is not matched.
Alexandre Oliva [Sat, 20 Nov 2021 05:51:27 +0000 (02:51 -0300)]
harden conds: detach without decls
When we create copies of SSA_NAMEs to hold "detached" copies of the
values for the hardening tests, we end up with assignments to
SSA_NAMEs that refer to the same decls. That would be generally
desirable, since it enables the variable to be recognized in dumps,
and makes coalescing more likely if the original variable dies at that
point. When the decl is a DECL_BY_REFERENCE, the SSA_NAME holds the
address of a parm or result, and it's read-only, so we shouldn't
create assignments to it. Gimple checkers flag at least the case of
results.
This patch arranges for us to avoid referencing the same decls, which
cures the problem, but retaining the visible association between the
SSA_NAMEs, by using the same identifier for the copy.
for gcc/ChangeLog
PR tree-optimization/102988
* gimple-harden-conditionals.cc (detach_value): Copy SSA_NAME
without decl sharing.
for gcc/testsuite/ChangeLog
PR tree-optimization/102988
* g++.dg/pr102988.C: New.
Antoni Boucher [Sat, 20 Nov 2021 01:44:34 +0000 (20:44 -0500)]
libgccjit: Add some reflection functions [PR96889]
2021-11-19 Antoni Boucher <bouanto@zoho.com>
gcc/jit/
PR target/96889
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_16): New ABI tag.
* docs/topics/functions.rst: Add documentation for the
functions gcc_jit_function_get_return_type and
gcc_jit_function_get_param_count
* docs/topics/types.rst: Add documentation for the functions
gcc_jit_function_type_get_return_type,
gcc_jit_function_type_get_param_count,
gcc_jit_function_type_get_param_type,
gcc_jit_type_unqualified, gcc_jit_type_dyncast_array,
gcc_jit_type_is_bool,
gcc_jit_type_dyncast_function_ptr_type,
gcc_jit_type_is_integral, gcc_jit_type_is_pointer,
gcc_jit_type_dyncast_vector,
gcc_jit_vector_type_get_element_type,
gcc_jit_vector_type_get_num_units,
gcc_jit_struct_get_field, gcc_jit_type_is_struct,
and gcc_jit_struct_get_field_count
* libgccjit.c:
(gcc_jit_function_get_return_type, gcc_jit_function_get_param_count,
gcc_jit_function_type_get_return_type,
gcc_jit_function_type_get_param_count,
gcc_jit_function_type_get_param_type, gcc_jit_type_unqualified,
gcc_jit_type_dyncast_array, gcc_jit_type_is_bool,
gcc_jit_type_dyncast_function_ptr_type, gcc_jit_type_is_integral,
gcc_jit_type_is_pointer, gcc_jit_type_dyncast_vector,
gcc_jit_vector_type_get_element_type,
gcc_jit_vector_type_get_num_units, gcc_jit_struct_get_field,
gcc_jit_type_is_struct, gcc_jit_struct_get_field_count): New
functions.
(struct gcc_jit_function_type, struct gcc_jit_vector_type):
New types.
* libgccjit.h:
(gcc_jit_function_get_return_type, gcc_jit_function_get_param_count,
gcc_jit_function_type_get_return_type,
gcc_jit_function_type_get_param_count,
gcc_jit_function_type_get_param_type, gcc_jit_type_unqualified,
gcc_jit_type_dyncast_array, gcc_jit_type_is_bool,
gcc_jit_type_dyncast_function_ptr_type, gcc_jit_type_is_integral,
gcc_jit_type_is_pointer, gcc_jit_type_dyncast_vector,
gcc_jit_vector_type_get_element_type,
gcc_jit_vector_type_get_num_units, gcc_jit_struct_get_field,
gcc_jit_type_is_struct, gcc_jit_struct_get_field_count): New
function declarations.
(struct gcc_jit_function_type, struct gcc_jit_vector_type):
New types.
* jit-recording.h: New functions (is_struct and is_vector)
* libgccjit.map (LIBGCCJIT_ABI_16): New ABI tag.
gcc/testsuite/
PR target/96889
* jit.dg/all-non-failing-tests.h: Add test-reflection.c.
* jit.dg/test-reflection.c: New test.
GCC Administrator [Sat, 20 Nov 2021 00:16:35 +0000 (00:16 +0000)]
Daily bump.
Jakub Jelinek [Fri, 19 Nov 2021 21:09:01 +0000 (22:09 +0100)]
c++: Avoid adding implicit attributes during apply_late_template_attributes [PR101180]
decl_attributes and its caller cplus_decl_attributes sometimes add
implicit attributes, e.g. optimize attribute if #pragma GCC optimize
is active, target attribute if #pragma GCC target is active, or
e.g. omp declare target attribute if in between #pragma omp declare target
and #pragma omp end declare target.
For templates that seems highly undesirable to me though, they should
get those implicit attributes from the spot the templates were parsed
(and they do get that), then tsubst through copy_node copies those
attributes, but then apply_late_template_attributes can or does add
a new set from the spot where they are instantiated, which can be pretty
random point of first use of the template.
Consider e.g.
#pragma GCC push_options
#pragma GCC target "avx"
template <int N>
inline void foo ()
{
}
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC target "crc32"
void
bar ()
{
foo<0> ();
}
#pragma GCC pop_options
testcase where the intention is that foo has avx target attribute
and bar has crc32 target attribute, but we end up with
__attribute__((target ("crc32"), target ("avx")))
on foo<0> (and due to yet another bug actually don't enable avx
in foo<0>). In this particular case it is a regression caused
by r12-299-ga0fdff3cf33f7284 which apparently calls
cplus_decl_attributes even if attributes != NULL but late_attrs
is NULL, before those changes we didn't call it in those cases.
But, if there is at least one unrelated dependent attribute this
would happen already in older releases.
The following patch fixes that by temporarily overriding the variables
that control the addition of the implicit attributes.
Shall we also change the function so that it doesn't call
cplus_decl_attributes if late_attrs is NULL, or was that change
intentional?
2021-11-19 Jakub Jelinek <jakub@redhat.com>
PR c++/101180
* pt.c (apply_late_template_attributes): Temporarily override
current_optimize_pragma, optimization_current_node,
current_target_pragma and scope_chain->omp_declare_target_attribute,
so that cplus_decl_attributes doesn't add implicit attributes.
* g++.target/i386/pr101180.C: New test.
Iain Sandoe [Fri, 19 Nov 2021 20:15:35 +0000 (20:15 +0000)]
gcc, doc: Fix Darwin bootstrap: Amend an @option command to elide a space.
At least some version(s) of makeinfo (4.8) do not like @option {-xxxx}
the brace has to follow the @option without any whitespace.
makeinfo 4.8 is installed on Darwin systems and this breaks bootstrap.
The amendment follows the style of the surrounding code.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:
* doc/invoke.texi: Remove whitespace after an @option.
David Malcolm [Thu, 18 Nov 2021 20:23:30 +0000 (15:23 -0500)]
analyzer: fix false leak due to overeager state merging [PR103217]
PR analyzer/103217 reports a false positive from -Wanalyzer-malloc-leak.
The root cause is due to overzealous state merger, where the
state-merging code decided to merge these two states by merging
the stores:
state A:
clusters within frame: ‘main’@1
cluster for: one_3: CONJURED(val_4 = strdup (src_2(D));, val_4)
cluster for: two_4: UNKNOWN(char *)
cluster for: one_21: CONJURED(val_4 = strdup (src_2(D));, val_4)
state B:
clusters within frame: ‘main’@1
cluster for: one_3: UNKNOWN(char *)
cluster for: two_4: CONJURED(val_4 = strdup (src_2(D));, val_4)
cluster for: two_18: CONJURED(val_4 = strdup (src_2(D));, val_4)
into:
clusters within frame: ‘main’@1
cluster for: one_3: UNKNOWN(char *)
cluster for: two_4: UNKNOWN(char *)
cluster for: one_21: UNKNOWN(char *)
cluster for: two_18: UNKNOWN(char *)
despite "CONJURED(val_4 = strdup (src_2(D));, val_4)" having sm-state,
in this case malloc:nonnull ({free}), thus leading to both references
to the conjured svalue being lost at merger.
This patch tweaks the state merger code so that it will not consider
merging two different svalues for the value of a region if either svalue
has non-purgable sm-state (in the above example, malloc:nonnull). This
fixes the false leak report above.
Doing so uncovered an issue with explode-2a.c in which the warnings
moved from the correct location to the "while" stmt. This turned out
to be a missing call to detect_leaks in phi-handling, which the patch
also fixes (in the PK_BEFORE_SUPERNODE case in
exploded_graph::process_node). Doing this fixed the regression in
explode-2a.c and also fixed the location of the leak warning in
explode-1.c.
The other side effect of the change is that pr94858-1.c now emits
a -Wanalyzer-too-complex warning, since pertinent state is no longer
being thrown away. There doesn't seem to be a good way of avoiding
this, so the patch also adds -Wno-analyzer-too-complex to that test
case (restoring the default).
gcc/analyzer/ChangeLog:
PR analyzer/103217
* engine.cc (exploded_graph::get_or_create_node): Pass in
m_ext_state to program_state::can_merge_with_p.
(exploded_graph::process_worklist): Likewise.
(exploded_graph::maybe_process_run_of_before_supernode_enodes):
Likewise.
(exploded_graph::process_node): Add missing call to detect_leaks
when handling phi nodes.
* program-state.cc (program_state::can_merge_with_p): Add
"ext_state" param. Pass it and state ptrs to
region_model::can_merge_with_p.
(selftest::test_program_state_merging): Update for new ext_state
param of program_state::can_merge_with_p.
(selftest::test_program_state_merging_2): Likewise.
* program-state.h (program_state::can_purge_p): Make const.
(program_state::can_merge_with_p): Add "ext_state" param.
* region-model.cc: Include "analyzer/program-state.h".
(region_model::can_merge_with_p): Add params "ext_state",
"state_a", and "state_b", use them when creating model_merger
object.
(model_merger::mergeable_svalue_p): New.
* region-model.h (region_model::can_merge_with_p): Add params
"ext_state", "state_a", and "state_b".
(model_merger::model_merger) Likewise, initializing new fields.
(model_merger::mergeable_svalue_p): New decl.
(model_merger::m_ext_state): New field.
(model_merger::m_state_a): New field.
(model_merger::m_state_b): New field.
* svalue.cc (svalue::can_merge_p): Call
model_merger::mergeable_svalue_p on both states and reject the
merger accordingly.
gcc/testsuite/ChangeLog:
PR analyzer/103217
* gcc.dg/analyzer/explode-1.c: Update for improvement to location
of leak warning.
* gcc.dg/analyzer/pr103217.c: New test.
* gcc.dg/analyzer/pr94858-1.c: Add -Wno-analyzer-too-complex.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Jonathan Wakely [Fri, 19 Nov 2021 13:33:24 +0000 (13:33 +0000)]
libstdc++: Improve tests for stringstream constructors in C++20
This ensures all constructors are checked.
libstdc++-v3/ChangeLog:
* testsuite/27_io/basic_istringstream/cons/char/1.cc: Check all
constructors.
* testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc:
Likewise.
* testsuite/27_io/basic_ostringstream/cons/char/1.cc: Likewise.
* testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc:
Likewise.
* testsuite/27_io/basic_stringstream/cons/char/1.cc: Likewise.
* testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc:
Likewise.
Jonathan Wakely [Fri, 19 Nov 2021 12:26:49 +0000 (12:26 +0000)]
libstdc++: Use __is_single_threaded in locale initialization
This replaces a __gthread_active_p() check with __is_single_threaded()
so that std::locale initialization doesn't use __gthread_once if it
happens before the first thread is created.
This means that _S_initialize_once() might now be called twice instead
of only once, because if __is_single_threaded() changes to false then we
will do the __gthread_once call even if _S_initialize_once() was already
called. Add a check to _S_initialize_once() and return immediately if
it is the second call.
Also use __builtin_expect to _S_initialize, as the branch will be taken
at most once in the lifetime of the program.
libstdc++-v3/ChangeLog:
* src/c++98/locale_init.cc (_S_initialize_once): Check if
initialization has already been done.
(_S_initialize): Replace __gthread_active_p with
__is_single_threaded. Use __builtin_expect.
Jonathan Wakely [Fri, 19 Nov 2021 18:27:59 +0000 (18:27 +0000)]
libstdc++: One more change for Clang to support constexpr std::string [PR103295]
All writes into the allocated buffer need to be via traits_type::assign
to begin lifetimes.
libstdc++-v3/ChangeLog:
PR libstdc++/103295
* include/bits/basic_string.tcc (_M_construct): Use the
traits assign member to write into allcoated memory.
Paul A. Clarke [Fri, 22 Oct 2021 17:09:43 +0000 (12:09 -0500)]
rs6000: Add optimizations for _mm_sad_epu8
Power9 ISA added `vabsdub` instruction which is realized in the
`vec_absd` instrinsic.
Use `vec_absd` for `_mm_sad_epu8` compatibility intrinsic, when
`_ARCH_PWR9`.
Also, the realization of `vec_sum2s` on little-endian includes
two rotates in order to position the input and output to match
the semantics of `vec_sum2s`:
- Rotate the second input vector left 12 bytes. In the current usage,
that vector is `{0}`, so this shift is unnecessary, but is currently
not eliminated under optimization.
- Rotate the vector produced by the `vsum2sws` instruction left 4 bytes.
The two words within each doubleword of this (rotated) result must then
be explicitly swapped to match the semantics of `_mm_sad_epu8`,
effectively reversing this rotate. So, this rotate (and a susequent
swap) are unnecessary, but not currently removed under optimization.
Using `__builtin_altivec_vsum2sws` retains both rotates, so is not an
option for removing the rotates.
For little-endian, use the `vsum2sws` instruction directly, and
eliminate the explicit rotate (swap).
2021-11-19 Paul A. Clarke <pc@us.ibm.com>
gcc
* config/rs6000/emmintrin.h (_mm_sad_epu8): Use vec_absd when
_ARCH_PWR9, optimize vec_sum2s when LE.
Marek Polacek [Fri, 19 Nov 2021 19:54:18 +0000 (14:54 -0500)]
c++: Fix cpp0x/lambda/lambda-nested9.C with C++11
Unfortunately dejagnu doesn't honor #if/#endif, so this test was failing
with -std=c++11:
FAIL: g++.dg/cpp0x/lambda/lambda-nested9.C -std=c++11 (test for errors, line 37)
Fixed thus.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/lambda/lambda-nested9.C: Adjust dg-error.
Iain Sandoe [Mon, 20 Sep 2021 17:41:56 +0000 (18:41 +0100)]
Darwin: Rework handling for unwinder code in libgcc_s and specs [PR80556].
This addresses a long-standing problem where a work-around for an unwinder
issue (also a regression) regresses other functionality. The patch replaces
several work-arounds with a fix for PR80556 and a work-around for PR88590.
* The fix for PR80556 requires a bump to the SO name for libgcc_s, since we
need to remove the unwinder symbols from it. This would trigger PR88590
hence the work-around for that.
* We weaken the symbols for emulated TLS support so that it is possible
for a DSO linked with static-libgcc to interoperate with a DSO linked with
libgcc_s. Likewise main exes.
* We remove all the gcc-4.2.1 era stubs machinery and workarounds.
* libgcc is always now linked ahead of libc, which avoids fails where the
libc (libSystem) builtins implementations are not up to date.
* The unwinder now always comes from the system
- for Darwin9 from /usr/lib/libgcc_s.1.dylib
- for Darwin10 from /usr/lib/libSystem.dylib
- for Darwin11+ from /usr/lib/system/libunwind.dylib.
We still insert a shim on Darwin10 to fix an omitted unwind function, but
the underlying unwinder remains the system one.
* The work-around for PR88590 has two parts (1) we always link libgcc from
its convenience lib on affected system versions (avoiding the need to find
the DSO path); (2) we add and export the emutls functions from DSOs - this
makes a relatively small (20k) addition to a DSO. These can be backed out
when a proper fix for PR88590 is committed.
For distributions that wish to install a libgcc_s.1.dylib to satisfy linkage
from exes that linked against the stubs can use a reexported libgcc_s.1.1
(since that contains all the symbols that were previously exported via the
stubs).
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:
PR target/80556
* config/darwin-driver.c (darwin_driver_init): Handle exported
symbols and symbol lists (suppress automatic export of the TLS
symbols).
* config/darwin.c (darwin_rename_builtins): Remove workaround.
* config/darwin.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise.
(REAL_LIBGCC_SPEC): Handle revised library uses.
* config/darwin.opt (nodefaultexport): New.
* config/i386/darwin.h (PR80556_WORKAROUND): Remove.
* config/i386/darwin32-biarch.h (PR80556_WORKAROUND): Likewise.
* config/i386/darwin64-biarch.h (PR80556_WORKAROUND): Likewise.
libgcc/ChangeLog:
* config.host: Add weak emutls crt to the extra_parts.
* config/i386/darwin-lib.h (DECLARE_LIBRARY_RENAMES): Remove
workaround.
* config/libgcc-libsystem.ver: Add exclude list for the system-
provided unwinder.
* config/t-slibgcc-darwin: Bump SO version, remove stubs code.
* config/i386/libgcc-darwin.10.4.ver: Removed.
* config/i386/libgcc-darwin.10.5.ver: Removed.
* config/rs6000/libgcc-darwin.10.4.ver: Removed.
* config/rs6000/libgcc-darwin.10.5.ver: Removed.
* config/t-darwin-noeh: New file.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/fp-int-convert-timode-3.c: Remove XFAIL.
* gcc.dg/torture/fp-int-convert-timode-4.c: Likewise.
Iain Sandoe [Sun, 19 Sep 2021 11:35:46 +0000 (12:35 +0100)]
libgcc, emutls: Allow building weak definitions of the emutls functions.
In order to better support use of the emulated TLS between objects with
DSO dependencies and static-linked libgcc, allow a target to make weak
definitions.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libgcc/ChangeLog:
* config/t-darwin: Build weak-defined emutls objects.
* emutls.c (__emutls_get_address): Add optional attributes.
(__emutls_register_common): Likewise.
(EMUTLS_ATTR): New.
Iain Sandoe [Fri, 19 Nov 2021 15:52:29 +0000 (15:52 +0000)]
libstdc++, testsuite: Add a prune expression for external tool bug.
Depending on the permutation of CPU, OS version and shared/non-
shared library inclusion, we get can get warnings from the external
tools (ld64, dsymutil) which are not actually libstdc++ issues but
relate to the external tools themselves. This is already pruned
in the main testsuite, this adds it to the library.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libstdc++-v3/ChangeLog:
* testsuite/lib/prune.exp: Prune dsymutil (ld64) warning.
Iain Sandoe [Fri, 19 Nov 2021 15:48:53 +0000 (15:48 +0000)]
libphobos, testsuite: Add prune clauses for two Darwin cases.
Depending on the permutation of CPU, OS version and shared/non-
shared library inclusion, we get can get two warnings from the
external tools (ld64, dsymutil) which are not actually GCC issues
but relate to the external tools. These are alrrady pruned in
the main testsuite, this adds them to the library.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
libphobos/ChangeLog:
* testsuite/lib/libphobos.exp: Prune warnings from external
tool bugs.
Jonathan Wakely [Fri, 19 Nov 2021 18:13:10 +0000 (18:13 +0000)]
libstdc++: Suppress -Wstringop warnings [PR103332]
libstdc++-v3/ChangeLog:
PR libstdc++/103332
PR libstdc++/102958
* testsuite/21_strings/basic_string/capacity/char/1.cc: Add
-Wno-stringop-overflow.
* testsuite/21_strings/basic_string/operators/char/1.cc:
Likewise.
* testsuite/experimental/filesystem/path/factory/u8path-char8_t.cc:
Add -Wno-stringop-overread.
Jonathan Wakely [Thu, 18 Nov 2021 10:33:14 +0000 (10:33 +0000)]
libstdc++: Begin lifetime of chars in constexpr std::string [PR103295]
Clang gives errors for constexpr std::string because the memory returned
by std::allocator<T>::allocate does not contain any objects yet, and
attempting to set them using char_traits::assign or char_traits::copy
fails with:
assignment to object outside its lifetime is not allowed in a constant expression
*__result = *__first;
^
This adds code to std::char_traits to use std::construct_at to begin
lifetimes when called during constant evaluation. To support
specializations of std::basic_string that don't use std::char_traits
there is now another layer of wrapper around the allocator_traits, so
that the lifetime of characters is begun as soon as the memory is
allocated. By doing it in the char traits and allocator traits, the rest
of basic_string can ignore the problem.
While modifying char_traits::copy and char_traits::assign to begin
lifetimes for the constexpr cases, I also replaced their uses of
std::copy and std::fill_n respectively. That means we don't need
<bits/stl_algobase.h> for char_traits.
libstdc++-v3/ChangeLog:
PR libstdc++/103295
* include/bits/basic_string.h (_Alloc_traits): Replace typedef
with struct for C++20 mode.
* include/bits/basic_string.tcc (_M_replace): Use _Alloc_traits
for allocation.
* include/bits/char_traits.h (__gnu_cxx::char_traits::assign):
Use std::_Construct during constant evaluation.
(__gnu_cxx::char_traits::assign(CharT*, const CharT*, size_t)):
Likewise. Replace std::fill_n with memset or manual loop.
(__gnu_cxx::char_traits::copy): Likewise, replacing std::copy
with memcpy.
* include/ext/vstring.h: Include <bits/stl_algobase.h> for
std::min.
* include/std/string_view: Likewise.
* testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc:
Add constexpr test.
Martin Jambor [Fri, 19 Nov 2021 17:46:00 +0000 (18:46 +0100)]
options: Make -Ofast switch off -fsemantic-interposition
Using -fno-semantic-interposition has been reported by various people
to bring about considerable speed up at the cost of strict compliance
to the ELF symbol interposition rules See for example
https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup
As such I believe it should be implied by our -Ofast optimization
level, not only so that benchmarks that can benefit run faster, but
also so that people looking at -Ofast documentation for options that
could speed their programs find it.
gcc/ChangeLog:
2021-11-12 Martin Jambor <mjambor@suse.cz>
* opts.c (default_options_table): Switch off
flag_semantic_interposition at Ofast.
* doc/invoke.texi (Optimize Options): Document that Ofast switches off
-fsemantic-interposition.
Jan Hubicka [Fri, 19 Nov 2021 17:09:13 +0000 (18:09 +0100)]
Use modref even for nested functions in ref_maybe_used_by_call_p_1
Remove test for function not having call chain guarding modref use in
ref_maybe_used_by_call_p_1. It never made sense since modref treats call chain
accesses explicitly. It was however copied from earlier check for ECF_CONST
(which seems dubious too, but I would like to discuss it independelty).
This enables us to detect that memory pointed to static chain (or parts of it)
are unused by the function.
lto-bootstrapped-regtested all lanugages on x86_64-linux.
gcc/ChangeLog:
2021-11-19 Jan Hubicka <hubicka@ucw.cz>
* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Do not guard modref
by !gimple_call_chain.
gcc/testsuite/ChangeLog:
2021-11-19 Jan Hubicka <hubicka@ucw.cz>
* gcc.dg/tree-ssa/modref-dse-6.c: New test.
Martin Sebor [Fri, 19 Nov 2021 16:44:31 +0000 (09:44 -0700)]
Restore ancient -Waddress for weak symbols [PR33925].
Resolves:
PR c/33925 - gcc -Waddress lost some useful warnings
PR c/102867 - -Waddress from macro expansion in readelf.c
gcc/c-family/ChangeLog:
PR c++/33925
PR c/102867
* c-common.c (decl_with_nonnull_addr_p): Call maybe_nonzero_address
and improve handling tof defined symbols.
gcc/c/ChangeLog:
PR c++/33925
PR c/102867
* c-typeck.c (maybe_warn_for_null_address): Suppress warnings for
code resulting from macro expansion.
gcc/cp/ChangeLog:
PR c++/33925
PR c/102867
* typeck.c (warn_for_null_address): Suppress warnings for code
resulting from macro expansion.
gcc/ChangeLog:
PR c++/33925
PR c/102867
* doc/invoke.texi (-Waddress): Update.
gcc/testsuite/ChangeLog:
PR c++/33925
PR c/102867
* g++.dg/warn/Walways-true-2.C: Adjust to avoid a valid warning.
* c-c++-common/Waddress-5.c: New test.
* c-c++-common/Waddress-6.c: New test.
* g++.dg/warn/Waddress-7.C: New test.
* gcc.dg/Walways-true-2.c: Adjust to avoid a valid warning.
* gcc.dg/weak/weak-3.c: Expect a warning.
Andrew MacLeod [Wed, 17 Nov 2021 19:14:06 +0000 (14:14 -0500)]
Limit depth for all GORI expressions.
Apply the logical_depth limit ranger uses to all stmts with multiple ssa-names
to avoid excessive outgoing calculations.
gcc/
PR tree-optimization/103254
* gimple-range-gori.cc (range_def_chain::get_def_chain): Limit the
depth for all statements with multple ssa names.
gcc/testsuite/
* gcc.dg/pr103254.c: New.
Stefan Schulze Frielinghaus [Fri, 19 Nov 2021 15:56:56 +0000 (16:56 +0100)]
IBM Z: Fix load-and-test peephole2 condition
For a peephole2 condition variable insn points to the first matched
insn. In order to refer to the second matched insn use
peep2_next_insn(1) instead.
gcc/ChangeLog:
* config/s390/s390.md (define_peephole2): Variable insn points
to the first matched insn. Use peep2_next_insn(1) to refer to
the second matched insn.
gcc/testsuite/ChangeLog:
* gcc.target/s390/
20211119.c: New test.
Tamar Christina [Fri, 19 Nov 2021 15:12:38 +0000 (15:12 +0000)]
middle-end: Handle FMA_CONJ correctly after SLP layout update.
Apologies, I got dinged by the i386 regressions bot for a test I didn't have in
my tree at the time I made the previous patch. The bot was telling me that FMA
stopped working after I strengthened the FMA check in the previous patch.
The reason is that the check is slightly early. The first check can indeed only
exit early when either node isn't a mult. However we need to delay till we know
if the node is a MUL or FMA before enforcing that both nodes must be a MULT
since the node to inspect is different if the operation is a MUL or FMA.
Also with the update patch for GCC 11 tree layout update to the new GCC 12 one
I had missed that the difference in which node is conjucated is not symmetrical.
So the test for it can just be testing the inverse order. It was Currently
no detecting when the first node was conjucated instead of the second one.
This also made me wonder why my own test didn't detect this. It turns out that
the tests, being copied from the _Float16 ones were incorrectly marked as
xfail. The _Float16 ones are marked as xfail since C doesn't have a conj
operation for _Float16, which means you get extra type-casts in between.
While you could use the GCC _Complex extension here I opted to mark them xfail
since I wanted to include detection over the widenings next year.
Secondly the double tests were being skipped because Adv. SIMD was missing from
targets supporting Complex Double vectorization.
With these changes all other tests run and pass and only XFAIL ones are
correctly the _Float16 ones. Sorry for missing this before, testing should now
cover all cases.
gcc/ChangeLog:
PR tree-optimization/103311
PR target/103330
* tree-vect-slp-patterns.c (vect_validate_multiplication): Fix CONJ
test to new codegen.
(complex_mul_pattern::matches): Move check downwards.
gcc/testsuite/ChangeLog:
PR tree-optimization/103311
PR target/103330
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-double.c: Fix it.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-double.c: Likewise.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-double.c: Likewise.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-float.c: Likewise.
* lib/target-supports.exp
(check_effective_target_vect_complex_add_double): Add Adv. SIMD.
Martin Liska [Fri, 19 Nov 2021 14:29:35 +0000 (15:29 +0100)]
Revert "Remove MAY_HAVE_DEBUG_MARKER_STMTS and MAY_HAVE_DEBUG_BIND_STMTS."
This reverts commit
206b22d021d94adbaa79e1d443c87415254b15de.
Giuliano Belinassi [Tue, 16 Nov 2021 16:25:32 +0000 (13:25 -0300)]
Do not abort compilation when dump file is /dev/*
The `configure` scripts generated with autoconf often tests compiler
features by setting output to `/dev/null`, which then sets the dump
folder as being /dev/* and the compilation halts with an error because
GCC cannot create files in /dev/. This is a problem when configure is
testing for compiler features because it cannot tell if the failure was
due to unsupported features or any other problem, and disable it even
if it is working.
As an example, running configure overriding CFLAGS="-fdump-ipa-clones"
will result in several compiler-features as being disabled because of
gcc halting with an error creating files in /dev/*.
This commit fixes this issue by checking if the output file is
/dev/null or /dev/zero. In this case we use the current working
directory for dump output instead of the directory of the output
file because we cannot write to /dev/*.
gcc/ChangeLog
2021-11-16 Giuliano Belinassi <gbelinassi@suse.de>
* gcc.c (process_command): Skip dumpdir override if file is a
not_actual_file_p.
* doc/invoke.texi: Update -dumpdir documentation.
gcc/testsuite/ChangeLog
2021-11-16 Giuliano Belinassi <gbelinassi@suse.de>
* gcc.dg/devnull-dump.c: New.
Signed-off-by: Giuliano Belinassi <gbelinassi@suse.de>
Patrick Palka [Fri, 19 Nov 2021 14:01:09 +0000 (09:01 -0500)]
c++: cp_walk_subtrees simplification for *_CAST_EXPR
Let walk_tree_1 do the operand walking for us.
gcc/cp/ChangeLog:
* tree.c (cp_walk_subtrees) <case *_CAST_EXPR>: Don't explicitly
walk the operands.
Patrick Palka [Fri, 19 Nov 2021 13:54:25 +0000 (08:54 -0500)]
c++: nested lambda capturing a capture proxy [PR94376]
Here when determining the type of the FIELD_DECL for the by-value capture
of 'i' in the inner lambda, we incorrectly give it the type const int
instead of int since the effective initializer is the proxy for the outer
capture, and this proxy is const since the outer lambda is non-mutable.
This patch fixes this by making lambda_capture_field_type handle
by-value capturing of capture proxies specially, namely we instead
consider the type of their FIELD_DECL which unlike the proxy has the
true cv-quals of the captured entity.
PR c++/94376
gcc/cp/ChangeLog:
* lambda.c (lambda_capture_field_type): Simplify by handling the
is_this case first. When capturing by-value a capture proxy,
consider the type of the corresponding field instead.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/lambda/lambda-nested9.C: New test.
Iain Buclaw [Fri, 19 Nov 2021 13:43:07 +0000 (14:43 +0100)]
libphobos: Increase size of defaultStackPages on OSX X86_64 targets.
As of macOS 11, libunwind now requires more stack space than 16k, so
default to a larger stack size. This is only applied to X86 as the
PAGESIZE is still 4k, however on AArch64 it is 16k.
libphobos/ChangeLog:
* libdruntime/core/thread/fiber.d (defaultStackPages): Increase size
on OSX X86_64 targets.
Iain Buclaw [Fri, 19 Nov 2021 13:26:07 +0000 (14:26 +0100)]
libphobos: Don't call __gthread_key_delete in the emutls destroy function.
Fixes a EXC_BAD_ACCESS issue seen on Darwin when the libphobos DSO gets
unloaded. Based on reading libgcc's emutls implementation, as it
doesn't call __gthread_key_delete directly, neither should libphobos.
libphobos/ChangeLog:
* libdruntime/gcc/emutls.d (emutlsDestroyThread): Don't remove entry
from global array.
(_d_emutls_destroy): Don't call __gthread_key_delete.
Andrew Pinski [Fri, 19 Nov 2021 01:42:41 +0000 (01:42 +0000)]
Fix tree-optimization/103314 : Limit folding of (type) X op CST where type is a nop convert to gimple
There is some re-association code in fold_binary which conflicts with
this optimization due keeping around some "constants" which are not
INTEGER_CST (1 << -1) so we end up in an infinite loop because of that.
So we need to limit this case to GIMPLE level only.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR tree-optimization/103314
gcc/ChangeLog:
* match.pd ((type) X op CST): Restrict the equal
TYPE_PRECISION case to GIMPLE only.
gcc/testsuite/ChangeLog:
* gcc.c-torture/compile/pr103314-1.c: New test.
Martin Liska [Thu, 18 Nov 2021 12:14:25 +0000 (13:14 +0100)]
Fix IPA modref ubsan.
modref_tree<tree_node*>::merge(modref_tree<tree_node*>*, vec<modref_parm_map, va_heap, vl_ptr>*, modref_parm_map*, bool)
is called with modref_parm_map chain_map;
The variable has uninitialized m.parm_offset_known and it is accessed
here:
gcc/ipa-modref-tree.h:572 a.parm_offset_known &= m.parm_offset_known;
PR ipa/103230
gcc/ChangeLog:
* ipa-modref-tree.h (struct modref_parm_map): Add default
constructor.
* ipa-modref.c (ipa_merge_modref_summary_after_inlining): Use it.
Richard Biener [Fri, 19 Nov 2021 07:54:18 +0000 (08:54 +0100)]
c++/103326 - fix ICE in tsubst with VECTOR_CST
This adds missing handling of VECTOR_CST.
2021-11-19 Richard Biener <rguenther@suse.de>
PR c++/103326
* pt.c (tsubst_copy): Handle VECTOR_CST.
* g++.dg/pr103326.C: New testcase.
Jakub Jelinek [Fri, 19 Nov 2021 09:05:01 +0000 (10:05 +0100)]
c++: Fix up -fstrong-eval-order handling of call arguments [PR70796]
For -fstrong-eval-order (default for C++17 and later) we make sure to
gimplify arguments in the right order, but as the following testcase
shows that is not enough.
The problem is that some lvalues can satisfy the is_gimple_val / fb_rvalue
predicate used by gimplify_arg for is_gimple_reg_type typed expressions,
or is_gimple_lvalue / fb_either used for other types.
E.g. in foo we have:
C::C (&p, ++i, ++i)
before gimplification where i is an automatic int variable and without this
patch gimplify that as:
i = i + 1;
i = i + 1;
C::C (&p, i, i);
which means that the ctor is called with the original i value incremented
by 2 in both arguments, while because the call is CALL_EXPR_ORDERED_ARGS
the first argument should be different. Similarly in qux we have:
B::B (&p, TARGET_EXPR <D.2274, *(const struct A &) A::operator++ (&i)>,
TARGET_EXPR <D.2275, *(const struct A &) A::operator++ (&i)>)
and gimplify it as:
_1 = A::operator++ (&i);
_2 = A::operator++ (&i);
B::B (&p, MEM[(const struct A &)_1], MEM[(const struct A &)_2]);
but because A::operator++ returns the passed in argument, again we have
the same value in both cases due to gimplify_arg doing:
/* Also strip a TARGET_EXPR that would force an extra copy. */
if (TREE_CODE (*arg_p) == TARGET_EXPR)
{
tree init = TARGET_EXPR_INITIAL (*arg_p);
if (init
&& !VOID_TYPE_P (TREE_TYPE (init)))
*arg_p = init;
}
which is perfectly fine optimization for calls with unordered arguments,
but breaks the ordered ones.
Lastly, in corge, we have before gimplification:
D::foo (NON_LVALUE_EXPR <p>, 3, ++p)
and gimplify it as
p = p + 4;
D::foo (p, 3, p);
which is again wrong, because the this argument isn't before the
side-effects but after it.
The following patch adds cp_gimplify_arg wrapper, which if ordered
and is_gimple_reg_type forces non-SSA_NAME is_gimple_variable
result into a temporary, and if ordered, not is_gimple_reg_type
and argument is TARGET_EXPR bypasses the gimplify_arg optimization.
So, in foo with this patch we gimplify it as:
i = i + 1;
i.0_1 = i;
i = i + 1;
C::C (&p, i.0_1, i);
in qux as:
_1 = A::operator++ (&i);
D.2312 = MEM[(const struct A &)_1];
_2 = A::operator++ (&i);
B::B (&p, D.2312, MEM[(const struct A &)_2]);
where D.2312 is a temporary and in corge as:
p.9_1 = p;
p = p + 4;
D::foo (p.9_1, 3, p);
The is_gimple_reg_type forcing into a temporary should be really cheap
(I think even at -O0 it should be optimized if there is no modification in
between), the aggregate copies might be more expensive but I think e.g. SRA
or FRE should be able to deal with those if there are no intervening
changes. But still, the patch tries to avoid those when it is cheaply
provable that nothing bad happens (if no argument following it in the
strong evaluation order doesn't have TREE_SIDE_EFFECTS, then even VAR_DECLs
etc. shouldn't be modified after it). There is also an optimization to
avoid doing that for this or for arguments with reference types as nothing
can modify the parameter values during evaluation of other argument's
side-effects.
I've tried if e.g.
int i = 1;
return i << ++i;
doesn't suffer from this problem as well, but it doesn't, the FE uses
SAVE_EXPR <i>, SAVE_EXPR <i> << ++i;
in that case which gimplifies the way we want (temporary in the first
operand).
2021-11-19 Jakub Jelinek <jakub@redhat.com>
PR c++/70796
* cp-gimplify.c (cp_gimplify_arg): New function.
(cp_gimplify_expr): Use cp_gimplify_arg instead of gimplify_arg,
pass true as last argument to it if there are any following
arguments in strong evaluation order with side-effects.
* g++.dg/cpp1z/eval-order11.C: New test.
Tamar Christina [Fri, 19 Nov 2021 08:48:11 +0000 (08:48 +0000)]
libstdc++: Fix ctype changed after newlib update.
Newlib changed ctype.h recently[1] by moving the short labels from ctype.h intro
the private namespace in ctype_.h. This broke embedded builds due to them no
longer being found. Instead they now expose the long names to match glibc.
This patch now uses the short or long names depending on is the short ones are
defined or not.
[1] https://github.com/bminor/newlib/commit/
3ba1bd0d9dbc015c14a0aaafcef042f706d1249a
libstdc++-v3/ChangeLog:
PR libstdc++/103305
* config/os/newlib/ctype_base.h (upper, lower, alpha, digit, xdigit,
space, print, graph, cntrl, punct, alnum, blank): Use short or long
names depending on if short ones are defined.
Richard Biener [Tue, 16 Nov 2021 10:47:26 +0000 (11:47 +0100)]
middle-end/103248 - fix RDIV_EXPR handling with fixed point
This fixes the previous adjustment to operation_could_trap_helper_p
where I failed to realize that RDIV_EXPR is also used for
fixed-point types. It also fixes that handling by properly
checking for a fixed_zerop divisor.
2021-11-16 Richard Biener <rguenther@suse.de>
PR middle-end/103248
* tree-eh.c (operation_could_trap_helper_p): Properly handle
fixed-point RDIV_EXPR.
* gcc.dg/pr103248.c: New testcase.
Richard Biener [Thu, 18 Nov 2021 12:40:32 +0000 (13:40 +0100)]
tree-optimization/102436 - restore loop store motion
This restores a case of conditional store motion we fail to handle
after the rewrite. We can recognize the special case of all
stores in a loop happening in a single conditionally executed
block which ensures stores are not re-ordered by executing them
in different loop iterations. Separating out the case avoids
complicating the already complex main path.
2021-11-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/102436
* tree-ssa-loop-im.c (execute_sm_if_changed): Add mode
to just create the if structure and return the then block.
(execute_sm): Add flag to indicate the var will re-use
another flag var.
(hoist_memory_references): Support a single conditional
block with all stores as special case.
* gcc.dg/torture/
20211118-1.c: New testcase.
* gcc.dg/tree-ssa/ssa-lim-18.c: Likewise.
Andrew Pinski [Thu, 18 Nov 2021 23:38:30 +0000 (23:38 +0000)]
Fix PR 103317, ICE after PHI-OPT, minmax_replacement producing invalid SSA
The problem is r12-5300-gf98f373dd822b35c allows phiopt to recognize more basic blocks
but missed one location where the basic block does not need to be empty but still
needs to have a single predecessor. This patch fixes that over sight.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR tree-optimization/103317
gcc/ChangeLog:
* tree-ssa-phiopt.c (minmax_replacement): For the non empty
middle bb case, check to make sure it has a single predecessor.
gcc/testsuite/ChangeLog:
* gcc.c-torture/compile/pr103317-1.c: New test.
Andrew Pinski [Tue, 16 Nov 2021 04:46:21 +0000 (04:46 +0000)]
Fix tree-optimization/103257: Missed jump threading due too early conversion of bool*A into bool?A:0
So like many optimizations on the gimple level, sometimes it makes sense to do the
optimization early or later. In this case, creating a cond expression early causes
other optimizations to be missed. So just disable it until canonicalize_math_p ()
is false.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR tree-optimization/103257
gcc/ChangeLog:
* match.pd
((m1 >/</>=/<= m2) * d -> (m1 >/</>=/<= m2) ? d : 0):
Disable until !canonicalize_math_p ().
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/vrp116.c: Check optimized instead of vrp1.
* gcc.dg/tree-ssa/pr103257-1.c: New test.
Marek Polacek [Wed, 11 Nov 2020 01:07:24 +0000 (20:07 -0500)]
c++: Implement -Wuninitialized for mem-initializers (redux) [PR19808]
2021 update: Last year I posted a version of this patch:
<https://gcc.gnu.org/pipermail/gcc-patches/2020-November/559162.html>
but it didn't make it in. The main objection seemed to be that the
patch tried to do too much, and overlapped with the ME uninitialized
warnings. Since the patch used walk_tree without any data flow info,
it issued false positives for things like a(0 ? b : 42) and similar.
I'll admit I've been dreading resurrecting this because of the lack
of clarity about where we should warn about what. On the other hand,
I think we really should do something about this. So I've simplified
the original patch as much as it seemed reasonable. For instance, it
doesn't even attempt to handle cases like "a((b = 42)), c(b)" -- for
these I simply give up for the whole mem-initializer (but who writes
code like that, anyway?). I also give up when a member is initialized
with a function call, because we don't know what the call could do.
See Wuninitialized-17.C, for which clang emits a false positive but
we don't. I remember having a hard time dealing with initializer lists
in my previous patch, so now I only handle simple a{b} cases, but no
more. It turned out that this abridged version still warns about 90%
cases where users would expect a warning.
More complicated cases are left for the ME, which, for unused inline
functions, will only warn with -fkeep-inline-functions, but so be it.
(This is bug 21678.)
This patch implements the long-desired -Wuninitialized warning for
member initializer lists, so that the front end can detect bugs like
struct A {
int a;
int b;
A() : b(1), a(b) { }
};
where the field 'b' is used uninitialized because the order of member
initializers in the member initializer list is irrelevant; what matters
is the order of declarations in the class definition.
I've implemented this by keeping a hash set holding fields that are not
initialized yet, so at first it will be {a, b}, and after initializing
'a' it will be {b} and so on. Then I use walk_tree to walk the
initializer and if we see that an uninitialized object is used, we warn.
Of course, when we use the address of the object, we may not warn:
struct B {
int &r;
int *p;
int a;
B() : r(a), p(&a), a(1) { } // ok
};
Likewise, don't warn in unevaluated contexts such as sizeof. Classes
without an explicit initializer may still be initialized by their
default constructors; whether or not something is considered initialized
is handled in perform_member_init, see member_initialized_p.
PR c++/19808
PR c++/96121
gcc/cp/ChangeLog:
* init.c (perform_member_init): Remove a forward declaration.
Walk the initializer using find_uninit_fields_r. New parameter
to track uninitialized fields. If a member is initialized,
remove it from the hash set.
(perform_target_ctor): Return the initializer.
(struct find_uninit_data): New class.
(find_uninit_fields_r): New function.
(find_uninit_fields): New function.
(emit_mem_initializers): Keep and initialize a set holding fields
that are not initialized. When handling delegating constructors,
walk the constructor tree using find_uninit_fields_r. Also when
initializing base clases. Pass uninitialized down to
perform_member_init.
gcc/ChangeLog:
* doc/invoke.texi: Update documentation for -Wuninitialized.
* tree.c (stabilize_reference): Set location.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wuninitialized-14.C: New test.
* g++.dg/warn/Wuninitialized-15.C: New test.
* g++.dg/warn/Wuninitialized-16.C: New test.
* g++.dg/warn/Wuninitialized-17.C: New test.
* g++.dg/warn/Wuninitialized-18.C: New test.
* g++.dg/warn/Wuninitialized-19.C: New test.
* g++.dg/warn/Wuninitialized-20.C: New test.
* g++.dg/warn/Wuninitialized-21.C: New test.
* g++.dg/warn/Wuninitialized-22.C: New test.
* g++.dg/warn/Wuninitialized-23.C: New test.
* g++.dg/warn/Wuninitialized-24.C: New test.
* g++.dg/warn/Wuninitialized-25.C: New test.
* g++.dg/warn/Wuninitialized-26.C: New test.
* g++.dg/warn/Wuninitialized-27.C: New test.
* g++.dg/warn/Wuninitialized-28.C: New test.
* g++.dg/warn/Wuninitialized-29.C: New test.
* g++.dg/warn/Wuninitialized-30.C: New test.
liuhongt [Sat, 9 Oct 2021 01:42:10 +0000 (09:42 +0800)]
Reduce cost of aligned sse register store.
Make them be equal to cost of unaligned ones to avoid odd alignment
peeling.
Impact for SPEC2017 on CLX:
fprate:
503.bwaves_r BuildSame
507.cactuBSSN_r -0.22
508.namd_r -0.02
510.parest_r -0.28
511.povray_r -0.20
519.lbm_r BuildSame
521.wrf_r -0.58
526.blender_r -0.30
527.cam4_r 1.07
538.imagick_r 0.01
544.nab_r -0.09
549.fotonik3d_r BuildSame
554.roms_r BuildSame
intrate:
500.perlbench_r -0.25
502.gcc_r -0.15
505.mcf_r BuildSame
520.omnetpp_r 1.03
523.xalancbmk_r -0.13
525.x264_r -0.05
531.deepsjeng_r -0.27
541.leela_r -0.24
548.exchange2_r -0.06
557.xz_r -0.10
999.specrand_ir 2.69
gcc/ChangeLog:
PR target/102543
* config/i386/x86-tune-costs.h (skylake_cost): Reduce cost of
storing 256/512-bit SSE register to be equal to cost of
unaligned store to avoid odd alignment peeling.
(icelake_cost): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr102543.c: New test.
Patrick Palka [Fri, 19 Nov 2021 00:32:22 +0000 (19:32 -0500)]
c++: implicit dummy object in requires clause [PR103198]
In the testcase below satisfaction misbehaves for f and g ultimately
because find_template_parameters fails to notice that the constraint
'val.x' depends on the template parms of the class template. In
contrast, satisfaction works just fine for h.
The problem seems to come down to a difference in how any_template_parm_r
handles 'this' vs a dummy object: it walks the TREE_TYPE of the former
but not the latter, and this causes us to miss the tparm dependencies in
f/g's constraints since in their case the implicit object parm through
which we access 'val' is a dummy object. (For h, since we know it's a
non-static member function when parsing its trailing constraints, the
implicit object parm is 'this', not a dummy object.)
This patch fixes this inconsistency by making any_template_parm_r walk
into the TREE_TYPE of a dummy object, like it already does for 'this'.
PR c++/103198
gcc/cp/ChangeLog:
* pt.c (any_template_parm_r): Walk the TREE_TYPE of a dummy
object.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-this1.C: New test.
GCC Administrator [Fri, 19 Nov 2021 00:16:34 +0000 (00:16 +0000)]
Daily bump.
Iain Buclaw [Thu, 18 Nov 2021 21:43:40 +0000 (22:43 +0100)]
d: Use HOST_WIDE_INT for type size temporaries.
These variables are later used as the value for the format specifier
`%wd`, which the expected type may not match dinteger_t, causing
unnecessary -Wformat warnings.
gcc/d/ChangeLog:
* decl.cc (d_finish_decl): Use HOST_WIDE_INT for type size
temporaries.
Marek Polacek [Wed, 3 Nov 2021 15:04:22 +0000 (11:04 -0400)]
c++: Implement C++23 P0849R8 - auto(x) [PR103049]
This patch implements P0849R8 which allows auto in a functional cast,
the result of which is a prvalue.
[expr.type.conv]/1 says that the type is determined by placeholder type
deduction. We only accept 'auto', not 'decltype(auto)' -- that the
type shall be auto comes from [dcl.type.auto.deduct]. Therefore the
rules are like for [temp.deduct.call], deducing template arguments from
a function call, so the result type will never be a reference, and we
decay arrays/functions.
PR c++/103049
gcc/cp/ChangeLog:
* semantics.c (finish_compound_literal): Accept C++23 auto{x}.
* typeck2.c (build_functional_cast_1): Accept C++23 auto(x).
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/auto25.C: Adjust dg-error.
* g++.dg/cpp0x/auto9.C: Likewise.
* g++.dg/cpp2a/concepts-pr84979-2.C: Likewise.
* g++.dg/cpp2a/concepts-pr84979-3.C: Likewise.
* g++.dg/cpp23/auto-fncast1.C: New test.
* g++.dg/cpp23/auto-fncast2.C: New test.
* g++.dg/cpp23/auto-fncast3.C: New test.
* g++.dg/cpp23/auto-fncast4.C: New test.
* g++.dg/cpp23/auto-fncast5.C: New test.
* g++.dg/cpp23/auto-fncast6.C: New test.
David Edelsohn [Thu, 18 Nov 2021 18:43:22 +0000 (13:43 -0500)]
Fix rs6000 predicates.md use of decl_replaceable_p
gcc/ChangeLog:
* config/rs6000/predicates.md (current_file_function_operand):
Add flag_semantic_interposition to call of decl_replaceable_p.
Harald Anlauf [Wed, 17 Nov 2021 21:21:24 +0000 (22:21 +0100)]
Fortran: NULL() is not interoperable
gcc/fortran/ChangeLog:
PR fortran/101329
* check.c (is_c_interoperable): Reject NULL() as it is not
interoperable.
gcc/testsuite/ChangeLog:
PR fortran/101329
* gfortran.dg/pr101329.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
Martin Liska [Thu, 18 Nov 2021 16:50:19 +0000 (17:50 +0100)]
IPA: fix reproducibility in IPA MOD REF
gcc/ChangeLog:
* ipa-modref.c (analyze_function): Do not execute the code
only if dump_file != NULL.
Martin Liska [Thu, 18 Nov 2021 16:39:23 +0000 (17:39 +0100)]
IPA: use cgraph_node instance
gcc/ChangeLog:
* ipa-modref.c (analyze_function): Use fnode instead of repeated
cgraph_node::get (current_function_decl).
Patrick Palka [Thu, 18 Nov 2021 18:10:28 +0000 (13:10 -0500)]
c++: error recovery during C++20 template-id ADL failure
When diagnosing ADL failure we try to perform a second unqualified
lookup for backwards compatibility with legacy code (via -fpermissive),
and for better diagnostics.
But for C++20 template-id ADL, the backwards compatibility code
sometimes causes confusing subsequent diagnostics such as in the
testcase below where we end up diagnosing deduction failure after
emitting the helpful "no declarations were found by ADL". This happens
because the code just discards the arguments of the template-id callee
when replacing it with the later-declared template, which leads to
overload resolution failure:
<stdin>: In instantiation of ‘void f() [with T = int]’:
<stdin>:12:22: required from here
<stdin>:5:9: error: ‘g’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
<stdin>:10:6: note: ‘template<class T> void g(int)’ declared here, later in the translation unit
<stdin>:5:9: error: no matching function for call to ‘g(int)’
<stdin>:10:6: note: candidate: ‘template<class T> void g(int)’
<stdin>:10:6: note: template argument deduction/substitution failed:
<stdin>:5:9: note: couldn’t deduce template parameter ‘T’
So for C++20 template-id ADL, this patch disables the backwards
compatibility code while keeping the helpful "no declarations were
found by ADL" diagnostic.
gcc/cp/ChangeLog:
* pt.c (tsubst_copy_and_build) <case CALL_EXPR>: Disable the
-fpermissive fallback for C++20 template-id ADL, but keep the
diagnostic.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/fn-template25.C: New test.
Jan Hubicka [Thu, 18 Nov 2021 17:42:35 +0000 (18:42 +0100)]
Turn -fsemantic-interposition to optimization flag
Turn flag_semantic_interposition to optimization option so it can be enabled
with per-function granuality. This is done by adding the flag among visibility
flags into the symbol table.
gcc/ChangeLog:
2021-11-18 Jan Hubicka <hubicka@ucw.cz>
* cgraph.c (cgraph_node::get_availability): Update call of
decl_replaceable_p.
(cgraph_node::verify_node): Verify that semantic_interposition flag
is set correclty.
* cgraph.h: (symtab_node): Add semantic_interposition flag.
* cgraphclones.c (set_new_clone_decl_and_node_flags): Clear
semantic_interposition flag.
* cgraphunit.c (cgraph_node::finalize_function): Set
semantic_interposition flag.
(cgraph_node::add_new_function): Likewise.
(varpool_node::finalize_decl): Likewise.
(cgraph_node::create_wrapper): Likewise.
* common.opt (fsemantic-interposition): Turn to optimization node.
* lto-cgraph.c (lto_output_node): Stream semantic_interposition.
(lto_output_varpool_node): Likewise.
(input_overwrite_node): Likewise.
(input_varpool_node): Likewise.
* symtab.c (symtab_node::dump_base): Dump new flag.
* varasm.c (decl_replaceable_p): Add semantic_interposition_p
parameter.
* varasm.h (decl_replaceable_p): Update declaration.
* varpool.c (varpool_node::ctor_useable_for_folding_p):
Use semantic_interposition flag.
(varpool_node::get_availability): Likewise.
(varpool_node::create_alias): Copy semantic_interposition flag.
gcc/cp/ChangeLog:
2021-11-18 Jan Hubicka <hubicka@ucw.cz>
* decl.c (finish_function): Update use of decl_replaceable_p.
gcc/lto/ChangeLog:
2021-11-18 Jan Hubicka <hubicka@ucw.cz>
* lto-partition.c (promote_symbol): Clear semantic_interposition flag.
gcc/testsuite/ChangeLog:
2021-11-18 Jan Hubicka <hubicka@ucw.cz>
* gcc.dg/lto/semantic-interposition-1_0.c: New test.
* gcc.dg/lto/semantic-interposition-1_1.c: New test.
Jan Hubicka [Thu, 18 Nov 2021 17:41:43 +0000 (18:41 +0100)]
Fix modref wrt __builtin_assume_aligned
__builtin_assume_aligned has bit contraictionary fnspec description "1cX "
which means that parameter 1 is returned but also unused. PTA code takes
precedence to parameter being returned, while modref takes the info that
parameter is unused. This patch tweaks modref to follow PTA semantics (as
suggested by Richard in the PR log)
gcc/ChangeLog:
2021-11-18 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103266
* ipa-modref.c (modref_eaf_analysis::merge_call_lhs_flags): Unused
parameter may still be returned.
(modref_eaf_analysis::analyze_ssa_name): Call merge_call_lhs_flags
even for unused function args.
gcc/testsuite/ChangeLog:
2021-11-18 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103266
* g++.dg/torture/pr103266.C: New test.
Tamar Christina [Thu, 18 Nov 2021 17:10:36 +0000 (17:10 +0000)]
middle-end: check that both sides of complex expression is a mul.
Both sides of the VEC_PERM_EXPR need to be a MULT but the check
was accidentally checking if both sides are a mul.
The FMS case would be handled by the validate_multiplication but
this makes the requirement more explicit and we exit earlier.
gcc/ChangeLog:
PR tree-optimization/103311
* tree-vect-slp-patterns.c (complex_mul_pattern::matches,
complex_fms_pattern::matches): Check for multiplications.
gcc/testsuite/ChangeLog:
PR tree-optimization/103311
* gcc.target/aarch64/pr103311.c: New test.
H.J. Lu [Wed, 27 Oct 2021 13:27:15 +0000 (06:27 -0700)]
x86: Add -mindirect-branch-cs-prefix
Add -mindirect-branch-cs-prefix to add CS prefix to call and jmp to
indirect thunk with branch target in r8-r15 registers so that the call
and jmp instruction length is 6 bytes to allow them to be replaced with
"lfence; call *%r8-r15" or "lfence; jmp *%r8-r15" at run-time.
gcc/
PR target/102952
* config/i386/i386.c (ix86_output_jmp_thunk_or_indirect): Emit
CS prefix for -mindirect-branch-cs-prefix.
(ix86_output_indirect_branch_via_reg): Likewise.
* config/i386/i386.opt: Add -mindirect-branch-cs-prefix.
* doc/invoke.texi: Document -mindirect-branch-cs-prefix.
gcc/testsuite/
PR target/102952
* gcc.target/i386/indirect-thunk-cs-prefix-1.c: New test.
* gcc.target/i386/indirect-thunk-cs-prefix-2.c: Likewise.