Commit Graph

192685 Commits

Author SHA1 Message Date
Jakub Jelinek
9715f10c06 asan: Fix up asan_redzone_buffer::emit_redzone_byte [PR105396]
On the following testcase, we have in main's frame 3 variables,
some red zone padding, 4 byte d, followed by 12 bytes of red zone padding, then
8 byte b followed by 24 bytes of red zone padding, then 40 bytes c followed
by some red zone padding.
The intended content of shadow memory for that is (note, each byte describes
8 bytes of memory):
f1 f1 f1 f1 04 f2 00 f2 f2 f2 00 00 00 00 00 f3 f3 f3 f3 f3
left red    d  mr b  middle r c              right red zone

f1 is left red zone magic
f2 is middle red zone magic
f3 is right red zone magic
00 when all 8 bytes are accessible
01-07 when only 1 to 7 bytes are accessible followed by inaccessible bytes

The -fdump-rtl-expand-details dump makes it clear that it misbehaves:
Flushing rzbuffer at offset -160 with: f1 f1 f1 f1
Flushing rzbuffer at offset -128 with: 04 f2 00 00
Flushing rzbuffer at offset -128 with: 00 00 00 f2
Flushing rzbuffer at offset -96 with: f2 f2 00 00
Flushing rzbuffer at offset -64 with: 00 00 00 f3
Flushing rzbuffer at offset -32 with: f3 f3 f3 f3
In the end we end up with
f1 f1 f1 f1 00 00 00 f2 f2 f2 00 00 00 00 00 f3 f3 f3 f3 f3
shadow bytes because at offset -128 there are 2 overlapping stores
as asan_redzone_buffer::emit_redzone_byte has flushed the temporary 4 byte
buffer in the middle.

