platform/upstream/gcc.git
2 years ago[Ada] Avoid unwanted warnings for statically-known-successful assertions
Steve Baird [Tue, 24 May 2022 21:09:14 +0000 (14:09 -0700)]
[Ada] Avoid unwanted warnings for statically-known-successful assertions

The -gnatwc switch enables warnings for test condition outcomes that are
known at compile time. Such warnings are unlikely to be useful in the
case of an assertion expression (or a subexpression thereof), so do not
generate them in that case.

gcc/ada/

* sem_warn.adb (Warn_On_Constant_Valid_Condition): Do not
generate a warning if the expression in question is an assertion
expression, or a subexpression thereof. But do call
Test_Comparison so that it can generate warnings for the cases
that it generates warnings for.
* sem_prag.ads: Modify Assertion_Expression_Pragma constant so
that the predicate Sem_Util.In_Assertion_Expression_Pragma
returns True for the expression of a Compile_Time_Error pragma.

2 years ago[Ada] Add a RM entry for the functional infinite sequences
Julien Bortolussi [Tue, 24 May 2022 14:15:47 +0000 (16:15 +0200)]
[Ada] Add a RM entry for the functional infinite sequences

Modify the RM to take into account the new functional container.

gcc/ada/

* doc/gnat_rm/the_gnat_library.rst: Add the new entry.
* gnat_rm.texi: Regenerate.

2 years ago[Ada] Give missing error on ambiguous operand of equality operator
Eric Botcazou [Tue, 24 May 2022 18:38:01 +0000 (20:38 +0200)]
[Ada] Give missing error on ambiguous operand of equality operator

When the code responsible for giving errors on ambiguous operands of
comparison and equality operators was moved from the 1st phase (analysis)
to the 2nd phase (resolution) of semantic processing, it was incorrectly
restricted to the operator case, which was valid during the 1st phase but
is not during the 2nd phase.

gcc/ada/

* sem_res.adb (Resolve_Comparison_Op): Deal with ambiguous operands
in all cases.
(Resolve_Equality_Op): Likewise, except for the case of the implicit
inequality operator created for a user-defined operator that is not
an intrinsic subprogram.

2 years ago[Ada] Add Ada 2022 features to sets containers
Bob Duff [Mon, 23 May 2022 13:47:18 +0000 (09:47 -0400)]
[Ada] Add Ada 2022 features to sets containers

This patch adds some Ada 2022 features to the set children of
Ada.Containers.

gcc/ada/

* libgnat/a-cbhase.adb, libgnat/a-cbhase.ads,
libgnat/a-cborse.adb, libgnat/a-cborse.ads,
libgnat/a-cihase.adb, libgnat/a-cihase.ads,
libgnat/a-ciorse.adb, libgnat/a-ciorse.ads,
libgnat/a-cohase.adb, libgnat/a-cohase.ads,
libgnat/a-conhel.adb, libgnat/a-conhel.ads,
libgnat/a-coorse.adb, libgnat/a-coorse.ads: Add Has_Element,
Element, Query_Element, and Next subprograms that take a Set
parameter. Add Tampering_With_Cursors_Prohibited function. These
are all new in Ada 2022.

2 years ago[Ada] Update the documentation of functional containers
Claire Dross [Tue, 24 May 2022 14:37:18 +0000 (16:37 +0200)]
[Ada] Update the documentation of functional containers

Functional containers are now controlled. Update the documentation
accordingly.

gcc/ada/

* doc/gnat_rm/the_gnat_library.rst: Functional vectors, sets,
and maps are now controlled.
* gnat_rm.texi: Regenerate.

2 years ago[Ada] Add GNAT specific pragmas to the equivalent Assertion_Policy for -gnata
Claire Dross [Tue, 24 May 2022 08:42:46 +0000 (10:42 +0200)]
[Ada] Add GNAT specific pragmas to the equivalent Assertion_Policy for -gnata

All assertion pragmas are enabled by default when using -gnata. We need
to add the GNAT specific ones to the list.

gcc/ada/

* doc/gnat_ugn/building_executable_programs_with_gnat.rst
(Debugging and Assertion Control): Add GNAT specific assertion
pragmas to the equivalent Assertion_Policy for the -gnata
option.
* gnat_ugn.texi: Regenerate.

2 years ago[Ada] Incorrect accessibility check on return of discriminated type
Justin Squirek [Thu, 24 Mar 2022 18:42:09 +0000 (18:42 +0000)]
[Ada] Incorrect accessibility check on return of discriminated type

This patch corrects an error in the compiler whereby the presence of a
call to a function returning a type with an access discriminant within
an expanded loop condition caused the wrong value to be supplied for the
extra- accessibility-of-result actual, thus causing incorrect checks
within the callee at the point of return.

This change also corrects a problem where spurious "null value not
allowed" warnings were generated for tagged type declarations with an
access discriminant specified as "null."

gcc/ada/

* sem_disp.adb (Most_Descendant_Use_Clause): Remove call to
deprecated Is_Internal.
* sem_util.adb (Innermost_Master_Scope_Depth): Use
Find_Enclosing_Scope instead of Nearest_Dynamic_Scope to avoid
cases where relevant scopes get skipped leading to an incorrect
scope depth calculation.

2 years ago[Ada] Plug loophole for built-in-place return with limited_with clause
Eric Botcazou [Mon, 23 May 2022 23:14:18 +0000 (01:14 +0200)]
[Ada] Plug loophole for built-in-place return with limited_with clause

When the result type of a function requiring built-in-place return is
only visible through a limited_with clause, the compiled needs to wait
for the nonlimited view to be available in order to compute whether
the built-in-place return is needed, and this comprises tagging the
function with the Returns_By_Ref flag.

gcc/ada/

* exp_ch6.adb (Build_In_Place_Formal): Also compute Returns_By_Ref
for the function if the extra formals were not built initially.

2 years ago[Ada] Fix for resolution of overloaded subprogram for Iterable aspect
Piotr Trojanek [Fri, 20 May 2022 20:29:51 +0000 (22:29 +0200)]
[Ada] Fix for resolution of overloaded subprogram for Iterable aspect

When resolving the Iterable aspect we look for a functions that are
declared in the same scope as the annotated type and that have the
required number and types formal parameters. However, we didn't guard
against functions that have no formal parameter at all.

gcc/ada/

* sem_ch13.adb (Resolve_Iterable_Operation): Add guard to
prevent crash when the examined function has no formal
parameters and Etype is called on Empty entity.

2 years ago[Ada] Create new unbounded functional sequence
Julien Bortolussi [Wed, 4 May 2022 15:45:34 +0000 (17:45 +0200)]
[Ada] Create new unbounded functional sequence

Add a new unbounded functional sequence. This sequence is indexed by
Big_Positive and so is unbounded from the user and spark points view.
Hower the actually implemented sequence are bounded by Count_Type'Last.

gcc/ada/

* libgnat/a-cfinse.adb, libgnat/a-cfinse.ads: Implementation
files of the sequence.
* Makefile.rtl, impunit.adb: Take into account the add of the
new files

2 years ago[Ada] Adjust description of Pure_Function pragma
Eric Botcazou [Mon, 23 May 2022 07:48:49 +0000 (09:48 +0200)]
[Ada] Adjust description of Pure_Function pragma

The current wording can be read as implying that the result of a call
to a pure function does not depend on the context, which is incorrect.
The pragma only guarantees the absence of side effects of such a call.

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst (Pure_Function):
Fix ambiguous wording about context dependence.
* gnat_rm.texi: Regenerate.

2 years agotree-optimization/106055 - issue with autopar
Richard Biener [Fri, 1 Jul 2022 13:32:30 +0000 (15:32 +0200)]
tree-optimization/106055 - issue with autopar

When autopar uses graphites canonicalize_loop_closed_ssa it fails to
check whether propagation is allowed and thus it ends up messing up
abnormal constraints.

2022-07-01  Richard Biener  <rguenther@suse.de>

PR tree-optimization/106055
* graphite.cc (canonicalize_loop_closed_ssa): Check whether
we can propagate.

* gcc.dg/graphite/pr106055.c: New testcase.

2 years agoi386: Extend cvtps2pd to memory
Haochen Jiang [Mon, 30 May 2022 09:12:31 +0000 (17:12 +0800)]
i386: Extend cvtps2pd to memory

gcc/ChangeLog:

PR target/43618
* config/i386/sse.md (extendv2sfv2df2): New define_expand.
(sse2_cvtps2pd_<mask_name>): Change constraint of operands[1].
(*sse2_cvtps2pd_<mask_name>_1): Rename from extendvsdfv2df2.

gcc/testsuite/ChangeLog:

PR target/43618
* gcc.target/i386/pr43618-1.c: New test.

2 years agoRemove some deprecated irange methods.
Aldy Hernandez [Sun, 3 Jul 2022 16:22:11 +0000 (18:22 +0200)]
Remove some deprecated irange methods.

Tested on x86-64 Linux.

gcc/ChangeLog:

* ipa-cp.cc (ipcp_vr_lattice::meet_with_1): Use operator!=.
* ipa-prop.cc (struct ipa_vr_ggc_hash_traits): Same.
* tree-ssa-loop-unswitch.cc (struct unswitch_predicate): Use set
with two arguments.
(find_unswitching_predicates_for_bb): Same.
* tree-vrp.cc (range_fold_unary_symbolics_p): Same.
* value-range-equiv.cc (value_range_equiv::equal_p): Use operator==.
* value-range.cc (irange::equal_p): Rename to...
(irange::operator==): ...this.
* value-range.h (irange::set): Remove.
(irange::operator==): Remove.
(irange::set_zero): Use set with two arguments.
* vr-values.cc (vr_values::extract_range_from_binary_expr): Same.
(vr_values::extract_range_from_unary_expr): Same.
(check_for_binary_op_overflow): Same.
(bounds_of_var_in_loop): Same.

2 years agoDaily bump.
GCC Administrator [Mon, 4 Jul 2022 00:16:19 +0000 (00:16 +0000)]
Daily bump.

2 years agox86: Support 2/4/8 byte constant vector stores
H.J. Lu [Sat, 18 Jun 2022 00:02:05 +0000 (17:02 -0700)]
x86: Support 2/4/8 byte constant vector stores

1. Add a predicate for constant vectors which can be converted to integer
constants suitable for constant integer stores.  For a 8-byte constant
vector, the converted 64-bit integer must be valid for store with 64-bit
immediate, which is a 64-bit integer sign-extended from a 32-bit integer.
2. Add a new pattern to allow 2-byte, 4-byte and 8-byte constant vector
stores, like

