platform/upstream/gcc.git
16 months agogccrs: ast: dump TypeAlias
Jakub Dupak [Fri, 14 Oct 2022 10:38:19 +0000 (12:38 +0200)]
gccrs: ast: dump TypeAlias

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Add code for dumping type aliases.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
16 months agogccrs: Refactor TraitResolver to not require a visitor
Philip Herron [Fri, 14 Oct 2022 13:00:16 +0000 (14:00 +0100)]
gccrs: Refactor TraitResolver to not require a visitor

gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-resolve.cc (TraitResolver::TraitResolver): Do not nullptr init
`resolved_trait_reference` anymore.
(TraitResolver::resolve_path): Simplify function and rename to...
(TraitResolver::resolve_path_to_trait): ...this.
(TraitResolver::lookup_path): Use new interface.
* typecheck/rust-hir-trait-resolve.h (class TraitResolver): Do not inherit `HIRFullVisitor`
class anymore.

16 months agogccrs: ast: dump: RangeExprs
David Faust [Thu, 13 Oct 2022 17:23:44 +0000 (10:23 -0700)]
gccrs: ast: dump: RangeExprs

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Add dump for RangeExprs.

16 months agogccrs: ast: dump: various simple Exprs
David Faust [Thu, 13 Oct 2022 17:15:05 +0000 (10:15 -0700)]
gccrs: ast: dump: various simple Exprs

Adds dump for:
- BorrowExpr
- DereferenceExpr
- ErrorPropagationExpr
- NegationExpr
- TypeCastExpr
- GroupedExpr

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Add dump for, BorrowExpr, DereferenceExpr,
ErrorPropagationExpr, NegationExpr, TypeCastExpr and GroupedExpr.

16 months agogccrs: ast: dump: ArrayExpr
David Faust [Thu, 13 Oct 2022 17:14:38 +0000 (10:14 -0700)]
gccrs: ast: dump: ArrayExpr

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Add dump code for ArrayExpr.

16 months agogccrs: ast: dump: ComparisonExpr and LazyBooleanExpr
David Faust [Thu, 13 Oct 2022 16:28:33 +0000 (09:28 -0700)]
gccrs: ast: dump: ComparisonExpr and LazyBooleanExpr

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Add dumps for ComparisonExpr and
LazyBooleanExpr.

16 months agogccrs: ast: dump: minor fixups to IfExpr formatting
David Faust [Thu, 13 Oct 2022 16:27:35 +0000 (09:27 -0700)]
gccrs: ast: dump: minor fixups to IfExpr formatting

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Fix IfExpr formatting.

16 months agogccrs: ast: dump: fix extra newline in block without tail
David Faust [Thu, 13 Oct 2022 16:25:57 +0000 (09:25 -0700)]
gccrs: ast: dump: fix extra newline in block without tail

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Fix block formatting.

16 months agogccrs: Method resolution must support multiple candidates
Philip Herron [Thu, 13 Oct 2022 09:10:37 +0000 (10:10 +0100)]
gccrs: Method resolution must support multiple candidates

This patch fixes bad method resolution in our operator_overload_9 case.
When we have a &mut reference to something and we deref we must resolve to
the mutable reference impl block. The interface we are using to resolve
methods is the can_eq interface which allows for permissive mutability
which means allowing for mutable reference being unified with an immutable
one. This meant we actual match against both the immutable and mutable
version leading to multiple candidate error.

The fix here adds a method resolution flag to the can_eq interface so that
we enforce mutability equality. The other hack is that we do not allow
can_eq of ParamTypes to generic Slices. I think there is some subtle thing
going on for that case. The Rustc method resolver actually filters the
impl blocks for reference types based looking up the relevant lang items
we need to do this as well but is a much larger refactor to our method
resolver which should be done seperately.

Fixes #1588

gcc/rust/ChangeLog:

* typecheck/rust-autoderef.cc: Add support for multiple resolution candidates.
* typecheck/rust-hir-dot-operator.cc (MethodResolver::MethodResolver): Edit
`try_result` field and change constructor.
(MethodResolver::Probe): Return set of candidates instead of singular candidate.
(MethodResolver::select): Add better implementation to account for multiple
candidates.
* typecheck/rust-hir-dot-operator.h (struct MethodCandidate): Overload comparison
operator in order to store them in `std::set`.
* typecheck/rust-hir-inherent-impl-overlap.h: Do not fail assertion on missing type.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Adapt code to use
multiple candidates.
* typecheck/rust-tyty.cc (set_cmp_autoderef_mode): Add code to handle automatic
derefs properly.
(reset_cmp_autoderef_mode): Add helper function to reset said mode.
* typecheck/rust-tyty.h (set_cmp_autoderef_mode): Declare function.
(reset_cmp_autoderef_mode): Likewise.
* typecheck/rust-tyty-cmp.h: Add handling of `autoderef_cmp_flag`

gcc/testsuite/ChangeLog:

* rust/compile/generics7.rs: Fix test with missing assertion.
* rust/execute/torture/operator_overload_9.rs: Fix test assertion.

16 months agogccrs: Add ABI mappings for rust-call to map to ABI::RUST
Philip Herron [Wed, 12 Oct 2022 11:26:24 +0000 (12:26 +0100)]
gccrs: Add ABI mappings for rust-call to map to ABI::RUST

gcc/rust/ChangeLog:

* util/rust-abi.cc (get_abi_from_string): Add missing "rust-call"
possibility for ABI variant.

16 months agogccrs: Add mappings for fn_once lang item
Philip Herron [Wed, 12 Oct 2022 11:25:52 +0000 (12:25 +0100)]
gccrs: Add mappings for fn_once lang item

gcc/rust/ChangeLog:

* util/rust-lang-item.h: Add `fn_once` lang item.

16 months agogccrs: Support type resolution on super traits on dyn objects
Philip Herron [Thu, 6 Oct 2022 13:46:17 +0000 (14:46 +0100)]
gccrs: Support type resolution on super traits on dyn objects

When checking if specified bounds satisfy other bounds we must lookup the
super traits. To finish the support for super traits we need to redo the
computation of method addresses to support super traits.

Addresses #914

gcc/rust/ChangeLog:

* backend/rust-compile.cc: Add note about missing support for super
traits.
* typecheck/rust-tyty.cc (BaseType::satisfies_bound): New function.
(BaseType::bounds_compatible): New function.
(DynamicObjectType::get_object_items): New function.
* typecheck/rust-hir-trait-ref.h: Use new API to perform type resolution
on dyn objects.

16 months agogccrs: early-name-resolver: Add simple macro name resolution
Arthur Cohen [Tue, 11 Oct 2022 09:12:50 +0000 (11:12 +0200)]
gccrs: early-name-resolver: Add simple macro name resolution

This name resolver performs the same macro name resolution as what was
previously done by the AttrVisitor visitor and macro expander.

It also resolves macro expressions in builtin-macros properly, as well
as expanded AST nodes when necessary.

gcc/rust/ChangeLog:

* Make-lang.in: Compile early name resolver.
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Move macro
name resolution.
* expand/rust-macro-builtins.cc (try_expand_macro_expression): Run ENR
when recursively expanding macros.
* expand/rust-macro-expand.cc (MacroExpander::expand_invoc): No longer
perform name resolution in `expand_invoc`.
* expand/rust-macro-expand.h (struct MacroExpander): Keep ENR within
MacroExpander.
* rust-session-manager.cc (Session::expansion): Run ENR.
* resolve/rust-early-name-resolver.cc: New file.
* resolve/rust-early-name-resolver.h: New file.

16 months agogccrs: ast: Add accept_vis() method to `GenericArg`
Arthur Cohen [Tue, 11 Oct 2022 13:54:07 +0000 (15:54 +0200)]
gccrs: ast: Add accept_vis() method to `GenericArg`

gcc/rust/ChangeLog:

* ast/rust-path.h: Add `accept_vis` method to `GenericArg` class.

16 months agogccrs: rust-ast-resolve-item: Add note about resolving glob uses
Arthur Cohen [Tue, 11 Oct 2022 09:39:15 +0000 (11:39 +0200)]
gccrs: rust-ast-resolve-item: Add note about resolving glob uses

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Add note for
glob import resolving.

16 months agogccrs: mappings: Add MacroInvocation -> MacroRulesDef mappings
Arthur Cohen [Tue, 11 Oct 2022 09:38:55 +0000 (11:38 +0200)]
gccrs: mappings: Add MacroInvocation -> MacroRulesDef mappings

gcc/rust/ChangeLog:

* util/rust-hir-map.h: Add new mappings.
* util/rust-hir-map.cc (Mappings::insert_macro_invocation): Add insertion
function into mappings.
(Mappings::lookup_macro_invocation): Add lookup function for mappings.

16 months agogccrs: fix ICE on missing closing paren
Marc Poulhiès [Fri, 7 Oct 2022 16:48:36 +0000 (18:48 +0200)]
gccrs: fix ICE on missing closing paren

Fix crash (segfault) on a missing closing parenthesis when parsing the
expressions in a block. The returned `expr` was missing a check before being
used.

Add corresponding test.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_stmt_or_expr_without_block):
Check if `expr` is valid after parsing it.

gcc/testsuite/ChangeLog:

* rust/compile/missing_closing_paren.rs: New test.

16 months agogccrs: intrinsics: Add data prefetching intrinsics
Arthur Cohen [Wed, 5 Oct 2022 15:49:44 +0000 (17:49 +0200)]
gccrs: intrinsics: Add data prefetching intrinsics

gcc/rust/ChangeLog:

* backend/rust-builtins.cc (BuiltinsContext::setup): Declare prefetch
intrinsics.
* backend/rust-compile-intrinsic.cc (enum class Prefetch): Add kinds of
prefetch intrinsics.
(prefetch_data_handler): New function.
(prefetch_read_data): Likewise.
(prefetch_write_data): Likewise.

gcc/testsuite/ChangeLog:

* rust/execute/torture/prefetch_data.rs: New test.

16 months agogccrs: ast: dump structs, enums and unions
David Faust [Thu, 6 Oct 2022 18:32:17 +0000 (11:32 -0700)]
gccrs: ast: dump structs, enums and unions

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Fill empty functions for
structs, enums and unions.

16 months agogccrs: ast: dump: add format_{tuple,struct}_field helpers
David Faust [Thu, 6 Oct 2022 20:43:06 +0000 (13:43 -0700)]
gccrs: ast: dump: add format_{tuple,struct}_field helpers

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::format_tuple_field): New.
(Dump::format_struct_field): New.
* ast/rust-ast-dump.h (format_tuple_field): New.
(format_struct_field): New.

