platform/upstream/gcc.git
3 years agors6000: Fix invalid splits when using Altivec style addresses [PR98959]
Peter Bergner [Mon, 8 Mar 2021 18:20:41 +0000 (12:20 -0600)]
rs6000: Fix invalid splits when using Altivec style addresses [PR98959]

The rs6000_emit_le_vsx_* functions assume they are not passed an Altivec
style "& ~16" address.  However, some of our expanders and splitters do
not verify we do not have an Altivec style address before calling those
functions, leading to an ICE.  The solution here is to guard the expanders
and splitters to ensure we do not call them if we're given an Altivec style
address.

2021-03-08  Peter Bergner  <bergner@linux.ibm.com>

gcc/
PR target/98959
* config/rs6000/rs6000.c (rs6000_emit_le_vsx_permute): Add an assert
to ensure we do not have an Altivec style address.
* config/rs6000/vsx.md (*vsx_le_perm_load_<mode>): Disable if passed
an Altivec style address.
(*vsx_le_perm_store_<mode>): Likewise.
(splitters after *vsx_le_perm_store_<mode>): Likewise.
(vsx_load_<mode>): Disable special expander if passed an Altivec
style address.
(vsx_store_<mode>): Likewise.

gcc/testsuite/
PR target/98959
* gcc.target/powerpc/pr98959.c: New test.

3 years agoc++: Incorrect specialization hash table [PR 99285]
Nathan Sidwell [Mon, 8 Mar 2021 18:01:21 +0000 (10:01 -0800)]
c++: Incorrect specialization hash table [PR 99285]

Class template partial specializations need to be in the
specialization hash, but not all of them.  This defers adding
streamed-in entities to the hash table, in the same way I deferred
adding the instantiation and specialization lists for 99170.

PR c++/99285
gcc/cp/
* cp-tree.h (match_mergeable_specialization)
(add_mergeable_specialization): Adjust parms.
* module.cc (trees_in::decl_value): Adjust
add_mergeable_specialization calls.
(trees_out::key_mergeable): Adjust match_mergeable_specialization
calls.
(specialization_add): Likewise.
* pt.c (match_mergeable_specialization): Do not insert.
(add_mergeable_specialization): Add to hash table here.
gcc/testsuite/
* g++.dg/modules/pr99285_a.H: New.
* g++.dg/modules/pr99285_b.H: New.

3 years agoaarch64: Fix PR99437 - tighten shift predicates for narrowing shift patterns
Kyrylo Tkachov [Mon, 8 Mar 2021 15:05:21 +0000 (15:05 +0000)]
aarch64: Fix PR99437 - tighten shift predicates for narrowing shift patterns

In this bug combine forms the (R)SHRN(2) instructions with an invalid shift amount.
The intrinsic expanders for these patterns validate the right shift amount but if the
final patterns end up being matched by combine (or other RTL passes I suppose) they
still let the wrong const_vector through.

This patch tightens up the predicates for the instructions involved by using predicates
for the right shift amount const_vectors.

gcc/ChangeLog:

PR target/99437
* config/aarch64/predicates.md (aarch64_simd_shift_imm_vec_qi): Define.
(aarch64_simd_shift_imm_vec_hi): Likewise.
(aarch64_simd_shift_imm_vec_si): Likewise.
(aarch64_simd_shift_imm_vec_di): Likewise.
* config/aarch64/aarch64-simd.md (aarch64_shrn<mode>_insn_le): Use
predicate from above.
(aarch64_shrn<mode>_insn_be): Likewise.
(aarch64_rshrn<mode>_insn_le): Likewise.
(aarch64_rshrn<mode>_insn_be): Likewise.
(aarch64_shrn2<mode>_insn_le): Likewise.
(aarch64_shrn2<mode>_insn_be): Likewise.
(aarch64_rshrn2<mode>_insn_le): Likewise.
(aarch64_rshrn2<mode>_insn_be): Likewise.

gcc/testsuite/ChangeLog:

PR target/99437
* gcc.target/aarch64/simd/pr99437.c: New test.

3 years agolibsanitizer: cherry-pick ad294e572bc5c16f9dc420cc994322de6ca3fbfb
Martin Liska [Mon, 8 Mar 2021 14:52:03 +0000 (15:52 +0100)]
libsanitizer: cherry-pick ad294e572bc5c16f9dc420cc994322de6ca3fbfb

libsanitizer/ChangeLog:

PR sanitizer/98920
* asan/asan_interceptors.cpp (COMMON_INTERCEPT_FUNCTION_VER):
Cherry pick.
(COMMON_INTERCEPT_FUNCTION_VER_UNVERSIONED_FALLBACK): Likewise.
* asan/asan_interceptors.h (ASAN_INTERCEPT_FUNC_VER_UNVERSIONED_FALLBACK): Likewise.
* sanitizer_common/sanitizer_common_interceptors.inc
(COMMON_INTERCEPT_FUNCTION_GLIBC_VER_MIN): Likewise.
(INIT_REGEX): Likewise.
* tsan/tsan_interceptors_posix.cpp (COMMON_INTERCEPT_FUNCTION_VER_UNVERSIONED_FALLBACK):
Likewise.

gcc/testsuite/ChangeLog:

PR sanitizer/98920
* c-c++-common/asan/pr98920.c: New test.

3 years ago[PR99422] LRA: Skip modifiers when processing memory address.
Vladimir N. Makarov [Mon, 8 Mar 2021 14:24:57 +0000 (09:24 -0500)]
[PR99422] LRA: Skip modifiers when processing memory address.

  Function process_address_1 can wrongly look at constraint modifiers
instead of the 1st constraint itself.  The patch solves the problem.

gcc/ChangeLog:

PR target/99422
* lra-constraints.c (skip_contraint_modifiers): New function.
(process_address_1): Use it before lookup_constraint call.

3 years agoi386: Enable UINTR and HRESET for -march that supports it
Martin Liska [Mon, 8 Mar 2021 11:08:37 +0000 (12:08 +0100)]
i386: Enable UINTR and HRESET for -march that supports it

gcc/ChangeLog:

PR target/99463
* config/i386/i386-options.c (ix86_option_override_internal):
Enable UINTR and HRESET for -march that supports it.

gcc/testsuite/ChangeLog:

PR target/99463
* gcc.target/i386/pr99463-2.c: New test.
* gcc.target/i386/pr99463.c: New test.

3 years agoIBM Z: Fix usage of "f" constraint with long doubles
Ilya Leoshkevich [Thu, 10 Dec 2020 14:43:59 +0000 (15:43 +0100)]
IBM Z: Fix usage of "f" constraint with long doubles

After switching the s390 backend to store long doubles in vector
registers, "f" constraint broke when used with the former: long doubles
correspond to TFmode, which in combination with "f" corresponds to
hard regs %v0-%v15, however, asm users expect a %f0-%f15 pair.

Fix by using TARGET_MD_ASM_ADJUST hook to convert TFmode values to
FPRX2mode and back.

gcc/ChangeLog:

2020-12-14  Ilya Leoshkevich  <iii@linux.ibm.com>

* config/s390/s390.c (f_constraint_p): New function.
(s390_md_asm_adjust): Implement TARGET_MD_ASM_ADJUST.
(TARGET_MD_ASM_ADJUST): Likewise.

gcc/testsuite/ChangeLog:

2020-12-14  Ilya Leoshkevich  <iii@linux.ibm.com>

* gcc.target/s390/vector/long-double-asm-commutative.c: New
test.
* gcc.target/s390/vector/long-double-asm-earlyclobber.c: New
test.
* gcc.target/s390/vector/long-double-asm-in-out.c: New test.
* gcc.target/s390/vector/long-double-asm-inout.c: New test.
* gcc.target/s390/vector/long-double-asm-matching.c: New test.
* gcc.target/s390/vector/long-double-asm-regmem.c: New test.
* gcc.target/s390/vector/long-double-volatile-from-i64.c: New
test.

3 years agotree-nested: Update assert for Fortran module vars [PR97927]
Tobias Burnus [Mon, 8 Mar 2021 12:05:48 +0000 (13:05 +0100)]
tree-nested: Update assert for Fortran module vars [PR97927]

gcc/ChangeLog:

PR fortran/97927
* tree-nested.c (convert_local_reference_stmt): Avoid calling
lookup_field_for_decl for Fortran module (= namespace context).

gcc/testsuite/ChangeLog:

PR fortran/97927
* gfortran.dg/module_variable_3.f90: New test.

3 years agoIBM Z: Fix vcond-shift.c testcase.
Andreas Krebbel [Mon, 8 Mar 2021 11:49:22 +0000 (12:49 +0100)]
IBM Z: Fix vcond-shift.c testcase.

Due to a common code change the comparison in the testcase is emitted
via vec_cmp instead of vcond.  The testcase checks for an optimization
currently only available via vcond.

Fixed by implementing the same optimization also in
s390_expand_vec_compare.

gcc/ChangeLog:

* config/s390/s390.c (s390_expand_vec_compare): Implement <0
comparison with arithmetic right shift.
(s390_expand_vcond): No need for a force_reg anymore.
s390_vec_compare will do it.
* config/s390/vector.md ("vec_cmp<mode><tointvec>"): Accept also
immediate operands.

3 years agoDaily bump.
GCC Administrator [Mon, 8 Mar 2021 00:16:34 +0000 (00:16 +0000)]
Daily bump.

3 years agoi386: Fix some -mavx512vl -mno-avx512bw bugs [PR99321]
Jakub Jelinek [Sun, 7 Mar 2021 09:27:28 +0000 (10:27 +0100)]
i386: Fix some -mavx512vl -mno-avx512bw bugs [PR99321]

As I wrote in the mail with the previous PR99321 fix, we have various
bugs where we emit instructions that need avx512bw and avx512vl
ISAs when compiling with -mavx512vl -mno-avx512bw.

Without the following patch, the attached testcase fails with:
/tmp/ccW4PsfG.s: Assembler messages:
/tmp/ccW4PsfG.s:9: Error: unsupported instruction `vpaddb'
/tmp/ccW4PsfG.s:20: Error: unsupported instruction `vpaddb'
/tmp/ccW4PsfG.s:31: Error: unsupported instruction `vpaddw'
/tmp/ccW4PsfG.s:42: Error: unsupported instruction `vpaddw'
/tmp/ccW4PsfG.s:53: Error: unsupported instruction `vpsubb'
/tmp/ccW4PsfG.s:64: Error: unsupported instruction `vpsubb'
/tmp/ccW4PsfG.s:75: Error: unsupported instruction `vpsubw'
/tmp/ccW4PsfG.s:86: Error: unsupported instruction `vpsubw'
/tmp/ccW4PsfG.s:97: Error: unsupported instruction `vpmullw'
/tmp/ccW4PsfG.s:108: Error: unsupported instruction `vpmullw'
/tmp/ccW4PsfG.s:133: Error: unsupported instruction `vpminub'
/tmp/ccW4PsfG.s:144: Error: unsupported instruction `vpminuw'
/tmp/ccW4PsfG.s:155: Error: unsupported instruction `vpminuw'
/tmp/ccW4PsfG.s:166: Error: unsupported instruction `vpminsb'
/tmp/ccW4PsfG.s:177: Error: unsupported instruction `vpminsb'
/tmp/ccW4PsfG.s:202: Error: unsupported instruction `vpminsw'
/tmp/ccW4PsfG.s:227: Error: unsupported instruction `vpmaxub'
/tmp/ccW4PsfG.s:238: Error: unsupported instruction `vpmaxuw'
/tmp/ccW4PsfG.s:249: Error: unsupported instruction `vpmaxuw'
/tmp/ccW4PsfG.s:260: Error: unsupported instruction `vpmaxsb'
/tmp/ccW4PsfG.s:271: Error: unsupported instruction `vpmaxsb'
/tmp/ccW4PsfG.s:296: Error: unsupported instruction `vpmaxsw'

We already have Yw constraint which is equivalent to v for
-mavx512bw -mavx512vl and to nothing otherwise, per discussions
this patch changes it to stand for x otherwise.  As it is an
undocumented internal constraint, hopefully it won't affect
any inline asm in the wild.
For the instructions that need both we need to use Yw and
v for modes that don't need that.

2021-03-07  Jakub Jelinek  <jakub@redhat.com>

PR target/99321
* config/i386/constraints.md (Yw): Use SSE_REGS if TARGET_SSE
but TARGET_AVX512BW or TARGET_AVX512VL is not set.  Adjust description
and comment.
* config/i386/sse.md (v_Yw): New define_mode_attr.
(*<insn><mode>3, *mul<mode>3<mask_name>, *avx2_<code><mode>3,
*sse4_1_<code><mode>3<mask_name>): Use <v_Yw> instead of v
in constraints.
* config/i386/mmx.md (mmx_pshufw_1, *vec_dupv4hi): Use Yw instead of
xYw in constraints.

* lib/target-supports.exp
(check_effective_target_assembler_march_noavx512bw): New effective
target.
* gcc.target/i386/avx512vl-pr99321-1.c: New test.

3 years agoDaily bump.
GCC Administrator [Sun, 7 Mar 2021 00:16:24 +0000 (00:16 +0000)]
Daily bump.

3 years agoc++: Fix constexpr evaluation of pre-increment when !lval [PR99287]
Patrick Palka [Sat, 6 Mar 2021 22:09:07 +0000 (17:09 -0500)]
c++: Fix constexpr evaluation of pre-increment when !lval [PR99287]

Here, during cxx_eval_increment_expression (with lval=false) of
++__first where __first is &"mystr"[0], we correctly update __first
to &"mystr"[1] but we end up returning &"mystr"[0] + 1 instead of
&"mystr"[1].  This unreduced return value inhibits other pointer
arithmetic folding during later constexpr evaluation, which ultimately
causes the constexpr evaluation to fail.