(set (mem:V2HI (reg:DI 84))
     (const_vector:V2HI [(const_int 0 [0]) (const_int 1 [0x1])]))

3. After reload, convert constant vector stores to constant integer
stores, like

(set (mem:SI (reg:DI 5 di [84]))
     (const_int 65536 [0x10000]))

For

void
foo (short * c)
{
  c[0] = 0;
  c[1] = 1;
}

it generates

movl $65536, (%rdi)

instead of

movl .LC0(%rip), %eax
movl %eax, (%rdi)

gcc/

PR target/106022
* config/i386/i386-protos.h (ix86_convert_const_vector_to_integer):
New.
* config/i386/i386.cc (ix86_convert_const_vector_to_integer):
New.
* config/i386/mmx.md (V_16_32_64): New.
(*mov<mode>_imm): New patterns for stores with 16-bit, 32-bit
and 64-bit constant vector.
* config/i386/predicates.md (x86_64_const_vector_operand): New.

gcc/testsuite/

PR target/106022
* gcc.target/i386/pr106022-1.c: New test.
* gcc.target/i386/pr106022-2.c: Likewise.
* gcc.target/i386/pr106022-3.c: Likewise.
* gcc.target/i386/pr106022-4.c: Likewise.

2 years agoMove range allocator code to value-range-storage.*
Aldy Hernandez [Sun, 3 Jul 2022 13:25:38 +0000 (15:25 +0200)]
Move range allocator code to value-range-storage.*

Now that vrange_storage is in its own file, I think it's prudent to
move all the vrange allocator code there since it's all related.
The users of value-range.h do not need to know the implementation
details of the storage facilities.

Tested and benchmarked on x86-64 Linux.

gcc/ChangeLog:

* gimple-range-cache.cc: Include value-range-storage.h.
* gimple-range-cache.h (class block_range_cache): Add "class" to
m_range_allocator.
* gimple-range-edge.cc
(gimple_outgoing_range::gimple_outgoing_range): Allocate allocator.
(gimple_outgoing_range::~gimple_outgoing_range): Free allocator.
(gimple_outgoing_range::calc_switch_ranges): Dereference allocator.
* gimple-range-edge.h: Add "class" to m_range_allocator.
* gimple-range-infer.cc
(infer_range_manager::infer_range_manager): Allocate allocator.
(infer_range_manager::~infer_range_manager): Free allocator.
(infer_range_manager::get_nonzero): Dereference allocator.
(infer_range_manager::add_range): Same.
* gimple-range-infer.h (class vrange_allocator): Add "class" to
m_range_allocator.
* value-range-storage.h (class vrange_allocator): Move from
value-range.h.
(class obstack_vrange_allocator): Same.
(class ggc_vrange_allocator): Same.
(vrange_allocator::alloc_vrange): Same.
(vrange_allocator::alloc_irange): Same.
* value-range.h (class vrange_allocator): Move to value-range-storage.h.
(class obstack_vrange_allocator): Same.
(class ggc_vrange_allocator): Same.

2 years agoAdd myself to write after approval and DCO.
Immad Mir [Sun, 3 Jul 2022 09:08:51 +0000 (14:38 +0530)]
Add myself to write after approval and DCO.

This is text alignment correction for my previous patch.

ChangeLog:
* MAINTAINERS: add myself.

2 years agoAdd myself to write-after-approval and DCO
Immad Mir [Sun, 3 Jul 2022 08:56:14 +0000 (14:26 +0530)]
Add myself to write-after-approval and DCO

ChangeLog:
* MAINTAINERS: Add myself to write after approval and DCO.

2 years agoImplement class vrange_storage to stream ranges to long term memory.
Aldy Hernandez [Fri, 10 Jun 2022 12:59:40 +0000 (14:59 +0200)]
Implement class vrange_storage to stream ranges to long term memory.

This patch implements a storage class that will be used to stream out
ranges to long term storage, initially in SSA_NAME_RANGE_INFO, but it
is flexible enough to use with our obstack allocator.  For instance,
in the future we could use it in the ranger cache to save memory.

The current size of range_info_def which is used in
SSA_NAME_RANGE_INFO is 16 bytes.  With this patch, the size of the
slot (irange_storage_slot) will be 24 bytes.  But we'll have the
ability to be able to store up to 5 pairs of sub-ranges if necessary.
If we ever need to save more (say for switches), we could explore a
trailing_wide_ints structure with a pointer to the m_len[N] bits as
Jakub has suggested.

In follow-up patches I will contribute the SSA_NAME_RANGE_INFO changes
as well as changes storing the nonzero bits within an irange.

For reference, the main interface is rather simple:

class vrange_storage
{
public:
  vrange_storage (vrange_allocator *alloc) : m_alloc (alloc) { }
  void *alloc_slot (const vrange &r);
  void free (void *slot);
  void get_vrange (const void *slot, vrange &r, tree type);
  void set_vrange (void *slot, const vrange &r);
  static bool fits_p (const void *slot, const vrange &r);
};

The above class will have the knowledge to stream out the different
ranges we support (currently only irange_storage_slot).  As has been
discussed, the irange storage will use trailing wide ints:

class GTY ((variable_size)) irange_storage_slot
{
<snip>
<snip>
  // This is the maximum number of wide_int's allowed in the trailing
  // ints structure, without going over 16 bytes (128 bits) in the
  // control word that preceeds the HOST_WIDE_INTs in
  // trailing_wide_ints::m_val[].
  static const unsigned MAX_INTS = 12;

  // Maximum number of range pairs we can handle, considering the
  // nonzero bits take one wide_int.
  static const unsigned MAX_PAIRS = (MAX_INTS - 1) / 2;

  trailing_wide_ints<MAX_INTS> m_ints;
};

Tested on x86-64 Linux.

gcc/ChangeLog:

* Makefile.in (OBJS): Add value-range-storage.o.
(GTFILES): Add value-range-storage.h.
* gengtype.cc (open_base_files): Add value-range-storage.h.
* value-range-storage.cc: New file.
* value-range-storage.h: New file.

2 years agoloongarch: use -mno-check-zero-division as the default for optimized code
Xi Ruoyao [Sat, 2 Jul 2022 08:16:44 +0000 (16:16 +0800)]
loongarch: use -mno-check-zero-division as the default for optimized code

Integer division by zero is undefined behavior anyway, and there are
already many platforms where neither the GCC port and the hardware do
anything to trap on division by zero.  So any portable program shall not
rely on SIGFPE on division by zero, in both theory and practice.  As the
result, there is no real reason to cost two additional instructions just
for the trap on division by zero with a new ISA.

One remaining reason to trap on division by zero may be debugging,
especially while -fsanitize=integer-divide-by-zero is not implemented
for LoongArch yet.  To make debugging easier, keep -mcheck-zero-division
as the default for -O0 and -Og, but use -mno-check-zero-division as the
default for all other optimization levels.

Co-authored-by: Lulu Cheng <chenglulu@loongson.cn>
gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_check_zero_div_p):
New static function.
(loongarch_idiv_insns): Use loongarch_check_zero_div_p instead
of TARGET_CHECK_ZERO_DIV.
(loongarch_output_division): Likewise.
* common/config/loongarch/loongarch-common.cc
(TARGET_DEFAULT_TARGET_FLAGS): Remove unneeded hook.
* doc/invoke.texi: Update to match the new behavior.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/20101011-1.c (dg-additional-options):
add -mcheck-zero-division for LoongArch targets.

2 years agoUse fixed-width types in allocation size tests
Tim Lange [Sun, 3 Jul 2022 01:22:30 +0000 (03:22 +0200)]
Use fixed-width types in allocation size tests

The patch changes the types inside the tests for the allocation size
checker to fixed-width types of stdint.h to account for different
architectures with different type widths.

2022-07-03  Tim Lange  <mail@tim-lange.me>

gcc/testsuite/ChangeLog:

* gcc.dg/analyzer/allocation-size-1.c: Use fixed-length types.
* gcc.dg/analyzer/allocation-size-2.c: Likewise.
* gcc.dg/analyzer/allocation-size-3.c: Likewise.
* gcc.dg/analyzer/allocation-size-4.c: Likewise.
* gcc.dg/analyzer/allocation-size-5.c: Likewise.

2 years agotree-optimization: only DSE trapping insn if -fdelete-dead-exceptions
Ian Lance Taylor [Fri, 1 Jul 2022 21:51:45 +0000 (14:51 -0700)]
tree-optimization: only DSE trapping insn if -fdelete-dead-exceptions

gcc/ChangeLog:

* tree-ssa-dse.cc (dse_optimize_stmt): Only delete a trapping
statement if -fdelete-dead-exceptions.

gcc/testsuite/ChangeLog:

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

2 years agoDaily bump.
GCC Administrator [Sun, 3 Jul 2022 00:16:23 +0000 (00:16 +0000)]
Daily bump.

2 years agoMAINTAINERS: Add myself to write after approval and DCO
Tim Lange [Sat, 2 Jul 2022 17:27:08 +0000 (19:27 +0200)]
MAINTAINERS: Add myself to write after approval and DCO

2022-07-02  Tim Lange  <mail@tim-lange.me>

ChangeLog:

* MAINTAINERS: Add myself.

2 years agoanalyzer: add allocation size checker [PR105900]
Tim Lange [Thu, 30 Jun 2022 22:02:17 +0000 (00:02 +0200)]
analyzer: add allocation size checker [PR105900]

This patch adds an checker that warns about code paths in which a buffer
is assigned to a incompatible type, i.e. when the allocated buffer size
is not a multiple of the pointee's size.

Regression-tested on x86_64 Linux. Also compiled coreutils, curl, openssh and
httpd with the patch enabled.

2022-07-01  Tim Lange  <mail@tim-lange.me>

gcc/analyzer/ChangeLog:

