Commit Graph

181300 Commits

Author SHA1 Message Date
David Malcolm
f3f312b535 analyzer: only use CWE-690 for unchecked return value [PR97893]
CWE-690 is only for dereferencing an unchecked return value; for
other kinds of NULL dereference, use the parent classification, CWE-476.

gcc/analyzer/ChangeLog:
	PR analyzer/97893
	* sm-malloc.cc (null_deref::emit): Use CWE-476 rather than
	CWE-690, as this isn't due to an unchecked return value.
	(null_arg::emit): Likewise.

gcc/testsuite/ChangeLog:
	PR analyzer/97893
	* gcc.dg/analyzer/malloc-1.c: Add CWE-690 and CWE-476 codes to
	expected output.
2020-11-18 15:53:36 -05:00
Iain Sandoe
0802809321 Objective-C++ : Avoid ICE on invalid with empty attributes.
Empty prefix attributes like:

__attribute__ (())
@interface MyClass
@end

cause an ICE at present, check for that case and skip them.

gcc/cp/ChangeLog:

	* parser.c (cp_parser_objc_valid_prefix_attributes): Check
	for empty attributes.
2020-11-18 20:42:35 +00:00
Eugene Rozenfeld
f44e609162 Optimize two patterns with three xors
gcc/
	PR tree-optimization/96671
	* match.pd (three xor patterns): New patterns.
2020-11-18 14:31:09 -05:00
Kwok Cheung Yeung
6fae7eda96 openmp: Retire nest-var ICV for OpenMP 5.1
This removes the nest-var ICV, expressing nesting in terms of the
max-active-levels-var ICV instead.  The max-active-levels-var ICV
is now per data environment rather than per device.

2020-11-18  Kwok Cheung Yeung  <kcy@codesourcery.com>

	libgomp/
	* env.c (gomp_global_icv): Remove nest_var field.  Add
	max_active_levels_var field.
	(gomp_max_active_levels_var): Remove.
	(parse_boolean): Return true on success.
	(handle_omp_display_env): Express OMP_NESTED in terms of
	max_active_levels_var.  Change format specifier for
	max_active_levels_var.
	(initialize_env): Set max_active_levels_var from
	OMP_MAX_ACTIVE_LEVELS, OMP_NESTED, OMP_NUM_THREADS and
	OMP_PROC_BIND.
	* icv.c (omp_set_nested): Express in terms of
	max_active_levels_var.
	(omp_get_nested): Likewise.
	(omp_set_max_active_levels): Use max_active_levels_var field instead
	of gomp_max_active_levels_var.
	(omp_get_max_active_levels): Likewise.
	* libgomp.h (struct gomp_task_icv): Remove nest_var field.  Add
	max_active_levels_var field.
	(gomp_supported_active_levels): Set to UCHAR_MAX.
	(gomp_max_active_levels_var): Delete.
	* libgomp.texi (omp_get_nested): Update documentation.
	(omp_set_nested): Likewise.
	(OMP_MAX_ACTIVE_LEVELS): Likewise.
	(OMP_NESTED): Likewise.
	(OMP_NUM_THREADS): Likewise.
	(OMP_PROC_BIND): Likewise.
	* parallel.c (gomp_resolve_num_threads): Replace reference
	to nest_var with max_active_levels_var.  Use max_active_levels_var
	field instead of gomp_max_active_levels_var.
2020-11-18 11:24:36 -08:00
Joseph Myers
965e0cc371 Update gcc zh_TW.po.
* zh_TW.po: Update.
2020-11-18 19:15:01 +00:00
Jakub Jelinek
95db7e9afe options, lto: Optimize streaming of optimization nodes
Honza mentioned that especially for the new param machinery, most of
streamed values are probably going to be the default values.  Perhaps
somehow we could stream them more effectively.

This patch implements it and brings further savings, the size
goes down from 574 bytes to 273 bytes, i.e. less than half.
Not trying to handle enums because the code doesn't know if (enum ...) 10
is even valid, similarly non-parameters because those really generally
don't have large initializers, and params without Init (those are 0
initialized and thus don't need to be handled).

2020-11-18  Jakub Jelinek  <jakub@redhat.com>

	* optc-save-gen.awk: Initialize var_opt_init.  In
	cl_optimization_stream_out for params with default values larger than
	10, xor the default value with the actual parameter value.  In
	cl_optimization_stream_in repeat the above xor.
2020-11-18 20:14:00 +01:00
Jakub Jelinek
d326ebc94f configury: --enable-link-serialization support
When performing LTO bootstraps, especially when using tmpfs for /tmp,
one can run a machine to halt when using higher levels of parallelism
and a large number of FEs, because there are too many concurrent LTO
link commands running at the same time and each one of them puts most of the
middle-end/backend objects into /tmp.

We have --enable-link-mutex configure option, but --enable-link-mutex has
a big problem that it decreases number of available jobs by the number of
link commands waiting for the lock, so e.g. when doing make -j32 build with
11 different big programs linked with $(LLINKER) we end up with just 22
effective jobs, and with e.g. make -j8 with those 11 different big programs
we actually most likely serialize everything during linking onto a single job.

