Commit Graph

189865 Commits

Author SHA1 Message Date
Martin Liska 79e9f721d1 Revert "Remove MAY_HAVE_DEBUG_MARKER_STMTS and MAY_HAVE_DEBUG_BIND_STMTS."
This reverts commit 206b22d021.
2021-11-19 15:29:35 +01:00
Giuliano Belinassi c7381debe4 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>
2021-11-19 11:27:21 -03:00
Patrick Palka cb09215ad0 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.
2021-11-19 09:01:09 -05:00
Patrick Palka fd740165e5 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.
2021-11-19 08:54:25 -05:00
Iain Buclaw f316727e5f 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.
2021-11-19 14:43:07 +01:00
Iain Buclaw d686cb0d74 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.
2021-11-19 14:26:07 +01:00
Andrew Pinski ea2954df43 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.
2021-11-19 12:06:43 +00:00
Martin Liska 74a4ece02d 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.
2021-11-19 12:33:19 +01:00
Richard Biener dd85c42c36 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.
2021-11-19 10:35:54 +01:00
Jakub Jelinek a84177aff7 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.
2021-11-19 10:05:01 +01:00
Tamar Christina 0e510ab534 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] 3ba1bd0d9d

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.
2021-11-19 08:48:11 +00:00
Richard Biener fb15abdc9b 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.
2021-11-19 09:35:57 +01:00
Richard Biener 0fc859f5ef 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.
2021-11-19 09:35:21 +01:00
Andrew Pinski 09d462146b 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.
2021-11-19 07:18:23 +00:00
Andrew Pinski 527e54a431 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.
2021-11-19 06:41:21 +00:00
Marek Polacek 0790c8aacd 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.
2021-11-18 22:31:11 -05:00
liuhongt d3152981f7 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.
2021-11-19 09:22:48 +08:00
Patrick Palka 09c24fe42f 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.
2021-11-18 19:32:22 -05:00
GCC Administrator 483092d3d9 Daily bump. 2021-11-19 00:16:34 +00:00
Iain Buclaw d6ec661e39 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.
2021-11-19 00:32:28 +01:00
Marek Polacek 93810fd673 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.
2021-11-18 18:00:08 -05:00
David Edelsohn 6f4ac4f81f 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.
2021-11-18 13:46:32 -05:00
Harald Anlauf 3535be6c6f 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>
2021-11-18 19:35:43 +01:00
Martin Liska 22c242342e IPA: fix reproducibility in IPA MOD REF
gcc/ChangeLog:

	* ipa-modref.c (analyze_function): Do not execute the code
	only if dump_file != NULL.
2021-11-18 19:34:13 +01:00
Martin Liska 616ca1024a IPA: use cgraph_node instance
gcc/ChangeLog:

	* ipa-modref.c (analyze_function): Use fnode instead of repeated
	cgraph_node::get (current_function_decl).
2021-11-18 19:34:11 +01:00
Patrick Palka 53c964ad99 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.
2021-11-18 13:10:28 -05:00
Jan Hubicka 75ac95f664 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.
2021-11-18 18:42:35 +01:00
Jan Hubicka c331a75d49 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.
2021-11-18 18:41:43 +01:00
Tamar Christina 4f0a2f5a3d 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.
2021-11-18 17:12:21 +00:00
H.J. Lu 2196a681d7 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.
2021-11-18 08:25:11 -08:00
Jonathan Wakely ca243ada71 libstdc++: Fix std::char_traits<C>::move for constexpr
The constexpr branch in __gnu_cxx::char_traits::move compares the string
arguments to see if they overlap, but relational comparisons between
unrelated pointers are not core constant expressions.

I want to replace the comparisons with a loop using pointer equality to
determine whether the end of the source string is in the destination
string. However, that doesn't work with GCC, due to PR c++/89074 so
allocate a temporary buffer instead and copy out into that first, so
that overlapping source and destination don't matter. The allocation
isn't supported by the current Intel icc so use the loop as a fallback.

libstdc++-v3/ChangeLog:

	* include/bits/char_traits.h (__gnu_cxx::char_traits::move):
	Do not compare unrelated pointers during constant evaluation.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc:
	Improve tests for char_traits::move.
2021-11-18 16:14:15 +00:00
Jeff Law 16fab6d691 Fix MIPS test after recent match.pd changes
gcc/testsuite
	* gcc.target/mips/octeon-bbit-1.c (f3): Add noipa attribute.