PR analyzer/105900
* analyzer.opt: Added Wanalyzer-allocation-size.
* checker-path.cc (region_creation_event::get_desc): Added call to new
virtual function pending_diagnostic::describe_region_creation_event.
* checker-path.h: Added region_creation_event::get_desc.
* diagnostic-manager.cc (diagnostic_manager::add_event_on_final_node):
New function.
* diagnostic-manager.h:
Added diagnostic_manager::add_event_on_final_node.
* pending-diagnostic.h (struct region_creation): New event_desc struct.
(pending_diagnostic::describe_region_creation_event): Added virtual
function to overwrite description of a region creation.
* region-model.cc (class dubious_allocation_size): New class.
(capacity_compatible_with_type): New helper function.
(class size_visitor): New class.
(struct_or_union_with_inheritance_p): New helper function.
(is_any_cast_p): New helper function.
(region_model::check_region_size): New function.
(region_model::set_value): Added call to
region_model::check_region_size.
* region-model.h (class region_model): New function check_region_size.
* svalue.cc (region_svalue::accept): Changed to post-order traversal.
(initial_svalue::accept): Likewise.
(unaryop_svalue::accept): Likewise.
(binop_svalue::accept): Likewise.
(sub_svalue::accept): Likewise.
(repeated_svalue::accept): Likewise.
(bits_within_svalue::accept): Likewise.
(widening_svalue::accept): Likewise.
(unmergeable_svalue::accept): Likewise.
(compound_svalue::accept): Likewise.
(conjured_svalue::accept): Likewise.
(asm_output_svalue::accept): Likewise.
(const_fn_result_svalue::accept): Likewise.

gcc/ChangeLog:

PR analyzer/105900
* doc/invoke.texi: Added Wanalyzer-allocation-size.

gcc/testsuite/ChangeLog:

PR analyzer/105900
* gcc.dg/analyzer/pr96639.c: Changed buffer size to omit warning.
* gcc.dg/analyzer/allocation-size-1.c: New test.
* gcc.dg/analyzer/allocation-size-2.c: New test.
* gcc.dg/analyzer/allocation-size-3.c: New test.
* gcc.dg/analyzer/allocation-size-4.c: New test.
* gcc.dg/analyzer/allocation-size-5.c: New test.

Signed-off-by: Tim Lange <mail@tim-lange.me>
2 years agoanalyzer: implement five new warnings for misuse of POSIX file descriptor APIs [PR106...
Immad Mir [Sat, 2 Jul 2022 16:39:37 +0000 (22:09 +0530)]
analyzer: implement five new warnings for misuse of POSIX file descriptor APIs [PR106003].

This patch adds a new state machine to the analyzer for checking usage of POSIX file descriptor
APIs with five new warnings.

It adds:
- check for FD leaks (CWE 775).
- check for double "close" of a FD (CWE-1341).
- check for read/write of a closed file descriptor.
- check whether a file descriptor was used without being checked for validity.
- check for read/write of a descriptor opened for just writing/reading.

gcc/ChangeLog:
PR analyzer/106003
* Makefile.in (ANALYZER_OBJS): Add sm-fd.o.
* doc/invoke.texi:  Add -Wanalyzer-fd-double-close, -Wanalyzer-fd-leak,
-Wanalyzer-fd-access-mode-mismatch, -Wanalyzer-fd-use-without-check,
-Wanalyzer-fd-use-after-close.

gcc/analyzer/ChangeLog:
PR analyzer/106003
* analyzer.opt (Wanalyzer-fd-leak): New option.
(Wanalyzer-fd-access-mode-mismatch): New option.
(Wanalyzer-fd-use-without-check): New option.
(Wanalyzer-fd-double-close): New option.
(Wanalyzer-fd-use-after-close): New option.
* sm.h (make_fd_state_machine): New decl.
* sm.cc (make_checkers): Call make_fd_state_machine.
* sm-fd.cc: New file.

gcc/testsuite/ChangeLog:
PR analyzer/106003
* gcc.dg/analyzer/fd-1.c: New test.
* gcc.dg/analyzer/fd-2.c: New test.
* gcc.dg/analyzer/fd-3.c: New test.
* gcc.dg/analyzer/fd-4.c: New test.

2 years agoDaily bump.
GCC Administrator [Sat, 2 Jul 2022 00:16:26 +0000 (00:16 +0000)]
Daily bump.

2 years agocompiler: use correct init order for multi-value initialization
Ian Lance Taylor [Fri, 1 Jul 2022 00:40:00 +0000 (17:40 -0700)]
compiler: use correct init order for multi-value initialization

Use the correct initialization order for

var a = c
var b, c = x.(bool)

The global c is initialized by the preinit of b, but were missing a
dependency of c on b, so a would be initialized to the zero value of c
rather than the correct value.

Simply adding the dependency of c on b didn't work because the preinit
of b refers to c, so that appeared circular.  So this patch changes
the init order to skip dependencies that only appear on the left hand
side of assignments in preinit blocks.

Doing that didn't work because the write barrier pass can transform "a
= b" into code like "gcWriteBarrier(&a, b)" that is not obviously a
simple assigment.  So this patch moves the collection of dependencies
to just after lowering, before the write barriers are inserted.

Making those changes permit relaxing the requirement that we don't
warn about self-dependency in preinit blocks, so now we correctly warn
for

var a, b any = b.(bool)

The test case is https://go.dev/cl/415238.

Fixes golang/go#53619

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

2 years agotrailing_wide_ints with runtime variable lengths
Aldy Hernandez [Fri, 10 Jun 2022 13:00:44 +0000 (15:00 +0200)]
trailing_wide_ints with runtime variable lengths

Currently global ranges are stored in SSA_NAME_RANGE_INFO as a pair of
wide_int-like objects along with the nonzero bits.  We frequently lose
precision when streaming out our higher resolution iranges.  The plan
was always to store the full irange between passes.  However, as was
originally discussed eons ago:

https://gcc.gnu.org/pipermail/gcc-patches/2017-May/475139.html

...we need a memory efficient way of saving iranges, preferably using
the trailing_wide_ints idiom.

The problem with doing so is that trailing_wide_ints assume a
compile-time specified number of elements.  For irange, we need to
determine the size at run-time.

One solution is to adapt trailing_wide_ints such that N is the maximum
number of elements allowed, and allow setting the actual number at
run-time (defaulting to N).  The attached patch does this, while
requiring no changes to existing users.

It uses a byte to store the number of elements in the
trailing_wide_ints control word.  The control word is currently a
16-bit precision, an 8-bit max-length, and the rest is used for
m_len[N].  On a 64-bit architecture, this allows for 5 elements in
m_len without having to use an extra word.  With this patch, m_len[]
would be smaller by one byte (4) before consuming the padding.  This
shouldn't be a problem as the only users of trailing_wide_ints use N=2
for NUM_POLY_INT_COEFFS in aarch64, and N=3 for range_info_def.

For irange, my plan is to use one more word to fit a maximum of 12
elements (the above 4 plus 8 more).  This would allow for 6 pairs of
sub-ranges which would be more than adequate for our needs.  In
previous tests we found that 99% of ranges fit within 3-4 pairs.  More
precisely, this would allow for 5 pairs, plus the nonzero bits, plus a
spare wide-int for future development.

Ultimately this means that streaming an irange would consume one more
word than what we currently do for range_info_def.  IMO this is a nice
trade-off considering we started storing a slew of wide-ints directly
;-).

Tested and benchmarked on x86-64 Linux.  There was no discernible
performance change in our benchmark suite.

gcc/ChangeLog:

* wide-int.h (struct trailing_wide_ints): Add m_num_elements.
(trailing_wide_ints::set_precision): Add num_elements argument.
(trailing_wide_ints::extra_size): Same.

2 years agolibstdc++: Add missing prerequisite to generated header [PR106162]
Jonathan Wakely [Fri, 1 Jul 2022 21:23:43 +0000 (22:23 +0100)]
libstdc++: Add missing prerequisite to generated header [PR106162]

The ${host_builddir}/largefile-config.h header can't be written until
its parent directory has been created, so it needs to have the creation
of that directory as a prerequisite.

libstdc++-v3/ChangeLog:

PR libstdc++/106162
* include/Makefile.am (largefile-config.h): Add
stamp-${host_alias} prerequisite.
* include/Makefile.in: Regenerate.

2 years agoc++: Minor cleanup in parser.cc
Lewis Hyatt [Fri, 1 Jul 2022 17:53:34 +0000 (13:53 -0400)]
c++: Minor cleanup in parser.cc

The code to determine whether a given token starts a module directive is
currently repeated in 4 places in parser.cc. I am about to submit a patch
that needs to add it in a 5th place, so since the code is not completely
trivial (needing to check for 3 different token types), it seems worthwhile
to factor this logic into its own function.

gcc/cp/ChangeLog:

* parser.cc (cp_token_is_module_directive): New function
refactoring common code.
(cp_parser_skip_to_closing_parenthesis_1): Use the new function.
(cp_parser_skip_to_end_of_statement): Likewise.
(cp_parser_skip_to_end_of_block_or_statement): Likewise.
(cp_parser_declaration): Likewise.

2 years agocompiler: rename "requires" to "needs"
Ian Lance Taylor [Fri, 1 Jul 2022 17:56:37 +0000 (10:56 -0700)]
compiler: rename "requires" to "needs"

As of C++20 "requires" is a C++ keyword.

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

2 years agoc++: fix broken copy elision with nested TARGET_EXPRs [PR105550]
Marek Polacek [Wed, 25 May 2022 22:11:31 +0000 (18:11 -0400)]
c++: fix broken copy elision with nested TARGET_EXPRs [PR105550]

In this problem, we are failing to properly perform copy elision with
a conditional operator, so this:

  constexpr A a = true ? A{} : A{};

fails with:

  error: 'A{((const A*)(&<anonymous>))}' is not a constant expression

The whole initializer is

  TARGET_EXPR <D.2395, 1 ? TARGET_EXPR <D.2393, {.p=(const struct A *) &<PLACEHOLDER_EXPR struct A>}> : TARGET_EXPR <D.2394, {.p=(const struct A *) &<PLACEHOLDER_EXPR struct A>}>>

where the outermost TARGET_EXPR is elided, but not the nested ones.
Then we end up replacing the PLACEHOLDER_EXPRs with the temporaries the
TARGET_EXPRs represent, which is precisely what should *not* happen with
copy elision.

I've tried the approach of tweaking ctx->object, but I ran into gazillion
problems with that.  I thought that I would let cxx_eval_constant_expression
/TARGET_EXPR create a new object only when ctx->object was null, then
adjust setting of ctx->object in places like cxx_bind_parameters_in_call
and cxx_eval_component_reference but that failed completely.  Sometimes
ctx->object has to be reset, sometimes it cannot be reset, 'this' needed
special handling, etc.  I gave up.

Instead, this patch strips TARGET_EXPRs from the operands of ?: like
we do in various other places in constexpr.c.