It turns out the simplification of &"mystr"[0] + 1 to &"mystr"[1]
is performed by cxx_fold_pointer_plus_expression, not by fold_build2.
So we perform this simplification during constexpr evaluation of
the temporary MODIFY_EXPR (during which we assign to __first the
simplified value), but then we return 'mod' which has only been folded
via fold_build2 and hasn't gone through cxx_fold_pointer_plus_expression.

This patch fixes this by updating 'mod' with the result of the
MODIFY_EXPR evaluation appropriately, so that it captures any additional
folding of the expression when !lval.  We now need to be wary of this
evaluation failing and returning e.g. the MODIFY_EXPR or NULL_TREE; it
seems checking *non_constant_p should cover our bases here and is
generally prudent.

gcc/cp/ChangeLog:

PR c++/99287
* constexpr.c (cxx_eval_increment_expression): Pass lval when
evaluating the MODIFY_EXPR, and update 'mod' with the result of
this evaluation.  Check *non_constant_p afterwards.  For prefix
ops, just return 'mod'.

gcc/testsuite/ChangeLog:

PR c++/99287
* g++.dg/cpp2a/constexpr-99287.C: New test.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>
3 years agomiddle-end: Pretty-print address space of aggregates
Julian Brown [Sat, 6 Mar 2021 19:07:26 +0000 (19:07 +0000)]
middle-end: Pretty-print address space of aggregates

This patch adds printing of "<address-space-N>" markers for aggregates
in non-default address spaces.

gcc/
* tree-pretty-print.c (dump_generic_node): Emit non-generic
address space info for aggregates.

3 years agod: Don't set default flag_complex_method.
Iain Buclaw [Sat, 6 Mar 2021 17:18:44 +0000 (18:18 +0100)]
d: Don't set default flag_complex_method.

D doesn't need C99-like requirements for complex multiply and divide,
the default set by common.opt is sufficient enough.

gcc/d/ChangeLog:

* d-lang.cc (d_init_options_struct): Don't set default
flag_complex_method.

3 years agolibgcov: Fix build on Darwin [PR99406]
Jakub Jelinek [Sat, 6 Mar 2021 15:22:27 +0000 (16:22 +0100)]
libgcov: Fix build on Darwin [PR99406]

As reported, bootstrap currently fails on older Darwin because MAP_ANONYMOUS
is not defined.

The following is what gcc/system.h does, so I think it should work for
libgcov.

2021-03-06  Jakub Jelinek  <jakub@redhat.com>

PR gcov-profile/99406
* libgcov.h (MAP_FAILED, MAP_ANONYMOUS): If HAVE_SYS_MMAN_H is
defined, define these macros if not defined already.

3 years agolibstdc++: Improve std::rot[lr] [PR99396]
Jakub Jelinek [Sat, 6 Mar 2021 10:11:30 +0000 (11:11 +0100)]
libstdc++: Improve std::rot[lr] [PR99396]

As can be seen on:

unsigned char f1 (unsigned char x, int y) { return std::rotl (x, y); }
unsigned char f2 (unsigned char x, int y) { return std::rotr (x, y); }
unsigned short f3 (unsigned short x, int y) { return std::rotl (x, y); }
unsigned short f4 (unsigned short x, int y) { return std::rotr (x, y); }
unsigned int f5 (unsigned int x, int y) { return std::rotl (x, y); }
unsigned int f6 (unsigned int x, int y) { return std::rotr (x, y); }
unsigned long int f7 (unsigned long int x, int y) { return std::rotl (x, y); }
unsigned long int f8 (unsigned long int x, int y) { return std::rotr (x, y); }
unsigned long long int f9 (unsigned long long int x, int y) { return std::rotl (x, y); }
unsigned long long int f10 (unsigned long long int x, int y) { return std::rotr (x, y); }
//unsigned __int128 f11 (unsigned __int128 x, int y) { return std::rotl (x, y); }
//unsigned __int128 f12 (unsigned __int128 x, int y) { return std::rotr (x, y); }

constexpr auto a = std::rotl (1234U, 0);
constexpr auto b = std::rotl (1234U, 5);
constexpr auto c = std::rotl (1234U, -5);
constexpr auto d = std::rotl (1234U, -__INT_MAX__ - 1);
the current <bit> definitions of std::__rot[lr] aren't pattern recognized
as rotates, they are too long/complex for that, starting with signed modulo,
special case for 0 and different cases for positive and negative.

For types with power of two bits the following patch adds definitions that
the compiler can pattern recognize and turn e.g. on x86_64 into ro[lr][bwlq]
instructions.  For weirdo types like unsigned __int20 etc. it keeps the
current definitions.

2021-03-06  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/99396
* include/std/bit (__rotl, __rotr): Add optimized variants for power of
two _Nd which the compiler can pattern match the rotates.

3 years agoc++: Fix tsubsting member variable template-id [PR96330]
Patrick Palka [Sat, 6 Mar 2021 05:07:43 +0000 (00:07 -0500)]
c++: Fix tsubsting member variable template-id [PR96330]

This makes tsubst_copy appropriately handle a variable template-id, which
in turn fixes tsubsting a COMPONENT_REF whose member operand is known at
parse time to be a variable template-id, as in the initialization of 'x'
in the first testcase.  Previously, we rejected this testcase with the
error "foo_t::bar<T> is not a function template", issued from
lookup_template_fuction.

We were already properly handling the analagous case where the object
operand of the COMPONENT_REF is dependent (and so the member operand is
a dependent template name), but there doesn't seems to be existing test
coverage for this, hence the second testcase below.

gcc/cp/ChangeLog:

PR c++/96330
* pt.c (tsubst_copy) <case TEMPLATE_ID_EXPR>: Rename local
variable 'fn' to 'tmpl'.  Handle a variable template-id by
calling lookup_template_variable.

gcc/testsuite/ChangeLog:

PR c++/96330
* g++.dg/cpp1y/var-templ68.C: New test.
* g++.dg/cpp1y/var-templ68a.C: New test.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>
3 years agoc++: adc_unify deduction with constrained auto [PR99365]
Patrick Palka [Sat, 6 Mar 2021 05:07:35 +0000 (00:07 -0500)]
c++: adc_unify deduction with constrained auto [PR99365]

My recent r11-7454 changed the way do_auto_deduction handles constrained
placeholders during template argument deduction (context == adc_unify)
when processing_template_decl != 0.  Before the patch, we would just
ignore the constraints on the placeholder, and return the deduced type.
After the patch, we now punt and return the original placeholder type

While this change fixed instances where we'd prematurely resolve a
constrained placeholder return or variable type with non-dependent
initializer at template parse time (such as PR96444), it broke the
adc_unify callers that rely on the previous behavior.

This patch restores the previous behavior during adc_unify deduction
while retaining the new behavior only during adc_variable_type or
adc_return_type deduction.

We additionally now need to pass the outer template arguments to
do_auto_deduction during unify, for sake of constraint checking.
But we want to avoid substituting these outer arguments into type
when the caller has already done so, so this patch adds a
TEMPLATE_TYPE_LEVEL check to do_auto_deduction to that effect.

This above is enough to fix partial specialization of non-nested
templates with constrained 'auto' template parameters, but it doesn't
fix the nested template case, ultimately because
most_specialized_partial_spec passes only the innermost template
arguments to get_partial_spec_bindings, and so outer_targs during
do_auto_deduction (called from unify) contains only the innermost
template arguments, and this breaks satisfaction.  Fixing this properly
is perhaps too risky at this stage, so this patch adds a hack to
do_auto_deduction to compensate for callers that don't supply all outer
template arguments.  The goal of this hack is to ensure placeholder type
constraint checking continues to work whenever it worked before
r11-7454, namely whenever the constraint is non-dependent.

Finally, this patch allows do_auto_deduction to resolve a constrained
placeholder type ahead of time (at template parse time), as long as the
constraint is non-dependent.

gcc/cp/ChangeLog:

PR c++/99365
* pt.c (unify) <case TEMPLATE_TYPE_PARM>: Pass targs as
outer_targs to do_auto_deduction.
(placeholder_type_constraint_dependent_p): Define.
(do_auto_deduction): When processing_template_decl != 0
and context is adc_unify and we have constraints, pretend the
constraints are satisfied instead of punting.  Otherwise don't
punt unless placeholder_type_constraint_dependent_p holds.
Add some clarifying sanity checks.  Add a hack to add missing
outermost template levels to outer_args before checking
satisfaction.  Don't substitute outer_targs into type if it's
already been done.

gcc/testsuite/ChangeLog:

PR c++/99365
* g++.dg/cpp2a/concepts-partial-spec9.C: New test.
* g++.dg/cpp2a/concepts-placeholder4.C: New test.

3 years agocris: don't define MAX_FIXED_MODE_SIZE
Hans-Peter Nilsson [Thu, 4 Mar 2021 21:58:42 +0000 (22:58 +0100)]
cris: don't define MAX_FIXED_MODE_SIZE

It's been 32 ever since the CRIS port was committed.
A TODO-item of mine has been to check whether the
non-default setting of MAX_FIXED_MODE_SIZE makes sense
wrt. performance and/or code-size with a modern gcc.  It
doesn't, so it goes.  The setting is now the default,
GET_MODE_BITSIZE (DImode) (defaults.h) i.e. 64.

Measurements at r11-7500 (f3641ac70eb0) on coremark with
"-O2 -march=v10 -mno-mul-bug-workaround" shows 0.04%
performance improvement with this change, and by inspection
the effect is that unused and/or unneeded stack-frames are
eliminated more often in the floating-point library (not in
the coremark main loop, thus the marginal improvement).  The
floating-point library is full of 64-bit unions used to pick
apart floating point numbers, so this kind of makes sense.

Inspection of a simulator trace shows that this is indeed
the only effect in coremark.  Other local micro-benchmarks
agree as to the net effect (no traces were inspected
though), and the most floating-point-heavy test shows an 8%
improvement.  These effects are of course subject to gcc
core tweaks and may make sense to be adjusted again in a
future release.

