Iain Buclaw [Thu, 16 Dec 2021 22:56:16 +0000 (23:56 +0100)]
config: Add check whether D compiler works (PR103528)
As well as checking for the existence of a GDC compiler, also validate
that it has also been built with libphobos, otherwise warn or fail with
the message that GDC is required to build d.
Xionghu Luo [Wed, 8 Dec 2021 01:24:35 +0000 (19:24 -0600)]
Don't move cold code out of loop by checking bb count
v8 changes:
1. Use hotter_than_inner_loop instead of colder to store a hotter loop
nearest to loop.
2. Update the logic in fill_coldest_and_hotter_out_loop and
get_coldest_out_loop to make common case O(1).
3. Update function argument bb_colder_than_loop_preheader.
4. Make cached array to vec<class *loop> for index checking.
v7 changes:
1. Refine get_coldest_out_loop to replace loop with checking
pre-computed coldest_outermost_loop and colder_than_inner_loop.
2. Add function fill_cold_out_loop, compute coldest_outermost_loop and
colder_than_inner_loop recursively without loop.
v6 changes:
1. Add function fill_coldest_out_loop to pre compute the coldest
outermost loop for each loop.
2. Rename find_coldest_out_loop to get_coldest_out_loop.
3. Add testcase ssa-lim-22.c to differentiate with ssa-lim-19.c.
v5 changes:
1. Refine comments for new functions.
2. Use basic_block instead of count in bb_colder_than_loop_preheader
to align with function name.
3. Refine with simpler implementation for get_coldest_out_loop and
ref_in_loop_hot_body::operator for better understanding.
v4 changes:
1. Sort out profile_count comparision to function bb_cold_than_loop_preheader.
2. Update ref_in_loop_hot_body::operator () to find cold_loop before compare.
3. Split RTL invariant motion part out.
4. Remove aux changes.
v3 changes:
1. Handle max_loop in determine_max_movement instead of outermost_invariant_loop.
2. Remove unnecessary changes.
3. Add for_all_locs_in_loop (loop, ref, ref_in_loop_hot_body) in can_sm_ref_p.
4. "gsi_next (&bsi);" in move_computations_worker is kept since it caused
infinite loop when implementing v1 and the iteration is missed to be
updated actually.
Richard suggested to "never hoist anything from a bb with lower execution
frequency to a bb with higher one in LIM invariantness_dom_walker
before_dom_children".
In gimple LIM analysis, add get_coldest_out_loop to move invariants to
expected target loop, if profile count of the loop bb is colder
than target loop preheader, it won't be hoisted out of loop.
Likely for store motion, if all locations of the REF in loop is cold,
don't do store motion of it.
SPEC2017 performance evaluation shows 1% performance improvement for
intrate GEOMEAN and no obvious regression for others. Especially,
500.perlbench_r +7.52% (Perf shows function S_regtry of perlbench is
largely improved.), and 548.exchange2_r+1.98%, 526.blender_r +1.00%
on P8LE.
gcc/ChangeLog:
2021-12-21 Xionghu Luo <luoxhu@linux.ibm.com>
* tree-ssa-loop-im.c (bb_colder_than_loop_preheader): New
function.
(get_coldest_out_loop): New function.
(determine_max_movement): Use get_coldest_out_loop.
(move_computations_worker): Adjust and fix iteration udpate.
(class ref_in_loop_hot_body): New functor.
(ref_in_loop_hot_body::operator): New.
(can_sm_ref_p): Use for_all_locs_in_loop.
(fill_coldest_and_hotter_out_loop): New.
(tree_ssa_lim_finalize): Free coldest_outermost_loop and
hotter_than_inner_loop.
(loop_invariant_motion_in_fun): Call fill_coldest_and_hotter_out_loop.
gcc/testsuite/ChangeLog:
2021-12-21 Xionghu Luo <luoxhu@linux.ibm.com>
* gcc.dg/tree-ssa/recip-3.c: Adjust.
* gcc.dg/tree-ssa/ssa-lim-19.c: New test.
* gcc.dg/tree-ssa/ssa-lim-20.c: New test.
* gcc.dg/tree-ssa/ssa-lim-21.c: New test.
* gcc.dg/tree-ssa/ssa-lim-22.c: New test.
* gcc.dg/tree-ssa/ssa-lim-23.c: New test.
Xionghu Luo [Wed, 8 Dec 2021 05:17:51 +0000 (23:17 -0600)]
Fix loop split incorrect count and probability
In tree-ssa-loop-split.c, split_loop and split_loop_on_cond does two
kind of split. split_loop only works for single loop and insert edge at
exit when split, while split_loop_on_cond is not limited to single loop
and insert edge at latch when split. Both split behavior should consider
loop count and probability update. For split_loop, loop split condition
is moved in front of loop1 and loop2; But split_loop_on_cond moves the
condition between loop1 and loop2, this patch does:
1) profile count proportion for both original loop and copied loop
without dropping down the true branch's count;
2) probability update in the two loops and between the two loops.
Regression tested pass.
Changes diff for split_loop and split_loop_on_cond cases:
Xionghu Luo [Tue, 21 Dec 2021 03:10:09 +0000 (21:10 -0600)]
Fix incorrect loop exit edge probability [PR103270]
r12-4526 cancelled jump thread path rotates loop. It exposes a issue in
profile-estimate when predict_extra_loop_exits, outer loop's exit edge
is marked as inner loop's extra loop exit and set with incorrect
prediction, then a hot inner loop will become cold loop finally through
optimizations, this patch add loop check when searching extra exit edges
to avoid unexpected predict_edge from predict_paths_for_bb.
If one later checks for saturation (reads VSCR), one needs a
corresponding SET of the value. It's set in an architecture-specific
manner that isn't described to GCC, but it's set, not just clobbered
and in an undefined state.
The RTL does not describe that VSCR is set to the value 0. The
(const_int 0) is not the value set. You can think of the (const_int
0) as a dummy RTL argument to the VSCR UNSPEC. UNSPEC requires at
least one argument and the pattern doesn't try to express the
argument, so it uses a dummy RTL constant. It's part of a PARALLEL
and the plus or minus already expresses the data dependency of the
pattern on the input operands."
gcc/ChangeLog:
2021-12-21 Xionghu Luo <luoxhu@linux.ibm.com>
* config/rs6000/altivec.md (altivec_vaddu<VI_char>s): Replace
UNSPEC_VADDU with us_plus.
(altivec_vadds<VI_char>s): Replace UNSPEC_VADDS with ss_plus.
(altivec_vsubu<VI_char>s): Replace UNSPEC_VSUBU with us_minus.
(altivec_vsubs<VI_char>s): Replace UNSPEC_VSUBS with ss_minus.
(altivec_abss_<mode>): Likewise.
Uros Bizjak [Mon, 20 Dec 2021 20:15:50 +0000 (21:15 +0100)]
i386: Fix <sse2p4_1>_pinsr<ssemodesuffix> and its splitters [PR103772]
The clever trick to duplicate the value of the input operand into itself
proved not so clever after all. The splitter should not clobber the input
operand in any case, since the register can hold the value outside the HImode
lowpart when accessed as subreg. Use the standard earlyclobber approach
instead.
The testcase fails with avx2 ISA, but I was not able to create the testcase
that wouldn't require -mavx512fp16 compile flag.
2021-12-20 Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog:
PR target/103772
* config/i386/sse.md (<sse2p4_1>_pinsr<ssemodesuffix>): Add
earlyclobber to (x,x,x,i) alternative.
(<sse2p4_1>_pinsr<ssemodesuffix> peephole2): Remove.
(<sse2p4_1>_pinsr<ssemodesuffix> splitter): Use output
operand as a temporary register. Split after reload_completed.
Patrick Palka [Mon, 20 Dec 2021 20:02:40 +0000 (15:02 -0500)]
c++: memfn lookup consistency in incomplete-class ctx
When instantiating a call to a member function of a class template, we
repeat the member function lookup in order to obtain the corresponding
partially instantiated functions. Within an incomplete-class context
however, we need to be more careful when repeating the lookup because we
don't want to introduce later-declared member functions that weren't
visible at template definition time. We're currently not careful enough
in this respect, which causes us to reject memfn1.C below.
This patch fixes this issue by making tsubst_baselink filter out from
the instantiation-time lookup those member functions that were invisible
at template definition time. This is really only necessary within an
incomplete-class context, so this patch adds a heuristic flag to BASELINK
to help us avoid needlessly performing this filtering step (which would
be a no-op) in complete-class contexts.
This is also necessary for the ahead-of-time overload set pruning
implemented in r12-6075 to be effective for member functions within
class templates.
gcc/cp/ChangeLog:
* call.c (build_new_method_call): Set
BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P on the pruned baselink.
* cp-tree.h (BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P): Define.
* pt.c (filter_memfn_lookup): New subroutine of tsubst_baselink.
(tsubst_baselink): Use filter_memfn_lookup on the new lookup
result when BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P is set on the
old baselink. Remove redundant BASELINK_P check.
* search.c (build_baselink): Set
BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P appropriately.
gcc/testsuite/ChangeLog:
* g++.dg/lookup/memfn1.C: New test.
* g++.dg/template/non-dependent16b.C: New test.
Roger Sayle [Mon, 20 Dec 2021 15:22:18 +0000 (15:22 +0000)]
x86_64: Improve code expanded for highpart multiplications.
While working on a middle-end patch to more aggressively use highpart
multiplications on targets that support them, I noticed that the RTL
expanded by the x86 backend interacts poorly with register allocation
leading to suboptimal code.
For the testcase,
typedef int __attribute ((mode(TI))) ti_t;
long foo(long x)
{
return ((ti_t)x * 19065) >> 64;
}
we'd like to avoid:
foo: movq %rdi, %rax
movl $19065, %edx
imulq %rdx
movq %rdx, %rax
ret
and would prefer:
foo: movl $19065, %eax
imulq %rdi
movq %rdx, %rax
ret
This patch provides a pair of peephole2 transformations to tweak the
spills generated by reload, and at the same time replaces the current
define_expand with a define_insn pattern using the new [su]mul_highpart
RTX codes.
2021-12-20 Roger Sayle <roger@nextmovesoftware.com>
Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog
* config/i386/i386.md (any_mul_highpart): New code iterator.
(sgnprefix, s): Add attribute support for [su]mul_highpart.
(<s>mul<mode>3_highpart): Delete expander.
(<s>mul<mode>3_highpart, <s>mulsi32_highpart_zext):
New define_insn patterns.
(define_peephole2): Tweak the register allocation for the above
instructions after reload.
gcc/testsuite/ChangeLog
* gcc.target/i386/smuldi3_highpart.c: New test case.
Patrick Palka [Mon, 20 Dec 2021 14:28:20 +0000 (09:28 -0500)]
c++: ahead-of-time overload set pruning for non-dep calls
This patch makes us remember the function selected by overload resolution
during ahead of time processing of a non-dependent call expression, so
that at instantiation time we avoid repeating some of the work of overload
resolution for the call. Note that we already do this for non-dependent
operator expressions via build_min_non_dep_op_overload.
Some caveats:
* When processing ahead of time a non-dependent call to a member
function template of a currently open class template (as in
g++.dg/template/deduce4.C), we end up generating an "inside-out"
partial instantiation such as S<T>::foo<int, int>(), the likes of
which we're apparently not prepared to fully instantiate. So in this
situation, we instead prune to the selected template instead of the
specialization in this situation.
* This change triggered a latent FUNCTION_DECL pretty printing issue
in cpp0x/error2.C -- since we now resolve the call to foo<0> ahead
of time, the error now looks like:
error: expansion pattern ‘foo()()=0’ contains no parameter pack
where the FUNCTION_DECL for foo<0> is clearly misprinted. But this
pretty-printing issue could be reproduced without this patch if
we define foo as a non-template function. Since this testcase was
added to verify pretty printing of TEMPLATE_ID_EXPR, I work around
this test failure by making the call to foo type-dependent and thus
immune to this ahead of time pruning.
* We now reject parts of cpp0x/fntmp-equiv1.C because we notice that
the non-dependent call d(f, b) in
int d(int, int);
template <unsigned long f, unsigned b, typename> e<d(f, b)> d();
is non-constexpr. Since this testcase is about equivalency of
dependent names in the context of declaration matching, it seems the
best fix here is to make the calls to d, d2 and d3 within the
function signatures dependent.
gcc/cp/ChangeLog:
* call.c (build_new_method_call): For a non-dependent call
expression inside a template, returning a templated tree
whose overload set contains just the selected function.
* semantics.c (finish_call_expr): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/error2.C: Make the call to foo type-dependent in
order to avoid latent pretty-printing issue for FUNCTION_DECL
inside MODOP_EXPR.
* g++.dg/cpp0x/fntmp-equiv1.C: Make the calls to d, d2 and d3
within the function signatures dependent.
* g++.dg/template/non-dependent16.C: New test.
* g++.dg/template/non-dependent16a.C: New test.
* g++.dg/template/non-dependent17.C: New test.
Jan Hubicka [Mon, 20 Dec 2021 07:43:13 +0000 (08:43 +0100)]
Fix handling of deferred SSA names in modref dataflow
In the testcase we fail to analyze SSA name because flag do_dataflow is set
and thus triggers early exist in analyze_ssa_name. Fixed by disabling
early exits when handling deferred names.
gcc/ChangeLog:
2021-12-20 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103669
* ipa-modref.c (modref_eaf_analysis::analyze_ssa_name): Add deferred
parameter.
(modref_eaf_analysis::propagate): Use it.
gcc/testsuite/ChangeLog:
2021-12-20 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103669
* g++.dg/torture/pr103669.C: New test.
Andrew Pinski [Sun, 19 Dec 2021 22:26:41 +0000 (22:26 +0000)]
Change the xfail in gcc.dg/uninit-pr89230-1.c
With the recent PHI-OPT patch for line numbers, I had missed this
testcase was now failing. The uninitialized warning was there
before my recent patch, just was on the wrong line. The testcase
had added an xfail in r12-4698-gf6d012338 (though a bug report was
not filed to record it).
This patch changes the dg-bogus messages around to catch both locations
and xfail both of them.
At least there is now a patch for the correct line numbers for the
phi-opt.
Committed after testing the testcase.
gcc/testsuite/ChangeLog:
* gcc.dg/uninit-pr89230-1.c: Change the dg-bogus messages
around and xfail both of them.
Jan Hubicka [Sun, 19 Dec 2021 21:28:40 +0000 (22:28 +0100)]
Fix early exit in modref_merge_call_site_flags
When adding support for static chain and return slot flags I forgot to update
early exit condition in modref_merge_call_site_flags. This yields to wrong
code as demonstrated by the Fortran testcase attached to PR (which I hope
someone will help me to turn into testuite one).
gcc/ChangeLog:
2021-12-19 Jan Hubicka <hubicka@ucw.cz>
PR ipa/103766
* ipa-modref.c (modref_merge_call_site_flags): Fix early exit condition
Matthias Kretz [Wed, 15 Dec 2021 08:45:06 +0000 (09:45 +0100)]
c++: don't ICE on NAMESPACE_DECL inside FUNCTION_DECL
Code like
void swap() {
namespace __variant = __detail::__variant;
...
}
create a NAMESPACE_DECL where the CP_DECL_CONTEXT is a FUNCTION_DECL.
DECL_TEMPLATE_INFO fails on NAMESPACE_DECL and therefore must be handled
first in the assertion.
Patrick Palka [Sun, 19 Dec 2021 19:42:14 +0000 (14:42 -0500)]
c++: nested lambda capturing a capture proxy, cont [PR94376]
The r12-5403 fix apparently doesn't handle the case where the inner
lambda explicitly rather than implicitly captures the capture proxy from
the outer lambda, which causes us to reject the first example in the
testcase below.
This is because compared to an implicit capture, the effective initializer
for an explicit capture is wrapped in a location wrapper (pointing to within
the capture list), and this wrapper foils the is_capture_proxy check added
in r12-5403.
The simplest fix appears to be to strip location wrappers accordingly
before checking is_capture_proxy. And to help prevent against this kind
of bug, this patch also makes is_capture_proxy assert it doesn't see a
location wrapper.
PR c++/94376
gcc/cp/ChangeLog:
* lambda.c (lambda_capture_field_type): Strip location wrappers
before checking for a capture proxy.
(is_capture_proxy): Assert that we don't see a location wrapper.
(mark_const_cap_r): Don't call is_constant_capture_proxy on a
location wrapper.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/lambda/lambda-nested9a.C: New test.
Patrick Palka [Sun, 19 Dec 2021 17:10:16 +0000 (12:10 -0500)]
c++: local_specializations and recursive constrained fn [PR103714]
Here during constraint checking for the inner call to A<0>::f<0>,
substitution into the PARM_DECL d in the atomic constraint yields the
wrong local specialization because local_specializations at this point
is nonempty, and contains specializations for the caller A<0>::f<1>.
This patch makes us call push_to_top_level during satisfaction, which'll
temporarily clear local_specializations for us.
PR c++/103714
gcc/cp/ChangeLog:
* constraint.cc (satisfy_declaration_constraints): Do
push_to_top_level and pop_from_top_level around the call to
satisfy_normalized_constraints.
Andrew Pinski [Sat, 18 Dec 2021 11:52:37 +0000 (11:52 +0000)]
Improve location for new statements in match-and-simplify phiopt
Before match-and-simplify was used in phiot, the location of the
new stamtents were all of that of the conditional, this adds that
back as I did not realize gimple_simplify didn't do that for you.
OK? Bootstrapped and tested on x86_64 with no regressions.
gcc/ChangeLog:
* tree-ssa-phiopt.c (gimple_simplify_phiopt): Annotate the
new sequence with the location of the conditional statement.
Roger Sayle [Sat, 18 Dec 2021 13:51:56 +0000 (13:51 +0000)]
x86: PR target/103611: Splitter for DST:DI = (HI:SI<<32)|LO:SI.
A common idiom is to create a DImode value from the "concat" of two SImode
values, using "(long long)hi << 32 | (long long)lo", where the operation
may be ior, xor or plus. On x86, with -m32, the high and low parts of
a DImode register are actually different SImode registers (typically %edx
and %eax) so ideally this idiom should reduce to two move instructions
(or optimally, just clever register allocation).
Unfortunately, GCC currently performs the IOR operation above on -m32,
and worse allocates DImode registers (split to SImode register pairs)
for both the zero extended HI and LO values.
Hence, for test1 from the new test case below:
typedef int __v4si __attribute__ ((__vector_size__ (16)));
long long test1(__v4si v) {
unsigned int loVal = (unsigned int)v[0];
unsigned int hiVal = (unsigned int)v[1];
return (long long)(loVal) | ((long long)(hiVal) << 32);
}
test1: pextrd $1, %xmm0, %edx
movd %xmm0, %eax
ret
The fix is to recognize and split the idiom (hi<<32)|zext(lo) prior
to register allocation on !TARGET_64BIT, simplifying this sequence to
"highpart(dst) = hi; lowpart(dst) = lo".
The one minor complication is that sse.md's define_insn for
*vec_extractv4si_0_zext_sse4 can sometimes interfere with this
optimization. It turns out that on !TARGET_64BIT, the zero_extend:DI
following vec_select:SI isn't free, and this insn gets split back
into multiple instructions during later passes, but too late to
be optimized away by this patch/reload. Hence the last hunk of
this patch is to restrict *vec_extractv4si_0_zext_sse4 to TARGET_64BIT.
Checking PR target/80286, where *vec_extractv4si_0_zext_sse4 was
first added, this seems reasonable.
2021-12-18 Roger Sayle <roger@nextmovesoftware.com>
Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog
PR target/103611
* config/i386/i386.md (any_or_plus): New code iterator.
(define_split): Split (HI<<32)|zext(LO) into piece-wise
move instructions on !TARGET_64BIT.
* config/i386/sse.md (*vec_extractv4si_0_zext_sse4):
Restrict to TARGET_64BIT.
gcc/testsuite/ChangeLog
PR target/103611
* gcc.target/i386/pr103611-2.c: New test case.
Roger Sayle [Sat, 18 Dec 2021 13:47:52 +0000 (13:47 +0000)]
PR target/32803: Add -Oz option for improved clang compatibility.
This patch adds support for an -Oz command line option, aggressively
optimizing for size at the expense of performance. GCC's current -Os
provides a reasonable balance of size and performance, whereas -Oz is
probably only useful for code size benchmarks such as CSiBE. Or so I
thought until I read in https://news.ycombinator.com/item?id=25408853
that clang's -Oz sometimes outperforms -O[23s]; I suspect modern instruction
decode stages can treat "pushq $1; popq %rax" as a short uop encoding.
Instead of introducing a new global variable, this patch simply abuses
the existing optimize_size by setting its value to 2. The only change
in behaviour is the tweak to the i386 backend implementing the suggestion
in PR target/32803 to use a short push/pop sequence for loading small
immediate values (-128..127) on x86, matching the behaviour of LLVM.
On x86_64, the simple function:
int foo() { return 25; }
currently generates with -Os:
foo: movl $25, %eax // 5 bytes
ret
With the proposed -Oz, it generates:
foo: pushq $25 // 2 bytes
popq %rax // 1 byte
ret
On CSiBE, this results in a 0.94% improvement (3703513 bytes total
down to 3668516 bytes).
2021-12-18 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR target/32803
* common.opt (Oz): New command line option.
* doc/invoke.texi: Document the new -Oz option.
* lto-wrapper.c (merge_and_complain, append_compiler_options):
Treat OPT_Oz as synonymous with OPT_Os.
* optc-save-gen.awk: Increase maximum value of optimize_size to 2.
* opts.c (default_options_optimization) [OPT_Oz]: Handle OPT_Oz
just like OPT_Os, except set opt->x_optimize_size to 2.
(common_handle_option): Skip OPT_Oz just like OPT_Os.
* config/i386/i386.md (*movdi_internal): Use a push/pop sequence
for suitable SImode TYPE_IMOV moves when optimize_size > 1.
(*movsi_internal): Likewise.
gcc/testsuite/ChangeLog
PR target/32803
* gcc.target/i386/pr32803.c: New test case.
tree-optimization/103759: Use sizetype everywhere for object sizes
Since all computations in tree-object-size are now done in sizetype and
not HOST_WIDE_INT, comparisons with HOST_WIDE_INT based unknown and
initval would be incorrect. Instead, use the sizetype trees directly to
generate and evaluate initval and unknown size values.
Fortran: Cast arguments of <ctype.h> functions to unsigned char
Functions from <ctype.h> should only be called on values that can be
represented by unsigned char. On targets where char is a signed type,
some of libgfortran calls have undefined behaviour.
The solution is to cast the argument to unsigned char type. I’ve defined
macros in libgfortran.h to do so, to retain legibility of the library
code.
PR libfortran/95177
libgfortran/ChangeLog
* libgfortran.h: include ctype.h, provide safe macros.
* io/format.c: use safe macros.
* io/list_read.c: use safe macros.
* io/read.c: use safe macros.
* io/write.c: use safe macros.
* runtime/environ.c: use safe macros.
Darwin: Future-proof and homogeneize detection of darwin versions
The current GCC branch will become 12.1.0, which will be the stable
version of GCC when the next macOS version is released. There are some
places in GCC that don’t handle darwin22 as a version, so we need to
future-proof it (gcc/config.gcc and gcc/config/darwin-driver.c). We
align that code with what Apple clang does, i.e. accept all potential
major macOS versions until 99.
This patch also homogenises the handling of darwin version numbers,
where the majority of places use darwin2*, but some used darwin2[0-9]*.
Since there never was a darwin2.x version, the two are equivalent, and
we prefer the simpler darwin2*
gcc/ChangeLog:
* config/darwin-driver.c: Make version code more future-proof.
* config.gcc: Homogeneize darwin versions.
* configure.ac: Homogeneize darwin versions.
* configure: Regenerate.
gcc/testsuite/ChangeLog:
* gcc.dg/darwin-minversion-link.c: Test darwin21.
* obj-c++.dg/cxx-ivars-3.mm: Homogeneize darwin versions.
* obj-c++.dg/objc-gc-3.mm: Homogeneize darwin versions.
* objc.dg/objc-gc-4.m: Homogeneize darwin versions.
Marek Polacek [Thu, 16 Dec 2021 21:29:41 +0000 (16:29 -0500)]
attribs: Fix wrong error with -Wno-attribute=A::b [PR103649]
My patch to implement -Wno-attribute=A::b caused a bogus error when
parsing
[[foo::bar(1, 2)]];
when -Wno-attributes=foo::bar was specified on the command line, because
when we create a fake foo::bar attribute and insert it into our attribute
table, it is created with max_length == 0 which doesn't allow any args.
That is wrong -- we know nothing about the attribute, so we shouldn't
require any specific number of arguments. And since unknown attributes
can be rather complex (see for example omp::{directive,sequence}), we
must skip parsing their arguments. To that end, I'm using max_length
with value -2.
Also let's not warn about things like
[[vendor::assume(true)]];
because they may have some meaning (this is reminiscent of C++ Portable
Assumptions).
PR c/103649
gcc/ChangeLog:
* attribs.c (handle_ignored_attributes_option): Create the fake
attribute with max_length == -2.
(attribute_ignored_p): New overloads.
* attribs.h (attribute_ignored_p): Declare them.
* tree-core.h (struct attribute_spec): Document that max_length
can be -2.
gcc/c/ChangeLog:
* c-decl.c (c_warn_unused_attributes): Don't warn for
attribute_ignored_p.
* c-parser.c (c_parser_std_attribute): Skip parsing of the attribute
arguments when the attribute is ignored.
gcc/cp/ChangeLog:
* parser.c (cp_parser_declaration): Don't warn for attribute_ignored_p.
(cp_parser_std_attribute): Skip parsing of the attribute
arguments when the attribute is ignored.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
z.C:4:10: error: class template 'bar' redeclared as non-template
4 | struct bar {
| ^~~
z.C:2:10: note: previous declaration here
2 | struct bar;
| ^~~
z.C:8:7: error: 'bar<...auto...> var' has incomplete type
8 | bar var;
| ^~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
which is clearer about what the problem is.
I thought it'd be nice to avoid printing the messages about failed CTAD,
too. To that end, I'm using CLASSTYPE_ERRONEOUS to suppress CTAD. Not
sure if that's entirely kosher.
The other direction (first a non-template class declaration followed by
a class template definition) we handle quite well:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
z.C:11:8: error: 'bar' is not a template
11 | struct bar {};
| ^~~
z.C:8:8: note: previous declaration here
8 | struct bar;
| ^~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PR c++/103749
gcc/cp/ChangeLog:
* decl.c (lookup_and_check_tag): Give an error when a class was
declared as template but no template header has been provided.
* pt.c (do_class_deduction): Don't deduce CLASSTYPE_ERRONEOUS
types.
gcc/testsuite/ChangeLog:
* g++.dg/template/redecl4.C: Adjust dg-error.
* g++.dg/diagnostic/redeclaration-2.C: New test.
The builtins now all return "long". The patterns have :GPR as the
output mode, so they can be 32-bit as well (the instruction makes sense
in 32 bit just fine). The builtins expand to the DImode version
normally, but to the SImode if {32bit} is true.
Iain Sandoe [Sat, 2 Oct 2021 16:20:08 +0000 (17:20 +0100)]
coroutines: Handle initial awaiters with non-void returns [PR 100127].
The way in which a C++20 coroutine is specified discards any value
that might be returned from the initial or final await expressions.
This ICE was caused by an initial await expression with an
await_resume () returning a reference, the function rewrite code
was not set up to expect this.
Fixed by looking through any indirection present and by explicitly
discarding the value, if any, returned by await_resume().
It does not seem useful to make a diagnostic for this, since
the user could define a generic awaiter that usefully returns
values when used in a different position from the initial (or
final) await expressions.
Iain Sandoe [Sun, 3 Oct 2021 18:46:09 +0000 (19:46 +0100)]
coroutines: Pass lvalues to user-defined operator new [PR 100772].
The wording of the standard has been clarified to be explicit that
the the parameters to any user-defined operator-new in the promise
class should be lvalues.
Bill Schmidt [Fri, 17 Dec 2021 16:39:00 +0000 (10:39 -0600)]
rs6000: Fix fake vec_promote overload
rs6000-overload.def defines one instance of vec_promote so that it can be
registered with the front end. Actual expansion of the vec_promote overload
is done with special-case code in rs6000-c.c. During another cleanup, I
observed that the fake instance has the wrong number of arguments. Fix that.
2021-12-17 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-overload.def (__builtin_vec_promote): Add second
argument.
This PR shows that I didn't properly test the multi-vector case when
adding support for SLP gather loads. The patch fixes that case using
the same approach as we do for non-SLP cases: keep the scalar base
the same, but iterate through the (also multi-vector) vector offsets.
“vec_num * j + i” is already used elsewhere as a way of handling both
the multi-vector SLP case and the multi-vector non-SLP case.
Iain Sandoe [Wed, 15 Dec 2021 14:11:58 +0000 (14:11 +0000)]
libgcc, Darwin: Add missing build dependencies.
There was a race condition where the link for the new shared EH library
(only used on earlier Darwin) could fail because the new crts had not been
copied to the gcc directory. This can cause a build failure (although
currently only seen on powerpc-darwin).
Fixed by adding specific dependency on the crts and on the multi target.
We also add the declaration header for the Darwin10 unwinder shim to the
powerpc cases, since we build that there for Rosetta use.
* config.host: Add shim declaration header to powerpc*-darwin builds.
* config/rs6000/t-darwin-ehs: Remove dependency on the powerpc end
file.
* config/t-darwin-ehs: Add dependencies to the shared unwinder
objects.
* config/t-slibgcc-darwin: Add extra_parts to the dependencies for
the shared EH lib. Add all-multi to the dependencies for the
libgcc_s.1.dylib redirections.
Iain Sandoe [Wed, 15 Dec 2021 20:25:27 +0000 (20:25 +0000)]
Darwin, Driver: Avoid a link line for empty commands.
We were pushing a spec value for weak_reference_mismatches unconditionally
which is not needed (the value was the default) and the side-effect of
this was that we appeared to need to drive a link command; leading to
unexpected diagnostics for cases where gcc was invoked with an empty
command line.
Also we were pushing flags for sysroot, os minimum version and controls
even if the command line was empty.
* config/darwin-driver.c (darwin_driver_init): Exit from the
option handling early if the command line is definitely enpty.
* config/darwin.h (SUBTARGET_DRIVER_SELF_SPECS): Remove
setting for the default content of weak_reference_mismatches.
Iain Sandoe [Fri, 17 Dec 2021 09:29:02 +0000 (09:29 +0000)]
Darwin, ppc: Additional change for r12-5974.
This adds a missed change from r12-5974-g926d64906af.
The builin_decls array has been renamed to drop the trailing
_x that was used during the main changes to the builtins.
Recognize the __builtin_dynamic_object_size builtin and add paths in the
object size path to deal with it, but treat it like
__builtin_object_size for now. Also add tests to provide the same
testing coverage for the new builtin name.
gcc/ChangeLog:
* builtins.def (BUILT_IN_DYNAMIC_OBJECT_SIZE): New builtin.
* tree-object-size.h: Move object size type bits enum from
tree-object-size.c and add new value OST_DYNAMIC.
* builtins.c (expand_builtin, fold_builtin_2): Handle it.
(fold_builtin_object_size): Handle new builtin and adjust for
change to compute_builtin_object_size.
* tree-object-size.c: Include builtins.h.
(compute_builtin_object_size): Adjust.
(early_object_sizes_execute_one,
dynamic_object_sizes_execute_one): New functions.
(object_sizes_execute): Rename insert_min_max_p argument to
early. Handle BUILT_IN_DYNAMIC_OBJECT_SIZE and call the new
functions.
* doc/extend.texi (__builtin_dynamic_object_size): Document new
builtin.
tree-object-size: Use trees and support negative offsets
Transform tree-object-size to operate on tree objects instead of host
wide integers. This makes it easier to extend to dynamic expressions
for object sizes.
The compute_builtin_object_size interface also now returns a tree
expression instead of HOST_WIDE_INT, so callers have been adjusted to
account for that.
The trees in object_sizes are each an object_size object with members
size (the bytes from the pointer to the end of the object) and wholesize
(the size of the whole object). This allows analysis of negative
offsets, which can now be allowed to the extent of the object bounds.
Tests have been added to verify that it actually works.
gcc/ChangeLog:
* tree-object-size.h (compute_builtin_object_size): Return tree
instead of HOST_WIDE_INT.
* builtins.c (fold_builtin_object_size): Adjust.
* gimple-fold.c (gimple_fold_builtin_strncat): Likewise.
* ubsan.c (instrument_object_size): Likewise.
* tree-object-size.c (object_size): New structure.
(object_sizes): Change type to vec<object_size>.
(initval): New function.
(unknown): Use it.
(size_unknown_p, size_initval, size_unknown): New functions.
(object_sizes_unknown_p): Use it.
(object_sizes_get): Return tree.
(object_sizes_initialize): Rename from object_sizes_set_force
and set VAL parameter type as tree. Add new parameter WHOLEVAL.
(object_sizes_set): Set VAL parameter type as tree and adjust
implementation. Add new parameter WHOLEVAL.
(size_for_offset): New function.
(decl_init_size): Adjust comment.
(addr_object_size): Change PSIZE parameter to tree and adjust
implementation. Add new parameter PWHOLESIZE.
(alloc_object_size): Return tree.
(compute_builtin_object_size): Return tree in PSIZE.
(expr_object_size, call_object_size, unknown_object_size):
Adjust for object_sizes_set change.
(merge_object_sizes): Drop OFFSET parameter and adjust
implementation for tree change.
(plus_stmt_object_size): Call collect_object_sizes_for directly
instead of merge_object_size and call size_for_offset to get net
size.
(cond_expr_object_size, collect_object_sizes_for,
object_sizes_execute): Adjust for change of type from
HOST_WIDE_INT to tree.
(check_for_plus_in_loops_1): Likewise and skip non-positive
offsets.
gcc/testsuite/ChangeLog:
* gcc.dg/builtin-object-size-1.c (test9): New test.
(main): Call it.
* gcc.dg/builtin-object-size-2.c (test8): New test.
(main): Call it.
* gcc.dg/builtin-object-size-3.c (test9): New test.
(main): Call it.
* gcc.dg/builtin-object-size-4.c (test8): New test.
(main): Call it.
* gcc.dg/builtin-object-size-5.c (test5, test6, test7): New
tests.
Jason Merrill [Tue, 14 Dec 2021 22:00:40 +0000 (17:00 -0500)]
c++: layout of aggregate base with DMI [PR103681]
C++14 changed the definition of 'aggregate' to allow default member
initializers, but such classes still need to be considered "non-POD for the
purpose of layout" for ABI compatibility with C++11 code. It seems rare to
derive from such a class, as evidenced by how long this bug has
survived (since r216750 in 2014), but it's certainly worth fixing.
We only warn when we were failing to allocate another field into the
tail padding of the newly aggregate class; this is the only ABI impact.
This also changes end_of_class to consider all data members, not just empty
data members; that used to be an additional flag, removed in r9-5710, but I
don't see any reason not to always include them. This makes the result of
the function correspond to the ABI nvsize term and its nameless counterpart
that does include virtual bases.
When looking closely at other users of end_of_class, I realized that we were
assuming that the latter corresponded to the ABI dsize term, but it doesn't
if the class ends with an empty virtual base (in the rare case that the
empty base can't be assigned offset 0), and this matters for layout of
[[no_unique_address]]. So I added another mode that returns the desired
value for that case. I'm not adding a warning for this ABI fix because it's
a C++20 feature.
PR c++/103681
gcc/ChangeLog:
* common.opt (fabi-version): Add v17.
gcc/cp/ChangeLog:
* cp-tree.h (struct lang_type): Add non_pod_aggregate.
(CLASSTYPE_NON_POD_AGGREGATE): New.
* class.c (check_field_decls): Set it.
(check_bases_and_members): Check it.
(check_non_pod_aggregate): New.
(enum eoc_mode): New.
(end_of_class): Always include non-empty fields.
Add eoc_nv_or_dsize mode.
(include_empty_classes, layout_class_type): Adjust.
Marek Polacek [Wed, 15 Dec 2021 22:41:53 +0000 (17:41 -0500)]
c++: delayed noexcept in member function template [PR99980]
Some time ago I noticed that we don't properly delay parsing of
noexcept for member function templates. This patch fixes that.
It didn't work because even though we set CP_PARSER_FLAGS_DELAY_NOEXCEPT
in cp_parser_member_declaration, member template declarations take
a different path: we call cp_parser_template_declaration and return
prior to setting the flag.
PR c++/99980
gcc/cp/ChangeLog:
* parser.c (cp_parser_single_declaration): Maybe pass
CP_PARSER_FLAGS_DELAY_NOEXCEPT down to cp_parser_init_declarator.
Patrick Palka [Thu, 16 Dec 2021 18:40:42 +0000 (13:40 -0500)]
c++: two-stage name lookup for overloaded operators [PR51577]
In order to properly implement two-stage name lookup for dependent
operator expressions, we need to remember the result of unqualified
lookup of the operator at template definition time, and reuse that
result rather than performing another unqualified lookup at
instantiation time.
Ideally we could just store the lookup in the expression directly, but
as pointed out in r9-6405 this isn't really possible since we use the
standard tree codes to represent most dependent operator expressions.
We could perhaps create a new tree code to represent dependent operator
expressions, with enough operands to store the lookup along with
everything else, but that'd require a lot of careful work to make sure
we handle this new tree code properly across the frontend.
But currently type-dependent operator (and call) expressions are given
an empty TREE_TYPE, which dependent_type_p treats as dependent, so this
field is effectively unused except to signal that the expression is
type-dependent. It'd be convenient if we could store the lookup there
while preserving the dependent-ness of the expression.
To that end, this patch creates a new kind of type, called
DEPENDENT_OPERATOR_TYPE, which we give to dependent operator expressions
and into which we can store the result of operator lookup at template
definition time (DEPENDENT_OPERATOR_TYPE_SAVED_LOOKUPS). Since this
type is always dependent (by definition), and since the frontend doesn't
seem to care much about the exact type of a type-dependent expression,
using this type in place of a NULL_TREE type seems to "just work"; only
dependent_type_p and WILDCARD_TYPE_P need to be adjusted to return true
for this new type.
The rest of the patch mostly consists of adding the necessary plumbing
to pass DEPENDENT_OPERATOR_TYPE_SAVED_LOOKUPS to add_operator_candidates,
adjusting all callers of build_x_* appropriately, and removing the now
unnecessary push_operator_bindings mechanism.
In passing, this patch simplifies finish_constraint_binary_op to avoid
using build_x_binary_op for building a binary constraint-expr; we don't
need to consider operator overloads here, as the &&/|| inside a
constraint effectively always has the built-in meaning (since atomic
constraints must have bool type).
This patch also makes FOLD_EXPR_OP yield a tree_code instead of a raw
INTEGER_CST.
Finally, this patch adds the XFAILed test operator-8.C which is about
broken two-stage name lookup for rewritten non-dependent operator
expressions, an existing bug that's otherwise only documented in
build_new_op.
PR c++/51577
PR c++/83035
PR c++/100465
gcc/cp/ChangeLog:
* call.c (add_operator_candidates): Add lookups parameter.
Use it to avoid performing a second unqualified lookup when
instantiating a dependent operator expression.
(build_new_op): Add lookups parameter and pass it appropriately.
* constraint.cc (finish_constraint_binary_op): Use
build_min_nt_loc instead of build_x_binary_op.
* coroutines.cc (build_co_await): Adjust call to build_new_op.
* cp-objcp-common.c (cp_common_init_ts): Mark
DEPENDENT_OPERATOR_TYPE appropriately.
* cp-tree.def (DEPENDENT_OPERATOR_TYPE): Define.
* cp-tree.h (WILDCARD_TYPE_P): Accept DEPENDENT_OPERATOR_TYPE.
(FOLD_EXPR_OP_RAW): New, renamed from ...
(FOLD_EXPR_OP): ... this. Change this to return the tree_code directly.
(DEPENDENT_OPERATOR_TYPE_SAVED_LOOKUPS): Define.
(templated_operator_saved_lookups): Define.
(build_new_op): Add lookups parameter.
(build_dependent_operator_type): Declare.
(build_x_indirect_ref): Add lookups parameter.
(build_x_binary_op): Likewise.
(build_x_unary_op): Likewise.
(build_x_compound_expr): Likewise.
(build_x_modify_expr): Likewise.
* cxx-pretty-print.c (get_fold_operator): Adjust after
FOLD_EXPR_OP change.
* decl.c (start_preparsed_function): Don't call
push_operator_bindings.
* decl2.c (grok_array_decl): Adjust calls to build_new_op.
* method.c (do_one_comp): Likewise.
(build_comparison_op): Likewise.
* module.cc (trees_out::type_node): Handle DEPENDENT_OPERATOR_TYPE.
(trees_in::tree_node): Likewise.
* name-lookup.c (lookup_name): Revert r11-2876 change.
(op_unqualified_lookup): Remove.
(maybe_save_operator_binding): Remove.
(discard_operator_bindings): Remove.
(push_operator_bindings): Remove.
* name-lookup.h (maybe_save_operator_binding): Remove.
(push_operator_bindings): Remove.
(discard_operator_bindings): Remove.
* parser.c (cp_parser_unary_expression): Adjust calls to build_x_*.
(cp_parser_binary_expression): Likewise.
(cp_parser_assignment_expression): Likewise.
(cp_parser_expression): Likewise.
(do_range_for_auto_deduction): Likewise.
(cp_convert_range_for): Likewise.
(cp_parser_perform_range_for_lookup): Likewise.
(cp_parser_template_argument): Likewise.
(cp_parser_omp_for_cond): Likewise.
(cp_parser_omp_for_incr): Likewise.
(cp_parser_omp_for_loop_init): Likewise.
(cp_convert_omp_range_for): Likewise.
(cp_finish_omp_range_for): Likewise.
* pt.c (fold_expression): Adjust after FOLD_EXPR_OP change. Pass
templated_operator_saved_lookups to build_x_*.
(tsubst_omp_for_iterator): Adjust call to build_x_modify_expr.
(tsubst_expr) <case COMPOUND_EXPR>: Pass
templated_operator_saved_lookups to build_x_*.
(tsubst_copy_and_build) <case INDIRECT_REF>: Likewise.
<case tcc_unary>: Likewise.
<case tcc_binary>: Likewise.
<case MODOP_EXPR>: Likewise.
<case COMPOUND_EXPR>: Likewise.
(dependent_type_p_r): Return true for DEPENDENT_OPERATOR_TYPE.
* ptree.c (cxx_print_type): Handle DEPENDENT_OPERATOR_TYPE.
* semantics.c (finish_increment_expr): Adjust call to
build_x_unary_op.
(finish_unary_op_expr): Likewise.
(handle_omp_for_class_iterator): Adjust calls to build_x_*.
(finish_omp_cancel): Likewise.
(finish_unary_fold_expr): Use build_dependent_operator_type.
(finish_binary_fold_expr): Likewise.
* tree.c (cp_free_lang_data): Don't call discard_operator_bindings.
* typeck.c (rationalize_conditional_expr): Adjust call to
build_x_binary_op.
(op_unqualified_lookup): Define.
(build_dependent_operator_type): Define.
(build_x_indirect_ref): Add lookups parameter and use
build_dependent_operator_type.
(build_x_binary_op): Likewise.
(build_x_array_ref): Likewise.
(build_x_unary_op): Likewise.
(build_x_compound_expr_from_list): Adjust call to
build_x_compound_expr.
(build_x_compound_expr_from_vec): Likewise.
(build_x_compound_expr): Add lookups parameter and use
build_dependent_operator_type.
(cp_build_modify_expr): Adjust call to build_new_op.
(build_x_modify_expr): Add lookups parameter and use
build_dependent_operator_type.
* typeck2.c (build_x_arrow): Adjust call to build_new_op.
libcc1/ChangeLog:
* libcp1plugin.cc (plugin_build_unary_expr): Adjust call to
build_x_unary_op.
(plugin_build_binary_expr): Adjust call to build_x_binary_op.
gcc/testsuite/ChangeLog:
* g++.dg/lookup/operator-3.C: Split out operator overload
declarations into ...
* g++.dg/lookup/operator-3-ops.h: ... here.
* g++.dg/lookup/operator-3a.C: New test.
* g++.dg/lookup/operator-4.C: New test.
* g++.dg/lookup/operator-4a.C: New test.
* g++.dg/lookup/operator-5.C: New test.
* g++.dg/lookup/operator-5a.C: New test.
* g++.dg/lookup/operator-6.C: New test.
* g++.dg/lookup/operator-7.C: New test.
* g++.dg/lookup/operator-8.C: New test.
Martin Liska [Thu, 16 Dec 2021 12:33:00 +0000 (13:33 +0100)]
opts: do not do sanity check when an error is seen
PR target/103709
gcc/c-family/ChangeLog:
* c-pragma.c (handle_pragma_pop_options): Do not check
global options modification when an error is seen in parsing
of options (pragmas or attributes).
Martin Liska [Wed, 15 Dec 2021 16:27:56 +0000 (17:27 +0100)]
pragma: respect pragma in lambda functions
In g:01ad8c54fdca we started supporting target pragma changes
that are primarily caused by optimization option. The same can happen
in the opposite way and we need to check for changes both
in optimization_current_node and target_option_current_node.
PR c++/103696
gcc/ChangeLog:
* attribs.c (decl_attributes): Check if
target_option_current_node is changed.
Bill Schmidt [Thu, 16 Dec 2021 13:47:58 +0000 (07:47 -0600)]
rs6000: Refactor altivec_build_resolved_builtin
While replacing the built-in machinery, we agreed to defer some necessary
refactoring of the overload processing. This patch cleans it up considerably.
I've put in one FIXME for an additional level of cleanup that should be done
independently. The various helper functions (resolve_VEC_*) can be simplified
if we move the argument processing in altivec_resolve_overloaded_builtin
earlier. But this requires making nontrivial changes to those functions that
will need careful review. Let's do that in a later patch.
2021-12-16 Bill Schmidt <wschmidt@linux.ibm.com>
gcc/
* config/rs6000/rs6000-c.c (resolution): New enum.
(resolve_vec_mul): New function.
(resolve_vec_cmpne): Likewise.
(resolve_vec_adde_sube): Likewise.
(resolve_vec_addec_subec): Likewise.
(resolve_vec_splats): Likewise.
(resolve_vec_extract): Likewise.
(resolve_vec_insert): Likewise.
(resolve_vec_step): Likewise.
(find_instance): Likewise.
(altivec_resolve_overloaded_builtin): Many cleanups. Call factored-out
functions. Move variable declarations closer to uses. Add commentary.
Remove unnecessary levels of braces. Avoid use of gotos. Change
misleading variable names. Use switches over if-else-if chains.
Marek Polacek [Fri, 10 Dec 2021 20:38:35 +0000 (15:38 -0500)]
c++: Allow constexpr decltype(auto) [PR102229]
My r11-2202 was trying to enforce [dcl.type.auto.deduct]/4, which says
"If the placeholder-type-specifier is of the form type-constraint[opt]
decltype(auto), T shall be the placeholder alone." But this made us
reject 'constexpr decltype(auto)', which, after clarification from CWG,
should be valid. [dcl.type.auto.deduct]/4 is supposed to be a syntactic
constraint, not semantic, so it's OK that the constexpr marks the object
as const.
As a consequence, checking TYPE_QUALS in do_auto_deduction is too late,
and we have a FIXME there anyway. So in this patch I'm attempting to
detect 'const decltype(auto)' earlier. If I'm going to use TYPE_QUALS,
it needs to happen before we mark the object as const due to constexpr,
that is, before grokdeclarator's
/* A `constexpr' specifier used in an object declaration declares
the object as `const'. */
if (constexpr_p && innermost_code != cdk_function)
...
Constrained decltype(auto) was a little problem, hence the TYPENAME
check. But in a typename context you can't use decltype(auto) anyway,
I think.
Thomas Schwinge [Fri, 10 Dec 2021 18:08:26 +0000 (19:08 +0100)]
testsuite: Be more informative for ICEs
For example, for the two (FAIL, XFAIL)
'gcc/testsuite/lib/gcc-dg.exp:gcc-dg-test-1' cases:
-FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++17 (internal compiler error)
+FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++17 (internal compiler error: tree check: expected var_decl or function_decl or field_decl or type_decl or concept_decl or template_decl, have namespace_decl in get_merge_kind, at cp/module.cc:10072)
H.J. Lu [Sat, 13 Nov 2021 14:11:41 +0000 (06:11 -0800)]
Sync with binutils: Support the PGO build for binutils+gdb
Sync with binutils for building binutils with LTO:
1dbde357be3 Add missing changes to Makefile.tpl af019bfde9b Support the PGO build for binutils+gdb
Add the --enable-pgo-build[=lto] configure option. When binutils+gdb
is not built together with GCC, --enable-pgo-build enables the PGO build:
1. First build with -fprofile-generate.
2. Use "make maybe-check-*" to generate profiling data and pass -i to make
to ignore errors when generating profiling data.
3. Use "make clean" to remove the previous build.
4. Rebuild with -fprofile-use.
With --enable-pgo-build=lto, -flto=jobserver -ffat-lto-objects are used
together with -fprofile-generate and -fprofile-use. Add '+' to the command
line for recursive make to support -flto=jobserver -ffat-lto-objects.
NB: --enable-pgo-build=lto enables the PGO build with LTO while
--enable-lto enables LTO support in toolchain.
BZ binutils/26766
* Makefile.tpl (BUILD_CFLAGS): New.
(CFLAGS): Append $(BUILD_CFLAGS).
(CXXFLAGS): Likewise.
(PGO_BUILD_GEN_FLAGS_TO_PASS): New.
(PGO_BUILD_TRAINING_CFLAGS): Likewise.
(PGO_BUILD_TRAINING_CXXFLAGS): Likewise.
(PGO_BUILD_TRAINING_FLAGS_TO_PASS): Likewise.
(PGO_BUILD_TRAINING_MFLAGS): Likewise.
(PGO_BUILD_USE_FLAGS_TO_PASS): Likewise.
(PGO-TRAINING-TARGETS): Likewise.
(PGO_BUILD_TRAINING): Likewise.
(all): Add '+' to the command line for recursive make. Support
the PGO build.
* configure.ac: Add --enable-pgo-build[=lto].
AC_SUBST PGO_BUILD_GEN_CFLAGS, PGO_BUILD_USE_CFLAGS and
PGO_BUILD_LTO_CFLAGS. Enable the PGO build in Makefile.
* Makefile.in: Regenerated.
* configure: Likewise.
François Dumont [Wed, 6 Oct 2021 04:55:19 +0000 (06:55 +0200)]
libstdc++: Overload std::__to_address for __gnu_cxx::__normal_iterator.
Prefer to overload __to_address to partially specialize std::pointer_traits because
std::pointer_traits would be mostly useless. Moreover partial specialization of
pointer_traits<__normal_iterator<P, C>> fails to rebind C, so you get incorrect types
like __normal_iterator<long*, vector<int>>. In the case of __gnu_debug::_Safe_iterator
the to_pointer method is impossible to implement correctly because we are missing
the parent container to associate the iterator to.
libstdc++-v3/ChangeLog:
* include/bits/stl_iterator.h
(std::pointer_traits<__gnu_cxx::__normal_iterator<>>): Remove.
(std::__to_address(const __gnu_cxx::__normal_iterator<>&)): New for C++11 to C++17.
* include/debug/safe_iterator.h
(std::__to_address(const __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<>,
_Sequence>&)): New for C++11 to C++17.
* testsuite/24_iterators/normal_iterator/to_address.cc: Add check on std::vector::iterator
to validate both __gnu_cxx::__normal_iterator<> __to_address overload in normal mode and
__gnu_debug::_Safe_iterator in _GLIBCXX_DEBUG mode.
Roger Sayle [Sun, 12 Dec 2021 17:03:03 +0000 (18:03 +0100)]
nvptx: Add -misa=sm_75 and -misa=sm_80
Add new target macros TARGET_SM75 and TARGET_SM80. Add support for
__builtin_tanhf, HFmode exp2/tanh and also for HFmode min/max, controlled by
TARGET_SM75 and TARGET_SM80 respectively.
The following has been tested on nvptx-none, hosted on x86_64-pc-linux-gnu
with a "make" and "make -k check" with no new failures.
gcc/ChangeLog:
* config/nvptx/nvptx-opts.h (ptx_isa): PTX_ISA_SM75 and PTX_ISA_SM80
ISA levels.
* config/nvptx/nvptx.opt: Add sm_75 and sm_80 to -misa.
* config/nvptx/nvptx.h (TARGET_SM75, TARGET_SM80):
New helper macros to conditionalize functionality on target ISA.
* config/nvptx/nvptx-c.c (nvptx_cpu_cpp_builtins): Add __PTX_SM__
support for the new ISA levels.
* config/nvptx/nvptx.c (nvptx_file_start): Add support for TARGET_SM75
and TARGET_SM80.
* config/nvptx/nvptx.md (define_c_enum "unspec"): New UNSPEC_TANH.
(define_mode_iterator HSFM): New iterator for HFmode and SFmode.
(exp2hf2): New define_insn controlled by TARGET_SM75.
(tanh<mode>2): New define_insn controlled by TARGET_SM75.
(sminhf3, smaxhf3): New define_isnns controlled by TARGET_SM80.
gcc/testsuite/ChangeLog:
* gcc.target/nvptx/float16-2.c: New test case.
* gcc.target/nvptx/tanh-1.c: New test case.
aarch64: Don't classify vector pairs as short vectors [PR103094]
In this PR we were wrongly classifying a pair of 8-byte vectors
as a 16-byte “short vector” (in the AAPCS64 sense). As the
comment in the patch says, this stems from an old condition
in aarch64_short_vector_p that is too loose, but that would
be difficult to tighten now.
We can still do the right thing for the newly-added modes though,
since there are no backwards compatibility concerns there.
Co-authored-by: Tamar Christina <tamar.christina@arm.com>
gcc/
PR target/103094
* config/aarch64/aarch64.c (aarch64_short_vector_p): Return false
for structure modes, rather than ignoring the type in that case.
gcc/testsuite/
PR target/103094
* gcc.target/aarch64/pr103094.c: New test.
purely due to the ordering of instructions. REE doesn't check uses of `v8`
because it assumes that with a zero extended value, you still have access to the
lower bits by using the the bottom part of the register.
This is true for scalar but not for vector. This would have been fine as well
if REE had eliminated the zero_extend on insn 11 and the rest but it doesn't do
so since REE can only handle cases where the SRC value are REG_P.
It does try to do this in add_removable_extension:
1160 /* For vector mode extensions, ensure that all uses of the
1161 XEXP (src, 0) register are in insn or debug insns, as unlike
1162 integral extensions lowpart subreg of the sign/zero extended
1163 register are not equal to the original register, so we have
1164 to change all uses or none and the current code isn't able
1165 to change them all at once in one transaction. */
However this code doesn't trigger for the example because REE doesn't check the
uses if the defining instruction doesn't feed into another extension..
Which is bogus. For vectors it should always check all usages.