PR c++/105550

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_conditional_expression): Strip TARGET_EXPRs.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/nsdmi-aggr16.C: Remove FIXME.
* g++.dg/cpp1y/nsdmi-aggr17.C: Remove FIXME.
* g++.dg/cpp0x/constexpr-elision1.C: New test.
* g++.dg/cpp1y/constexpr-elision1.C: New test.

2 years agoOpenMP: Handle tofrom with target enter/exit data
Tobias Burnus [Fri, 1 Jul 2022 15:52:03 +0000 (17:52 +0200)]
OpenMP: Handle tofrom with target enter/exit data

In 5.2, a map clause can be map-entering or map-exiting,
either containing 'tofrom'. The main reason for this is
permit 'map(x)' with 'omp target enter/exit data',
avoiding to specify 'to:/from:' explicitly. (OpenMP
defaults to 'tofrom'.)

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_target_enter_data,
c_parser_omp_target_exit_data): Accept tofrom
map-type modifier but use 'to' / 'from' internally.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_target_enter_data,
cp_parser_omp_target_exit_data): Accept tofrom
map-type modifier but use 'to' / 'from' internally.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (show_omp_namelist): For the map-type,
also handle the always modifer and release/delete.
* openmp.cc (resolve_omp_clauses): Accept tofrom
map-type modifier for target enter/exit data,
but use 'to' / 'from' internally.

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.2): Mark target enter/exit data
with fromto as implemented.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/target-data-2.c: New test.
* c-c++-common/gomp/target-data-3.c: New test.
* gfortran.dg/gomp/target-data-1.f90: New test.
* gfortran.dg/gomp/target-data-2.f90: New test.

2 years agoi386: Use "r" constraint in *andn<mode>3_doubleword_bmi
Uros Bizjak [Fri, 1 Jul 2022 15:25:03 +0000 (17:25 +0200)]
i386: Use "r" constraint in *andn<mode>3_doubleword_bmi

ANDN is non-destructive, so use "r" instead of "0" for its operand 1 constraint.

2022-07-01  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

* config/i386/i386.md (*andn<mode>3_doubleword_bmi):
Use "r" constraint for operand 1.

2 years agoc++: warn about using keywords as identifiers [PR106111]
Marek Polacek [Tue, 28 Jun 2022 22:59:19 +0000 (18:59 -0400)]
c++: warn about using keywords as identifiers [PR106111]

In C++03, -Wc++11-compat should warn about

  int constexpr;

since 'constexpr' is a keyword in C++11.  Jonathan reports that
we don't emit a similar warning for 'alignas' or 'alignof', and,
as I found out, 'thread_local'.

Similarly, we don't warn for most C++20 keywords.  That happens
because RID_LAST_CXX20 hasn't been updated in a while.

PR c++/106111

gcc/c-family/ChangeLog:

* c-common.h (enum rid): Update RID_LAST_CXX20.

gcc/cp/ChangeLog:

* parser.cc (cp_lexer_get_preprocessor_token): Also warn about
RID_ALIGNOF, RID_ALIGNAS, RID_THREAD.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/keywords1.C: New test.
* g++.dg/cpp2a/keywords1.C: New test.

2 years agoAdd a recursion limit to the demangle_const function in the Rust demangler.
Nick Clifton [Fri, 1 Jul 2022 14:58:52 +0000 (15:58 +0100)]
Add a recursion limit to the demangle_const function in the Rust demangler.

libiberty/
PR demangler/105039
* rust-demangle.c (demangle_const): Add recursion limit.

2 years agoc++: tweak resolve_args change
Jason Merrill [Fri, 1 Jul 2022 04:37:10 +0000 (00:37 -0400)]
c++: tweak resolve_args change

I don't know why I used tf_error instead of complain here.

PR c++/105779

gcc/cp/ChangeLog:

* call.cc (resolve_args): Use complain.

2 years agoc++: add fixup to missing .template warning
Jason Merrill [Wed, 29 Jun 2022 21:12:09 +0000 (17:12 -0400)]
c++: add fixup to missing .template warning

I experimented with giving this diagnostic in another place, which didn't
work out, but we can still benefit from adding the fixup.

gcc/cp/ChangeLog:

* parser.cc (missing_template_diag): Split out...
(cp_parser_id_expression): ...from here.

2 years agoc++: dependent generic lambda template-id [PR106024]
Jason Merrill [Fri, 24 Jun 2022 03:14:35 +0000 (23:14 -0400)]
c++: dependent generic lambda template-id [PR106024]

We were wrongly looking up the generic lambda op() in a dependent scope, and
then trying to look up its instantiation at substitution time, but lambdas
aren't instantiated, so we crashed.  The fix is to not look into dependent
class scopes.

But this created trouble with wrongly trying to use a template from the
enclosing scope when we aren't actually looking at a template-argument-list,
in template/lookup18.C, so let's avoid that.

PR c++/106024

gcc/cp/ChangeLog:

* parser.cc (missing_template_diag): Factor out...
(cp_parser_id_expression): ...from here.
(cp_parser_lookup_name): Don't look in dependent object_type.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-generic10.C: New test.

2 years agoAvoid unused sbitmap in update_ssa
Richard Biener [Fri, 1 Jul 2022 11:59:32 +0000 (13:59 +0200)]
Avoid unused sbitmap in update_ssa

The following avoids copying and using blocks_to_update to
the interesting_blocks sbitmap when doing update_ssa as it is
unused besides the redundant query in the domwalk.

* tree-into-ssa.cc (rewrite_update_dom_walker::before_dom_children):
Do not look at interesting_blocks which is a copy of
blocks_to_update.
(update_ssa): Do not initialize it.
(pass_build_ssa::execute): Set interesting_blocks to NULL
after releasing it.

2 years agoRevert maybe_ne -> known_ne change in vn_reference_lookup_3
Richard Biener [Fri, 1 Jul 2022 11:16:33 +0000 (13:16 +0200)]
Revert maybe_ne -> known_ne change in vn_reference_lookup_3

This reverts the change as discussed.

2022-07-01  Richard Biener  <rguenther@suse.de>

* tree-ssa-sccvn.cc (vn_reference_lookup_3): Revert
back to using maybe_ne (off, -1).

2 years agoMake sure checking code is conditional in VN
Richard Biener [Fri, 1 Jul 2022 10:35:58 +0000 (12:35 +0200)]
Make sure checking code is conditional in VN

VN has checking code with gcc_unreachable (), the following makes
it cheaper by instead guarding the side-effect with flag_checking.

2022-07-01  Richard Biener  <rguenther@suse.de>

* tree-ssa-sccvn.cc (vn_nary_op_insert_into): Make
checking dominance check conditional on flag_checking.

2 years agolibstdc++: Add nodiscard attribute to filesystem operations
Jonathan Wakely [Fri, 1 Jul 2022 10:40:29 +0000 (11:40 +0100)]
libstdc++: Add nodiscard attribute to filesystem operations

Some of these are not truly "pure" because they access the file system,
e.g. exists and file_size, but they do not modify anything and are only
useful for the return value.

If you really want to use one of those functions just to check whether
an error is reported (either via an exception or an error_code&
argument) you can still do so, but you need to cast the discarded result
to void.  Several tests need such a change, because they were indeed
only calling the functions to check for expected errors.

libstdc++-v3/ChangeLog:

* include/bits/fs_ops.h: Add nodiscard to all pure functions.
* include/experimental/bits/fs_ops.h: Likewise.
* testsuite/27_io/filesystem/operations/all.cc: Do not discard
results of absolute and canonical.
* testsuite/27_io/filesystem/operations/absolute.cc: Cast
discarded result to void.
* testsuite/27_io/filesystem/operations/canonical.cc: Likewise.
* testsuite/27_io/filesystem/operations/exists.cc: Likewise.
* testsuite/27_io/filesystem/operations/is_empty.cc: Likewise.
* testsuite/27_io/filesystem/operations/read_symlink.cc:
Likewise.
* testsuite/27_io/filesystem/operations/status.cc: Likewise.
* testsuite/27_io/filesystem/operations/symlink_status.cc:
Likewise.
* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
Likewise.
* testsuite/experimental/filesystem/operations/canonical.cc:
Likewise.
* testsuite/experimental/filesystem/operations/exists.cc:
Likewise.
* testsuite/experimental/filesystem/operations/is_empty.cc:
Likewise.
* testsuite/experimental/filesystem/operations/read_symlink.cc:
Likewise.
* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
Likewise.

2 years agogcn: Remove useless register keyword
Tobias Burnus [Fri, 1 Jul 2022 10:21:24 +0000 (12:21 +0200)]
gcn: Remove useless register keyword

gcc/ChangeLog:

* config/gcn/gcn-protos.h (print_operand_address): Remove register
keyword on 'rtx addr' argument.

2 years ago[Committed] Add constraints to new andn<dwi>_doubleword_bmi pattern in i386.md.
Roger Sayle [Fri, 1 Jul 2022 10:14:12 +0000 (11:14 +0100)]
[Committed] Add constraints to new andn<dwi>_doubleword_bmi pattern in i386.md.

Many thanks to Uros for spotting that I'd forgotten to add constraints
to the new define_insn_and_split *andn<dwi>_doubleword_bmi when moving it
from pre-reload to post-reload.  I've pushed this obvious fix after a
make bootstrap on x86_64-pc-linux-gnu.  Sorry for the inconvenience to
anyone building the tree with a non-default architecture that enables
BMI.

2022-07-01  Roger Sayle  <roger@nextmovesoftware.com>
    Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog
* config/i386/i386.md (*andn<mode>3_doubleword_bmi): Add constraints
to post-reload define_insn_and_split.

2 years agoEnable some features for RTEMS in libstdc++
Sebastian Huber [Wed, 8 Jun 2022 06:44:36 +0000 (08:44 +0200)]
Enable some features for RTEMS in libstdc++

Remove RTEMS support from crossconfig.m4 since this code is not used due to
"with_newlib" being "yes".

libstdc++-v3/ChangeLog:

* configure: Regnerate.
* configure.ac (newlib, *-rtems*): Enable TLS support for all RTEMS
targets except bfin, lm32, mips, moxie, or1k, and v850.
For all RTEMS targets, define HAVE_ALIGNED_ALLOC, HAVE_AT_QUICK_EXIT,
HAVE_LINK, HAVE_POLL, HAVE_QUICK_EXIT, HAVE_READLINK, HAVE_SETENV,
HAVE_SLEEP, HAVE_SOCKATMARK, HAVE_STRERROR_L, HAVE_SYMLINK,
HAVE_TRUNCATE, and HAVE_USLEEP.
* crossconfig.m4 (*-rtems*): Remove.