16 months agogccrs: ast: dump: add emit_generic_params helper
David Faust [Thu, 6 Oct 2022 18:32:02 +0000 (11:32 -0700)]
gccrs: ast: dump: add emit_generic_params helper

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): move generic params dump ...
(Dump::emit_generic_params): ... here.
* ast/rust-ast-dump.h (emit_generic_params): New.

16 months agogccrs: Support looking up super traits for trait items
Philip Herron [Wed, 5 Oct 2022 16:24:42 +0000 (17:24 +0100)]
gccrs: Support looking up super traits for trait items

When supporting calls to super traits we need to allow lookups based on
the super traits as specified on the TraitReferences.

Fixes #1555

gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-ref.h (lookup_trait_item): Add lookup
in super_trait.

gcc/testsuite/ChangeLog:

* rust/compile/torture/issue-1555.rs: New test.

16 months agogccrs: Ensure uniqueness on Path probe's
Philip Herron [Wed, 5 Oct 2022 16:24:26 +0000 (17:24 +0100)]
gccrs: Ensure uniqueness on Path probe's

When we lookup names in paths such as Foo::bar, foo is a type we resolve
and then we lookup 'bar' based on what type Foo is which includes probing
relevant bounds of this type. We currently return a vector of possible
candidates and this patch changes it so that we return a set of unique
items based on DefId.

Addresses #1555

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc
(CompileExpr::resolve_method_address): Use auto and minor change
in candidate init.
* typecheck/rust-hir-type-check-path.cc
(TypeCheckExpr::resolve_segments): Likewise.
* typecheck/rust-hir-type-check-type.cc: Likewise.
* backend/rust-compile-resolve-path.cc
(HIRCompileBase::query_compile): Likewise. Removecall to
set_ty_ref.
* typecheck/rust-hir-path-probe.h (struct PathProbeCandidate): Add
locus initializer in ctor, implement get_defid.
(class PathProbeType::Probe): return a set instead of vector.
Adjust class impl.
(class ReportMultipleCandidateError): Do not inherit from
HIRImplVisitor anymore and remove corresponding impl. Adjust for
change in Probe. Simplify Report handling.
(class PathProbeImplTrait::Probe): Adjust return type.

16 months agogccrs: Track DefId on ADT variants
Philip Herron [Wed, 5 Oct 2022 16:22:43 +0000 (17:22 +0100)]
gccrs: Track DefId on ADT variants

We must track the DefID on variants for algebraic data types as this will
allow us to enforce unique'ness on path queries relating to this.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-enumitem.cc
(TypeCheckEnumItem::visit): Adjust VariantDef ctor calls with
DefID.
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):
Likewise.
* typecheck/rust-tyty.h (VariantDef): Add defid parameter to ctor.

16 months agogccrs: builtins: Move implementation into source file
Arthur Cohen [Thu, 6 Oct 2022 08:19:11 +0000 (10:19 +0200)]
gccrs: builtins: Move implementation into source file

gcc/rust/ChangeLog:

* Make-lang.in: Add `rust-builtins.o` as target
* backend/rust-builtins.h: Refactor to new file.
* backend/rust-builtins.cc: New file.

16 months agogccrs: ast: dump If expressions
David Faust [Wed, 5 Oct 2022 17:11:38 +0000 (10:11 -0700)]
gccrs: ast: dump If expressions

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Implement visitor for If
expressions.

16 months agogccrs: ast: dump assignment and compound assignment expr
David Faust [Wed, 5 Oct 2022 17:10:18 +0000 (10:10 -0700)]
gccrs: ast: dump assignment and compound assignment expr

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Dump assignment and compound
assignment expressions.

16 months agogccrs: testing: try loop in const function
Faisal Abbas [Mon, 3 Oct 2022 18:32:30 +0000 (19:32 +0100)]
gccrs: testing: try loop in const function

Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com>
gcc/testsuite/ChangeLog:

* rust/compile/const9.rs: New test.

Signed-off-by: Faisal Abbas <faisal.abbas@elastica.co>
16 months agogccrs: Add catch for recusive type queries
Philip Herron [Fri, 30 Sep 2022 12:41:09 +0000 (13:41 +0100)]
gccrs: Add catch for recusive type queries

When we have a type query where by generic substitution occurs we can hit
the case where we need to Probe the bounds of the substited item to
determine whether the the bounds are compatible this can cause us to
end up querying the same type recursively.

Fixes #1550

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::query_type):
Check for recursive queries.
* typecheck/rust-hir-type-check.h: New functions: `query_completed`,
`query_in_progress`, `insert_query`.
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): Use `query_type` API.

16 months agogccrs: dump: Emit visibility when dumping items
Arthur Cohen [Tue, 27 Sep 2022 13:50:39 +0000 (15:50 +0200)]
gccrs: dump: Emit visibility when dumping items

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::emit_visibility): New function.
(Dump::visit): Call into `emit_visibility`.
(Dump::format_function_common): Likewise.
* ast/rust-ast-dump.h: Declare `emit_visibility`.

16 months agogccrs: visibility: Rename get_public_vis_type -> get_vis_type
Arthur Cohen [Tue, 27 Sep 2022 13:49:59 +0000 (15:49 +0200)]
gccrs: visibility: Rename get_public_vis_type -> get_vis_type

gcc/rust/ChangeLog:

* ast/rust-item.h: Rename get_public_vis_type.
* hir/rust-ast-lower.cc (translate_visibility): Use new name.

16 months agogccrs: Fix missing dead code analysis ICE on local enum definition
Philip Herron [Tue, 27 Sep 2022 08:50:06 +0000 (09:50 +0100)]
gccrs: Fix missing dead code analysis ICE on local enum definition

When resolving local enum's within a Block the name resolution info is
not at the top of the stack so this patch introduces a new mappings class
for miscellaneous name resolutions which can be used during path analaysis.

Fixes #1272

gcc/rust/ChangeLog:

* resolve/rust-name-resolver.h: Add miscellenaous item mappings.
* resolve/rust-name-resolver.cc (Resolver::insert_resolved_misc): Use
new mappings.
(Resolver::lookup_resolved_misc): Likewise.
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments):
Adapt function to insert into miscelleanous mappings.
* checks/lints/rust-lint-marklive.cc (MarkLive::find_ref_node_id):
Allow lookup in miscelleanous mappings in mark-live phase.

gcc/testsuite/ChangeLog:

* rust/compile/issue-1272.rs: New test.

16 months agotree-optimization/108868 - new testcase
Richard Biener [Tue, 21 Feb 2023 09:32:10 +0000 (10:32 +0100)]
tree-optimization/108868 - new testcase

New testcase for the fixed bug.

PR tree-optimization/108868
* gcc.dg/pr108868.c: New testcase.

16 months agotree-optimization/108855 - new testcase
Richard Biener [Tue, 21 Feb 2023 09:31:29 +0000 (10:31 +0100)]
tree-optimization/108855 - new testcase

New testcase for the fixed bug.

PR tree-optimization/108855
* gcc.dg/pr108855.c: New testcase.

16 months agoRevert "tree-optimization/108691 - indirect calls to setjmp"
Richard Biener [Tue, 21 Feb 2023 09:26:30 +0000 (10:26 +0100)]
Revert "tree-optimization/108691 - indirect calls to setjmp"

This reverts commit 6436add49ed9ecf74f1f01b4fe18961df4f3e83d.

16 months agoxtensa: Enforce return address saving when -Og is specified
Takayuki 'January June' Suwa [Sat, 18 Feb 2023 04:54:10 +0000 (13:54 +0900)]
xtensa: Enforce return address saving when -Og is specified

Leaf function often omits saving its return address to the stack slot,
and this feature often makes debugging very confusing, especially for
stack dump analysis.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (xtensa_call_save_reg): Change to return
true if register A0 (return address register) when -Og is specified.

16 months agoDaily bump.
GCC Administrator [Tue, 21 Feb 2023 00:18:20 +0000 (00:18 +0000)]
Daily bump.

16 months agoi386: Introduce general_x64constmem_operand predicate
Uros Bizjak [Mon, 20 Feb 2023 22:17:20 +0000 (23:17 +0100)]
i386: Introduce general_x64constmem_operand predicate

Instructions that use high-part QImode registers can not be encoded
with REX prefix.  To avoid REX prefix, operand constraints allow
only legacy QImode registers, immediates and constant memory operands.
The patch introduces matching predicate, so invalid operands are not
combined into instruction RTX only to be later fixed up by reload pass.

2023-02-20  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

* config/i386/predicates.md
(general_x64constmem_operand): New predicate.
* config/i386/i386.md (*cmpqi_ext<mode>_1):
Use nonimm_x64constmem_operand.
(*cmpqi_ext<mode>_3): Use general_x64constmem_operand.
(*addqi_ext<mode>_1): Ditto.
(*testqi_ext<mode>_1): Ditto.
(*andqi_ext<mode>_1): Ditto.
(*andqi_ext<mode>_1_cc): Ditto.
(*<any_or:code>qi_ext<mode>_1): Ditto.
(*xorqi_ext<mode>_1_cc): Ditto.

17 months agopowerpc: Another umaddditi4 fix [PR108862]
Jakub Jelinek [Mon, 20 Feb 2023 21:07:57 +0000 (22:07 +0100)]
powerpc: Another umaddditi4 fix [PR108862]

The following testcase is miscompiled on powerpc64le-linux with
-O2 -mcpu=power9.  The problem is that gen_umaddditi4 is called with
the same TImode register for both op0 and op3, and maddlddi4
overwrites the low half of op0 before the low half of op3 is read,
so when they are the same register it reads the result of maddlddi4.

The following patch fixes that by swapping maddlddi4 and
umadddi4_highpart{,_le} during expansion, as the latter writes into
a temporary pseudo and so can't change anything maddlddi4 depends on.

2023-02-20  Jakub Jelinek  <jakub2redhat.com>

PR target/108862
* config/rs6000/rs6000.md (umaddditi4): Swap gen_maddlddi4 with
gen_umadddi4_highpart{,_le}.

* gcc.dg/pr108862.c: New test.
* gcc.target/powerpc/pr108862.c: New test.

17 months agolibstdc++: Update baseline symbols for m68k-linux
Andreas Schwab [Sat, 11 Feb 2023 10:30:45 +0000 (11:30 +0100)]
libstdc++: Update baseline symbols for m68k-linux

libstdc++-v3/:
* config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Update.

17 months agoc++: ICE with -fno-elide-constructors and trivial fn [PR101073]
Marek Polacek [Thu, 9 Feb 2023 00:13:18 +0000 (19:13 -0500)]
c++: ICE with -fno-elide-constructors and trivial fn [PR101073]