The following patch implements a new configure option,
--enable-link-serialization, which implements different serialization and
as it doesn't use the mutex, just modifying the old option to be implemented
differently would be strange.  We can deprecate and later remove the old
option.  The new option doesn't use any shell mutexes, but uses make
dependencies.

The option is implemented inside of gcc/ configure and Makefiles,
which means that even inside of gcc/ make all (as well as e.g. make lto-dump)
will serialize and build all previous large binaries when configured this
way.
One can always make -j32 cc1 DO_LINK_SERIALIZATION=
to avoid that.
Furthermore, I've implemented the idea I wrote about, so that
--enable-link-serialization
is the same as
--enable-link-serialization=1
and means the large link commands are serialized, one can (the default)
--disable-link-serialization
which will cause all links to be parallelizable, but one can also
--enable-link-serialization=3
etc. which says that at most 3 of the large link commands can run
concurrently.
And finally I've implemented (only if the serialization is enabled) simple
progress bars for the linking.
With --enable-link-serialization and e.g. the 5 large links I have in my
current tree (cc1, cc1plus, f951, lto1 and lto-dump), before the linking it
prints
Linking |==--      | 20%
and after it
Linking |====      | 40%
(each == characters stand for already finished links, each --
characters stand for the link being started).
With --enable-link-serialization=3 it will change the way the start is
printed, one will get:
Linking |--        | 0%
at the start of cc1 link,
Linking |>>--      | 0%
at the start of the second large link and
Linking |>>>>--    | 0%
at the start of the third large link, where the >> characters stand for
already pending links.  The printing at the end of link command is
the same as with the full serialization, i.e. for the above 3:
Linking |==        | 20%
Linking |====      | 40%
Linking |======    | 60%
but one could actually get them in any order depending on which of those 3
finishes first - to get it 100% accurate I'd need to add some directory with
files representing finished links or similar, doesn't seem worth it.

2020-11-18  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* configure.ac: Add $lang.prev rules, INDEX.$lang and SERIAL_LIST and
	SERIAL_COUNT variables to Make-hooks.
	(--enable-link-serialization): New configure option.
	* Makefile.in (DO_LINK_SERIALIZATION, LINK_PROGRESS): New variables.
	* doc/install.texi (--enable-link-serialization): Document.
	* configure: Regenerated.
gcc/c/
	* Make-lang.in (c.serial): New goal.
	(.PHONY): Add c.serial c.prev.
	(cc1$(exeext)): Call LINK_PROGRESS.
gcc/cp/
	* Make-lang.in (c++.serial): New goal.
	(.PHONY): Add c++.serial c++.prev.
	(cc1plus$(exeext)): Depend on c++.prev.  Call LINK_PROGRESS.
gcc/fortran/
	* Make-lang.in (fortran.serial): New goal.
	(.PHONY): Add fortran.serial fortran.prev.
	(f951$(exeext)): Depend on fortran.prev.  Call LINK_PROGRESS.
gcc/lto/
	* Make-lang.in (lto, lto1.serial, lto2.serial): New goals.
	(.PHONY): Add lto lto1.serial lto1.prev lto2.serial lto2.prev.
	(lto.all.cross, lto.start.encap): Remove dependencies.
	($(LTO_EXE)): Depend on lto1.prev.  Call LINK_PROGRESS.
	($(LTO_DUMP_EXE)): Depend on lto2.prev.  Call LINK_PROGRESS.
gcc/objc/
	* Make-lang.in (objc.serial): New goal.
	(.PHONY): Add objc.serial objc.prev.
	(cc1obj$(exeext)): Depend on objc.prev.  Call LINK_PROGRESS.
gcc/objcp/
	* Make-lang.in (obj-c++.serial): New goal.
	(.PHONY): Add obj-c++.serial obj-c++.prev.
	(cc1objplus$(exeext)): Depend on obj-c++.prev.  Call LINK_PROGRESS.
gcc/ada/
	* gcc-interface/Make-lang.in (ada.serial): New goal.
	(.PHONY): Add ada.serial ada.prev.
	(gnat1$(exeext)): Depend on ada.prev.  Call LINK_PROGRESS.
gcc/brig/
	* Make-lang.in (brig.serial): New goal.
	(.PHONY): Add brig.serial brig.prev.
	(brig1$(exeext)): Depend on brig.prev.  Call LINK_PROGRESS.
gcc/go/
	* Make-lang.in (go.serial): New goal.
	(.PHONY): Add go.serial go.prev.
	(go1$(exeext)): Depend on go.prev.  Call LINK_PROGRESS.
gcc/jit/
	* Make-lang.in (jit.serial): New goal.
	(.PHONY): Add jit.serial jit.prev.
	($(LIBGCCJIT_FILENAME)): Depend on jit.prev.  Call LINK_PROGRESS.
gcc/d/
	* Make-lang.in (d.serial): New goal.
	(.PHONY): Add d.serial d.prev.
	(d21$(exeext)): Depend on d.prev.  Call LINK_PROGRESS.