2021-11-18 10:47:21 -05:00
David Edelsohn 1b2b930152 Fix typo.
libgomp/ChangeLog:

	* alloc.c (gomp_aligned_alloc): Fix typo.
2021-11-18 10:26:55 -05:00
Patrick Palka 90de06a7b3 c++: template-id ADL and partial instantiation [PR99911]
Here when partially instantiating the call get<U>(T{}) with T=N::A
(for which earlier unqualified name lookup for 'get' found nothing)
the arguments after substitution are no longer dependent but the callee
still is, so perform_koenig_lookup postpones ADL.  But then we go on to
diagnose the unresolved template name anyway, as if ADL was already
performed and failed.

This patch fixes this by avoiding the error path in question when the
template arguments of an unresolved template-id are still dependent,
mirroring the dependence check in perform_koenig_lookup.

	PR c++/99911

gcc/cp/ChangeLog:

	* pt.c (tsubst_copy_and_build) <case CALL_EXPR>: Don't diagnose
	name lookup failure if the arguments to an unresolved template
	name are still dependent.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/fn-template24.C: New test.
2021-11-18 10:05:13 -05:00
Patrick Palka 6fa8e0896c c++: unqual lookup performed twice w/ template-id ADL [PR102670]
Here we're incorrectly performing unqualified lookup of 'adl' again at
substitution time for the call adl<I>(t) (for which name lookup at parse
time found nothing) which causes us to reject the testcase because the
second unqualified lookup finds the later-declared variable template
'adl', leading to confusion.  Fixed thusly.

The testcase concepts-recursive-sat1.C needed to be adjusted to use ADL
proper instead of relying on this incorrect second unqualified lookup.

	PR c++/102670

gcc/cp/ChangeLog:

	* pt.c (tsubst_copy_and_build) <case CALL_EXPR>: When looking
	for an identifier callee in the koenig_p case, also look through
	TEMPLATE_ID_EXPR.  Use tsubst_copy to substitute through the
	template arguments of the template-id.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-recursive-sat1.C: Adjust to use ADL
	proper.
	* g++.dg/cpp2a/fn-template23.C: New test.
2021-11-18 10:04:27 -05:00
David Edelsohn e3dbd2e140 aix: detect power10 processor.
For -mcpu=native, GCC needs to detect the processor.  This
patch adds the processor value for Power10.

	Suggested by Kevin Alder.

	* config/rs6000/driver-rs6000.c (detect_processor_aix): Add
	power10.
2021-11-18 09:31:12 -05:00
Jonathan Wakely 9646a3229b libstdc++: Replace AC_CACHE_VAL with AC_CACHE_CHECK
This replaces most uses of AC_CACHE_VAL with AC_CACHE_CHECK, which means
we don't need separate AC_MSG_CHECKING and AC_MSG_RESULT macros.

There are a few trivial bugs fixed as a side effect, where an
AC_MSG_RESULT was printed out even if the actual checks hadn't been
done. That didn't affect the results, only the content of config.log.

libstdc++-v3/ChangeLog:

	* acinclude.m4: Replace AC_CACHE_VAL with AC_CACHE_CHECK.
	* configure: Regenerate.
2021-11-18 13:56:33 +00:00
Tamar Christina 1a0bce98dc middle-end: Fix FMA detection when inspecting gimple which have no LHS.
convert_mult_to_fma assumes that all gimple_assigns have a LHS set.  This
assumption is however not true when an IFN is kept around just for the
side-effects.  In those situations you have just the IFN and lhs will be null.

Since there's no LHS, there also can't be any ADD and such it can't be an FMA
so it's correct to just return early if no LHS.

gcc/ChangeLog:

	PR tree-optimization/103253
	* tree-ssa-math-opts.c (convert_mult_to_fma): Check for LHS.

gcc/testsuite/ChangeLog:

	PR tree-optimization/103253
	* gcc.dg/vect/pr103253.c: New test.
2021-11-18 11:23:45 +00:00
Matthias Kretz efb7c51024 c-family: Add __builtin_assoc_barrier
New builtin to enable explicit use of PAREN_EXPR in C & C++ code.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

gcc/testsuite/ChangeLog:

	* c-c++-common/builtin-assoc-barrier-1.c: New test.