The function is called with an offset and value.  If the passed offset is
consecutive with the prev_offset + buffer size (off == offset), then
we handle it correctly, similarly if the new offset is far enough from the
old one (we then flush whatever was in the buffer and if needed add up to 3
bytes of 00 before actually pushing value.

But what isn't handled correctly is when the offset isn't consecutive to
what has been added last time, but it is in the same 4 byte word of shadow
memory (32 bytes of actual memory), like the above case where
we have consecutive 04 f2 and then skip one shadow memory byte (aka 8 bytes
of real memory) and then want to emit f2.  Emitting that as a store
of little-endian 0x0000f204 followed by a store of 0xf2000000 to the same
address doesn't work, we want to emit 0xf200f204.

The following patch does that by pushing 1 or 2 00 bytes.
Additionally, as a small cleanup, instead of using
      m_shadow_bytes.safe_push (value);
      flush_if_full ();
in all of if, else if and else bodies it sinks those 2 stmts to the end
of function as all do the same thing.

2022-04-27  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/105396
	* asan.cc (asan_redzone_buffer::emit_redzone_byte): Handle the case
	where offset is bigger than off but smaller than m_prev_offset + 32
	bits by pushing one or more 0 bytes.  Sink the
	m_shadow_bytes.safe_push (value); flush_if_full (); statements from
	all cases to the end of the function.

	* gcc.dg/asan/pr105396.c: New test.
2022-04-27 08:34:18 +02:00
Kewen Lin
39d2411c78 rs6000: Move V2DI vec_neg under power8-vector [PR105271]
As PR105271 shows, __builtin_altivec_neg_v2di requires option
-mpower8-vector as its pattern expansion relies on subv2di which
has guard VECTOR_UNIT_P8_VECTOR_P (V2DImode).  This fix is to move
the related lines for __builtin_altivec_neg_v2di to the section
of stanza power8-vector.

	PR target/105271

gcc/ChangeLog:

	* config/rs6000/rs6000-builtins.def (NEG_V2DI): Move to [power8-vector]
	stanza.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr105271.c: New test.
2022-04-26 20:41:16 -05:00
GCC Administrator
01ad093b5f Daily bump. 2022-04-27 00:16:46 +00:00
Jason Merrill
9ace5d4dab c++: pack init-capture of unresolved overload [PR102629]
Here we were failing to diagnose that the initializer for the capture pack
is an unresolved overload.  It turns out that the reason we didn't recognize
the deduction failure in do_auto_deduction was that the individual 'auto' in
the expansion of the capture pack was still marked as a parameter pack, so
we were deducing it to an empty pack instead of failing.

	PR c++/102629

gcc/cp/ChangeLog:

	* pt.cc (gen_elem_of_pack_expansion_instantiation): Clear
	TEMPLATE_TYPE_PARAMETER_PACK on auto.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-pack-init7.C: New test.
2022-04-26 16:12:08 -04:00
Thomas Schwinge
2579d6124d GCN: Make "gang-private data-share memory exhausted" error more verbose
[...]: error: 512 bytes of gang-private data-share memory exhausted (increase with ‘-mgang-private-size=560’, for example)

	gcc/
	* config/gcn/gcn.cc (gcn_print_lds_decl): Make "gang-private
	data-share memory exhausted" error more verbose.
2022-04-26 21:31:28 +02:00
Joseph Myers
b683a0e635 Update gcc sv.po
* sv.po: Update.
2022-04-26 18:58:10 +00:00
Patrick Palka
b6a48401da c++: decltype of non-dependent call of class type [PR105386]
We need to pass tf_decltype when instantiating a non-dependent decltype
operand, like tsubst does in the dependent case, so that we don't force
completion of a prvalue operand's class type.

	PR c++/105386

gcc/cp/ChangeLog:

	* semantics.cc (finish_decltype_type): Pass tf_decltype to
	instantiate_non_dependent_expr_sfinae.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/decltype81.C: New test.
2022-04-26 10:53:38 -04:00
Martin Liska
cd4acb8cd9 lto: use diagnostics_context in print_lto_docs_link
Properly parse OPT_fdiagnostics_urls_ and then initialize both urls
and colors for global_dc. Doing that we would follow the configure
option --with-documentation-root-url, -fdiagnostics-urls is respected.
Plus we'll print colored warning and note messages.

	PR lto/105364

gcc/ChangeLog:

	* lto-wrapper.cc (print_lto_docs_link): Use global_dc.
	(run_gcc): Parse OPT_fdiagnostics_urls_.
	(main): Initialize global_dc.
2022-04-26 15:46:52 +02:00
Iain Buclaw
796b7cbac3 libphobos: Don't call free on the TLS array in the emutls destroy function.
Fixes a segfault seen on Darwin when a GC scan is ran after a thread has
been destroyed.  As the global emutlsArrays hash still has a reference
to the array itself, and tries to iterate all elements.

Setting the length to zero frees all allocated elements in the array,
and ensures that it is skipped when the _d_emutls_scan is called.

libphobos/ChangeLog:

	* libdruntime/gcc/emutls.d (emutlsDestroyThread): Clear the per-thread
	TLS array, don't call free().
2022-04-26 14:32:11 +01:00
Jonathan Wakely
41ccd683f0 libstdc++: Add std::atomic<shared_ptr>(nullptr_t) constructor (LWG 3661)
This DR was approved at the February 2022 plenary.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (atomic<shared_ptr>): Add
	constructor for constant initialization from nullptr_t.
	* testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc:
	Check for new constructor.
2022-04-26 13:22:18 +01:00
Jonathan Wakely
e3c5e8360b libstdc++: Define std::hash<std::filesystem::path> (LWG 3657)
This DR was approved at the February 2022 plenary.

libstdc++-v3/ChangeLog:

	* include/bits/fs_path.h (hash<filesystem::path>): Define.
	* testsuite/27_io/filesystem/path/nonmember/hash_value.cc:
	Check std::hash specialization.
2022-04-26 13:22:18 +01:00
Segher Boessenkool
ad56a60f58 rs6000: Make the has_arch target selectors actually work
2022-04-26  Segher Boessenkoool  <segher@kernel.crashing.org>

gcc/testsuite/
	PR target/105349
	* lib/target-supports.exp (check_effective_target_has_arch_pwr5): Use
	the specified dg-options.
	(check_effective_target_has_arch_pwr6): Ditto.
	(check_effective_target_has_arch_pwr7): Ditto.
	(check_effective_target_has_arch_pwr8): Ditto.
	(check_effective_target_has_arch_pwr9): Ditto.
	(check_effective_target_has_arch_pwr10): Ditto.
	(check_effective_target_has_arch_ppc64): Ditto.
2022-04-26 11:31:31 +00:00
Jakub Jelinek
7d31c678d6 ifcvt: Improve noce_try_store_flag_mask [PR105314]
The following testcase regressed on riscv due to the splitting of critical
edges in the sink pass, similarly to x86_64 compared to GCC 11 we now swap
the edges, whether true or false edge goes to an empty forwarded bb.
From GIMPLE POV, those 2 forms are equivalent, but as can be seen here, for
some ifcvt opts it matters one way or another.

On this testcase, noce_try_store_flag_mask used to trigger and transformed
if (pseudo2) pseudo1 = 0;
into
pseudo1 &= -(pseudo2 == 0);
But with the swapped edges ifcvt actually sees
if (!pseudo2) pseudo3 = pseudo1; else pseudo3 = 0;
and noce_try_store_flag_mask punts.  IMHO there is no reason why it
should punt those, it is equivalent to
pseudo3 = pseudo1 & -(pseudo2 == 0);
and especially if the target has 3 operand AND, it shouldn't be any more
costly (and even with 2 operand AND, it might very well happen that RA
can make it happen without any extra moves).

Initially I've just removed the rtx_equal_p calls from the conditions
and didn't add anything there, but that broke aarch64 bootstrap and
regressed some testcases on x86_64, where if_info->a or if_info->b could be
some larger expression that we can't force into a register.
Furthermore, the case where both if_info->a and if_info->b are constants is
better handled by other ifcvt optimizations like noce_try_store_flag
or noce_try_inverse_constants or noce_try_store_flag_constants.
So, I've restricted it to just a REG (perhaps SUBREG of REG might be ok too)
next to what has been handled previously.

2022-04-26  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/105314
	* ifcvt.cc (noce_try_store_flag_mask): Don't require that the non-zero
	operand is equal to if_info->x, instead use the non-zero operand
	as one of the operands of AND with if_info->x as target.

	* gcc.target/riscv/pr105314.c: New test.
2022-04-26 10:11:58 +02:00
Jakub Jelinek
d4836ac9ac reassoc: Don't call fold_convert if !fold_convertible_p [PR105374]
As mentioned in the PR, we ICE because maybe_fold_*_comparisons returns
an expression with V4SImode type and we try to fold_convert it to
V4BImode, which isn't allowed.

IMHO no matter whether we change maybe_fold_*_comparisons we should
play safe on the reassoc side and punt if we can't convert like
we punt for many other reasons.  This fixes the testcase on ARM.

Testcase not included, not exactly sure where and what directives it
should have in gcc.target/arm/ testsuite.  Christophe, do you think you
could handle that incrementally?

2022-04-26  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/105374
	* tree-ssa-reassoc.cc (eliminate_redundant_comparison): Punt if
	!fold_convertible_p rather than assuming fold_convert must succeed.
2022-04-26 09:57:34 +02:00
Jakub Jelinek
1b45ae16ff testsuite: Fix up g++.target/i386/vec-tmpl1.C testcase [PR65211]
This test fails on i686-linux:
Excess errors:
.../gcc/testsuite/g++.target/i386/vec-tmpl1.C:13:27: warning: SSE vector return without SSE enabled changes the ABI [-Wpsabi]

2022-04-26  Jakub Jelinek  <jakub@redhat.com>

	PR c++/65211
	* g++.target/i386/vec-tmpl1.C: Add -Wno-psabi as
	dg-additional-options.
2022-04-26 09:54:43 +02:00
Jakub Jelinek
5face32b7f i386: Fix up ICE with -mveclibabi={acml,svml} [PR105367]
The following testcase ICEs, because conversion between scalar float types
which have the same mode are useless in GIMPLE, but for mathfn_built_in the
exact type matters (it treats say double and _Float64 or float and _Float32
differently, using different suffixes and for the _Float* sometimes
returning NULL when float/double do have a builtin).

In ix86_veclibabi_{svml,acml} we are using mathfn_built_in just so that
we don't have to translate the combined_fn and SFmode vs. DFmode into
strings ourselfs, and we already earlier punt on anything but SFmode and
DFmode.  So, this patch just uses the double or float types depending
on the modes, rather than the types we actually got and which might be
_Float64 or _Float32 etc.

2022-04-26  Jakub Jelinek  <jakub@redhat.com>

	PR target/105367
	* config/i386/i386.cc (ix86_veclibabi_svml, ix86_veclibabi_acml): Pass
	el_mode == DFmode ? double_type_node : float_type_node instead of
	TREE_TYPE (type_in) as first arguments to mathfn_built_in.

	* gcc.target/i386/pr105367.c: New test.
2022-04-26 09:40:03 +02:00
Jakub Jelinek
22c24ba48a testsuite: Improve unlimited_polymorphic_3.f03 [PR103662]
On Mon, Apr 25, 2022 at 01:38:25PM +0200, Mikael Morin wrote:
> I have just pushed the attached fix for two UNRESOLVED checks at -O0 that I
> hadn’t seen.

I don't like forcing of DSE in -O0 compilation, wouldn't it be better
to just not check the dse dump at -O0 like in the following patch?

Even better would be to check that the z._data = stores are both present
in *.optimized dump, but that doesn't really work at -O2 or above because
we inline the functions and optimize it completely away (both the stores
and corresponding reads).

The first hunk is needed so that __OPTIMIZE__ effective target works in
Fortran testsuite, otherwise one gets a pedantic error and __OPTIMIZE__
is considered not to match at all.

2022-04-26  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/103662
	* lib/target-supports.exp (check_effective_target___OPTIMIZE__): Add
	a var definition to avoid pedwarn about empty translation unit.
	* gfortran.dg/unlimited_polymorphic_3.f03: Remove -ftree-dse from
	dg-additional-options, guard scan-tree-dump-not directives on
	__OPTIMIZE__ target.
2022-04-26 09:17:32 +02:00
Jakub Jelinek
57a957cb71 libgomp: Fix up two non-GOMP_USE_ALIGNED_WORK_SHARES related issues [PR105358]
Last fall I've changed struct gomp_work_share, so that it doesn't have
__attribute__((aligned (64))) lock member in the middle unless the target has
non-emulated aligned allocator, otherwise it just makes sure the first and
second halves are 64 bytes appart for cache line reasons, but doesn't make
the struct 64-byte aligned itself and so we can use normal allocators for it.

When the struct isn't 64-byte aligned, the amount of tail padding significantly
decreases, to 0 or 4 bytes or so.  The library uses that tail padding when
the ordered_teams_ids array (array of uints) and/or the memory for lastprivate
conditional temporaries (the latter wants to guarantee long long alignment).
The problem with it on ia32 darwin9 is that while the struct contains
long long members, long long is just 4 byte aligned while __alignof__(long long)
is 8.  That causes problems in gomp_init_work_share, where we currently rely on
if offsetof (struct gomp_work_share, inline_ordered_team_ids) is long long
aligned, then that tail array will be aligned at runtime and so no extra
memory for dynamic realignment will be needed (that is false when the whole
struct doesn't have long long alignment).  And also in the remaining hunks
causes another problem, where we compute INLINE_ORDERED_TEAM_IDS_OFF
as the above offsetof aligned up to long long boundary and subtract
sizeof (struct gomp_work_share) and INLINE_ORDERED_TEAM_IDS_OFF.
When unlucky, the former isn't multiple of 8 and the latter is 4 bigger
than that and as the subtraction is done in size_t, we end up with (size_t) -4,
so the comparison doesn't really work.

The fixes add additional conditions to make it work properly, but all of them
should be evaluated at compile time when optimizing and so shouldn't slow
anything.

2022-04-26  Jakub Jelinek  <jakub@redhat.com>

	PR libgomp/105358
	* work.c (gomp_init_work_share): Don't mask of adjustment for
	dynamic long long realignment if struct gomp_work_share has smaller
	alignof than long long.
	* loop.c (GOMP_loop_start): Don't use inline_ordered_team_ids if
	struct gomp_work_share has smaller alignof than long long or if
	sizeof (struct gomp_work_share) is smaller than
	INLINE_ORDERED_TEAM_IDS_OFF.
	* loop_ull.c (GOMP_loop_ull_start): Likewise.
	* sections.c (GOMP_sections2_start): Likewise.
2022-04-26 08:57:17 +02:00
Jason Merrill
65735d21ac c++: generic lambda fn parm pack [PR104624]
Parameter packs from the enclosing context can be used unexpanded in a
lambda that is itself part of a pack expansion, but not packs that are part
of the lambda itself.  We already check for capture packs; we also need to
check for function parameter packs of the lambda call operator.

	PR c++/104624

gcc/cp/ChangeLog:

	* pt.cc (check_for_bare_parameter_packs): Check for lambda
	function parameter pack.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/lambda-generic-variadic22.C: New test.
2022-04-25 23:54:02 -04:00
Patrick Palka
c83b9c54d9 c++: ICE with requires-expr and -Wsequence-point [PR105304]
Here we're crashing from verify_sequence_points for this requires-expr
condition because it contains a templated CAST_EXPR with empty operand,
and verify_tree doesn't ignore this empty operand only because the
manual tail recursion that it performs for unary expression trees skips
the NULL test.

	PR c++/105304

gcc/c-family/ChangeLog:

	* c-common.cc (verify_tree) [restart]: Move up to before the
	NULL test.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-requires30.C: New test.
2022-04-25 21:49:00 -04:00
Patrick Palka
288e4c64f6 c++: partial ordering with dependent NTTP type [PR105289]
Here ever since r11-6483-ge2e2f3f2c9400f we're rejecting and crashing
on (respectively) two testcases that we used to accept in C++17 mode
since r8-1437-g3da557ec145823.  Both testcases declare a partial
specialization of a primary template that has an NTTP with dependent
type, and the validity of these partial specializations is unclear and
the subject of PR86193 / CWG 455.

So for now, this minimal patch just aims to fix the crash in the second
testcase.  During deduction, when checking whether the type of an NTTP
uses still-undeduced parameters, we were incorrectly substituting into
the previously substituted type instead of into its original type.

In passing this patch also downgrades the "not more specialized"
diagnostic from a permerror to a pedwarn.

	PR c++/105289
	PR c++/86193

gcc/cp/ChangeLog:

	* pt.cc (process_partial_specialization): Downgrade "partial
	specialization isn't more specialized" diagnostic from permerror
	to an on-by-default pedwarn.
	(unify) <case TEMPLATE_PARM_INDEX>: When substituting into the
	NTTP type a second time, use the original type not the
	substituted type.

gcc/testsuite/ChangeLog:

	* g++.dg/template/partial-specialization11.C: New test.
	* g++.dg/template/partial-specialization12.C: New test.
2022-04-25 21:46:56 -04:00
GCC Administrator
98de0da603 Daily bump. 2022-04-26 00:16:51 +00:00
David Malcolm
6ad3ca0077 analyzer: fix ICEs on complex constants [PR105365,105366]
gcc/analyzer/ChangeLog:
	PR analyzer/105365
	PR analyzer/105366
	* svalue.cc
	(cmp_cst): Rename to...
	(cmp_csts_same_type): ...this.  Convert all recursive calls to
	calls to...
	(cmp_csts_and_types): ....this new function.
	(svalue::cmp_ptr): Update for renaming of cmp_cst

gcc/testsuite/ChangeLog:
	PR analyzer/105365
	PR analyzer/105366
	* gcc.dg/analyzer/pr105365.c: New test.
	* gcc.dg/analyzer/pr105366.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-04-25 19:36:37 -04:00
David Malcolm
a5dc2641ad gimple-fold: fix further missing stmt locations [PR104308]
PR analyzer/104308 initially reported about a
-Wanalyzer-use-of-uninitialized-value diagnostic using UNKNOWN_LOCATION
when complaining about certain memmove operations where the source
is uninitialized.

In r12-7856-g875342766d4298 I fixed the missing location for
a stmt generated by gimple_fold_builtin_memory_op, but the reporter
then found another way to generate such a stmt with UNKNOWN_LOCATION.

I've now gone through gimple_fold_builtin_memory_op looking at all
statement creation, and found three places in which a new statement
doesn't have a location set on it (either directly via
gimple_set_location, or indirectly via gsi_replace), one of which is
the new reproducer.

This patch adds a gimple_set_location to these three cases, and adds
test coverage for one of them (the third hunk within the patch), fixing
the new reproducer for PR analyzer/104308.

gcc/ChangeLog:
	PR analyzer/104308
	* gimple-fold.cc (gimple_fold_builtin_memory_op): Explicitly set
	the location of new_stmt in all places that don't already set it,
	whether explicitly, or via a call to gsi_replace.

gcc/testsuite/ChangeLog:
	PR analyzer/104308
	* gcc.dg/analyzer/pr104308.c: Add test coverage.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-04-25 19:34:33 -04:00
Jakub Jelinek
b220243191 fortran: Fix up gfc_trans_oacc_construct [PR104717]
So that move_sese_region_to_fn works properly, OpenMP/OpenACC constructs
for which that function is invoked need an extra artificial BIND_EXPR
around their body so that we move all variables of the bodies.

The C/C++ FEs do that both for OpenMP constructs like OMP_PARALLEL, OMP_TASK
or OMP_TARGET and for OpenACC constructs that behave similarly to
OMP_TARGET, but the Fortran FE only does that for OpenMP constructs.

The following patch does that for OpenACC constructs too.

	PR fortran/104717
	gcc/fortran/
	* trans-openmp.cc (gfc_trans_oacc_construct): Wrap construct body
	in an extra BIND_EXPR.
	gcc/testsuite/
	* gfortran.dg/goacc/pr104717.f90: New test.
	* gfortran.dg/goacc/privatization-1-compute-loop.f90: Adjust.
	libgomp/
	* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Adjust.

Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
2022-04-25 23:14:02 +02:00
Martin Liska
68fd1c9f22 contrib: filter out a new Clang warning
Filter out:
libcpp/lex.cc:1289:7: warning: use of the 'likely' attribute is a C++20 extension [-Wc++20-attribute-extensions]

contrib/ChangeLog:

	* filter-clang-warnings.py: Filter out
	-Wc++20-attribute-extensions in lex.cc.
2022-04-25 22:26:55 +02:00
Jonathan Wakely
2fbdcf5e58 libstdc++: Implement constexpr std::unique_ptr for C++23 (P2273R3)
libstdc++-v3/ChangeLog:

	* include/bits/ptr_traits.h (__cpp_lib_constexpr_memory): Define
	conditionally.
	* include/bits/unique_ptr.h (__cpp_lib_constexpr_memory):
	Define for C++23.
	(default_delete, default_delete<T[]>, __uniq_ptr_impl)
	(unique_ptr, unique_ptr<T[], D>): Add constexpr to all member
	functions.
	* include/std/version (__cpp_lib_constexpr_memory): Define new
	value for C++23.
	* testsuite/20_util/unique_ptr/assign/constexpr.cc: New test.
	* testsuite/20_util/unique_ptr/comparison/constexpr.cc: New test.
	* testsuite/20_util/unique_ptr/cons/constexpr_c++20.cc: New test.
	* testsuite/20_util/unique_ptr/creation/constexpr.cc: New test.
	* testsuite/20_util/unique_ptr/modifiers/constexpr.cc: New test.
	* testsuite/20_util/unique_ptr/specialized_algorithms/constexpr.cc:
	New test.
2022-04-25 16:16:33 +01:00
Jonathan Wakely
a5cee0480c libstdc++: Add deduction guides for std::packaged_task [PR105375]
This change was LWG 3117.

The test is copied from 20_util/function/cons/deduction.cc

libstdc++-v3/ChangeLog:

	PR libstdc++/105375
	* include/std/future (packaged_task): Add deduction guides.
	* testsuite/30_threads/packaged_task/cons/deduction.cc: New test.
2022-04-25 16:16:33 +01:00
Marek Polacek
1ba397e9f9 c++: __builtin_shufflevector with value-dep expr [PR105353]
Here we issue an error from c_build_shufflevector while parsing a template
because it got a TEMPLATE_PARM_INDEX, but this function expects INTEGER_CSTs
(except the first two arguments).  It checks if any of the arguments are
type-dependent, if so, we leave the processing for later, but it should
also check value-dependency for the 3rd+ arguments, so as to avoid the
problem above.

This is not a regression -- __builtin_shufflevector was introduced in
GCC 12, but it looks safe enough.

	PR c++/105353

gcc/cp/ChangeLog:

	* typeck.cc (build_x_shufflevector): Use
	instantiation_dependent_expression_p except for the first two
	arguments.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/builtin-shufflevector-3.C: New test.
2022-04-25 11:15:51 -04:00
Paul A. Clarke
235f88dbc3 docs: Fix 'modff' reference in extend.texi
In commit a2a919aa50 (2003), built-ins for modf and modff were added.
In extend.texi, section "Other Builtins", "modf" was added to the paragraph
"There are also built-in versions of the ISO C99 functions [...]" and
"modf" was also added to the paragraph "The ISO C90 functions [...]".
"modff" was not added to either paragraph.

Based on the context clues about where "modfl" and other similar function
pairs like "powf/powl" appear, I believe the reference to "modf" in the
first paragraph (C99) should instead be "modff".

2022-04-25  Paul A. Clarke  <pc@us.ibm.com>

gcc
	* doc/extend.texi (Other Builtins): Correct reference to 'modff'.
2022-04-25 09:49:24 -05:00
Andrew MacLeod
362e2a9c62 Retain existing range knowledge when prefilling statements.
When range_of_stmt was adjusted to avoid large recursion depth, we need to
intersect the calculated range whth the any known range to avoid losing
info.  Range_of_stmt does this, but the new prefill code missed it.

	PR tree-optimization/105276
	gcc/
	* gimple-range.cc (gimple_ranger::prefill_stmt_dependencies): Include
	existing global range with calculated value.

	gcc/testsuite/
	* g++.dg/pr105276.C: New.
2022-04-25 09:58:53 -04:00
Martin Liska
46cd445fc0 contrib: filter out a new Clang warning
contrib/ChangeLog:

	* filter-clang-warnings.py: Filter out
	-Wbitwise-instead-of-logical.
2022-04-25 15:42:09 +02:00
Philipp Fent
71999fde2a libstdc++: Add pretty printer for std::initializer_list
Re-using the std::span printer, this now shows the contents of the
initializer list instead of the pointer and length members.

Signed-off-by: Philipp Fent <fent@in.tum.de>

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdSpanPrinter._iterator):
	Rename as iterator.
	(StdInitializerListPrinter): Define new printer.
	(build_libstdcxx_dictionary): Register new printer.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Check printer for
	initializer_list.