In constexpr-nsdmi3.C, with -fno-elide-constructors, we don't elide
the Y::Y(const Y&) call used to initialize o.c.  So store_init_value
-> cxx_constant_init must constexpr-evaluate the call to Y::Y(const Y&)
in cxx_eval_call_expression.  It's a trivial function, so we do the
"Shortcut trivial constructor/op=" code and rather than evaluating
the function, we just create an assignment

  o.c = *(const struct Y &) (const struct Y *) &(&<PLACEHOLDER_EXPR struct X>)->b

which is a MODIFY_EXPR, so the preeval code in cxx_eval_store_expression
clears .ctor and .object, therefore we can't replace the PLACEHOLDER_EXPR
whereupon we crash at

      /* A placeholder without a referent.  We can get here when
         checking whether NSDMIs are noexcept, or in massage_init_elt;
         just say it's non-constant for now.  */
      gcc_assert (ctx->quiet);

The PLACEHOLDER_EXPR can also be on the LHS as in constexpr-nsdmi10.C.
I don't think we can do much here, but I noticed that the whole
trivial_fn_p (fun) block is only entered when -fno-elide-constructors.
This is true since GCC 9; it wasn't easy to bisect what changes made it
so, but r240845 is probably one of them.  -fno-elide-constructors is an
option for experiments only so it's not clear to me why we'd still want
to shortcut trivial constructor/op=.  I propose to remove the code and
add a checking assert to make sure we're not getting a trivial_fn_p
unless -fno-elide-constructors.

PR c++/101073

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_call_expression): Replace shortcutting trivial
constructor/op= with a checking assert.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-nsdmi3.C: New test.
* g++.dg/cpp1y/constexpr-nsdmi10.C: New test.

17 months agolibstdc++: Fix uses of non-reserved names in simd header
Matthias Kretz [Thu, 16 Feb 2023 15:29:54 +0000 (16:29 +0100)]
libstdc++: Fix uses of non-reserved names in simd header

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd.h (__extract_part, split):
Use reserved name for template parameter.

17 months agolibstdc++: Update baseline symbols for riscv64-linux
Andreas Schwab [Sat, 11 Feb 2023 10:28:01 +0000 (11:28 +0100)]
libstdc++: Update baseline symbols for riscv64-linux

libstdc++-v3/
* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt: Update.

17 months agoRISC-V: prefetch.* only take base register with zero-offset for the address
Kito Cheng [Mon, 20 Feb 2023 13:47:01 +0000 (21:47 +0800)]
RISC-V: prefetch.* only take base register with zero-offset for the address

Catched by running gcc.c-torture/execute/builtin-prefetch-2.c with
-march=rv64gc_zicbop.

gcc/ChangeLog:

* config/riscv/riscv.md (prefetch): Use r instead of p for the
address operand.
(riscv_prefetchi_<mode>): Ditto.

17 months agoc++: ICE with redundant capture [PR108829]
Marek Polacek [Thu, 16 Feb 2023 22:41:24 +0000 (17:41 -0500)]
c++: ICE with redundant capture [PR108829]

Here we crash in is_capture_proxy:

  /* Location wrappers should be stripped or otherwise handled by the
     caller before using this predicate.  */
  gcc_checking_assert (!location_wrapper_p (decl));

We only crash with the redundant capture:

  int abyPage = [=, abyPage] { ... }

because prune_lambda_captures is only called when there was a default
capture, and with [=] only abyPage won't be in LAMBDA_EXPR_CAPTURE_LIST.

The problem is that LAMBDA_CAPTURE_EXPLICIT_P wasn't propagated
correctly and so var_to_maybe_prune proceeded where it shouldn't.

Co-Authored by: Patrick Palka <ppalka@redhat.com>

PR c++/108829

gcc/cp/ChangeLog:

* pt.cc (prepend_one_capture): Set LAMBDA_CAPTURE_EXPLICIT_P.
(tsubst_lambda_expr): Pass LAMBDA_CAPTURE_EXPLICIT_P to
prepend_one_capture.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/lambda/lambda-108829-2.C: New test.
* g++.dg/cpp0x/lambda/lambda-108829.C: New test.

17 months agotree-optimization/108816 - vect versioning check split confusion
Richard Biener [Mon, 20 Feb 2023 09:59:15 +0000 (10:59 +0100)]
tree-optimization/108816 - vect versioning check split confusion

The split of the versioning condition assumes the definition is
in the condition block which is ensured by the versioning code.
But that only works when we actually have to insert any statements
for the versioning condition.  The following adjusts the guard
accordingly and asserts this condition.

PR tree-optimization/108816
* tree-vect-loop-manip.cc (vect_loop_versioning): Adjust
versioning condition split prerequesite, assert required
invariant.

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

17 months agorust: Fix rust-tree.cc compilation on SPARC
Rainer Orth [Mon, 20 Feb 2023 10:40:24 +0000 (11:40 +0100)]
rust: Fix rust-tree.cc compilation on SPARC

This patch

commit 27a89f84c458ae938bc3eb92ad0d594c06fc3b42
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Fri Feb 17 23:36:20 2023 +0100

    '#include "tm_p.h"' in 'gcc/rust/backend/rust-tree.cc'

broke rust bootstrap on SPARC:

In file included from ./tm_p.h:4,
                 from /vol/gcc/src/hg/master/local/gcc/rust/backend/rust-tree.cc:38:
/vol/gcc/src/hg/master/local/gcc/config/sparc/sparc-protos.h:46:47: error: use of enum 'memmodel' without previous declaration
   46 | extern void sparc_emit_membar_for_model (enum memmodel, int, int);
      |                                               ^~~~~~~~

Fixed by including memmodel.h.  Tested on sparc-sun-solaris2.11 and
i386-pc-solaris2.11.

2023-02-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/rust:
* backend/rust-tree.cc: Include memmodel.h.

17 months agotree-optimization/108825 - checking ICE with unroll-and-jam
Richard Biener [Mon, 20 Feb 2023 08:54:37 +0000 (09:54 +0100)]
tree-optimization/108825 - checking ICE with unroll-and-jam

The issue is that unroll-and-jam applies RPO VN on the transformed body but
that leaves the IL in "indetermined" state (it returns a TODO to make it
valid again).  But unroll-and-jam then continues to transform another loop and
in using the tree_unroll_loop helper runs into tree_transform_and_unroll_loop
performing IL checking on the whole function.

While the real fix is to elide all such checking I'm only making the
loop-local LC SSA verifier not perform function-wide SSA verification
at this point.

PR tree-optimization/108825
* tree-ssa-loop-manip.cc (verify_loop_closed_ssa): For
loop-local verfication only verify there's no pending SSA
update.

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

17 months agotree-optimization/108819 - niter analysis ICE with unexpected constant
Richard Biener [Fri, 17 Feb 2023 13:21:39 +0000 (14:21 +0100)]
tree-optimization/108819 - niter analysis ICE with unexpected constant

The following makes sure we do not ICE on unfolded stmts like
_1 = 1 & 1.

PR tree-optimization/108819
* tree-ssa-loop-niter.cc (number_of_iterations_cltz): Check
we have an SSA name as iv_2 as expected.

17 months agoDaily bump.
GCC Administrator [Mon, 20 Feb 2023 00:16:30 +0000 (00:16 +0000)]
Daily bump.

17 months agolibgm2/libm2iso/RTco.cc (re-implementation) Bugfix for [PR108835]
Gaius Mulley [Sun, 19 Feb 2023 22:08:31 +0000 (22:08 +0000)]
libgm2/libm2iso/RTco.cc (re-implementation) Bugfix for [PR108835]

This is a re-implementation of RTco.cc which fixes the race hazzard
seen occasionally when running testtransfer and coroutines from the
modula2 testsuite.

libgm2/ChangeLog:

PR testsuite/108835
* libm2iso/RTco.cc: Re-implementation using a single lock
mutex and inlined wait/signal implementation within
transfer.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
17 months agoDaily bump.
GCC Administrator [Sun, 19 Feb 2023 00:16:39 +0000 (00:16 +0000)]
Daily bump.

17 months agoc++: static_assert (false) in template [DR2518]
Jason Merrill [Sat, 11 Feb 2023 00:16:45 +0000 (16:16 -0800)]
c++: static_assert (false) in template [DR2518]

For a long time, people have expected to be able to write
static_assert (false) in a template and only have it diagnosed if the
template is instantiated, but we (and other implementations) gave an error
about the uninstantiated template because the standard says that if no valid
instantiation of the template is possible, the program is ill-formed, no
diagnostic required, and we try to diagnose IFNDR things when feasible.

At the meeting last week we were looking at CWG2518, which wanted to specify
that an implementation must not accept a program containing a failing #error
or static_assert.  We also looked at P2593, which proposed allowing
static_assert in an uninstantiated template.  We ended up combining these
two in order to avoid requiring implementations to reject programs with
static_assert (false) in uninstantiated templates.

The committee accepted this as a DR, so I'm making the change to all
standard modes.  This behavior was also conformant previously, since no
diagnostic was required in this case.

We continue to diagnose non-constant or otherwise ill-formed conditions, so
no changes to existing tests were needed.

DR 2518
PR c++/52809
PR c++/53638
PR c++/87389
PR c++/89741
PR c++/92099
PR c++/104041
PR c++/104691

gcc/cp/ChangeLog:

* semantics.cc (finish_static_assert): Don't diagnose in
template context.

gcc/testsuite/ChangeLog:

* g++.dg/DRs/dr2518.C: New test.

17 months agoreassoc: Fold some statements [PR108819]
Jakub Jelinek [Sat, 18 Feb 2023 11:40:49 +0000 (12:40 +0100)]
reassoc: Fold some statements [PR108819]

This spot in update_ops can replace one or both of the assign operands with
constants, creating 1 & 1 and similar expressions which can confuse later
passes until they are folded.  Rather than folding both constants by hand
and also handling swapping of operands for commutative ops if the first one
is constant and second one is not, the following patch just uses
fold_stmt_inplace to do that.  I think we shouldn't fold more than the
single statement because that could screw up the rest of the pass, we'd have
to mark all those with uids, visited and the like.

2023-02-18  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/108819
* tree-ssa-reassoc.cc (update_ops): Fold new stmt in place.

* gcc.dg/pr108819.c: New test.

17 months agoi386: Fix up replacement of registers in certain peephole2s [PR108832]
Jakub Jelinek [Sat, 18 Feb 2023 11:40:04 +0000 (12:40 +0100)]
i386: Fix up replacement of registers in certain peephole2s [PR108832]

