Commit Graph

189865 Commits

Author SHA1 Message Date
Jason Merrill 1df539fd19 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.
2021-11-22 17:43:10 -05:00
Jason Merrill 5440c88e61 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.
2021-11-22 17:42:53 -05:00
Jakub Jelinek a6e0d59370 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>
2021-11-22 22:29:20 +01:00
Roger Sayle a944b5dec3 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.
2021-11-22 18:15:36 +00:00
Martin Liska c38c547a70 docs: remove duplicate param documentation
gcc/ChangeLog:

	* doc/invoke.texi: Remove duplicate documentation for 3 params.
2021-11-22 17:37:12 +01:00
Jakub Jelinek 1aedb3920a 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.
2021-11-22 17:07:19 +01:00
Jonathan Wakely d7376862b6 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.
2021-11-22 14:57:17 +00:00
Florian Weimer f58bf16f67 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.
2021-11-22 13:31:10 +01:00
Florian Weimer 90986c5f0a 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.
2021-11-22 13:30:23 +01:00
Richard Biener f456eaf2e0 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.
2021-11-22 12:18:08 +01:00
Jakub Jelinek 4b1e14346a 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.
2021-11-22 10:13:24 +01:00
liuhongt b5844cb0bc 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.
2021-11-22 11:24:11 +08:00
Kewen Lin 2b5b8610e9 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.
2021-11-21 20:18:31 -06:00
GCC Administrator ae957bef06 Daily bump. 2021-11-22 00:16:29 +00:00
Jakub Jelinek da17c304e2 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.
2021-11-21 21:08:04 +01:00
Jakub Jelinek 364539710f 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.
2021-11-21 21:06:23 +01:00
Harald Anlauf 8fef6f720a 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>
2021-11-21 19:29:27 +01:00
Jan Hubicka 0f5afb6263 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.
2021-11-21 16:15:41 +01:00
Jan Hubicka c8260767aa 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
2021-11-21 16:13:40 +01:00
Jan Hubicka 09a4ffb72a 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.
2021-11-21 13:22:34 +01:00
Roger Sayle dc915b361b 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.
2021-11-21 11:40:08 +00:00
GCC Administrator f658f1d7a2 Daily bump. 2021-11-21 00:16:32 +00:00
Jan Hubicka ce2dbf943a 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.
2021-11-21 00:39:42 +01:00
Jan Hubicka a0e99d5bb7 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.
2021-11-21 00:35:22 +01:00
Jeff Law 7950c96ca6 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.
2021-11-20 11:30:09 -05:00
François Dumont 5f40d34b6d 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.
2021-11-20 16:11:22 +01:00
Andrew Pinski 74faa9834a 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.
2021-11-20 08:06:18 +00:00
Alexandre Oliva 38e4a361e7 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.
2021-11-20 02:51:27 -03:00
Antoni Boucher cfe8dbd9c0 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.
2021-11-19 20:45:12 -05:00
GCC Administrator 9c0773984c Daily bump. 2021-11-20 00:16:35 +00:00
Jakub Jelinek b751b225e4 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.
2021-11-19 22:09:01 +01:00
Iain Sandoe 16d1d97626 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.
2021-11-19 20:53:25 +00:00
David Malcolm f573d35147 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>
2021-11-19 15:25:27 -05:00
Jonathan Wakely be08d57317 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.
2021-11-19 20:23:50 +00:00
Jonathan Wakely 5faf1c8c7a 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.
2021-11-19 20:22:52 +00:00
Jonathan Wakely 1f8d01eb14 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.
2021-11-19 20:17:52 +00:00
Paul A. Clarke fc6c6f64ec 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.
2021-11-19 14:00:50 -06:00
Marek Polacek b903e0f3ad 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.
2021-11-19 14:59:12 -05:00
Iain Sandoe d4943ce939 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.
2021-11-19 19:58:11 +00:00
Iain Sandoe b9873b4e2c 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.
2021-11-19 19:53:39 +00:00
Iain Sandoe c7b782d847 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.
2021-11-19 19:52:03 +00:00
Iain Sandoe 532fae74c3 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.
2021-11-19 19:51:27 +00:00
Jonathan Wakely b8f2efaed0 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.
2021-11-19 18:15:52 +00:00
Jonathan Wakely 2d76292bd6 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.
2021-11-19 18:15:15 +00:00
Martin Jambor 458d2c6899
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.
2021-11-19 18:46:08 +01:00
Jan Hubicka ada63d56be 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.
2021-11-19 18:09:13 +01:00
Martin Sebor 16137fbb92 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.
2021-11-19 09:47:57 -07:00
Andrew MacLeod ee448a523d 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.
2021-11-19 11:38:06 -05:00
Stefan Schulze Frielinghaus f47870e6a2 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.
2021-11-19 16:56:56 +01:00
Tamar Christina 487d604b6f 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.
2021-11-19 15:12:38 +00:00