2 years agoRevert "testsuite/102690: Only check warning for lp64 in Warray-bounds-16.C"
Kito Cheng [Fri, 1 Jul 2022 09:55:55 +0000 (17:55 +0800)]
Revert "testsuite/102690: Only check warning for lp64 in Warray-bounds-16.C"

This reverts commit 0f6eef398045deb2a62d18b526831719c7c20c8a.

2 years agowide-int: Fix up wi::shifted_mask [PR106144]
Jakub Jelinek [Fri, 1 Jul 2022 09:17:41 +0000 (11:17 +0200)]
wide-int: Fix up wi::shifted_mask [PR106144]

As the following self-test testcase shows, wi::shifted_mask sometimes
doesn't create canonicalized wide_ints, which then fail to compare equal
to canonicalized wide_ints with the same value.
In particular, wi::mask (128, false, 128) gives { -1 } with len 1 and prec 128,
while wi::shifted_mask (0, 128, false, 128) gives { -1, -1 } with len 2
and prec 128.
The problem is that the code is written with the assumption that there are
3 bit blocks (or 2 if start is 0), but doesn't consider the possibility
where there are 2 bit blocks (or 1 if start is 0) where the highest block
isn't present.  In that case, there is the optional block of negate ? 0 : -1
elts, followed by just one elt (either one from the if (shift) or just
negate ? -1 : 0) and the rest is implicit sign-extension.
Only if end < prec there is 1 or more bits above it that have different bit
value and so we need to emit all the elts till end and then one more elt.

if (end == prec) would work too, because we have:
  if (width > prec - start)
    width = prec - start;
  unsigned int end = start + width;
so end is guaranteed to be end <= prec, dunno what is preferred.

2022-07-01  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/106144
* wide-int.cc (wi::shifted_mask): If end >= prec, return right after
emitting element for shift or if shift is 0 first element after start.
(wide_int_cc_tests): Add tests for equivalency of wi::mask and
wi::shifted_mask with 0 start.

2 years agoPR target/106122: Don't update %esp via the stack with -Oz on x86.
Roger Sayle [Fri, 1 Jul 2022 08:18:07 +0000 (09:18 +0100)]
PR target/106122: Don't update %esp via the stack with -Oz on x86.

When optimizing for size with -Oz, setting a register can be minimized by
pushing an immediate value to the stack and popping it to the destination.
Alas the one general register that shouldn't be updated via the stack is
the stack pointer itself, where "pop %esp" can't be represented in GCC's
RTL ("use of a register mentioned in pre_inc, pre_dec, post_inc or
post_dec is not permitted within the same instruction").  This patch
fixes PR target/106122 by explicitly checking for SP_REG in the
problematic peephole2.

2022-07-01  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR target/106122
* config/i386/i386.md (peephole2): Avoid generating pop %esp
when optimizing for size.

gcc/testsuite/ChangeLog
PR target/106122
* gcc.target/i386/pr106122.c: New test case.

2 years agoDouble word logical operation clean-ups in i386.md.
Roger Sayle [Fri, 1 Jul 2022 08:13:17 +0000 (09:13 +0100)]
Double word logical operation clean-ups in i386.md.

This patch tidies up and unifies doubleword handling in i386.md;
converting all doubleword splitters for logic operations to post-reload
form, generalizing their define_insn_and_split templates to <dwi> form
(supporting TARGET_64BIT ? TImode : DImode), and where required tweaking
the corresponding expanders to use SDWIM to support TImode doubleword
operations.

2022-07-01  Roger Sayle  <roger@nextmovesoftware.com>
    Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog
* config/i386/i386.md (general_szext_operand): Add TImode
support using x86_64_hilo_general_operand predicate.
(*cmp<dwi>_doubleword): Use x86_64_hilo_general_operand predicate.
(*add<dwi>3_doubleword): Improved optimization of zero addition.
(and<mode>3): Use SDWIM mode iterator to add support for double
word bit-wise AND in TImode.  Use force_reg when double word
immediate operand isn't x86_64_hilo_general_operand.
(and<dwi>3_doubleword): Generalized from anddi3_doubleword and
converted into a post-reload splitter.
(*andndi3_doubleword): Previous define_insn deleted.
(*andn<mode>3_doubleword_bmi): New define_insn_and_split for
TARGET_BMI that splits post-reload.
(*andn<mode>3_doubleword): New define_insn_and_split for
!TARGET_BMI, that lowers/splits before reload.
(<any_or><mode>3): Use SDWIM mode iterator to add suppport for
double word bit-wise XOR and bit-wise IOR in TImode.  Use
force_reg when double word immediate operand isn't
x86_64_hilo_general_operand.
(*<any_or>di3_doubleword): Generalized from <any_or>di3_doubleword.
(one_cmpl<mode>2): Use SDWIM mode iterator to add support for
double word bit-wise NOT in TImode.
(one_cmpl<dwi>2_doubleword): Generalize from one_cmpldi2_doubleword
and converted into a post-reload splitter.

2 years agoAmend fix for PR middle-end/105874
Eric Botcazou [Fri, 1 Jul 2022 07:59:05 +0000 (09:59 +0200)]
Amend fix for PR middle-end/105874

The original fix is very likely too big a hammer.

gcc/
PR middle-end/105874
* expr.cc (expand_expr_real_1) <normal_inner_ref>: Force
EXPAND_MEMORY for the expansion of the inner reference only
in the usual cases where a memory reference is required.

2 years agolto: pass -pthread to AM_LDFLAGS [PR 106118]
Pekka Seppänen [Tue, 28 Jun 2022 14:14:09 +0000 (17:14 +0300)]
lto: pass -pthread to AM_LDFLAGS [PR 106118]

Move -pthread from configure.ac to Makefile.in so that it is passed to AM_LDFLAGS.

PR lto/106118

lto-plugin/ChangeLog:

* configure.ac: Move -pthread from here...
* Makefile.am: ...to here.
* configure: Regenerate.
* Makefile.in: Likewise.

2 years agotree-optimization/106131 - wrong code with FRE rewriting
Richard Biener [Thu, 30 Jun 2022 08:33:40 +0000 (10:33 +0200)]
tree-optimization/106131 - wrong code with FRE rewriting

The following makes sure to not use the original TBAA type for
looking up a value across an aggregate copy when we had to offset
the read.

2022-06-30  Richard Biener  <rguenther@suse.de>

PR tree-optimization/106131
* tree-ssa-sccvn.cc (vn_reference_lookup_3): Force alias-set
zero when offsetting the read looking through an aggregate
copy.

* g++.dg/torture/pr106131.C: New testcase.

2 years agoif-to-switch: properly allow side effects only for first condition
Martin Liska [Thu, 30 Jun 2022 13:00:17 +0000 (15:00 +0200)]
if-to-switch: properly allow side effects only for first condition

Properly allow side effects only for a first BB in a condition chain.

PR tree-optimization/106126

gcc/ChangeLog:

* gimple-if-to-switch.cc (struct condition_info): Save
has_side_effect.
(find_conditions): Parse all BBs.
(pass_if_to_switch::execute): Allow only side effects for first
BB.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr106126.c: New test.

2 years agoi386: Add AVX512BW to AVX512F in MASK_ISA2
Haochen Jiang [Wed, 29 Jun 2022 02:38:34 +0000 (10:38 +0800)]
i386: Add AVX512BW to AVX512F in MASK_ISA2

gcc/ChangeLog:

* common/config/i386/i386-common.cc (OPTION_MASK_ISA2_AVX512F_UNSET):
Add OPTION_MASK_ISA2_AVX512BW_UNSET, remove
OPTION_MASK_ISA2_AVX512BF16_UNSET and
OPTION_MASK_ISA2_AVX512FP16_UNSET.

2 years agoAdd myself for write after approval
Haochen Jiang [Fri, 1 Jul 2022 01:58:13 +0000 (09:58 +0800)]
Add myself for write after approval

ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.

2 years agoDaily bump.
GCC Administrator [Fri, 1 Jul 2022 00:16:27 +0000 (00:16 +0000)]
Daily bump.

2 years agolibgo: handle stat st_atim32 field and SYS_SECCOMP
Ian Lance Taylor [Wed, 29 Jun 2022 22:32:04 +0000 (15:32 -0700)]
libgo: handle stat st_atim32 field and SYS_SECCOMP

Patches for musl support, from Sören Tempel.

Fixes PR go/105225

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

2 years agoFortran: error recovery on invalid CLASS(), PARAMETER declarations [PR105243]
Harald Anlauf [Wed, 29 Jun 2022 19:36:17 +0000 (21:36 +0200)]
Fortran: error recovery on invalid CLASS(), PARAMETER declarations [PR105243]

gcc/fortran/ChangeLog:

PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* decl.cc (gfc_match_data_decl): Reject CLASS entity declaration
when it is given the PARAMETER attribute.

gcc/testsuite/ChangeLog:

PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* gfortran.dg/class_58.f90: Fix test.
* gfortran.dg/class_73.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
2 years agoc-family: Add <time.h> names to diagnostics for known headers
Jonathan Wakely [Wed, 29 Jun 2022 22:41:46 +0000 (23:41 +0100)]
c-family: Add <time.h> names to diagnostics for known headers

gcc/c-family/ChangeLog:

* known-headers.cc (get_stdlib_header_for_name): Add <time.h>
names.

gcc/testsuite/ChangeLog:

* g++.dg/spellcheck-stdlib.C: Check <ctime> types and functions.

2 years agolto: Fix option merging [PR106129]
Joseph Myers [Thu, 30 Jun 2022 16:41:40 +0000 (16:41 +0000)]
lto: Fix option merging [PR106129]

The LTO merging of options from different input files was broken by:

commit 227a2ecf663d69972b851f51f1934d18927b62cd
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Mar 12 11:53:47 2021 +0100

    lto-wrapper: Use vec<cl_decoded_option> data type.

Previously, find_and_merge_options would merge options it read into
those in *opts. After this commit, options in *opts on entry to
find_and_merge_options are ignored; the only merging that takes place
is between multiple sets of options in the same input file that are
read in the same call to this function (not sure how that case can
occur at all). The effects include, for example, that if some objects
are built with PIC enabled and others with it disabled, and the last
LTO object processed has PIC enabled, the choice of PIC for the last
object will result in the whole program being built as PIC, when the
merging logic is intended to ensure that a mixture of PIC and non-PIC
objects results in the whole program being built as non-PIC.

Fix this with an extra argument to find_and_merge_options to determine
whether merging should take place.  This shows up a second issue with
that commit (which I think wasn't actually intended to change code
semantics at all): once merging is enabled again, the check for
-Xassembler options became an infinite loop in the case where both
inputs had -Xassembler options, with the same first option, so fix
that loop to restore the previous semantics.

Note that I'm not sure how LTO option merging might be tested in the
testsuite (clearly there wasn't sufficient, if any, coverage to detect
these bugs).

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

PR lto/106129
* lto-wrapper.cc (find_option): Add argument start.
(merge_and_complain): Loop over existing_opt_index and
existing_opt2_index for Xassembler check.  Update calls to
find_option.
(find_and_merge_options): Add argument first to determine whether
to merge options with those passed in *opts.
(run_gcc): Update calls to find_and_merge_options.

2 years agolibstdc++: Fix comment typos
Jonathan Wakely [Thu, 30 Jun 2022 10:28:23 +0000 (11:28 +0100)]
libstdc++: Fix comment typos

libstdc++-v3/ChangeLog:

* include/bits/utility.h: Fix comment typos.

2 years agolibstdc++: Improve exceptions thrown from fs::temp_directory_path
Jonathan Wakely [Tue, 28 Jun 2022 15:09:21 +0000 (16:09 +0100)]
libstdc++: Improve exceptions thrown from fs::temp_directory_path

Currently the throwing overload of fs::temp_directory_path() will
discard the path that was obtained from the environment. When it fails
because the path doesn't resolve to a directory you get an unhelpful
error like:

  filesystem error: temp_directory_path: Not a directory

It would be better to also print the path in that case, e.g.

  filesystem error: temp_directory_path: Not a directory [/home/bob/tmp]

libstdc++-v3/ChangeLog:

* src/c++17/fs_ops.cc (fs::temp_directory_path()): Include path
in exception.
(fs::temp_directory_path(error_code&)): Rearrange to more
closely match the structure of the first overload.
* src/filesystem/ops.cc (fs::temp_directory_path): Likewise.
* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
Check that exception contains the path.
* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
Likewise.

2 years agolibstdc++: Fix experimental::filesystem::status on Windows [PR88881]
Jonathan Wakely [Tue, 28 Jun 2022 14:56:30 +0000 (15:56 +0100)]
libstdc++: Fix experimental::filesystem::status on Windows [PR88881]

Although the Filesystem TS isn't properly supported on Windows (unlike
the C++17 Filesystem lib), most tests do pass. Two of the failures are
due to PR 88881 which was only fixed for std::filesystem not the TS.
This applies the fix to the TS implementation too.