As mentioned in the PR, replace_rtx has 2 modes, one that only replaces
x == from with to, the other which i386.md uses which also replaces
REGNO (x) == REGNO (from) with to if both are REGs, but assert they have
the same mode.  This is reasonable behavior if one replaces from with
some other expression, say constant etc., but ICEs whenever the register
appears in a different mode, which happens e.g. on the following testcase,
where from/to has DImode but inside of the operands we have SImode of
the from register.  replace_rtx also does some limited simplifications
(though far less than simplify_replace_fn_rtx), which is needed if
from a REG is replaced say with CONST_INT, but the peephole2s that use
this only replace one REG with another one.

The following patch introduces a new backend function for this, avoids doing
any simplifications and just replaces the REGs, for safety on a copy of
the expression if any changes will be needed.

2023-02-18  Jakub Jelinek  <jakub@redhat.com>

PR target/108832
* config/i386/i386-protos.h (ix86_replace_reg_with_reg): Declare.
* config/i386/i386-expand.cc (ix86_replace_reg_with_reg): New
function.
* config/i386/i386.md: Replace replace_rtx calls in all peephole2s
with ix86_replace_reg_with_reg.

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

17 months agolibstdc++: Switch two links to www.open-std.org to https
Gerald Pfeifer [Sat, 18 Feb 2023 09:59:11 +0000 (10:59 +0100)]
libstdc++: Switch two links to open-std.org to https

libstdc++-v3/ChangeLog:

* doc/xml/faq.xml: Switch two links to www.open-std.org to https.
* doc/html/faq.html: Regenerate.

17 months agodoc: Update link to AVR-LibC
Gerald Pfeifer [Sat, 18 Feb 2023 09:45:44 +0000 (10:45 +0100)]
doc: Update link to AVR-LibC

gcc/ChangeLog:

* doc/invoke.texi (AVR Options): Update link to AVR-LibC.

17 months agoC: Detect all variably modified types [PR108375]
Martin Uecker [Wed, 15 Feb 2023 09:54:00 +0000 (10:54 +0100)]
C: Detect all variably modified types [PR108375]

Some variably modified types were not detected correctly.
Define C_TYPE_VARIABLY_MODIFIED via TYPE_LANG_FLAG 6 in the CFE.
This flag records whether a type is variably modified and is
set for all such types including arrays with variably modified
element type or structures and unions with variably modified
members. This is then used to detect such types in the C FE
and middle-end (via the existing language hook).

gcc/c/ChangeLog:
PR c/108375
* c-decl.cc (decl_jump_unsafe): Use c_type_variably_modified_p.
(diagnose_mismatched_decl): Dito.
(warn_about_goto): Dito:
(c_check_switch_jump_warnings): Dito.
(finish_decl): Dito.
(finish_struct): Dito.
(grokdeclarator): Set C_TYPE_VARIABLY_MODIFIED.
(finish_struct): Set C_TYPE_VARIABLY_MODIFIED.
* c-objc-common.cc (c_var_mod_p): New function.
(c_var_unspec_p): Remove.
* c-objc-common.h: Set lang hook.
* c-parser.cc (c_parser_declararion_or_fndef): Use c_type_variably_modified_p.
(c_parser_typeof_specifier): Dito.
(c_parser_has_attribute_expression): Dito.
(c_parser_generic_selection): Dito.
* c-tree.h: Define C_TYPE_VARIABLY_MODIFIED and define c_var_mode_p.
* c-typeck.cc: Remove c_vla_mod_p and use C_TYPE_VARIABLY_MODIFIED.

gcc/testsuite/ChangeLog:
PR c/108375
* gcc.dg/pr108375-1.c: New test.
* gcc.dg/pr108375-2.c: New test.

17 months agoFix ICE related to implicit access attributes for VLA arguments [PR105660]
Martin Uecker [Wed, 8 Feb 2023 14:02:43 +0000 (15:02 +0100)]
Fix ICE related to implicit access attributes for VLA arguments [PR105660]

When constructing the specifier string when merging an access attribute
that encodes information about VLA arguments, the string was constructed
in random order by iterating through a hash table. Fix this by iterating
though the list of arguments.

gcc/c-family/Changelog:
PR c/105660
* c-attribs.cc (append_access_attr): Use order of arguments when
construction string.
(append_access_attr_idxs): Rename and make static.
* c-warn.cc (warn_parm_array_mismatch): Add assertion.

gcc/testsuite/ChangeLog:
PR c/105660
* gcc.dg/pr105660-1.c: New test.
* gcc.dg/pr105660-2.c: New test.

17 months agoLoongArch: Fix multiarch tuple canonization
Xi Ruoyao [Mon, 13 Feb 2023 10:38:53 +0000 (18:38 +0800)]
LoongArch: Fix multiarch tuple canonization

Multiarch tuple will be coded in file or directory names in
multiarch-aware distros, so one ABI should have only one multiarch
tuple.  For example, "--target=loongarch64-linux-gnu --with-abi=lp64s"
and "--target=loongarch64-linux-gnusf" should both set multiarch tuple
to "loongarch64-linux-gnusf".  Before this commit,
"--target=loongarch64-linux-gnu --with-abi=lp64s --disable-multilib"
will produce wrong result (loongarch64-linux-gnu).

A recent LoongArch psABI revision mandates "loongarch64-linux-gnu" to be
used for -mabi=lp64d (instead of "loongarch64-linux-gnuf64") for some
non-technical reason [1].  Note that we cannot make
"loongarch64-linux-gnuf64" an alias for "loongarch64-linux-gnu" because
to implement such an alias, we must create thousands of symlinks in the
distro and doing so would be completely unpractical.  This commit also
aligns GCC with the revision.

Tested by building cross compilers with --enable-multiarch and multiple
combinations of --target=loongarch64-linux-gnu*, --with-abi=lp64{s,f,d},
and --{enable,disable}-multilib; and run "xgcc --print-multiarch" then
manually verify the result with eyesight.

[1]: https://github.com/loongson/LoongArch-Documentation/pull/80

gcc/ChangeLog:

* config.gcc (triplet_abi): Set its value based on $with_abi,
instead of $target.
(la_canonical_triplet): Set it after $triplet_abi is set
correctly.
* config/loongarch/t-linux (MULTILIB_OSDIRNAMES): Make the
multiarch tuple for lp64d "loongarch64-linux-gnu" (without
"f64" suffix).

17 months agoRemove #if GIMPLE around 1 - a pattern
Andrew Pinski [Fri, 17 Feb 2023 16:43:27 +0000 (16:43 +0000)]
Remove #if GIMPLE around 1 - a pattern

This removes the "#if GIMPLE" around the
"1 - a" pattern as ssa_name_has_boolean_range
(get_range_query) works when cfun is a nullptr.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

* match.pd: Remove #if GIMPLE around the
"1 - a" pattern

17 months agoSupport get_range_query with a nullptr argument
Andrew Pinski [Fri, 17 Feb 2023 16:45:43 +0000 (16:45 +0000)]
Support get_range_query with a nullptr argument

get_range_query didn't support a nullptr argument
before and would crash.
See also the thread at
https://inbox.sourceware.org/gcc/4f6718af-e17a-41ef-a886-f45e4ac3d7a4@redhat.com/T/

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

* value-query.h (get_range_query): Return the global ranges
for a nullptr func.

17 months agoDaily bump.
GCC Administrator [Sat, 18 Feb 2023 00:17:20 +0000 (00:17 +0000)]
Daily bump.

17 months ago'#include "tm_p.h"' in 'gcc/rust/backend/rust-tree.cc'
Thomas Schwinge [Fri, 17 Feb 2023 22:36:20 +0000 (23:36 +0100)]
'#include "tm_p.h"' in 'gcc/rust/backend/rust-tree.cc'

... to resolve issues like:

<https://github.com/Rust-GCC/gccrs/issues/1864> "Upstream GCC broken for --target=pdp11-aout":

    In file included from ./tm.h:18:0,
                     from [...]/gcc/target.h:52,
                     from [...]/gcc/rust/backend/rust-tree.cc:34:
    [...]/gcc/rust/backend/rust-tree.cc: In function ‘void Rust::mark_exp_read(tree)’:
    [...]/gcc/config/pdp11/pdp11.h:572:48: error: ‘pdp11_gen_int_label’ was not declared in this scope
       pdp11_gen_int_label ((LABEL), (PREFIX), (NUM))
                                                    ^
    [...]/gcc/rust/backend/rust-tree.cc:53:3: note: in expansion of macro ‘ASM_GENERATE_INTERNAL_LABEL’
       ASM_GENERATE_INTERNAL_LABEL (tmp_name, "Lsrc_loc", 1);
       ^
    [...]/gcc/rust/backend/rust-tree.cc: In function ‘tree_node* Rust::fold_builtin_source_location(location_t)’:
    [...]/gcc/config/pdp11/pdp11.h:572:48: error: ‘pdp11_gen_int_label’ was not declared in this scope
       pdp11_gen_int_label ((LABEL), (PREFIX), (NUM))
                                                    ^
    [...]/gcc/rust/backend/rust-tree.cc:4799:7: note: in expansion of macro ‘ASM_GENERATE_INTERNAL_LABEL’
           ASM_GENERATE_INTERNAL_LABEL (tmp_name, "Lsrc_loc", source_location_id++);
           ^
    make[1]: *** [rust/rust-tree.o] Error 1

<https://github.com/Rust-GCC/gccrs/issues/1819> "New build failure on upstream GCC for --target=powerpc-ibm-aix7.{1,2}":

    In file included from ./tm.h:22:0,
                     from [...]/gcc/target.h:52,
                     from [...]/gcc/rust/backend/rust-tree.cc:34:
    [...]/gcc/rust/backend/rust-tree.cc: In function ‘void Rust::mark_exp_read(tree)’:
    [...]/gcc/config/rs6000/xcoff.h:206:63: error: ‘rs6000_xcoff_strip_dollar’ was not declared in this scope
       sprintf (LABEL, "*%s..%u", rs6000_xcoff_strip_dollar (PREFIX), (unsigned) (NUM))
                                                                   ^
    [...]/gcc/rust/backend/rust-tree.cc:53:3: note: in expansion of macro ‘ASM_GENERATE_INTERNAL_LABEL’
       ASM_GENERATE_INTERNAL_LABEL (tmp_name, "Lsrc_loc", 1);
       ^
    [...]/gcc/rust/backend/rust-tree.cc: In function ‘tree_node* Rust::fold_builtin_source_location(location_t)’:
    [...]/gcc/config/rs6000/xcoff.h:206:63: error: ‘rs6000_xcoff_strip_dollar’ was not declared in this scope
       sprintf (LABEL, "*%s..%u", rs6000_xcoff_strip_dollar (PREFIX), (unsigned) (NUM))
                                                                   ^
    [...]/gcc/rust/backend/rust-tree.cc:4799:7: note: in expansion of macro ‘ASM_GENERATE_INTERNAL_LABEL’
           ASM_GENERATE_INTERNAL_LABEL (tmp_name, "Lsrc_loc", source_location_id++);
           ^
    make[1]: *** [rust/rust-tree.o] Error 1