gcc/cp/ChangeLog:

	* constexpr.c (cxx_eval_constant_expression): Handle PAREN_EXPR
	via cxx_eval_constant_expression.
	* cp-objcp-common.c (names_builtin_p): Handle
	RID_BUILTIN_ASSOC_BARRIER.
	* cp-tree.h: Adjust TREE_LANG_FLAG documentation to include
	PAREN_EXPR in REF_PARENTHESIZED_P.
	(REF_PARENTHESIZED_P): Add PAREN_EXPR.
	* parser.c (cp_parser_postfix_expression): Handle
	RID_BUILTIN_ASSOC_BARRIER.
	* pt.c (tsubst_copy_and_build): If the PAREN_EXPR is not a
	parenthesized initializer, build a new PAREN_EXPR.
	* semantics.c (force_paren_expr): Simplify conditionals. Set
	REF_PARENTHESIZED_P on PAREN_EXPR.
	(maybe_undo_parenthesized_ref): Test PAREN_EXPR for
	REF_PARENTHESIZED_P.

gcc/c-family/ChangeLog:

	* c-common.c (c_common_reswords): Add __builtin_assoc_barrier.
	* c-common.h (enum rid): Add RID_BUILTIN_ASSOC_BARRIER.

gcc/c/ChangeLog:

	* c-decl.c (names_builtin_p): Handle RID_BUILTIN_ASSOC_BARRIER.
	* c-parser.c (c_parser_postfix_expression): Likewise.

gcc/ChangeLog:

	* doc/extend.texi: Document __builtin_assoc_barrier.
2021-11-18 11:24:11 +01:00
Jakub Jelinek edd2249b17 libsanitizer: Fix bootstrap on FreeBSD [PR102675]
Here is an alternative to the patch changing a file imported from
compiler-rt upstream, so that we don't need to cary a local patch for that
particular problem.

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

	PR bootstrap/102675
	* sanitizer_common/Makefile.am: Use -DUSE_SYSTEM_MD5 in AM_CXXFLAGS
	of sanitizer_platform_limits_freebsd.cpp.
	* sanitizer_common/Makefile.in: Regenerated.
2021-11-18 10:08:03 +01:00
Martin Liska 206b22d021 Remove MAY_HAVE_DEBUG_MARKER_STMTS and MAY_HAVE_DEBUG_BIND_STMTS.
The macros correspond 1:1 to an option flags and make it harder
to find all usages of the flags.

gcc/c-family/ChangeLog:

	* c-gimplify.c (genericize_c_loop): Use option directly.

gcc/c/ChangeLog:

	* c-parser.c (add_debug_begin_stmt): Use option directly.

gcc/ChangeLog:

	* cfgexpand.c (pass_expand::execute): Use option directly.
	* function.c (allocate_struct_function): Likewise.
	* gimple-low.c (lower_function_body): Likewise.
	(lower_stmt): Likewise.
	* gimple-ssa-backprop.c (backprop::prepare_change): Likewise.
	* ipa-param-manipulation.c (ipa_param_adjustments::modify_call): Likewise.
	* ipa-split.c (split_function): Likewise.
	* lto-streamer-in.c (input_function): Likewise.
	* sese.c (sese_insert_phis_for_liveouts): Likewise.
	* ssa-iterators.h (num_imm_uses): Likewise.
	* tree-cfg.c (make_blocks): Likewise.
	(gimple_merge_blocks): Likewise.
	* tree-inline.c (tree_function_versioning): Likewise.
	* tree-loop-distribution.c (generate_loops_for_partition): Likewise.
	* tree-sra.c (analyze_access_subtree): Likewise.
	* tree-ssa-dce.c (remove_dead_stmt): Likewise.
	* tree-ssa-loop-ivopts.c (remove_unused_ivs): Likewise.
	* tree-ssa-phiopt.c (spaceship_replacement): Likewise.
	* tree-ssa-reassoc.c (reassoc_remove_stmt): Likewise.
	* tree-ssa-tail-merge.c (tail_merge_optimize): Likewise.
	* tree-ssa-threadedge.c (propagate_threaded_block_debug_into): Likewise.
	* tree-ssa.c (gimple_replace_ssa_lhs): Likewise.
	(target_for_debug_bind): Likewise.
	(insert_debug_temp_for_var_def): Likewise.
	(insert_debug_temps_for_defs): Likewise.
	(reset_debug_uses): Likewise.
	* tree-ssanames.c (release_ssa_name_fn): Likewise.
	* tree-vect-loop-manip.c (adjust_vec_debug_stmts): Likewise.
	(adjust_debug_stmts): Likewise.
	(adjust_phi_and_debug_stmts): Likewise.
	(vect_do_peeling): Likewise.
	* tree-vect-loop.c (vect_transform_loop_stmt): Likewise.
	(vect_transform_loop): Likewise.
	* tree.h (MAY_HAVE_DEBUG_MARKER_STMTS): Remove
	(MAY_HAVE_DEBUG_BIND_STMTS): Remove.
	(MAY_HAVE_DEBUG_STMTS): Use options directly.