libstdc++-v3/ChangeLog:

PR libstdc++/88881
* src/filesystem/ops.cc (has_trailing_slash): New helper
function.
(fs::status): Strip trailing slashes.
(fs::symlink_status): Likewise.
* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
Clean the environment before each test and use TMP instead of
TMPDIR so the test passes on Windows.

2 years agoImplement ggc_vrange_allocator.
Aldy Hernandez [Fri, 10 Jun 2022 13:02:51 +0000 (15:02 +0200)]
Implement ggc_vrange_allocator.

This patch makes the vrange_allocator an abstract class, and uses it
to implement the obstack allocator as well as a new GC allocator.

The GC bits will be used to implement the vrange storage class for
global ranges, which will be contributed in the next week or so.

Tested and benchmarked on x86-64 Linux.

gcc/ChangeLog:

* gimple-range-cache.cc (block_range_cache::block_range_cache):
Rename vrange_allocator to obstack_vrange_allocator.
(ssa_global_cache::ssa_global_cache): Same.
* gimple-range-edge.h (class gimple_outgoing_range): Same.
* gimple-range-infer.h (class infer_range_manager): Same.
* value-range.h (class vrange_allocator): Make abstract.
(class obstack_vrange_allocator): Inherit from vrange_allocator.
(class ggc_vrange_allocator): New.

2 years agoc++: Note macro locations
Nathan Sidwell [Mon, 27 Jun 2022 14:51:12 +0000 (07:51 -0700)]
c++: Note macro locations

In order to prune ordinary locations, we need to note the locations of
macros we'll be writing out.  This rearanges the macro processing to achieve
that.  Also drop an unneeded parameter from macro reading & writing.

Fix some it's/its errors.

gcc/cp/
* module.cc (module_state::write_define): Drop located param.
(module_state::read_define): Likewise.
(module_state::prepare_macros): New, broken out of ...
(module_state::write_macros): ... here.  Adjust.
(module_state::write_begin): Adjust.
gcc/testsuite/
* g++.dg/modules/inext-1.H: Check include-next happened.

2 years agoUse xchg for DImode double word rotate by 32 bits with -m32 on x86.
Roger Sayle [Thu, 30 Jun 2022 10:00:03 +0000 (11:00 +0100)]
Use xchg for DImode double word rotate by 32 bits with -m32 on x86.

This patch was motivated by the investigation of Linus Torvalds' spill
heavy cryptography kernels in PR 105930.  The <any_rotate>di3 expander
handles all rotations by an immediate constant for 1..63 bits with the
exception of 32 bits, which FAILs and is then split by the middle-end.
This patch makes these 32-bit doubleword rotations consistent with the
other DImode rotations during reload, which results in reduced register
pressure, fewer instructions and the use of x86's xchg instruction
when appropriate.  In theory, xchg can be handled by register renaming,
but even on micro-architectures where it's implemented by 3 uops (no
worse than a three instruction shuffle), avoiding nominating a
"temporary" register, reduces user-visible register pressure (and
has obvious code size benefits).

The effects are best shown with the new testcase:

unsigned long long bar();
unsigned long long foo()
{
  unsigned long long x = bar();
  return (x>>32) | (x<<32);
}

for which GCC with -m32 -O2 currently generates:

        subl    $12, %esp
        call    bar
        addl    $12, %esp
        movl    %eax, %ecx
        movl    %edx, %eax
        movl    %ecx, %edx
        ret

but with this patch now generates:

        subl    $12, %esp
        call    bar
        addl    $12, %esp
        xchgl   %edx, %eax
        ret

With this patch, the number of lines of assembly language generated
for the blake2b kernel (from the attachment to PR105930) decreases
from 5626 to 5404. Although there's an impressive reduction in
instruction count, there's no change/reduction in stack frame size.

2022-06-30  Roger Sayle  <roger@nextmovesoftware.com>
    Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog
* config/i386/i386.md (swap_mode): Rename from *swap<mode> to
provide gen_swapsi.
(<any_rotate>di3): Handle !TARGET_64BIT rotations by 32 bits
via new gen_<insn>32di2_doubleword below.
(<anyrotate>32di2_doubleword): New define_insn_and_split
that splits after reload as either a pair of move instructions
or an xchgl (using gen_swapsi).

gcc/testsuite/ChangeLog
* gcc.target/i386/xchg-3.c: New test case.

2 years agoAvoid computing RPO for update_ssa
Richard Biener [Wed, 29 Jun 2022 12:55:43 +0000 (14:55 +0200)]
Avoid computing RPO for update_ssa

At some point when domwalk got the ability to use RPO for ordering
dominator children we carefully avoided update_ssa eating the cost
of RPO compute.  Unfortunately some later consolidation of CTORs
lost this again so the following makes this explicit via a special
value to the bb_index_to_rpo argument of domwalk, speeding up
update_ssa again.

* domwalk.h (dom_walker::dom_walker): Update comment to
reflect reality and new special argument value for
bb_index_to_rpo.
* domwalk.cc (dom_walker::dom_walker): Recognize -1
bb_index_to_rpo.
* tree-into-ssa.cc
(rewrite_update_dom_walker::rewrite_update_dom_walker): Tell
dom_walker to not use RPO.

2 years agoremove dead member variable in dom_jt_state
Martin Liska [Thu, 30 Jun 2022 08:23:28 +0000 (10:23 +0200)]
remove dead member variable in dom_jt_state

gcc/ChangeLog:

* tree-ssa-dom.cc (pass_dominator::execute): Remove m_ranger as
it is unused.

2 years agoRevert "MAINTAINERS: Add myself for write after approval"
Cui,Lili [Thu, 30 Jun 2022 03:38:40 +0000 (11:38 +0800)]
Revert "MAINTAINERS: Add myself for write after approval"

This reverts commit 1e6ff6993c98ff843932c1b222958dc7ae90e9a4.

2 years agoMAINTAINERS: Add myself for write after approval
Cui,Lili [Thu, 30 Jun 2022 03:21:09 +0000 (11:21 +0800)]
MAINTAINERS: Add myself for write after approval

ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.

2 years agotestsuite/102690: Only check warning for lp64 in Warray-bounds-16.C
Kito Cheng [Tue, 28 Jun 2022 10:43:42 +0000 (18:43 +0800)]
testsuite/102690: Only check warning for lp64 in Warray-bounds-16.C

That warning won't happen on ilp32 targets, seems like Andrew Pinski
already mention that[1] before.

Verified on riscv32-unknown-elf and riscv64-unknown-elf.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92879#c1

gcc/testsuite/ChangeLog:

PR testsuite/102690
* g++.dg/warn/Warray-bounds-16.C: XFAIL only on lp64 for the
warning.

2 years agoDon't use gori dependencies to optimize.
Andrew MacLeod [Wed, 29 Jun 2022 17:34:05 +0000 (13:34 -0400)]
Don't use gori dependencies to optimize.

  The routine fold_using_range::relation_fold_and_or needs to veriyf that both
operands of 2 stmts are the same, and uses GORIs dependency cache for this.
This cache cannot be counted on to reflect the current contents of a
stmt, expecially in the presence of an IL changing pass.  Instead, look at the
statement operands.

PR tree-optimization/106114
gcc/
* gimple-range-fold.cc (fold_using_range::relation_fold_and_or): Check
statement operands instead of GORI cache.
gcc/testsuite/
* gcc.dg/pr106114.c: New.

2 years agotarget: Fix asm generation for AVX builtins when using -masm=intel [PR106095]
Antoni Boucher [Sun, 26 Jun 2022 22:49:15 +0000 (18:49 -0400)]
target: Fix asm generation for AVX builtins when using -masm=intel [PR106095]