2022-04-25 13:32:04 +01:00
Mikael Morin
6cc26f3037 testsuite: add additional option to force DSE execution [PR103662]
This fixes a dump tree match check that is UNRESOLVED with the -O0
optimization option, as the optimization pass corresponding to the
dump file is not run at -O0, and the dump is not generated.

	PR fortran/103662

gcc/testsuite/ChangeLog:

	* gfortran.dg/unlimited_polymorphic_3.f03: Force execution of
	the DSE optimization pass.
2022-04-25 13:26:18 +02:00
Richard Biener
f0e170f72f tree-optimization/105368 - avoid overflow in powi_cost
The following avoids undefined signed overflow when computing
the absolute of the exponent in powi_cost.

2022-04-25  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/105368
	* tree-ssa-math-opts.cc (powi_cost): Use absu_hwi.
2022-04-25 11:46:59 +02:00
Richard Biener
ab91c10792 tree-optimization/100810 - avoid undefs in IVOPT rewrites
The following attempts to avoid IVOPTs rewriting uses using
IV candidates that involve undefined behavior by using uninitialized
SSA names.  First we restrict the set of candidates we produce
for such IVs to the original ones and mark them as not important.
Second we try to only allow expressing uses with such IV if they
originally use them.  That is to avoid rewriting all such uses
in terms of other IVs.  Since cand->iv and use->iv seem to never
exactly match up we resort to comparing the IV bases.

