]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
12 months agolibstdc++: Implement P2968R2 "Making std::ignore a first-class object"
Jonathan Wakely [Thu, 25 Jul 2024 12:00:09 +0000 (13:00 +0100)] 
libstdc++: Implement P2968R2 "Making std::ignore a first-class object"

This was recently approved for C++26, but we can apply the changes for
all modes back to C++11. There's no reason not to make the assignment
usable in constant expressions for C++11 mode, and noexcept for all
modes.

Move the definitions to <bits/utility.h> so they're available in
<utility> as well as <tuple>.

libstdc++-v3/ChangeLog:

* include/bits/utility.h (_Swallow_assign): Make assignment
constexpr for C++11 as well, and add noexcept.
* include/std/tuple (_Swallow_assign, ignore): Move to
bits/utility.h.
* testsuite/20_util/headers/utility/ignore.cc: New test.

12 months agolibstdc++: Reorder template params of std::optional comparisons (LWG 2945)
Jonathan Wakely [Tue, 23 Jul 2024 16:14:03 +0000 (17:14 +0100)] 
libstdc++: Reorder template params of std::optional comparisons (LWG 2945)

libstdc++-v3/ChangeLog:

* include/std/optional: Reorder parameters in comparison
operators as per LWG 2945.

12 months agoc++: Implement C++26 P2558R2 - Add @, $, and ` to the basic character set [PR110343]
Jakub Jelinek [Thu, 25 Jul 2024 19:36:31 +0000 (21:36 +0200)] 
c++: Implement C++26 P2558R2 - Add @, $, and ` to the basic character set [PR110343]

The following patch implements the easy parts of the paper.
When @$` are added to the basic character set, it means that
R"@$`()@$`" should now be valid (here I've noticed most of the
raw string tests were tested solely with -std=c++11 or -std=gnu++11
and I've tried to change that), and on the other side even if
by extension $ is allowed in identifiers, \u0024 or \U00000024
or \u{24} should not be, similarly how \u0041 is not allowed.

The paper in 3.1 claims though that
 #include <stdio.h>

 #define STR(x) #x

int main()
{
  printf("%s", STR(\u0060)); // U+0060 is ` GRAVE ACCENT
}
should have been accepted before this paper (and rejected after it),
but g++ rejects it.

I've tried to understand it, but am confused on what is the right
behavior and why.

Consider
 #define STR(x) #x
const char *a = "\u00b7";
const char *b = STR(\u00b7);
const char *c = "\u0041";
const char *d = STR(\u0041);
const char *e = STR(a\u00b7);
const char *f = STR(a\u0041);
const char *g = STR(a \u00b7);
const char *h = STR(a \u0041);
const char *i = "\u066d";
const char *j = STR(\u066d);
const char *k = "\u0040";
const char *l = STR(\u0040);
const char *m = STR(a\u066d);
const char *n = STR(a\u0040);
const char *o = STR(a \u066d);
const char *p = STR(a \u0040);

Neither clang nor gcc emit any diagnostics on the a, c, i and k
initializers, those are certainly valid (c is invalid in C23 though).  g++
emits with -pedantic-errors errors on all the others, while clang++ on the
ones with STR involving \u0041, \u0040 and a\u0066d.  The chosen values are
\u0040 '@' as something being changed by this paper, \u0041 'A' as basic
character set char valid in identifiers before/after, \u00b7 as an example
of character which is pedantically valid in identifiers if not at the start
and \u066d s something pedantically not valid in identifiers.

Now, https://eel.is/c++draft/lex.charset#6 says that UCN used outside of a
string/character literal which corresponds to basic character set character
(or control character) is ill-formed, that would make d, f, h cases invalid
for C++ and l, n, p cases invalid for C++26.

https://eel.is/c++draft/lex.name states which characters can appear at the
start of the identifier and which can appear after the start.  And
https://eel.is/c++draft/lex.pptoken states that preprocessing-token is
either identifier, or tons of other things, or "each non-whitespace
character that cannot be one of the above"

Then https://eel.is/c++draft/lex.pptoken#1 says that this last category is
invalid if the preprocessing token is being converted into token.

And https://eel.is/c++draft/lex.pptoken#2 includes "If any character not in
the basic character set matches the last category, the program is
ill-formed."

Now, e.g.  for the C++23 STR(\u0040) case, \u0040 is there not in the basic
character set, so valid outside of the literals (not the case anymore in
C++26), but it isn't nondigit and doesn't have XID_Start property, so it
isn't IMHO an identifier and so must be the "each non-whitespace character
that cannot be one of the above" case.  Why doesn't the above mentioned
https://eel.is/c++draft/lex.pptoken#2 sentence make that invalid?  Ignoring
that, I'd say it would be then stringized and that feels like it is what
clang++ is doing.  Now, e.g.  for the STR(a\u066d) case, I wonder why that
isn't lexed as a identifier followed by \u066d "each non-whitespace
character that cannot be one of the above" token and stringified similarly,
clang++ rejects that.

What GCC libcpp seems to be doing is that if that forms_identifier_p calls
_cpp_valid_utf8 or _cpp_valid_ucn with an argument which tells it is first
or second+ in identifier, and e.g.  _cpp_valid_ucn then for UCNs valid in
string literals calls
  else if (identifier_pos)
    {
      int validity = ucn_valid_in_identifier (pfile, result, nst);

      if (validity == 0)
        cpp_error (pfile, CPP_DL_ERROR,
                   "universal character %.*s is not valid in an identifier",
                   (int) (str - base), base);
      else if (validity == 2 && identifier_pos == 1)
        cpp_error (pfile, CPP_DL_ERROR,
   "universal character %.*s is not valid at the start of an identifier",
                   (int) (str - base), base);
    }
so basically all those invalid in identifiers cases emit an error and
pretend to be valid in identifiers, rather than what e.g.  _cpp_valid_utf8
does for C but not for C++ and only for the chars completely invalid in
identifiers rather than just valid in identifiers but not at the start:
          /* In C++, this is an error for invalid character in an identifier
             because logically, the UTF-8 was converted to a UCN during
             translation phase 1 (even though we don't physically do it that
             way).  In C, this byte rather becomes grammatically a separate
             token.  */

          if (CPP_OPTION (pfile, cplusplus))
            cpp_error (pfile, CPP_DL_ERROR,
                       "extended character %.*s is not valid in an identifier",
                       (int) (*pstr - base), base);
          else
            {
              *pstr = base;
              return false;
            }
The comment doesn't really match what is done in recent C++ versions because
there UCNs are translated to characters and not the other way around.

2024-07-25  Jakub Jelinek  <jakub@redhat.com>

PR c++/110343
libcpp/
* lex.cc: C++26 P2558R2 - Add @, $, and ` to the basic character set.
(lex_raw_string): For C++26 allow $@` characters in prefix.
* charset.cc (_cpp_valid_ucn): For C++26 reject \u0024 in identifiers.
gcc/testsuite/
* c-c++-common/raw-string-1.c: Use { c || c++11 } effective target,
remove c++ specific dg-options.
* c-c++-common/raw-string-2.c: Likewise.
* c-c++-common/raw-string-4.c: Likewise.
* c-c++-common/raw-string-5.c: Likewise.  Expect some diagnostics
only for non-c++26, for c++26 expect different.
* c-c++-common/raw-string-6.c: Use { c || c++11 } effective target,
remove c++ specific dg-options.
* c-c++-common/raw-string-11.c: Likewise.
* c-c++-common/raw-string-13.c: Likewise.
* c-c++-common/raw-string-14.c: Likewise.
* c-c++-common/raw-string-15.c: Use { c || c++11 } effective target,
change c++ specific dg-options to just -Wtrigraphs.
* c-c++-common/raw-string-16.c: Likewise.
* c-c++-common/raw-string-17.c: Use { c || c++11 } effective target,
remove c++ specific dg-options.
* c-c++-common/raw-string-18.c: Use { c || c++11 } effective target,
remove -std=c++11 from c++ specific dg-options.
* c-c++-common/raw-string-19.c: Likewise.
* g++.dg/cpp26/raw-string1.C: New test.
* g++.dg/cpp26/raw-string2.C: New test.

12 months ago[PR rtl-optimization/116039] Fix life computation for promoted subregs
Jeff Law [Thu, 25 Jul 2024 18:32:28 +0000 (12:32 -0600)] 
[PR rtl-optimization/116039] Fix life computation for promoted subregs

So this turned out to be a neat little test and while the fuzzer found it on
RISC-V, I wouldn't be surprised if the underlying issue is also the root cause
of the loongarch issue with ext-dce.

The key issue is that if we have something like

(set (dest) (any_extend (subreg (source))))

If the subreg object is marked with SUBREG_PROMOTED and the sign/unsigned state
matches the any_extend opcode, then combine (and I guess anything using
simplify-rtx) may simplify that to

(set (dest) (source))

That implies that bits outside the mode of the subreg are actually live and
valid.  This needs to be accounted for during liveness computation.

We have to be careful here though. If we're too conservative about setting
additional bits live, then we'll inhibit the desired optimization in the
coremark examples.  To do a good job we need to know the extension opcode.

I'm extremely unhappy with how the use handling works in ext-dce.  It mixes
different conceptual steps and has horribly complex control flow.  It only
handles a subset of the unary/binary opcodes, etc etc.  It's just damn mess.
It's going to need some more noodling around.

In the mean time this is a bit hacky in that it depends on non-obvious behavior
to know it can get the extension opcode, but I don't want to leave the trunk in
a broken state while I figure out the refactoring problem.

Bootstrapped and regression tested on x86 and tested on the crosses.  Pushing to the trunk.

PR rtl-optimization/116039
gcc/
* ext-dce.cc (ext_dce_process_uses): Add some comments about concerns
with current code.  Mark additional bit groups as live when we have
an extension of a suitably promoted subreg.

gcc/testsuite
* gcc.dg/torture/pr116039.c: New test.

12 months agoFortran: Suppress wrong End Of File error with user defined IO.
Jerry DeLisle [Wed, 24 Jul 2024 17:29:08 +0000 (10:29 -0700)] 
Fortran: Suppress wrong End Of File error with user defined IO.

PR libfortran/105361

libgfortran/ChangeLog:

* io/list_read.c (finish_list_read): Add a condition check for
a user defined derived type IO operation to avoid calling the
EOF error.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr105361.f90: New test.

12 months agoRISC-V: xtheadmemidx: Fix mode test for pre/post-modify addressing
Christoph Müllner [Wed, 24 Jul 2024 12:10:01 +0000 (14:10 +0200)] 
RISC-V: xtheadmemidx: Fix mode test for pre/post-modify addressing

auto_inc_dec (-O3) performs optimizations like the following
if RVV and XTheadMemIdx is enabled.

(insn 23 20 27 3 (set (mem:V4QI (reg:DI 136 [ ivtmp.13 ]) [0 MEM <vector(4) char> [(char *)_39]+0 S4 A32])
        (reg:V4QI 168)) "gcc/testsuite/gcc.target/riscv/pr116033.c":12:27 3183 {*movv4qi}
     (nil))
(insn 40 39 41 3 (set (reg:DI 136 [ ivtmp.13 ])
        (plus:DI (reg:DI 136 [ ivtmp.13 ])
            (const_int 20 [0x14]))) 5 {adddi3}
     (nil))
====>
(insn 23 20 27 3 (set (mem:V4QI (post_modify:DI (reg:DI 136 [ ivtmp.13 ])
                (plus:DI (reg:DI 136 [ ivtmp.13 ])
                    (const_int 20 [0x14]))) [0 MEM <vector(4) char> [(char *)_39]+0 S4 A32])
        (reg:V4QI 168)) "gcc/testsuite/gcc.target/riscv/pr116033.c":12:27 3183 {*movv4qi}
     (expr_list:REG_INC (reg:DI 136 [ ivtmp.13 ])
        (nil)))

The reason why the pass believes that this is legal is,
that the mode test in th_memidx_classify_address_modify()
requires INTEGRAL_MODE_P (mode), which includes vector modes.

Let's restrict the mode test such, that only MODE_INT is allowed.

PR target/116033

gcc/ChangeLog:

* config/riscv/thead.cc (th_memidx_classify_address_modify):
Fix mode test.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr116033.c: New test.

Reported-by: Patrick O'Neill <patrick@rivosinc.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
12 months agocp+coroutines: teach convert_to_void to diagnose discarded co_awaits
Arsen Arsenović [Mon, 22 Jul 2024 13:49:20 +0000 (15:49 +0200)] 
cp+coroutines: teach convert_to_void to diagnose discarded co_awaits

co_await expressions are nearly calls to Awaitable::await_resume, and,
as such, should inherit its nodiscard.  A discarded co_await expression
should, hence, act as if its call to await_resume was discarded.

This patch teaches convert_to_void how to discard 'through' a
CO_AWAIT_EXPR. When we discard a CO_AWAIT_EXPR, we can also just discard
the await_resume() call conveniently embedded within it.  This results
in a [[nodiscard]] diagnostic that the PR noted was missing.

gcc/cp/ChangeLog:

PR c++/110171
* coroutines.cc (co_await_get_resume_call): New function.
Returns the await_resume expression of a given co_await.
* cp-tree.h (co_await_get_resume_call): New function.
* cvt.cc (convert_to_void): Handle CO_AWAIT_EXPRs and call
maybe_warn_nodiscard on their resume exprs.

gcc/testsuite/ChangeLog:

PR c++/110171
* g++.dg/coroutines/pr110171-1.C: New test.
* g++.dg/coroutines/pr110171.C: New test.

12 months agocp/coroutines: do not rewrite parameters in unevaluated contexts
Arsen Arsenović [Thu, 18 Jul 2024 16:16:49 +0000 (18:16 +0200)] 
cp/coroutines: do not rewrite parameters in unevaluated contexts

It is possible to use parameters of a parent function of a lambda in
unevaluated contexts without capturing them.  By not capturing them, we
work around the usual mechanism we use to prevent rewriting captured
parameters.  Prevent this by simply skipping rewrites in unevaluated
contexts.  Those won't mind the value not being present anyway.

This prevents an ICE during parameter substitution.  In the testcase
from the PR, the rewriting machinery finds a param in the body of the
coroutine, which it did not previously encounter while processing the
coroutine declaration, and that does not have a DECL_VALUE_EXPR, and
fails.

gcc/cp/ChangeLog:

PR c++/111728
* coroutines.cc (rewrite_param_uses): Skip unevaluated
subexpressions.

gcc/testsuite/ChangeLog:

PR c++/111728
* g++.dg/coroutines/pr111728.C: New test.

12 months ago[committed] Trivial testcase adjustment
Jeff Law [Thu, 25 Jul 2024 14:42:04 +0000 (08:42 -0600)] 
[committed] Trivial testcase adjustment

I made pr116037.c dependent on int32 just based on the constants used without
noting the int128 vector type.  Naturally on targets that don't support int128
the test fails.  Fixed by changing the target selector from int32 to int128.