gcc/ChangeLog:
PR target/106095
* config/i386/sse.md: Fix asm generation.

gcc/testsuite/ChangeLog:
PR target/106095
* gcc.target/i386/pr106095.c: Add test using those AVX builtins.

2 years agoDaily bump.
GCC Administrator [Thu, 30 Jun 2022 00:16:46 +0000 (00:16 +0000)]
Daily bump.

2 years agolibgccjit: Fix bug where unary_op will return an integer type instead of the correct...
Antoni Boucher [Wed, 29 Jun 2022 23:56:56 +0000 (19:56 -0400)]
libgccjit: Fix bug where unary_op will return an integer type instead of the correct type

2022-06-29  Antoni Boucher  <bouanto@zoho.com>

gcc/jit/
PR jit/105812
* jit-playback.cc: Use the correct return type when folding in
as_truth_value.

gcc/testsuite/
PR jit/105812
* jit.dg/test-asm.cc: Add include missing to make the test pass.
* jit.dg/test-pr105812-bool-operations.c: New test.

2 years agocompiler: check repeated const expressions in new scope
Ian Lance Taylor [Wed, 29 Jun 2022 00:03:28 +0000 (17:03 -0700)]
compiler: check repeated const expressions in new scope

Test case is const8.go in https://go.dev/cl/414795.

Fixes golang/go#53585

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

2 years agod: Fix error: aggregate value used where floating point was expected
Iain Buclaw [Wed, 29 Jun 2022 19:52:39 +0000 (21:52 +0200)]
d: Fix error: aggregate value used where floating point was expected

Casting from vector to static array is permitted, and the frontend
generates a reinterpret cast, but casting back the other way resulted in
an error.  This has been fixed to be properly handled in the code
generation pass of VectorExp, and the conversion for lvalue and rvalue
handling done in convert_expr and convert_for_rvalue respectively.

PR d/106139

gcc/d/ChangeLog:

* d-convert.cc (convert_expr): Handle casting from array to vector.
(convert_for_rvalue): Rewrite vector to array casts of the same
element type into a constructor.
(convert_for_assignment): Return calling convert_for_rvalue.
* expr.cc (ExprVisitor::visit (VectorExp *)): Handle generating a
vector expression from a static array.
* toir.cc (IRVisitor::visit (ReturnStatement *)): Call
convert_for_rvalue on return value.

gcc/testsuite/ChangeLog:

* gdc.dg/pr106139a.d: New test.
* gdc.dg/pr106139b.d: New test.
* gdc.dg/pr106139c.d: New test.
* gdc.dg/pr106139d.d: New test.

2 years agojit: avoid calloc() poisoning on musl [PR106102]
Sergei Trofimovich [Mon, 27 Jun 2022 22:42:44 +0000 (23:42 +0100)]
jit: avoid calloc() poisoning on musl [PR106102]

On musl <pthread.h> uses calloc() (via <sched.h>). jit/ includes
it directly and exposes use of poisoned calloc():

    /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/jit/jit-playback.cc
    make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1
    make[3]: *** Waiting for unfinished jobs....
    In file included from /<<NIX>>/musl-1.2.3-dev/include/pthread.h:30,
                     from ../../gcc-13-20220626/gcc/jit/jit-playback.cc:44:
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc"
       84 | void *calloc(size_t, size_t);
          |       ^
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc"
      124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
          |                                    ^

The change moves <pthread.h> inclusion to "system.h" under new
INCLUDE_PTHREAD_H guard and uses this mechanism in libgccjit.

gcc/

PR c++/106102
* system.h: Introduce INCLUDE_PTHREAD_H macros to include <pthread.h>.

gcc/jit/

PR c++/106102
* jit-playback.cc: Include <pthread.h> via "system.h" to avoid calloc()
poisoning.
* jit-recording.cc: Ditto.
* libgccjit.cc: Ditto.

2 years agoFortran: improve error recovery for EXTENDS_TYPE_OF() [PR106121]
Harald Anlauf [Tue, 28 Jun 2022 20:29:28 +0000 (22:29 +0200)]
Fortran: improve error recovery for EXTENDS_TYPE_OF() [PR106121]

gcc/fortran/ChangeLog:

PR fortran/106121
* simplify.cc (gfc_simplify_extends_type_of): Do not attempt to
simplify when one of the arguments is a CLASS variable that was
not properly declared.

gcc/testsuite/ChangeLog:

PR fortran/106121
* gfortran.dg/extends_type_of_4.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
2 years agoc++: Rename macro location structs
Nathan Sidwell [Fri, 24 Jun 2022 12:17:24 +0000 (05:17 -0700)]
c++: Rename macro location structs

The macro location tables should really mention they are about
locations.  So rename them.  Also, add a missing free of the remapping
table, and remove some now-unneeded macro checking.

gcc/cp/
* module.cc (macro_info, macro_traits, macro_table,
macro_remap): Rename to ...
(macro_loc_info, macro_loc_traits, macro_loc_table,
macro_loc_remap): ... these.  Update all uses.
(module_state::write_prepare_maps): Remove unneeded macro checking.
(module_state::write_begin): Free macro_loc_remap.

2 years agod: Fix build on aarch64-suse-linux
Iain Buclaw [Wed, 29 Jun 2022 16:27:08 +0000 (18:27 +0200)]
d: Fix build on aarch64-suse-linux

The variables being used to get the result out of TYPE_VECTOR_SUBPARTS
were being flagged by -Werror=maybe-uninitialized.  As they have already
been checked for being constant earlier, use `to_constant' instead.

gcc/d/ChangeLog:

* intrinsics.cc (build_shuffle_mask_type): Use to_constant when
getting the number of subparts from a vector type.
(expand_intrinsic_vec_shufflevector): Likewise.

2 years agonios2: Fix PIC function call slowness
Joseph Myers [Wed, 29 Jun 2022 15:55:41 +0000 (15:55 +0000)]
nios2: Fix PIC function call slowness

On Nios II, PIC function calls use R_NIOS2_CALL* relocations, which
may refer to a GOT entry that initially points to a PLT entry to
resolve the function on first call and that is then changed by the
dynamic linker to point directly to the function to be called so
subsequent calls do not go through the dynamic linker.  To quote the
ABI, "A global offset table (GOT) entry referenced using
R_NIOS2_GOT16, R_NIOS2_GOT_LO as well as R_NIOS2_GOT_HA must be
resolved at load time.  A GOT entry referenced only using
R_NIOS2_CALL16, R_NIOS2_CALL_LO as well as R_NIOS2_CALL_HA can
initially refer to a procedure linkage table (PLT) entry and then be
resolved lazily.".

However, GCC wrongly treats function addresses loaded from the GOT
with such relocations as constant.  If the address load is pulled out
of a loop, then every call in the loop looks up the function by name.
This shows up as very slow execution of many glibc testcases in glibc
2.35 and later (tests that call functions from shared libc many times
in a loop), where tests are now built as PIE by default.  Fix this
problem by using gen_rtx_MEM instead of gen_const_mem when loading
addresses for PIC function calls.

Tested with no regressions for cross to nios2-linux-gnu, where many
glibc tests pass that previously timed out.

* config/nios2/nios2.cc (nios2_load_pic_address): Use gen_rtx_MEM
not gen_const_mem for UNSPEC_PIC_CALL_SYM.

2 years agolibgfortran: Switch some more __float128 uses to _Float128
Jakub Jelinek [Wed, 29 Jun 2022 15:06:02 +0000 (17:06 +0200)]
libgfortran: Switch some more __float128 uses to _Float128

My patch apparently left some __float128 uses in libgfortran
that could use _Float128 instead, the following patch changes that.

2022-06-29  Jakub Jelinek  <jakub@redhat.com>

* mk-kinds-h.sh: Change __float128 to _Float128 in a comment.
* acinclude.m4 (LIBGFOR_CHECK_MATH_IEEE128): Use _Float128 instead of
__float128.
* libgfortran.h (isnan): Change __float128 to _Float128 in a comment.
(__acoshieee128, __acosieee128, __asinhieee128, __asinieee128,
__atan2ieee128, __atanhieee128, __atanieee128, __copysignieee128,
__coshieee128, __cosieee128, __erfcieee128, __erfieee128,
__expieee128, __fabsieee128, __fmaieee128, __fmodieee128, __jnieee128,
__log10ieee128, __logieee128, __powieee128, __sinhieee128,
__sinieee128, __sqrtieee128, __tanhieee128, __tanieee128,
__ynieee128, __strtoieee128): Use _Float128 instead of __float128.
* configure: Regenerated.

2 years agolibgfortran: Fix up LIBGFOR_CHECK_FLOAT128 [PR106137]
Jakub Jelinek [Wed, 29 Jun 2022 15:04:50 +0000 (17:04 +0200)]
libgfortran: Fix up LIBGFOR_CHECK_FLOAT128 [PR106137]

My recent gfortran + libgfortran patch apparently broke (some?) aarch64
builds.  While it is desirable to use just _Float128 rather than __float128,
we only want to use it (and e.g. define HAVE_FLOAT128) on targets where
_Float128 is supported and long double isn't IEEE quad precision.
Which is targets that support __float128 type which we have been testing
for before - _Float128 is supported on those targets and on targets where
long double is IEEE quad precision.

So, the following patch restores check for whether __float128 is supported
into the LIBGFOR_CHECK_FLOAT128 check which determines whether
HAVE_FLOAT128 is defined or whether to use libquadmath, so that e.g. on
aarch64 where long double is IEEE quad we don't do that.

2022-06-29  Jakub Jelinek  <jakub@redhat.com>

PR bootstrap/106137
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Adjust comment.
Also test for __float128.
(HAVE_FLOAT128): Adjust description.
* config.h.in: Regenerated.
* configure: Regenerated.

2 years agolibsanitizer: cherry-pick 791e0d1bc85d
Martin Liska [Wed, 29 Jun 2022 13:28:07 +0000 (15:28 +0200)]
libsanitizer: cherry-pick 791e0d1bc85d

791e0d1bc85d: [compiler-rt] Add NO_EXEC_STACK_DIRECTIVE on s390x

2 years agortl-optimization/106082 - preserve EH note for no non-local goto
Richard Biener [Tue, 28 Jun 2022 11:08:33 +0000 (13:08 +0200)]
rtl-optimization/106082 - preserve EH note for no non-local goto

The following makes sure we preserve EH notes on call insns that
indicate the call doesn't perform a non-local goto when distributing
notes after combining insns.

2022-06-28  Richard Biener  <rguenther@suse.de>

PR rtl-optimization/106082
* combine.cc (distribute_notes): Preserve notes when
they indicate a call doesn't perform a non-local goto.

2 years agotree-optimization/106112 - fix CSE from wider operation
Richard Biener [Tue, 28 Jun 2022 11:57:29 +0000 (13:57 +0200)]
tree-optimization/106112 - fix CSE from wider operation

The following fixes a mistake in looking up an extended operand
in the CSE of a truncated operation.

2022-06-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/106112
* tree-ssa-sccvn.cc (valueized_wider_op): Properly extend
a constant operand according to its type.

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

2 years agotestsuite/ix86: SSE2 is a prereq to _Float16 use
Jan Beulich [Wed, 29 Jun 2022 08:27:22 +0000 (10:27 +0200)]
testsuite/ix86: SSE2 is a prereq to _Float16 use

When enabling AVX512FP via attribute or pragma, the _Float16 type would
remain unavailable when at initialization time SSE2 wouldn't be seen as
available for use. While this may hint at a wider underlying issue (like
the feature, the type may want providing dynamically, albeit this may be
challenging in particular for functions returning _Float16 yet having
the attribute specified after their return type), for now simply make
SSE2 available when targeting ix86.

gcc/testsuite/

* gcc.target/i386/avx512fp16-reduce-op-2.c: Force SSE2 for i?86.
* gcc.target/i386/pr99464.c: Likewise.

2 years agotestsuite/ix86: prune MMX ABI warning
Jan Beulich [Wed, 29 Jun 2022 08:26:26 +0000 (10:26 +0200)]
testsuite/ix86: prune MMX ABI warning

So far on 32-bit hosts this test failed (for both C and C++) because of
the ABI change warning occurring without (explictly) enabling MMX.

gcc/testsuite/

* c-c++-common/torture/builtin-shufflevector-2.c: Prune ix86 MMX
ABI warning.

2 years agodocs: remove removed param from documentation
Martin Liska [Wed, 29 Jun 2022 08:08:05 +0000 (10:08 +0200)]
docs: remove removed param from documentation

gcc/ChangeLog:

* doc/invoke.texi: Remove removed evrp-mode.

2 years agoLoongArch: Remove undefined behavior from code [PR 106097]
Lulu Cheng [Mon, 27 Jun 2022 08:26:25 +0000 (16:26 +0800)]
LoongArch: Remove undefined behavior from code [PR 106097]

C++2017 and previous standard description:

The value of E1 << E2 is E1 left-shifted E2 bit positions;
vacated bits are zero-filled. If E1 has an unsigned type,
the value of the result is E1×2E2, reduced modulo one more
than the maximum value representable inthe result type.
Otherwise, if E1 has a signed type and non-negative value,
and E1×2E2 is representablein the corresponding unsigned
type of the result type, then that value, converted to the
result type, is the resulting value; otherwise, the behavior
is undefined.

The value of E1 >> E2 is E1 right-shifted E2 bit positions.
If E1 has an unsigned type or if E1 has a signed type and
a non-negative value, the value of the result is the integral
part of the quotient of E1/2E2. If E1 has a signed type and
a negative value, the resulting value is implementation-defined.

gcc/ChangeLog:

PR target/106097
* config/loongarch/loongarch.cc (loongarch_build_integer):
Remove undefined behavior from code.

2 years agod: Add SIMD intrinsics module and compiler built-ins.
Iain Buclaw [Tue, 28 Jun 2022 17:22:34 +0000 (19:22 +0200)]
d: Add SIMD intrinsics module and compiler built-ins.

Vectors in D are exposed by the use of the `__vector(T[N])' type, and
whilst most unary and binary operations work as you'd expect, there are
some operations that are not possible without doing the operation
unrolled, or calling some target-specific built-in, or with inline asm.