The approach ends up similar to the one posted by Roger at
https://gcc.gnu.org/pipermail/gcc-patches/2021-August/578441.html
but it marks IV candidates rather than use groups and the cases
we allow in determine_group_iv_cost_generic are slightly different.

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

	PR tree-optimization/100810
	* tree-ssa-loop-ivopts.cc (struct iv_cand): Add involves_undefs flag.
	(find_ssa_undef): New function.
	(add_candidate_1): Avoid adding derived candidates with
	undefined SSA names and mark the original ones.
	(determine_group_iv_cost_generic): Reject rewriting
	uses with a different IV when that involves undefined SSA names.

	* gcc.dg/torture/pr100810.c: New testcase.
	* gcc.dg/torture/pr105337.c: Likewise.
2022-04-25 09:25:33 +02:00
Steve Kargl
b6e22db856 target/89125 - BSD and math functions
Back story: When GCC is configured and built on non-glibc platforms,
it seems very little to no effort is made to enumerate the available
C99 libm functions.  It is all or nothing for C99 libm.  The patch
introduces a new function, used on only FreeBSD, to inform gcc that
it has C99 libm functions (minus a few which clearly GCC does not check
nor test).

2022-04-15  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR target/89125
	* config/freebsd.h: Define TARGET_LIBC_HAS_FUNCTION to be
	bsd_libc_has_function.
	* targhooks.cc (bsd_libc_has_function): New function.
	Expand the supported math functions to inclue C99 libm.
	* targhooks.h (bsd_libc_has_function): New Prototype.