Pushed to the trunk.

gcc/testsuite
* gcc.dg/torture/pr116037.c: Fix target selector.

12 months agotree-optimization/116083 - improve behavior when SLP discovery limit is reached
Richard Biener [Thu, 25 Jul 2024 11:39:49 +0000 (13:39 +0200)] 
tree-optimization/116083 - improve behavior when SLP discovery limit is reached

The following avoids some useless work when the SLP discovery limit
is reached, for example allocating a node to cache the failure
and starting discovery on split store groups when analyzing BBs.

It does not address the issue in the PR which is a gratious budget
for discovery when the store group size approaches the number of
overall statements.

PR tree-optimization/116083
* tree-vect-slp.cc (vect_build_slp_tree): Do not allocate
a discovery fail node when we reached the discovery limit.
(vect_build_slp_instance): Terminate early when the
discovery limit is reached.

12 months agolibstdc++: fix uses of explicit object parameter [PR116038]
Patrick Palka [Thu, 25 Jul 2024 13:02:13 +0000 (09:02 -0400)] 
libstdc++: fix uses of explicit object parameter [PR116038]

The type of an implicit object parameter is always the current class.
For an explicit object parameter however, its deduced type can be a
derived class of the current class.  So when combining multiple
implicit-object overloads into a single explicit-object overload we need
to account for this possibility.  For example when accessing a member of
the current class through an explicit object parameter, it may now be a
derived class from which the member is not accessible, as in the below
testcases.

This pitfall is discussed[1] in the deducing this paper.  The general
solution is to cast the explicit object parameter to (a reference to)
the current class rather than e.g. using std::forward which preserves
the deduced type.

This patch corrects the existing problematic uses of explicit object
parameters in the library, all of which forward the parameter via
std::forward, to instead cast the parameter to the current class via
our __like_t alias template.  Note that unlike the paper's like_t,
ours always returns a reference so we can just write

  __like_t<Self, B>(self)

instead of

  (_like_t<Self, B>&&)self

as the paper does.

[1]: https://wg21.link/P0847#name-lookup-within-member-functions (and the
section after that)

PR libstdc++/116038

libstdc++-v3/ChangeLog:

* include/std/functional (_Bind_front::operator()): Use __like_t
instead of std::forward when forwarding __self.
(_Bind_back::operator()): Likewise.
* include/std/ranges (_Partial::operator()): Likewise.
(_Pipe::operator()): Likewise.
* testsuite/20_util/function_objects/bind_back/116038.cc: New test.
* testsuite/20_util/function_objects/bind_front/116038.cc: New test.
* testsuite/std/ranges/adaptors/116038.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
12 months agortl-ssa: Define INCLUDE_ARRAY
Richard Sandiford [Thu, 25 Jul 2024 12:25:32 +0000 (13:25 +0100)] 
rtl-ssa: Define INCLUDE_ARRAY

g:72fbd3b2b2a497dbbe6599239bd61c5624203ed0 added a use of std::array
without explicitly forcing <array> to be included.  That didn't cause
problems in my local builds but understandably did for some people.

gcc/
* doc/rtl.texi: Document the need to define INCLUDE_ARRAY before
including rtl-ssa.h.
* rtl-ssa.h: Likewise (in comment).
* config/aarch64/aarch64-cc-fusion.cc: Add INCLUDE_ARRAY.
* config/aarch64/aarch64-early-ra.cc: Likewise.
* config/riscv/riscv-avlprop.cc: Likewise.
* config/riscv/riscv-vsetvl.cc: Likewise.
* fwprop.cc: Likewise.
* late-combine.cc: Likewise.
* pair-fusion.cc: Likewise.
* rtl-ssa/accesses.cc: Likewise.
* rtl-ssa/blocks.cc: Likewise.
* rtl-ssa/changes.cc: Likewise.
* rtl-ssa/functions.cc: Likewise.
* rtl-ssa/insns.cc: Likewise.
* rtl-ssa/movement.cc: Likewise.

12 months agodoc: Document -O1 as the preferred level for large machine-generated code
Sam James [Tue, 23 Jul 2024 14:06:10 +0000 (15:06 +0100)] 
doc: Document -O1 as the preferred level for large machine-generated code

At -O1, the intention is that we compile things in a "reasonable" amount
of time (ditto memory use). In particular, we try to especially avoid
optimizations which scale poorly on pathological cases, as is the case
for large machine-generated code.

Recommend -O1 for large machine-generated code, as has been informally
done on bugs for a while now.

This applies (broadly speaking) for both large machine-generated functions
but also to a lesser extent repetitive small-but-still-not-tiny functions
from a generator program.

gcc/ChangeLog:
PR middle-end/114855
* doc/invoke.texi (Optimize options): Mention machine-generated
code for -O1.

12 months agotree-optimization/116081 - typedef vs. non-typedef in vectorization
Richard Biener [Thu, 25 Jul 2024 10:46:30 +0000 (12:46 +0200)] 
tree-optimization/116081 - typedef vs. non-typedef in vectorization

The following fixes the code generation difference when using
a typedef for the scalar type.  The issue is using a pointer
equality test for an INTEGER_CST which fails when the types
are different variants.

PR tree-optimization/116081
* tree-vect-loop.cc (get_initial_defs_for_reduction):
Use operand_equal_p for comparing the element with the
neutral op.

12 months agolibstdc++: Add noexcept to bad_expected_access<void> members (LWG 4031)
Jonathan Wakely [Wed, 26 Jun 2024 13:15:29 +0000 (14:15 +0100)] 
libstdc++: Add noexcept to bad_expected_access<void> members (LWG 4031)

libstdc++-v3/ChangeLog:

* include/std/expected (bad_expected_access<void>): Add noexcept
to special member functions, as per LWG 4031.
* testsuite/20_util/expected/bad.cc: Check for nothrow copy and
move members.

12 months agolibstdc++: Use concepts and conditional explicit in std::optional
Jonathan Wakely [Tue, 23 Jul 2024 11:45:37 +0000 (12:45 +0100)] 
libstdc++: Use concepts and conditional explicit in std::optional

For C++20 mode we can improve compile times by using conditional
explicit to reduce the number of constructor overloads. We can also use
requires-clauses instead of SFINAE to implement constraints on the
constructors and assignment operators.

libstdc++-v3/ChangeLog:

* include/std/optional (optional): Use C++20 features to
simplify overload sets for constructors and assignment
operators.

12 months agolibstdc++: Implement LWG 3836 for std::optional bool conversions
Jonathan Wakely [Tue, 23 Jul 2024 11:45:37 +0000 (12:45 +0100)] 
libstdc++: Implement LWG 3836 for std::optional bool conversions

libstdc++-v3/ChangeLog:

* include/std/optional (optional): Constrain constructors to
prevent problematic bool conversions, as per LWG 3836.
* testsuite/20_util/optional/cons/lwg3836.cc: New test.

12 months agolibstdc++: Implement LWG 3836 for std::expected bool conversions
Jonathan Wakely [Wed, 24 Jul 2024 17:08:03 +0000 (18:08 +0100)] 
libstdc++: Implement LWG 3836 for std::expected bool conversions

libstdc++-v3/ChangeLog:

* include/std/expected (expected): Constrain constructors to
prevent problematic bool conversions, as per LWG 3836.
* testsuite/20_util/expected/lwg3836.cc: New test.

12 months agolibstdc++: Use concepts to simplify std::optional base classes
Jonathan Wakely [Mon, 22 Jul 2024 19:40:17 +0000 (20:40 +0100)] 
libstdc++: Use concepts to simplify std::optional base classes

In C++20 mode we can simplify some of the std::optional base class
hierarchy using concepts. We can overload the destructor and copy
constructor and move constructor with a trivial defaulted version and a
constrained non-trivial version. This allows us to remove some class
template partial specializations that were used to conditionally define
those special members as trivial or non-trivial. This should not change
any semantics, but should be less work for the compiler, due to not
needing to match partial specializations, and completely removing one
level of the inheritance hierarchy.

libstdc++-v3/ChangeLog:

* include/std/optional (_Optional_payload_base::_Storage)
[C++20]: Define constrained non-trivial destructor.
(_Optional_payload_base::_Storage<U, false>) [C++20]: Do not
define partial specialization when primary template has
constrained destructor.
(_Optional_base) [C++20]: Define constrained trivial copy and
move cons and move constructors. Define payload accessors here
instead of inheriting them from _Optional_base_impl.
(_Optional_base_impl, _Optional_base<T, false, true>)
(_Optional_base<T, true, false>, _Optional_base<T, true, true>)
[C++20]: Do not define.

12 months agolibstdc++: Use _M_get() in std::optional internals
Jonathan Wakely [Tue, 23 Jul 2024 10:46:05 +0000 (11:46 +0100)] 
libstdc++: Use _M_get() in std::optional internals

Now that _base::_M_get() doesn't check the precondition, we can use
_M_get() instead of operator*() for the internal uses where we've
already checked the precondition holds.

Add a using-declaration so that we don't need to lookup _M_get in the
dependent base class, and make optional<U> a friend so that the
converting constructors and assignment operators can use the parameter's
_M_get member.

libstdc++-v3/ChangeLog:

* include/std/optional (optional): Add using-declaraction for
_Base::_M_get and declare optional<U> as friend.
(optional(const optional<U>&)): Use
_M_get instead of operator*.
(optional(optional<U>&&)): Likewise.
(operator=(const optional<U>&)): Likewise.
(operator=(optional<U>&&)): Likewise.
(and_then, tansform): Likewise.

12 months agolibstdc++: Move std::optional assertions out of _M_get()
Jonathan Wakely [Mon, 22 Jul 2024 19:24:19 +0000 (20:24 +0100)] 
libstdc++: Move std::optional assertions out of _M_get()

Currently we implement the precondition for accessing the contained
value of a std::optional in the _M_get() accessor in the base class.
This means that we always check the assertions even in internal
functions that have an explicit check for a contained value being
present, such as value() and value_or(U&&). Although those redundant
assertions should get optimized out in most cases, they might hurt
inliner heuristics and generally give the compiler more work to do.
And they won't be optimized out at all for non-optimized builds.

The current assertions also result in repeated invalid bug reports, such
as PR 91281, PR 101659, PR 102712, and PR 107894.

We can move the assertions from the internal accessors to the public
member functions where the preconditions are specified.

Reviewed-by: Ville Voutilainen <ville.voutilainen@gmail.com>
libstdc++-v3/ChangeLog:

* include/std/optional (_Optional_base_impl::_M_get()): Move
assertions to ...
(optional::operator->, optional::operator*): ... here.

12 months agotree-optimization/116079 - store motion and clobbers
Richard Biener [Thu, 25 Jul 2024 06:58:42 +0000 (08:58 +0200)] 
tree-optimization/116079 - store motion and clobbers

When we move a store out of an inner loop and remove a clobber in
the process, analysis of the inner loop can run into the clobber
via the meta-data and crash when accessing its basic-block.  The
following avoids this by clearing the VDEF which is how it identifies
already processed stores.

PR tree-optimization/116079
* tree-ssa-loop-im.cc (hoist_memory_references): Clear
VDEF of elided clobbers.

* gcc.dg/torture/pr116079.c: New testcase.

12 months agotree-optimization/116081 - typedef vs. non-typedef in vectorization
Richard Biener [Thu, 25 Jul 2024 06:34:20 +0000 (08:34 +0200)] 
tree-optimization/116081 - typedef vs. non-typedef in vectorization

The following addresses a behavioral difference in vector type
analysis for typedef vs. non-typedef.  It doesn't fix the issue
at hand but avoids a spurious difference in the dumps.

PR tree-optimization/116081
* tree-vect-stmts.cc (vect_get_vector_types_for_stmt):
Properly compare types.

12 months agoRISC-V: Error early with V and no M extension.
Robin Dapp [Wed, 24 Jul 2024 07:08:00 +0000 (09:08 +0200)] 
RISC-V: Error early with V and no M extension.

For calculating the value of a poly_int at runtime we use a
multiplication instruction that requires the M extension.
Instead of just asserting and ICEing this patch emits an early
error at option-parsing time.

gcc/ChangeLog:

PR target/116036

* config/riscv/riscv.cc (riscv_override_options_internal): Error
with TARGET_VECTOR && !TARGET_MUL.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-31.c: Add m to arch string and expect it.
* gcc.target/riscv/arch-32.c: Ditto.
* gcc.target/riscv/arch-37.c: Ditto.
* gcc.target/riscv/arch-38.c: Ditto.
* gcc.target/riscv/predef-14.c: Ditto.
* gcc.target/riscv/predef-15.c: Ditto.
* gcc.target/riscv/predef-16.c: Ditto.
* gcc.target/riscv/predef-26.c: Ditto.
* gcc.target/riscv/predef-27.c: Ditto.
* gcc.target/riscv/predef-32.c: Ditto.
* gcc.target/riscv/predef-33.c: Ditto.
* gcc.target/riscv/predef-36.c: Ditto.
* gcc.target/riscv/predef-37.c: Ditto.
* gcc.target/riscv/rvv/autovec/pr111486.c: Add m to arch string.
* gcc.target/riscv/compare-debug-1.c: Ditto.
* gcc.target/riscv/compare-debug-2.c: Ditto.
* gcc.target/riscv/rvv/base/pr116036.c: New test.

12 months agoRISC-V: Allow LICM hoist POLY_INT configuration code sequence
Juzhe-Zhong [Thu, 1 Feb 2024 15:45:50 +0000 (23:45 +0800)] 
RISC-V: Allow LICM hoist POLY_INT configuration code sequence

Realize in recent benchmark evaluation (coremark-pro zip-test):

        vid.v   v2
        vmv.v.i v5,0
.L9:
        vle16.v v3,0(a4)
        vrsub.vx        v4,v2,a6   ---> LICM failed to hoist it outside the loop.

The root cause is:

(insn 56 47 57 4 (set (subreg:DI (reg:HI 220) 0)
        (reg:DI 223)) "rvv.c":11:9 208 {*movdi_64bit}  -> Its result used by the following vrsub.vx then supress the hoist of the vrsub.vx
     (nil))

(insn 57 56 59 4 (set (reg:RVVMF2HI 216)
        (if_then_else:RVVMF2HI (unspec:RVVMF32BI [
                    (const_vector:RVVMF32BI repeat [
                            (const_int 1 [0x1])
                        ])
                    (reg:DI 350)
                    (const_int 2 [0x2]) repeated x2
                    (const_int 1 [0x1])
                    (reg:SI 66 vl)
                    (reg:SI 67 vtype)
                ] UNSPEC_VPREDICATE)
            (minus:RVVMF2HI (vec_duplicate:RVVMF2HI (reg:HI 220))
                (reg:RVVMF2HI 217))
            (unspec:RVVMF2HI [
                    (reg:DI 0 zero)
                ] UNSPEC_VUNDEF))) "rvv.c":11:9 6938 {pred_subrvvmf2hi_reverse_scalar}
     (expr_list:REG_DEAD (reg:HI 220)
        (nil)))