2020-11-18 20:11:37 +01:00
Richard Sandiford
71e234a5c9 testsuite: Adjust bb-slp-pr68892.c for AArch64
AArch64 passes the "not profitable" test because it treats vec_construct
as having a high-enough cost.  This means that we can try other vector
modes, which in turn causes "BB vectorization with gaps at the end of
a load is not supported" to be printed more than once.  The number of
times that we print the message doesn't seem important, so the patch
converts it to a plain scan-tree-dump.

gcc/testsuite/
	* gcc.dg/vect/bb-slp-pr68892.c: Don't XFAIL the profitability
	test for aarch64*-*-*.  Allow the "BB vectorization with gaps"
	message to be printed more than once.
2020-11-18 18:40:33 +00:00
Richard Sandiford
ee9dd1c302 testsuite: Adjust gcc.dg/vect/slp-21.c for Arm targets
On arm* and aarch64* targets, we can vectorise the second of the main
loops using SLP, not just the third.  As the comments say, whether this
is supported depends on a very specific permutation, so it seemed better
to use direct target selectors.

gcc/testsuite/
	* gcc.dg/vect/slp-21.c: Expect 4 SLP instances to be vectorized
	on arm* and aarch64* targets.
2020-11-18 18:40:32 +00:00
Richard Sandiford
6a9cd27ac6 testsuite: Add vect_perm3_int guards
SLP vectorisation of gcc.dg/vect/fast-math-vect-call-1.c involves
a group of 3 floats, which requires the same permutation as
vect_perm3_int.

The load/store_lanes XFAILs in gcc.dg/vect/slp-perm-6.c implicitly
assumed vect_perm3_int, which is true for Advanced SIMD but not for
VLA SVE.  Whether it's true for fixed-length SVE depends on the
vector length.

The xfail selector applies on top of the target selector, so it's
not necessary to make the xfail selector a strict subset of the
target selector.

gcc/testsuite/
	* gcc.dg/vect/fast-math-vect-call-1.c: Only expect SLP to be used
	on vect_perm3_int targets.
	* gcc.dg/vect/slp-perm-6.c: Likewise.  Only XFAIL the LOAD/STORE_LANES
	tests on vect_perm3_int targets.
2020-11-18 18:40:32 +00:00
Richard Sandiford
6d0ffd9a3e testsuite: Add a vect_partial_vectors_usage_2 guard
We don't need an epilogue loop if the main loop can operate on
partial vectors, so this patch disables an associated test.
The alternative would be to force partial-vectors-usage=1
on the command line.

gcc/testsuite/
	* gcc.dg/vect/vect-epilogues.c: XFAIL test for epilogue loop
	vectorization if vect_partial_vectors_usage_2.
2020-11-18 18:40:31 +00:00
Richard Sandiford
0f545ad9b6 testsuite: Fix vect/vect-sdiv-pow2-1.c
We're now able to vectorise the set-up loop:

      int p = power2 (fns[i].po2);
      for (int j = 0; j < N; j++)
        a[j] = ((p << 4) * j) / (N - 1) - (p << 5);

This patch adds an asm to stop the loop being vectorised.

gcc/testsuite/
	* gcc.dg/vect/vect-sdiv-pow2-1.c (main): Add an asm to the
	set-up loop.
2020-11-18 18:40:30 +00:00
Nathan Sidwell
92648faa1c aix: Fixinclude
This fixes an ODR violation in the AIX headers that is detected by C++
modules.  While unnamed structs with typedef names for linkage
purposes are accepted, this case is an anonymous struct without such a
typedef name -- the typedef is attached to the pointer-to-struct type.
Fixed by naming the struct.

	fixincludes/
	* inclhack.def (aix_physaddr_t): New.
	* fixincl.x: Regenerated.
2020-11-18 10:33:30 -08:00
Nathan Sidwell
c9c3d5f28a preprocessor: C++ module-directives
C++20 modules introduces a new kind of preprocessor directive -- a
module directive.  These are directives but without the leading '#'.
We have to detect them by sniffing the start of a logical line.  When
detected we replace the initial identifiers with unspellable tokens
and pass them through to the language parser the same way deferred
pragmas are.  There's a PRAGMA_EOL at the logical end of line too.

One additional complication is that we have to do header-name lexing
after the initial tokens, and that requires changes in the macro-aware
piece of the preprocessor.  The above sniffer sets a counter in the
lexer state, and that triggers at the appropriate point.  We then do
the same header-name lexing that occurs on a #include directive or
has_include pseudo-macro.  Except that the header name ends up in the
token stream.

A couple of token emitters need to deal with the new token possibility.

	gcc/c-family/
	* c-lex.c (c_lex_with_flags): CPP_HEADER_NAMEs can now be seen.
	libcpp/
	* include/cpplib.h (struct cpp_options): Add module_directives
	option.
	(NODE_MODULE): New node flag.
	(struct cpp_hashnode): Make rid-code a bitfield, increase bits in
	flags and swap with type field.
	* init.c (post_options): Create module-directive identifier nodes.
	* internal.h (struct lexer_state): Add directive_file_token &
	n_modules fields.  Add module node enumerator.
	* lex.c (cpp_maybe_module_directive): New.
	(_cpp_lex_token): Call it.
	(cpp_output_token): Add '"' around CPP_HEADER_NAME token.
	(do_peek_ident, do_peek_module): New.
	(cpp_directives_only): Detect module-directive lines.
	* macro.c (cpp_get_token_1): Deal with directive_file_token
	triggering.