2022-04-25 09:25:33 +02:00
Richard Biener
4f77738c3b rtl-optimization/105231 - distribute_notes and REG_EH_REGION
The following mitigates a problem in combine distribute_notes which
places an original REG_EH_REGION based on only may_trap_p which is
good to test whether a non-call insn can possibly throw but not if
actually it does or we care.  That's something we decided at RTL
expansion time where we possibly still know the insn evaluates
to a constant.

In fact, the REG_EH_REGION note with lp > 0 can only come from the
original i3 and an assert is added to that effect.  That means we only
need to retain the note on i3 or, if that cannot trap, drop it but we
should never move it to i2.

The following places constraints on the insns to combine with
non-call exceptions since we cannot handle the case where we
have more than one EH side-effect in the IL.  The patch also
makes sure we can accumulate that on i3 and do not split
a possible exception raising part of it to i2.  As a special
case we do not place any restriction on all externally
throwing insns when there is no REG_EH_REGION present.

2022-04-22  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/105231
	* combine.cc (distribute_notes): Assert that a REG_EH_REGION
	with landing pad > 0 is from i3.  Put any REG_EH_REGION note
	on i3 or drop it if the insn can not trap.
	(try_combine): Ensure that we can merge REG_EH_REGION notes
	with non-call exceptions.  Ensure we are not splitting a
	trapping part of an insn with non-call exceptions when there
	is any REG_EH_REGION note to preserve.

	* gcc.dg/torture/pr105231.c: New testcase.
