Martin Liska [Thu, 8 Sep 2022 18:00:33 +0000 (20:00 +0200)]
opts: always compare array option values with memcmp
gcc/ChangeLog:
* optc-save-gen.awk: Always compare array option values with memcmp.
GCC Administrator [Fri, 9 Sep 2022 00:18:05 +0000 (00:18 +0000)]
Daily bump.
François Dumont [Thu, 8 Sep 2022 04:55:20 +0000 (06:55 +0200)]
libstdc++: mallinfo deprecated, use mallinfo2 when glibc => 2.33
glibc mallinfo is now deprecated resulting in make check-performance
failure. When glibc => 2.33 prefer mallinfo2.
libstdc++-v3/ChangeLog:
* testsuite/util/testsuite_performance.h (__gnu_test::MallocInfo): New.
(__gnu_test::malloc_info): New, replace mallinfo on current platform
supporting it and use mallinfo2 when glibc >= 2.33.
Tobias Burnus [Thu, 8 Sep 2022 19:03:21 +0000 (21:03 +0200)]
OpenMP: Document ompx warnings + add Fortran omx warning [PR106670]
omp/ompx sentinels are for vendor extensions; as they might be required for
the correctness of the program, a warning should be printable. This patch
documents in the OpenMP 5.2 table the existing warnings, including the new
warning for for fixed source form Fortran.
PR fortran/106670
gcc/fortran/ChangeLog:
* scanner.cc (skip_fixed_omp_sentinel): Add -Wsurprising warning
for 'omx' sentinels with -fopenmp.
* invoke.texi (-Wsurprising): Document additional warning case.
libgomp/ChangeLog:
* libgomp.texi (OpenMP 5.2): Add comment to ompx/omx entry.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/ompx-1.c: New test.
* c-c++-common/gomp/ompx-2.c: New test.
* g++.dg/gomp/ompx-attrs-1.C: New test.
* gfortran.dg/gomp/ompx-1.f90: New test.
* gfortran.dg/gomp/omx-1.f: New test.
* gfortran.dg/gomp/omx-2.f: New test.
Tobias Burnus [Thu, 8 Sep 2022 18:56:49 +0000 (20:56 +0200)]
libgomp.texi: Document libmemkind + nvptx/gcn specifics
libgomp/ChangeLog:
* libgomp.texi (OpenMP-Implementation Specifics): New; add libmemkind
section; move OpenMP Context Selectors from ...
(Offload-Target Specifics): ... here; add 'AMD Radeo (GCN)' and
'nvptx' sections.
Jonathan Wakely [Tue, 6 Sep 2022 12:21:09 +0000 (13:21 +0100)]
c++: Fix type completeness checks for type traits [PR106838]
The check_trait_type function is used for a number of different type
traits that have different requirements on their arguments. For example,
__is_constructible allows arrays of unknown bound even if the array
element is an incomplete type, but __is_aggregate does not, it always
requires the array element type to be complete. Other traits have
different requirements again, e.g. __is_empty allows incomplete unions,
and arrays (of known or unknown bound) of incomplete types.
This alters the check_trait_type function to take an additional KIND
parameter which indicates which set of type trait requirements to check.
As noted in a comment, the requirements for __is_aggregate deviate from
the ones for std::is_aggregate in the standard. It's not necessary for
the elements of an array to be complete types, because arrays are always
aggregates.
The type_has_virtual_destructor change is needed to avoid an ICE.
Previously it could never be called for incomplete union types as they
were (incorrectly) rejected by check_trait_type.
This change causes some additional diagnostics in some libstdc++ tests,
where the front end was not previously complaining about invalid types
that the library assertions diagnosed. We should consider removing the
library assertions from traits where the front end implements the
correct checks now.
PR c++/106838
gcc/cp/ChangeLog:
* class.cc (type_has_virtual_destructor): Return false for
union types.
* semantics.cc (check_trait_type): Add KIND parameter to support
different sets of requirements.
(finish_trait_expr): Pass KIND argument for relevant traits.
gcc/ChangeLog:
* doc/extend.texi (Type Traits): Fix requirements. Document
__is_aggregate and __is_final.
gcc/testsuite/ChangeLog:
* g++.dg/ext/array4.C: Fix invalid use of __is_constructible.
* g++.dg/ext/unary_trait_incomplete.C: Fix tests for traits with
different requirements.
libstdc++-v3/ChangeLog:
* testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc:
Prune additional errors from front-end.
* testsuite/20_util/is_move_constructible/incomplete_neg.cc:
Likewise.
* testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc:
Likewise.
* testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc:
Likewise.
* testsuite/20_util/is_swappable_with/incomplete_neg.cc:
Likewise.
Jonathan Wakely [Thu, 8 Sep 2022 12:46:02 +0000 (13:46 +0100)]
libstdc++: Add always_inline attribute to std::byte operators
libstdc++-v3/ChangeLog:
* include/c_global/cstddef (byte): Add always_inline attribute
to all operator overloads.
(to_integer): Add always_inline attribute.
Thomas Rodgers [Thu, 25 Aug 2022 10:11:40 +0000 (12:11 +0200)]
libstdc++: Clear padding bits in atomic compare_exchange
This change implements P0528 which requires that padding bits not
participate in atomic compare exchange operations. All arguments to the
generic template are 'sanitized' by the __builtin_clear_padding intrinsic
before they are used in comparisons. This requires that any stores
also sanitize the incoming value.
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Thomas Rodgers <trodgers@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/atomic_base.h (__atomic_impl::__maybe_has_padding):
New function.
(__atomic_impl::clear_padding): Likewise.
(__atomic_impl::__compare_exchange): Likewise.
(__atomic_impl::compare_exchange_weak): Delegate to
__compare_exchange.
(__atomic_impl::compare_exchange_strong): Likewise.
* include/std/atomic (atomic<T>::atomic(T)): Clear padding when
possible in a constexpr function.
(atomic::store): Clear padding.
(atomic::exchange): Likewise.
(atomic::compare_exchange_weak): Use __compare_exchange.
(atomic::compare_exchange_strong): Likewise.
* testsuite/29_atomics/atomic/compare_exchange_padding.cc: New
test.
* testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc:
New test.
Jonathan Wakely [Wed, 7 Sep 2022 19:17:04 +0000 (20:17 +0100)]
libstdc++: Find make_error_code and make_error_condition via ADL only
The new proposed resolution for LWG 3629 says that std::error_code and
std::error_condition should only use ADL to find their customization
points. This means we need to use a poison pill to prevent lookup from
finding overloads in the enclosing namespaces.
We can also remove the forward declarations of std::make_error_code and
std::make_error_condition, because they aren't needed now. ADL can find
them anyway (when std is an associated namespace), and unqualified name
lookup will not (and should not) find them.
libstdc++-v3/ChangeLog:
* include/std/system_error (__adl_only::make_error_code): Add
deleted function.
(__adl_only::make_error_condition): Likewise.
(error_code::error_code(ErrorCodeEnum)): Add using-declaration
for deleted function.
(error_condition::error_condition(ErrorConditionEnum)):
Likewise.
* testsuite/19_diagnostics/error_code/cons/lwg3629.cc: New test.
* testsuite/19_diagnostics/error_condition/cons/lwg3629.cc: New test.
Tim Lange [Wed, 7 Sep 2022 15:41:28 +0000 (17:41 +0200)]
analyzer: support for symbolic values in the out-of-bounds checker [PR106625]
This patch adds support for reasoning about the inequality of two symbolic
values in the special case specifically suited for reasoning about
out-of-bounds past the end of the buffer. With this patch, the analyzer
catches off-by-one errors and more even when the offset and capacity is
symbolic.
Regrtested on Linux x86_64 and tested on coreutils, curl, httpd and
openssh as usual.
2022-09-07 Tim Lange <mail@tim-lange.me>
gcc/analyzer/ChangeLog:
PR analyzer/106625
* analyzer.h (region_offset): Eliminate m_is_symbolic member.
* region-model-impl-calls.cc (region_model::impl_call_realloc):
Refine implementation to be more precise.
* region-model.cc (class symbolic_past_the_end):
Abstract diagnostic class to complain about accesses past the end
with symbolic values.
(class symbolic_buffer_overflow):
Concrete diagnostic class to complain about buffer overflows with
symbolic values.
(class symbolic_buffer_overread):
Concrete diagnostic class to complain about buffer overreads with
symbolic values.
(region_model::check_symbolic_bounds): New function.
(maybe_get_integer_cst_tree): New helper function.
(region_model::check_region_bounds):
Add call to check_symbolic_bounds if offset is not concrete.
(region_model::eval_condition_without_cm):
Add support for EQ_EXPR and GT_EXPR with binaryop_svalues.
(is_positive_svalue): New hleper function.
(region_model::symbolic_greater_than):
New function to handle GT_EXPR comparisons with symbolic values.
(region_model::structural_equality): New function to compare
whether two svalues are structured the same, i.e. evaluate to
the same value.
(test_struct): Reflect changes to region::calc_offset.
(test_var): Likewise.
(test_array_2): Likewise and add selftest with symbolic i.
* region-model.h (class region_model): Add check_symbolic_bounds,
symbolic_greater_than and structural_equality.
* region.cc (region::get_offset):
Reflect changes to region::calc_offset.
(region::calc_offset):
Compute the symbolic offset if the offset is not concrete.
(region::get_relative_symbolic_offset): New function to return the
symbolic offset in bytes relative to its parent.
(field_region::get_relative_symbolic_offset): Likewise.
(element_region::get_relative_symbolic_offset): Likewise.
(offset_region::get_relative_symbolic_offset): Likewise.
(bit_range_region::get_relative_symbolic_offset): Likewise.
* region.h: Add get_relative_symbolic_offset.
* store.cc (binding_key::make):
Reflect changes to region::calc_offset.
(binding_map::apply_ctor_val_to_range): Likewise.
(binding_map::apply_ctor_pair_to_child_region): Likewise.
(binding_cluster::bind_compound_sval): Likewise.
(binding_cluster::get_any_binding): Likewise.
(binding_cluster::maybe_get_compound_binding): Likewise.
gcc/ChangeLog:
PR analyzer/106625
* doc/invoke.texi:
State that the checker also reasons about symbolic values.
gcc/testsuite/ChangeLog:
PR analyzer/106625
* gcc.dg/analyzer/data-model-1.c: Change expected result.
* gcc.dg/analyzer/out-of-bounds-5.c: New test.
* gcc.dg/analyzer/out-of-bounds-realloc-grow.c: New test.
* gcc.dg/analyzer/symbolic-gt-1.c: New test.
Marcel Vollweiler [Thu, 8 Sep 2022 17:01:33 +0000 (10:01 -0700)]
OpenMP, libgomp: Environment variable syntax extension
This patch considers the environment variable syntax extension for
device-specific variants of environment variables from OpenMP 5.1 (see
OpenMP 5.1 specification, p. 75 and p. 639). An environment variable (e.g.
OMP_NUM_TEAMS) can have different suffixes:
_DEV (e.g. OMP_NUM_TEAMS_DEV): affects all devices but not the host.
_DEV_<device> (e.g. OMP_NUM_TEAMS_DEV_42): affects only device with
number <device>.
no suffix (e.g. OMP_NUM_TEAMS): affects only the host.
In future OpenMP versions also suffix _ALL will be introduced (see discussion
https://github.com/OpenMP/spec/issues/3179). This is also considered in this
patch:
_ALL (e.g. OMP_NUM_TEAMS_ALL): affects all devices and the host.
The precedence is as follows (descending). For the host:
1. no suffix
2. _ALL
For devices:
1. _DEV_<device>
2. _DEV
3. _ALL
That means, _DEV_<device> is used whenever available. Otherwise _DEV is used if
available, and at last _ALL. If there is no value for any of the variable
variants, default values are used as already implemented before.
This patch concerns parsing (a), storing (b), output (c) and transmission to the
device (d):
(a) The actual number of devices and the numbering are not known when parsing
the environment variables. Thus all environment variables are iterated and
searched for device-specific ones.
(b) Only configured device-specific variables are stored. Thus, a linked list
is used.
(c) The output is done in omp_display_env (see specification p. 468f). Global
ICVs are tagged with [all], see https://github.com/OpenMP/spec/issues/3179.
ICVs which are not global but aren't handled device-specific yet are tagged
with [host]. omp_display_env outputs the initial values of the ICVs. That is
why a dedicated data structure is introduced for the inital values only
(gomp_initial_icv_list).
(d) Device-specific ICVs are transmitted to the device via GOMP_ADDITIONAL_ICVS.
libgomp/ChangeLog:
* config/gcn/icv-device.c (omp_get_default_device): Return device-
specific ICV.
(omp_get_max_teams): Added for GCN devices.
(omp_set_num_teams): Likewise.
(ialias): Likewise.
* config/nvptx/icv-device.c (omp_get_default_device): Return device-
specific ICV.
(omp_get_max_teams): Added for NVPTX devices.
(omp_set_num_teams): Likewise.
(ialias): Likewise.
* env.c (struct gomp_icv_list): New struct to store entries of initial
ICV values.
(struct gomp_offload_icv_list): New struct to store entries of device-
specific ICV values that are copied to the device and back.
(struct gomp_default_icv_values): New struct to store default values of
ICVs according to the OpenMP standard.
(parse_schedule): Generalized for different variants of OMP_SCHEDULE.
(print_env_var_error): Function that prints an error for invalid values
for ICVs.
(parse_unsigned_long_1): Removed getenv. Generalized.
(parse_unsigned_long): Likewise.
(parse_int_1): Likewise.
(parse_int): Likewise.
(parse_int_secure): Likewise.
(parse_unsigned_long_list): Likewise.
(parse_target_offload): Likewise.
(parse_bind_var): Likewise.
(parse_stacksize): Likewise.
(parse_boolean): Likewise.
(parse_wait_policy): Likewise.
(parse_allocator): Likewise.
(omp_display_env): Extended to output different variants of environment
variables.
(print_schedule): New helper function for omp_display_env which prints
the values of run_sched_var.
(print_proc_bind): New helper function for omp_display_env which prints
the values of proc_bind_var.
(enum gomp_parse_type): Collection of types used for parsing environment
variables.
(ENTRY): Preprocess string lengths of environment variables.
(OMP_VAR_CNT): Preprocess table size.
(OMP_HOST_VAR_CNT): Likewise.
(INT_MAX_STR_LEN): Constant for the maximal number of digits of a device
number.
(gomp_get_icv_flag): Returns if a flag for a particular ICV is set.
(gomp_set_icv_flag): Sets a flag for a particular ICV.
(print_device_specific_icvs): New helper function for omp_display_env to
print device specific ICV values.
(get_device_num): New helper function for parse_device_specific.
Extracts the device number from an environment variable name.
(get_icv_member_addr): Gets the memory address for a particular member
of an ICV struct.
(gomp_get_initial_icv_item): Get a list item of gomp_initial_icv_list.
(initialize_icvs): New function to initialize a gomp_initial_icvs
struct.
(add_initial_icv_to_list): Adds an ICV struct to gomp_initial_icv_list.
(startswith): Checks if a string starts with a given prefix.
(initialize_env): Extended to parse the new syntax of environment
variables.
* icv-device.c (omp_get_max_teams): Added.
(ialias): Likewise.
(omp_set_num_teams): Likewise.
* icv.c (omp_set_num_teams): Moved to icv-device.c.
(omp_get_max_teams): Likewise.
(ialias): Likewise.
* libgomp-plugin.h (GOMP_DEVICE_NUM_VAR): Removed.
(GOMP_ADDITIONAL_ICVS): New target-side struct that
holds the designated ICVs of the target device.
* libgomp.h (enum gomp_icvs): Collection of ICVs.
(enum gomp_device_num): Definition of device numbers for _ALL, _DEV, and
no suffix.
(enum gomp_env_suffix): Collection of possible suffixes of environment
variables.
(struct gomp_initial_icvs): Contains all ICVs for which we need to store
initial values.
(struct gomp_default_icv):New struct to hold ICVs for which we need
to store initial values.
(struct gomp_icv_list): Definition of a linked list that is used for
storing ICVs for the devices and also for _DEV, _ALL, and without
suffix.
(struct gomp_offload_icvs): New struct to hold ICVs that are copied to
a device.
(struct gomp_offload_icv_list): Definition of a linked list that holds
device-specific ICVs that are copied to devices.
(gomp_get_initial_icv_item): Get a list item of gomp_initial_icv_list.
(gomp_get_icv_flag): Returns if a flag for a particular ICV is set.
* libgomp.texi: Updated.
* plugin/plugin-gcn.c (GOMP_OFFLOAD_load_image): Extended to read
further ICVs from the offload image.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_load_image): Likewise.
* target.c (gomp_get_offload_icv_item): Get a list item of
gomp_offload_icv_list.
(get_gomp_offload_icvs): New. Returns the ICV values
depending on the device num and the variable hierarchy.
(gomp_load_image_to_device): Extended to copy further ICVs to a device.
* testsuite/libgomp.c-c++-common/icv-5.c: New test.
* testsuite/libgomp.c-c++-common/icv-6.c: New test.
* testsuite/libgomp.c-c++-common/icv-7.c: New test.
* testsuite/libgomp.c-c++-common/icv-8.c: New test.
* testsuite/libgomp.c-c++-common/omp-display-env-1.c: New test.
* testsuite/libgomp.c-c++-common/omp-display-env-2.c: New test.
Richard Sandiford [Thu, 8 Sep 2022 15:18:28 +0000 (16:18 +0100)]
vect: Fix scalar stmt typo in vect_optimize_slp_pass [PR106886]
Fix a stupid typo in my vect_optimize_slp_pass patch.
gcc/
PR tree-optimization/106886
* tree-vect-slp.cc (vect_optimize_slp_pass::get_result_with_layout):
Fix copying of scalar stmts.
gcc/testsuite/
PR tree-optimization/106886
* gcc.dg/vect/bb-slp-layout-21.c: New test.
Chung-Lin Tang [Thu, 8 Sep 2022 15:14:38 +0000 (23:14 +0800)]
nios2: Add #undef of MUSL_DYNAMIC_LINKER
Add #undef of MUSL_DYNAMIC_LINKER before #define, to satisfy build checks
when configured with --enable-werror-always.
gcc/ChangeLog:
* config/nios2/linux.h (MUSL_DYNAMIC_LINKER): Add #undef before #define.
Patrick Palka [Thu, 8 Sep 2022 14:49:04 +0000 (10:49 -0400)]
c++: Add testcase for already fixed PR [PR99209]
This was incidentally fixed by r13-806-g221acd67ca50f8.
PR c++/99209
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/lambda-uneval17.C: New test.
Richard Biener [Wed, 7 Sep 2022 10:01:34 +0000 (12:01 +0200)]
Fix some gimple_ctrl_altering_p mistakes
CFG cleanup resets the control altering flag for noreturn functions
when they are ECF_LEAF (like __builtin_unreachable ()). The
.ABNORMAL_DISPATCHER call built during CFG construction is not
marked as control altering. Several passes inserting traps or
unreachables fail to set the flag. And more.
PR middle-end/106870
* gimple-harden-conditionals.cc (insert_check_and_trap):
Set the control-altering flag on the built IFN_TRAP.
* gimple.cc (gimple_build_builtin_unreachable): Likewise.
* tree-cfg.cc (handle_abnormal_edges): Set the control-altering
flag on the .ABNORMAL_DISPATCHER call.
* tree-cfgcleanup.cc (cleanup_call_ctrl_altering_flag): Avoid
resetting the control altering flag for ECF_NORETURN calls.
(cleanup_control_flow_bb): Set the control altering flag on
discovered noreturn calls.
* symtab-thunks.cc (expand_thunk): Set the control altering
flag for the noreturn tailcall case.
* tree-eh.cc (lower_resx): Likewisw for trap and unwind_resume
calls.
Patrick Palka [Thu, 8 Sep 2022 13:45:45 +0000 (09:45 -0400)]
c++: unnecessary instantiation of constexpr var [PR99130]
Here the use of 'value' from within an unevaluated context causes us
to overeagerly instantiate it, via maybe_instantiate_decl called from
mark_used, despite the use occurring in a context that doesn't require
a definition.
This seems to only affect constexpr variable specializations, though
we used to have the same issue for constexpr function specializations
until r6-1309-g81371eff9bc7ef made us delay their instantiation until
necessary during constexpr evaluation.
This patch expands upon the r6-1309 fix to make mark_used avoid
unnecessarily instantiating constexpr variable specializations too,
by pulling out from maybe_instantiate_decl the condition
(decl_maybe_constant_var_p (decl)
|| (TREE_CODE (decl) == FUNCTION_DECL
&& DECL_OMP_DECLARE_REDUCTION_P (decl))
|| undeduced_auto_decl (decl))
into each of its three callers (including mark_used), removing the
problematic first test from mark_used, and simplifying accordingly.
The net result is that only mark_used is changed because the other two
callers, resolve_address_of_overloaded_function and decl_constant_var_p,
already guard the call appropriately. (This relaxation of mark_used
seems to be safe because during constexpr evaluation we already take
care to instantiate a constexpr variable as necessary via
decl_constant_value etc).
PR c++/99130
gcc/cp/ChangeLog:
* decl2.cc (maybe_instantiate_decl): Adjust function comment.
Check VAR_OR_FUNCTION_DECL_P. Pull out the disjunction into ...
(mark_used): ... here, removing the decl_maybe_constant_var_p
part of it.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/constexpr-decltype5.C: New test.
Lewis Hyatt [Wed, 7 Sep 2022 13:33:26 +0000 (09:33 -0400)]
pch: Fix the reconstruction of adhoc data hash table
The function rebuild_location_adhoc_htab() was meant to reconstruct the
adhoc location hash map after restoring a line_maps instance from a
PCH. However, the function has never performed as intended because it
missed the last step of adding the data into the newly reconstructed hash
map. This patch fixes that.
It does not seem possible to construct a test case such that the current
incorrect behavior is observable as a compiler issue. It would be
observable, if it were possible for a precompiled header to contain an
adhoc location with a non-zero custom data pointer. But currently, such
data pointers are used only by the middle end to track inlining
information, and this happens later, too late to show up in a PCH.
I also noted that location_adhoc_data_update, which updates the hash map
pointers in a different scenario, was relying on undefined pointer
arithmetic behavior. I'm not aware of this having caused any issue in
practice, but in this patch I have also changed it to use defined pointer
operations instead.
libcpp/ChangeLog:
* line-map.cc (location_adhoc_data_update): Remove reliance on
undefined behavior.
(get_combined_adhoc_loc): Likewise.
(rebuild_location_adhoc_htab): Fix issue where the htab was not
properly updated.
Jakub Jelinek [Thu, 8 Sep 2022 11:08:22 +0000 (13:08 +0200)]
openmp: Implement doacross(sink: omp_cur_iteration - 1)
This patch implements doacross(sink: omp_cur_iteration - 1) that the
previous patchset emitted a sorry on during omp expansion.
It can be implemented with existing library functions.
To recap, depend(source)/doacross(source:)/doacross(source:omp_cur_iteration)
is implemented calling GOMP_doacross_post or GOMP_doacross_ull_post,
called with an array of long or unsigned long long elements, one for
all collapsed loops together and one for each further ordered loop if any.
We initialize that array in each thread when grabbing further set of iterations
and update it at the end of loops, so that it represents the current iteration
(as 0 based counters). When the worksharing loop is created, we tell the
library through another similar array the counts (the loop needs to be
rectangular) in each dimension, first element is count of all logical iterations
in the collapsed loops.
depend(sink:v1 op N1, v2 op N2, ...) is then implemented by conditionally calling
GOMP_doacross_wait/GOMP_doacross_ull_wait. For N? of 0 there is no check,
otherwise if it wants to wait in a particular dimension for a previous iteration,
we check that the corresponding iterator isn't the first one (or first few),
where the previous iterator in that dimension would be out of range, and similarly
for checking of next iteration in a dimension that it isn't the last one (or last few)
where it would be similarly out of bounds. Then the collapsed loop counters are
folded into a single 0 based counter (first argument) and then other 0 based
iterations counters on what iteration it should wait for.
Now, doacross(sink: omp_cur_iteration - 1) is supposed to wait for the previous
logical iteration in the combined iteration space of all ordered loops.
For the very first iteration in that combined iteration space it does nothing,
there is no previous iteration. And similarly it does nothing if there
are more ordered loops than collapsed loop and it isn't the first logical
iteration of the combined loops inside of the collapsed loops, because as implemented
we know the previous iteration in that case is always executed by the same thread
as the current one.
In the implementation, we use the same value as is stored in the first element
of the array for GOMP_doacross_post/GOMP_doacross_ull_post, if that value is 0,
we do nothing. The rest is different based on if ordered argument is equal to
collapse or not. If it is, then we otherwise call
GOMP_doacross_wait/GOMP_doacross_ull_wait with a single argument, one less than
that counter we compare against 0.
If ordered argument is bigger than collapse, we add a per-thread boolean variable
.first.N, which we set to true at the start of the outermost ordered loop inside
of the collapsed set of loops and set to false at the end of the innermost
ordered loop. If .first.N is false, we don't do anything (we know the previous
iteration was handled by the current thread and by my reading of the spec we don't
need to emit even a memory barrier in that case, because it is just synchronization
with the same thread), otherwise we call GOMP_doacross_wait/GOMP_doacross_ull_wait
with the first argument one less than the counter we compare against 0, and then
one less than 2nd and following counts if iterations we pass to the workshare
initialization. If say .counts.N passed to the workshare initialization is
{ 256, 13, 5, 2 } for collapse(3) ordered(6) loop, then
GOMP_doacross_post/GOMP_doacross_ull_post is called with arguments equal to
.ordereda.N[0] - 1, 12, 4, 1.
2022-09-08 Jakub Jelinek <jakub@redhat.com>
gcc/
* omp-expand.cc (expand_omp_ordered_sink): Add CONT_BB argument.
Add doacross(sink:omp_cur_iteration-1) support.
(expand_omp_ordered_source_sink): Clear counts[fd->ordered + 1].
Adjust expand_omp_ordered_sink caller.
(expand_omp_for_ordered_loops): If counts[fd->ordered + 1] is
non-NULL, set that variable to true at the start of outermost
non-collapsed loop and set it to false at the end of innermost
ordered loop.
(expand_omp_for_generic): If fd->ordered, allocate
1 + (fd->ordered - fd->collapse) further elements in counts array.
Copy to counts + 2 + fd->ordered the counts of fd->collapse ..
fd->ordered - 1 loop if any.
gcc/testsuite/
* c-c++-common/gomp/doacross-7.c: New test.
libgomp/
* libgomp.texi (OpenMP 5.2): Mention that omp_cur_iteration is now
fully supported.
* testsuite/libgomp.c/doacross-4.c: New test.
* testsuite/libgomp.c/doacross-5.c: New test.
* testsuite/libgomp.c/doacross-6.c: New test.
* testsuite/libgomp.c/doacross-7.c: New test.
Richard Biener [Thu, 8 Sep 2022 10:22:26 +0000 (12:22 +0200)]
tree-optimization/106881 - constrain uninit control edge add
The following avoids adding fallthru edges to the control chain from
the post-dominator walk.
PR tree-optimization/106881
* gimple-predicate-analysis.cc (compute_control_dep_chain_pdom):
Add only non-fallthru edges and avoid the same set of edges
as the caller does.
* gcc.dg/uninit-pr106881.c: New testcase.
Richard Biener [Thu, 8 Sep 2022 11:00:45 +0000 (13:00 +0200)]
testsuite/106872 - fix uninit predicate dump scan
On ppc we see a doloop temp rather than ivtmp.
PR testsuite/106872
* gcc.dg/uninit-pred-12.c: Adjust.
Aldy Hernandez [Thu, 8 Sep 2022 06:11:43 +0000 (08:11 +0200)]
Implement known/maybe fpclassify like API for frange.
gcc/ChangeLog:
* gimple-range-fold.cc
(fold_using_range::range_of_builtin_int_call): Use fpclassify like API.
* range-op-float.cc (finite_operand_p): Same.
(finite_operands_p): Same.
(foperator_lt::fold_range): Same.
(foperator_le::fold_range): Same.
(foperator_gt::fold_range): Same.
(foperator_ge::fold_range): Same.
(foperator_unordered::fold_range): Same.
(foperator_unordered::op1_range): Same.
(foperator_ordered::fold_range): Same.
* value-range.cc (frange::set_nan): Same.
(frange::set_signbit): Same.
(frange::union_): Same.
(frange::intersect): Same.
(frange::operator==): Same.
(frange::singleton_p): Same.
(frange::verify_range): Same.
(range_tests_nan): Same.
(range_tests_floats): Same.
* value-range.h(frange::known_finite): New.
(frange::maybe_inf): New.
(frange::known_inf): New.
(frange::maybe_nan): New.
(frange::known_nan): New.
(frange::known_signbit): New.
Iain Buclaw [Thu, 8 Sep 2022 10:29:32 +0000 (12:29 +0200)]
d: Include tm.h in all D target platform sources, remove memmodel.h
The tm.h header would pull in config/elfos.h, which defines
TARGET_D_MINFO_SECTION needed for the D module support in the front-end
to emit data to the correct section for the run-time library to pick up.
The removal of it in r13-2385 caused a stage2 bootstrap failure on all
Solaris targets.
The memmodel header has also been removed as it is no longer required
now tm_p.h is no longer used by these sources.
gcc/ChangeLog:
* config/darwin-d.cc: Include tm.h.
* config/dragonfly-d.cc: Likewise.
* config/freebsd-d.cc: Remove memmodel.h.
* config/glibc-d.cc: Likewise.
* config/netbsd-d.cc: Include tm.h.
* config/openbsd-d.cc: Likewise.
* config/sol2-d.cc: Likewise.
Christophe Lyon [Tue, 6 Sep 2022 16:08:36 +0000 (16:08 +0000)]
arm: Fix constant immediates predicates and constraints for some MVE builtins
Several MVE builtins incorrectly use the same predicate/constraint
pair for several modes, which does not match the specification.
This patch uses the appropriate iterator instead.
2022-09-06 Christophe Lyon <christophe.lyon@arm.com>
gcc/
* config/arm/mve.md (mve_vqshluq_n_s<mode>): Use
MVE_pred/MVE_constraint instead of mve_imm_7/Ra.
(mve_vqshluq_m_n_s<mode>): Likewise.
(mve_vqrshrnbq_n_<supf><mode>): Use MVE_pred3/MVE_constraint3
instead of mve_imm_8/Rb.
(mve_vqrshrunbq_n_s<mode>): Likewise.
(mve_vqrshrntq_n_<supf><mode>): Likewise.
(mve_vqrshruntq_n_s<mode>): Likewise.
(mve_vrshrnbq_n_<supf><mode>): Likewise.
(mve_vrshrntq_n_<supf><mode>): Likewise.
(mve_vqrshrnbq_m_n_<supf><mode>): Likewise.
(mve_vqrshrntq_m_n_<supf><mode>): Likewise.
(mve_vrshrnbq_m_n_<supf><mode>): Likewise.
(mve_vrshrntq_m_n_<supf><mode>): Likewise.
(mve_vqrshrunbq_m_n_s<mode>): Likewise.
(mve_vsriq_n_<supf><mode): Use MVE_pred2/MVE_constraint2 instead
of mve_imm_selective_upto_8/Rg.
(mve_vsriq_m_n_<supf><mode>): Likewise.
Jiufu Guo [Thu, 8 Sep 2022 05:55:53 +0000 (13:55 +0800)]
rs6000: allow constant splitter run in split1 pass
Currently, these two splitters (touched in this patch) are using predicate
`int_reg_operand_not_pseudo`, then they work in split2 pass after RA in
most times, and can not run before RA.
It would not be a bad idea to allow these splitters before RA. Then more
passes (e.g. combine, sched...) could optimize the emitted instructions.
And if splitting before RA, for current constant splitter, we may have more
freedom to create pseduo to help to generate more parallel instructions.
For the example in the leading patch [PATCH 1/2]: pli+plit+rldimi would be
better than pli+sldi+paddi.
Test this patch with spec, we could see performance gain some times; while
the improvement is not stable and woud caused by the patch indirectly.
gcc/ChangeLog:
* config/rs6000/rs6000.md (splitter for set to and_mask constants):
Use int_reg_operand (instead of int_reg_operand_not_pseudo).
(splitter for multi-insn constant loads): Ditto.
Sebastian Huber [Thu, 1 Sep 2022 08:22:47 +0000 (10:22 +0200)]
RTEMS: Add -mvrsave multilibs
gcc/ChangeLog:
* config/rs6000/rtems.h (CPP_OS_DEFAULT_SPEC): Define __PPC_VRSAVE__ if
-mvrsave is present.
* config/rs6000/t-rtems: Add -mvrsave multilib variants for
-mcpu=e6500.
GCC Administrator [Thu, 8 Sep 2022 00:18:33 +0000 (00:18 +0000)]
Daily bump.
Jonathan Wakely [Tue, 6 Sep 2022 10:58:21 +0000 (11:58 +0100)]
libstdc++: Add missing runtime exception to licence notice
This file is missing the GCC Runtime Library Exception text in the
licence header. That is unintentional, and it should have been present.
libstdc++-v3/ChangeLog:
* include/std/barrier: Add missing runtime exception.
Martin Liska [Wed, 7 Sep 2022 14:33:59 +0000 (16:33 +0200)]
Restore detection of HAVE_XCOFF_DWARF_EXTRAS
gcc/ChangeLog:
* configure.ac: Restore detection of HAVE_XCOFF_DWARF_EXTRAS.
* config/rs6000/rs6000.cc (HAVE_XCOFF_DWARF_EXTRAS): Reset it.
* configure: Regenerate.
* config.in: Regenerate.
Jason Merrill [Fri, 2 Sep 2022 12:45:02 +0000 (08:45 -0400)]
c++: diagnostic for template placeholder in parm [PR106793]
Talking about the declarator form doesn't help when fixing that would get
you a different error about placeholders not being valid in a parameter.
This also adds a <> fixit, which isn't enough for most templates, but is a
start.
PR c++/106793
gcc/cp/ChangeLog:
* decl.cc (grokdeclarator): Improve placeholder diagnostics.
* parser.cc (cp_parser_type_id_1): Add fixit.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/auto-array2.C: Adjust.
* g++.dg/cpp1z/class-deduction113.C: New test.
Jeff Law [Wed, 7 Sep 2022 16:32:31 +0000 (12:32 -0400)]
Update my email address
/
* MAINTAINERS: Update my email address.
Surya Kumari Jangala [Wed, 3 Aug 2022 04:00:03 +0000 (23:00 -0500)]
sched1: Fix -fcompare-debug issue in schedule_region [PR105586]
In schedule_region(), a basic block that does not contain any real insns
is not scheduled and the dfa state at the entry of the bb is not copied
to the fallthru basic block. However a DEBUG insn is treated as a real
insn, and if a bb contains non-real insns and a DEBUG insn, it's dfa
state is copied to the fallthru bb. This was resulting in
-fcompare-debug failure as the incoming dfa state of the fallthru block
is different with -g. We should always copy the dfa state of a bb to
it's fallthru bb even if the bb does not contain real insns.
2022-08-22 Surya Kumari Jangala <jskumari@linux.ibm.com>
gcc/
PR rtl-optimization/105586
* sched-rgn.cc (save_state_for_fallthru_edge): New function.
(schedule_region): Use it for all blocks.
gcc/testsuite/
PR rtl-optimization/105586
* gcc.target/powerpc/pr105586.c: New test.
Arsen Arsenović [Sun, 4 Sep 2022 19:04:23 +0000 (21:04 +0200)]
c++: top level bind when rewriting coroutines [PR106188]
In the edge case of a coroutine not containing any locals, the ifcd/switch
temporaries would get added to the coroutine frame, corrupting its
layout. To prevent this, we can make sure there is always a BIND_EXPR at
the top of the function body, and thus, always a place for our new
temporaries to go without interfering with the coroutine frame.
PR c++/106188 - Incorrect frame layout after transforming conditional statement without top-level bind expression
PR c++/106713 - if (co_await ...) crashes with a jump to ud2
PR c++/106188
PR c++/106713
gcc/cp/ChangeLog:
* coroutines.cc (coro_rewrite_function_body): Ensure we have a
BIND_EXPR wrapping the function body.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/pr106188.C: New test.
Signed-off-by: Arsen Arsenović <arsen@aarsen.me>
Patrick Palka [Wed, 7 Sep 2022 14:21:51 +0000 (10:21 -0400)]
libstdc++: Optimize is_reference
Instead of defining is_reference in terms of is_[lr]value_reference,
just define it directly.
libstdc++-v3/ChangeLog:
* include/std/type_traits (is_reference): Make the primary
template derive from false_type. Define two partial
specializations that derive from true_type.
Patrick Palka [Wed, 7 Sep 2022 14:21:45 +0000 (10:21 -0400)]
libstdc++: Optimize is_void and is_null_pointer
Instead of defining these in terms of a helper class template
and the relatively expensive __remove_cv_t, just declare four
explicit specializations of the main template, one for each choice
of cv-quals.
libstdc++-v3/ChangeLog:
* include/std/type_traits (__is_void_helper): Remove.
(is_void): Make the primary template derive from false_type,
and define four explicit specializations that derive from
true_type.
(__is_null_pointer_helper, is_null_pointer): Likewise.
Jason Merrill [Tue, 6 Sep 2022 14:35:21 +0000 (10:35 -0400)]
libstdc++: small dynamic_cast optimization
This change speeds up the simple benchmark below by about 40%.
struct A { virtual ~A() {} };
struct B: A { } b;
A* ap = &b;
void *sink;
int main()
{
for (long i = 0; i < 4000000000L; ++i)
sink = dynamic_cast<B*>(ap);
}
libstdc++-v3/ChangeLog:
* libsupc++/dyncast.cc (__dynamic_cast): Avoid virtual function
call in simple success case.
Joseph Myers [Wed, 7 Sep 2022 13:56:25 +0000 (13:56 +0000)]
c: New C2x keywords
C2x follows C++ in making alignas, alignof, bool, false,
static_assert, thread_local and true keywords; implement this
accordingly. This implementation makes them normal keywords in C2x
mode just like any other keyword (C2x leaves open the possibility of
implementation using predefined macros instead - thus, there aren't
any testcases asserting that they aren't macros). As in C++ and
previous versions of C, true and false are handled like signed 1 and 0
in #if (there was an intermediate state in some C2x drafts where they
had different macro expansions that were unsigned in #if).
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
As with the removal of unprototyped functions, this change has a high
risk of breaking some old code and people doing GNU/Linux distribution
builds may wish to see how much is broken in a build with a -std=gnu2x
default.
gcc/
* ginclude/stdalign.h [defined __STDC_VERSION__ &&
__STDC_VERSION__ > 201710L]: Disable all content.
* ginclude/stdbool.h [defined __STDC_VERSION__ && __STDC_VERSION__
> 201710L] (bool, true, false): Do not define.
gcc/c-family/
* c-common.cc (c_common_reswords): Use D_C2X instead of D_CXXONLY
for alignas, alignof, bool, false, static_assert, thread_local and
true.
gcc/c/
* c-parser.cc (c_parser_static_assert_declaration_no_semi)
(c_parser_alignas_specifier, c_parser_alignof_expression): Allow
for C2x spellings of keywords.
(c_parser_postfix_expression): Handle RID_TRUE and RID_FALSE.
gcc/testsuite/
* gcc.dg/c11-keywords-1.c, gcc.dg/c2x-align-1.c,
gcc.dg/c2x-align-6.c, gcc.dg/c2x-bool-2.c,
gcc.dg/c2x-static-assert-3.c, gcc.dg/c2x-static-assert-4.c,
gcc.dg/c2x-thread-local-1.c: New tests.
* gcc.dg/c2x-bool-1.c: Update expectations.
libcpp/
* include/cpplib.h (struct cpp_options): Add true_false.
* expr.cc (eval_token): Check true_false not cplusplus to
determine whether to handle true and false keywords.
* init.cc (struct lang_flags): Add true_false.
(lang_defaults): Update.
(cpp_set_lang): Set true_false.
Martin Liska [Wed, 7 Sep 2022 09:47:40 +0000 (11:47 +0200)]
Restore XCOFF for DWARF on AIX.
PR bootstrap/106855
gcc/ChangeLog:
* collect2.cc (scan_prog_file): Restore if XCOFF_DEBUGGING_INFO.
* config/rs6000/rs6000.cc (rs6000_option_override_internal):
Restore usage of XCOFF_DEBUGGING_INFO.
* config/rs6000/xcoff.h (XCOFF_DEBUGGING_INFO): Restore.
* dwarf2asm.cc (XCOFF_DEBUGGING_INFO): Restore support for
XCOFF_DEBUGGING_INFO.
(dw2_asm_output_nstring): Likewise.
(USE_LINKONCE_INDIRECT): Likewise.
* dwarf2out.cc (XCOFF_DEBUGGING_INFO): Likewise.
(HAVE_XCOFF_DWARF_EXTRAS): Likewise.
(output_fde): Likewise.
(output_call_frame_info): Likewise.
(have_macinfo): Likewise.
(add_AT_loc_list): Likewise.
(add_AT_view_list): Likewise.
(output_compilation_unit_header): Likewise.
(output_pubnames): Likewise.
(output_aranges): Likewise.
(output_line_info): Likewise.
(output_macinfo): Likewise.
(dwarf2out_finish): Likewise.
(dwarf2out_early_finish): Likewise.
Richard Biener [Wed, 7 Sep 2022 10:50:40 +0000 (12:50 +0200)]
tree-optimization/106866 - avoid dead abnormal edges from DCE
When DCE clears cfun->calls_setjmp then suddenly we don't need
any abnormal call edges anymore. The following makes sure to
prune them which otherwise can confuse other passes.
PR tree-optimization/106866
* tree-ssa-dce.cc (eliminate_unnecessary_stmts): When
we changed cfun->calls_setjmp make sure to purge all
abnormal call edges.
* gcc.dg/uninit-pr106866.c: New testcase.
Tom de Vries [Wed, 7 Sep 2022 11:19:05 +0000 (13:19 +0200)]
[gdb/build] Fix build breaker with --enable-shared
When building gdb with --enable-shared, I run into:
...
ld: build/zlib/libz.a(libz_a-inffast.o): relocation R_X86_64_32S against \
`.rodata' can not be used when making a shared object; recompile with -fPIC
ld: build/zlib/libz.a(libz_a-inflate.o): warning: relocation against \
`inflateResetKeep' in read-only section `.text'
collect2: error: ld returned 1 exit status
make[3]: *** [libbfd.la] Error 1
...
This is a regression since commit
a08bdb159bb ("[gdb/build] Fix gdbserver
build with -fsanitize=thread").
The problem is that a single case statement in configure is shared to handle
special requirements for both the host libiberty and host zlib, which has the
effect that only one is handled.
Fix this by handling libiberty and zlib each in its own case statement.
Build on x86_64-linux, with and without --enable-shared.
ChangeLog:
2022-09-07 Tom de Vries <tdevries@suse.de>
* configure.ac: Set extra_host_libiberty_configure_flags and
extra_host_zlib_configure_flags in separate case statements.
* configure: Regenerate.
Aldy Hernandez [Wed, 7 Sep 2022 10:58:49 +0000 (12:58 +0200)]
[PR106867] Add test for PR.
PR tree-optimization/106867
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr106867.c: New test.
Xianmiao Qu [Wed, 7 Sep 2022 09:19:54 +0000 (17:19 +0800)]
C-SKY: Fix expanding of float LE comparing with zero for fpuv3.
The original code will cause the warning:
/usr/lib/gcc-snapshot/bin/g++ -fno-PIE -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o csky.o -MT csky.o -MMD -MP -MF ./.deps/csky.TPo ../../gcc/gcc/config/csky/csky.cc
In file included from ../../gcc/gcc/config/csky/csky.h:183,
from ./tm.h:20,
from ../../gcc/gcc/backend.h:28,
from ../../gcc/gcc/config/csky/csky.cc:27:
../../gcc/gcc/config/csky/csky.cc: In function 'bool csky_emit_compare_float(rtx_code, rtx, rtx)':
../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context]
29 | #define CSKY_ISA_FEATURE_DEFINE(x) isa_bit_ ## x
| ^~~~~~~~
../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE'
30 | #define CSKY_ISA_FEATURE_GET(x) CSKY_ISA_FEATURE_DEFINE (x)
| ^~~~~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/csky/csky.cc:6346:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET'
6346 | || CSKY_ISA_FEATURE_GET(fpv2_df)
| ^~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context]
29 | #define CSKY_ISA_FEATURE_DEFINE(x) isa_bit_ ## x
| ^~~~~~~~
../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE'
30 | #define CSKY_ISA_FEATURE_GET(x) CSKY_ISA_FEATURE_DEFINE (x)
| ^~~~~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/csky/csky.cc:6346:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET'
6346 | || CSKY_ISA_FEATURE_GET(fpv2_df)
| ^~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context]
29 | #define CSKY_ISA_FEATURE_DEFINE(x) isa_bit_ ## x
| ^~~~~~~~
../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE'
30 | #define CSKY_ISA_FEATURE_GET(x) CSKY_ISA_FEATURE_DEFINE (x)
| ^~~~~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/csky/csky.cc:6347:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET'
6347 | || CSKY_ISA_FEATURE_GET(fpv2_divd)))
| ^~~~~~~~~~~~~~~~~~~~
The 'CSKY_ISA_FEATURE_DEFINE (x)' is an enum contant, it will cause the condition always being true.
In addition to warning, it will let FPUV3 to generate a move instruction, which is unnecessary.
In a simple test case, the move instruction can be combined, so it was not found in the testsuite.
But in some complex scenarios, this may generate some redundant instructions.
The correct way is to use 'CSKY_ISA_FEATURE' instead of 'CSKY_ISA_FEATURE_DEFINE'.
gcc/
* config/csky/csky.cc (csky_emit_compare_float): Fix the expanding of
float LE comparing with zero for fpuv3.
* config/csky/csky.h (TARGET_SUPPORT_FPV2): New, true if any fpuv2
features are enabled.
Richard Biener [Wed, 7 Sep 2022 08:44:33 +0000 (10:44 +0200)]
tree-optimization/106860 - fix profile scaling in split_loop
The following fixes a mistake in loop splitting which assumes loop
latches have a single predecessor and that edge is from the exit
test. Instead work from the single exit edge we have to find the
edge towards the latch.
PR tree-optimization/106860
* tree-ssa-loop-split.cc (split_loop): Find the exit to
latch edge from the loop exit edge instead of from the
latch. Verify we're going to find it.
* g++.dg/opt/pr106860.C: New testcase.
Richard Biener [Tue, 6 Sep 2022 13:30:53 +0000 (15:30 +0200)]
mark region also for USE predicate discovery
The following makes sure to mark the dominating region also for
USE predicate discovery, avoiding compute_control_dep_chain to
walk to unrelated areas, eating up walking budget.
* gimple-predicate-analysis.cc (dfs_mark_dominating_region):
Adjust to take the region exit source as argument.
(uninit_analysis::init_from_phi_def): Adjust.
(uninit_analysis::init_use_preds): Mark the dominating region
before computing control dependences.
Richard Sandiford [Wed, 7 Sep 2022 09:52:04 +0000 (10:52 +0100)]
aarch64: Fix +nosimd handling of FPR moves
8-bit and 16-bit FPR moves would ICE for +nosimd+fp, and some other
moves would handle FPR<-zero inefficiently. This is very much a
niche case at the moment, but something like it becomes more
important with SME streaming mode.
The si, di and vector tests already passed, they're just included for
completeness.
We're a bit inconsistent about whether alternatives involving FPRs
are marked with arch==fp or arch=* (i.e. default). E.g. FPR loads
and stores are sometimes * and sometimes fp.
IMO * makes more sense. FPRs should not be used at all without
TARGET_FLOAT, so TARGET_FLOAT represents the base architecture
when FPRs are enabled. I think it's more useful if non-default
arches represent a genuine restriction.
gcc/
* config/aarch64/aarch64.md (*mov<SHORT:mode>_aarch64): Extend
w<-w, r<-w and w<-r alternatives to !simd, using 32-bit moves
in that case. Extend w<-r to w<-Z.
(*mov<HFBF:mode>_aarch64): Likewise, but with Y instead of Z.
(*movti_aarch64): Use an FMOV from XZR for w<-Z if MOVI is not
available.
(define_split): Do not apply the floating-point immediate-to-register
split to zeros, even if MOVI is not available.
gcc/testsuite/
* gcc.target/aarch64/movqi_1.c: New test.
* gcc.target/aarch64/movhi_1.c: Likewise.
* gcc.target/aarch64/movsi_1.c: Likewise.
* gcc.target/aarch64/movdi_2.c: Likewise.
* gcc.target/aarch64/movti_2.c: Likewise.
* gcc.target/aarch64/movhf_1.c: Likewise.
* gcc.target/aarch64/movsf_1.c: Likewise.
* gcc.target/aarch64/movdf_1.c: Likewise.
* gcc.target/aarch64/movtf_2.c: Likewise.
* gcc.target/aarch64/movv8qi_1.c: Likewise.
* gcc.target/aarch64/movv16qi_1.c: Likewise.
Richard Sandiford [Wed, 7 Sep 2022 09:52:03 +0000 (10:52 +0100)]
aarch64: Prevent FPR register asms for +nofp
+nofp disabled the automatic allocation of FPRs, but it didn't stop
users from explicitly putting register variables in FPRs. We'd then
either report an ICE or generate unsupported instructions.
It's still possible (and deliberately redundant) to specify FPRs in
clobber lists.
gcc/
* config/aarch64/aarch64.cc (aarch64_conditional_register_usage):
Disallow use of FPRs in register asms for !TARGET_FLOAT.
gcc/testsuite/
* gcc.target/aarch64/nofp_2.c: New test.
Lulu Cheng [Wed, 7 Sep 2022 03:25:45 +0000 (11:25 +0800)]
LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend [PR106828].
gcc/ChangeLog:
PR target/106828
* config/loongarch/loongarch.cc (loongarch_asan_shadow_offset): New.
(TARGET_ASAN_SHADOW_OFFSET): New.
gcc/testsuite/ChangeLog:
PR target/106828
* g++.target/loongarch/pr106828.C: New test.
Jakub Jelinek [Wed, 7 Sep 2022 06:54:13 +0000 (08:54 +0200)]
openmp: Fix handling of target constructs in static member functions [PR106829]
Just calling current_nonlambda_class_type in static member functions returns
non-NULL, but something that isn't *this and if unlucky can match part of the
IL and can be added to target clauses.
if (DECL_NONSTATIC_MEMBER_P (decl)
&& current_class_ptr)
is a guard used elsewhere (in check_accessibility_of_qualified_id).
2022-09-07 Jakub Jelinek <jakub@redhat.com>
PR c++/106829
* semantics.cc (finish_omp_target_clauses): If current_function_decl
isn't a nonstatic member function, don't set data.current_object to
non-NULL.
* g++.dg/gomp/pr106829.C: New test.
Jakub Jelinek [Wed, 7 Sep 2022 06:44:38 +0000 (08:44 +0200)]
libcpp: Named universal character escapes and delimited escape sequence tweaks
On Tue, Aug 30, 2022 at 09:10:37PM +0000, Joseph Myers wrote:
> I'm seeing build failures of glibc for powerpc64, as illustrated by the
> following C code:
>
> #if 0
> \NARG
> #endif
>
> (the actual sysdeps/powerpc/powerpc64/sysdep.h code is inside #ifdef
> __ASSEMBLER__).
>
> This shows some problems with this feature - and with delimited escape
> sequences - as it affects C. It's fine to accept it as an extension
> inside string and character literals, because \N or \u{...} would be
> invalid in the absence of the feature (i.e. the syntax for such literals
> fails to match, meaning that the rule about undefined behavior for a
> single ' or " as a pp-token applies). But outside string and character
> literals, the usual lexing rules apply, the \ is a pp-token on its own and
> the code is valid at the preprocessing level, and with expansion of macros
> appearing before or after the \ (e.g. u defined as a macro in the \u{...}
> case) it may be valid code at the language level as well. I don't know
> what older C++ versions say about this, but for C this means e.g.
>
> #define z(x) 0
> #define a z(
> int x = a\NARG);
>
> needs to be accepted as expanding to "int x = 0;", not interpreted as
> using the \N feature in an identifier and produce an error.
The following patch changes this, so that:
1) outside of string/character literals, \N without following { is never
treated as an error nor warning, it is silently treated as \ separate
token followed by whatever is after it
2) \u{123} and \N{LATIN SMALL LETTER A WITH ACUTE} are not handled as
extension at all outside of string/character literals in the strict
standard modes (-std=c*) except for -std=c++{23,2b}, only in the
-std=gnu* modes, because it changes behavior on valid sources, e.g.
#define z(x) 0
#define a z(
int x = a\u{123});
int y = a\N{LATIN SMALL LETTER A WITH ACUTE});
3) introduces -Wunicode warning (on by default) and warns for cases
of what looks like invalid delimited escape sequence or named
universal character escape outside of string/character literals
and is treated as separate tokens
2022-09-07 Jakub Jelinek <jakub@redhat.com>
libcpp/
* include/cpplib.h (struct cpp_options): Add cpp_warn_unicode member.
(enum cpp_warning_reason): Add CPP_W_UNICODE.
* init.cc (cpp_create_reader): Initialize cpp_warn_unicode.
* charset.cc (_cpp_valid_ucn): In possible identifier contexts, don't
handle \u{ or \N{ specially in -std=c* modes except -std=c++2{3,b}.
In possible identifier contexts, don't emit an error and punt
if \N isn't followed by {, or if \N{} surrounds some lower case
letters or _. In possible identifier contexts when not C++23, don't
emit an error but warning about unknown character names and treat as
separate tokens. When treating as separate tokens \u{ or \N{, emit
warnings.
gcc/
* doc/invoke.texi (-Wno-unicode): Document.
gcc/c-family/
* c.opt (Winvalid-utf8): Use ObjC instead of objC. Remove
" in comments" from description.
(Wunicode): New option.
gcc/testsuite/
* c-c++-common/cpp/delimited-escape-seq-4.c: New test.
* c-c++-common/cpp/delimited-escape-seq-5.c: New test.
* c-c++-common/cpp/delimited-escape-seq-6.c: New test.
* c-c++-common/cpp/delimited-escape-seq-7.c: New test.
* c-c++-common/cpp/named-universal-char-escape-5.c: New test.
* c-c++-common/cpp/named-universal-char-escape-6.c: New test.
* c-c++-common/cpp/named-universal-char-escape-7.c: New test.
* g++.dg/cpp23/named-universal-char-escape1.C: New test.
* g++.dg/cpp23/named-universal-char-escape2.C: New test.
Jiufu Guo [Wed, 7 Sep 2022 05:32:55 +0000 (13:32 +0800)]
rs6000: remove unused splitter on const_scalar_int_operand
There are two splitters, both are calling rs6000_emit_set_const to emit
instructions for constant building.
One splitter checks `const_int_operand`, this splitter is always used.
Another spitter checks `const_scalar_int_operand`, this one is never
used now.
Checking the history, that splitter is introduced around 1999 for
HOST_BITS_PER_WIDE_INT=32, as below:
(define_split
[(set (match_operand:DI 0 "gpc_reg_operand" "")
(match_operand:DI 1 "const_double_operand" ""))]
"HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
&& num_insns_constant (operands[1], DImode) > 1"
And `HOST_BITS_PER_WIDE_INT == 32` is eliminated later, since it is
`const_double_operand` can cover it.
When wide_int is introduced, `const_double_operand` is replaced by
`const_scalar_int_operand`.
Now, HOST_BITS_PER_WIDE_INT is forced to 64, this splitter is safe
to remove.
gcc/ChangeLog:
* config/rs6000/rs6000.md (const_scalar_int splitter): Remove.
Jiufu Guo [Thu, 11 Aug 2022 12:01:28 +0000 (20:01 +0800)]
rs6000: fix misleading new patterns of splitters
As a comment in
https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599556.html
Those splitters call rs6000_emit_set_const directly, and the replacements
are never used. Using (pc) would be less misleading.
gcc/ChangeLog:
* config/rs6000/rs6000.md: (constant splitters): Use "(pc)" as the
replacements.
Ian Lance Taylor [Sat, 3 Sep 2022 17:37:07 +0000 (10:37 -0700)]
runtime: ignore __morestack function in runtime.Callers
We were ignoring all functions starting with "__morestack_", but not
the function "__morestack" itself. Without this change, some tests
such as recover.go started failing recently, though I'm not sure
exactly what changed.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/427935
Kewen Lin [Wed, 7 Sep 2022 01:37:57 +0000 (20:37 -0500)]
rs6000/test: Fix empty TU in some cases of effective targets [PR106345]
As the failure of test case gcc.target/powerpc/pr92398.p9-.c in
PR106345 shows, some test sources for some powerpc effective
targets use empty translation unit wrongly. The test sources
could go with options like "-ansi -pedantic-errors", then those
effective target checkings will fail unexpectedly with the
error messages like:
error: ISO C forbids an empty translation unit [-Wpedantic]
This patch is to fix empty TUs with one dummy function definition
accordingly.
PR testsuite/106345
gcc/testsuite/ChangeLog:
* lib/target-supports.exp (check_effective_target_powerpc_sqrt): Add
a function definition to avoid pedwarn about empty translation unit.
(check_effective_target_has_arch_pwr5): Likewise.
(check_effective_target_has_arch_pwr6): Likewise.
(check_effective_target_has_arch_pwr7): Likewise.
(check_effective_target_has_arch_pwr8): Likewise.
(check_effective_target_has_arch_pwr9): Likewise.
(check_effective_target_has_arch_pwr10): Likewise.
(check_effective_target_has_arch_ppc64): Likewise.
(check_effective_target_ppc_float128): Likewise.
(check_effective_target_ppc_float128_insns): Likewise.
(check_effective_target_powerpc_vsx): Likewise.
liuhongt [Thu, 4 Aug 2022 01:04:22 +0000 (09:04 +0800)]
Extend vectorizer to handle nonlinear induction for neg, mul/lshift/rshift with a constant.
For neg, the patch create a vec_init as [ a, -a, a, -a, ... ] and no
vec_step is needed to update vectorized iv since vf is always multiple
of 2(negative * negative is positive).
For shift, the patch create a vec_init as [ a, a >> c, a >> 2*c, ..]
as vec_step as [ c * nunits, c * nunits, c * nunits, ... ], vectorized iv is
updated as vec_def = vec_init >>/<< vec_step.
For mul, the patch create a vec_init as [ a, a * c, a * pow(c, 2), ..]
as vec_step as [ pow(c,nunits), pow(c,nunits),...] iv is updated as vec_def =
vec_init * vec_step.
The patch handles nonlinear iv for
1. Integer type only, floating point is not handled.
2. No slp_node.
3. iv_loop should be same as vector loop, not nested loop.
4. No UD is created, for mul, use unsigned mult to avoid UD, for
shift, shift count should be less than type precision.
gcc/ChangeLog:
PR tree-optimization/103144
* tree-vect-loop.cc (vect_is_nonlinear_iv_evolution): New function.
(vect_analyze_scalar_cycles_1): Detect nonlinear iv by upper function.
(vect_create_nonlinear_iv_init): New function.
(vect_peel_nonlinear_iv_init): Ditto.
(vect_create_nonlinear_iv_step): Ditto
(vect_create_nonlinear_iv_vec_step): Ditto
(vect_update_nonlinear_iv): Ditto
(vectorizable_nonlinear_induction): Ditto.
(vectorizable_induction): Call
vectorizable_nonlinear_induction when induction_type is not
vect_step_op_add.
* tree-vect-loop-manip.cc (vect_update_ivs_after_vectorizer):
Update nonlinear iv for epilogue loop.
* tree-vectorizer.h (enum vect_induction_op_type): New enum.
(STMT_VINFO_LOOP_PHI_EVOLUTION_TYPE): New Macro.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr103144-mul-1.c: New test.
* gcc.target/i386/pr103144-mul-2.c: New test.
* gcc.target/i386/pr103144-neg-1.c: New test.
* gcc.target/i386/pr103144-neg-2.c: New test.
* gcc.target/i386/pr103144-shift-1.c: New test.
* gcc.target/i386/pr103144-shift-2.c: New test.
GCC Administrator [Wed, 7 Sep 2022 00:17:51 +0000 (00:17 +0000)]
Daily bump.
Jason Merrill [Tue, 6 Sep 2022 18:18:39 +0000 (14:18 -0400)]
c++: C++23 operator[] allows default arguments
This usage was intended to be allowed by P2128, but it didn't make it into
the final wording. Fixed by CWG 2507.
DR2507
gcc/cp/ChangeLog:
* decl.cc (grok_op_properties): Return sooner for C++23 op[].
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/subscript8.C: New test.
Richard Biener [Tue, 6 Sep 2022 11:46:00 +0000 (13:46 +0200)]
tree-optimization/106754 - fix compute_control_dep_chain defect
The following handles the situation of a loop exit along the
control path to the PHI def or from there to the use in a different
way, aoviding premature abort of the walks as noticed in the two
cases where the exit is outermost (gcc.dg/uninit-pred-11.c) or
wrapped in a condition that is on the path (gcc.dg/uninit-pred-12.c).
Instead of handling such exits during recursion we now pick them
up in the parent when walking post-dominators. That requires an
additional post-dominator walk at the outermost level which is
facilitated by splitting out the walk to a helper function and
the existing wrapper added earlier.
The patch also removes the bogus early exit from
uninit_analysis::init_use_preds, fixing a simplified version
of the PR106155 testcase.
PR tree-optimization/106754
* gimple-predicate-analysis.cc (compute_control_dep_chain_pdom):
New function, split out from compute_control_dep_chain. Handle
loop-exit like conditions here by pushing to the control vector.
(compute_control_dep_chain): Adjust and streamline dumping.
In the wrapper perform a post-dominator walk as well.
(uninit_analysis::init_use_preds): Remove premature early exit.
* gcc.dg/uninit-pred-12.c: New testcase.
* gcc.dg/uninit-pr106155-1.c: Likewise.
Max Filippov [Sat, 13 Aug 2022 04:02:15 +0000 (21:02 -0700)]
xtensa: gcc: add static PIE support
gcc/
* config/xtensa/linux.h (LINK_SPEC): Add static-pie.
Aldy Hernandez [Tue, 6 Sep 2022 06:20:54 +0000 (08:20 +0200)]
Handle > INF and < INF correctly in range-op-float.cc
The gfortran.dg/minlocval*.f90 tests are generating conditionals past
the infinities. For example:
if (x <= +Inf)
foo (x);
else
bar (x);
It seems to me that the only possible value for x on the false side is
either NAN or undefined (for !HONOR_NANS).
gcc/ChangeLog:
* range-op-float.cc (build_le): Handle NANs and going past infinity.
(build_lt): Same.
(build_ge): Same.
(build_gt): Same.
(foperator_lt::op1_range): Avoid adjustments to range if build_*
returned false.
(foperator_lt::op2_range): Same.
(foperator_le::op1_range): Same.
(foperator_le::op2_range): Same.
(foperator_gt::op1_range): Same.
(foperator_gt::op2_range): Same.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/vrp-float-inf-1.c: New test.
Richard Biener [Tue, 6 Sep 2022 09:56:04 +0000 (11:56 +0200)]
Fix use predicate computation for uninit analysis
In uninit analysis we try to prove that a use is always properly guarded
so it is never reached when the used value is not initialized. This
fails to be conservative when during the computation of the use
predicate components of the || .. || .. chain are dropped so we have
to detect this case and fall back to the conservative computation.
* gimple-predicate-analysis.cc (compute_control_dep_chain):
Add output flag to indicate whether we possibly have dropped
any chains. Return whether the info is complete from the
wrapping overload.
(uninit_analysis::init_use_preds): Adjust accordingly, with
a workaround for PR106754.
(uninit_analysis::init_from_phi_def): Properly guard the
case where we complete an empty chain.
Philipp Fent [Sun, 4 Sep 2022 18:47:34 +0000 (20:47 +0200)]
libstdc++: Fix pretty printer tests of tuple indexes
Signed-off-by: Philipp Fent <fent@in.tum.de>
libstdc++-v3/ChangeLog:
* testsuite/libstdc++-prettyprinters/48362.cc: Fix expected
tuple indices.
* testsuite/libstdc++-prettyprinters/cxx11.cc: Likewise.
Jan-Benedict Glaw [Tue, 6 Sep 2022 11:05:21 +0000 (13:05 +0200)]
Document unused function argument
This patch fixes a small warning about the unused outer_rtx argument in the
msp430 backend.
2022-09-06 Jan-Benedict Glaw <jbglaw@lug-owl.de>
gcc/ChangeLog:
* config/msp430/msp430.cc (msp430_single_op_cost): Document unused argument.
Prathamesh Kulkarni [Tue, 6 Sep 2022 09:48:04 +0000 (15:18 +0530)]
tree-ssa-forwprop.cc: Adjust res_type when operands have differing vector lengths.
gcc/
* tree-ssa-forwprop.cc (simplify_permutation): Set res_type to a vector
type with same element type as arg0, and length as op2.
Richard Biener [Tue, 6 Sep 2022 08:42:50 +0000 (10:42 +0200)]
tree-optimization/106844 - fix ICE in init_use_preds
The following fixes an oversight in the last change to
compute_control_dep_chain where we have to return whether we found
a chain.
PR tree-optimization/106844
* gimple-predicate-analysis.cc (compute_control_dep_chain):
Return whether we found a chain.
* gcc.dg/pr106844.c: New testcase.
Richard Biener [Tue, 6 Sep 2022 08:08:44 +0000 (10:08 +0200)]
tree-optimization/106841 - gather and hybrid SLP
Hybrid SLP detection currently fails to consider a not direct
offset operand of a scatter/gather operation. The following fixes
this.
PR tree-optimization/106841
* tree-vect-slp.cc (vect_detect_hybrid_slp): Also process
scatter/gather offset.
* g++.dg/vect/pr106841.cc: New testcase.
Tobias Burnus [Tue, 6 Sep 2022 08:02:13 +0000 (10:02 +0200)]
Fix Fortran/openmp: Partial OpenMP 5.2 doacross
This removed a checking snippet which accidentally was left in in commit
r13-2446-g938cda536019cd6a1bc0dd2346381185b420bbf8 ; this caused
fails in gfortran.dg/gomp/doacross-5.f90 (added in that very commit).
Note that a similar but refined check is now done in the middle end.
(The ME version additionally checks whether doacross is present.)
gcc/fortran/
* openmp.cc (resolve_omp_clauses): Remove ordered/linear
check as it is handled now in the middle end.
Jakub Jelinek [Tue, 6 Sep 2022 07:24:13 +0000 (09:24 +0200)]
openmp: Be consistent on parsing offsets between normal sink vector and omp_cur_iteration - 1
For normal sink vectors, we just check that the token is CPP_NUMBER and with
INTEGER_CST value, while for omp_cur_iteration I was additionally requiring
integer_type_node type (so only 1, 001, 0x0001 but not 1L or 1ULL etc.).
I think we need to clarify what we actually should allow in the standard, until
then it is better to be consistent.
2022-09-06 Jakub Jelinek <jakub@redhat.com>
gcc/c/
* c-parser.cc (c_parser_omp_clause_doacross_sink): Don't verify val
in omp_cur_iteration - 1 has integer_type_node type.
gcc/cp/
* parser.cc (cp_parser_omp_clause_doacross_sink): Don't verify val
in omp_cur_iteration - 1 has integer_type_node type.
gcc/testsuite/
* c-c++-common/gomp/doacross-6.c (corge): Don't expect an error here.
Add a few further tests.
Jakub Jelinek [Tue, 6 Sep 2022 07:21:10 +0000 (09:21 +0200)]
openmp: Fix ICE when splitting invalid depend(source)/depend(sink:vec)
As we now create OMP_CLAUSE_DOACROSS rather than OMP_CLAUSE_DEPEND when
depend is used with source/sink modifiers, c_omp_split_clauses can see
OMP_CLAUSE_DOACROSS clause too before we diagnose it as erroneous.
The following patch treats it like OMP_CLAUSE_DEPEND during
the splitting but adds an assertion.
2022-09-06 Jakub Jelinek <jakub@redhat.com>
PR c/106836
* c-omp.cc (c_omp_split_clauses): Handle OMP_CLAUSE_DOACROSS.
* c-c++-common/gomp/pr106836.c: New test.
Jan-Benedict Glaw [Tue, 6 Sep 2022 07:18:36 +0000 (09:18 +0200)]
No actual regclasses for bpf
Building for for bpf-unknown-none target, recent GCCs will issue an unused
variable warning as the REGNO_REG_CLASS macro doesn't actually use its
argument. Reference the argument as (void) to silence the warning.
.../gcc/configure --prefix=... --enable-werror-always --enable-languages=all --disable-gcov --disable-shared --disable-threads --target=bpf-unknown-none --without-headers
[...]
make V=1 all-gcc
[...]
/usr/lib/gcc-snapshot/bin/g++ -fno-PIE -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o regcprop.o -MT regcprop.o -MMD -MP -MF ./.deps/regcprop.TPo ../../gcc/gcc/regcprop.cc
../../gcc/gcc/regcprop.cc: In function 'bool copyprop_hardreg_forward_1(basic_block, value_data*)':
../../gcc/gcc/regcprop.cc:794:24: error: unused variable 'regno' [-Werror=unused-variable]
794 | unsigned int regno = REGNO (SET_SRC (set));
| ^~~~~
cc1plus: all warnings being treated as errors
make[1]: *** [Makefile:1146: regcprop.o] Error 1
make[1]: Leaving directory '/var/lib/laminar/run/gcc-bpf-unknown-none/1/toolchain-build/gcc'
make: *** [Makefile:4565: all-gcc] Error 2
gcc/
* config/bpf/bpf.h (REGNO_REG_CLASS): Reference arguments as (void).
Jakub Jelinek [Tue, 6 Sep 2022 07:19:24 +0000 (09:19 +0200)]
openmp: Introduce gimple_omp_ordered_standalone_p
On Sat, Sep 03, 2022 at 10:07:27AM +0200, Jakub Jelinek via Gcc-patches wrote:
> Incrementally, I'd like to change the way we differentiate between
> stand-alone and block-associated ordered constructs, because the current
> way of looking for presence of doacross clause doesn't work well if those
> clauses are removed because they had been invalid (wrong syntax or
> unknown variables in it etc.)
The following, so far only lightly tested, patch implements that.
2022-09-06 Jakub Jelinek <jakub@redhat.com>
gcc/
* gimple.h (enum gf_mask): Add GF_OMP_ORDERED_STANDALONE enumerator.
(gimple_omp_subcode): Use GIMPLE_OMP_ORDERED instead of
GIMPLE_OMP_TEAMS as upper bound.
(gimple_omp_ordered_standalone_p, gimple_omp_ordered_standalone): New
inline functions.
* gimplify.cc (find_standalone_omp_ordered): Look for OMP_ORDERED with
NULL OMP_ORDERED_BODY rather than with OMP_DOACROSS clause.
(gimplify_expr): Call gimple_omp_ordered_standalone for OMP_ORDERED
with NULL OMP_ORDERED_BODY.
* omp-low.cc (check_omp_nesting_restrictions): Use
gimple_omp_ordered_standalone_p test instead of
omp_find_clause (..., OMP_CLAUSE_DOACROSS).
(lower_omp_ordered): Likewise.
* omp-expand.cc (expand_omp, build_omp_regions_1,
omp_make_gimple_edges): Likewise.
gcc/cp/
* pt.cc (tsubst_expr) <case OMP_ORDERED>: If OMP_BODY was NULL, keep
it NULL after instantiation too.
gcc/testsuite/
* c-c++-common/gomp/sink-3.c: Don't expect a superfluous error during
error recovery.
* c-c++-common/gomp/doacross-6.c (foo): Add further tests.
Eric Botcazou [Mon, 22 Aug 2022 21:32:05 +0000 (23:32 +0200)]
[Ada] Mark artificial formal parameters in the debug info
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_param): Set DECL_ARTIFICIAL.
Eric Botcazou [Mon, 22 Aug 2022 21:23:52 +0000 (23:23 +0200)]
[Ada] Fix problematic line debug info attached to call to finalizer
The End_Label is not defined for body nodes so a small tweak is needed.
gcc/ada/
* gcc-interface/trans.cc (At_End_Proc_to_gnu): Use the End_Label of
the child Handled_Statement_Sequence for body nodes.
(set_end_locus_from_node): Minor tweaks.
Eric Botcazou [Tue, 16 Aug 2022 15:54:59 +0000 (17:54 +0200)]
[Ada] Fix internal error on double renaming of private constant
The first renaming uses the type of the full view of the constant but not
the second, which introduces problematic view conversions downstream.
gcc/ada/
* gcc-interface/trans.cc (Full_View_Of_Private_Constant): New
function returning the Full_View of a private constant, after
looking through a chain of renamings, if any.
(Identifier_to_gnu): Call it on the entity. Small cleanup.
Eric Botcazou [Tue, 19 Jul 2022 18:55:05 +0000 (20:55 +0200)]
[Ada] Fix missing name for access type in generic instantiation
Pointer types aren't named types in C so we need to take extra care in Ada
to make sure that the name of access types is preserved.
gcc/ada/
* gcc-interface/utils.cc (gnat_pushdecl): Preserve named
TYPE_DECLs consistently for all kind of pointer types.
Eric Botcazou [Tue, 12 Jul 2022 12:22:53 +0000 (14:22 +0200)]
[Ada] Extend No_Dependence restriction to code generation (continued)
gcc/ada/
* gcc-interface/trans.cc (gnat_to_gnu) <N_Op_Divide>: Report a
violation of No_Dependence on System.GCC if the result type is
larger than a word.
<N_Op_Shift>: Likewise.
<N_Op_Mod>: Likewise.
<N_Op_Rem>: Likewise.
(convert_with_check): Report a violation of No_Dependence on
System.GCC for a conversion between an integer type larger than
a word and a floating-point type.
Steve Baird [Mon, 22 Aug 2022 22:25:28 +0000 (15:25 -0700)]
[Ada] Disable lock free protected implementation if target lacks support
Do not select a lock free implementation if Targparm.Support_Atomic_Primitives
is False (which indicates that the target cannot support it).
gcc/ada/
* sem_ch9.adb
(Allows_Lock_Free_Implementation): Return False if
Support_Atomic_Primitives is False.
Steve Baird [Sat, 13 Aug 2022 00:04:38 +0000 (17:04 -0700)]
[Ada] Enable lock free protected implementation by default
In the past, the Lock_Free aspect of a protected type (including an
anonymous type) defaulted to False. In the case where an explicit
"Lock_Free => True" aspect specification would be legal, the aspect now
defaults to True (which means that a lock-free implementation is used to
implement the type's protected operations); this is like the previous
behavior of the compiler with the -gnatd9 switch specified. Support for
the Lock_Free attribute (which should not be confused with the Lock_Free
aspect) is removed.
gcc/ada/
* debug.adb: Remove comment regarding the -gnatd9 switch.
* doc/gnat_rm/implementation_defined_attributes.rst: Remove all
mention of the Lock_Free attribute.
* gnat_rm.texi, gnat_ugn.texi: Regenerate.
* exp_attr.adb, sem_attr.adb: Remove all mention of the former
Attribute_Lock_Free enumeration element of the Attribute_Id type.
* sem_ch9.adb
(Allows_Lock_Free_Implementation): Remove the Debug_Flag_9 test.
Return False in the case of a protected function whose result type
requires use of the secondary stack.
(Satisfies_Lock_Free_Requirements): This functions checks for
certain constructs and returns False if one is found. In the case
of a protected function, there is no need to check to see if the
protected object is being modified. So it is ok to omit *some*
checks in the case of a protected function. But other checks which
are required (e.g., the test for a reference to a variable that is
not part of the protected object) were being incorrectly omitted.
This could result in accepting "Lock_Free => True" aspect
specifications that should be rejected.
* snames.adb-tmpl: Name_Lock_Free no longer requires special
treatment in Get_Pragma_Id or Is_Pragma_Name (because it is no
longer an attribute name).
* snames.ads-tmpl: Move the declaration of Name_Lock_Free to
reflect the fact that it is no longer the name of an attribute.
Delete Attribute_Lock_Free from the Attribute_Id enumeration type.
Steve Baird [Fri, 19 Aug 2022 17:26:29 +0000 (10:26 -0700)]
[Ada] Restore missing Aggregate aspect for Ada.Containers.Ordered_Sets.Set
Ada RM A.18.9 includes a specification of the Aggregate aspect for the type
Ada.Containers.Ordered_Sets. That aspect specification was deliberately
commented out in a-coorse.ads at one time, but that workaround is no longer
needed.
gcc/ada/
* libgnat/a-coorse.ads: Restore Aggregate aspect specification for
type Set.
Marc Poulhiès [Mon, 22 Aug 2022 08:25:09 +0000 (10:25 +0200)]
[Ada] Fix formal parameters list for secondary stack allocation procedure
The introduction of the Alignment parameter for the secondary stack
allocator in previous change was missing the corresponding change in the
Build_Allocate_Deallocate_Proc when creating the formal parameters list.
gcc/ada/
* exp_util.adb (Build_Allocate_Deallocate_Proc): Add
Alignment_Param in the formal list for calls to SS_Allocate.
Piotr Trojanek [Fri, 12 Aug 2022 09:33:20 +0000 (11:33 +0200)]
[Ada] Retain Has_Private_View flag for actuals of inlined subprograms
When instantiating a body to inline (either because frontend inlining is
enabled with switch -gnatN or because of inlining-for-proof in GNATprove
mode) we rewrite occurrences of formal parameters into the corresponding
actual parameters. Then we switch type views, so that if the formal had
a full view in the body to inline then the corresponding actual will
have a full view in the particular inlined body.
However, when rewriting occurrences of the formal parameter we were
losing information about whether the formal had a private view.
gcc/ada/
* inline.adb (Process_Formals): Preserve Has_Private_View flag while
rewriting formal into actual parameters.
Javier Miranda [Mon, 15 Aug 2022 16:54:40 +0000 (16:54 +0000)]
[Ada] Enforce matching of extra formals
This patch enforces matching of extra formals in overridden subprograms,
subprogram renamings, and subprograms to which attributes 'Access,
'Unchecked_Access, or 'Unrestricted_Access is applied (for these access
cases the subprogram is checked against its corresponding subprogram
type).
gcc/ada/
* debug.adb
(Debug_Flag_Underscore_X): Switch added temporarily to allow
disabling extra formal checks.
* exp_attr.adb
(Expand_N_Attribute_Reference [access types]): Add extra formals
to the subprogram referenced in the prefix of 'Unchecked_Access,
'Unrestricted_Access or 'Access; required to check that its extra
formals match the extra formals of the corresponding subprogram
type.
* exp_ch3.adb
(Stream_Operation_OK): Declaration moved to the public part of the
package.
(Validate_Tagged_Type_Extra_Formals): New subprogram.
(Expand_Freeze_Record_Type): Improve the code that takes care of
adding the extra formals of dispatching primitives; extended to
add also the extra formals to renamings of dispatching primitives.
* exp_ch3.ads
(Stream_Operation_OK): Declaration moved from the package body.
* exp_ch6.adb
(Has_BIP_Extra_Formal): Subprogram declaration moved to the public
part of the package. In addition, a parameter has been added to
disable an assertion that requires its use with frozen entities.
(Expand_Call_Helper): Enforce assertion checking extra formals on
thunks.
(Is_Build_In_Place_Function): Return False for entities with
foreign convention.
(Make_Build_In_Place_Call_In_Object_Declaration): Occurrences of
Is_Return_Object replaced by the local variable
Is_OK_Return_Object that evaluates to False for scopes with
foreign convention.
(Might_Have_Tasks): Fix check of class-wide limited record types.
(Needs_BIP_Task_Actuals): Remove assertion to allow calling this
function in more contexts; in addition it returns False for
functions returning objects with foreign convention.
(Needs_BIP_Finalization_Master): Likewise.
(Needs_BIP_Alloc_Form): Likewise.
* exp_ch6.ads
(Stream_Operation_OK): Declaration moved from the package body. In
addition, a parameter has been added to disable assertion that
requires its use with frozen entities.
* freeze.adb
(Check_Itype): Add extra formals to anonymous access subprogram
itypes.
(Freeze_Expression): Improve code that disables the addition of
extra formals to functions with foreign convention.
(Check_Extra_Formals): Moved to package Sem_Ch6 as
Extra_Formals_OK.
(Freeze_Subprogram): Add extra formals to non-dispatching
subprograms.
* sem_ch3.adb
(Access_Subprogram_Declaration): Defer the addition of extra
formals to the freezing point so that we know the convention.
(Check_Anonymous_Access_Component): Likewise.
(Derive_Subprogram): Fix documentation.
* sem_ch6.adb
(Check_Anonymous_Return): Fix check of access to class-wide
limited record types.
(Check_Untagged_Equality): Placed in alphabetical order.
(Extra_Formals_OK): Subprogram moved from freeze.adb.
(Extra_Formals_Match_OK): New subprogram.
(Has_BIP_Formals): New subprogram.
(Has_Extra_Formals): New subprograms.
(Needs_Accessibility_Check_Extra): New subprogram.
(Needs_Constrained_Extra): New subprogram.
(Parent_Subprogram): New subprogram.
(Add_Extra_Formal): Minor code cleanup.
(Create_Extra_Formals): Enforce matching extra formals on
overridden and aliased entities.
(Has_Reliable_Extra_Formals): New subprogram.
* sem_ch6.ads
(Extra_Formals_OK): Subprogram moved from freeze.adb.
(Extra_Formals_Match_OK): New subprogram.
* sem_eval.adb
(Compile_Time_Known_Value): Improve predicate to avoid assertion
failure; found working on this ticket; this change does not affect
the behavior of the compiler because this subprogram has an
exception handler that returns False when the assertion fails.
* sem_util.adb
(Needs_Result_Accessibility_Level): Do not return False for
dispatching operations compiled with Ada_Version < 2012 since they
they may be overridden by primitives compiled with Ada_Version >=
Ada_2012.
Arnaud Charlet [Fri, 19 Aug 2022 16:25:45 +0000 (16:25 +0000)]
[Ada] Disable if expression optimization for LLVM
gcc/ada/
* exp_ch4.adb (Expand_N_If_Expression): Disable optimization
for LLVM.
Javier Miranda [Mon, 15 Aug 2022 18:31:50 +0000 (18:31 +0000)]
[Ada] Report error in non-legal class-wide conditions
gcc/ada/
* sem_prag.adb
(Analyze_Pre_Post_Condition_In_Decl_Part): Improve check to report
an error in non-legal class-wide conditions.
Steve Baird [Mon, 15 Aug 2022 23:58:36 +0000 (16:58 -0700)]
[Ada] Slice length computation bug in Generic_Bounded_Length generics
In some cases involving null slices, the Slice subprograms (both the
function and the procedure) in each of the three Generic_Bounded_Length
generic packages (for String, Wide_String, and Wide_Wide_String)
could raise Constraint_Error in cases where this is incorrect.
gcc/ada/
* libgnat/a-strsup.adb, libgnat/a-stwisu.adb, libgnat/a-stzsup.adb
(Super_Slice function and procedure): fix slice length computation.
Steve Baird [Wed, 17 Aug 2022 17:13:55 +0000 (10:13 -0700)]
[Ada] Improve documentation of validation checking control switches
Correct incorrect text and clarify unclear text that has been identified
in the "Validity Checking" section of the GNAT UG.
gcc/ada/
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Improve -gnatVa, -gnatVc, -gnatVd, -gnatVe, -gnatVf, -gnatVo,
-gnatVp, -gnatVr, and -gnatVs switch descriptions.
* gnat_ugn.texi: Regenerate.
Justin Squirek [Thu, 18 Aug 2022 19:48:22 +0000 (19:48 +0000)]
[Ada] Handle new At_End expansion during unnesting
This patch modifies the marking of nested subprograms requiring static links,
so that the changes made to "At end" procedures get handled properly.
gcc/ada/
* exp_unst.adb
(Visit_Node): Add N_Block_Statement to the enclosing construct
case since they can now have "At end" procedures. Also, recognize
calls from "At end" procedures when recording subprograms.
Piotr Trojanek [Fri, 12 Aug 2022 10:15:53 +0000 (12:15 +0200)]
[Ada] Fix comment about mapping of parameters and inlining static funcs
Fix glitch in a cross-reference in comment.
gcc/ada/
* inline.adb (Replace_Formal): Fix name of the referenced routine.
Piotr Trojanek [Mon, 8 Aug 2022 14:18:38 +0000 (16:18 +0200)]
[Ada] Cleanup unnecessary shadowing in expansion of attribute Old
Code cleanup; semantics is unaffected.
gcc/ada/
* exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Old]):
Remove unnecessary local constant that was shadowing another
constant with the same initial value.
Julien Bortolussi [Thu, 4 Aug 2022 16:15:13 +0000 (18:15 +0200)]
[Ada] Fix a bug in the contract of formal ordered sets
There are 2 main issues in the postcondition of the function Replace
of the formal ordered sets, in the sub package Generic_Keys. One is
related to the fact that when the element is changed, the key is
also changed. The second one is due to the fact that the arrival of
the new element might modify the ordering of the set and thus
the Positions might be modified.
As a consequence, the postcondition might be false and thus fail
at runtime.
gcc/ada/
* libgnat/a-cforse.ads (Replace): Fix the postcondition.
Steve Baird [Wed, 10 Aug 2022 21:04:29 +0000 (14:04 -0700)]
[Ada] Cope with scalar subtypes that have a non-scalar basetype.
In some cases, the compiler builds a subtype entity Typ such that
Is_Scalar (Typ) is True and Is_Scalar (Base_Type (Typ)) is False.
This comes up in some cases involving a subtype of a private type,
where the full view of the private type is a scalar type. In such a
situation, it may also be the case that Is_Enumeration_Type (Typ) is True
and Is_Enumeration_Type (Base_Type (Typ)) is False. Some code incorrectly
assumed that if a subtype is known to be a scalar (respectively, enumeration)
type, then the same must be true of the base type of that subtype. Fix that
code to handle the case where that assumption does not hold.
gcc/ada/
* exp_attr.adb
(Attribute_Valid): Ensure that PBtyp is initialized to a value for
which Is_Scalar_Type is True.
* checks.adb
(Determine_Range): Call Implemention_Base_Type instead of
Base_Type in order to ensure that result is suitable for passing
to Enum_Pos_To_Rep.
Bob Duff [Mon, 8 Aug 2022 18:45:31 +0000 (14:45 -0400)]
[Ada] Place "at end" on body nodes
This patch fixes a bug where finalization code might refer to variables
outside their lifetime. The previous version moved declarations into the
Handled_Statement_Sequence (HSS), so that the "at end" handler of the
HSS could handle exceptions raised by those declarations. The
First_Real_Statement field was used to find the first statement after
the moved declarations. In addition, if the HSS already had exception
handlers, it was wrapped in another layer of block_statement. This
doesn't work if there are variable-sized objects allocated on the
(primary) stack, because the stack will be popped before the "at end" is
invoked.
In the new version, we allow "at end" on nodes such as
N_Subprogram_Body, in addition to HSS. We modify gigi so that such an
"at end" applies to the whole body (declarations and HSS) by extending
support for At_End_Proc mechanism to N_Block_Statement and N_*_Body
nodes. This also removes the support for First_Real_Statement. In
particular, an exception raised by the declarations will trigger the "at
end". We no longer move declarations into the HSS, we no longer have a
First_Real_Statement field, and we no longer do the wrapping mentioned
above.
This change requires various other changes, in cases where we depended
on the First_Real_Statement and the moving/wrapping mentioned above.
gcc/ada/
* gen_il-fields.ads
(First_Real_Statement): Remove this field.
* gen_il-gen-gen_nodes.adb: Remove the First_Real_Statement field.
Add the At_End_Proc field to nodes that have both Declarations and
HSS.
* sinfo.ads
(At_End_Proc): Document new semantics.
(First_Real_Statement): Remove comment.
* exp_ch11.adb
(Expand_N_Handled_Sequence_Of_Statements): Remove
First_Real_Statement.
* exp_ch7.adb
(Build_Cleanup_Statements): Remove "Historical note"; it doesn't
seem useful, and we have revision history.
(Create_Finalizer): Insert the finalizer later, typically in the
statement list, in some cases.
(Build_Finalizer_Call): Attach the "at end" handler to the parent
of the HSS node in most cases, so it applies to declarations.
(Expand_Cleanup_Actions): Remove Wrap_HSS_In_Block and the call to
it. Remove the code that moves declarations. Remove some redundant
code.
* exp_ch9.adb
(Build_Protected_Entry): Copy the At_End_Proc.
(Build_Protected_Subprogram_Body): Reverse the sense of Exc_Safe,
to avoid double negatives. Remove "Historical note" as in
exp_ch7.adb.
(Build_Unprotected_Subprogram_Body): Copy the At_End_Proc from the
protected version.
(Expand_N_Conditional_Entry_Call): Use First (Statements(...))
instead of First_Real_Statement(...).
(Expand_N_Task_Body): Put the Abort_Undefer call at the beginning
of the declarations, rather than in the HSS. Use First
(Statements(...)) instead of First_Real_Statement(...). Copy the
At_End_Proc.
* inline.adb
(Has_Initialized_Type): Return False if the declaration does not
come from source.
* libgnarl/s-tpoben.ads
(Lock_Entries, Lock_Entries_With_Status): Document when these
things raise Program_Error. It's not clear that
Lock_Entries_With_Status ought to be raising exceptions, but at
least it's documented now.
* sem.ads: Minor comment fixes.
* sem_ch6.adb
(Analyze_Subprogram_Body_Helper): Use First (Statements(...))
instead of First_Real_Statement(...).
(Analyze_Null_Procedure): Minor comment fix.
* sem_util.adb
(Might_Raise): Return True for N_Raise_Expression. Adjust the part
about exceptions generated by the back end to match the reality of
what the back end generates.
(Update_First_Real_Statement): Remove.
* sem_util.ads: Remove First_Real_Statement from comment.
* sinfo-utils.ads
(First_Real_Statement): New function that always returns Empty.
This should be removed once gnat-llvm and codepeer have been
updated to not refer to First_Real_Statement.
* sprint.adb
(Sprint_At_End_Proc): Deal with printing At_End_Proc.
* sem_prag.adb: Minor comment fixes.
* gcc-interface/trans.cc (At_End_Proc_to_gnu): New function.
(Subprogram_Body_to_gnu): Call it to handle an At_End_Proc.
(Handled_Sequence_Of_Statements_to_gnu): Likewise. Remove the
support for First_Real_Statement and clean up the rest.
(Exception_Handler_to_gnu): Do not push binding levels.
(Compilation_Unit_to_gnu): Adjust call to process_decls.
(gnat_to_gnu) <N_Package_Specification>: Likewise. <N_Entry_Body>:
Likewise. <N_Freeze_Entity>: Likewise. <N_Block_Statement>:
Likewise and call At_End_Proc_to_gnu to handle an At_End_Proc.
<N_Package_Body>: Likewise.
(process_decls): Remove GNAT_END_LIST parameter and adjust
recursive calls.
Co-authored-by: Eric Botcazou <ebotcazou@adacore.com>
Steve Baird [Tue, 9 Aug 2022 16:51:41 +0000 (09:51 -0700)]
[Ada] Document change to legality checks for Inox case statements
INOX (which is enabled via -gnatX) supports composite case-statement selectors.
As a temporary measure, simplify the coverage-related compile-time checks
for such case statements via two changes: an others choice is always
required for such a case statement, and no legality checks relating to
overlapping of case choices are performed.
gcc/ada/
* doc/gnat_rm/implementation_defined_pragmas.rst: Document new
temporary rule that a "when others =>" case choice must be given
when casing on a composite selector.
* gnat_rm.texi: Regenerate.
Steve Baird [Mon, 25 Jul 2022 23:03:10 +0000 (16:03 -0700)]
[Ada] Temporarily simplify legality checks for Inox case statements
INOX (which is enabled via -gnatX) supports composite case-statement selectors.
As a temporary measure, simplify the coverage-related compile-time checks
for such case statements via two changes: an others choice is always
required for such a case statement, and no legality checks relating to
overlapping of case choices are performed.
gcc/ada/
* sem_case.adb: Define a new Boolean constant,
Simplified_Composite_Coverage_Rules, initialized to True. Setting
this constant to True has two effects: 1- Representative value
sets are not fully initialized - this is done to avoid capacity
problems, as well as for performance. 2- In
Check_Case_Pattern_Choices, the only legality check performed is a
check that a "when others =>" choice is present.
Piotr Trojanek [Tue, 9 Aug 2022 13:09:53 +0000 (15:09 +0200)]
[Ada] Tune message for illegal aspect Relaxed_Initialization
Error message about illegal aspect Relaxed_Initialization was lacking a
whitespace character.
gcc/ada/
* sem_ch13.adb (Analyze_Aspect_Relaxed_Initialization): Fix error
template.
Steve Baird [Tue, 2 Aug 2022 00:04:20 +0000 (17:04 -0700)]
[Ada] Bad Valid_Scalars result if signed int component type signed has partial view.
For an object X of a composite type, the attribute X'Valid_Scalars should
return False if and only if there exists at least one invalid scalar
subcomponent of X. The validity test for a scalar part may include a
range test. In some cases involving a private type that is implemented as
a signed integer type, this range test was incorrectly implemented using
unsigned comparisons. For an enclosing object X, this could result in
X'Valid_Scalars yielding the wrong Boolean result. Such an incorrect
result would almost always be False, although an incorrect True result is
theoretically possible (this would require that both bounds of the
component subtype are negative and that the invalid component has a positive
value).
gcc/ada/
* exp_attr.adb
(Make_Range_Test): In determining which subtype's First and Last
attributes are to be queried as part of a range test, call
Validated_View in order to get a scalar (as opposed to private)
subtype.
(Attribute_Valid): In determining whether to perform a signed or
unsigned comparison for a range test, call Validated_View in order
to get a scalar (as opposed to private) type. Also correct a typo
which, by itself, is the source of the problem reported for this
ticket.
Steve Baird [Fri, 29 Jul 2022 22:54:19 +0000 (15:54 -0700)]
[Ada] ICE handling discriminant-dependent index constraint for access component
The compiler would fail with an internal error in some cases involving
a discriminated record type that provides a discriminant-dependent index
constraint for the subtype of a component of an access-to-array type when a
dereference of that component of some object is mentioned in a pre- or
postcondition expression.
gcc/ada/
* sem_ch4.adb
(Analyze_Selected_Component): Define new Boolean-valued function,
Constraint_Has_Unprefixed_Discriminant_Reference, which takes a
subtype that is subject to a discriminant-dependent constraint and
returns True if any of the constraint values are unprefixed
discriminant names. Usually, the Etype of a selected component
node is set to Etype of the component. However, in the case of an
access-to-array component for which this predicate returns True,
we instead use the base type of the Etype of the component.
Normally such problematic discriminant references are addressed by
calling Build_Actual_Subtype_Of_Component, but that doesn't work
if Full_Analyze is False.
Piotr Trojanek [Mon, 8 Aug 2022 10:32:12 +0000 (12:32 +0200)]
[Ada] Add formal verification dependencies to libgnat
Spec units for verification of the GNAT standard library with GNATprove
must be listed as part of the libgnat package, as otherwise libadalang
will complain about missing dependencies.
gcc/ada/
* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Include
System.Value_U_Spec and System.Value_I_Spec units.
Eric Botcazou [Fri, 5 Aug 2022 07:42:58 +0000 (09:42 +0200)]
[Ada] Correctly round Value attribute for floating point in more cases
This provides correct rounding in the IEEE 754 sense for the Value attribute
of floating-point types in more cases, by switching from tables of powers of
10 to tables of powers of 5 for precomputed values, thus making it possible
to use a single divide for denormals and normalized numbers just above them.
Although this significantly increases the size of the tables, object files
for them are still quite small (1, 2 and 4 KB respectively on x86-64).
gcc/ada/
* libgnat/s-powflt.ads (Powfive): New constant array.
* libgnat/s-powlfl.ads (Powfive): Likewise.
(Powfive_100): New constant.
(Powfive_200): Likewise.
(Powfive_300): Likewise.
* libgnat/s-powllf.ads (Powfive): New constant array.
(Powfive_100): New constant.
(Powfive_200): Likewise.
(Powfive_300): Likewise.
* libgnat/s-valflt.ads (Impl): Replace Powten with Powfive and pass
Null_Address for the address of large constants.
* libgnat/s-vallfl.ads (Impl): Replace Powten with Powfive and pass
the address of large constants.
* libgnat/s-valllf.ads (Impl): Likewise.
* libgnat/s-valrea.ads (System.Val_Real): Replace Powten_Address
with Powfive_Address and add Powfive_{1,2,3}00_Address parameters.
* libgnat/s-valrea.adb (Is_Large_Type): New boolean constant.
(Is_Very_Large_Type): Likewise.
(Maxexp32): Change value of 10 to that of 5.
(Maxexp64): Likewise.
(Maxexp80): Likewise.
(Integer_to_Real): Use a combination of tables of powers of 5 and
scaling if the base is 10.
(Large_Powten): Rename into...
(Large_Powfive): ...this. Add support for large constants.
(Large_Powfive): New overloaded function for very large exponents.
Piotr Trojanek [Fri, 5 Aug 2022 14:31:19 +0000 (16:31 +0200)]
[Ada] Improve detection of illegal Iterable aspects
Handling of aspect Iterable was lacking guards against illegal code, so
the compiler either crashed or emitted cryptic errors while expanding
loops that rely on this aspect.
gcc/ada/
* doc/gnat_rm/implementation_defined_aspects.rst
(Aspect Iterable): Include Last and Previous primitives in
syntactic and semantic description.
* exp_attr.adb
(Expand_N_Attribute_Reference): Don't expect attributes like
Iterable that can only appear in attribute definition clauses.
* sem_ch13.adb
(Analyze_Attribute_Definition_Clause): Prevent crash on
non-aggregate Iterable attribute; improve basic diagnosis of
attribute values.
(Resolve_Iterable_Operation): Improve checks for illegal
primitives in aspect Iterable, e.g. with wrong number of formal
parameters.
(Validate_Iterable_Aspect): Prevent crashes on syntactically
illegal aspect expression.
* sem_util.adb
(Get_Cursor_Type): Fix style.
* gnat_ugn.texi, gnat_rm.texi: Regenerate.
Eric Botcazou [Mon, 1 Aug 2022 21:10:40 +0000 (23:10 +0200)]
[Ada] Correctly round Value attribute for floating point in more cases
This provides correct rounding in the IEEE 754 sense for the Value attribute
of floating-point types in more cases, by bumping the number of significant
bits used in the initial integer mantissa obtained from parsing.
gcc/ada/
* libgnat/s-valuer.ads (System.Value_R): Add Parts formal parameter
as well as Data_Index, Scale_Array and Value_Array types.
(Scan_Raw_Real): Change type of Scale and return type.
(Value_Raw_Real): Likewise.
* libgnat/s-valuer.adb (Round_Extra): Reorder parameters and adjust
recursive call.
(Scan_Decimal_Digits): Reorder parameters, add N parameter and deal
with multi-part scale and value.
(Scan_Integral_Digits): Likewise.
(Scan_Raw_Real): Change type of Scale and return type and deal with
multi-part scale and value.
(Value_Raw_Real): Change type of Scale and return type and tidy up.
* libgnat/s-valued.adb (Impl): Pass 1 as Parts actual parameter.
(Scan_Decimal): Adjust to type changes.
(Value_Decimal): Likewise.
* libgnat/s-valuef.adb (Impl): Pass 1 as Parts actual parameter.
(Scan_Fixed): Adjust to type changes.
(Value_Fixed): Likewise.
* libgnat/s-valrea.adb (Need_Extra): Delete.
(Precision_Limit): Always use the precision of the mantissa.
(Impl): Pass 2 as Parts actual parameter.
(Exact_Log2): New expression function.
(Integer_to_Real): Change type of Scale and Val and deal with a
2-part integer mantissa.
(Scan_Real): Adjust to type changes.
(Value_Real): Likewise.
Xianmiao Qu [Tue, 6 Sep 2022 07:10:36 +0000 (15:10 +0800)]
C-SKY: Fix missing operand when do spilt for cskyv2_addcc and cskyv2_addcc_invert.
It will cause ICE when compiling the case:
gcc/testsuite/gcc.dg/params/blocksort-part.c
gcc/
* config/csky/csky.md (cskyv2_addcc): Fix missing operand.
(cskyv2_addcc_invert): Likewise.