2020-11-18 10:24:12 -08:00
Nathan Sidwell
7ceb899e93 preprocessor: Add support for header unit translation
libcpp/
	* files.c (struct _cpp_file): Add header_unit field.
	(_cpp_stack_file): Add header unit support.
	(cpp_find_header_unit): New.
	* include/cpplib.h (cpp_find_header_unit): Declare.
2020-11-18 08:45:46 -08:00
Nathan Sidwell
db87f19ae3 preprocessor: Update mkdeps for modules
This is slightly different to the original patch I posted.  This adds
separate module target and dependency functions (rather than a single
bi-modal function).

	libcpp/
	* include/cpplib.h (struct cpp_options): Add modules to
	dep-options.
	* include/mkdeps.h (deps_add_module_target): Declare.
	(deps_add_module_dep): Declare.
	* mkdeps.c (class mkdeps): Add modules, module_name, cmi_name,
	is_header_unit fields.  Adjust cdtors.
	(deps_add_module_target, deps_add_module_dep): New.
	(make_write): Write module dependencies, if enabled.
2020-11-18 08:44:49 -08:00
Patrick Palka
d4a788c717 libstdc++: Fix ranges::join_view::_Iterator::operator-> [LWG 3500]
This applies the proposed resolution of LWG 3500, which corrects the
return type and constraints of this member function to use the right
iterator type.  Additionally, a nearby local variable is uglified.

libstdc++-v3/ChangeLog:

	* include/std/ranges (join_view::_Iterator::_M_satisfy): Uglify
	local variable inner.
	(join_view::_Iterator::operator->): Use _Inner_iter instead of
	_Outer_iter in the function signature as per LWG 3500.
	* testsuite/std/ranges/adaptors/join.cc (test08): Test it.
2020-11-18 10:23:57 -05:00
Vladimir N. Makarov
2f2709e691 [PR97870] LRA: don't remove asm goto, just nullify it.
gcc/

2020-11-18  Vladimir Makarov  <vmakarov@redhat.com>

	PR target/97870
	* lra-constraints.c (curr_insn_transform): Do not delete asm goto
	with wrong constraints.  Nullify it saving CFG.
2020-11-18 10:11:33 -05:00
Tobias Burnus
cb1a4876a0 testsuite/libgomp.c/usleep.h: Use sleep-loop also for GCN
As typically configured, newlib's libc.a does not build 'posix' and,
hence, usleep is not available. Thus, use the same fallback as for nvptx.

libgomp/
	* testsuite/libgomp.c/usleep.h (fallback_usleep): Renamed from
	nvptx_usleep; use also for device={arch(gcn)}.
2020-11-18 14:11:27 +01:00
Matthias Klose
ba97b53260 Fix PR ada/97859, building ada cross compiler targeting powerpc64le-linux-gnu
2020-11-18  Matthias Klose  <doko@ubuntu.com>

	PR ada/97859
	* Makefile.rtl (powerpc% linux%): Also match powerpc64le cpu.
2020-11-18 13:24:33 +01:00
Jozef Lawrynowicz
bf7b94d407 MSP430: Add 64-bit hardware multiply support
Hardware multipliers that support widening 32-bit multiplication can
be used to perform a 64-bit * 64-bit multiplication more efficiently
than a software implementation.

The following equation is used to perform 64-bit multiplication for
devices with "32bit" or "f5series" hardware multiply versions:

  64bit_result = (low32_op0 * lop32_op1)
    + ((low32_op0 * high32_op1) << 32)
       + ((high32_op0 * low32_op1) << 32)

libgcc/ChangeLog:

	* config/msp430/lib2hw_mul.S (mult64_hw): New.
	(if MUL_32): Use mult64_hw for __muldi3.
	(if MUL_F5): Use mult64_hw for __muldi3.
	* config/msp430/lib2mul.c (__muldi3): New.
	* config/msp430/t-msp430 (LIB2FUNCS_EXCLUDE): Define.
2020-11-18 11:05:27 +00:00
Jozef Lawrynowicz
e045b85836 MSP430: Add mul{hi,si} and {u,}mulsidi3 expanders
GCC generates better code when multiplication operations, which require
library functions to perform, are caught in early in RTL, rather than
leaving the operation to be mapped to a library function later on.

When there is hardware multiply support, it is more efficient to perform
widening multiplication using the hardware multiplier instead of letting
GCC widen the arguments before calling the multiplication routine in the
wider mode.

gcc/ChangeLog:

	* config/msp430/msp430.md (mulhi3): New.
	(mulsi3): New.
	(mulsidi3): Rename to *mulsidi3_inline.
	(umulsidi3): Rename to *umulsidi3_inline.
	(mulsidi3): New define_expand.
	(umulsidi3): New define_expand.