2022-04-25 09:25:33 +02:00
Hongyu Wang
3c940d4270 AVX512F: Add missing macro for mask(z?)_scalf_s[sd] [PR 105339]
Add missing macro under O0 and adjust macro format for scalf
intrinsics.

gcc/ChangeLog:

	PR target/105339
	* config/i386/avx512fintrin.h (_mm512_scalef_round_pd):
	Add parentheses for parameters and djust format.
	(_mm512_mask_scalef_round_pd): Ditto.
	(_mm512_maskz_scalef_round_pd): Ditto.
	(_mm512_scalef_round_ps): Ditto.
	(_mm512_mask_scalef_round_ps): Ditto.
	(_mm512_maskz_scalef_round_ps): Ditto.
	(_mm_scalef_round_sd): Use _mm_undefined_pd.
	(_mm_scalef_round_ss): Use _mm_undefined_ps.
	(_mm_mask_scalef_round_sd): New macro.
	(_mm_mask_scalef_round_ss): Ditto.
	(_mm_maskz_scalef_round_sd): Ditto.
	(_mm_maskz_scalef_round_ss): Ditto.

gcc/testsuite/ChangeLog:

	PR target/105339
	* gcc.target/i386/sse-14.c: Add tests for new macro.
2022-04-25 09:17:36 +08:00
GCC Administrator
bd64885971 Daily bump. 2022-04-25 00:16:21 +00:00
Jeff Law
6b7441a46c [committed] exec-stack warning for test which wants executable stacks
gcc/testsuite
	* gcc.dg/lto/pr94157_0.c: Also request executable stack from
	the linker.