gcc/cp/ChangeLog:

	* parser.c (add_debug_begin_stmt): Use option directly.
2021-11-18 10:06:41 +01:00
Richard Biener e28afbb90f testsuite/103278 - adjust gcc.dg/tree-ssa/if-to-switch-3.c
Analysis shows that after the CD-DCE change we produce better
code which makes if-to-switch run into case-values-threshold on
some architectures, thus the switch is deemed to simple to be
worth generating.  The following statically provides
--param case-values-threshold to make the testcase less
target dependent.

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

	PR testsuite/103278
	* gcc.dg/tree-ssa/if-to-switch-3.c: Supply
	--param case-values-threshold=4.
2021-11-18 10:02:17 +01:00
Richard Biener 8f9f5101d5 tree-optimization/103277 - do abnormal cleanup after call DSE
We can now DSE calls in more cases which requires us to eventually
purge dead abnormal edges.  This implements this.

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

	PR tree-optimization/103277
	* tree-ssa-dse.c (need_ab_cleanup): New.
	(dse_optimize_redundant_stores): Adjust.
	(delete_dead_or_redundant_assignment): Get extra
	need_ab_cleanup argument and set when abnormal cleanup is
	needed.
	(dse_optimize_call): Adjust.
	(dse_optimize_stmt): Likewise.
	(pass_dse::execute): Allocate and deallocate need_ab_cleanup.
	Perform abnormal cleanup.
	* tree-ssa-dse.h (delete_dead_or_redundant_assignment): Adjust.

	* gcc.dg/pr103277.c: New testcase.
2021-11-18 10:02:17 +01:00
Hongyu Wang 15f5e70cbb i386: Fix wrong codegen for -mrelax-cmpxchg-loop
For -mrelax-cmpxchg-loop introduced by PR 103069/r12-5265, it would
produce infinite loop. The correct code should be

.L84:
        movl    (%rdi), %ecx
        movl    %eax, %edx
        orl     %esi, %edx
        cmpl    %eax, %ecx
        jne     .L82
        lock cmpxchgl   %edx, (%rdi)
        jne     .L84
	movl    %r8d, %eax  <<< retval is missing in previous impl
	ret
.L82:
        rep nop
        jmp     .L84

Adjust corresponding expander to fix such issue, and fix runtime test
so the problem would be exposed.

gcc/ChangeLog:

	* config/i386/i386-expand.c (ix86_expand_atomic_fetch_op_loop):
	Adjust generated cfg to avoid infinite loop.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr103069-2.c: Adjust.
2021-11-18 16:29:19 +08:00
Jakub Jelinek 17da2c7425 libgomp: Ensure that either gomp_team is properly aligned [PR102838]
struct gomp_team has struct gomp_work_share array inside of it.
If that latter structure has 64-byte aligned member in the middle,
the whole struct gomp_team needs to be 64-byte aligned, but we weren't
allocating it using gomp_aligned_alloc.

This patch fixes that, except that on gcn team_malloc is special, so
I've instead decided at least for now to avoid using aligned member
and use the padding instead on gcn.

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

	PR libgomp/102838
	* libgomp.h (GOMP_USE_ALIGNED_WORK_SHARES): Define if
	GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC is defined and __AMDGCN__ is not.
	(struct gomp_work_share): Use GOMP_USE_ALIGNED_WORK_SHARES instead of
	GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC.
	* work.c (alloc_work_share, gomp_work_share_start): Likewise.
	* team.c (gomp_new_team): If GOMP_USE_ALIGNED_WORK_SHARES, use
	gomp_aligned_alloc instead of team_malloc.