2020-11-18 11:03:39 +00:00
Richard Biener
30270bf042 tree-optimization/97886 - deal with strange LC PHI nodes
This makes vectorization properly assign vector types to PHI
nodes that copy from externals on loop exit edges.

2020-11-18  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/97886
	* tree-vect-loop.c (vectorizable_lc_phi): Properly assign
	vector types to invariants for SLP.
2020-11-18 11:25:00 +01:00
Iain Buclaw
798bdfa0eb d: Fix LHS of array concatentation evaluated before the RHS.
In an array append expression:

    array ~= fun(array);

The array in the left hand side of the expression was extended before
evaluating the result of the right hand side, which resulted in the
newly uninitialized array index being used before set.

This fixes that so that the result of the right hand side is always
saved in a reusable temporary before assigning to the destination.

gcc/d/ChangeLog:

	PR d/97843
	* d-codegen.cc (build_assign): Evaluate TARGET_EXPR before use in
	the right hand side of an assignment.
	* expr.cc (ExprVisitor::visit (CatAssignExp *)): Force a TARGET_EXPR
	on the element to append if it is a CALL_EXPR.

gcc/testsuite/ChangeLog:

	PR d/97843
	* gdc.dg/torture/pr97843.d: New test.
2020-11-18 10:22:18 +01:00
Iain Buclaw
27d8c3516b d: Fix a couple of ICEs found in the dmd front-end (PR97842)
- Segmentation fault on incomplete static if.
- Segmentation fault resolving typeof() expression when gagging is on.

Reviewed-on: https://github.com/dlang/dmd/pull/11971

gcc/d/ChangeLog:

	PR d/97842
	* dmd/MERGE: Merge upstream dmd b6a779e49
2020-11-18 10:22:06 +01:00
Iain Buclaw
fa9091ad93 d: Add dragonflybsd support for D compiler and runtime
gcc/ChangeLog:

	* config.gcc (*-*-dragonfly*): Add dragonfly-d.o and t-dragonfly.
	* config/dragonfly-d.c: New file.
	* config/t-dragonfly: New file.

libphobos/ChangeLog:

	* configure.tgt: Add *-*-dragonfly* as a supported target.
	* configure: Regenerate.
	* m4/druntime/os.m4 (DRUNTIME_OS_SOURCES): Add dragonfly* as a posix
	target.
2020-11-18 10:22:06 +01:00
Iain Buclaw
4c4dfe21df libphobos: Merge upstream phobos 7948e0967.
Removes deprecated functions from std.string module.

Reviewed-on: https://github.com/dlang/phobos/pull/7694

libphobos/ChangeLog:

	* src/MERGE: Merge upstream phobos 7948e0967.
2020-11-18 10:21:26 +01:00
Jakub Jelinek
ba009860ae openmp: Fix ICE on non-rectangular loop with known 0 iterations
The loops in the testcase are non-rectangular and have 0 iterations
(the outer loop iterates, but the inner one never).  In this case we
just have the overall number of iterations computed (0), and don't have
factor and other values computed.  We never need to map logical iterations
to the individual iterations in that case, and we were crashing during
expansion of that code.

2020-11-18  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/97862
	* omp-expand.c (expand_omp_for_init_vars): Don't use the sqrt path
	if number of iterations is constant 0.

	* c-c++-common/gomp/pr97862.c: New test.
2020-11-18 09:40:45 +01:00
Kito Cheng
4b81528241 RISC-V: Support version controling for ISA standard extensions
- New option -misa-spec support: -misa-spec=[2.2|20190608|20191213] and
   corresponding configuration option --with-isa-spec.

 - Current default ISA spec set to 2.2, but we intend to bump this to
   20191213 or later in next release.