2022-04-24 13:39:22 -04:00
Mikael Morin
fa5cd7102d fortran: Detect duplicate unlimited polymorphic types [PR103662]
This fixes a type-based alias analysis issue with unlimited polymorphic
class descriptors (types behind class(*)) causing data initialisation to
be removed by optimization.

The fortran front-end may create multiple declarations for types, for
example if a type is redeclared in each program unit it is used in.
To avoid optimization seeing them as non-aliasing, a list of derived
types is created at resolution time, and used at translation to set
the same TYPE_CANONICAL type for each duplicate type declaration.

This mechanism didn’t work for unlimited polymorphic descriptors types,
as there is a short-circuit return skipping all the resolution handling
for them, including the type registration.

This change adds type registration at the short-circuit return, and
updates type comparison to handle specifically unlimited polymorphic
fake symbols, class descriptor types and virtual table types.

The test, which exhibited mismatching dynamic types had to be fixed as
well.

	PR fortran/103662

gcc/fortran/ChangeLog:

	* interface.cc (gfc_compare_derived_types): Support comparing
	unlimited polymorphic fake symbols.  Recursively compare class
	descriptor types and virtual table types.
	* resolve.cc (resolve_fl_derived): Add type to the types list
	on unlimited polymorphic short-circuit return.

gcc/testsuite/ChangeLog:

	* gfortran.dg/unlimited_polymorphic_3.f03 (foo): Separate
	bind(c) and sequence checks to...
	(foo_bc, foo_sq): ... two different procedures.
	(main, foo*): Change type declarations so that type name,
	component name, and either bind(c) or sequence attribute match
	between the main type declarations and the procedure type
	declarations.
	(toplevel): Add optimization dump checks.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
2022-04-24 15:05:41 +02:00
GCC Administrator
afe0b5b7ce Daily bump. 2022-04-24 00:16:27 +00:00
Jakub Jelinek
1ceddd7497 i386: Improve ix86_expand_int_movcc [PR105338]
The following testcase regressed on x86_64 on the trunk, due to some GIMPLE
pass changes (r12-7687) we end up an *.optimized dump difference of:
@@ -8,14 +8,14 @@ int foo (int i)

   <bb 2> [local count: 1073741824]:
   if (i_2(D) != 0)
-    goto <bb 4>; [35.00%]
+    goto <bb 3>; [35.00%]
   else
-    goto <bb 3>; [65.00%]
+    goto <bb 4>; [65.00%]

-  <bb 3> [local count: 697932184]:
+  <bb 3> [local count: 375809640]:

   <bb 4> [local count: 1073741824]:
-  # iftmp.0_1 = PHI <5(2), i_2(D)(3)>
+  # iftmp.0_1 = PHI <5(3), i_2(D)(2)>
   return iftmp.0_1;

 }
and similarly for the other functions.  That is functionally equivalent and
there is no canonical form for those.  The reason for i_2(D) in the PHI
argument as opposed to 0 is the uncprop pass, that is in many cases
beneficial for expansion as we don't need to load the value into some pseudo
in one of the if blocks.
Now, for the 11.x ordering we have the pseudo = i insn in the extended basic
block (it comes first) and so forwprop1 undoes what uncprop does by
propagating constant 0 there.  But for the 12.x ordering, the extended basic
block contains pseudo = 5 and pseudo = i is in the other bb and so fwprop1
doesn't change it.
During the ce1 pass, we attempt to emit a conditional move and we have very
nice code for the cases where both last operands of ?: are constant, and yet
another for !TARGET_CMOVE if at least one of them is.

The following patch will undo the uncprop behavior during
ix86_expand_int_movcc, but just for those spots that can benefit from both
or at least one operands being constant, leaving the pure cmov case as is
(because then it is useful not to have to load a constant into a pseudo
as it already is in one).  We can do that in the
op0 == op1 ? op0 : op3
or
op0 != op1 ? op2 : op0
cases if op1 is a CONST_INT by pretending it is
op0 == op1 ? op1 : op3
or
op0 != op1 ? op2 : op1

2022-04-23  Jakub Jelinek  <jakub@redhat.com>

	PR target/105338
	* config/i386/i386-expand.cc (ix86_expand_int_movcc): Handle
	op0 == cst1 ? op0 : op3 like op0 == cst1 ? cst1 : op3 for the non-cmov
	cases.

	* gcc.target/i386/pr105338.c: New test.
2022-04-23 10:25:31 +02:00
GCC Administrator
ab54f6007c Daily bump. 2022-04-23 00:16:24 +00:00
Thomas W Rodgers
7c21556daf libstdc++: Make atomic notify_one and notify_all non-const
<recording this here for future reference>
PR102994 "atomics: std::atomic<ptr>::wait is not marked const" raises the
issue that the current libstdc++ implementation marks the notify members
const, the implementation strategy used by libstdc++, as well as libc++
and the Microsoft STL, do not require the atomic to be mutable (it is hard
to conceive of a desirable implementation approach that would require it).
The original paper proposing the wait/notify functionality for atomics
(p1185) also had these members marked const for the first three revisions,
but that was changed without explanation in r3 and subsequent revisions of
the paper.

After raising the issue to the authors of p1185 and the author of the
libc++ implementation, the consensus seems to be "meh, it's harmless" so
there seems little appetite for an LWG issue to revisit the subject.

This patch changes the libstdc++ implementation to be in agreement with
the standard by removing const from those notify_one/notify_all members.