While MAX_FIXED_MODE_SIZE is IMO supposed to be an optional
macro for performance, setting it to anything smaller than
twice the size of an address exposes bad decisions in gcc
middle end, sometimes leading to internal compiler errors.
(It being set to 32 should *not* affect use of DImode as an
integer mode; it's for "integer machine modes of this size
or smaller can be used for structures and unions with the
appropriate sizes".)  Thus, with the default 64 instead of
32, there are two tests that now pass for the first time:
gcc.dg/attr-vector_size.c and gcc.dg/tree-ssa/pr93121-1.c.

gcc:
* config/cris/cris.h (MAX_FIXED_MODE_SIZE): Don't define.

3 years agogcc.target/cris/pr93372-1.c: Adjust expectations for eliminated stack-frame
Hans-Peter Nilsson [Fri, 5 Mar 2021 22:01:07 +0000 (23:01 +0100)]
gcc.target/cris/pr93372-1.c: Adjust expectations for eliminated stack-frame

See comment.

* gcc.target/cris/pr93372-1.c: Adjust expected assembler result
to allow an eliminated stack-frame.

3 years agoDaily bump.
GCC Administrator [Sat, 6 Mar 2021 00:16:43 +0000 (00:16 +0000)]
Daily bump.

3 years agoc++: Pointer-to-member fn conversion with noexcept [PR99374]
Marek Polacek [Thu, 4 Mar 2021 19:25:01 +0000 (14:25 -0500)]
c++: Pointer-to-member fn conversion with noexcept [PR99374]

The issue in this PR is that we wrongly reject converting pointers to
member function of incomplete types, one of which has noexcept.  Recall
that pointers (including pointers to member functions) to non-throwing
functions can be implicitly converted to potentially-throwing functions
(but not vice versa).

We reject the conversion when called from can_convert_arg_bad because
standard_conversion can't create such a conversion.  It comes down to
the DERIVED_FROM_P check in the TYPE_PTRMEMFUNC_P block.  It considers
every class derived from itself, but not when the class is incomplete.
But surely we want to reach fnptr_conv_p when tbase is fbase (one of
them could be an alias to the other so use same_type_p instead of ==).

Another approach would be to not perform DERIVED_FROM_P at all when
either tbase or fbase are incomplete (so perhaps something like at the
end of ptr_reasonably_similar).

gcc/cp/ChangeLog:

PR c++/99374
* call.c (standard_conversion): When converting pointers to
member, don't return NULL when the bases are equivalent but
incomplete.

gcc/testsuite/ChangeLog:

PR c++/99374
* g++.dg/cpp1z/noexcept-type23.C: New test.

3 years agoc++: ICE with -Wshadow and enumerator in template [PR99120]
Marek Polacek [Fri, 5 Mar 2021 15:41:41 +0000 (10:41 -0500)]
c++: ICE with -Wshadow and enumerator in template [PR99120]

We crash here, because in a template, an enumerator doesn't have
a type until we've called finish_enum_value_list.  But our -Wshadow
implementation, check_local_shadow, is called when we pushdecl in
build_enumerator, which takes place before finish_enum_value_list.

gcc/cp/ChangeLog:

PR c++/99120
* name-lookup.c (check_local_shadow): Check if the type of decl
is non-null before checking TYPE_PTR*.

gcc/testsuite/ChangeLog:

PR c++/99120
* g++.dg/warn/Wshadow-17.C: New test.

3 years agotestsuite: Update testcase for PR96078 fix [PR99363]
Jason Merrill [Fri, 5 Mar 2021 22:07:25 +0000 (17:07 -0500)]
testsuite: Update testcase for PR96078 fix [PR99363]

My fix for PR96078 made us stop warning about flatten on an alias if the
target has the alias, which is exactly the case tested here.  So let's
remove the expected warning and add a similar case which does warn.

gcc/testsuite/ChangeLog:

PR c/99363
* gcc.dg/attr-flatten-1.c: Adjust.

3 years agoopenmp: Avoid ICEs due to orphaned labels in OpenMP regions [PR99322]
Jakub Jelinek [Fri, 5 Mar 2021 20:52:35 +0000 (21:52 +0100)]
openmp: Avoid ICEs due to orphaned labels in OpenMP regions [PR99322]

When performing cfg cleanup at the end of cfg pass, if there are any OpenMP
regions and some basic blocks are unreachable and contain forced labels,
remove_bb moves the labels to previous bb, but if the two bb belong to different
OpenMP regions, that means it will end up in a different function from where
it was assumed to be and checked e.g. during gimplification or OpenMP region
SESE checking.

The following patch will place the labels to some bb from the right OpenMP
region if the previous bb is not that.  I think it should happen very rarely,
normally the bbs from each OpenMP region should be from the before-cfg pass
adjacent and the problems will usually be only if the OpenMP regions are
no-return, so I hope it isn't fatal that it searches through all bbs on the miss.
If it turns out to be a problem, it can always lazily create some better data
structure and maintain it through bb removals when it reaches that case the
first time.

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

PR middle-end/99322
* tree-cfg.c (bb_to_omp_idx): New variable.
(execute_build_cfg): Release the bb_to_omp_idx vector after
cleanup_tree_cfg returns.
(handle_abnormal_edges): Remove bb_to_omp_idx argument, adjust
for bb_to_omp_idx being a vec<int> instead of pointer to array
of ints.
(make_edges): Remove bb_to_omp_idx local variable, don't pass
it to handle_abnormal_edges, adjust for bb_to_omp_idx being a
vec<int> instead of pointer to array of ints and don't free/release
it at the end.
(remove_bb): When removing a bb and placing forced label somewhere
else, ensure it is put into the same OpenMP region during cfg
pass if possible or to entry successor as fallback.  Unregister
bb from bb_to_omp_idx.

* c-c++-common/gomp/pr99322.c: New test.

3 years agoc++: Duplicate namespace bindings [PR 99245]
Nathan Sidwell [Fri, 5 Mar 2021 20:49:34 +0000 (12:49 -0800)]
c++: Duplicate namespace bindings [PR 99245]

Header units can declare the same entity, and this can lead to one of
them containing a (non-using) binding to an import.  If one gets the
cluster ordering just right, an assert will trigger.  Relax that assert.

PR c++/99245
gcc/cp/
* module.cc (module_state::write_cluster): Relax binding assert.
gcc/testsuite/
* g++.dg/modules/pr99245_a.H: New.
* g++.dg/modules/pr99245_b.H: New.

3 years agoPR libfortran/99218 - matmul on temporary array accesses invalid memory
Harald Anlauf [Fri, 5 Mar 2021 19:57:54 +0000 (20:57 +0100)]
PR libfortran/99218 - matmul on temporary array accesses invalid memory

Do not invoke tuned rank-2 times rank-2 matmul if rank(b) == 1.

libgfortran/ChangeLog:

PR libfortran/99218
* m4/matmul_internal.m4: Invoke tuned matmul only for rank(b)>1.
* generated/matmul_c10.c: Regenerated.
* generated/matmul_c16.c: Likewise.
* generated/matmul_c4.c: Likewise.
* generated/matmul_c8.c: Likewise.
* generated/matmul_i1.c: Likewise.
* generated/matmul_i16.c: Likewise.
* generated/matmul_i2.c: Likewise.
* generated/matmul_i4.c: Likewise.
* generated/matmul_i8.c: Likewise.
* generated/matmul_r10.c: Likewise.
* generated/matmul_r16.c: Likewise.
* generated/matmul_r4.c: Likewise.
* generated/matmul_r8.c: Likewise.
* generated/matmulavx128_c10.c: Likewise.
* generated/matmulavx128_c16.c: Likewise.
* generated/matmulavx128_c4.c: Likewise.
* generated/matmulavx128_c8.c: Likewise.
* generated/matmulavx128_i1.c: Likewise.
* generated/matmulavx128_i16.c: Likewise.
* generated/matmulavx128_i2.c: Likewise.
* generated/matmulavx128_i4.c: Likewise.
* generated/matmulavx128_i8.c: Likewise.
* generated/matmulavx128_r10.c: Likewise.
* generated/matmulavx128_r16.c: Likewise.
* generated/matmulavx128_r4.c: Likewise.
* generated/matmulavx128_r8.c: Likewise.

gcc/testsuite/ChangeLog:

PR libfortran/99218
* gfortran.dg/matmul_21.f90: New test.

3 years agoc++: Local instantiations of imported specializations [PR 99377]
Nathan Sidwell [Fri, 5 Mar 2021 18:34:23 +0000 (10:34 -0800)]
c++: Local instantiations of imported specializations [PR 99377]

This turned out to be the function version of the previous fix.  We
can import an implicit specialization declaration that we need to
instantiate.  We must mark the instantiation so we remember to stream
it.

PR c++/99377
gcc/cp/
* pt.c (instantiate_decl): Call set_instantiating_module.
gcc/testsuite/
* g++.dg/modules/pr99377_a.H: New.
* g++.dg/modules/pr99377_b.C: New.
* g++.dg/modules/pr99377_c.C: New.

3 years agocoroutines : Adjust constraints on when to build ctors [PR98118].
Iain Sandoe [Wed, 17 Feb 2021 15:13:57 +0000 (15:13 +0000)]
coroutines : Adjust constraints on when to build ctors [PR98118].

PR98118 shows that TYPE_NEEDS_CONSTRUCTING is necessary but not
sufficient.  Use type_build_ctor_call() instead.

gcc/cp/ChangeLog:

PR c++/98118
* coroutines.cc (build_co_await): Use type_build_ctor_call()
to determine cases when a CTOR needs to be built.
(flatten_await_stmt): Likewise.
(morph_fn_to_coro): Likewise.

gcc/testsuite/ChangeLog:

PR c++/98118
* g++.dg/coroutines/pr98118.C: New test.

3 years agocoroutines : Do not accept throwing final await expressions [PR95616].
Iain Sandoe [Mon, 15 Feb 2021 17:11:31 +0000 (17:11 +0000)]
coroutines : Do not accept throwing final await expressions [PR95616].

From the PR:

The wording of [dcl.fct.def.coroutine]/15 states:
 * The expression co_await promise.final_suspend() shall not be
   potentially-throwing ([except.spec]).

See http://eel.is/c++draft/dcl.fct.def.coroutine#15
and http://eel.is/c++draft/except.spec#6

ie. all of the following must be declared noexcept (if they form part of the await-expression):
- promise_type::final_suspend()
- finalSuspendObj.operator co_await()
- finalSuspendAwaiter.await_ready()
- finalSuspendAwaiter.await_suspend()
- finalSuspendAwaiter.await_resume()
- finalSuspedObj destructor
- finalSuspendAwaiter destructor

This implements the checks for these cases and rejects such code with
a diagnostic if exceptions are enabled.

gcc/cp/ChangeLog:

PR c++/95616
* coroutines.cc (coro_diagnose_throwing_fn): New helper.
(coro_diagnose_throwing_final_aw_expr): New helper.
(build_co_await): Diagnose throwing final await expression
components.
(build_init_or_final_await): Diagnose a throwing promise
final_suspend() call.

gcc/testsuite/ChangeLog:

PR c++/95616
* g++.dg/coroutines/pr95616-0-no-exceptions.C: New test.
* g++.dg/coroutines/pr95616-0.C: New test.
* g++.dg/coroutines/pr95616-1-no-exceptions.C: New test.
* g++.dg/coroutines/pr95616-1.C: New test.
* g++.dg/coroutines/pr95616-2.C: New test.
* g++.dg/coroutines/pr95616-3-no-exceptions.C: New test.
* g++.dg/coroutines/pr95616-3.C: New test.
* g++.dg/coroutines/pr95616-4.C: New test.
* g++.dg/coroutines/pr95616-5.C: New test.
* g++.dg/coroutines/pr95616-6.C: New test.

3 years agocoroutines : Handle exceptions throw before the first await_resume() [PR95615].
Iain Sandoe [Mon, 15 Feb 2021 15:09:27 +0000 (15:09 +0000)]
coroutines : Handle exceptions throw before the first await_resume() [PR95615].

The coroutine body is wrapped in a try-catch block which is responsible for
handling any exceptions thrown by the original function body.  Originally, the
initial suspend expression was outside this, but an amendement to the standard
places the await_resume call inside and eveything else outside.

This means that any exception thrown prior to the initial suspend expression
await_resume() will propagate to the ramp function.  However, some portion of
the coroutine state will exist at that point (how much depends on where the
exception is thrown from).  For example, we might have some frame parameter
copies, or the promise object or the return object any of which might have a
non-trivial DTOR.  Also the frame itself needs to be deallocated. This patch
fixes the handling of these cases.

gcc/cp/ChangeLog:

PR c++/95615
* coroutines.cc (struct param_info): Track parameter copies that need
a DTOR.
(coro_get_frame_dtor): New helper function factored from build_actor().
(build_actor_fn): Use coro_get_frame_dtor().
(morph_fn_to_coro): Track parameters that need DTORs on exception,
likewise the frame promise and the return object.  On exception, run the
DTORs for these, destroy the frame and then rethrow the exception.

gcc/testsuite/ChangeLog:

PR c++/95615
* g++.dg/coroutines/torture/pr95615-01.C: New test.
* g++.dg/coroutines/torture/pr95615-02.C: New test.
* g++.dg/coroutines/torture/pr95615-03.C: New test.
* g++.dg/coroutines/torture/pr95615-04.C: New test.
* g++.dg/coroutines/torture/pr95615-05.C: New test.

3 years ago[PR99378] LRA: Skip decomposing address for asm insn operand with unknown constraint.
Vladimir N. Makarov [Fri, 5 Mar 2021 16:41:25 +0000 (11:41 -0500)]
[PR99378] LRA: Skip decomposing address for asm insn operand with unknown constraint.

  Function get_constraint_type returns CT__UNKNOWN for empty constraint
and CT_FIXED_FORM for "X".  So process_address_1 skipped
decompose_mem_address only for "X" constraint.  To do the same for empty
constraint, skip decompose_mem_address for CT__UNKNOWN.

gcc/ChangeLog:

PR target/99378
* lra-constraints.c (process_address_1): Skip decomposing address
for asm insn operand with unknown constraint.

gcc/testsuite/ChangeLog:

PR target/99378
* gcc.target/i386/pr99123-2.c: New.

3 years agoipa: Fix resolving speculations through cgraph_edge::set_call_stmt
Martin Jambor [Fri, 5 Mar 2021 16:25:20 +0000 (17:25 +0100)]
ipa: Fix resolving speculations through cgraph_edge::set_call_stmt

In the PR 98078 testcase, speculative call-graph edges which were
created by IPA-CP are confirmed during inlining but
cgraph_edge::set_call_stmt does not take it very well.

The function enters the update_speculative branch and updates the
edges in the speculation bundle separately (by a recursive call), but
when it processes the first direct edge, most of the bundle actually
ceases to exist because it is devirtualized.  It nevertheless goes on
to attempt to update the indirect edge (that has just been removed),
which surprisingly gets as far as adding the edge to the
call_site_hash, the same devirtualized edge for the second time, and
that triggers an assert.

Fixed by this patch which makes the function aware that it is about to
resolve a speculation and do so instead of updating components of
speculation.  Also, it does so before dealing with the hash because
the speculation resolution code needs the hash to point to the first
speculative direct edge and also cleans the hash up by calling
update_call_stmt_hash_for_removing_direct_edge.

Bootstrapped and tested on x86_64-linux, also profile-LTO-bootstrapped
on the same system.

gcc/ChangeLog:

2021-01-20  Martin Jambor  <mjambor@suse.cz>

PR ipa/98078
* cgraph.c (cgraph_edge::set_call_stmt): Do not update all
corresponding speculative edges if we are about to resolve
sepculation.  Make edge direct (and so resolve speculations) before
removing it from call_site_hash.
(cgraph_edge::make_direct): Relax the initial assert to allow calling
the function on speculative direct edges.

3 years agoc++: instantiating imported specializations [PR 99389]
Nathan Sidwell [Fri, 5 Mar 2021 13:25:54 +0000 (05:25 -0800)]
c++: instantiating imported specializations [PR 99389]

When an incomplete class specialization is imported, and is completed
by instantiation, we were failing to mark the instantiation, and thus
didn't stream it out.  Leading to errors in importing as we had
members of an incomplete type.

PR c++/99389
gcc/cp/
* pt.c (instantiate_class_template_1): Set instantiating module
here.
gcc/testsuite/
* g++.dg/modules/pr99389_a.H: New.
* g++.dg/modules/pr99389_b.C: New.
* g++.dg/modules/pr99389_c.C: New.

3 years agoFix build breakage with latest glibc release
Eric Botcazou [Fri, 5 Mar 2021 11:45:41 +0000 (12:45 +0100)]
Fix build breakage with latest glibc release

gcc/ada/
PR ada/99264
* init.c (__gnat_alternate_sta) [Linux]: Remove preprocessor test on
MINSIGSTKSZ and bump size to 32KB.
* libgnarl/s-osinte__linux.ads (Alternate_Stack_Size): Bump to 32KB.

3 years agoFix oversight in support for forward declarations
Eric Botcazou [Fri, 5 Mar 2021 11:40:53 +0000 (12:40 +0100)]
Fix oversight in support for forward declarations

gcc/c-family/
* c-ada-spec.c (dump_ada_declaration) <TYPE_DECL>: Dump nested types
after entering the separate class package, if any.

3 years agoFix undefined behavior spotted by the sanitizer
Eric Botcazou [Fri, 5 Mar 2021 11:38:49 +0000 (12:38 +0100)]
Fix undefined behavior spotted by the sanitizer

gcc/
PR rtl-optimization/99376
* rtlanal.c (nonzero_bits1) <arithmetic operators>: If the number
of low-order zero bits is too large, set the result to 0 directly.

3 years agoOpenACC: C/C++ - fix async parsing [PR99137]
Tobias Burnus [Fri, 5 Mar 2021 10:41:44 +0000 (11:41 +0100)]
OpenACC: C/C++ - fix async parsing [PR99137]

gcc/c/ChangeLog:

PR c/99137
* c-parser.c (c_parser_oacc_clause_async): Reject comma expressions.

gcc/cp/ChangeLog:

PR c/99137
* parser.c (cp_parser_oacc_clause_async): Reject comma expressions.

gcc/testsuite/ChangeLog:

PR c/99137
* c-c++-common/goacc/asyncwait-1.c: Update dg-error; add
additional test.

3 years agoFortran: Follow fixes to -freal-{4,8}-real* handling [PR99355,PR57871]
Tobias Burnus [Fri, 5 Mar 2021 09:43:11 +0000 (10:43 +0100)]
Fortran: Follow fixes to -freal-{4,8}-real* handling [PR99355,PR57871]

gcc/fortran/ChangeLog:

PR fortran/99355
PR fortran/57871
* invoke.texi (-freal{4,8}-real-*): Extend description.
* primary.c (match_real_constant): Also promote real literals
with '_kind' number.

gcc/testsuite/ChangeLog:

* gfortran.dg/real4-10-real8-10.f90: Add check for real literals
with '_kind' number.
* gfortran.dg/real4-10-real8-16.f90: Likewise.
* gfortran.dg/real4-10-real8-4.f90: Likewise.
* gfortran.dg/real4-10.f90: Likewise.
* gfortran.dg/real4-16-real8-10.f90: Likewise.
* gfortran.dg/real4-16-real8-16.f90: Likewise.
* gfortran.dg/real4-16-real8-4.f90: Likewise.
* gfortran.dg/real4-16.f90: Likewise.
* gfortran.dg/real4-8-real8-10.f90: Likewise.
* gfortran.dg/real4-8-real8-16.f90: Likewise.
* gfortran.dg/real4-8-real8-4.f90: Likewise.
* gfortran.dg/real4-8.f90: Likewise.
* gfortran.dg/real8-10.f90: Likewise.
* gfortran.dg/real8-16.f90: Likewise.
* gfortran.dg/real8-4.f90: Likewise.

3 years agogcc.dg/debug/dwarf2/stacked-qualified-types-3.c: xfail for cris
Hans-Peter Nilsson [Fri, 5 Mar 2021 00:44:05 +0000 (01:44 +0100)]
gcc.dg/debug/dwarf2/stacked-qualified-types-3.c: xfail for cris

The test is still failing and is a regression on master for
cris-elf: the remedy for (all) other targets wasn't
sufficient.  I'm not myself going to put any effort into it
(debug-information being different enough for a test to
fail, is not a priority) and apparently not anyone else in
the last 5 years, so I'm just going to xfail it.

gcc/testsuite:
PR debug/66668
* gcc.dg/debug/dwarf2/stacked-qualified-types-3.c: xfail for cris-*-*

3 years agoDaily bump.
GCC Administrator [Fri, 5 Mar 2021 00:16:21 +0000 (00:16 +0000)]
Daily bump.

3 years agoDarwin, testsuite : Prune 'object file not found for object'.
Iain Sandoe [Sun, 10 Jan 2021 09:48:13 +0000 (09:48 +0000)]
Darwin, testsuite : Prune 'object file not found for object'.

This is not a GCC problem, but a fault in the static linker where,
when a source file is used multiple times, with conditional compilation
the source file is only referenced by the linker for the first object.
Then, when dsymutil tries to find the source file for next object based
off that source there is no record for it.

gcc/testsuite/ChangeLog:

* lib/prune.exp: Prune useless output caused by a linker bug.

3 years agoexpand: Fix ICE in store_bit_field_using_insv [PR93235]
Jakub Jelinek [Thu, 4 Mar 2021 18:38:08 +0000 (19:38 +0100)]
expand: Fix ICE in store_bit_field_using_insv [PR93235]

The following testcase ICEs on aarch64.  The problem is that
op0 is (subreg:HI (reg:HF ...) 0) and because we can't create a SUBREG of a
SUBREG and aarch64 doesn't have HImode insv, only SImode insv,
store_bit_field_using_insv tries to create (subreg:SI (reg:HF ...) 0)
which is not valid for the target and so gen_rtx_SUBREG ICEs.

The following patch fixes it by punting if the to be created SUBREG
doesn't validate, callers of store_bit_field_using_insv can handle
the fallback.

2021-03-04  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/93235
* expmed.c (store_bit_field_using_insv): Return false of xop0 is a
SUBREG and a SUBREG to op_mode can't be created.

* gcc.target/aarch64/pr93235.c: New test.

3 years agoHandle ERROR_MARK in direct_abstract_declarator
Richard Biener [Thu, 4 Mar 2021 12:31:52 +0000 (13:31 +0100)]
Handle ERROR_MARK in direct_abstract_declarator

The gcc.dg/noncompile/pr79758.c testcase prints

pr79758.c:5:6: error: redefinition of 'fn1'
'error_mark' not supported by direct_abstract_declarator)'/home/rguenther/src/gcc3/gcc/testsuite/gcc.dg/noncompile/pr79758.c:4:6: note: previous definition of 'fn1' with type