gcc/ChangeLog:

	* common/config/riscv/riscv-common.c (riscv_ext_version): New.
	(riscv_ext_version_table): Ditto.
	(get_default_version): Ditto.
	(riscv_subset_t::implied_p): New field.
	(riscv_subset_t::riscv_subset_t): Init implied_p.
	(riscv_subset_list::add): New.
	(riscv_subset_list::handle_implied_ext): Pass riscv_subset_t
	instead of separated argument.
	(riscv_subset_list::to_string): Handle zifencei and zicsr, and
	omit version if version is unknown.
	(riscv_subset_list::parsing_subset_version): New argument `ext`,
	remove default_major_version and default_minor_version, get
	default version info via get_default_version.
	(riscv_subset_list::parse_std_ext): Update argument for
	parsing_subset_version calls.
	Handle 2.2 ISA spec, always enable zicsr and zifencei, they are
	included in baseline ISA in that time.
	(riscv_subset_list::parse_multiletter_ext): Update argument for
	`parsing_subset_version` and `add` calls.
	(riscv_subset_list::parse): Adjust argument for
	riscv_subset_list::handle_implied_ext call.
	* config.gcc (riscv*-*-*): Handle --with-isa-spec=.
	* config.in (HAVE_AS_MISA_SPEC): New.
	(HAVE_AS_MARCH_ZIFENCEI): Ditto.
	* config/riscv/riscv-opts.h (riscv_isa_spec_class): New.
	(riscv_isa_spec): Ditto.
	* config/riscv/riscv.h (HAVE_AS_MISA_SPEC): New.
	(ASM_SPEC): Pass -misa-spec if gas supported.
	* config/riscv/riscv.opt (riscv_isa_spec_class) New.
	* configure.ac (HAVE_AS_MARCH_ZIFENCEI): New test.
	(HAVE_AS_MISA_SPEC): Ditto.
	* configure: Regen.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-9.c: New.
	* gcc.target/riscv/arch-10.c: Ditto.
	* gcc.target/riscv/arch-11.c: Ditto.
	* gcc.target/riscv/attribute-6.c: Remove, we don't support G
	with version anymore.
	* gcc.target/riscv/attribute-8.c: Reorder arch string to fit canonical
	ordering.
	* gcc.target/riscv/attribute-9.c: We don't emit version for
	unknown extensions now.
	* gcc.target/riscv/attribute-11.c: Add -misa-spec=2.2 flags.
	* gcc.target/riscv/attribute-12.c: Ditto.
	* gcc.target/riscv/attribute-13.c: Ditto.
	* gcc.target/riscv/attribute-14.c: Ditto.
	* gcc.target/riscv/attribute-15.c: New.
	* gcc.target/riscv/attribute-16.c: Ditto.
	* gcc.target/riscv/attribute-17.c: Ditto.
2020-11-18 15:02:27 +08:00
Kito Cheng
b03be74bad RISC-V: Support zicsr and zifencei extension for -march.
- CSR related instructions and fence instructions has to be splitted from
   baseline ISA, zicsr and zifencei are corresponding sub-extension.

gcc/ChangeLog:

	* common/config/riscv/riscv-common.c (riscv_implied_info):
	d and f implied zicsr.
	(riscv_ext_flag_table): Handle zicsr and zifencei.
	* config/riscv/riscv-opts.h (MASK_ZICSR): New.
	(MASK_ZIFENCEI): Ditto.
	(TARGET_ZICSR): Ditto.
	(TARGET_ZIFENCEI): Ditto.
	* config/riscv/riscv.md (clear_cache): Check TARGET_ZIFENCEI.
	(fence_i): Ditto.
	* config/riscv/riscv.opt (riscv_zi_subext): New.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-8.c: New.
	* gcc.target/riscv/attribute-14.c: Ditto.
2020-11-18 15:02:22 +08:00
Kito Cheng
6a5bb4705f RISC-V: Handle implied extension in canonical ordering.
- ISA spec has specify the order between multi-letter extensions, implied
   extension also need to follow store in canonical ordering, so
   most easy way is we keep that in-order during insertion.

gcc/ChangeLog:

	* common/config/riscv/riscv-common.c (single_letter_subset_rank): New.
	(multi_letter_subset_rank): Ditto.
	(subset_cmp): Ditto.
	(riscv_subset_list::add): Insert subext in canonical ordering.
	(riscv_subset_list::parse_std_ext): Move handle_implied_ext to ...
	(riscv_subset_list::parse): ... here.
2020-11-18 14:02:49 +08:00
guojiufu
d87ee7f1c9 Clean up loop-closed PHIs after loop finalize
This patch propagates loop-closed PHIs them out at
loop_optimizer_finalize.  For some cases, to clean up loop-closed PHIs
would save efforts of optimization passes after loopdone.

Thanks,
Jiufu Guo.

gcc/ChangeLog:
2020-10-18  Jiufu Guo   <guojiufu@linux.ibm.com>

	* cfgloop.h (loop_optimizer_finalize): Add flag argument.
	* loop-init.c (loop_optimizer_finalize): Call clean_up_loop_closed_phi.
	* tree-cfgcleanup.h (clean_up_loop_closed_phi): New declare.
	* tree-ssa-loop.c (tree_ssa_loop_done): Call loop_optimizer_finalize
	with flag argument.
	* tree-ssa-propagate.c (clean_up_loop_closed_phi): New function.

gcc/testsuite/ChangeLog:
2020-10-18  Jiufu Guo   <guojiufu@linux.ibm.com>

	* gcc.dg/tree-ssa/loopclosedphi.c: New test.
2020-11-18 13:29:14 +08:00
Ian Lance Taylor
397654d66a cmd/go, cmd/cgo: update gofrontend mangling checks
This is a port of two patches in the master repository.

https://golang.org/cl/259298

    cmd/cgo: split gofrontend mangling checks into cmd/internal/pkgpath

    This is a step toward porting https://golang.org/cl/219817 from the
    gofrontend repo to the main repo.

    Note that this also corrects the implementation of the v2 mangling
    scheme to use ..u and ..U where appropriate.

https://golang.org/cl/259299

    cmd/go: use cmd/internal/pkgpath for gccgo pkgpath symbol