libstdc++-v3/ChangeLog:

	PR libstdc++/102994
	* include/bits/atomic_base.h (atomic_flag::notify_one,
	notify_all): Remove const qualification.
	(__atomic_base::notify_one, notify_all): Likewise.
	* include/std/atomic (atomic<bool>::notify_one, notify_all):
	Likewise.
	(atomic::notify_one, notify_all): Likewise.
	(atomic<T*>::notify_one, notify_all): Likewise.
	(atomic_notify_one, atomic_notify_all): Likewise.
	* testsuite/29_atomics/atomic/wait_notify/102994.cc: Adjust test
	to account for change in notify_one/notify_all signature.
2022-04-22 15:53:41 -07:00
Mikael Morin
7964ab6c36 fortran: Use pointer arithmetic to index arrays [PR102043]
The code generated for array references used to be ARRAY_REF trees as
could be expected.  However, the middle-end may conclude from those
trees that the indexes used are non-negative (more precisely not below
the lower bound), which is a wrong assumption in the case of "reversed-
order" arrays.

The problematic arrays are those with a descriptor and having a negative
stride for at least one dimension.  The descriptor data points to the
first element in array order (which is not the first in memory order in
that case), and the negative stride(s) makes walking the array backwards
(towards lower memory addresses), and we can access elements with
negative index wrt data pointer.

With this change, pointer arithmetic is generated by default for array
references, unless we are in a case where negative indexes can’t happen
(array descriptor’s dim element, substrings, explicit shape,
allocatable, or assumed shape contiguous).  A new flag is added to
choose between array indexing and pointer arithmetic, and it’s set
if the context can tell array indexing is safe (descriptor dim
element, substring, temporary array), or a new method is called
to decide on whether the flag should be set for one given array
expression.

	PR fortran/102043

gcc/fortran/ChangeLog:

	* trans.h (gfc_build_array_ref): Add non_negative_offset
	argument.
	* trans.cc (gfc_build_array_ref): Ditto. Use pointer arithmetic
	if non_negative_offset is false.
	* trans-expr.cc (gfc_conv_substring): Set flag in the call to
	gfc_build_array_ref.
	* trans-array.cc (gfc_get_cfi_dim_item,
	gfc_conv_descriptor_dimension): Same.
	(build_array_ref): Decide on whether to set the flag and update
	the call.
	(gfc_conv_scalarized_array_ref): Same.  New argument tmp_array.
	(gfc_conv_tmp_array_ref): Update call to
	gfc_conv_scalarized_ref.
	(non_negative_strides_array_p): New function.

gcc/testsuite/ChangeLog:

	* gfortran.dg/array_reference_3.f90: New.
	* gfortran.dg/negative_stride_1.f90: New.
	* gfortran.dg/vector_subscript_8.f90: New.
	* gfortran.dg/vector_subscript_9.f90: New.
	* gfortran.dg/c_loc_test_22.f90: Update dump patterns.
	* gfortran.dg/finalize_10.f90: Same.

Co-Authored-By: Richard Biener <rguenther@suse.de>
2022-04-22 22:52:50 +02:00
Mikael Morin
761dda5748 fortran: Generate an array temporary reference [PR102043]
This avoids regressing on char_cast_1.f90 and char_cast_2.f90 later in
the patch series when the code generation for array references is
changed to use pointer arithmetic.

The regressing testcases match part of an array reference in the
generated tree dump and it’s not clear how the pattern should be
rewritten to match the equivalent with pointer arithmetic.

This change uses a method specific to array temporaries to generate
array-references, so that these array references are flagged as safe
for array indexing and will not be updated to use pointer arithmetic.

	PR fortran/102043

gcc/fortran/ChangeLog:
	* trans-array.cc (gfc_conv_expr_descriptor): Use
	gfc_conv_tmp_array_ref.
2022-04-22 22:52:38 +02:00
Mikael Morin
e72fbb6915 fortran: Update index extraction code. [PR102043]
This avoids a regression on hollerith4.f90 and hollerith6.f90 later in
the patch series when code generation for array references is changed
to use pointer arithmetic.

The problem comes from the extraction of the array index from an
ARRAY_REF tree, which doesn’t work if the tree is not an ARRAY_REF
any more.

This updates the code generated for remaining size evaluation to work
with a source tree that uses either array indexing or pointer
arithmetic.

	PR fortran/102043

gcc/fortran/ChangeLog:

	* trans-io.cc: Add handling for the case where the array
	is referenced using pointer arithmetic.
2022-04-22 22:52:26 +02:00
Mikael Morin
89ca0fffa4 fortran: Pre-evaluate string pointers. [PR102043]
This avoids a regression on deferred_character_23.f90 later in the
patch series when array references are rewritten to use pointer
arithmetic.

The problem is a SAVE_EXPR tree as TYPE_SIZE_UNIT of one array element
type, which is used by the pointer arithmetic expressions.  As these
expressions appear in both branches of an if-then-else block, the tree
is lowered to a variable in one of the branches but it’s used in both
branches, which is invalid middle-end code.

This change pre-evaluates the array references or pointer arithmetics
to variables before the if-then-else block, so that the SAVE_EXPR are
expanded to variables in the parent scope of the if-then-else block,
and expressions referencing the variables remain valid in both
branches.

	PR fortran/102043

gcc/fortran/ChangeLog:
	* trans-expr.cc: Pre-evaluate src and dest to variables
	before using them.

gcc/testsuite/ChangeLog:
	* gfortran.dg/dependency_49.f90: Update variable occurence
	count.
2022-04-22 22:52:12 +02:00