2021-11-18 09:10:40 +01:00
Jakub Jelinek 7a2aa63fad libgomp: Fix up aligned_alloc arguments [PR102838]
C says that aligned_alloc size must be an integral multiple of alignment.
While glibc doesn't care about it, apparently Solaris does.
So, this patch decreases the priority of aligned_alloc among the other
variants because it needs more work and can waste more memory and rounds
up the size to multiple of alignment.

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

	PR libgomp/102838
	* alloc.c (gomp_aligned_alloc): Prefer _aligned_alloc over
	memalign over posix_memalign over aligned_alloc over fallback
	with malloc instead of aligned_alloc over _aligned_alloc over
	posix_memalign over memalign over fallback with malloc.  For
	aligned_alloc, round up size up to multiple of al.
2021-11-18 09:07:31 +01:00
konglin1 a72b7a455c i386: add alias for f*mul_*ch intrinsics
gcc/ChangeLog:

	* config/i386/avx512fp16intrin.h (_mm512_mul_pch): Add alias for _mm512_fmul_pch.
	(_mm512_mask_mul_pch): Likewise.
	(_mm512_maskz_mul_pch): Likewise.
	(_mm512_mul_round_pch): Likewise.
	(_mm512_mask_mul_round_pch): Likewise.
	(_mm512_maskz_mul_round_pch): Likewise.
	(_mm512_cmul_pch): Likewise.
	(_mm512_mask_cmul_pch): Likewise.
	(_mm512_maskz_cmul_pch): Likewise.
	(_mm512_cmul_round_pch): Likewise.
	(_mm512_mask_cmul_round_pch): Likewise.
	(_mm512_maskz_cmul_round_pch): Likewise.
	(_mm_mul_sch): Likewise.
	(_mm_mask_mul_sch): Likewise.
	(_mm_maskz_mul_sch): Likewise.
	(_mm_mul_round_sch): Likewise.
	(_mm_mask_mul_round_sch): Likewise.
	(_mm_maskz_mul_round_sch): Likewise.
	(_mm_cmul_sch): Likewise.
	(_mm_mask_cmul_sch): Likewise.
	(_mm_maskz_cmul_sch): Likewise.
	(_mm_cmul_round_sch): Likewise.
	(_mm_mask_cmul_round_sch): Likewise.
	(_mm_maskz_cmul_round_sch): Likewise.
	* config/i386/avx512fp16vlintrin.h (_mm_mul_pch): Likewise.
	(_mm_mask_mul_pch): Likewise.
	(_mm_maskz_mul_pch): Likewise.
	(_mm256_mul_pch): Likewise.
	(_mm256_mask_mul_pch): Likewise.
	(_mm256_maskz_mul_pch): Likewise.
	(_mm_cmul_pch): Likewise.
	(_mm_mask_cmul_pch): Likewise.
	(_mm_maskz_cmul_pch): Likewise.
	(_mm256_cmul_pch): Likewise.
	(_mm256_mask_cmul_pch): Likewise.
	(_mm256_maskz_cmul_pch): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx512fp16-vfcmulcph-1a.c: Add new test for alias.
	* gcc.target/i386/avx512fp16-vfcmulcsh-1a.c: Likewise.
	* gcc.target/i386/avx512fp16-vfmulcph-1a.c: Likewise.
	* gcc.target/i386/avx512fp16-vfmulcsh-1a.c: Likewise.
	* gcc.target/i386/avx512fp16vl-vfcmulcph-1a.c: Likewise.
	* gcc.target/i386/avx512fp16vl-vfmulcph-1a.c: Likewise.
2021-11-18 10:58:38 +08:00
GCC Administrator 280d2838c1 Daily bump. 2021-11-18 00:16:34 +00:00
Andrew Pinski 3222135700 Fix PR tree-optimization/103228 and 103228: folding of (type) X op CST where type is a nop convert
Currently we fold (type) X op CST into (type) (X op ((type-x) CST)) when the conversion widens
but not when the conversion is a nop. For the same reason why we move the widening conversion
(the possibility of removing an extra conversion), we should do the same if the conversion is a
nop.

Committed as approved with the comment change.

	PR tree-optimization/103228
	PR tree-optimization/55177

gcc/ChangeLog:

	* match.pd ((type) X bitop CST): Also do this
	transformation for nop conversions.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/pr103228-1.c: New test.
	* gcc.dg/tree-ssa/pr55177-1.c: New test.
2021-11-17 23:39:48 +00:00
Jonathan Wakely 0e4a8656e8 libstdc++: Fix author name in ChangeLog
The constexpr std::string commit was my own work, but the commit still
had the author name from an earlier cherry-pick that eventually got
entirely reverted. This fixes the name in the ChangeLog file.
2021-11-17 22:41:49 +00:00