For golang/go#37272
For golang/go#41862

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/270637
2020-11-17 18:32:07 -08:00
GCC Administrator
4dabb03719 Daily bump. 2020-11-18 00:16:34 +00:00
Jonathan Wakely
1e3e6c700f libstdc++: Revert changes for SYS_clock_gettime64 [PR 93421]
As discussed in the PR, it's incredibly unlikely that a system that
needs to use the SYS_clock_gettime syscall (e.g. glibc 2.16 or older) is
going to define the SYS_clock_gettime64 macro. Ancient systems that need
to use the syscall aren't going to have time64 support.

This reverts the recent changes to try and make clock_gettime syscalls
be compatible with systems that have been updated for time64 (those
changes were wrong anyway as they misspelled the SYS_clock_gettime64
macro). The changes for futex syscalls are retained, because we still
use them on modern systems that might be using time64.

To ensure that the clock_gettime syscalls are safe, configure will fail
if SYS_clock_gettime is needed, and SYS_clock_gettime64 is also defined
(but to a distinct value from SYS_clock_gettime), and the tv_sec member
of timespec is larger than long. This means we will be unable to build
on a hypothetical system where we need the time32 version of
SYS_clock_gettime but where userspace is using a time64 struct timespec.
In the unlikely event that this failure is triggered on any real
systems, we can fix it later. But we probably won't need to.

libstdc++-v3/ChangeLog:

	PR libstdc++/93421
	* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Fail if struct
	timespec isn't compatible with SYS_clock_gettime.
	* configure: Regenerate.
	* src/c++11/chrono.cc: Revert changes for time64 compatibility.
	Add static_assert instead.
	* src/c++11/futex.cc (_M_futex_wait_until_steady): Assume
	SYS_clock_gettime can use struct timespec.
2020-11-17 22:38:49 +00:00
Sebastian Pop
61ef34c503 add --with-{cpu,arch,tune}-{32,64} as alias flags for --with-{cpu,arch,tune}
gcc/
	* config.gcc: add configure flags --with-{cpu,arch,tune}-{32,64}
	as alias flags for --with-{cpu,arch,tune} on AArch64.
	* doc/install.texi: Document new flags for aarch64.
2020-11-17 22:16:04 +00:00
Sebastian Pop
04dedd1814 add --with-tune configure flag
fixes a configure error on Arm64 when passing --with-tune=... to configure:
```
This target does not support --with-tune.
Valid --with options are: abi cpu arch
```
The missing flag sets target tuning to a different value than generic tuning.

gcc/
	* config.gcc: Add --with-tune to AArch64 configure flags.
2020-11-17 22:16:03 +00:00
Andrew MacLeod
1e27e7a582 recognize implied ranges for modulo.
implement op1_range for modulo with implied positive and negative ranges.

	gcc/
	PR tree-optimization/91029
	* range-op.cc (operator_trunc_mod::op1_range): New.
	gcc/testsuite/
	* gcc.dg/pr91029.c: New.
2020-11-17 16:59:48 -05:00
Jan Hubicka
0c1db9fa47 Fix ipa-icf ICE on variadic types
* ipa-icf.c (sem_function::hash_stmt): Fix conditional on
	variably_modified_type_p.
2020-11-17 22:56:29 +01:00
Nathan Sidwell
d3ae802402 extend cache_integer_cst
This modules-related patch extends cache_integer_cst.  Currently, when
given a small cst, that cst is added to the type's small and /must
not/ already be there.  Large values are fine if they are already in
the large cache.  This adds a parameter to indicate small duplicates
are ok, and it returns the cached value -- either what was already
tehre, or the newly inserted const.

	gcc/
	* tree.h (cache_integer_cst): Add defaulted might_duplicate parm.
	* tree.c (cache_integer_cst): Return the integer cst, add
	might_duplicate parm to permit finding a small duplicate.
2020-11-17 13:28:08 -08:00
Nathan Sidwell
e0da4aed17 c++: duplicate block-scope extern [PR 97877]
We ICED with a duplicated block-scope extern, as duplicate_decls was
dropping the decl_lang_specific of olddecl.  Simplys adding
appropriate retrofitting and copying turned out to be insufficient
because you can get a block-scope using decl also matching the extern.
The latter seems a little suspicious and I have asked CWG for advice.
While there robustified the assert about releasing olddecls'
lang-specific -- if it had one, the new decl better have one.

	PR c++/97877
	gcc/cp/
	* decl.c (duplicate_decls): Deal with duplicated DECL_LOCAL_DECL_P
	decls.  Extend decl_lang_specific checking assert.
	gcc/testsuite/
	* g++.dg/lookup/pr97877.C: New.
2020-11-17 13:28:08 -08:00
Nathan Sidwell
066c89d1e1 global trees
This reorders the common and c++ global tree arrays.  It introduces a
module-specific High Water Mark, below which are the immutable slots
initialized at startup and beyond which are the lazily filled slots
(and a few immutables we need to locate by name lookup anyway).

	gcc/c-family/
	* c-common.h (enum c_tree_index): Reorder to place lazy fields
	after newly-added CTI_MODULE_HWM.
	gcc/cp/
	* cp-tree.h (enum cp_tree_index): Reorder to place lazy fields
	after newly-added CPTI_MODULE_HWM.