which shows a) re-entry of pp_printf via pp_unsupported_tree and b) a
bogus diagnostic.  The following handles ERROR_MARK in
direct_abstract_declarator, yielding in the better

/home/rguenther/src/gcc3/gcc/testsuite/gcc.dg/noncompile/pr79758.c:5:6: error: redefinition of 'fn1'
/home/rguenther/src/gcc3/gcc/testsuite/gcc.dg/noncompile/pr79758.c:4:6: note: previous definition of 'fn1' with type 'void(<type-error>)'

but still maybe not perfect.

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

gcc/c-family/
* c-pretty-print.c (c_pretty_printer::direct_abstract_declarator):
Handle ERROR_MARK.

3 years agoprofiling: fix streaming of TOPN counters
Martin Liska [Tue, 16 Feb 2021 15:28:06 +0000 (16:28 +0100)]
profiling: fix streaming of TOPN counters

libgcc/ChangeLog:

PR gcov-profile/99105
* libgcov-driver.c (write_top_counters): Rename to ...
(write_topn_counters): ... this.
(write_one_data): Pre-allocate buffer for number of items
in the corresponding linked lists.
* libgcov.h (malloc_mmap): New function.
(allocate_gcov_kvp): Use it.

gcc/testsuite/ChangeLog:

PR gcov-profile/99105
* gcc.dg/tree-prof/indir-call-prof-malloc.c: Use profile
correction as the wrapped malloc is called one more time
from libgcov.
* gcc.dg/tree-prof/pr97461.c: Likewise.

3 years agoc++: Fix up [[nodiscard]] on ctors on targetm.cxx.cdtor_returns_this targets [PR99362]
Jakub Jelinek [Thu, 4 Mar 2021 15:04:48 +0000 (16:04 +0100)]
c++: Fix up [[nodiscard]] on ctors on targetm.cxx.cdtor_returns_this targets [PR99362]

In the P1771R1 changes JeanHeyd reverted part of Alex' PR88146 fix,
but that seems to be incorrect to me.
Where P1771R1 suggests warnings for [[nodiscard]] on constructors is
handled in a different place - in particular the TARGET_EXPR handling
of convert_to_void.  When we have CALL_EXPR of a ctor, on most arches
that call has void return type and so returns early, and on arm where
the ctor returns the this pointer it is undesirable to warn as it warns
about all ctor calls, not just the ones where it should warn.

The P1771R1 changes added a test for this, but as it was given *.c
extension rather than *.C, the test was never run and so this didn't get
spotted immediately.  The test also had a bug, (?n) can't be used
in dg-warning/dg-error because those are implemented by prepending
some regexp before the user provided one and (?n) must come at the start
of the regexp.  Furthermore, while -ftrack-macro-expansion=0 is useful
in one nodiscard test which uses macros, I don't see how it would be
relevant to all the other cpp2a/nodiscard* tests which don't use any
macros.

2021-03-04  Jakub Jelinek  <jakub@redhat.com>

PR c++/88146
PR c++/99362
gcc/cp/
* cvt.c (convert_to_void): Revert 2019-10-17 changes.  Clarify
comment.
gcc/testsuite/
* g++.dg/cpp2a/nodiscard-constructor.c: Renamed to ...
* g++.dg/cpp2a/nodiscard-constructor1.C: ... this.  Remove
-ftrack-macro-expansion=0 from dg-options.  Don't use (?n) in
dg-warning regexps, instead replace .* with \[^\n\r]*.
* g++.dg/cpp2a/nodiscard-constructor2.C: New test.
* g++.dg/cpp2a/nodiscard-reason-only-one.C: Remove
-ftrack-macro-expansion=0 from dg-options.
* g++.dg/cpp2a/nodiscard-reason-nonstring.C: Likewise.
* g++.dg/cpp2a/nodiscard-once.C: Likewise.

3 years agoc-ppoutput: Fix preprocessing ICE on very large line number [PR99325]
Jakub Jelinek [Thu, 4 Mar 2021 15:02:07 +0000 (16:02 +0100)]
c-ppoutput: Fix preprocessing ICE on very large line number [PR99325]

In libcpp, lines are represented as linenum_type, which is unsigned int.
The following testcases ICE because maybe_print_line_1 is sometimes called
with UNKNOWN_LOCATION (e.g. at pragma eof) and while most of the time
the
        && src_line >= print.src_line
        && src_line < print.src_line + 8