This introduces a new `gcc.simd' module that introduces the following.

 - Prefetching has been exposed by a convenient `prefetch' function in
   the library.

 - Loading and storing from an unaligned address have been exposed by
   `loadUnaligned' and `storeUnaligned' intrinsics.

 - Vector permutations have been exposed by `shuffle`, and
   `shufflevector' intrinsics.

 - Converting between two vectors with a different element type has been
   exposed by a `convertvector' intrinsic.

 - The ternary operator has been exposed with a `blendvector' intrinsic.

 - Comparison operators have been exposed by `equalMask',
   `notEqualMask', `greaterMask', and `greaterEqualMask' intrinsics.

 - Logic operators have been exposed by convenient `notMask',
   `andAndMask', and `orOrMask' functions in the library.

To be compatible with the LLVM D compiler's own SIMD intrinsic module,
there is also the addition of an `extractelement' and `insertelement'
convenience functions, and an alternative interface for calling the
`shufflevector' function.

The addition of these intrinsics lowers the boundary for users working
in SIMD to get the desired codegen they want out of the compiler.

Most of what is present here - apart from tests - is the adding of
machinery in the intrinsics suite of functions to do validation on
templated intrinsics.  Whilst these are still matched from the library
by their generic (untyped) signature, there is a still an assumption
that what has been instantiated and handed down to the code generator is
valid, because why would these definitions be found outside of the
in-tree D runtime library?  The majority of intrinsics are not
templates, so the test on the mangled signature string still guarantees
all types are as we expect them to be.  However there are still a small
handful of other templated intrinsics (core.bitop.{rol,ror},
core.math.toPrec, std.math.traits.isNaN, ...) that are currently
unchecked, so would benefit from being included into this built-in
checking function at some point in the future.

gcc/d/ChangeLog:

* intrinsics.cc: Include diagnostic.h, langhooks.h,
vec-perm-indices.h.
(maybe_set_intrinsic): Add cases for new simd intrinsics.
(warn_mismatched_return_type): New function.
(warn_mismatched_argument): New function.
(build_shuffle_mask_type): New function.
(maybe_warn_intrinsic_mismatch): New function.
(expand_intrinsic_vec_cond): New function.
(expand_intrinsic_vec_convert): New function.
(expand_intrinsic_vec_blend): New function.
(expand_intrinsic_vec_shuffle): New function.
(expand_intrinsic_vec_shufflevector): New function.
(expand_intrinsic_vec_load_unaligned): New function.
(expand_intrinsic_vec_store_unaligned): New function.
(maybe_expand_intrinsic): Check signature of intrinsic before handing
off to front-end lowering.  Add cases for new simd intrinsics.
* intrinsics.def (INTRINSIC_LOADUNALIGNED): Define intrinsic.
(INTRINSIC_STOREUNALIGNED): Define intrinsic.
(INTRINSIC_SHUFFLE): Define intrinsic.
(INTRINSIC_SHUFFLEVECTOR): Define intrinsic.
(INTRINSIC_CONVERTVECTOR): Define intrinsic.
(INTRINSIC_BLENDVECTOR): Define intrinsic.
(INTRINSIC_EQUALMASK): Define intrinsic.
(INTRINSIC_NOTEQUALMASK): Define intrinsic.
(INTRINSIC_GREATERMASK): Define intrinsic.
(INTRINSIC_GREATEREQUALMASK): Define intrinsic.

libphobos/ChangeLog:

* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add gcc/simd.d.
* libdruntime/Makefile.in: Regenerate.
* libdruntime/gcc/simd.d: New file.

gcc/testsuite/ChangeLog:

* gdc.dg/Wbuiltin_declaration_mismatch.d: Rename to...
* gdc.dg/Wbuiltin_declaration_mismatch1.d: ...this.
* gdc.dg/Wbuiltin_declaration_mismatch2.d: New test.
* gdc.dg/torture/simd_blendvector.d: New test.
* gdc.dg/torture/simd_cond.d: New test.
* gdc.dg/torture/simd_convertvector.d: New test.
* gdc.dg/torture/simd_load.d: New test.
* gdc.dg/torture/simd_logical.d: New test.
* gdc.dg/torture/simd_shuffle.d: New test.
* gdc.dg/torture/simd_shufflevector.d: New test.
* gdc.dg/torture/simd_store.d: New test.

2 years agoDaily bump.
GCC Administrator [Wed, 29 Jun 2022 00:17:00 +0000 (00:17 +0000)]
Daily bump.

2 years agolibcpp: Update ucnid.h to Unicode 14
Lewis Hyatt [Tue, 28 Jun 2022 21:33:37 +0000 (17:33 -0400)]
libcpp: Update ucnid.h to Unicode 14

This patch updates ucnid.h from Unicode 13 to Unicode 14.  Additionally, the
procedure detailed in contrib/unicode/README, which updates
generated_wcwidth.h, has been expanded with instructions for updating this
file as well, so that both may be done at the same time conveniently.  Two
additional Unicode data files which are needed to create ucnid.h are also
added to source control in contrib/unicode.

contrib/ChangeLog:

* unicode/README: Added instructions for updating ucnid.h.
* unicode/DerivedCoreProperties.txt: New file added to source
control from Unicode 14.0 release.
* unicode/DerivedNormalizationProps.txt: Likewise.

libcpp/ChangeLog:

* ucnid.h: Regenerated for Unicode 14.0.

2 years agocompiler: use package path with embedded builtin type
Ian Lance Taylor [Sun, 26 Jun 2022 05:09:16 +0000 (22:09 -0700)]
compiler: use package path with embedded builtin type

The test case is https://go.dev/cl/414235.

Fixes golang/go#52856

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

2 years agolibgo: make runtime.Version return a meaningful string
Ian Lance Taylor [Tue, 28 Jun 2022 00:22:53 +0000 (17:22 -0700)]
libgo: make runtime.Version return a meaningful string

Fixes golang/go#51850

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

2 years agod: Use create_tmp_var_raw and get_callee_fndecl
Iain Buclaw [Tue, 28 Jun 2022 16:49:27 +0000 (18:49 +0200)]
d: Use create_tmp_var_raw and get_callee_fndecl

A couple of small patterns that repeat are generating a temporary, and
getting a function out of a CALL_EXPR.  There are convenience functions
for these in the common parts of gcc, use them instead.

gcc/d/ChangeLog:

* d-codegen.cc: Include gimple-expr.h.
(force_target_expr): Use create_tmp_var_raw.
* decl.cc: Inlucde gimple-expr.h.
(build_local_temp): Use create_tmp_var_raw.
* intrinsics.cc (expand_intrinsic_rotate): Use get_callee_fndecl.
(maybe_expand_intrinsic): Likewise.