2020-11-17 13:28:07 -08:00
Harald Anlauf
c49f56adcb Fortran texi: Fix description of GFC_RTCHECK_* macros.
gcc/fortran/ChangeLog:

	* gfortran.texi: Fix description of GFC_RTCHECK_* to match actual
	code.
2020-11-17 22:26:26 +01:00
Andrew MacLeod
a5f9c27bfc IOR with nonzero, range cannot contain 0.
Remove zero from IOR ranges with non-zero masks.

	gcc/
	PR tree-optimization/83072
	* range-op.cc (wi_optimize_and_or): Remove zero from IOR range when
	mask is non-zero.
	gcc/testsuite/
	* gcc.dg/pr83072.c: New.
2020-11-17 11:58:07 -05:00
Iain Sandoe
c2cf58f0e3 C++ : Remove an overzealous checking assert [PR97871]
It seems we accept __attribute__(()) without any diagnostic at present,
so my added checking assert fires for something like:

__attribute__ (()) int a;

Fixed by removing the assert; in the case that the user enters something
like:

__attribute__ (()) extern "C" int foo;

The diagnostic about attributes before linkage specs will fire and show
the empty attributes.

gcc/cp/ChangeLog:

	PR c++/97871
	* parser.c (cp_parser_declaration): Remove checking assert.
2020-11-17 16:54:33 +00:00
Joseph Myers
1ffd8e34d1 float.h: Handle C2x __STDC_WANT_IEC_60559_EXT__
TS 18661-1 and 18661-2 have various definitions conditional on
__STDC_WANT_IEC_60559_BFP_EXT__ and __STDC_WANT_IEC_60559_DFP_EXT__
macros.  When those TSes were integrated into C2x, most of the feature
test macro conditionals were removed (with declarations for decimal FP
becoming conditional only on whether decimal FP is supported by the
implementation and those for binary FP becoming unconditionally
required).

A few tests of those feature test macros remained for declarations
that appeared only in Annex F and not in the main part of the
standard.  A change accepted for C2x at the last WG14 meeting (but not
yet added to the working draft in git) was to replace both those
macros by __STDC_WANT_IEC_60559_EXT__; if __STDC_WANT_IEC_60559_EXT__
is defined, the specific declarations in the headers will then depend
on which features are supported by the implementation, as for
declarations not controlled by a feature test macro at all.

Thus, add a check of __STDC_WANT_IEC_60559_EXT__ for CR_DECIMAL_DIG in
float.h, the only case of this change relevant to GCC.

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

gcc/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

	* ginclude/float.h (CR_DECIMAL_DIG): Also define for
	[__STDC_WANT_IEC_60559_EXT__].

gcc/testsuite/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

	* gcc.dg/cr-decimal-dig-3.c: New test.
2020-11-17 16:30:35 +00:00
Joseph Myers
ac30c8b8d0 float.h: C2x *_IS_IEC_60559 macros
C2x adds float.h macros that say whether float, double and long double
match an IEC 60559 (IEEE 754) format and operations.  Add these
macros to GCC's float.h.

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

gcc/c-family/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

	* c-cppbuiltin.c (builtin_define_float_constants): Define
	"*_IS_IEC_60559__" macros.

gcc/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

	* ginclude/float.h [__STDC_VERSION__ > 201710L] (FLT_IS_IEC_60559,
	DBL_IS_IEC_60559, LDBL_IS_IEC_60559): New macros.

gcc/testsuite/
2020-11-17  Joseph Myers  <joseph@codesourcery.com>

	* gcc.dg/c11-float-6.c, gcc.dg/c2x-float-10.c: New tests.
2020-11-17 16:28:11 +00:00
David Edelsohn
8895913273 testsuite: allow opd section
PPC64 Linux ELFv1 uses function descriptors with the descriptor
placed in the .opd section.  This patch expands the pattern in the testcase
to accept .opd section name associated with the function name.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr25376.c: Allow .opd section.
2020-11-17 11:28:23 -05:00
Nathan Sidwell
b196e76aec preprocessor: new callbacks
These two callbacks are needed for C++ modules.  The first is for
handling macros from header-units.  These are resolved lazily.  The
second is for include-translation -- whether a #include gets turned
into a header-unit import.

	libcpp/
	* include/cpplib.h (struct cpp_callbacks): Add
	user_deferred_macro & translate_include.
2020-11-17 08:22:02 -08:00
Jonathan Wakely
ecf65330c1 libstdc++: Fix unconditional definition of __cpp_lib_span in <version> [PR 97869}
The <span> header is empty unless Concepts are supported, but <version>
defines the __cpp_lib_span feature test macro unconditionally. It should
be guarded by the same conditions as in <span>.

libstdc++-v3/ChangeLog:

	PR libstdc++/97869
	* include/precompiled/stdc++.h: Include <coroutine>.
	* include/std/version (__cpp_lib_span): Check __cpp_lib_concepts
	before defining.
2020-11-17 16:13:14 +00:00