This patch fixes it generate (set (reg:HI) (subreg:HI (reg:DI))) instead of (set (subreg:DI (reg:DI)) (reg:DI)).

After this patch:

vid.v v2
vrsub.vx v2,v2,a7
vmv.v.i v4,0
.L3:
vle16.v v3,0(a4)

Tested on both RV32 and RV64 no regression.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_legitimize_move): Fix poly_int dest generation.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/poly_licm-1.c: New test.
* gcc.target/riscv/rvv/autovec/poly_licm-2.c: New test.
* gcc.target/riscv/rvv/autovec/poly_licm-3.c: New test.

12 months agolibstdc++: Fix testsuite for remote testing (and sim)
Andrew Pinski [Thu, 25 Jul 2024 01:50:08 +0000 (18:50 -0700)] 
libstdc++: Fix testsuite for remote testing (and sim)

The problem here is that v3_additional_files will have a space
at the begining of the string as dg-additional-files will append
`" " $files` to it.  Then when split is called on that string,
there will be an empty file and copying a dir will just fail for
remote/sim testing (I didn't look at why it works for native
testing though).

Ran a full libstdc++ testsuite using a sim board for testing.

libstdc++-v3/ChangeLog:

* testsuite/lib/libstdc++.exp (v3_target_compile): Call
string trim on v3_target_compile before calling split.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
12 months agortl-ssa: Fix split_clobber_group tree insertion [PR116044]
Richard Sandiford [Thu, 25 Jul 2024 07:54:22 +0000 (08:54 +0100)] 
rtl-ssa: Fix split_clobber_group tree insertion [PR116044]

PR116044 is a regression in the testsuite on AMD GCN caused (again)
by the split_clobber_group code.  The first patch in this area
(g:71b31690a7c52413496e91bcc5ee4c68af2f366f) fixed a bug caused
by carrying the old group over as one of the split ones.  That
patch instead:

- created two new groups
- inserted them in the splay tree as neighbours of the old group
- removed the old group, and
- invalidated the old group (to force lazy recomputation when
  a clobber's parent group is queried)

However, this left add_def trying to insert the new definition
relative to a stale splay tree root.  The second patch
(g:34f33ea801563e2eabb348e8d3e9344a91abfd48) attempted to fix
that by inserting it relative to the new root.  But that's not
always correct either.  We specifically want to insert it after
the first of the two new groups, whether that group is the root
or not.

This patch does that, and tries to refactor the code to make
it a bit less brittle.

gcc/
PR rtl-optimization/116044
* rtl-ssa/functions.h (function_info::split_clobber_group): Return
an array of two clobber_groups.
* rtl-ssa/accesses.cc (function_info::split_clobber_group): Return
the new clobber groups.  Don't modify the splay tree here.
(function_info::add_def): Update call accordingly.  Generalize
the splay tree insertion code so that the new definition can be
inserted as a child of any existing node, not just the root.
Fix the insertion used after calling split_clobber_group.

12 months agoSVE Intrinsics: Change return type of redirect_call to gcall.
Jennifer Schmitz [Tue, 23 Jul 2024 10:54:50 +0000 (03:54 -0700)] 
SVE Intrinsics: Change return type of redirect_call to gcall.

As suggested in the review of
https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657474.html,
this patch changes the return type of gimple_folder::redirect_call from
gimple * to gcall *. The motivation for this is that so far, most callers of
the function had been casting the result of the function to gcall. These
call sites were updated.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/

* config/aarch64/aarch64-sve-builtins.cc
(gimple_folder::redirect_call): Update return type.
* config/aarch64/aarch64-sve-builtins.h: Likewise.
* config/aarch64/aarch64-sve-builtins-sve2.cc (svqshl_impl::fold):
Remove cast to gcall.
(svrshl_impl::fold): Likewise.

12 months agoMaintain complex constraint vector order during PTA solving
Richard Biener [Tue, 23 Jul 2024 12:05:47 +0000 (14:05 +0200)] 
Maintain complex constraint vector order during PTA solving

There's a FIXME comment in the PTA constraint solver that the vector
of complex constraints can get unsorted which can lead to duplicate
entries piling up during node unification.  The following fixes this
with the assumption that delayed updates to constraints are uncommon
(otherwise re-sorting the whole vector would be more efficient).

* tree-ssa-structalias.cc (constraint_equal): Take const
reference to constraints.
(constraint_vec_find): Similar.
(solve_graph): Keep constraint vector sorted and verify
sorting with checking.

12 months agoi386: Adjust rtx cost for imulq and imulw [PR115749]
Lingling Kong [Thu, 25 Jul 2024 01:42:06 +0000 (09:42 +0800)] 
i386: Adjust rtx cost for imulq and imulw [PR115749]

gcc/ChangeLog:

PR target/115749
* config/i386/x86-tune-costs.h (struct processor_costs):
Adjust rtx_cost of imulq and imulw for COST_N_INSNS (4)
to COST_N_INSNS (3).

gcc/testsuite/ChangeLog:

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

12 months agoDaily bump.
GCC Administrator [Thu, 25 Jul 2024 00:19:51 +0000 (00:19 +0000)] 
Daily bump.

12 months agodiagnostics: SARIF output: tweak output for UNKNOWN_LOCATION
David Malcolm [Wed, 24 Jul 2024 22:07:57 +0000 (18:07 -0400)] 
diagnostics: SARIF output: tweak output for UNKNOWN_LOCATION

gcc/ChangeLog:
* diagnostic-format-sarif.cc (sarif_builder::make_locations_arr):
Don't add entirely empty location objects, such as for
UNKNOWN_LOCATION.
(test_sarif_diagnostic_context::test_sarif_diagnostic_context):
Add param "main_input_filename".
(selftest::test_simple_log): Provide above param.  Verify that
"locations" is empty.
(selftest::test_simple_log_2): New.
(selftest::diagnostic_format_sarif_cc_tests): Call it.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agodiagnostics: add selftests for SARIF output
David Malcolm [Wed, 24 Jul 2024 22:07:56 +0000 (18:07 -0400)] 
diagnostics: add selftests for SARIF output

The existing DejaGnu-based tests for our SARIF output used regexes
to verify the JSON at the string level, which lets us test for
the presence of properties, but doesn't check the overall structure.

This patch uses the selftest framework to verify the structure of
the tree of JSON values for a log containing one diagnostic.

No functional change intended.

gcc/ChangeLog:
* diagnostic-format-sarif.cc (sarif_builder::flush_to_object):
New, using code moved from...
(sarif_builder::end_group): ...here.
(class selftest::test_sarif_diagnostic_context): New.
(selftest::test_simple_log): New.
(selftest::diagnostic_format_sarif_cc_tests): Call it.
* json.h (json::object::is_empty): New.
* selftest-diagnostic.cc (test_diagnostic_context::report): New.
* selftest-diagnostic.h (test_diagnostic_context::report): New
decl.
* selftest-json.cc (selftest::assert_json_string_eq): New.
(selftest::expect_json_object_with_string_property): New.
(selftest::assert_json_string_property_eq): New.
* selftest-json.h (selftest::assert_json_string_eq): New decl.
(ASSERT_JSON_STRING_EQ): New macro.
(selftest::expect_json_object_with_string_property): New decl.
(EXPECT_JSON_OBJECT_WITH_STRING_PROPERTY): New macro.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agodiagnostics: SARIF output: add "annotations" property (§3.28.6)
David Malcolm [Wed, 24 Jul 2024 22:07:56 +0000 (18:07 -0400)] 
diagnostics: SARIF output: add "annotations" property (§3.28.6)

This patch extends our SARIF output so that if a diagnostic has any
labelled source ranges, the "location" object gains an "annotations"
property capturing them (§3.28.6).

For example, given this textual output:

../../src/gcc/testsuite/gcc.dg/bad-binary-ops.c: In function ‘test_2’:
../../src/gcc/testsuite/gcc.dg/bad-binary-ops.c:31:11: error: invalid operands to binary + (have ‘struct s’ and ‘struct t’)
   30 |   return (some_function ()
      |           ~~~~~~~~~~~~~~~~
      |           |
      |           struct s
   31 |           + some_other_function ());
      |           ^ ~~~~~~~~~~~~~~~~~~~~~~
      |             |
      |             struct t

the SARIF output gains this within the result's location[0]:

   "annotations": [{"startLine": 30,
                    "startColumn": 11,
                    "endColumn": 27,
                    "message": {"text": "struct s"}},
                   {"startLine": 31,
                    "startColumn": 13,
                    "endColumn": 35,
                    "message": {"text": "struct t"}}]}]},

gcc/ChangeLog:
* diagnostic-format-sarif.cc
(sarif_builder::make_location_object): Add "annotations" property if
there are any labelled ranges (§3.28.6).
(selftest::test_make_location_object): Verify annotations are added
to location_obj.
* json.h (json::array::size): New.
(json::array::operator[]): New.
* selftest-json.cc
(selftest::expect_json_object_with_array_property): New.
* selftest-json.h
(selftest::expect_json_object_with_array_property): New decl.
(EXPECT_JSON_OBJECT_WITH_ARRAY_PROPERTY): New macro.

gcc/testsuite/ChangeLog:
* c-c++-common/diagnostic-format-sarif-file-Wbidi-chars.c: Verify
that we have an "annotations" property for the labelled
ranges (§3.28.6).

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agodiagnostics: SARIF output: add "{start,end}TimeUtc" properties (§§3.20.7-8)
David Malcolm [Wed, 24 Jul 2024 22:07:55 +0000 (18:07 -0400)] 
diagnostics: SARIF output: add "{start,end}TimeUtc" properties (§§3.20.7-8)

gcc/ChangeLog:
* diagnostic-format-sarif.cc
(make_date_time_string_for_current_time): New.
(sarif_invocation::sarif_invocation): Set "startTimeUtc"
property (§3.20.7).
(sarif_invocation::prepare_to_flush): Set "endTimeUtc"
property (§3.20.8).

gcc/testsuite/ChangeLog:
* c-c++-common/diagnostic-format-sarif-file-1.c: Verify that we have
"startTimeUtc" and "endTimeUtc" properties of the correct form.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agodiagnostics: SARIF output: add "arguments" property (§3.20.2)
David Malcolm [Wed, 24 Jul 2024 22:07:55 +0000 (18:07 -0400)] 
diagnostics: SARIF output: add "arguments" property (§3.20.2)

gcc/ChangeLog:
* diagnostic-format-sarif.cc (sarif_invocation::sarif_invocation):
Add "original_argv" param and use it to populate "arguments"
property (§3.20.2).
(sarif_builder::sarif_builder): Pass argv to m_invocation_obj's
ctor.
* diagnostic.cc (diagnostic_context::initialize): Initialize
m_original_argv.
(diagnostic_context::finish): Clean up m_original_argv.
(diagnostic_context::set_original_argv): New.
* diagnostic.h: Include "unique-argv.h".
(diagnostic_context::set_original_argv): New decl.
(diagnostic_context::get_original_argv): New decl.
(diagnostic_context::m_original_argv): New field.
* toplev.cc: Include "unique-argv.h".
(general_init): Add "original_argv" param and move it to global_dc.
(toplev::main): Stash a copy of the original argv before expansion,
and pass it to general_init for use by SARIF output.
* unique-argv.h: New file.

gcc/jit/ChangeLog:
* jit-playback.cc (jit::playback_context::compile) Add a trailing
null to argvec.

gcc/testsuite/ChangeLog:
* c-c++-common/diagnostic-format-sarif-file-1.c: Verify that we
have an "arguments" property (§3.20.2).

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agodiagnostics: SARIF output: add "workingDirectory" property (§3.20.19)
David Malcolm [Wed, 24 Jul 2024 22:07:55 +0000 (18:07 -0400)] 
diagnostics: SARIF output: add "workingDirectory" property (§3.20.19)

gcc/ChangeLog:
* diagnostic-format-sarif.cc
(sarif_builder::make_artifact_location_object): Make public.
(sarif_invocation::sarif_invocation): Add param "builder".
Use it to potentially populate the "workingDirectory" property
with the result of pwd (§3.20.19).
(sarif_builder::sarif_builder): Pass *this to m_invocation_obj's
ctor.

gcc/testsuite/ChangeLog:
* c-c++-common/diagnostic-format-sarif-file-1.c: Verify that we have
a "workingDirectory" property.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agodiagnostics: SARIF output: potentially add escaped renderings of source (§3.3.4)
David Malcolm [Wed, 24 Jul 2024 22:07:54 +0000 (18:07 -0400)] 
diagnostics: SARIF output: potentially add escaped renderings of source (§3.3.4)

This patch adds support to our SARIF output for cases where
rich_loc.escape_on_output_p () is true, such as for -Wbidi-chars.

In such cases, the pertinent SARIF "location" object gains a property
bag with property "gcc/escapeNonAscii": true, and the "artifactContent"
within the location's physical location's snippet" gains a "rendered"
property (§3.3.4) that escapes non-ASCII text in the snippet, such as:

"rendered": {"text":

where "text" has a string value such as (for a "trojan source" attack):

  "9 |     /*<U+202E> } <U+2066>if (isAdmin)<U+2069> <U+2066> begin admins only */\n"
  "  |       ~~~~~~~~                                ~~~~~~~~                    ^\n"
  "  |       |                                       |                           |\n"
  "  |       |                                       |                           end of bidirectional context\n"
  "  |       U+202E (RIGHT-TO-LEFT OVERRIDE)         U+2066 (LEFT-TO-RIGHT ISOLATE)\n"

where the escaping is affected by -fdiagnostics-escape-format=; with
-fdiagnostics-escape-format=bytes, the rendered text of the above is:

  "9 |     /*<e2><80><ae> } <e2><81><a6>if (isAdmin)<e2><81><a9> <e2><81><a6> begin admins only */\n"
  "  |       ~~~~~~~~~~~~                                        ~~~~~~~~~~~~                    ^\n"
  "  |       |                                                   |                               |\n"
  "  |       U+202E (RIGHT-TO-LEFT OVERRIDE)                     U+2066 (LEFT-TO-RIGHT ISOLATE)  end of bidirectional context\n"

The patch also refactors/adds enough selftest machinery to be able to
test the snippet generation from within the selftest framework, rather
than just within DejaGnu (where the regex-based testing isn't
sophisticated enough to verify such properties as the above).

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add selftest-json.o.
* diagnostic-format-sarif.cc: Include "selftest.h",
"selftest-diagnostic.h", "selftest-diagnostic-show-locus.h",
"selftest-json.h", and "text-range-label.h".
(class content_renderer): New.
(sarif_builder::m_rules_arr): Convert to std::unique_ptr.
(sarif_builder::make_location_object): Add class
escape_nonascii_renderer.  If rich_loc.escape_on_output_p (),
pass a nonnull escape_nonascii_renderer to
maybe_make_physical_location_object as its snippet_renderer, and
add a property bag property "gcc/escapeNonAscii" to the SARIF
location object.  For other overloads of make_location_object,
pass nullptr for the snippet_renderer.
(sarif_builder::maybe_make_region_object_for_context): Add
"snippet_renderer" param and pass it to
maybe_make_artifact_content_object.
(sarif_builder::make_tool_object): Drop "const".
(sarif_builder::make_driver_tool_component_object): Likewise.
Use typesafe unique_ptr variant of object::set for setting "rules"
property on driver_obj.
(sarif_builder::maybe_make_artifact_content_object): Add param "r"
and use it to potentially set the "rendered" property (§3.3.4).
(selftest::test_make_location_object): New.
(selftest::diagnostic_format_sarif_cc_tests): New.
* diagnostic-show-locus.cc: Include "text-range-label.h" and
"selftest-diagnostic-show-locus.h".
(selftests::diagnostic_show_locus_fixture::diagnostic_show_locus_fixture):
New.
(selftests::test_layout_x_offset_display_utf8): Use
diagnostic_show_locus_fixture to simplify and consolidate setup
code.
(selftests::test_diagnostic_show_locus_one_liner): Likewise.
(selftests::test_one_liner_colorized_utf8): Likewise.
(selftests::test_diagnostic_show_locus_one_liner_utf8): Likewise.
* gcc-rich-location.h (class text_range_label): Move to new file
text-range-label.h.
* selftest-diagnostic-show-locus.h: New file, based on material in
diagnostic-show-locus.cc.
* selftest-json.cc: New file.
* selftest-json.h: New file.
* selftest-run-tests.cc (selftest::run_tests): Call
selftest::diagnostic_format_sarif_cc_tests.
* selftest.h (selftest::diagnostic_format_sarif_cc_tests): New decl.

gcc/testsuite/ChangeLog:
* c-c++-common/diagnostic-format-sarif-file-Wbidi-chars.c: Verify
that we have a property bag with property "gcc/escapeNonAscii": true.
Verify that we have a "rendered" property for a snippet.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Include
"text-range-label.h".

gcc/ChangeLog:
* text-range-label.h: New file, taking class text_range_label from
gcc-rich-location.h.

libcpp/ChangeLog:
* include/rich-location.h
(semi_embedded_vec::semi_embedded_vec): Add copy ctor.
(rich_location::rich_location): Remove "= delete" from decl of
copy ctor.  Add deleted decl of move ctor.
(rich_location::operator=): Remove "= delete" from decl of
copy assignment.  Add deleted decl of move assignment.
(fixit_hint::fixit_hint): Add copy ctor decl.  Add deleted decl of
move.
(fixit_hint::operator=): Add copy assignment decl.  Add deleted
decl of move assignment.
* line-map.cc (rich_location::rich_location): New copy ctor.
(fixit_hint::fixit_hint): New copy ctor.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agodiagnostics: JSON output: use std::unique_ptr throughout
David Malcolm [Wed, 24 Jul 2024 22:07:54 +0000 (18:07 -0400)] 
diagnostics: JSON output: use std::unique_ptr throughout

No functional change intended.

gcc/ChangeLog:
* diagnostic-format-json.cc: Include "make-unique.h".
(json_output_format::m_toplevel_array): Convert to
std::unique_ptr.
(json_output_format::json_output_format): Update accordingly.
(json_output_format::~json_output_format): Remove manual
"delete" of field.
(json_from_expanded_location): Convert return type to
std::unique_ptr.
(json_from_location_range): Likewise.  Use nullptr rather than
NULL.
(json_from_fixit_hint): Convert return type to std::unique_ptr.
(json_from_metadata): Likewise.
(make_json_for_path): Likewise.
(json_output_format::on_end_diagnostic): Use std::unique_ptr
throughout.
(json_file_output_format::~json_file_output_format): Use nullptr.
(selftest::test_unknown_location): Update to use std::unique_ptr.
(selftest::test_bad_endpoints): Likewise.  Replace NULL with
nullptr.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agodiagnostics: SARIF output: use std::unique_ptr throughout
David Malcolm [Wed, 24 Jul 2024 22:07:53 +0000 (18:07 -0400)] 
diagnostics: SARIF output: use std::unique_ptr throughout

No functional change intended.

gcc/analyzer/ChangeLog:
* checker-event.cc (maybe_add_sarif_properties): Update setting
of "original_fndecl" to use typesafe unique_ptr variant of
json::object::set.

gcc/ChangeLog:
* diagnostic-format-sarif.cc: Include "make-unique.h".  Convert
raw pointers to std::unique_ptr throughout to indicate ownership,
adding comments in the few places where pointers are borrowed.
Use typesafe unique_ptr variants of json::object::set and
json::array::append throughout to make types of properties more
explicit, whilst using "auto" to reduce typing.
Use "nullptr" rather than "NULL" throughout.
* diagnostic-format-sarif.h (make_sarif_logical_location_object):
Use std::unique_ptr for return type.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agojson: support std::unique_ptr in array::append and object::set
David Malcolm [Wed, 24 Jul 2024 22:07:53 +0000 (18:07 -0400)] 
json: support std::unique_ptr in array::append and object::set

This patch uses templates to add overloads of json::array::append and
json::object::set taking std::unique_ptr<T> where T is a subclass of
json::value.

Doing so makes it much easier to track memory ownership and enforce
schema validity when constructing non-trivial JSON; using the wrong
kind of JSON value leads to compile-time errors like the following:

error: cannot convert ‘unique_ptr<sarif_message>’ to ‘unique_ptr<sarif_log>’
  629 |   location_obj->set<sarif_log> ("message", std::move (message_obj));
      |                                            ~~~~~~~~~~^~~~~~~~~~~~~
      |                                                      |
      |                                                      unique_ptr<sarif_message>

No functional change intended.

gcc/ChangeLog:
* diagnostic-format-json.cc: Define INCLUDE_MEMORY.
* diagnostic-format-sarif.cc: Likewise.
* dumpfile.cc: Likewise.
* gcov.cc: Likewise.
* json.cc: Likewise.  Include "make-unique.h".
(selftest::test_formatting): Exercise overloads of
array::append and object::set that use unique_ptr.
* json.h: Require INCLUDE_MEMORY to have been defined.
(json::object::set): Add a template to add a family of overloads
taking a std::unique_ptr<JsonType>
(json::array::append): Likewise.
* optinfo-emit-json.cc: Define INCLUDE_MEMORY.
* optinfo.cc: Likewise.
* timevar.cc: Likewise.
* toplev.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agodiagnostics: output formats: use references for non-null pointers
David Malcolm [Wed, 24 Jul 2024 22:07:53 +0000 (18:07 -0400)] 
diagnostics: output formats: use references for non-null pointers

No functional change intended.

gcc/ChangeLog:
* diagnostic-format-json.cc (json_from_expanded_location): Make
"static". Pass param "context" by reference, as it cannot be null.
(json_from_location_range): Likewise for param "context".
(json_from_fixit_hint): Likewise.
(make_json_for_path): Likewise.
(json_output_format::on_end_diagnostic): Update for above changes.
(diagnostic_output_format_init_json::diagnostic_output_format_init_json):
Pass param "context" by reference, as it cannot be null.
(diagnostic_output_format_init_json_stderr): Likewise.
(diagnostic_output_format_init_json_file): Likewise.
(selftest::test_unknown_location): Update for above changes.
(selftest::test_bad_endpoints): Likewise.
* diagnostic-format-sarif.cc (sarif_builder::m_context): Convert
from pointer to reference.
(sarif_invocation::add_notification_for_ice): Convert both params
from pointers to references.
(sarif_invocation::prepare_to_flush): Likewise for "context".
(sarif_result::on_nested_diagnostic): Likewise for "context" and
"builder".
(sarif_result::on_diagram): Likewise.
(sarif_ice_notification::sarif_ice_notification): Likewise.
(sarif_builder::sarif_builder): Likewise for "context".
(sarif_builder::end_diagnostic): Likewise.
(sarif_builder::emit_diagram): Likewise.
(sarif_builder::make_result_object): Likewise.
(make_reporting_descriptor_object_for_warning): Likewise.
(sarif_builder::make_locations_arr): Update for change to m_context.
(sarif_builder::get_sarif_column): Likewise.
(sarif_builder::make_message_object_for_diagram): Convert "context"
from pointer to reference.
(sarif_builder::make_tool_object): Likewise for "m_context".
(sarif_builder::make_driver_tool_component_object): Likewise.
(sarif_builder::get_or_create_artifact): Likewise.
(sarif_builder::maybe_make_artifact_content_object): Likewise.
(sarif_builder::get_source_lines): Likewise.
(sarif_output_format::on_end_diagnostic): Update for above changes.
(sarif_output_format::on_diagram): Likewise.
(sarif_output_format::sarif_output_format): Likewise.
(diagnostic_output_format_init_sarif): Convert param "context"
from pointer to reference.
(diagnostic_output_format_init_sarif_stderr): Likewise.
(diagnostic_output_format_init_sarif_file): Likewise.
(diagnostic_output_format_init_sarif_stream): Likewise.
* diagnostic.cc (diagnostic_output_format_init): Likewise.
* diagnostic.h (diagnostic_output_format_init): Likewise.
(diagnostic_output_format_init_json_stderr): Likewise.
(diagnostic_output_format_init_json_file): Likewise.
(diagnostic_output_format_init_sarif_stderr): Likewise.
(diagnostic_output_format_init_sarif_file): Likewise.
(diagnostic_output_format_init_sarif_stream): Likewise.
(json_from_expanded_location): Delete decl.
* gcc.cc (driver_handle_option): Update for change to
diagnostic_output_format_init.
* opts.cc (common_handle_option): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agodiagnostics: SARIF output: add sarif_object subclasses throughout
David Malcolm [Wed, 24 Jul 2024 22:07:52 +0000 (18:07 -0400)] 
diagnostics: SARIF output: add sarif_object subclasses throughout

No functional change intended.

gcc/ChangeLog:
* diagnostic-format-sarif.cc: Introduce subclasses of sarif_object
for all aspects of the spec that we're using.  Replace almost all
usage of json::object with uses of these subclasses, the only
remaining use of json::object being for originalUriBaseIds, as per
SARIF 2.1.0 §3.14.14.  This stronger typing makes it considerably
easier to maintain validity against the schema.
* diagnostic-format-sarif.h (class sarif_logical_location): New.
(make_sarif_logical_location_object): Convert return type from
json::object * to sarif_logical_location *.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agogcov: reduce use of naked "new" for json output
David Malcolm [Wed, 24 Jul 2024 22:07:52 +0000 (18:07 -0400)] 
gcov: reduce use of naked "new" for json output

No functional change intended.

gcc/ChangeLog:
* gcov.cc (output_intermediate_json_line): Use
json::object::set_integer to avoid naked "new".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agoanalyzer: reduce use of naked "new" for json dumps
David Malcolm [Wed, 24 Jul 2024 22:07:52 +0000 (18:07 -0400)] 
analyzer: reduce use of naked "new" for json dumps

No functional change intended.

gcc/analyzer/ChangeLog:
* call-string.cc (call_string::to_json): Avoid naked "new".
* constraint-manager.cc (bounded_range::set_json_attr): Likewise.
(equiv_class::to_json): Likewise.
(constraint::to_json): Likewise.
(bounded_ranges_constraint::to_json): Likewise.
* diagnostic-manager.cc (saved_diagnostic::to_json): Likewise.
(saved_diagnostic::maybe_add_sarif_properties): Likewise.
* engine.cc (exploded_node::to_json): Likewise.
(exploded_edge::to_json): Likewise.
* program-point.cc (program_point::to_json): Likewise.
* program-state.cc (program_state::to_json): Likewise.
* sm.cc (state_machine::to_json): Likewise.
* store.cc (binding_cluster::to_json): Likewise.
(store::to_json): Likewise.
* supergraph.cc (supernode::to_json): Likewise.
(superedge::to_json): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agojson: add array::append_string
David Malcolm [Wed, 24 Jul 2024 22:07:51 +0000 (18:07 -0400)] 
json: add array::append_string

No functional change intended.

gcc/analyzer/ChangeLog:
* supergraph.cc (supernode::to_json): Avoid naked "new" by using
json::array::append_string.
(supernode::to_json): Likewise.

gcc/ChangeLog:
* diagnostic-format-sarif.cc (sarif_artifact::populate_roles):
Avoid naked "new" by using json::array::append_string.
(sarif_builder::maybe_make_kinds_array): Likewise.
* json.cc (json::array::append_string): New.
(selftest::test_writing_arrays): Use it.
* json.h (json::array::append_string): New decl.
* optinfo-emit-json.cc (optrecord_json_writer::pass_to_json):
Avoid naked "new" by using json::array::append_string.
(optrecord_json_writer::optinfo_to_json): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agojson: add dump overload for easier debugging
David Malcolm [Wed, 24 Jul 2024 22:07:51 +0000 (18:07 -0400)] 
json: add dump overload for easier debugging

This has saved me a lot of typing in the debugger.

gcc/ChangeLog:
* json.cc (value::dump): New overload, taking no params.
* json.h (value::dump): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
12 months agoc++: parse error with -std=c++14 -fconcepts [PR116071]
Jason Merrill [Wed, 24 Jul 2024 20:20:33 +0000 (16:20 -0400)] 
c++: parse error with -std=c++14 -fconcepts [PR116071]

cp_parser_simple_type_specifier tries a variety of different things that
might qualify as a user-defined type: an actual type-name, a constrained
auto, a CTAD placeholder.  In a context where a type-specifier is optional,
this is all tentative.  With -std=c++14 -fconcepts, we try type-name and
constrained auto in sub-tentative parses, and when we run out of things to
try we haven't found anything but also haven't failed the outer tentative
parse, so parse_definitely succeeds, discarding the nested-name-specifier.

Fixed by failing if we didn't find anything.

I said in r14-3203 that we should disable this combination of flags if
further problems arise, but this seems like a more general problem that only
happened to occur with just this combination of flags.  So it lives on.

PR c++/116071

gcc/cp/ChangeLog:

* parser.cc (cp_parser_simple_type_specifier): Call
cp_parser_simulate_error if nothing worked.

gcc/testsuite/ChangeLog:

* g++.dg/parse/pr116071.C: New test.

12 months agoc++: Mostly concepts related formatting fixes
Jakub Jelinek [Wed, 24 Jul 2024 17:46:58 +0000 (19:46 +0200)] 
c++: Mostly concepts related formatting fixes

When playing with P2963R3, while reading and/or modifying code I've fixed
various comment or code formatting issues (and in 3 spots also comment
wording), but including that in the WIP P2963R3 patch made that patch
totally unreadable because these changes were 4 times the size of the
actual code changes.

So, here it is separated to a pure formatting + comment wording patch.

2024-07-24  Jakub Jelinek  <jakub@redhat.com>

* constraint.cc (subst_info::quiet, subst_info::noisy): Formatting
fixes.
(known_non_bool_p): Comment formatting fixes.
(unpack_concept_check): Likewise.
(resolve_function_concept_overload): Likewise.
(resolve_function_concept_check): Likewise.
(resolve_concept_check): Likewise.
(deduce_constrained_parameter): Likewise.
(finish_type_constraints): Likewise.
(get_returned_expression): Likewise.
(get_variable_initializer): Likewise.
(norm_info::update_context, norm_info::ctx_params): Formatting
fixes.
(norm_info::context): Comment formatting fixes.
(normalize_logical_operation): Likewise.  Formatting fix.
(normalize_concept_check): Comment formatting fixes.
(normalize_atom): Likewise.
(normalize_expression): Likewise.
(get_normalized_constraints_from_info): Likewise.
(get_normalized_constraints_from_decl): Likewise.  Formatting
fixes.
(atomic_constraints_identical_p): Comment formatting fixes.
(constraints_equivalent_p): Formatting fixes.
(inchash::add_constraint): Likewise.
(associate_classtype_constraints): Comment formatting fixes.
(get_constraints): Likewise.
(set_constraints): Likewise.
(build_concept_check_arguments): Likewise.
(build_function_check): Likewise.
(build_concept_check): Likewise.
(finish_shorthand_constraint): Likewise.
(get_shorthand_constraints): Likewise.
(check_constraint_variables): Likewise.
(tsubst_constraint_variables): Likewise.
(tsubst_requires_expr): Likewise.
(get_mapped_args): Likewise.  Formatting fixes.
(satisfy_atom): Comment formatting fixes.
(satisfy_constraint_r): Comment wording and formatting fixes.
(satisfy_normalized_constraints): Comment formatting fixes.
(satisfy_declaration_constraints): Likewise.
(evaluate_concept_check): Likewise.
(finish_requires_expr): Likewise.
(finish_compound_requirement): Likewise.
(check_function_concept): Likewise.
(equivalently_constrained): Likewise.
(more_constrained): Likewise.
(diagnose_atomic_constraint): Likewise.
* cp-tree.h (TREE_LANG_FLAG_0): Fix a comment error,
FOLD_EXPR_MODIFY_P instead of FOLD_EXPR_MODOP_P.
(DECL_MAIN_FREESTANDING_P, DECL_MAIN_P): Comment formatting fixes.
(enum cpp0x_warn_str): Likewise.
(enum composite_pointer_operation): Likewise.
(enum expr_list_kind): Likewise.
(enum impl_conv_rhs): Likewise.
(enum impl_conv_void): Likewise.
(struct deferred_access_check): Likewise.
(ATOMIC_CONSTR_EXPR): Likewise.
(FUNCTION_REF_QUALIFIED): Likewise.
(DECL_DEPENDENT_P): Likewise.
(FOLD_EXPR_MODIFY_P): Likewise.
(FOLD_EXPR_OP_RAW): Likewise.
(FOLD_EXPR_PACK): Likewise.
(FOLD_EXPR_INIT): Likewise.
(TYPE_WAS_UNNAMED): Likewise.
(class cp_unevaluated): Likewise.
(struct ovl_op_info_t assertion): Likewise.
(cp_declarator::function::requires_clause): Likewise.
(variable_template_p): Likewise.
(concept_definition_p): Likewise.
* logic.cc (clause::clause): Likewise.
(clause::replace): Likewise.
(clause::insert): Likewise.  Formatting fixes.
(struct formula): Comment formatting fixes.
(formula::branch): Likewise.
(debug): Formatting fixes.
(dnf_size_r): Comment formatting fixes.
(cnf_size_r): Likewise.
(dnf_size): Likewise.
(cnf_size): Likewise.
(branch_clause): Likewise.
(decompose_term): Likewise.  Formatting fixes.
(struct subsumption_entry): Comment formatting fixes.
(subsumption_cache): Likewise.
(save_subsumption): Likewise.  Formatting fixes.
(subsumes_constraints_nonnull): Formatting fixes.

12 months ago[rtl-optimization/116037] Explicitly track if a destination was skipped in ext-dce
Jeff Law [Wed, 24 Jul 2024 17:16:26 +0000 (11:16 -0600)] 
[rtl-optimization/116037] Explicitly track if a destination was skipped in ext-dce

So this has been in the hopper since the first bugs were reported against
ext-dce.  It'd been holding off committing as I was finding other issues in
terms of correctness of live computations.  There's still problems in that
space, but I think it's time to push this chunk forward.  I'm marking it as
116037, but it may impact other bugs.

This patch starts explicitly tracking if set processing skipped a destination,
which can happen for wide modes (TI+), vectors, certain subregs, etc.  This is
computed during ext_dce_set_processing.

During use processing we use that flag to determine reliably if we need to make
the inputs fully live and to avoid even trying to eliminate an extension if we
skipped output processing.

While testing this I found that a recent change to fix cases where we had two
subreg input operands mucked up the code to make things like a shift/rotate
count fully live.  So that goof has been fixed.

Bootstrapped and regression tested on x86.  Most, but not all, of these changes
have also been tested on the crosses.  Pushing to the trunk.

I'm not including it in this patch but I'm poking at converting this code to
use note_uses/note_stores to make it more maintainable.  The SUBREG and
STRICT_LOW_PART handling of note_stores is problematical, but I think it's
solvable.  I haven't tried a conversion to note_uses yet.

PR rtl-optimization/116037
gcc/
* ext-dce.cc (ext_dce_process_sets): Note if we ever skip a dest
and return that info explicitly.
(ext_dce_process_uses): If a set was skipped, then consider all bits
in every input as live.  Do not try to optimize away an extension if
we skipped processing a destination in the same insn.  Restore code
to make shift/rotate count fully live.
(ext_dce_process_bb): Handle API changes for ext_dce_process_sets.

gcc/testsuite/
* gcc.dg/torture/pr116037.c: New test

12 months agotestsuite: Fix up pr116034.c test for big/pdp endian [PR116061]
Jakub Jelinek [Wed, 24 Jul 2024 16:00:05 +0000 (18:00 +0200)] 
testsuite: Fix up pr116034.c test for big/pdp endian [PR116061]

Didn't notice the memmove is into an int variable, so the test
was still failing on big endian.

2024-07-24  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/116034
PR testsuite/116061
* gcc.dg/pr116034.c (g): Change type from int to unsigned short.
(foo): Guard memmove call on __SIZEOF_SHORT__ == 2.

12 months agolibstdc++: Fix <ostream> and <istream> for -std=gnu++14 -fconcepts [PR116070]
Jonathan Wakely [Wed, 24 Jul 2024 10:32:22 +0000 (11:32 +0100)] 
libstdc++: Fix <ostream> and <istream> for -std=gnu++14 -fconcepts [PR116070]

This questionable combination of flags causes a number of errors. The
ones in the rvalue stream overloads need to be fixed in the gcc-14
branch so I'm committing it separately to simplify backporting.

libstdc++-v3/ChangeLog:

PR libstdc++/116070
* include/std/istream: Check feature test macro before using
is_class_v and is_same_v.
* include/std/ostream: Likewise.

12 months agolibstdc++: Fix std::vector<bool> for -std=gnu++14 -fconcepts [PR116070]
Jonathan Wakely [Wed, 24 Jul 2024 10:32:22 +0000 (11:32 +0100)] 
libstdc++: Fix std::vector<bool> for -std=gnu++14 -fconcepts [PR116070]

This questionable combination of flags causes a number of errors. This
one in std::vector<bool> needs to be fixed in the gcc-13 branch so I'm
committing it separately to simplify backporting.

libstdc++-v3/ChangeLog:

PR libstdc++/116070
* include/bits/stl_bvector.h: Check feature test macro before
using is_default_constructible_v.

12 months agolibstdc++: Remove duplicate include header from ranges_algobase.h
Michael Levine [Tue, 23 Jul 2024 11:50:31 +0000 (12:50 +0100)] 
libstdc++: Remove duplicate include header from ranges_algobase.h

The bits/stl_algobase.h header was added to bits/ranges_algobase.h
separately through two related commits:
r15-1106-g674d213ab91871
r15-1117-g0bb1db32ccf54a

The comment for the first time it is included in the file is also
incorrect (my error from that 2nd one) since it is really being included
for __memcmp, not __memcpy

This patch removes the duplicate header include.

libstdc++-v3/ChangeLog:

* include/bits/ranges_algobase.h: Remove duplicate include of
<bits/stl_algobase.h>.

Signed-off-by: Michael Levine <mlevine55@bloomberg.net>
12 months agoaarch64: Extend aarch64_feature_flags to 128 bits
Andrew Carlotti [Fri, 10 May 2024 12:34:34 +0000 (13:34 +0100)] 
aarch64: Extend aarch64_feature_flags to 128 bits

Replace the existing uint64_t typedef with a bbitmap<2> typedef.  Most
of the preparatory work was carried out in previous commits, so this
patch itself is fairly small.

gcc/ChangeLog:

* common/config/aarch64/aarch64-common.cc
(aarch64_set_asm_isa_flags): Store a second uint64_t value.
* config/aarch64/aarch64-opts.h
(aarch64_feature_flags): Switch typedef to bbitmap<2>.
* config/aarch64/aarch64.cc
(aarch64_set_current_function): Extract isa mode from val[0].
* config/aarch64/aarch64.h
(aarch64_get_asm_isa_flags): Load a second uint64_t value.
(aarch64_get_isa_flags): Ditto.
(aarch64_asm_isa_flags): Ditto.
(aarch64_isa_flags): Ditto.
(HANDLE): Use bbitmap<2>::from_index to initialise flags.
(AARCH64_FL_ISA_MODES): Do arithmetic on integer type.
(AARCH64_ISA_MODE): Extract value from bbitmap<2> array.
* config/aarch64/aarch64.opt
(aarch64_asm_isa_flags_1): New variable.
(aarch64_isa_flags_1): Ditto.

12 months agoAdd new bbitmap<N> class
Andrew Carlotti [Fri, 21 Jun 2024 17:59:25 +0000 (18:59 +0100)] 
Add new bbitmap<N> class

This class provides a constant-size bitmap that can be used as almost a
drop-in replacement for bitmaps stored in integer types.  The
implementation is entirely within the header file and uses recursive
templated operations to support effective optimisation and usage in
constexpr expressions.

This initial implementation hardcodes the choice of uint64_t elements
for storage and initialisation, but this could instead be specified via
a second template parameter.

gcc/ChangeLog:

* bbitmap.h: New file.

12 months agoaarch64: Use constructor explicitly in get_flags_off
Andrew Carlotti [Thu, 11 Jul 2024 00:25:05 +0000 (01:25 +0100)] 
aarch64: Use constructor explicitly in get_flags_off

gcc/ChangeLog:

* config/aarch64/aarch64-feature-deps.h
(get_flags_off): Construct aarch64_feature_flags (0) explicitly.

12 months agoaarch64: Add bool conversion to TARGET_* macros
Andrew Carlotti [Wed, 10 Jul 2024 13:42:37 +0000 (14:42 +0100)] 
aarch64: Add bool conversion to TARGET_* macros

Use a new AARCH64_HAVE_ISA macro in TARGET_* definitions, and eliminate
all the AARCH64_ISA_* feature macros.

gcc/ChangeLog:

* config/aarch64/aarch64-c.cc
(aarch64_define_unconditional_macros): Use TARGET_V8R macro.
(aarch64_update_cpp_builtins): Use TARGET_* macros.
* config/aarch64/aarch64.h (AARCH64_HAVE_ISA): New macro.
(AARCH64_ISA_SM_OFF, AARCH64_ISA_SM_ON, AARCH64_ISA_ZA_ON)
(AARCH64_ISA_V8A, AARCH64_ISA_V8_1A, AARCH64_ISA_CRC)
(AARCH64_ISA_FP, AARCH64_ISA_SIMD, AARCH64_ISA_LSE)
(AARCH64_ISA_RDMA, AARCH64_ISA_V8_2A, AARCH64_ISA_F16)
(AARCH64_ISA_SVE, AARCH64_ISA_SVE2, AARCH64_ISA_SVE2_AES)
(AARCH64_ISA_SVE2_BITPERM, AARCH64_ISA_SVE2_SHA3)
(AARCH64_ISA_SVE2_SM4, AARCH64_ISA_SME, AARCH64_ISA_SME_I16I64)
(AARCH64_ISA_SME_F64F64, AARCH64_ISA_SME2, AARCH64_ISA_V8_3A)
(AARCH64_ISA_DOTPROD, AARCH64_ISA_AES, AARCH64_ISA_SHA2)
(AARCH64_ISA_V8_4A, AARCH64_ISA_SM4, AARCH64_ISA_SHA3)
(AARCH64_ISA_F16FML, AARCH64_ISA_RCPC, AARCH64_ISA_RCPC8_4)
(AARCH64_ISA_RNG, AARCH64_ISA_V8_5A, AARCH64_ISA_TME)
(AARCH64_ISA_MEMTAG, AARCH64_ISA_V8_6A, AARCH64_ISA_I8MM)
(AARCH64_ISA_F32MM, AARCH64_ISA_F64MM, AARCH64_ISA_BF16)
(AARCH64_ISA_SB, AARCH64_ISA_RCPC3, AARCH64_ISA_V8R)
(AARCH64_ISA_PAUTH, AARCH64_ISA_V8_7A, AARCH64_ISA_V8_8A)
(AARCH64_ISA_V8_9A, AARCH64_ISA_V9A, AARCH64_ISA_V9_1A)
(AARCH64_ISA_V9_2A, AARCH64_ISA_V9_3A, AARCH64_ISA_V9_4A)
(AARCH64_ISA_MOPS, AARCH64_ISA_LS64, AARCH64_ISA_CSSC)
(AARCH64_ISA_D128, AARCH64_ISA_THE, AARCH64_ISA_GCS): Remove.
(TARGET_BASE_SIMD, TARGET_SIMD, TARGET_FLOAT)
(TARGET_NON_STREAMING, TARGET_STREAMING, TARGET_ZA, TARGET_SHA2)
(TARGET_SHA3, TARGET_AES, TARGET_SM4, TARGET_F16FML)
(TARGET_CRC32, TARGET_LSE, TARGET_FP_F16INST)
(TARGET_SIMD_F16INST, TARGET_DOTPROD, TARGET_SVE, TARGET_SVE2)
(TARGET_SVE2_AES, TARGET_SVE2_BITPERM, TARGET_SVE2_SHA3)
(TARGET_SVE2_SM4, TARGET_SME, TARGET_SME_I16I64)
(TARGET_SME_F64F64, TARGET_SME2, TARGET_ARMV8_3, TARGET_JSCVT)
(TARGET_FRINT, TARGET_TME, TARGET_RNG, TARGET_MEMTAG)
(TARGET_I8MM, TARGET_SVE_I8MM, TARGET_SVE_F32MM)
(TARGET_SVE_F64MM, TARGET_BF16_FP, TARGET_BF16_SIMD)
(TARGET_SVE_BF16, TARGET_PAUTH, TARGET_BTI, TARGET_MOPS)
(TARGET_LS64, TARGET_CSSC, TARGET_SB, TARGET_RCPC, TARGET_RCPC2)
(TARGET_RCPC3, TARGET_SIMD_RDMA, TARGET_ARMV9_4, TARGET_D128)
(TARGET_THE, TARGET_GCS): Redefine using AARCH64_HAVE_ISA.
(TARGET_V8R, TARGET_V9A): New.
* config/aarch64/aarch64.md (arch_enabled): Use TARGET_RCPC2.
* config/aarch64/iterators.md (GPI_I16): Use TARGET_FP_F16INST.
(GPF_F16): Ditto.
* config/aarch64/predicates.md
(aarch64_rcpc_memory_operand): Use TARGET_RCPC2.

12 months agoaarch64: Add explicit bool cast to return value
Andrew Carlotti [Wed, 10 Jul 2024 14:00:16 +0000 (15:00 +0100)] 
aarch64: Add explicit bool cast to return value

gcc/ChangeLog:

* config/aarch64/aarch64.cc
(aarch64_valid_sysreg_name_p): Add bool cast.

12 months agoaarch64: Decouple feature flag option storage type
Andrew Carlotti [Fri, 10 May 2024 10:56:57 +0000 (11:56 +0100)] 
aarch64: Decouple feature flag option storage type

The awk scripts that process the .opt files are relatively fragile and
only handle a limited set of data types correctly.  The unrecognised
aarch64_feature_flags type is handled as a uint64_t, which happens to be
correct for now.  However, that assumption will change when we extend
the mask to 128 bits.

This patch changes the option members to use uint64_t types, and adds a
"_0" suffix to the names (both for future extensibility, and to allow
the original name to be used for the full aarch64_feature_flags mask
within generator files).

gcc/ChangeLog:

* common/config/aarch64/aarch64-common.cc
(aarch64_set_asm_isa_flags): Reorder, and add suffix to names.
* config/aarch64/aarch64.h
(aarch64_get_asm_isa_flags): Add "_0" suffix.
(aarch64_get_isa_flags): Ditto.
(aarch64_asm_isa_flags): Redefine using renamed uint64_t value.
(aarch64_isa_flags): Ditto.
* config/aarch64/aarch64.opt:
(aarch64_asm_isa_flags): Rename to...
(aarch64_asm_isa_flags_0): ...this, and change to uint64_t.
(aarch64_isa_flags): Rename to...
(aarch64_isa_flags_0): ...this, and change to uint64_t.

12 months agoaarch64: Define aarch64_get_{asm_|}isa_flags
Andrew Carlotti [Fri, 10 May 2024 10:46:17 +0000 (11:46 +0100)] 
aarch64: Define aarch64_get_{asm_|}isa_flags

Building an aarch64_feature_flags value from data within a gcc_options
or cl_target_option struct will get more complicated in a later commit.
Use a macro to avoid doing this manually in more than one location.

gcc/ChangeLog:

* common/config/aarch64/aarch64-common.cc
(aarch64_handle_option): Use new macro.
* config/aarch64/aarch64.cc
(aarch64_override_options_internal): Ditto.
(aarch64_option_print): Ditto.
(aarch64_set_current_function): Ditto.
(aarch64_can_inline_p): Ditto.
(aarch64_declare_function_name): Ditto.
(aarch64_start_file): Ditto.
* config/aarch64/aarch64.h (aarch64_get_asm_isa_flags): New
(aarch64_get_isa_flags): New.
(aarch64_asm_isa_flags): Use new macro.
(aarch64_isa_flags): Ditto.

12 months agoaarch64: Introduce aarch64_isa_mode type
Andrew Carlotti [Fri, 3 May 2024 15:51:05 +0000 (16:51 +0100)] 
aarch64: Introduce aarch64_isa_mode type

Currently there are many places where an aarch64_feature_flags variable
is used, but only the bottom three isa mode bits are set and read.
Using a separate data type for these value makes it more clear that
they're not expected or required to have any of their upper feature bits
set.  It will also make things simpler and more efficient when we extend
aarch64_feature_flags to 128 bits.

This patch uses explicit casts whenever converting from an
aarch64_feature_flags value to an aarch64_isa_mode value.  This isn't
strictly necessary, but serves to highlight the locations where an
explicit conversion will become necessary later.

gcc/ChangeLog:

* config/aarch64/aarch64-opts.h: Add aarch64_isa_mode typedef.
* config/aarch64/aarch64-protos.h
(aarch64_gen_callee_cookie): Use aarch64_isa_mode parameter.
(aarch64_sme_vq_immediate): Ditto.
* config/aarch64/aarch64.cc
(aarch64_fntype_pstate_sm): Use aarch64_isa_mode values.
(aarch64_fntype_pstate_za): Ditto.
(aarch64_fndecl_pstate_sm): Ditto.
(aarch64_fndecl_pstate_za): Ditto.
(aarch64_fndecl_isa_mode): Ditto.
(aarch64_cfun_incoming_pstate_sm): Ditto.
(aarch64_cfun_enables_pstate_sm): Ditto.
(aarch64_call_switches_pstate_sm): Ditto.
(aarch64_gen_callee_cookie): Ditto.
(aarch64_callee_isa_mode): Ditto.
(aarch64_insn_callee_abi): Ditto.
(aarch64_sme_vq_immediate): Ditto.
(aarch64_add_offset_temporaries): Ditto.
(aarch64_add_offset): Ditto.
(aarch64_add_sp): Ditto.
(aarch64_sub_sp): Ditto.
(aarch64_guard_switch_pstate_sm): Ditto.
(aarch64_switch_pstate_sm): Ditto.
(aarch64_init_cumulative_args): Ditto.
(aarch64_allocate_and_probe_stack_space): Ditto.
(aarch64_expand_prologue): Ditto.
(aarch64_expand_epilogue): Ditto.
(aarch64_start_call_args): Ditto.
(aarch64_expand_call): Ditto.
(aarch64_end_call_args): Ditto.
(aarch64_set_current_function): Ditto, with added conversions.
(aarch64_handle_attr_arch): Avoid macro with changed type.
(aarch64_handle_attr_cpu): Ditto.
(aarch64_handle_attr_isa_flags): Ditto.
(aarch64_switch_pstate_sm_for_landing_pad):
Use arch64_isa_mode values.
(aarch64_switch_pstate_sm_for_jump): Ditto.
(pass_switch_pstate_sm::gate): Ditto.
* config/aarch64/aarch64.h
(AARCH64_ISA_MODE_{SM_ON|SM_OFF|ZA_ON}): New macros.
(AARCH64_FL_SM_STATE): Mark as possibly unused.
(AARCH64_ISA_MODE_SM_STATE): New aarch64_isa_mode mask.
(AARCH64_DEFAULT_ISA_MODE): New aarch64_isa_mode value.
(AARCH64_FL_DEFAULT_ISA_MODE): Define using above value.
(AARCH64_ISA_MODE): Change type to aarch64_isa_mode.
(arm_pcs): Use aarch64_isa_mode value.

12 months agoaarch64: Eliminate a temporary variable.
Andrew Carlotti [Fri, 10 May 2024 11:56:44 +0000 (12:56 +0100)] 
aarch64: Eliminate a temporary variable.

The name would become misleading in a later commit anyway, and I think
this is marginally more readable.

gcc/ChangeLog:

* config/aarch64/aarch64.cc
(aarch64_override_options): Remove temporary variable.

12 months agoaarch64: Move AARCH64_NUM_ISA_MODES definition
Andrew Carlotti [Fri, 3 May 2024 15:09:27 +0000 (16:09 +0100)] 
aarch64: Move AARCH64_NUM_ISA_MODES definition

AARCH64_NUM_ISA_MODES will be used within aarch64-opts.h in a later
commit.

gcc/ChangeLog:

* config/aarch64/aarch64.h (DEF_AARCH64_ISA_MODE): Move to...
* config/aarch64/aarch64-opts.h (DEF_AARCH64_ISA_MODE): ...here.

12 months agoaarch64: Remove unused global aarch64_tune_flags
Andrew Carlotti [Wed, 17 Apr 2024 18:28:20 +0000 (19:28 +0100)] 
aarch64: Remove unused global aarch64_tune_flags

gcc/ChangeLog:

* config/aarch64/aarch64.cc
(aarch64_tune_flags): Remove unused global variable.
(aarch64_override_options_internal): Remove dead assignment.

12 months agoc++: add fixed testcase [PR109997]
Jason Merrill [Wed, 24 Jul 2024 15:07:42 +0000 (11:07 -0400)] 
c++: add fixed testcase [PR109997]

Fixed by r14-9713 for PR100667.

PR c++/109997

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_assignable1.C: New test.

12 months agooptabs/rs6000: Rename iorc and andc to iorn and andn
Andrew Pinski [Tue, 23 Jul 2024 04:23:38 +0000 (21:23 -0700)] 
optabs/rs6000: Rename iorc and andc to iorn and andn

When I was trying to add an scalar version of iorc and andc, the optab that
got matched was for and/ior with the mode of csi and cdi instead of iorc and
andc optabs for si and di modes. Since csi/cdi are the complex integer modes,
we need to rename the optabs to be without c there. This changes c to n which
is a neutral and known not to be first letter of a mode.

Bootstrapped and tested on x86_64 and powerpc64le.

gcc/ChangeLog:

* config/rs6000/rs6000-builtins.def: s/iorc/iorn/. s/andc/andn/
for the code.
* config/rs6000/rs6000-string.cc (expand_cmp_vec_sequence): Update
to iorn.
* config/rs6000/rs6000.md (andc<mode>3): Rename to ...
(andn<mode>3): This.
(iorc<mode>3): Rename to ...
(iorn<mode>3): This.
* doc/md.texi: Update documentation for the rename.
* internal-fn.def (BIT_ANDC): Rename to ...
(BIT_ANDN): This.
(BIT_IORC): Rename to ...
(BIT_IORN): This.
* optabs.def (andc_optab): Rename to ...
(andn_optab): This.
(iorc_optab): Rename to ...
(iorn_optab): This.
* gimple-isel.cc (gimple_expand_vec_cond_expr): Update for the
renamed internal functions, ANDC/IORC to ANDN/IORN.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
12 months agomodula2: Improve error message to include symbol name.
Gaius Mulley [Wed, 24 Jul 2024 13:26:39 +0000 (14:26 +0100)] 
modula2: Improve error message to include symbol name.

gcc/m2/ChangeLog:

* gm2-compiler/M2StateCheck.mod (GenerateError): Add
symbol name to the error message.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
12 months agomodula2: Add GNU flex as a build and install prerequisite.
Gaius Mulley [Wed, 24 Jul 2024 13:25:45 +0000 (14:25 +0100)] 
modula2: Add GNU flex as a build and install prerequisite.

gcc/ChangeLog:

* doc/install.texi (GM2-prerequisite): Add GNU flex.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
12 months agotree-optimization/116057 - wrong code with CCP and vector CTORs
Richard Biener [Wed, 24 Jul 2024 11:16:35 +0000 (13:16 +0200)] 
tree-optimization/116057 - wrong code with CCP and vector CTORs

The following fixes an issue with CCPs likely_value when faced with
a vector CTOR containing undef SSA names and constants.  This should
be classified as CONSTANT and not UNDEFINED.

PR tree-optimization/116057
* tree-ssa-ccp.cc (likely_value): Also walk CTORs in stmt
operands to look for constants.

* gcc.dg/torture/pr116057.c: New testcase.

12 months agoRevert "aarch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2"
Kyrylo Tkachov [Wed, 24 Jul 2024 11:55:43 +0000 (17:25 +0530)] 
Revert "aarch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2"

This reverts commit 4c5eb66e701bc9f3bf1298269f52559b10d63a09.

12 months agoaarch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2
Jennifer Schmitz [Tue, 23 Jul 2024 06:24:45 +0000 (23:24 -0700)] 
aarch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2

According to the Neoverse V2 Software Optimization Guide (section 4.14), the
instruction pairs CMP+CSEL and CMP+CSET can be fused, which had not been
implemented so far. This patch implements and tests the two fusion pairs.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
There was also no non-noise impact on SPEC CPU2017 benchmark.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/

* config/aarch64/aarch64.cc (aarch_macro_fusion_pair_p): Implement
fusion logic.
* config/aarch64/aarch64-fusion-pairs.def (cmp+csel): New entry.
(cmp+cset): Likewise.
* config/aarch64/tuning_models/neoversev2.h: Enable logic in
field fusible_ops.

gcc/testsuite/

* gcc.target/aarch64/cmp_csel_fuse.c: New test.
* gcc.target/aarch64/cmp_cset_fuse.c: Likewise.

12 months agolibstdc++: Rename tests [PR12048]
Jonathan Wakely [Mon, 22 Jul 2024 14:50:19 +0000 (15:50 +0100)] 
libstdc++: Rename tests [PR12048]

These have the wrong PR number in the filenames.

libstdc++-v3/ChangeLog:

PR libstdc++/12048
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc: Move to...
* testsuite/ext/stdio_sync_filebuf/wchar_t/12048-1.cc: ...here.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc: Move to...
* testsuite/ext/stdio_sync_filebuf/wchar_t/12048-2.cc: ...here.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc: Move to...
* testsuite/ext/stdio_sync_filebuf/wchar_t/12048-3.cc: ...here.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc: Move to...
* testsuite/ext/stdio_sync_filebuf/wchar_t/12048-4.cc: ...here.

12 months agolibstdc++: Stop copying all data files into test directory
Jonathan Wakely [Mon, 22 Jul 2024 13:07:32 +0000 (14:07 +0100)] 
libstdc++: Stop copying all data files into test directory

This removes the TODO in libstdc++_init, so that we don't copy all *.tst
and *.txt files from testsuite/data into every test's working directory.
Instead, only the necessary files declared with dg-additional-files are
copied.

libstdc++-v3/ChangeLog:

* testsuite/lib/libstdc++.exp (libstdc++_init): Do not copy all
data files into test directory.

12 months agolibstdc++: Use dg-additional-files in some non-I/O tests
Jonathan Wakely [Mon, 22 Jul 2024 14:15:16 +0000 (15:15 +0100)] 
libstdc++: Use dg-additional-files in some non-I/O tests

libstdc++-v3/ChangeLog:

* testsuite/20_util/hash/chi2_q_document_words.cc: Use
dg-additional-files for input text.
* testsuite/performance/ext/pb_ds/all_text_find.cc: Likewise.
* testsuite/performance/ext/pb_ds/multimap_text_find.hpp:
Likewise.
* testsuite/performance/ext/pb_ds/multimap_text_insert.hpp:
Likewise.
* testsuite/performance/ext/pb_ds/multimap_text_insert_mem.hpp:
Likewise.
* testsuite/performance/ext/pb_ds/priority_queue_text_join.cc:
Likewise.
* testsuite/performance/ext/pb_ds/priority_queue_text_modify.hpp: Likewise.
* testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem.cc: Likewise.
* testsuite/performance/ext/pb_ds/priority_queue_text_push.cc:
Likewise.
* testsuite/performance/ext/pb_ds/priority_queue_text_push_pop.cc: Likewise.
* testsuite/performance/ext/pb_ds/tree_text_insert.cc: Likewise.
* testsuite/performance/ext/pb_ds/tree_text_lor_find.cc:
Likewise.

12 months agolibstdc++: Use dg-additional-files in some algorithm tests
Jonathan Wakely [Mon, 22 Jul 2024 13:01:43 +0000 (14:01 +0100)] 
libstdc++: Use dg-additional-files in some algorithm tests

Use the dg-additional-files directive to declare files that need to be
copied into the test's working directory. This is currently redundant
(as all .tst and .txt files are copied for all tests) but is a step
towards not copying all files.

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/advance/istreambuf_iterators/char/2.cc:
Use dg-additional-files.
* testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/2.cc:
Likewise.
* testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc:
Likewise.
* testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc:
Likewise.
* testsuite/25_algorithms/copy_n/istreambuf_iterator/2.cc:
Likewise.
* testsuite/25_algorithms/copy_n/istreambuf_iterator/deque.cc:
Likewise.
* testsuite/25_algorithms/find/istreambuf_iterators/char/2.cc:
Likewise.
* testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/2.cc:
Likewise.

12 months agolibstdc++: Add file-io-diff to replace @diff@ markup in I/O tests
Jonathan Wakely [Mon, 22 Jul 2024 13:39:57 +0000 (14:39 +0100)] 
libstdc++: Add file-io-diff to replace @diff@ markup in I/O tests

This adds a new dg-final action to compare two files after a test has
run, so that we can verify that fstream operations produce the expected
results. With this change, all uses of @diff@ that seem potentially
useful have been converted to actually compare the files and FAIL if
they differ.

The file-io-diff action can take two arguments naming the files to be
compared, or for convenience it can take a single string and will
compare STR.tst and STR.txt, as that's how it's commonly used.

Additionally, all remaining uses of @require@ are converted to
dg-additional-files directives, so that the TODO in libstdc++.exp can
be resolved.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_filebuf/close/char/1.cc: Remove
@require@ and @diff@. Use dg-final file-io-diff action.
* testsuite/27_io/basic_istream/extractors_other/char/2.cc:
Likewise.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc:
Likewise.
* testsuite/27_io/basic_istream/get/char/2.cc: Likewise.
* testsuite/27_io/basic_istream/get/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_istream/ignore/char/3.cc: Likewise.
* testsuite/27_io/basic_istream/ignore/wchar_t/3.cc: Likewise.
* testsuite/27_io/basic_istream/peek/char/6414.cc: Likewise.
* testsuite/27_io/basic_istream/peek/wchar_t/6414.cc: Likewise.
* testsuite/27_io/basic_istream/seekg/char/fstream.cc: Likewise.
* testsuite/27_io/basic_istream/seekg/wchar_t/fstream.cc:
Likewise.
* testsuite/27_io/basic_istream/tellg/char/fstream.cc: Likewise.
* testsuite/27_io/basic_istream/tellg/wchar_t/fstream.cc:
Likewise.
* testsuite/27_io/basic_ofstream/open/char/1.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/1.cc:
Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc:
Likewise.
* testsuite/27_io/ios_base/sync_with_stdio/1.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/2.cc:
Likewise. Check file positions.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/2.cc:
Likewise.
* testsuite/lib/libstdc++.exp (file-io-diff): New proc.

12 months agolibstdc++: Use dg-additional-files in some I/O tests
Jonathan Wakely [Mon, 22 Jul 2024 13:01:43 +0000 (14:01 +0100)] 
libstdc++: Use dg-additional-files in some I/O tests

Use the dg-additional-files directive to declare files that need to be
copied into the test's working directory. This is currently redundant
(as all .tst and .txt files are copied for all tests) but is a step
towards not copying all files.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_filebuf/imbue/char/2.cc: Use
dg-additional-files.
* testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_filebuf/open/char/path.cc: Likewise.
* testsuite/27_io/basic_filebuf/pbackfail/char/9761.cc:
Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/3-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/3.cc: Likewise.
* testsuite/27_io/basic_filebuf/underflow/10096.cc: Likewise.
* testsuite/27_io/basic_fstream/cons/char/path.cc: Likewise.
* testsuite/27_io/basic_fstream/open/char/path.cc: Likewise.
* testsuite/27_io/basic_ifstream/assign/1.cc: Likewise.
* testsuite/27_io/basic_ifstream/cons/move.cc: Likewise.
* testsuite/27_io/basic_ifstream/cons/char/path.cc: Likewise.
* testsuite/27_io/basic_ifstream/open/char/path.cc: Likewise.
* testsuite/27_io/basic_ifstream/open/wchar_t/1.cc: Likewise.
* testsuite/27_io/objects/char/10.cc: Likewise.
* testsuite/27_io/objects/char/12048-1.cc: Likewise.
* testsuite/27_io/objects/char/12048-2.cc: Likewise.
* testsuite/27_io/objects/char/12048-3.cc: Likewise.
* testsuite/27_io/objects/char/12048-4.cc: Likewise.
* testsuite/27_io/objects/char/12048-5.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-1.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-2.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-3.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-4.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-5.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/char/12048-1.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/char/12048-2.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/char/12048-3.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/char/12048-4.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc: Likewise.

12 months agolibstdc++: Replace @require@ markup in some I/O tests
Jonathan Wakely [Wed, 17 Jul 2024 12:27:19 +0000 (13:27 +0100)] 
libstdc++: Replace @require@ markup in some I/O tests

We can replace the @require@ markup with { dg-additional-files ... }
directives, so that the required files are explicitly named and are
explicitly copied into place for tests that require it. This will allow
a later change to remove the "Copy all required data files" step in the
proc libstdc++_init in testsuite/lib/libstdc++.exp that is marked TODO.
This commit uses dg-additional-files for a subset of the files that
contain @require@.

Also remove the @diff@ markup where appears to be copy & pasted from
other test files, and so serves no purpose. For example, there is no
output file created by 27_io/basic_ifstream/cons/char/1.cc so there is
nothing for @diff@ to compare. Maybe the purpose was to check that
reading the .tst file with an ifstream doesn't change it, but we've
survived without doing those comparisons for many years so I think we
can remove those cases of @diff@ markup.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_filebuf/close/char/2.cc: Remove
@require@ and @diff@ markup. Use dg-additional-files. Remove
unused variable.
* testsuite/27_io/basic_filebuf/close/char/3.cc: Remove
@require@ and @diff@ markup. Use dg-additional-files.
* testsuite/27_io/basic_filebuf/close/char/4.cc: Likewise.
* testsuite/27_io/basic_filebuf/close/char/5.cc: Likewise.
* testsuite/27_io/basic_filebuf/in_avail/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/is_open/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/open/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/open/char/2.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/1-in.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/2-in.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputn/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Likewise.
Remove unused variable.
* testsuite/27_io/basic_filebuf/sputn/char/2-in.cc: Remove
@require@ and @diff@ markup. Use dg-additional-files.
* testsuite/27_io/basic_filebuf/sungetc/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sungetc/char/2-in.cc: Likewise.
* testsuite/27_io/basic_ifstream/cons/char/1.cc: Likewise.
* testsuite/27_io/basic_ifstream/open/char/1.cc: Likewise.
* testsuite/27_io/basic_ifstream/rdbuf/char/2832.cc: Likewise.
* testsuite/27_io/basic_istream/readsome/char/6746-2.cc:
Likewise.
* testsuite/27_io/basic_istream/readsome/wchar_t/6746-2.cc:
Likewise.
* testsuite/27_io/basic_istream/seekg/char/sstream.cc: Likewise.
* testsuite/27_io/basic_istream/seekg/wchar_t/sstream.cc:
Likewise.
* testsuite/27_io/basic_istream/tellg/char/1.cc: Likewise.
* testsuite/27_io/basic_istream/tellg/char/sstream.cc: Likewise.
* testsuite/27_io/basic_istream/tellg/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_istream/tellg/wchar_t/sstream.cc:
Likewise.
* testsuite/27_io/basic_ofstream/open/char/1.cc: Likewise.
* testsuite/lib/dg-options.exp (dg-additional-files): Append to
v3_additional_files instead of replacing.
* testsuite/lib/libstdc++.exp (v3_target_compile): Reset
v3_additional_files after copying files.

12 months agolibstdc++: Clean up @diff@ markup in some I/O tests
Jonathan Wakely [Mon, 22 Jul 2024 12:00:26 +0000 (13:00 +0100)] 
libstdc++: Clean up @diff@ markup in some I/O tests

We have a number of 27_io/* tests with comments like this:

// @require@ %-*.tst
// @diff@ %-*.tst %-*.txt

It seems that these declare required data files used by the test and a
post-test action to compare the test output with the expected result.
We do have tests that depend on some *.tst and/or *.txt files that are
copied from testsuite/data into each test's working directory before it
runs, so the comments are related to those dependencies.  However,
nothing in the current test framework actually makes use of these
comments. Currently, every test gets a fresh copy of every *.tst and
*.txt file in the testsuite/data directory, whether the test actually
requires them or not.

This change is the first in a series to clean up this unused markup in
the tests. This first step is to just remove all @require@ and @diff@
comments where they seem to serve no purpose at all. These tests do not
open any of the *.tst or *.txt files that are copied into the test's
working directory from the testsuite/data directory, so they don't
"require" any of those files, and there's no need to "diff" them after
the test runs.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_filebuf/close/char/4879.cc: Remove
@require@ and @diff@ comments.
* testsuite/27_io/basic_filebuf/close/char/9964.cc: Likewise.
* testsuite/27_io/basic_filebuf/open/char/3.cc: Likewise.
* testsuite/27_io/basic_filebuf/open/char/9507.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/2-io.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/2-out.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputn/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sungetc/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sungetc/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Likewise.
Remove unused variable.
* testsuite/27_io/basic_filebuf/sputn/char/2-io.cc: Likewise.
* testsuite/27_io/basic_ofstream/cons/char/1.cc: Remove
@require@ and @diff@ comments. Remove unused variables.
* testsuite/27_io/basic_ofstream/rdbuf/char/2832.cc: Remove
* testsuite/27_io/ios_base/sync_with_stdio/2.cc: Likewise.

12 months ago[MAINTAINERS] Update email and move to DCO
Matthew Malcomson [Tue, 23 Jul 2024 13:56:41 +0000 (14:56 +0100)] 
[MAINTAINERS] Update email and move to DCO

* MAINTAINERS: Update my email address.

Signed-off-by: Matthew Malcomson <mmalcomson@nvidia.com>
12 months agoRISC-V: Disable Zba optimization pattern if XTheadMemIdx is enabled
Christoph Müllner [Tue, 23 Jul 2024 12:48:02 +0000 (14:48 +0200)] 
RISC-V: Disable Zba optimization pattern if XTheadMemIdx is enabled

It is possible that the Zba optimization pattern zero_extendsidi2_bitmanip
matches for a XTheadMemIdx INSN with the effect of emitting an invalid
instruction as reported in PR116035.

The pattern above is used to emit a zext.w instruction to zero-extend
SI mode registers to DI mode.  A similar functionality can be achieved
by XTheadBb's th.extu instruction.  And indeed, we have the equivalent
pattern in thead.md (zero_extendsidi2_th_extu).  However, that pattern
depends on !TARGET_XTHEADMEMIDX.  To compensate for that, there are
specific patterns that ensure that zero-extension instruction can still
be emitted (th_memidx_bb_zero_extendsidi2 and friends).

While we could implement something similar (th_memidx_zba_zero_extendsidi2)
it would only make sense, if there existed real HW that does implement Zba
and XTheadMemIdx, but not XTheadBb.  Unless such a machine exists, let's
simply disable zero_extendsidi2_bitmanip if XTheadMemIdx is available.

PR target/116035

gcc/ChangeLog:

* config/riscv/bitmanip.md: Disable zero_extendsidi2_bitmanip
for XTheadMemIdx.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr116035-1.c: New test.
* gcc.target/riscv/pr116035-2.c: New test.

Reported-by: Patrick O'Neill <patrick@rivosinc.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
12 months agox86: Don't enable APX_F in 32-bit mode
Lingling Kong [Wed, 24 Jul 2024 06:52:47 +0000 (14:52 +0800)] 
x86: Don't enable APX_F in 32-bit mode

gcc/ChangeLog:

PR target/115978
* config/i386/driver-i386.cc (host_detect_local_cpu):  Enable
APX_F only for 64-bit codegen.
* config/i386/i386-options.cc (DEF_PTA):  Skip PTA_APX_F if
not in 64-bit mode.

gcc/testsuite/ChangeLog:

PR target/115978
* gcc.target/i386/pr115978-1.c: New test.
* gcc.target/i386/pr115978-2.c: Ditto.

12 months agoInternal-fn: Only allow modes describe types for internal fn[PR115961]
Pan Li [Thu, 18 Jul 2024 09:23:36 +0000 (17:23 +0800)] 
Internal-fn: Only allow modes describe types for internal fn[PR115961]

The direct_internal_fn_supported_p has no restrictions for the type
modes.  For example the bitfield like below will be recog as .SAT_TRUNC.

struct e
{
  unsigned pre : 12;
  unsigned a : 4;
};

__attribute__((noipa))
void bug (e * v, unsigned def, unsigned use) {
  e & defE = *v;
  defE.a = min_u (use + 1, 0xf);
}

This patch would like to add checks for the direct_internal_fn_supported_p,
and only allows the tree types describled by modes.

The below test suites are passed for this patch:
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.

PR target/115961

gcc/ChangeLog:

* internal-fn.cc (type_strictly_matches_mode_p): Add new func
impl to check type strictly matches mode or not.
(type_pair_strictly_matches_mode_p): Ditto but for tree type
pair.
(direct_internal_fn_supported_p): Add above check for the tree
type pair.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr115961-run-1.C: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
12 months ago[PR rtl-optimization/115877][6/n] Add testcase from pr115877
Jeff Law [Wed, 24 Jul 2024 01:11:04 +0000 (19:11 -0600)] 
[PR rtl-optimization/115877][6/n] Add testcase from pr115877

This just adds the testcase from pr115877.  It's working now on the trunk.  I'm
not done with cleanups/bugfixing, but there's no reason to not have the
testcase installed at this point.

PR rtl-optimization/115877
gcc/testsuite
* gcc.dg/torture/pr115877.c: New test.

12 months agoDaily bump.
GCC Administrator [Wed, 24 Jul 2024 00:18:20 +0000 (00:18 +0000)] 
Daily bump.

12 months agoOutput CodeView type information for rvalue references
Mark Harmstone [Sat, 20 Jul 2024 19:18:14 +0000 (20:18 +0100)] 
Output CodeView type information for rvalue references

Translates DW_TAG_rvalue_reference_type DIEs into LF_POINTER types.

gcc/
* dwarf2codeview.cc (get_type_num_reference_type): Handle rvalue refs.
(get_type_num_array_type): Add DW_TAG_rvalue_reference_type to switch.
(get_type_num): Handle DW_TAG_rvalue_reference_type DIEs.
* dwarf2codeview.h (CV_PTR_MODE_RVREF): Define.

12 months agoOutput CodeView type information for references
Mark Harmstone [Sat, 20 Jul 2024 19:12:30 +0000 (20:12 +0100)] 
Output CodeView type information for references

Translates DW_TAG_reference_type DIEs into LF_POINTER types.

gcc/
* dwarf2codeview.cc (get_type_num_reference_type): New function.
(get_type_num_array_type): Add DW_TAG_reference_type to switch.
(get_type_num): Handle DW_TAG_reference_type DIEs.
* dwarf2codeview.h (CV_PTR_MODE_LVREF): Define.

12 months agoRISC-V: Fix snafu in SI mode splitters patch
Vineet Gupta [Tue, 23 Jul 2024 22:12:11 +0000 (15:12 -0700)] 
RISC-V: Fix snafu in SI mode splitters patch

SPEC2017 perlbench for RISC-V was broke as runtime output mismatch
failure.

> 3830:  mbox2: dWshe3Aa1EULre4CT5O/ErYFrk+o/EOoebA1kTVjQVQQH2EjT5fHcYnwjj2MdBmZu5y3Ce4Ei4QQZo/SNrry9g
>        mbox2: uuWPimQiU0D4UrwFP+LS0lFNph4qL43WV1A6T3tHleatIOUaHixhrJU9NoA2lc9KjwYpdEL0lNTXkvo8ymNHzA
>               ^
> 3832:  mbox3: 8f4jdv6GIf0lX3DcdwRdEm6/aZwnmGX6n86GzCvmkwTKFXQjwlwVHc8jy8XlcyiIPr3yXTkgVOiP3cRYvyYQPg
>        mbox3: 9xQySgP6qbhfxl8Usu1WfGA5UhStB5AN31wueGM6OF4Jp59DkqJPu6ksGblOU5u0nQapQC1e9oYIs16a2mq2NA
>               ^
> specdiff run completed

Edwin bisected this to 273f16a125c4 ("[v3][RISC-V] Handle bit
manipulation of SImode values") which had the operands swapped in one
of the new splitters introduced.

No test as reducer narrows it to down to the exact test introduced by
the original commit.

gcc/ChangeLog:
* config/riscv/bitmanip.md: Fix splitter.

Reported-by: Edwin Lu <ewlu@rivosinc.com>
Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
12 months agodoc: add missing @option for musttail
Marek Polacek [Tue, 23 Jul 2024 20:32:20 +0000 (16:32 -0400)] 
doc: add missing @option for musttail

gcc/ChangeLog:

* doc/extend.texi: Add missing @option.

12 months agoAdd documentation for musttail attribute
Andi Kleen [Wed, 24 Jan 2024 07:38:23 +0000 (23:38 -0800)] 
Add documentation for musttail attribute

gcc/ChangeLog:

PR c/83324
* doc/extend.texi: Document [[musttail]]

12 months agoAdd tests for C/C++ musttail attributes
Andi Kleen [Wed, 24 Jan 2024 07:54:56 +0000 (23:54 -0800)] 
Add tests for C/C++ musttail attributes

Some adopted from the existing C musttail plugin tests.
Also extends the ability to query the sibcall capabilities of the
target.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp:
(check_effective_target_struct_tail_call): New function.
* c-c++-common/musttail1.c: New test.
* c-c++-common/musttail12.c: New test.
* c-c++-common/musttail13.c: New test.
* c-c++-common/musttail2.c: New test.
* c-c++-common/musttail3.c: New test.
* c-c++-common/musttail4.c: New test.
* c-c++-common/musttail5.c: New test.
* c-c++-common/musttail7.c: New test.
* c-c++-common/musttail8.c: New test.
* g++.dg/musttail10.C: New test.
* g++.dg/musttail11.C: New test.
* g++.dg/musttail6.C: New test.
* g++.dg/musttail9.C: New test.

12 months agoC: Implement musttail attribute for returns
Andi Kleen [Wed, 24 Jan 2024 15:44:23 +0000 (07:44 -0800)] 
C: Implement musttail attribute for returns

Implement a C23 clang compatible musttail attribute similar to the earlier
C++ implementation in the C parser.

gcc/c/ChangeLog:

PR c/83324
* c-parser.cc (struct attr_state): Define with musttail_p.
(c_parser_statement_after_labels): Handle [[musttail]].
(c_parser_std_attribute): Dito.
(c_parser_handle_musttail): Dito.
(c_parser_compound_statement_nostart): Dito.
(c_parser_all_labels): Dito.
(c_parser_statement): Dito.
* c-tree.h (c_finish_return): Add musttail_p flag.
* c-typeck.cc (c_finish_return): Handle musttail_p flag.

12 months agoC++: Support clang compatible [[musttail]] (PR83324)
Andi Kleen [Wed, 24 Jan 2024 07:44:48 +0000 (23:44 -0800)] 
C++: Support clang compatible [[musttail]] (PR83324)

This patch implements a clang compatible [[musttail]] attribute for
returns.

musttail is useful as an alternative to computed goto for interpreters.
With computed goto the interpreter function usually ends up very big
which causes problems with register allocation and other per function
optimizations not scaling. With musttail the interpreter can be instead
written as a sequence of smaller functions that call each other. To
avoid unbounded stack growth this requires forcing a sibling call, which
this attribute does. It guarantees an error if the call cannot be tail
called which allows the programmer to fix it instead of risking a stack
overflow. Unlike computed goto it is also type-safe.

It turns out that David Malcolm had already implemented middle/backend
support for a musttail attribute back in 2016, but it wasn't exposed
to any frontend other than a special plugin.

This patch adds a [[gnu::musttail]] attribute for C++ that can be added
to return statements. The return statement must be a direct call
(it does not follow dependencies), which is similar to what clang
implements. It then uses the existing must tail infrastructure.

For compatibility it also detects clang::musttail

Passes bootstrap and full test

gcc/c-family/ChangeLog:

* c-attribs.cc (set_musttail_on_return): New function.
* c-common.h (set_musttail_on_return): Declare new function.

gcc/cp/ChangeLog:

PR c/83324
* cp-tree.h (AGGR_INIT_EXPR_MUST_TAIL): Add.
* parser.cc (cp_parser_statement): Handle musttail.
(cp_parser_jump_statement): Dito.
* pt.cc (tsubst_expr): Copy CALL_EXPR_MUST_TAIL_CALL.
* semantics.cc (simplify_aggr_init_expr): Handle musttail.

12 months agoc++: normalizing ttp constraints [PR115656]
Patrick Palka [Tue, 23 Jul 2024 17:16:14 +0000 (13:16 -0400)] 
c++: normalizing ttp constraints [PR115656]

Here we normalize the constraint same_as<T, bool> for the first
time during ttp coercion of B / UU, specifically constraint subsumption
checking.  During this normalization the set of in-scope template
parameters i.e. current_template_parms is empty, which we rely on
during normalization of the ttp constraints since we pass in_decl=NULL_TREE
to norm_info.  And this tricks the satisfaction cache into thinking that
the satisfaction value of same_as<T, bool> is independent of its template
parameters, and we incorrectly conflate the satisfaction value with
T = bool vs T = long and accept the specialization A<long, B>.

Since is_compatible_template_arg rewrites the ttp's constraints to
be in terms of the argument template's parameters, and since it's
the only caller of weakly_subsumes, the latter funcion can instead
pass in_decl=tmpl to avoid relying on current_template_parms.  This
patch implements this, and in turns renames weakly_subsumes to
ttp_subsumes to reflect that this predicate is now hardcoded for this
one caller.

PR c++/115656

gcc/cp/ChangeLog:

* constraint.cc (weakly_subsumes): Pass in_decl=tmpl to
get_normalized_constraints_from_info.  Rename to ...
(ttp_subsumes): ... this.
* cp-tree.h (weakly_subsumes): Rename to ...
(ttp_subsumes): ... this.
* pt.cc (is_compatible_template_arg): Adjust after renaming.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-ttp7.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
12 months agoc++: missing SFINAE during alias CTAD [PR115296]
Patrick Palka [Tue, 23 Jul 2024 15:37:31 +0000 (11:37 -0400)] 
c++: missing SFINAE during alias CTAD [PR115296]

During the alias CTAD transformation, if substitution failed for some
guide we should just silently discard the guide.  We currently do
discard the guide, but not silently, as in the below testcase which
we diagnose forming a too-large array type when transforming the
user-defined deduction guides.

This patch fixes this by using complain=tf_none instead of
tf_warning_or_error throughout alias_ctad_tweaks.

PR c++/115296

gcc/cp/ChangeLog:

* pt.cc (alias_ctad_tweaks): Use complain=tf_none instead of
tf_warning_or_error.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias23.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
12 months agoPR modula2/116048 ICE when encountering wrong kind of qualident
Gaius Mulley [Tue, 23 Jul 2024 14:54:16 +0000 (15:54 +0100)] 
PR modula2/116048 ICE when encountering wrong kind of qualident

Following on from PR-115957 further ICEs can be generated by using the
wrong kind of qualident symbol.  For example using a variable instead of
a type or using a type instead of a const.  This fix tracks the expected
qualident kind state when parsing const, type and variable declarations.
If the error is unrecoverable then a detailed message explaining the
context of the qualident (and why the seen qualident is wrong) is
generated.

gcc/m2/ChangeLog:

PR modula2/116048
* Make-lang.in (GM2-COMP-BOOT-DEFS): Add M2StateCheck.def.
(GM2-COMP-BOOT-MODS): Add M2StateCheck.mod.
(GM2-COMP-DEFS): Add M2StateCheck.def.
(GM2-COMP-MODS): Add M2StateCheck.mod.
* gm2-compiler/M2Quads.mod (StartBuildWith): Generate
unrecoverable error is the qualident type is NulSym.
Replace MetaError1 with MetaErrorT1 and position the error
to the qualident.
* gm2-compiler/P3Build.bnf (M2StateCheck): Import procedures.
(seenError): New variable.
(WasNoError): Remove variable.
(BlockState): New variable.
(ErrorString): Rewrite using seenError.
(CompilationUnit): Ditto.
(QualidentCheck): New rule.
(ConstantDeclaration): Bookend with InclConst and ExclConst.
(Constructor): Add InclConstructor, ExclConstructor and call
CheckQualident.
(ConstActualParameters): Call PushState, PopState, InclConstFunc
and CheckQualident.
(TypeDeclaration): Bookend with InclType and ExclType.
(SimpleType): Call QualidentCheck.
(CaseTag): Ditto.
(OptReturnType): Ditto.
(VariableDeclaration): Bookend with InclVar and ExclVar.
(Designator): Call QualidentCheck.
(Formal;Type): Ditto.
* gm2-compiler/PCBuild.bnf (M2StateCheck): Import procedures.
(ConstantDeclaration): Rewrite using InclConst and ExclConst.
(Constructor): Bookend with InclConstructor and ExclConstructor.
Call CheckQualident.
(ConstructorOrConstActualParameters): Rewrite and cal
l CheckQualident.
(ConstActualParameters): Bookend with PushState PopState.
Call InclConstFunc and CheckQualident.
* gm2-gcc/init.cc (_M2_M2StateCheck_init): New declaration.
(_M2_P3Build_init): New declaration.
(init_PerCompilationInit): Call _M2_M2StateCheck_init and
_M2_P3Build_init.
* gm2-compiler/M2StateCheck.def: New file.
* gm2-compiler/M2StateCheck.mod: New file.

gcc/testsuite/ChangeLog:

PR modula2/116048
* gm2/errors/fail/errors-fail.exp: Remove -Wstudents
and add -Wuninit-variable-checking=all.
Replace gm2_init_pim with gm2_init_iso.
* gm2/errors/fail/testfio.mod: Modify test code to
provoke an error in the first basic block.
* gm2/errors/fail/testparam.mod: Ditto.
* gm2/errors/fail/array1.mod: Ditto.
* gm2/errors/fail/badtype.mod: New test.
* gm2/errors/fail/badvar.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
12 months agocp/coroutines: add a test for PR c++/103953
Arsen Arsenović [Tue, 23 Jul 2024 11:01:03 +0000 (13:01 +0200)] 
cp/coroutines: add a test for PR c++/103953

This PR seems to have been fixed by a fix for a seemingly unrelated PR.
Lets add a regression test to make sure it stays fixed.

PR c++/103953 - Leak of coroutine return object

PR c++/103953

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/torture/pr103953.C: New test.

Reviewed-by: Iain Sandoe <iain@sandoe.co.uk>
12 months agoinstall.texi (gcn): Suggest newer commit for Newlib
Tobias Burnus [Tue, 23 Jul 2024 10:41:40 +0000 (12:41 +0200)] 
install.texi (gcn): Suggest newer commit for Newlib

Newlib 4.4.0 lacks two commits: 7dd4eb1db (2024-03-25) to fix device console
output for GFX10/GFX11 and ed50a50b9 (2024-04-04) to make the added lock.h
compilable with C++. This commit mentiones now also the second commit.

gcc/ChangeLog:

* doc/install.texi (amdgcn-x-amdhsa): Suggest newer git version
for newlib.

12 months agoreport message for operator %a on unaddressible operand
Jiufu Guo [Tue, 23 Jul 2024 05:34:20 +0000 (13:34 +0800)] 
report message for operator %a on unaddressible operand

Hi,

For PR96866, when printing asm code for modifier "%a", an addressable
operand is required.  While the constraint "X" allow any kind of
operand even which is hard to get the address directly. e.g. extern
symbol whose address is in TOC.
An error message would be reported to indicate the invalid asm operand.

Compare with previous version, test case is updated with -mno-pcrel.

Bootstrap&regtest pass on ppc64{,le}.
Is this ok for trunk?

BR,
Jeff(Jiufu Guo)

PR target/96866

gcc/ChangeLog:

* config/rs6000/rs6000.cc (print_operand_address): Emit message for
unsupported operand.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr96866-1.c: New test.
* gcc.target/powerpc/pr96866-2.c: New test.