check doesn't succeed for the src_line of 0 from UNKNOWN_LOCATION, when
print.src_line is from very large line numbers (UINT_MAX - 7 and above)
it succeeds (with UB on the compiler side) but src_file is NULL for
UNKNOWN_LOCATION and so the strcmp call ICEs.
As print.src_line can easily wrap around, this patch changes its type
to unsigned int to match libcpp, so that we don't invoke UB in the compiler.
For print.src_line of UINT_MAX - 7 and above, src_line from UNKNOWN_LOCATION
will not pass that test anymore, but when it wraps around to 0, it can,
so I've also added a check for src_loc != UNKNOWN_LOCATION (or, if
preferred, could be src_file != NULL).
Besides fixing the ICE and UB in the compiler, I believe worst case the
patch will cause printing a few more line directives in the preprocessed
source around the wrapping from lines UINT_MAX - 7 to 0 (but less
around the wrapping from INT_MAX to INT_MAX + 1U), but I think those
are exceptional cases (sources with > 2billion lines are rare and
we warn or error on #line > INT_MAX).

2021-03-04  Jakub Jelinek  <jakub@redhat.com>

PR c/99325
* c-ppoutput.c (print): Change src_line type from int to unsigned.
(token_streamer::stream) Likewise.
(maybe_print_line_1): Likewise.  Don't strcmp src_file if src_loc is
UNKNOWN_LOCATION.

* gcc.dg/cpp/line11.c: New test.
* gcc.dg/cpp/line12.c: New test.

3 years agoaarch64: Add missing error_mark_node check [PR99381]
Alex Coplan [Thu, 4 Mar 2021 14:36:39 +0000 (14:36 +0000)]
aarch64: Add missing error_mark_node check [PR99381]

We were missing a check in function_resolver::require_vector_type to see
if the argument type was already invalid. This was causing us to attempt
to emit a diagnostic and subsequently ICE in print_type. Fixed thusly.

gcc/ChangeLog:

PR target/99381
* config/aarch64/aarch64-sve-builtins.cc
(function_resolver::require_vector_type): Handle error_mark_node.

gcc/testsuite/ChangeLog:

PR target/99381
* gcc.target/aarch64/pr99381.c: New test.

3 years agoc++: Post-pending redesign cleanup [PR 99170]
Nathan Sidwell [Wed, 3 Mar 2021 20:30:45 +0000 (12:30 -0800)]
c++: Post-pending redesign cleanup [PR 99170]

With pending entities reimplemented, the remaining use of uintset can just
use a regular hash map -- I only used a uintset because it was there.
So one adhoc hash-table/vector structure goes away.

PR c++/99170
gcc/cp/
* module.cc (class uintset): Delete.
(typedef attached_map_t): A hash map.
(attached_table): Use attached_map_t.  Adjust uses ...
(trees_out::decl_value, trees_in::decl_value): ... here ...
(trees_out::key_mergeable): ... here ...
(trees_in::key_mergeable): ... here ...
(maybe_attach_decl): ... here ...
(direct_import): ... and here.

3 years agoAdd input_modes parameter to TARGET_MD_ASM_ADJUST hook
Ilya Leoshkevich [Tue, 5 Jan 2021 19:55:09 +0000 (20:55 +0100)]
Add input_modes parameter to TARGET_MD_ASM_ADJUST hook

If TARGET_MD_ASM_ADJUST changes a mode of an input operand (which
should be ok as long as the hook itself as well as after_md_seq make up
for it), input_mode will contain stale information.

It might be tempting to fix this by removing input_mode altogether and
just using GET_MODE (), but this will not work correctly with constants.
So add input_modes parameter and document that it should be updated
whenever inputs parameter is updated.

gcc/ChangeLog:

2021-01-05  Ilya Leoshkevich  <iii@linux.ibm.com>

* cfgexpand.c (expand_asm_loc): Pass new parameter.
(expand_asm_stmt): Likewise.
* config/arm/aarch-common-protos.h (arm_md_asm_adjust): Add new
parameter.
* config/arm/aarch-common.c (arm_md_asm_adjust): Likewise.
* config/arm/arm.c (thumb1_md_asm_adjust): Likewise.
* config/cris/cris.c (cris_md_asm_adjust): Likewise.
* config/i386/i386.c (ix86_md_asm_adjust): Likewise.
* config/mn10300/mn10300.c (mn10300_md_asm_adjust): Likewise.
* config/nds32/nds32.c (nds32_md_asm_adjust): Likewise.
* config/pdp11/pdp11.c (pdp11_md_asm_adjust): Likewise.
* config/rs6000/rs6000.c (rs6000_md_asm_adjust): Likewise.
* config/vax/vax.c (vax_md_asm_adjust): Likewise.
* config/visium/visium.c (visium_md_asm_adjust): Likewise.
* doc/tm.texi (md_asm_adjust): Likewise.
* target.def (md_asm_adjust): Likewise.

3 years agoIBM Z: Compile mul-signed-overflow tests on old machines
Ilya Leoshkevich [Tue, 2 Mar 2021 01:12:38 +0000 (02:12 +0100)]
IBM Z: Compile mul-signed-overflow tests on old machines

Commit 34d39d140913 ("IBM Z: Run mul-signed-overflow tests only on
z14") restricted mul-signed-overflow tests to z14+.  It's actually fine
to compile them on old machines, only running needs to be restricted.

gcc/testsuite/ChangeLog:

* gcc.target/s390/mul-signed-overflow-1.c: Compile on old
machines.
* gcc.target/s390/mul-signed-overflow-2.c: Likewise.

3 years agoc++: Redesign pending entity handling [PR 99170]
Nathan Sidwell [Wed, 3 Mar 2021 18:09:41 +0000 (10:09 -0800)]
c++: Redesign pending entity handling [PR 99170]

This patch addresses 99170.  with modules (and in particular header
units), one module can provide a (maybe nested) class or template and
another module can provide a definition or (maybe partial)
specialization of said entity, or member thereof.  when both are
imported into a 3rd TU, and that TU instantiates or uses the class, it
needs to stream in those entities (in general).  But how does it key
those entities to the original?  It can't /just/ use the entity index,
because, when header-units and/or partitions are in play, the entity
index /is not unique/.  I had two complicated schemes that tried to
unify that, but it failed.  Here's a simpler scheme.  Such pending
entities are keyed to the namespace and identifier of the
namespace-scope entity that contains them.  Thus the final TU needs to
find that entity and look in a hash table for lists of sections that
need loading just before instantiating a template or looking inside a
class.

I would like to make this more efficient, but given the complex scheme
failed, I'm shooting for correctness right now.  There will be a
follow up patch to complete the cleanup this enables.

PR c++/99170
gcc/cp/
* cp-tree.h
* lex.c (cxx_dup_lang_specific_decl): Adjust for module_attached_p
rename.
* module.cc (class pending_key): New.
(default_hash_traits<pending_key>): New specialization.
(pending_map_t): New typedef.
(pending_table): Replace old table.
(trees_out::lang_decl_bools): Adjust.
(trees_in::lang_decl_bools): Adjust.
(trees_in::install_entity): Drop pending member and specialization
handling.
(find_pending_key): New.
(depset::hash::fiund_dependencies): Use it.
(pendset_lazy_load): Delete.
(module_state::write_cluster): Don't count pendings here.  Bye
Duff's device-like thing.
(module_state::write_pendings): Reimplement.
(module_state::read_pendings): Reimplement.
(lazy_specializations_p): Delete.
(module_state::write): Adjust write_pendings call.
(lazy_load_pendings): New.
(lazy_load_specializations): Delete.
(lazy_load_members): Delete.
(init_modules): Adjust.
* name-lookup.c (maybe_lazily_declare): Call lazy_load_pendings
not lazy_load_members.
(note_pending_specializations): Delete.
(load_pending_specializations): Delete.
* name-lookup.h (BINDING_VECTR_PENDING_SPECIALIZATIONS_P): Delete.
(BINDING_VECTOR_PENDING_MEMBERS_P): Delete.
(BINDING_VECTR_PENDING_MEMBERS_P): Delete.
(note_pending_specializations): Delete.
(load_pending_specializations): Delete.
* pt.c (lookup_template_class_1): Call lazy_load_pendings not
lazy_load_specializations.
(instantiate_template_class_1): Likewise.
(instantiate_decl): Call lazy_load_pendings.
* typeck.c (complete_type): Likewise.
gcc/testsuite/
* g++.dg/modules/pr99170-1_a.H: New.
* g++.dg/modules/pr99170-1_b.C: New.
* g++.dg/modules/pr99170-2.h: New.
* g++.dg/modules/pr99170-2_a.C: New.
* g++.dg/modules/pr99170-2_b.C: New.
* g++.dg/modules/pr99170-3_a.H: New.
* g++.dg/modules/pr99170-3_b.C: New.
* g++.dg/modules/inst-2_b.C: Adjust scan.
* g++.dg/modules/inst-4_a.C: Adjust scan.
* g++.dg/modules/inst-4_b.C: Adjust scan.
* g++.dg/modules/member-def-1_b.C: Adjust scan.
* g++.dg/modules/member-def-1_c.C: Adjust scan.
* g++.dg/modules/tpl-spec-1_a.C: Adjust scan.
* g++.dg/modules/tpl-spec-1_b.C: Adjust scan.
* g++.dg/modules/tpl-spec-2_b.C: Adjust scan.
* g++.dg/modules/tpl-spec-2_c.C: Adjust scan.
* g++.dg/modules/tpl-spec-2_d.C: Adjust scan.
* g++.dg/modules/tpl-spec-3_a.C: Adjust scan.
* g++.dg/modules/tpl-spec-3_b.C: Adjust scan.
* g++.dg/modules/tpl-spec-4_a.C: Adjust scan.
* g++.dg/modules/tpl-spec-4_b.C: Adjust scan.
* g++.dg/modules/tpl-spec-5_a.C: Adjust scan.
* g++.dg/modules/tpl-spec-5_b.C: Adjust scan.

3 years agogcov: call mmap MAP_ANONYMOUS with fd equal to -1
Martin Liska [Thu, 4 Mar 2021 10:45:47 +0000 (11:45 +0100)]
gcov: call mmap MAP_ANONYMOUS with fd equal to -1

libgcc/ChangeLog:

PR gcov-profile/99385
* libgcov.h (allocate_gcov_kvp): Call mmap with fd equal to -1.

3 years agomiddle-end/97855 - avoid recursing into pp_printf
Richard Biener [Thu, 4 Mar 2021 08:00:55 +0000 (09:00 +0100)]
middle-end/97855 - avoid recursing into pp_printf

When diagnostic messages use pretty-printer formats like %D or %E
the pp_printf invocation can end up in tree pretty-printers which
then have to avoid using pp_printf themselves since this function
is not re-entrant.

The following removes all pp_printf uses from tree-pretty-print.c
fixing the observed malformed diagnostics.  It also poisons the
identifier so new uses are less likely to creep in.

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

PR middle-end/97855
* tree-pretty-print.c: Poison pp_printf.
(dump_decl_name): Avoid use of pp_printf.
(dump_block_node): Likewise.
(dump_generic_node): Likewise.

3 years agolibstdc++: Fix buffer overflows in tests [PR 99382]
Jonathan Wakely [Thu, 4 Mar 2021 10:28:38 +0000 (10:28 +0000)]
libstdc++: Fix buffer overflows in tests [PR 99382]

This seems to be a typo/thinko in the definition of the arrays used as
storage.

libstdc++-v3/ChangeLog:

PR libstdc++/99382
* testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc:
Make storage larger than required. Verify no write to the last
element.
* testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc:
Likewise.

3 years agolibgomp: Use sizeof(void*) based checks instead of looking through $CC $CFLAGS for...
Jakub Jelinek [Thu, 4 Mar 2021 08:43:34 +0000 (09:43 +0100)]
libgomp: Use sizeof(void*) based checks instead of looking through $CC $CFLAGS for -m32/-mx32

Some gcc configurations default to -m32 but support -m64 too.  This patch
just makes the ILP32 tests more reliable by following what e.g. libsanitizer
configury does.

2021-03-04  Jakub Jelinek  <jakub@redhat.com>

* configure.ac: Add AC_CHECK_SIZEOF([void *]).
* plugin/configfrag.ac: Check $ac_cv_sizeof_void_p value instead of
checking of -m32 or -mx32 options on the command line.
* config.h.in: Regenerated.
* configure: Regenerated.

3 years agoFortran: Fix -freal-{4,8}-real* handling [PR99355]
Tobias Burnus [Thu, 4 Mar 2021 07:18:31 +0000 (08:18 +0100)]
Fortran: Fix -freal-{4,8}-real* handling [PR99355]

Avoid chain kind conversion for, e.g., -freal-4-real-8 -freal-8-real-10.
Note that gfc_default_double_kind/gfc_default_double_kind already
honors the -freal flags.

gcc/fortran/ChangeLog:

PR fortran/99355
* decl.c (gfc_match_old_kind_spec, gfc_match_kind_spec): Avoid
redoing kind conversions.
* primary.c (match_real_constant): Likewise.

gcc/testsuite/ChangeLog:

PR fortran/99355
* gfortran.dg/real4-10-real8-10.f90: New test.
* gfortran.dg/real4-10-real8-16.f90: New test.
* gfortran.dg/real4-10-real8-4.f90: New test.
* gfortran.dg/real4-10.f90: New test.
* gfortran.dg/real4-16-real8-10.f90: New test.
* gfortran.dg/real4-16-real8-16.f90: New test.
* gfortran.dg/real4-16-real8-4.f90: New test.
* gfortran.dg/real4-16.f90: New test.
* gfortran.dg/real4-8-real8-10.f90: New test.
* gfortran.dg/real4-8-real8-16.f90: New test.
* gfortran.dg/real4-8-real8-4.f90: New test.
* gfortran.dg/real4-8.f90: New test.
* gfortran.dg/real8-10.f90: New test.
* gfortran.dg/real8-16.f90: New test.
* gfortran.dg/real8-4.f90: New test.

3 years agoDaily bump.
GCC Administrator [Thu, 4 Mar 2021 00:16:48 +0000 (00:16 +0000)]
Daily bump.

3 years agogcc.misc-tests/outputs.exp: enumerate tests
Hans-Peter Nilsson [Wed, 3 Mar 2021 23:57:21 +0000 (00:57 +0100)]
gcc.misc-tests/outputs.exp: enumerate tests

Go from:
PASS: outputs asm default 1: outputs-0.s
PASS: outputs asm default 1: extra
PASS: outputs asm default 1: std out
PASS: outputs asm default 2: outputs-1.s
PASS: outputs asm default 2: outputs-2.s
PASS: outputs asm default 2: extra
PASS: outputs asm default 2: std out
PASS: outputs obj default 1: outputs-0.o
PASS: outputs obj default 1: extra
PASS: outputs obj default 1: std out
...

to:
PASS: outputs-1 asm default 1: outputs-0.s
PASS: outputs-1 asm default 1: extra
PASS: outputs-1 asm default 1: std out
PASS: outputs-2 asm default 2: outputs-1.s
PASS: outputs-2 asm default 2: outputs-2.s
PASS: outputs-2 asm default 2: extra
PASS: outputs-2 asm default 2: std out
PASS: outputs-3 obj default 1: outputs-0.o
PASS: outputs-3 obj default 1: extra
PASS: outputs-3 obj default 1: std out
...

thereby helping a human to quickly pin-point the result of a
specific test.

This mechanical patch was produced by applying
perl -pe 's/^(outest "\$b) /sprintf("%s-%d ",$1, ++$n)/e;'
to outputs.exp.

gcc/testsuite:
* gcc.misc-tests/outputs.exp: Enumerate tests.

3 years agogcc.misc-tests/outputs.exp: assert unique test-names
Hans-Peter Nilsson [Thu, 25 Feb 2021 05:03:47 +0000 (06:03 +0100)]
gcc.misc-tests/outputs.exp: assert unique test-names

The gcc.misc-tests/outputs.exp tests can take some effort to
digest.

Navigating and debugging causes for failing tests here isn't
helped by the existence of tests with duplicate names.
Let's stop that from happening.  This requires that test-run
output is actually reviewed, as Tcl errors don't stop the
test-run, but then again there's no such dejagnu construct
that I know of.

Tested x86_64-pc-linux-gnu.

gcc/testsuite:
* gcc.misc-tests/outputs.exp: Append discriminating
suffixes to tests with duplicate names.
(outest): Assert that each running test has a unique
name.

3 years agoCorrect a workaround for vectorized stores.
Martin Sebor [Wed, 3 Mar 2021 23:56:45 +0000 (16:56 -0700)]
Correct a workaround for vectorized stores.

Resolves:
PR middle-end/96963 - -Wstringop-overflow false positive with -ftree-vectorize when assigning consecutive char struct members
PR middle-end/94655 - -Wstringop-overflow on implicit string assignment with vectorized char store

gcc/ChangeLog:

PR middle-end/96963
PR middle-end/94655
* builtins.c (handle_array_ref): New helper.
(handle_mem_ref): New helper.
(compute_objsize_r): Factor out ARRAY_REF and MEM_REF handling
into new helper functions.  Correct a workaround for vectorized
assignments.

gcc/testsuite/ChangeLog:

PR middle-end/96963
PR middle-end/94655
* gcc.dg/Wstringop-overflow-47.c: Xfail tests.
* gcc.dg/Wstringop-overflow-65.c: New test.
* gcc.dg/Warray-bounds-69.c: Same.

3 years agoUpdate size attribute for Power10.
Pat Haugen [Wed, 3 Mar 2021 23:54:30 +0000 (17:54 -0600)]
Update size attribute for Power10.

2021-03-03  Pat Haugen  <pthaugen@linux.ibm.com>

gcc/
* config/rs6000/dfp.md (extendddtd2, trunctddd2, *cmp<mode>_internal1,
floatditd2, ftrunc<mode>2, fix<mode>di2, dfp_ddedpd_<mode>,
dfp_denbcd_<mode>, dfp_dxex_<mode>, dfp_diex_<mode>,
*dfp_sgnfcnc_<mode>, dfp_dscli_<mode>, dfp_dscri_<mode>): Update size
attribute for Power10.
* config/rs6000/mma.md (*movoo): Likewise.
* config/rs6000/rs6000.md (define_attr "size"): Add 256.
(define_mode_attr bits): Add DD/TD modes.
* config/rs6000/sync.md (load_quadpti, store_quadpti, load_lockedpti,
store_conditionalpti): Update size attribute for Power10.

3 years agoc++: Defer cloning to post-loading [PR 99170]
Nathan Sidwell [Wed, 3 Mar 2021 20:38:20 +0000 (12:38 -0800)]
c++: Defer cloning to post-loading [PR 99170]

It turns out that cloning can cause use to load things. Specifically when
checking paramter shadows (this is avoidable), and also the delete
operator of a deleting dtor (not avoidable).  Doing that in the middle of
loading is a bad thing.  This defers it to a post-load worklist.  If it
causes more loading at that point there is no problem, as we've completed
the first set of loads, bar this bit of cleanup.

Again, this doesn't fix 99170, but is a step towards a solution.

PR c++/99170
gcc/cp/
* module.cc (post_load_decls): New.
(lazy_snum, recursive_lazy): Move earlier.
(module_state::read_cluster): Push cloning onto post_load_decls.
(post_load_processing): New.  Do the cloning here.
(module_state::read_inits): Call post_load_processing.
(module_state::read_language): Likewise.
(lazy_load_binding, lazy_load_specializations): Likewise
(lazy_load_members): Likewise

3 years agoc++: Add fixed test [PR96474]
Marek Polacek [Wed, 3 Mar 2021 20:10:21 +0000 (15:10 -0500)]
c++: Add fixed test [PR96474]

Was happy to find out that my recent dguide fix (r11-7483) fixed
this test too.  In particular, the

+  /* Wait until the enclosing scope is non-dependent.  */
+  if (DECL_CLASS_SCOPE_P (tmpl)
+      && dependent_type_p (DECL_CONTEXT (tmpl)))
+    return ptype;

bit.

gcc/testsuite/ChangeLog:

PR c++/96474
* g++.dg/cpp1z/class-deduction83.C: New test.

3 years agoc++: Defer specialization registration [PR 99170]
Nathan Sidwell [Wed, 3 Mar 2021 19:22:56 +0000 (11:22 -0800)]
c++: Defer specialization registration [PR 99170]

This defers inserting specializations into the specialization table,
until we have completed their streaming.  When streaming a cluster we
ensure that all imports are populated before any of the cluster, so
they need no visibility of other specializations.  Further within the
same import, we've already partitioned the graph, so no earlier
cluster can be refering to a specialization in a later cluster.
Inserting them early causes problems when other specializations of the
same template are inserted.  (This doesn't fix 99170, but is a
necessary change for that PR).

Earlier on, I had less deferred processing, but it has become clearer
that deferred worklists are the right way of handling a few things.
This patch highlights a fixme, in that we're streaming a key twice,
and need not do that, but I wanted to get correctness first.  Besides
the second streaming will end up being a back reference, which is of
course much cheaper than a by-value stream.

PR c++/99170
gcc/cp/
* module.cc (trees_out::decl_value): Stream specialization keys
after decl.
(trees_in::decl_value): Stream them back and insert after
completing the decl.
(trees_out::key_mergeable): Drop some streaming here ...
(trees_in::key_mergeable): ... and here.  Don't insert into
specialization tables.

3 years agod: Fix heap-buffer-overflow in checkModFileAlias [PR 99337]
Iain Buclaw [Wed, 3 Mar 2021 14:34:04 +0000 (15:34 +0100)]
d: Fix heap-buffer-overflow in checkModFileAlias [PR 99337]

The code wrongly assumed memcmp did not read past the mismatch.

Reviewed-on: https://github.com/dlang/dmd/pull/12247

gcc/d/ChangeLog:

PR d/99337
* dmd/MERGE: Merge upstream dmd a3c9bf422.

3 years agoc++: Unify REQUIRES_EXPR evaluation / diagnostic routines
Patrick Palka [Wed, 3 Mar 2021 17:03:09 +0000 (12:03 -0500)]
c++: Unify REQUIRES_EXPR evaluation / diagnostic routines

This folds the diagnose_requires_expr routines into the corresponding
tsubst_requires_expr ones.  This is achieved by making the latter
routines take a sat_info instead of a subst_info, and assigning the
appropriate meanings to the flags sat_info::noisy and
sat_info::diagnose_unsatisfaction_p during tsubst_requires_expr:
info.noisy() controls whether to diagnose invalid types and expressions
inside the requirements, and info.diagnose_unsatisfaction_p() controls
whether to additionally diagnose why the requires-expression evaluates
to false.

gcc/cp/ChangeLog:

* constraint.cc (struct sat_info): Document the different
meanings of noisy() and diagnose_unsatisfaction_p() during
satisfaction and requires-expression evaluation.
(tsubst_valid_expression_requirement): Take a sat_info instead
of a subst_info.  Perform the substitution quietly first.  Fold
in error-replaying code from diagnose_valid_expression.
(tsubst_simple_requirement): Take a sat_info instead of a
subst_info.
(tsubst_type_requirement_1): New.  Fold in error-replaying code
from diagnose_valid_type.
(tsubst_type_requirement): Use the above.  Take a sat_info
instead of a subst_info.
(tsubst_compound_requirement): Likewise.  Fold in
error-replaying code from diagnose_compound_requirement.
(tsubst_nested_requirement): Take a sat_info instead of a
subst_info.  Fold in error-replaying code from
diagnose_nested_requirement.
(tsubst_requirement): Take a sat_info instead of a subst_info.
(tsubst_requires_expr): Split into two versions, one that takes
a sat_info argument and another that takes a complain and
in_decl argument.  Remove outdated documentation.  Document the
effects of the sat_info argument.  Don't short-circuit
processing of requirements when diagnosing unsatisfaction,
mirroring diagnose_requires_expr.
(satisfy_nondeclaration_constraint) <case REQUIRES_EXPR>: Remove
assert, and se the three-parameter version of tsubst_requires_expr.
(diagnose_trait_expr): Make static.  Take a template argument
vector instead of a parameter mapping.
(diagnose_valid_expression): Remove.
(diagnose_valid_type): Remove.
(diagnose_simple_requirement): Remove.
(diagnose_compound_requirement): Remove.
(diagnose_type_requirement): Remove.
(diagnose_nested_requirement): Remove.
(diagnose_requirement): Remove.
(diagnose_requires_expr): Remove.
(diagnose_atomic_constraint): Take a sat_info instead of a
subst_info.  Adjust call to diagnose_trait_expr.  Call
tsubst_requires_expr instead of diagnose_requires_expr.
(diagnose_constraints): Remove special casing of REQUIRES_EXPR
and just always call constraint_satisfaction_value.

3 years agoc++: Clean up normalization and satisfaction routines
Patrick Palka [Wed, 3 Mar 2021 17:01:13 +0000 (12:01 -0500)]
c++: Clean up normalization and satisfaction routines

This patch mostly performs some straightforward refactoring:

  - Renamed satisfy_constraint to satisfy_normalized_constraints
  - Renamed the three-parameter version of satisfy_constraint_expression
    to satisfy_nondeclaration_constraints
  - Removed normalize_(non)?template_requirements
  - Removed satisfy_associated_constraints (and made its callers
    check for dependent template args sooner, before normalization)
  - Removed the tsubst_flags_t parameter of evaluate_concept_check
  - Combined the two versions of constraint_satisfaction_value
  - Combined the two versions of constraint_satisfied_p

Additionally, this patch removes the handling of general
constraint-expressions from satisfy_nondeclaration_constraints, and
hence constraints_satisfied_p and constraint_satisfaction_value now take
only things that carry their own template information needed for
normalization, and, as a special case, REQUIRES_EXPRs.  But the latter
now get evaluated directly via tsubst_requires_expr rather than going
through satisfaction.

(That we used to evaluate REQUIRES_EXPR via satisfaction might even be a
correctness issue: since we cache satisfaction in special ways that don't
apply to regular evaluation, going through satisfaction could in theory
cause us to reuse a cached value for a REQUIRES_EXPR when we shouldn't
have.)

gcc/cp/ChangeLog:

* constexpr.c (cxx_eval_call_expression): Adjust call to
evaluate_concept_check.
(cxx_eval_constant_expression) <case REQUIRES_EXPR>: Use
evaluate_requires_expression instead of
satisfy_constraint_expression.
<case TEMPLATE_ID_EXPR>: Adjust call to evaluate_concept_check.
* constraint.cc (struct sat_info): Adjust comment about which
satisfaction entrypoints use noisy-unsat.
(normalize_template_requirements): Remove (and adjust callers
appropriately).
(normalize_nontemplate_requirements): Likewise.
(tsubst_nested_requirement): Use constraint_satisfaction_value
instead of satisfy_constraint_expression, which'll do the
noisy replaying of ill-formed quiet satisfaction for us.
(decl_satisfied_cache): Adjust comment.
(satisfy_constraint): Rename to ...
(satisfy_normalized_constraints): ... this.
(satisfy_associated_constraints): Remove (and make its
callers check for dependent arguments).
(satisfy_constraint_expression): Rename to ...
(satisfy_nondeclaration_constraints): ... this.  Assert that
'args' is empty when 't' is a concept-id.  Removing handling
bare constraint-expressions, and handle REQUIRES_EXPRs
specially.  Adjust comment accordingly.
(satisfy_declaration_constraints): Assert in the two-parameter
version that 't' is not a TEMPLATE_DECL.  Adjust following
removal of normalize_(non)?template_requirements and
satisfy_asociated_constraints.
(constraint_satisfaction_value): Combine the two- and
three-parameter versions in the natural way.
(constraints_satisfied_p): Combine the one- and two-parameter
versions in the natural way.  Improve documentation.
(evaluate_requires_expr): Define.
(evaluate_concept_check): Remove 'complain' parameter.  Use
constraint_satisfaction_value instead of
satisfy_constraint_expression.
(diagnose_nested_requirement): Adjust following renaming of
satisfy_constraint_expression.
(diagnose_constraints): Handle REQUIRES_EXPR by going through
diagnose_requires_expr directly instead of treating it as a
constraint-expression.  Improve documentation.
* cp-gimplify.c (cp_genericize_r) <case CALL_EXPR>: Adjust call
to evaluate_concept_check.
<case REQUIRES_EXPR>: Use evaluate_requires_expr instead of
constraints_satisfied_p.
<case TEMPLATE_ID_EXPR>: Adjust call to evaluate_concept_check.
* cp-tree.h (evaluate_requires_expr): Declare.
(evaluate_concept_check): Remove tsubst_flag_t parameter.
(satisfy_constraint_expression): Remove declaration.
(constraints_satisfied_p): Remove one-parameter declaration.
Add a default argument to the two-parameter declaration.
* cvt.c (convert_to_void): Adjust call to
evaluate_concept_check.

3 years agotestsuite: aarch64: Add tests for vcvt FP intrinsics
Jonathan Wright [Thu, 18 Feb 2021 19:01:06 +0000 (19:01 +0000)]
testsuite: aarch64: Add tests for vcvt FP intrinsics

Add tests for vcvtx* and vcvt_fXX_fXX floating-point Neon intrinsics.
Since these intrinsics are only supported for AArch64, these tests
are restricted to only run on AArch64 targets.

gcc/testsuite/ChangeLog:

2021-02-18  Jonathan Wright  <jonathan.wright@arm.com>

* gcc.target/aarch64/advsimd-intrinsics/vcvt_fXX_fXX.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vcvtx.c:
New test.

3 years agotestsuite: aarch64: Add tests for v[q]mov[u]n_high intrinsics
Jonathan Wright [Tue, 2 Mar 2021 17:37:54 +0000 (17:37 +0000)]
testsuite: aarch64: Add tests for v[q]mov[u]n_high intrinsics

Add tests for v[q]mov[u]n_high Neon intrinsics. Since these
intrinsics are only supported for AArch64, these tests are restricted
to only run on AArch64 targets.

gcc/testsuite/ChangeLog:

2021-03-02  Jonathan Wright  <jonathan.wright@arm.com>

* gcc.target/aarch64/advsimd-intrinsics/vmovn_high.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vqmovn_high.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vqmovun_high.c:
New test.

3 years agotestsuite: aarch64: Add tests for v[r]shrn_high intrinsics
Jonathan Wright [Tue, 2 Mar 2021 15:30:30 +0000 (15:30 +0000)]
testsuite: aarch64: Add tests for v[r]shrn_high intrinsics

Add tests for v[r]shrn_high Neon intrinsics. Since these intrinsics
are only supported for AArch64, these tests are restricted to only
run on AArch64 targets.

gcc/testsuite/ChangeLog:

2021-03-02  Jonathan Wright  <jonathan.wright@arm.com>

* gcc.target/aarch64/advsimd-intrinsics/vrshrn_high_n.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vshrn_high_n.c:
New test.

3 years agotestsuite: aarch64: Add tests for narrowing-arithmetic intrinsics
Jonathan Wright [Tue, 2 Mar 2021 11:57:31 +0000 (11:57 +0000)]
testsuite: aarch64: Add tests for narrowing-arithmetic intrinsics

Add tests for v[r]addhn_high and v[r]subhn_high Neon intrinsics.
Since these intrinsics are only supported for AArch64, these tests
are restricted to only run on AArch64 targets.

gcc/testsuite/ChangeLog:

2021-03-02  Jonathan Wright  <jonathan.wright@arm.com>

* gcc.target/aarch64/advsimd-intrinsics/vXXXhn_high.inc:
New test template.
* gcc.target/aarch64/advsimd-intrinsics/vaddhn_high.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vraddhn_high.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vrsubhn_high.c:
New test.
* gcc.target/aarch64/advsimd-intrinsics/vsubhn_high.c:
New test.

3 years agoc++: Fix -fstrong-eval-order for operator &&, || and , [PR82959]
Jakub Jelinek [Wed, 3 Mar 2021 15:12:23 +0000 (16:12 +0100)]
c++: Fix -fstrong-eval-order for operator &&, || and , [PR82959]

P0145R3 added
"However, the operands are sequenced in the order prescribed for the built-in
operator" rule for overloaded operator calls when using the operator syntax.
op_is_ordered follows that, but added just the overloaded operators
added in that paper.  &&, || and comma operators had rules that
lhs is sequenced before rhs already in C++98.
The following patch adds those cases to op_is_ordered.

2021-03-03  Jakub Jelinek  <jakub@redhat.com>

PR c++/82959
* call.c (op_is_ordered): Handle TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR
and COMPOUND_EXPR.

* g++.dg/cpp1z/eval-order10.C: New test.

3 years agosparcv9: Disable -Wuninitialized warnings breaking bootstrap [PR92002]
Rainer Orth [Wed, 3 Mar 2021 15:01:50 +0000 (16:01 +0100)]
sparcv9: Disable -Wuninitialized warnings breaking bootstrap [PR92002]

sparcv9 bootstrap has been broken for 1 1/2 years now by spurious
-Wuninitialized warnings:

In function ‘wide_int wi::max_value(unsigned int, signop)’,
    inlined from ‘wide_int wi::max_value(unsigned int, signop)’ at /vol/gcc/src/hg/master/local/gcc/wide-int.cc:330:1:
/vol/gcc/src/hg/master/local/gcc/wide-int.cc:335:31: error: ‘<anonymous>.generic_wide_int<wide_int_storage>::<anonymous>.wide_int_storage::val[1]’ may be used uninitialized [-Werror=maybe-uninitialized]
  335 |     return shwi (-1, precision);
      |                               ^
[...]
In function ‘wide_int get_nonzero_bits(const_tree)’,
    inlined from ‘wide_int get_nonzero_bits(const_tree)’ at /vol/gcc/src/hg/master/local/gcc/tree-ssanames.c:531:1:
/vol/gcc/src/hg/master/local/gcc/tree-ssanames.c:544:67: error: ‘<anonymous>.generic_wide_int<wide_int_storage>::<anonymous>.wide_int_storage::val[1]’ may be used uninitialized [-Werror=maybe-uninitialized]
  544 |                          | (HOST_WIDE_INT) pi->misalign, precision);
      |                                                                   ^
[...]

Before we ship yet another release with this issue, I suggest to at
least include a workaround of demoting them to warnings.

Tested on sparcv9-sun-solaris2.11.

2021-03-03  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
PR bootstrap/92002
* config/sparc/t-sparc (tree-ssanames.o-warn): Don't error for
-Wuninitialized, -Wmaybe-uninitialized.
(wide-int.o-warn): Likewise.

3 years agoc++: ICE with deduction guide in checking type-dep [PR99009, PR97034]
Marek Polacek [Fri, 12 Feb 2021 17:21:15 +0000 (12:21 -0500)]
c++: ICE with deduction guide in checking type-dep [PR99009, PR97034]

We represent deduction guides with FUNCTION_DECLs, but they are built
without DECL_CONTEXT, leading to an ICE in type_dependent_expression_p
on the assert that the type of a function template with no dependent
(innermost!) template arguments must be non-dependent.  Consider the
attached class-deduction79.C: we create a deduction guide:

  template<class T> G(T)-> E<Z>::G<T>

we deduce T and create a partial instantiation:

  G(T) -> E<Z>::G<T> [with T = int]

And then do_class_deduction wants to create a CALL_EXPR from the above
using build_new_function_call -> build_over_call which calls mark_used
-> maybe_instantiate_noexcept -> type_dependent_expression_p.

There, the innermost template arguments are non-dependent (<int>), but
the fntype is dependent -- the return type is a TYPENAME_TYPE, and
since we have no DECL_CONTEXT, this check holds:

  /* Otherwise, if the function decl isn't from a dependent scope, it can't be
     type-dependent.  Checking this is important for functions with auto return
     type, which looks like a dependent type.  */
  if (TREE_CODE (expression) == FUNCTION_DECL
      && !(DECL_CLASS_SCOPE_P (expression)
           && dependent_type_p (DECL_CONTEXT (expression)))

whereupon we ICE.

This patch fixes it by deferring the class deduction until the
enclosing scope is non-dependent.  build_deduction_guide and maybe_aggr_guide
needed a little tweaking to make the deduction work in a member
template.

Co-Authored-By: Jason Merrill <jason@redhat.com>
gcc/cp/ChangeLog:

PR c++/97034
PR c++/99009
* pt.c (build_deduction_guide): Use INNERMOST_TEMPLATE_ARGS.
(maybe_aggr_guide): Use the original template type where needed.  In
a class member template, partially instantiate the result of
collect_ctor_idx_types.
(do_class_deduction): Defer the deduction until the enclosing
scope is non-dependent.

gcc/testsuite/ChangeLog:

PR c++/97034
PR c++/99009
* g++.dg/cpp1z/class-deduction81.C: New test.
* g++.dg/cpp1z/class-deduction82.C: New test.
* g++.dg/cpp2a/class-deduction-aggr8.C: New test.
* g++.dg/cpp2a/class-deduction-aggr9.C: New test.
* g++.dg/cpp2a/class-deduction-aggr10.C: New test.

3 years agoarm: Ignore --with-mode when CPU only supports one instruction set.
Richard Earnshaw [Tue, 2 Mar 2021 14:51:11 +0000 (14:51 +0000)]
arm: Ignore --with-mode when CPU only supports one instruction set.

Arm processors can support up to two instruction sets.  Some early
cores only support the traditional A32 (Arm) instructions, while some
more recent devices only support T32 (Thumb) instructions.

When configuring the compiler,--with-mode can be used to select the
default instruction set to target if the user has not made an explicit
choice, but this can cause needless problems if the default is not
supported by the requested CPU.

To fix this this patch adjusts the way that the --with-mode selection
is processed so that it can take into account the selected CPU or
architecture and not create a meaningless combination.

gcc:
* common/config/arm/arm-common.c: Include configargs.h.
(arm_config_default): New function.
(arm_target_mode): Renamed from arm_target_thumb_only.  Handle
processors that do not support Thumb.  Take into account the
--with-mode configuration setting for selecting the default.
* config/arm/arm.h (OPTION_DEFAULT_SPECS): Remove entry for 'mode'.
(TARGET_MODE_SPEC_FUNCTIONS): Update for function name change.

3 years agoc++: C++17 and decltype of multi-operator expression [PR95675]
Jason Merrill [Wed, 3 Mar 2021 04:59:00 +0000 (23:59 -0500)]
c++: C++17 and decltype of multi-operator expression [PR95675]

A call that is the immediate operand of decltype has special semantics: no
temporary is produced, so it's OK for the return type to be e.g. incomplete.
But we were treating (e | f) the same way, which confused overload
resolution when we then tried to evaluate ... | g.

Fixed by making build_temp do what its name says, and force the C++17
temporary materialization conversion.

gcc/cp/ChangeLog:

PR c++/95675
* call.c (build_temp): Wrap a CALL_EXPR in a TARGET_EXPR
if it didn't get one before.

gcc/testsuite/ChangeLog:

PR c++/95675
* g++.dg/cpp0x/decltype-call5.C: New test.
* g++.dg/cpp0x/decltype-call6.C: New test.

3 years agolibstdc++: Update Solaris baselines for GCC 11.1
Rainer Orth [Wed, 3 Mar 2021 13:25:51 +0000 (14:25 +0100)]
libstdc++: Update Solaris baselines for GCC 11.1

The following patch updates the Solaris baselines for GCC 11.1.  There's
only one caveat: comparing the Solaris 11.3 and 11.4 baselines, I find

+FUNC:_ZSt10from_charsPKcS0_RdSt12chars_format@@GLIBCXX_3.4.29
+FUNC:_ZSt10from_charsPKcS0_ReSt12chars_format@@GLIBCXX_3.4.29
+FUNC:_ZSt10from_charsPKcS0_RfSt12chars_format@@GLIBCXX_3.4.29

i.e.

std::from_chars(char const*, char const*, double&, std::chars_format)

and similarly for long double, float.  Those are from from
src/c++17/floating_from_chars.cc and only defined if
_GLIBCXX_HAVE_USELOCALE, i.e. depend on the XPG7 addition.  Given that
only Solaris 11.4 supports XPG7, I've taken the 11.3 baselines to avoid
having separate ones for 11.3 and 11.4.

Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (sparc and x86,
32 and 64-bit, 11.3 and 11.4).

2021-02-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* config/abi/post/i386-solaris/baseline_symbols.txt: Regenerate.
* config/abi/post/i386-solaris/amd64/baseline_symbols.txt:
Likewise.
* config/abi/post/sparc-solaris/baseline_symbols.txt: Likewise.
* config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt:
Likewise.

3 years agogcov: use mmap pools for KVP.
Martin Liska [Wed, 13 Jan 2021 10:17:03 +0000 (11:17 +0100)]
gcov: use mmap pools for KVP.

gcc/ChangeLog:

PR gcov-profile/97461
* gcov-io.h (GCOV_PREALLOCATED_KVP): Remove.

libgcc/ChangeLog:

PR gcov-profile/97461
* config.in: Regenerate.
* configure: Likewise.
* configure.ac: Check sys/mman.h header file
* libgcov-driver.c (struct gcov_kvp): Remove static
pre-allocated pool and use a dynamic one.
* libgcov.h (MMAP_CHUNK_SIZE): New.
(gcov_counter_add): Use mmap to allocate pool for struct
gcov_kvp.

3 years agotestsuite: i386: Fix gcc.target/i386/pr95798-?.c on Solaris
Rainer Orth [Wed, 3 Mar 2021 12:49:28 +0000 (13:49 +0100)]
testsuite: i386: Fix gcc.target/i386/pr95798-?.c on Solaris

The new gcc.target/i386/pr95798-?.c tests FAIL on 64-bit Solaris/x86:

+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 1,
8\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 2,
16\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 3,
24\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 4,
32\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 5,
40\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 6,
48\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-1.c scan-assembler 7,
56\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 1,
8\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 2,
16\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 3,
24\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 4,
32\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 5,
40\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 6,
48\\\\(%rsp,%r[a-z0-9]*,8\\\\)
+FAIL: gcc.target/i386/pr95798-2.c scan-assembler 7,
56\\\\(%rsp,%r[a-z0-9]*,8\\\\)

This happens because Solaris/amd64 defaults to -fno-omit-frame-pointer
and can be avoided by always passing -fomit-frame-pointer.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

2021-03-02  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* gcc.target/i386/pr95798-1.c: Add -fomit-frame-pointer to
dg-options.
* gcc.target/i386/pr95798-2.c: Likewise.

3 years agoc++: namespace reachability [PR 99344]
Nathan Sidwell [Fri, 26 Feb 2021 15:51:13 +0000 (07:51 -0800)]
c++: namespace reachability [PR 99344]

This reworks namespace serializing to avoid some issues I ran into
when working on 99170.  In modules, (non-anonymous) namespaces are
strange beasts, that always have external linkage, but may have
module-specific visibility.  I still don't get the latter 100%
correct, but this is in the right direction.

PR c++/99344
gcc/cp/
* module.cc (trees_out::decl_node): Small refactor.
(depset::hash::add_binding_entity): Return true on meeting an
import.  Set namespace's import here.
(module_state:write_namespaces): Inform of purview too.
(module_state:read_namespaces): Adjust.
* name-lookup.c (implicitly_export_namespace): Delete.
(do_pushdecl): Don't call it.
(push_namespace): Likewise, set purview.
(add_imported_namespace): Reorder parms.
* name-lookup.h (add_imported_namespace): Alter param ordering.
gcc/testsuite/
* g++.dg/modules/namespace-2_a.C
* g++.dg/modules/pr99344_a.C
* g++.dg/modules/pr99344_b.C

3 years agolibstdc++: Don't use reserved identifiers in simd headers
Rainer Orth [Wed, 3 Mar 2021 12:16:35 +0000 (13:16 +0100)]
libstdc++: Don't use reserved identifiers in simd headers

Two simd tests FAIL on Solaris, both SPARC and x86:

FAIL: experimental/simd/standard_abi_usable.cc -msse2 -O2 -Wno-psabi (test for excess errors)
FAIL: experimental/simd/standard_abi_usable_2.cc -msse2 -O2 -Wno-psabi (test for excess errors)

This happens because the simd headers use identifiers documented in the
libstdc++ manual as reserved by system headers.

Fixed as follows, tested on i386-pc-solaris2.11, sparc-sun-solaris2.11,
and x86_64-pc-linux-gnu.

2021-02-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* include/experimental/bits/simd.h: Replace reserved _X, _B by
_Xp, _Bp.
* include/experimental/bits/simd_builtin.h: Likewise.
* include/experimental/bits/simd_x86.h: Likewise.

3 years agoFix ICE with pathologically large frames
Eric Botcazou [Wed, 3 Mar 2021 11:25:03 +0000 (12:25 +0100)]
Fix ICE with pathologically large frames

gcc/
PR target/99234
* config/i386/i386.c (ix86_compute_frame_layout): For a SEH target,
point back the hard frame pointer to its default location when the
frame is larger than SEH_MAX_FRAME_SIZE.

3 years agoi386: Fix a peephole2 for -mavx512vl -mno-avx512bw [PR99321]
Jakub Jelinek [Wed, 3 Mar 2021 09:06:14 +0000 (10:06 +0100)]
i386: Fix a peephole2 for -mavx512vl -mno-avx512bw [PR99321]

As the testcase shows, the
(define_peephole2
  [(set (match_operand 0 "sse_reg_operand")
        (match_operand 1 "sse_reg_operand"))
   (set (match_dup 0)
        (match_operator 3 "commutative_operator"
          [(match_dup 0)
           (match_operand 2 "memory_operand")]))]
peephole2 can for AVX512VL without AVX512BW (I guess it is a hyphothetical
CPU, but unfortunately they are separate CPUID bits and we have separate
options for them) turn something that is valid without that peephole2
into something that is invalid (and in this case ICEs).
The problem is that the vpadd[bw], vpmullw, vpmin[su][bw] and vpmax[su][bw]
instructions require both AVX512BW and AVX512VL when they have
16-byte or 32-byte operands.  If operands[0] is %[xy]mm0 .. %[xy]mm15
but operands[1] is %[xy]mm16 .. %[xy]mm31, then before we have
a vector move which uses vmovdqa{32,64} and doesn't need AVX512BW,
AVX512VL is I think implied from HARD_REGNO_MODE_OK only supporting
V{16Q,32Q,8H,16H}imode in EXT_REX_SSE_REGNO_P regs with AVX512VL, and then
we have a commutative operation with that %[xy]mm0 .. %[xy]mm15 destination
and one source and a memory operand, so VEX encoded operation.
And, the peephole2 wants to replace it with a load into the destination
register from memory (ok) and then the commutative arith instruction.
But that needs EVEX encoding because of the high register and so requires
AVX512BW which might not be enabled.
The exception is and/ior/xor, because the hw doesn't have
vp{and,or,xor}{b,w} instructions at all, it uses vp{and,or,xor}d instead
and that of course doesn't need AVX512BW.

BTW, there are other bugs I need to look at, while the vp{min,max}ub with
16-byte operands instruction properly requires avx512bw for v constraints
and otherwise uses x, e.g. the vpadd[bw] etc. instructions don't.
I'll try to handle that incrementally later this week.

2021-03-03  Jakub Jelinek  <jakub@redhat.com>

PR target/99321
* config/i386/predicates.md (logic_operator): New define_predicate.
* config/i386/i386.md (mov + mem using comm arith peephole2):
Punt if operands[1] is EXT_REX_SSE_REGNO_P, AVX512BW is not enabled
and the inner mode is [QH]Imode.

* gcc.target/i386/pr99321.c: New test.

3 years agoc-family: Avoid ICE on va_arg [PR99324]
Jakub Jelinek [Wed, 3 Mar 2021 08:55:19 +0000 (09:55 +0100)]
c-family: Avoid ICE on va_arg [PR99324]

build_va_arg calls the middle-end mark_addressable, which e.g. requires that
cfun is non-NULL.  The following patch calls instead c_common_mark_addressable_vec
which is the c-family variant similarly to the FE c_mark_addressable and
cxx_mark_addressable, except that it doesn't error on addresses of register
variables.  As the taking of the address is artificial for the .VA_ARG
ifn and when that is lowered goes away, it is similar case to the vector
subscripting for which c_common_mark_addressable_vec has been added.

2021-03-03  Jakub Jelinek  <jakub@redhat.com>

PR c/99324
* c-common.c (build_va_arg): Call c_common_mark_addressable_vec
instead of mark_addressable.  Fix a comment typo -
neutrallly -> neutrally.

* gcc.c-torture/compile/pr99324.c: New test.

3 years agodwarf2out: Fix -gsplit-dwarf on riscv or other non-.uleb128 targets [PR99090]
Jakub Jelinek [Wed, 3 Mar 2021 08:53:58 +0000 (09:53 +0100)]
dwarf2out: Fix -gsplit-dwarf on riscv or other non-.uleb128 targets [PR99090]

As mentioned in the PR, riscv* only supports .uleb128 with constant
arguments, doesn't support difference of two labels because of aggressive
linker relaxations.  But I bet various other targets, especially those not
using GNU assembler, might suffer from the same problem.
As the FIXME comment in output_loc_list indicates, we ICE on
-gsplit-dwarf on those targets whenever we need .debug_loclists, because
we only emit DW_LLE_startx_length which requires working .uleb128 delta
of 2 code section labels.  We can't use DW_LLE_base_addressx
once followed by DW_LLE_offset_pair either because the latter suffers
from the same issue - need .uleb128 difference of code section labels
(and in that case not just for the second operand but also for the first).

So, this patch implements what the comment said and emits DW_LLE_startx_endx
instead, which wastes more space in .debug_addr, but will work.

Bootstrapped/regtested on x86_64-linux and i686-linux and as written in the
PR, Jim has tested it on riscv*linux.  Ok for trunk?

BTW, for HAVE_AS_LEB128 -gdwarf-5 -gsplit-dwarf, maybe we should consider
instead of always emitting DW_LLE_startx_length do all the optimizations
that we do for HAVE_AS_LEB128 -gdwarf-5, or at least a subset of them.
For !have_multiple_function_sections, we in that case emit just
DW_LLE_offset_pair (that can certainly be a win for small TUs, we wouldn't
need any .debug_addr entry in that case; on the other side, just using
DW_LLE_offset_pair can be harmful for very large TUs especially if the
loclist has many entries, emitting in that case a single DW_LLE_base_address
or for -gsplit-dwarf DW_LLE_base_addressx followed by DW_LLE_offset_pair
might be much smaller), and for have_multiple_function_sections figuring
out if DW_LLE_base_address followed by DW_LLE_offset_pair entries
or DW_LLE_start_length is bettter.  So perhaps a middle-ground for
-gsplit-dwarf would be to always do the have_multiple_function_sections
behavior, i.e. DW_LLE_base_addressx followed by DW_LLE_offset_pair vs.
DW_LLE_startx_length decisions based on the ranges and their counts.
And perhaps dwz could optimize afterwards, on linked binaries or shared
libraries it knows all the offsets and could figure out optimal DW_LLE_*.

2021-03-03  Jakub Jelinek  <jakub@redhat.com>

PR debug/99090
* dwarf2out.c (dw_loc_list_struct): Add end_entry member.
(new_loc_list): Clear end_entry.
(output_loc_list): Only use DW_LLE_startx_length for -gsplit-dwarf
if HAVE_AS_LEB128, otherwise use DW_LLE_startx_endx.  Fix comment
typo.
(index_location_lists): For dwarf_version >= 5 without HAVE_AS_LEB128,
initialize also end_entry.

3 years agocfgrtl: Fix up fixup_partitions caused ICE [PR99085]
Jakub Jelinek [Wed, 3 Mar 2021 08:51:54 +0000 (09:51 +0100)]
cfgrtl: Fix up fixup_partitions caused ICE [PR99085]

fixup_partitions sometimes changes some basic blocks from hot partition to
cold partition, in particular if after unreachable block removal or other
optimizations a hot partition block is dominated by cold partition block(s).
It fixes up the edges and jumps on those edges, but when after reorder
blocks and in rtl (non-cfglayout) mode that is clearly not enough, because
it keeps the block order the same and so we can end up with more than
1 hot/cold section transition in the same function.

So, this patch fixes that up too.

2021-03-03  Jakub Jelinek  <jakub@redhat.com>

PR target/99085
* cfgrtl.c (fixup_partitions): When changing some bbs from hot to cold
partitions, if in non-layout mode after reorder_blocks also move
affected blocks to ensure a single partition transition.

* gcc.dg/graphite/pr99085.c: New test.

3 years agolibgfortran: Fix negation for largest integer [PR81986]
Tobias Burnus [Wed, 3 Mar 2021 07:05:45 +0000 (08:05 +0100)]
libgfortran: Fix negation for largest integer [PR81986]

libgfortran/ChangeLog:
2021-03-01  Vittorio Zecca  <zeccav@gmail.com>
    Tobias Burnus  <tobias@codesourcery.com>

PR libfortran/81986
* runtime/string.c (gfc_itoa): Cast to unsigned before
negating.

3 years agocgraph: flatten and same_body aliases [PR96078]
Jason Merrill [Fri, 12 Feb 2021 03:01:19 +0000 (22:01 -0500)]
cgraph: flatten and same_body aliases [PR96078]

The patch for PR92372 made us start warning about a flatten attribute on an
alias.  But in the case of C++ 'tor base/complete variants, the user didn't
create the alias.  If the alias target also has the attribute, the alias
points to a flattened function, so we shouldn't warn.

gcc/ChangeLog:

PR c++/96078
* cgraphunit.c (process_function_and_variable_attributes): Don't
warn about flatten on an alias if the target also has it.
* cgraph.h (symtab_node::get_alias_target_tree): New.

gcc/testsuite/ChangeLog:

PR c++/96078
* g++.dg/ext/attr-flatten1.C: New test.

3 years agolibbacktrace: don't special case file 0
Ian Lance Taylor [Wed, 3 Mar 2021 02:14:55 +0000 (18:14 -0800)]
libbacktrace: don't special case file 0

It's no longer necessary as file 0 is now set up in all cases.

* dwarf.c (read_line_program): Don't special case file 0.
(read_function_entry): Likewise.

3 years agoDaily bump.
GCC Administrator [Wed, 3 Mar 2021 00:16:48 +0000 (00:16 +0000)]
Daily bump.

3 years agoaix: Fix TLS thread pointer function names.
David Edelsohn [Tue, 2 Mar 2021 15:11:47 +0000 (10:11 -0500)]
aix: Fix TLS thread pointer function names.

This patch adds missing periods to the symbol name for TLS helper functions.

gcc/ChangeLog:

* config/rs6000/rs6000.md (tls_get_tpointer_internal): Prepend
period to symbol name.
(tls_get_addr_internal<mode>): Same.

3 years agooutputs.exp: skip @file -save-temps if target has -L or -I
Hans-Peter Nilsson [Thu, 25 Feb 2021 04:07:37 +0000 (05:07 +0100)]
outputs.exp: skip @file -save-temps if target has -L or -I

The outputs.exp tests check what temporary files are created
and left behind with e.g. -save-temps.

Additional files are created in presence of @file option.
Adding an -I or -L option causes *another* temporary file to
appear.  I take it that's deliberate, as there are tests for
that behavior.

For native testing, the default test-framework baseboard
file unix.exp doesn't add any -I or -L options and all tests
pass.  For a newlib target however, you'll have a couple of
-L options (see the nopts handling in outputs.exp), leading
to:

Running /x/gcc/gcc/testsuite/gcc.misc-tests/outputs.exp ...
FAIL: outputs exe savetmp namedb: extra
outputs.args.1
FAIL: outputs exe savetmp named2: extra
outputs.args.1
FAIL: outputs exe savetmp named2: extra
outputs.args.3
FAIL: outputs lto sing unnamed: extra
a.args.1

The failing tests are among the actual tests that check the
behavior of @file, and are confused by the additional -L.

Identify presence of -I or -L from the test framework and
skip those tests.

Tested cris-elf and x86_64-pc-linux-gnu.

gcc/testsuite:
* gcc.misc-tests/outputs.exp: Skip @file -save-temps
tests if target test-framework has -L or -I options.

3 years ago[PATCH] Fix Ada bootstrap failure on Cygwin since switch to C++11 (PR98590)
Mikael Pettersson [Tue, 2 Mar 2021 22:20:06 +0000 (15:20 -0700)]
[PATCH] Fix Ada bootstrap failure on Cygwin since switch to C++11 (PR98590)

gcc/ada
PR bootstrap/98590
* cstreams.c: Ensure fileno_unlocked() is visible on Cygwin.

3 years agocompiler: allow //go:embed in files underscore-importing embed
Michael Matloob [Tue, 2 Mar 2021 00:02:38 +0000 (19:02 -0500)]
compiler: allow //go:embed in files underscore-importing embed

The embed spec allows for //go:embed to be used in files that
underscore-import package "embed". This is useful for embeds to
[]byte and string vars because the embed.FS type may not be referenced
if those are the only types of embeds in a file. Because the compiler
previously checked whether there were any aliases to the embed
package to decide if //go:embed could be used, it would reject
files with only underscore imports of embed. Instead, record
whether the embed import is encountered at all, similar to what
is done with unsafe, to decide whether //go:embed is allowed.

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

3 years agolibbacktrace: pass -1 to error callback for unrecognized DWARF
Ian Lance Taylor [Tue, 2 Mar 2021 21:45:56 +0000 (13:45 -0800)]
libbacktrace: pass -1 to error callback for unrecognized DWARF

PR libbacktrace/98818
* dwarf.c (dwarf_buf_error): Add errnum parameter.  Change all
callers.
* backtrace.h: Update backtrace_error_callback comment.

3 years agodiagnostics: fix ICE on fix-it hints on very long lines [PR99323]
David Malcolm [Tue, 2 Mar 2021 20:46:06 +0000 (15:46 -0500)]
diagnostics: fix ICE on fix-it hints on very long lines [PR99323]

PR c/99323 describes an ICE due to a failed assertion deep inside the
fix-it printing machinery, where the fix-it hints on one line have not
been properly sorted in layout's constructor.

The underlying issue occurs when multiple fix-it hints affect a line
wider that LINE_MAP_MAX_COLUMN_NUMBER, where the location_t values for
characters after that threshold fall back to having column zero.

It's not meaningful to try to handle fix-it hints without column
information, so this patch rejects them as they are added to the
rich_location, falling back to the "no fix-it hints on this diagnostic"
case, fixing the crash.

gcc/ChangeLog:
PR c/99323
* diagnostic-show-locus.c
(selftest::test_one_liner_many_fixits_2): Fix accidental usage of
column 0.

gcc/testsuite/ChangeLog:
PR c/99323
* gcc.dg/pr99323-1.c: New test.
* gcc.dg/pr99323-2.c: New test.

libcpp/ChangeLog:
PR c/99323
* line-map.c (rich_location::maybe_add_fixit): Reject fix-it hints
at column 0.

3 years agoPR middle-end/99276 - grammar in diagnostics for overflowing the destination
Martin Sebor [Tue, 2 Mar 2021 20:37:01 +0000 (13:37 -0700)]
PR middle-end/99276 - grammar in diagnostics for overflowing the destination

gcc/ChangeLog:

PR middle-end/99276
* builtins.c (warn_for_access): Remove stray warning text.

3 years agoPR middle-end/99295 - documentation on __attribute__((malloc)) is wrong
Martin Sebor [Tue, 2 Mar 2021 18:19:49 +0000 (11:19 -0700)]
PR middle-end/99295 - documentation on __attribute__((malloc)) is wrong

gcc/ChangeLog:

PR middle-end/99295
* doc/extend.texi (attribute malloc): Reword and clarify nonaliasing
property.