Fix-up for recent commit e66fec8e6ba35edf01f86c2bf6514109aba4ded2
"gccrs: const folding port".

gcc/rust/
* backend/rust-tree.cc: '#include "tm_p.h"'.

17 months agodoc: Fix typo in -Wall description
Siddhesh Poyarekar [Fri, 17 Feb 2023 14:06:59 +0000 (09:06 -0500)]
doc: Fix typo in -Wall description

-Wall enables -Wuse-after-free=2 and not -Wuse-after-free=3.

gcc/ChangeLog:

* doc/invoke.texi (@item -Wall): Fix typo in
-Wuse-after-free.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
17 months agoc++: speculative constexpr and is_constant_evaluated [PR108243]
Patrick Palka [Fri, 17 Feb 2023 20:18:10 +0000 (15:18 -0500)]
c++: speculative constexpr and is_constant_evaluated [PR108243]

This PR illustrates that __builtin_is_constant_evaluated currently acts
as an optimization barrier for our speculative constexpr evaluation,
since we don't want to prematurely fold the builtin to false before the
expression in question undergoes manifestly constant evaluation if
appropriate (in which case the builtin must instead be folded to true).

This patch fixes this by permitting __builtin_is_constant_evaluated to
get folded as false at appropiate points, namely during cp_fold_function
and cp_fully_fold_init where we know we're done with manifestly constant
evaluation.  The function cp_fold gets a flags parameter that controls
whether we pass mce_false or mce_unknown to maybe_constant_value when
folding a CALL_EXPR.

PR c++/108243
PR c++/97553

gcc/cp/ChangeLog:

* cp-gimplify.cc (enum fold_flags): Define.
(fold_flags_t): Declare.
(cp_fold_data::genericize): Replace this data member with ...
(cp_fold_data::fold_flags): ... this.
(cp_fold_r): Adjust use of cp_fold_data and calls to cp_fold.
(cp_fold_function): Likewise.
(cp_fold_maybe_rvalue): Add an internal overload that
additionally takes and propagates a fold_flags_t parameter, and
define the existing public overload in terms of it.
(cp_fold_rvalue): Likewise.
(cp_fully_fold_init): Adjust use of cp_fold_data.
(fold_cache): Replace with ...
(fold_caches): ... this 2-element array of caches.
(get_fold_cache): Define.
(clear_fold_cache): Adjust.
(cp_fold): Add fold_flags_t parameter.  Use get_fold_cache.
Pass flags to calls to cp_fold, cp_fold_rvalue and
cp_fold_maybe_rvalue.
<case CALL_EXPR>: If ff_mce_false is set, fold
__builtin_is_constant_evaluated to false and pass mce_false to
maybe_constant_value.

gcc/testsuite/ChangeLog:

* g++.dg/opt/is_constant_evaluated1.C: New test.
* g++.dg/opt/is_constant_evaluated2.C: New test.

17 months agoc++: make manifestly_const_eval tri-state
Patrick Palka [Fri, 17 Feb 2023 20:18:08 +0000 (15:18 -0500)]
c++: make manifestly_const_eval tri-state

This patch converts the constexpr machinery's manifestly_const_eval flag
into a tri-state enum to allow us to express wanting to fold
__builtin_is_constant_evaluated to false via speculative constexpr
evaluation.  For now, only the maybe_constant_value entry point is
changed to take this enum; the others continue to take bool.  The
subsequent patch will teach cp_fold (which uses maybe_constant_value) to
fold the builtin to false when called from cp_fold_function and
cp_fully_fold_init.

gcc/cp/ChangeLog:

* constexpr.cc (constexpr_call::manifestly_const_eval): Give
it type int instead of bool.
(constexpr_ctx::manifestly_const_eval): Give it type mce_value
instead of bool.
(cxx_eval_builtin_function_call): Adjust after making
manifestly_const_eval tri-state.
(cxx_eval_call_expression): Likewise.
(cxx_eval_binary_expression): Likewise.
(cxx_eval_conditional_expression): Likewise.
(cxx_eval_constant_expression): Likewise.
(cxx_eval_outermost_constant_expr): Likewise.
(cxx_constant_value): Likewise.
(cxx_constant_dtor): Likewise.
(maybe_constant_value): Give manifestly_const_eval parameter
type mce_value instead of bool and adjust accordingly.
(fold_non_dependent_expr_template): Adjust call
to cxx_eval_outermost_constant_expr.
(fold_non_dependent_expr): Likewise.
(maybe_constant_init_1): Likewise.
* constraint.cc (satisfy_atom): Adjust call to
maybe_constant_value.
* cp-tree.h (enum class mce_value): Define.
(maybe_constant_value): Adjust manifestly_const_eval parameter
type and default argument.
* decl.cc (compute_array_index_type_loc): Adjust call to
maybe_constant_value.
* pt.cc (convert_nontype_argument): Likewise.

17 months agoii386: Generate QImode binary ops with high-part input register [PR108831]
Uros Bizjak [Fri, 17 Feb 2023 16:00:12 +0000 (17:00 +0100)]
ii386: Generate QImode binary ops with high-part input register [PR108831]

Following testcase:

--cut here--
struct S
{
  unsigned char pad1;
  unsigned char val;
  unsigned short pad2;
};

unsigned char
test_add (unsigned char a, struct S b)
{
  a += b.val;

  return a;
}
--cut here--

should be compiled to something like:

        addb %dh, %al

but is currently compiled to:

        movzbl  %dh, %edx
        addl    %edx, %eax

The patch implements insn patterns that model QImode binary ops with
high-part QImode input register.  These ops can not be encoded with
REX prefix, so only Q registers and constant memory output operands
are allowed on x86_64 targets.

2023-02-17  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/108831
* config/i386/predicates.md
(nonimm_x64constmem_operand): New predicate.
* config/i386/i386.md (*addqi_ext<mode>_0): New insn pattern.
(*subqi_ext<mode>_0): Ditto.
(*andqi_ext<mode>_0): Ditto.
(*<any_or:code>qi_ext<mode>_0): Ditto.

gcc/testsuite/ChangeLog:

PR target/108831
* gcc.target/i386/pr108831-1.c: New test.
* gcc.target/i386/pr108831-2.c: Ditto.

17 months agosimplify-rtx: Fix VOIDmode operand handling in simplify_subreg [PR108805]
Uros Bizjak [Fri, 17 Feb 2023 14:58:12 +0000 (15:58 +0100)]
simplify-rtx: Fix VOIDmode operand handling in simplify_subreg [PR108805]

simplify_subreg can return VOIDmode const_int operand and will
cause ICE in simplify_gen_subreg when this operand is passed to it.

The patch uses int_outermode instead of GET_MODE of temporary as the
innermode argument of simplify_gen_subreg.

2023-02-17  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/108805
* simplify-rtx.cc (simplify_context::simplify_subreg): Use
int_outermode instead of GET_MODE (tem) to prevent
VOIDmode from entering simplify_gen_subreg.

gcc/testsuite/ChangeLog:

PR target/108805
* gcc.dg/pr108805.c: New test.

17 months agofixincludes: Bypass solaris_math_12 on newer Solaris 11.4
Rainer Orth [Fri, 17 Feb 2023 12:48:45 +0000 (13:48 +0100)]
fixincludes: Bypass solaris_math_12 on newer Solaris 11.4

Solaris 11 <math.h> long had this snippet

which badly broke libstdc++.  This has long been undone using
fixincludes in

[fixincludes, v3] Don't define libstdc++-internal macros in Solaris 10+ <math.h>
https://gcc.gnu.org/ml/gcc-patches/2016-11/msg00330.html

However, the issue came up again recently when that code broke the LLVM
build, too, which unfortunately doesn't know about GCC's include-fixed
directory.  The issue was reinvestigated and it turned out that the
workaround/hack is only needed for specific old versions of the Sun/Oracle
Studio compilers.  So <math.h> now looks like

/* Accommodate historical C++11 -std=c++03 behavior of Studio 12.4 and 12.5 */
    ((__SUNPRO_CC == 0x5130) || (__SUNPRO_CC == 0x5140) ||  \
     defined(__MATH_PREEMPTS_GLIBCXX_C99_MATH))

If this change is in place, there's no longer a need for the fixincludes
fix, so this patch bypasses it as appropriate.

Tested on Solaris 11.3 (without the fixed header) and recent 11.4 (with
the fixed header).

2022-11-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

fixincludes:
* inclhack.def (solaris_math_12): Add bypass.
* fixincl.x: Regenerate.

17 months agocontrib: Fix make_sunver.pl warning
Rainer Orth [Fri, 17 Feb 2023 12:33:25 +0000 (13:33 +0100)]
contrib: Fix make_sunver.pl warning

Petr informed me that perl 5.32 bundled with Solaris 11.4 warns about
make_sunver.pl:

Unescaped left brace in regex is passed through in regex; marked by <-- HERE in m/^([ \t]*){ <-- HERE $/ at /vol/gcc/src/hg/master/local/libgomp/../contrib/make_sunver.pl line 216.

I didn't notice since I'm using a common installation of perl 5.12
across Solaris versions that doesn't show that warning.

His patch fixes the issue.  Tested on Solaris 11.3 (perl 5.12) and 11.4
(perl 5.32).

2023-01-20  Petr Sumbera  <petr.sumbera@oracle.com>

contrib:
* make_sunver.pl: Escape brace.

17 months agotree-optimization/108821 - store motion and volatiles
Richard Biener [Fri, 17 Feb 2023 11:36:44 +0000 (12:36 +0100)]
tree-optimization/108821 - store motion and volatiles

The following fixes store motion to not re-issue volatile stores
to preserve TBAA behavior since that will result in the number
of volatile accesses changing.

PR tree-optimization/108821
* tree-ssa-loop-im.cc (sm_seq_valid_bb): We can also not
move volatile accesses.

* gcc.dg/tree-ssa/ssa-lim-24.c: New testcase.

17 months agoFix wrong-code issue in VN
Richard Biener [Fri, 17 Feb 2023 08:30:49 +0000 (09:30 +0100)]
Fix wrong-code issue in VN

The following fixes the wrong removed dead store discovered on the
PR108657 testcase when the reported DSE issue is not fixed.
The issue is we were using ssa_undefined_value_p on virtual operands
which returns a result based on the real definition of the definition
statement.  That doesn't make sense so this patch guards the calls
properly and makes sure nobody else does the same mistake.

* tree-ssa.cc (ssa_undefined_value_p): Assert we are not
called on virtual operands.
* tree-ssa-sccvn.cc (vn_phi_lookup): Guard
ssa_undefined_value_p calls.
(vn_phi_insert): Likewise.
(set_ssa_val_to): Likewise.
(visit_phi): Avoid extra work with equivalences for
virtual operand PHIs.

17 months agoFortran test: Modify test cases to pass on mingw.
Jerry DeLisle [Fri, 17 Feb 2023 03:29:44 +0000 (19:29 -0800)]
Fortran test: Modify test cases to pass on mingw.

gcc/testsuite/ChangeLog:

* gfortran.dg/ISO_Fortran_binding_14.f90: Change example function to
CLOCK which is available on mingw as well as other platforms.
* gfortran.dg/pr96486.f90: Change variable to PATH likewise.

17 months agoRISC-V: Fix vmnot asm check (Should check vmnot.m instead of vmnot.mm)
Ju-Zhe Zhong [Thu, 16 Feb 2023 03:34:28 +0000 (11:34 +0800)]
RISC-V: Fix vmnot asm check (Should check vmnot.m instead of vmnot.mm)

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/binop_vx_constraint-148.c: Change vmnot.mm to vmnot.m.
* gcc.target/riscv/rvv/base/binop_vx_constraint-149.c: Change vmnot.mm to vmnot.m.
* gcc.target/riscv/rvv/base/binop_vx_constraint-150.c: Change vmnot.mm to vmnot.m.
* gcc.target/riscv/rvv/base/binop_vx_constraint-151.c: Change vmnot.mm to vmnot.m.
* gcc.target/riscv/rvv/base/binop_vx_constraint-152.c: Change vmnot.mm to vmnot.m.
* gcc.target/riscv/rvv/base/binop_vx_constraint-153.c: Change vmnot.mm to vmnot.m.
* gcc.target/riscv/rvv/base/binop_vx_constraint-156.c: Change vmnot.mm to vmnot.m.
* gcc.target/riscv/rvv/base/binop_vx_constraint-157.c: Change vmnot.mm to vmnot.m.
* gcc.target/riscv/rvv/base/binop_vx_constraint-159.c: Change vmnot.mm to vmnot.m.
* gcc.target/riscv/rvv/base/binop_vx_constraint-160.c: Change vmnot.mm to vmnot.m.
* gcc.target/riscv/rvv/base/binop_vx_constraint-161.c: Change vmnot.mm to vmnot.m.

17 months agoRISC-V: Add RVV all mask C/C++ intrinsics support
Ju-Zhe Zhong [Thu, 16 Feb 2023 03:30:01 +0000 (11:30 +0800)]
RISC-V: Add RVV all mask C/C++ intrinsics support

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins-bases.cc (class mask_logic): New
class.
(class mask_nlogic): Ditto.
(class mask_notlogic): Ditto.
(class vmmv): Ditto.
(class vmclr): Ditto.
(class vmset): Ditto.
(class vmnot): Ditto.
(class vcpop): Ditto.
(class vfirst): Ditto.
(class mask_misc): Ditto.
(class viota): Ditto.
(class vid): Ditto.
(BASE): Ditto.
* config/riscv/riscv-vector-builtins-bases.h: Ditto.
* config/riscv/riscv-vector-builtins-functions.def (vmand): Ditto.
(vmnand): Ditto.
(vmandn): Ditto.
(vmxor): Ditto.
(vmor): Ditto.
(vmnor): Ditto.
(vmorn): Ditto.
(vmxnor): Ditto.
(vmmv): Ditto.
(vmclr): Ditto.
(vmset): Ditto.
(vmnot): Ditto.
(vcpop): Ditto.
(vfirst): Ditto.
(vmsbf): Ditto.
(vmsif): Ditto.
(vmsof): Ditto.
(viota): Ditto.
(vid): Ditto.
* config/riscv/riscv-vector-builtins-shapes.cc (struct alu_def): Ditto.
(struct mask_alu_def): Ditto.
(SHAPE): Ditto.
* config/riscv/riscv-vector-builtins-shapes.h: Ditto.
* config/riscv/riscv-vector-builtins.cc: Ditto.
* config/riscv/riscv-vsetvl.cc (pass_vsetvl::cleanup_insns): Fix bug
for dest it scalar RVV intrinsics.
* config/riscv/vector-iterators.md (sof): New iterator.
* config/riscv/vector.md (@pred_<optab>n<mode>): New pattern.
(@pred_<optab>not<mode>): New pattern.
(@pred_popcount<VB:mode><P:mode>): New pattern.
(@pred_ffs<VB:mode><P:mode>): New pattern.
(@pred_<misc_op><mode>): New pattern.
(@pred_iota<mode>): New pattern.
(@pred_series<mode>): New pattern.

17 months agoRISC-V: Rename tu_preds to none_tu_preds [NFC]
Ju-Zhe Zhong [Wed, 15 Feb 2023 11:22:31 +0000 (19:22 +0800)]
RISC-V: Rename tu_preds to none_tu_preds [NFC]

To be consistent with other naming of preds array variable.
Change tu_preds into none_tu_preds which indicate such preds
include vop and vop_tu combinations.

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins-functions.def (vadc): Rename.
(vsbc): Ditto.
(vmerge): Ditto.
(vmv_v): Ditto.
* config/riscv/riscv-vector-builtins.cc: Ditto.

17 months agoRISC-V: Normalize SEW = 64 handling into a simplified function
Ju-Zhe Zhong [Wed, 15 Feb 2023 08:39:54 +0000 (16:39 +0800)]
RISC-V: Normalize SEW = 64 handling into a simplified function

Co-authored-by: kito-cheng <kito.cheng@sifive.com>
gcc/ChangeLog:

* config/riscv/riscv-protos.h (sew64_scalar_helper): New function.
* config/riscv/riscv-v.cc (has_vi_variant_p): Adjust.
(sew64_scalar_helper): New function.
* config/riscv/vector.md: Normalization.

Co-authored-by: kito-cheng <kito.cheng@sifive.com>
17 months agoRISC-V: Rearrange the organization of declarations of RVV intrinsics [NFC]
Ju-Zhe Zhong [Tue, 14 Feb 2023 22:27:33 +0000 (06:27 +0800)]
RISC-V: Rearrange the organization of declarations of RVV intrinsics [NFC]

This patch doesn't change any functionality, only rearrange the oraganzation.
Make it to be consistent with RVV ISA. Add annotation for it to make codes
more readable.

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins-functions.def (vsetvlmax): Rearrange.
(vsm): Ditto.
(vsse): Ditto.
(vsoxei64): Ditto.
(vsub): Ditto.
(vand): Ditto.
(vor): Ditto.
(vxor): Ditto.
(vsll): Ditto.
(vsra): Ditto.
(vsrl): Ditto.
(vmin): Ditto.
(vmax): Ditto.
(vminu): Ditto.
(vmaxu): Ditto.
(vmul): Ditto.
(vmulh): Ditto.
(vmulhu): Ditto.
(vmulhsu): Ditto.
(vdiv): Ditto.
(vrem): Ditto.
(vdivu): Ditto.
(vremu): Ditto.
(vnot): Ditto.
(vsext): Ditto.
(vzext): Ditto.
(vwadd): Ditto.
(vwsub): Ditto.
(vwmul): Ditto.
(vwmulu): Ditto.
(vwmulsu): Ditto.
(vwaddu): Ditto.
(vwsubu): Ditto.
(vsbc): Ditto.
(vmsbc): Ditto.
(vnsra): Ditto.
(vmerge): Ditto.
(vmv_v): Ditto.
(vmsne): Ditto.
(vmslt): Ditto.
(vmsgt): Ditto.
(vmsle): Ditto.
(vmsge): Ditto.
(vmsltu): Ditto.
(vmsgtu): Ditto.
(vmsleu): Ditto.
(vmsgeu): Ditto.
(vnmsac): Ditto.
(vmadd): Ditto.
(vnmsub): Ditto.
(vwmacc): Ditto.
(vsadd): Ditto.
(vssub): Ditto.
(vssubu): Ditto.
(vaadd): Ditto.
(vasub): Ditto.
(vasubu): Ditto.
(vsmul): Ditto.
(vssra): Ditto.
(vssrl): Ditto.
(vnclip): Ditto.

17 months agoRISC-V: Move saturating add/subtract md pattern location [NFC]
Ju-Zhe Zhong [Tue, 14 Feb 2023 23:18:20 +0000 (07:18 +0800)]
RISC-V: Move saturating add/subtract md pattern location [NFC]

gcc/ChangeLog:

* config/riscv/vector.md (@pred_<optab><mode>): Rearrange.
(@pred_<optab><mode>_scalar): Ditto.
(*pred_<optab><mode>_scalar): Ditto.
(*pred_<optab><mode>_extended_scalar): Ditto.

17 months agoRISC-V: Remove "extern" for namespace [NFC]
Ju-Zhe Zhong [Tue, 14 Feb 2023 15:39:03 +0000 (23:39 +0800)]
RISC-V: Remove "extern" for namespace [NFC]

Just like other targets, aarch64_sve namespace in aarch64-protos.h
arm_mve in arm-protos, nds namesace in nds32-protos.h

They all don't have 'extern' in namespace.
This is a NFC patch to make RISC-V be consistent with other targets.
No functionality change.

gcc/ChangeLog:

* config/riscv/riscv-protos.h (riscv_run_selftests): Remove 'extern'.
(init_builtins): Ditto.
(mangle_builtin_type): Ditto.
(verify_type_context): Ditto.
(handle_pragma_vector):  Ditto.
(builtin_decl): Ditto.
(expand_builtin): Ditto.
(const_vec_all_same_in_range_p): Ditto.
(legitimize_move): Ditto.
(emit_vlmax_op): Ditto.
(emit_nonvlmax_op): Ditto.
(get_vlmul): Ditto.
(get_ratio): Ditto.
(get_ta): Ditto.
(get_ma): Ditto.
(get_avl_type): Ditto.
(calculate_ratio): Ditto.
(enum vlmul_type): Ditto.
(simm5_p): Ditto.
(neg_simm5_p): Ditto.
(has_vi_variant_p): Ditto.

17 months agoRISC-V: Replace simm32_p with immediate_operand (Pmode)
Ju-Zhe Zhong [Tue, 14 Feb 2023 15:04:49 +0000 (23:04 +0800)]
RISC-V: Replace simm32_p with immediate_operand (Pmode)

simm32_p is used to check constant int value within 32-bit.
It's used in handling SEW = 64 in rv32 system since such constant int
value with 32-bit allow us use vx instruction.

The current implementation of simm32_p is quite ugly and now I figure
out immedate_operand (op, pmode) can help us to check whether the op
is a constant value within 32-bit.

I already have a bunch testcases to test SEW = 64 in rv32 system and
all regression tests are passed with this patch.

gcc/ChangeLog:

* config/riscv/riscv-protos.h (simm32_p): Remove.
* config/riscv/riscv-v.cc (simm32_p): Ditto.
* config/riscv/vector.md: Use immediate_operand
instead of riscv_vector::simm32_p.

17 months agoFortran Tests: Allow passing on mingw.
Jerry DeLisle [Fri, 17 Feb 2023 02:13:56 +0000 (18:13 -0800)]
Fortran Tests: Allow passing on mingw.

gcc/testsuite/ChangeLog:

* gfortran.dg/bind_c_array_params_2.f90: Add *-*-ming* to dg-final.

17 months agoDaily bump.
GCC Administrator [Fri, 17 Feb 2023 00:17:49 +0000 (00:17 +0000)]
Daily bump.

17 months agoanalyzer: respect some conditions from bit masks [PR108806]
David Malcolm [Thu, 16 Feb 2023 23:12:55 +0000 (18:12 -0500)]
analyzer: respect some conditions from bit masks [PR108806]

PR analyzer/108806 reports false +ves seen from -fanalyzer on code like this
in qemu-7.2.0's hw/intc/omap_intc.c:

  [...snip...]
  struct omap_intr_handler_bank_s* bank = NULL;
  if ((offset & 0xf80) == 0x80) {
    [...set "bank" to non-NULL...]
  }
  switch (offset) {
    [...snip various cases that don't deref "bank"...]
    case 0x80:
      return bank->inputs;
    case 0x84:
      return bank->mask;
    [...etc...]
   }

where the analyzer falsely complains about execution paths in which
"(offset & 0xf80) == 0x80" was false (leaving "bank" as NULL), but then
in which "switch (offset)" goes to a case for which
"(offset & 0xf80) == 0x80" is true and dereferences NULL "bank", i.e.
paths in which "(offset & 0xf80) == 0x80" is both true *and* false.

This patch adds enough logic to constraint_manager for -fanalyzer to
reject such execution paths as impossible, fixing the false +ves.

Integration testing shows this eliminates 20 probable false positives:

Comparison: 9.08% -> 9.34% GOOD: 66 BAD: 661 -> 641 (-20)

where the affected warnings/projects are:

  -Wanalyzer-null-dereference: 0.00% GOOD: 0 BAD: 279 -> 269 (-10)
        qemu-7.2.0: 175 -> 165 (-10)

  -Wanalyzer-use-of-uninitialized-value: 0.00% GOOD: 0 BAD: 153 -> 143 (-10)
     coreutils-9.1:  18 ->  14 (-4)
        qemu-7.2.0:  54 ->  48 (-6)

gcc/analyzer/ChangeLog:
PR analyzer/108806
* constraint-manager.cc (bounded_range::dump_to_pp): Use
bounded_range::singleton_p.
(constraint_manager::add_bounded_ranges): Handle singleton ranges
by adding an EQ_EXPR constraint.
(constraint_manager::impossible_derived_conditions_p): New.
(constraint_manager::eval_condition): Reject EQ_EXPR when it would
imply impossible derived conditions.
(selftest::test_bits): New.
(selftest::run_constraint_manager_tests): Run it.
* constraint-manager.h (bounded_range::singleton_p): New.
(constraint_manager::impossible_derived_conditions_p): New decl.
* region-model.cc (region_model::get_rvalue_1): Handle
BIT_AND_EXPR, BIT_IOR_EXPR, and BIT_XOR_EXPR.

gcc/testsuite/ChangeLog:
PR analyzer/108806
* gcc.dg/analyzer/null-deref-pr108806-qemu.c: New test.
* gcc.dg/analyzer/pr103217.c: Add -Wno-analyzer-too-complex.
* gcc.dg/analyzer/switch.c (test_bitmask_1): New.
(test_bitmask_2): New.
* gcc.dg/analyzer/uninit-pr108806-qemu.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
17 months agodoc: Reword how to get possible values of a parameter
Gerald Pfeifer [Thu, 16 Feb 2023 22:56:34 +0000 (23:56 +0100)]
doc: Reword how to get possible values of a parameter

gcc/ChangeLog:

* doc/invoke.texi (Optimize Options): Reword the explanation
getting minimal, maximal and default values of a parameter.

17 months agotestsuite, objective-c: Cater for Windows intptr type.
Iain Sandoe [Thu, 16 Feb 2023 16:18:11 +0000 (16:18 +0000)]
testsuite, objective-c: Cater for Windows intptr type.

This adjusts the diagnostic output matches to cater for the differences
in intptr types on Windows.

Patch from 'nightstrike'.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/ChangeLog:

* objc.dg/proto-lossage-4.m: Amendn diagnostic matches for Windows.

17 months agoc++: TYPENAME_TYPE lookup ignoring non-types [PR107773]
Patrick Palka [Thu, 16 Feb 2023 16:12:19 +0000 (11:12 -0500)]
c++: TYPENAME_TYPE lookup ignoring non-types [PR107773]

Currently when resolving a TYPENAME_TYPE for 'typename T::m' via
make_typename_type, we consider only type bindings of 'm' and ignore
non-type ones.  But [temp.res.general]/3 says, in a note, "the usual
qualified name lookup ([basic.lookup.qual]) applies even in the presence
of 'typename'", and qualified name lookup doesn't discriminate between
type and non-type bindings.  So when resolving such a TYPENAME_TYPE
we want the lookup to consider all bindings.

An exception is when we have a TYPENAME_TYPE corresponding to the
qualifying scope of the :: scope resolution operator, such as 'T::type'
in 'T::type::m'.  In that case, [basic.lookup.qual]/1 applies, and
lookup for such a TYPENAME_TYPE must ignore non-type bindings.  So in
order to correctly handle all cases, make_typename_type needs an
additional flag controlling whether to restrict the lookup.

To that end this patch adds a new tsubst flag tf_qualifying_scope
denoting whether we're substituting the LHS of the :: operator,
which make_typename_type will look for to conditionally restrict the
lookup to type bindings (by default we want to consider all bindings).
So in contexts such as substituting into the scope of TYPENAME_TYPE,
SCOPE_REF or USING_DECL we simply pass tf_qualifying_scope to the
relevant tsubst / tsubst_copy call, and if that scope is a TYPENAME_TYPE
then make_typename_type will restrict the lookup accordingly.  This flag
is intended to apply only to overall scope (TYPENAME_TYPE or not) so we
must be careful to clear the flag to avoid propagating it when recursing
into sub-trees of the scope.

PR c++/107773

gcc/cp/ChangeLog:

* cp-tree.h (enum tsubst_flags): New flag tf_qualifying_scope.
* decl.cc (make_typename_type): Use lookup_member instead of
lookup_field.  If tf_qualifying_scope is set, pass want_type=true
instead of =false to lookup_member.  Generalize format specifier
in diagnostic to handle both type and non-type bindings.
* pt.cc (tsubst_aggr_type_1): Clear tf_qualifying_scope.  Tidy
the function.
(tsubst_decl) <case USING_DECL>: Set tf_qualifying_scope when
substituting USING_DECL_SCOPE.
(tsubst): Clear tf_qualifying_scope right away and remember if
it was set.  Do the same for tf_tst_ok sooner.
<case TYPENAME_TYPE>: Set tf_qualifying_scope when substituting
TYPE_CONTEXT.  Pass tf_qualifying_scope to make_typename_type
if it was set.
(tsubst_qualified_id): Set tf_qualifying_scope when substituting
the scope.
(tsubst_copy): Clear tf_qualifying_scope and remember if it was
set.
<case SCOPE_REF>: Set tf_qualifying_scope when substituting the
scope.
<case *_TYPE>: Pass tf_qualifying_scope to tsubst if it was set.
* search.cc (lookup_member): Document default argument.

gcc/testsuite/ChangeLog:

* g++.dg/template/typename24.C: New test.
* g++.dg/template/typename25.C: New test.
* g++.dg/template/typename25a.C: New test.
* g++.dg/template/typename26.C: New test.

17 months agoMAINTAINERS: stepping down from my positions
Martin Liska [Thu, 16 Feb 2023 15:50:38 +0000 (16:50 +0100)]
MAINTAINERS: stepping down from my positions

ChangeLog:

* MAINTAINERS: I'm stepping down from my positions.

17 months agodon't declare header-defined functions both static and inline
Patrick Palka [Thu, 16 Feb 2023 15:30:20 +0000 (10:30 -0500)]
don't declare header-defined functions both static and inline

Many functions defined in our headers are declared 'static inline' which
is a C idiom whose use predates our move to C++ as the implementation
language.  But in C++ the inline keyword is more than just a compiler
hint, and is sufficient to give the function the intended semantics.
In fact declaring a function both static and inline is a pessimization
since static effectively disables the desired definition merging
behavior enabled by inline, and is also a source of (harmless) ODR
violations when a static inline function gets called from a non-static
inline one (such as tree_operand_check calling tree_operand_length).

This patch mechanically fixes the vast majority of occurrences of this
anti-pattern throughout the compiler's headers via the command line

  sed -i 's/^static inline/inline/g' gcc/*.h gcc/*/*.h

There's also a manual change to remove the redundant declarations
of is_ivar and lookup_category in gcc/objc/objc-act.cc which would
otherwise conflict with their modified definitions in objc-act.h
(due to the difference in staticness).

Besides fixing some ODR violations, this speeds up stage1 cc1plus by
about 2% and reduces the size of its text segment by 1.5MB.

gcc/ChangeLog:

* addresses.h: Mechanically drop 'static' from 'static inline'
functions via s/^static inline/inline/g.
* asan.h: Likewise.
* attribs.h: Likewise.
* basic-block.h: Likewise.
* bitmap.h: Likewise.
* cfghooks.h: Likewise.
* cfgloop.h: Likewise.
* cgraph.h: Likewise.
* cselib.h: Likewise.
* data-streamer.h: Likewise.
* debug.h: Likewise.
* df.h: Likewise.
* diagnostic.h: Likewise.
* dominance.h: Likewise.
* dumpfile.h: Likewise.
* emit-rtl.h: Likewise.
* except.h: Likewise.
* expmed.h: Likewise.
* expr.h: Likewise.
* fixed-value.h: Likewise.
* gengtype.h: Likewise.
* gimple-expr.h: Likewise.
* gimple-iterator.h: Likewise.
* gimple-predict.h: Likewise.
* gimple-range-fold.h: Likewise.
* gimple-ssa.h: Likewise.
* gimple.h: Likewise.
* graphite.h: Likewise.
* hard-reg-set.h: Likewise.
* hash-map.h: Likewise.
* hash-set.h: Likewise.
* hash-table.h: Likewise.
* hwint.h: Likewise.
* input.h: Likewise.
* insn-addr.h: Likewise.
* internal-fn.h: Likewise.
* ipa-fnsummary.h: Likewise.
* ipa-icf-gimple.h: Likewise.
* ipa-inline.h: Likewise.
* ipa-modref.h: Likewise.
* ipa-prop.h: Likewise.
* ira-int.h: Likewise.
* ira.h: Likewise.
* lra-int.h: Likewise.
* lra.h: Likewise.
* lto-streamer.h: Likewise.
* memmodel.h: Likewise.
* omp-general.h: Likewise.
* optabs-query.h: Likewise.
* optabs.h: Likewise.
* plugin.h: Likewise.
* pretty-print.h: Likewise.
* range.h: Likewise.
* read-md.h: Likewise.
* recog.h: Likewise.
* regs.h: Likewise.
* rtl-iter.h: Likewise.
* rtl.h: Likewise.
* sbitmap.h: Likewise.
* sched-int.h: Likewise.
* sel-sched-ir.h: Likewise.
* sese.h: Likewise.
* sparseset.h: Likewise.
* ssa-iterators.h: Likewise.
* system.h: Likewise.
* target-globals.h: Likewise.
* target.h: Likewise.
* timevar.h: Likewise.
* tree-chrec.h: Likewise.
* tree-data-ref.h: Likewise.
* tree-iterator.h: Likewise.
* tree-outof-ssa.h: Likewise.
* tree-phinodes.h: Likewise.
* tree-scalar-evolution.h: Likewise.
* tree-sra.h: Likewise.
* tree-ssa-alias.h: Likewise.
* tree-ssa-live.h: Likewise.
* tree-ssa-loop-manip.h: Likewise.
* tree-ssa-loop.h: Likewise.
* tree-ssa-operands.h: Likewise.
* tree-ssa-propagate.h: Likewise.
* tree-ssa-sccvn.h: Likewise.
* tree-ssa.h: Likewise.
* tree-ssanames.h: Likewise.
* tree-streamer.h: Likewise.
* tree-switch-conversion.h: Likewise.
* tree-vectorizer.h: Likewise.
* tree.h: Likewise.
* wide-int.h: Likewise.

gcc/c-family/ChangeLog:

* c-common.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.

gcc/c/ChangeLog:

* c-parser.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.

gcc/cp/ChangeLog:

* cp-tree.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.

gcc/fortran/ChangeLog:

* gfortran.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.

gcc/jit/ChangeLog:

* jit-dejagnu.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.
* jit-recording.h: Likewise.

gcc/objc/ChangeLog:

* objc-act.h: Mechanically drop static from static inline
functions via s/^static inline/inline/g.
* objc-map.h: Likewise.
* objc-act.cc: Remove the redundant redeclarations of is_ivar
and lookup_category.

17 months agolibstdc++: Fix incorrect function call in -ffast-math optimization
Matthias Kretz [Fri, 3 Feb 2023 16:47:05 +0000 (17:47 +0100)]
libstdc++: Fix incorrect function call in -ffast-math optimization

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd_math.h (__hypot): Bitcasting
between scalars requires the __bit_cast helper function instead
of simd_bit_cast.

17 months agolibstdc++: Fix incorrect __builtin_is_constant_evaluated calls
Matthias Kretz [Thu, 2 Feb 2023 11:29:33 +0000 (12:29 +0100)]
libstdc++: Fix incorrect __builtin_is_constant_evaluated calls

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd_x86.h
(_SimdImplX86::_S_not_equal_to, _SimdImplX86::_S_less)
(_SimdImplX86::_S_less_equal): Do not call
__builtin_is_constant_evaluated in constexpr-if.

17 months agolibstdc++: printf format string fix in testsuite
Matthias Kretz [Thu, 2 Feb 2023 11:28:39 +0000 (12:28 +0100)]
libstdc++: printf format string fix in testsuite

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* testsuite/experimental/simd/tests/bits/verify.h
(verify::verify): Use %zx for size_t in format string.

17 months agolibstdc++: Use a PCH to speed up check-simd
Matthias Kretz [Thu, 2 Feb 2023 11:26:35 +0000 (12:26 +0100)]
libstdc++: Use a PCH to speed up check-simd

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* testsuite/experimental/simd/generate_makefile.sh: Generate and
pre-compile pch.h, which includes all headers that do not depend
on command-line macros.
* testsuite/experimental/simd/tests/bits/main.h: New file.
(iterate_abis, main): Moved from verify.h.
* testsuite/experimental/simd/tests/bits/verify.h
(iterate_abis, main): Moved to main.h.
* testsuite/experimental/simd/tests/bits/conversions.h: Add
include guard.
(genHalfBits): Simplify.
* testsuite/experimental/simd/tests/bits/make_vec.h: Add include
guard.
(make_alternating_mask): Moved from mask_loadstore.
* testsuite/experimental/simd/tests/bits/mathreference.h: Add
include guard.
* testsuite/experimental/simd/tests/bits/test_values.h: Ditto.
* testsuite/experimental/simd/tests/mask_loadstore.cc
(make_mask, make_alternating_mask): Removed.
* testsuite/experimental/simd/tests/mask_reductions.cc: Ditto.
* testsuite/experimental/simd/tests/operators.cc (genHalfBits):
Removed.
* testsuite/experimental/simd/tests/abs.cc: Only include
bits/main.h.
Ditto.
* testsuite/experimental/simd/tests/algorithms.cc: Ditto.
* testsuite/experimental/simd/tests/broadcast.cc: Ditto.
* testsuite/experimental/simd/tests/casts.cc: Ditto.
* testsuite/experimental/simd/tests/fpclassify.cc: Ditto.
* testsuite/experimental/simd/tests/frexp.cc: Ditto.
* testsuite/experimental/simd/tests/generator.cc: Ditto.
* testsuite/experimental/simd/tests/hypot3_fma.cc: Ditto.
* testsuite/experimental/simd/tests/integer_operators.cc: Ditto.
* testsuite/experimental/simd/tests/ldexp_scalbn_scalbln_modf.cc:
* testsuite/experimental/simd/tests/loadstore.cc: Ditto.
* testsuite/experimental/simd/tests/logarithm.cc: Ditto.
* testsuite/experimental/simd/tests/mask_broadcast.cc: Ditto.
* testsuite/experimental/simd/tests/mask_conversions.cc: Ditto.
* testsuite/experimental/simd/tests/mask_implicit_cvt.cc: Ditto.
* testsuite/experimental/simd/tests/mask_operator_cvt.cc: Ditto.
* testsuite/experimental/simd/tests/mask_operators.cc: Ditto.
* testsuite/experimental/simd/tests/math_1arg.cc: Ditto.
* testsuite/experimental/simd/tests/math_2arg.cc: Ditto.
* testsuite/experimental/simd/tests/operator_cvt.cc: Ditto.
* testsuite/experimental/simd/tests/reductions.cc: Ditto.
* testsuite/experimental/simd/tests/remqo.cc: Ditto.
* testsuite/experimental/simd/tests/simd.cc: Ditto.
* testsuite/experimental/simd/tests/sincos.cc: Ditto.
* testsuite/experimental/simd/tests/split_concat.cc: Ditto.
* testsuite/experimental/simd/tests/splits.cc: Ditto.
* testsuite/experimental/simd/tests/trigonometric.cc: Ditto.
* testsuite/experimental/simd/tests/trunc_ceil_floor.cc: Ditto.
* testsuite/experimental/simd/tests/where.cc: Ditto.

17 months agolibstdc++: Document timeout and timeout-factor of simd tests
Matthias Kretz [Thu, 2 Feb 2023 09:48:10 +0000 (10:48 +0100)]
libstdc++: Document timeout and timeout-factor of simd tests

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* testsuite/experimental/simd/README.md: Document the timeout
and timeout-factor directives. Minor typo fixed.

17 months agolibstdc++: Annotate most lambdas with always_inline
Matthias Kretz [Sat, 14 Jan 2023 16:07:59 +0000 (17:07 +0100)]
libstdc++: Annotate most lambdas with always_inline

All of the annotated lambdas are simply a necessary means for
implementing these functions and should never result in an actual
function call. Many of these lambdas would go away if C++ had better
language support for packs.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

PR libstdc++/108030
* include/experimental/bits/simd_detail.h: Define
_GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA.
* include/experimental/bits/simd.h: Annotate lambdas with
_GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA.
* include/experimental/bits/simd_builtin.h: Ditto.
* include/experimental/bits/simd_converter.h: Ditto.
* include/experimental/bits/simd_fixed_size.h: Ditto.
* include/experimental/bits/simd_math.h: Ditto.
* include/experimental/bits/simd_neon.h: Ditto.
* include/experimental/bits/simd_x86.h: Ditto.

17 months agolibstdc++: Ensure __builtin_constant_p isn't lost on the way
Matthias Kretz [Fri, 13 Jan 2023 15:20:36 +0000 (16:20 +0100)]
libstdc++: Ensure __builtin_constant_p isn't lost on the way

The more expensive code path should only be taken if it can be optimized
away.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
libstdc++-v3/ChangeLog:

* include/experimental/bits/simd.h
(_SimdWrapper::_M_is_constprop_none_of)
(_SimdWrapper::_M_is_constprop_all_of): Return false unless the
computed result still satisfies __builtin_constant_p.

17 months agolibstdc++: Replace non-ascii character in test
Jonathan Wakely [Thu, 16 Feb 2023 14:41:17 +0000 (14:41 +0000)]
libstdc++: Replace non-ascii character in test

This ensures the test will work with -fexec-charset=ascii.

libstdc++-v3/ChangeLog:

* testsuite/std/format/arguments/lwg3810.cc: Replace UTF-8
ellipsis character.

17 months agolibstdc++: Implement <experimental/synchronized_value> (P0290)
Jonathan Wakely [Wed, 15 Feb 2023 15:07:15 +0000 (15:07 +0000)]
libstdc++: Implement <experimental/synchronized_value> (P0290)

This was approved for the Concurrency TS v2 in Issaquah.

Although the TS is based on C++20, this enables the new header for C++17
as well. This will make it available to more users, and I hope that will
get more feedback on the feature.

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/experimental/synchronized_value: New file.
* testsuite/experimental/synchronized_value.cc: New test.

17 months agolibstdc++: Fix name of <experimental/optional> in comment
Jonathan Wakely [Wed, 15 Feb 2023 13:29:56 +0000 (13:29 +0000)]
libstdc++: Fix name of <experimental/optional> in comment

libstdc++-v3/ChangeLog:

* include/experimental/optional: Fix header name in comment.