Commit graph

179498 commits

Author SHA1 Message Date
Andrea Corallo
4ecc0061c4 libgccjit: Add new gcc_jit_global_set_initializer entry point
gcc/jit/ChangeLog

2020-08-01  Andrea Corallo  <andrea.corallo@arm.com>

	* docs/topics/compatibility.rst (LIBGCCJIT_ABI_14): New ABI tag.
	* docs/topics/expressions.rst (gcc_jit_global_set_initializer):
	Document new entry point in section 'Global variables'.
	* jit-playback.c (global_new_decl, global_finalize_lvalue): New
	method.
	(playback::context::new_global): Make use of global_new_decl,
	global_finalize_lvalue.
	(load_blob_in_ctor): New template function in use by the
	following.
	(playback::context::new_global_initialized): New method.
	* jit-playback.h (class context): Decl 'new_global_initialized',
	'global_new_decl', 'global_finalize_lvalue'.
	(lvalue::set_initializer): Add implementation.
	* jit-recording.c (recording::memento_of_get_pointer::get_size)
	(recording::memento_of_get_type::get_size): Add implementation.
	(recording::global::write_initializer_reproducer): New function in
	use by 'recording::global::write_reproducer'.
	(recording::global::replay_into)
	(recording::global::write_to_dump)
	(recording::global::write_reproducer): Handle
	initialized case.
	* jit-recording.h (class type): Decl 'get_size' and
	'num_elements'.
	* libgccjit++.h (class lvalue): Declare new 'set_initializer'
	method.
	(class lvalue): Decl 'is_global' and 'set_initializer'.
	(class global) Decl 'write_initializer_reproducer'. Add
	'm_initializer', 'm_initializer_num_bytes' fields.  Implement
	'set_initializer'. Add a destructor to free 'm_initializer'.
	* libgccjit.c (gcc_jit_global_set_initializer): New function.
	* libgccjit.h (gcc_jit_global_set_initializer): New function
	declaration.
	* libgccjit.map (LIBGCCJIT_ABI_14): New ABI tag.

gcc/testsuite/ChangeLog

2020-08-01  Andrea Corallo  <andrea.corallo@arm.com>

	* jit.dg/all-non-failing-tests.h: Add test-blob.c.
	* jit.dg/test-global-set-initializer.c: New testcase.
2020-09-11 12:18:59 +02:00
Tom de Vries
1554556312 [libatomic] Add nvptx support
Add nvptx support to libatomic.

Given that atomic_test_and_set is not implemented for nvptx (PR96964), the
compiler translates __atomic_test_and_set falling back onto the "Failing all
else, assume a single threaded environment and simply perform the operation"
case in expand_atomic_test_and_set, so it doesn't map onto an actual atomic
operation.

Still, that counts as supported for the configure test of libatomic, so we
end up with HAVE_ATOMIC_TAS_1/2/4/8/16 == 1, and the corresponding
__atomic_test_and_set_1/2/4/8/16 in libatomic all using that non-atomic
implementation.

Fix this by adding an atomic_test_and_set expansion for nvptx, that uses
libatomics __atomic_test_and_set_1.

This again makes the configure tests for HAVE_ATOMIC_TAS_1/2/4/8/16 fail, so
instead we use this case in tas_n.c:
...
/* If this type is smaller than word-sized, fall back to a word-sized
   compare-and-swap loop.  */
bool
SIZE(libat_test_and_set) (UTYPE *mptr, int smodel)
...
which for __atomic_test_and_set_8 uses INVERT_MASK_8.

Add INVERT_MASK_8 in libatomic_i.h, as well as MASK_8.

Tested libatomic testsuite on nvptx.

gcc/ChangeLog:

	PR target/96964
	* config/nvptx/nvptx.md (define_expand "atomic_test_and_set"): New
	expansion.

libatomic/ChangeLog:

	PR target/96898
	* configure.tgt: Add nvptx.
	* libatomic_i.h (MASK_8, INVERT_MASK_8): New macro definition.
	* config/nvptx/host-config.h: New file.
	* config/nvptx/lock.c: New file.
2020-09-11 12:06:15 +02:00
Andrew Stubbs
8ae0de5621 amdgcn: align TImode registers
This prevents execution failures caused by partially overlapping input and
output registers.  This is the same solution already used for DImode.

gcc/ChangeLog:

	* config/gcn/gcn.c (gcn_hard_regno_mode_ok): Align TImode registers.
	* config/gcn/gcn.md: Assert that TImode registers do not early clobber.
2020-09-11 10:55:32 +01:00
Richard Biener
054fc495fa improve BB vectorization dump locations
This tries to improve BB vectorization dumps by providing more
precise locations.  Currently the vect_location is simply the
very last stmt in a basic-block that has a location.  So for

double a[4], b[4];
int x[4], y[4];
void foo()
{
  a[0] = b[0]; // line 5
  a[1] = b[1];
  a[2] = b[2];
  a[3] = b[3];
  x[0] = y[0]; // line 9
  x[1] = y[1];
  x[2] = y[2];
  x[3] = y[3];
} // line 13

we show the user with -O3 -fopt-info-vec

t.c:13:1: optimized: basic block part vectorized using 16 byte vectors

while with the patch we point to both independently vectorized
opportunities:

t.c:5:8: optimized: basic block part vectorized using 16 byte vectors
t.c:9:8: optimized: basic block part vectorized using 16 byte vectors

there's the possibility that the location regresses in case the
root stmt in the SLP instance has no location.  For a SLP subgraph
with multiple entries the location also chooses one entry at random,
not sure in which case we want to dump both.

Still as the plan is to extend the basic-block vectorization
scope from single basic-block to multiple ones this is a first
step to preserve something sensible.

Implementation-wise this makes both costing and code-generation
happen on the subgraphs as analyzed.

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

	* tree-vectorizer.h (_slp_instance::location): New method.
	(vect_schedule_slp): Adjust prototype.
	* tree-vectorizer.c (vec_info::remove_stmt): Adjust
	the BB region begin if we removed the stmt it points to.
	* tree-vect-loop.c (vect_transform_loop): Adjust.
	* tree-vect-slp.c (_slp_instance::location): Implement.
	(vect_analyze_slp_instance): For BB vectorization set
	vect_location to that of the instance.
	(vect_slp_analyze_operations): Likewise.
	(vect_bb_vectorization_profitable_p): Remove wrapper.
	(vect_slp_analyze_bb_1): Remove cost check here.
	(vect_slp_region): Cost check and code generate subgraphs separately,
	report optimized locations and missed optimizations due to
	profitability for each of them.
	(vect_schedule_slp): Get the vector of SLP graph entries to
	vectorize as argument.
2020-09-11 11:29:18 +02:00
Eric Botcazou
ef4ab841d9 Fix ICE on nested packed variant record type
This is a regression present on the mainline and 10 branch: the compiler
aborts on code accessing a component of a packed record type whose type
is a packed discriminated record type with variant part.

gcc/ada/ChangeLog:
	* gcc-interface/utils.c (type_has_variable_size): New function.
	(create_field_decl): In the packed case, also force byte alignment
	when the type of the field has variable size.

gcc/testsuite/ChangeLog:
	* gnat.dg/pack27.adb: New test.
	* gnat.dg/pack27_pkg.ads: New helper.
2020-09-11 11:14:49 +02:00
Eric Botcazou
b5ffd55a61 Add missing stride entry in debug info
This adds a missing stride entry for bit-packed arrays of record types.

gcc/ada/ChangeLog:
	* gcc-interface/misc.c (get_array_bit_stride): Return TYPE_ADA_SIZE
	for record and union types.
2020-09-11 11:13:54 +02:00
Eric Botcazou
230e0dbdcb Drop GNAT encodings for fixed-point types
GDB can now deal with the DWARF representation just fine.

gcc/ada/ChangeLog:
	* gcc-interface/misc.c (gnat_get_fixed_point_type): Bail out only
	when the GNAT encodings are specifically used.
2020-09-11 11:13:16 +02:00
Eric Botcazou
7c919c12be Fix crash on array component with nonstandard index type
This is a regression present on mainline, 10 and 9 branches: the compiler
goes into an infinite recursion eventually exhausting the stack for the
declaration of a discriminated record type with an array component having
a discriminant as bound and an index type that is an enumeration type with
a non-standard representation clause.

gcc/ada/ChangeLog:
	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Subtype>: Only
	create extra subtypes for discriminants if the RM size of the base
	type of the index type is lower than that of the index type.

gcc/testsuite/ChangeLog:
	* gnat.dg/specs/discr7.ads: New test.
2020-09-11 10:43:38 +02:00
Eric Botcazou
e898facaf3 Adjust email address 2020-09-11 10:16:17 +02:00
Eric Botcazou
a82c4c4cef Adjust email address 2020-09-11 10:12:28 +02:00
Eric Botcazou
dedf9ebc89 Adjust email address 2020-09-11 10:09:59 +02:00
Richard Biener
a9c960a3bd tree-optimization/97013 - avoid duplicate 'vectorization is not profitable'
This avoids dumping 'vectorization is not profitable' one more time
if none of the opportunities in a BB is profitable.

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

	PR tree-optimization/97013
	* tree-vect-slp.c (vect_slp_analyze_bb_1): Remove duplicate dumping.
2020-09-11 09:01:25 +02:00
Richard Biener
563326b5e4 random vectorizer fixes
This fixes random things found when doing SLP discovery from
arbitrary sets of stmts.

2020-09-10  Richard Biener  <rguenther@suse.de>

	* tree-vect-slp.c (vect_build_slp_tree_1): Check vector
	types for all lanes are compatible.
	(vect_analyze_slp_instance): Appropriately check for stores.
	(vect_schedule_slp): Likewise.
2020-09-11 08:10:38 +02:00
Tom de Vries
5e044c673f [nvptx] Fix UB in nvptx_assemble_value
When nvptx_assemble_value is called with size == 16, this bitshift runs
into UB:
...
  val &= ((unsigned  HOST_WIDE_INT)2 << (size * BITS_PER_UNIT - 1)) - 1;
...

Fix this by checking the shift amount.

Tested on nvptx.

gcc/ChangeLog:

	* config/nvptx/nvptx.c (nvptx_assemble_value): Fix undefined
	behaviour.
2020-09-11 07:27:56 +02:00
Tom de Vries
60e537a026 [nvptx] Fix printing of 128-bit constant (negative case)
For this code:
...
__int128 min_one = -1;
...
we currently generate:
...
.visible .global .align 8 .u64 min_one[2] = { -1, 0 };
...

Fix this in nvptx_assemble_value, such that we have instead:
...
.visible .global .align 8 .u64 min_one[2] = { -1, -1 };
...

gcc/ChangeLog:

	* config/nvptx/nvptx.c (nvptx_assemble_value): Handle negative
	__int128.

gcc/testsuite/ChangeLog:

	* gcc.target/nvptx/int128.c: New test.
2020-09-11 07:27:54 +02:00
Aaron Sawdey
848e74bea1 [PATCH][PR96791] disable POImode ld/st for memcpy
This is a (hopefully temporary) fix to PR96791. This will make
the default be -mno-block-ops-vector-pair even on power10, so we will
not hit the issue of DSE trying to truncate a POImode register. I am
still concerned it will be possible to hit this because the MMA builtins
will also generate POImode stores, but I think any example of that will
be somewhat more contrived.

gcc/ChangeLog:

	* config/rs6000/rs6000.c (rs6000_option_override_internal):
	Change default.
2020-09-10 21:13:38 -05:00
David Malcolm
b7028f060c analyzer: stricter handling of non-pure builtins [PR96798]
Amongst other things PR analyzer/96798 notes that
region_model::on_call_pre treats any builtin that hasn't been coded
yet as a no-op (albeit with an unknown return value), which is wrong
for non-pure builtins.

This patch updates that function's handling of such builtins so that it
instead conservatively assumes that any escaped/reachable regions can
be affected by the call, and implements enough handling of specific
builtins to avoid regressing the testsuite (I hope).

gcc/analyzer/ChangeLog:
	PR analyzer/96798
	* region-model-impl-calls.cc (region_model::impl_call_memcpy):
	New.
	(region_model::impl_call_strcpy): New.
	* region-model.cc (region_model::on_call_pre): Flag unhandled
	builtins that are non-pure as having unknown side-effects.
	Implement BUILT_IN_MEMCPY, BUILT_IN_MEMCPY_CHK, BUILT_IN_STRCPY,
	BUILT_IN_STRCPY_CHK, BUILT_IN_FPRINTF, BUILT_IN_FPRINTF_UNLOCKED,
	BUILT_IN_PUTC, BUILT_IN_PUTC_UNLOCKED, BUILT_IN_FPUTC,
	BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS, BUILT_IN_FPUTS_UNLOCKED,
	BUILT_IN_FWRITE, BUILT_IN_FWRITE_UNLOCKED, BUILT_IN_PRINTF,
	BUILT_IN_PRINTF_UNLOCKED, BUILT_IN_PUTCHAR,
	BUILT_IN_PUTCHAR_UNLOCKED, BUILT_IN_PUTS, BUILT_IN_PUTS_UNLOCKED,
	BUILT_IN_VFPRINTF, BUILT_IN_VPRINTF.
	* region-model.h (region_model::impl_call_memcpy): New decl.
	(region_model::impl_call_strcpy): New decl.

gcc/testsuite/ChangeLog:
	PR analyzer/96798
	* gcc.dg/analyzer/memcpy-1.c: New test.
	* gcc.dg/analyzer/strcpy-1.c: New test.
2020-09-10 21:08:09 -04:00
GCC Administrator
fdcc0283c6 Daily bump. 2020-09-11 00:16:28 +00:00
Michael Meissner
aa53f657aa PowerPC: Change cmove function return to bool.
In doing the other work for adding ISA 3.1 128-bit minimum, maximum, and
conditional move support, I noticed the two functions that process conditional
moves return 'int' instead of 'bool'.  This patch changes these functions to
return 'bool'.

gcc/
2020-09-10  Michael Meissner  <meissner@linux.ibm.com>

	* config/rs6000/rs6000-protos.h (rs6000_emit_cmove): Change return
	type to bool.
	(rs6000_emit_int_cmove): Change return type to bool.
	* config/rs6000/rs6000.c (rs6000_emit_cmove): Change return type
	to bool.
	(rs6000_emit_int_cmove): Change return type to bool.
2020-09-10 19:11:45 -04:00
Tom de Vries
af47a2035a [nvptx] Fix printing of 128-bit constant
Currently, for this code from c-c++-common/spec-barrier-1.c:
...
__int128 g = 9;
...
we generate:
...
// BEGIN GLOBAL VAR DEF: g
.visible .global .align 8 .u64 g[2] = { 9, 9 };
...
and consequently the test-case fails in execution.

The problem is caused by a shift in nvptx_assemble_value:
...
      val >>= part * BITS_PER_UNIT;
...
where the shift amount is equal to the number of bits in val, which is
undefined behaviour.

Fix this by detecting the situation and setting val to 0.

Tested on nvptx.

gcc/ChangeLog:

	PR target/97004
	* config/nvptx/nvptx.c (nvptx_assemble_value): Handle shift by
	number of bits in shift operand.
2020-09-10 21:30:33 +02:00
Jakub Jelinek
a8f9b4c54c lto: Fix up lto BLOCK tree streaming
When I've tried to backport recent LTO changes of mine, I've ran into
FAIL: g++.dg/ubsan/align-3.C   -O2 -flto -fno-use-linker-plugin -flto-partition=none  output pattern test
FAIL: g++.dg/ubsan/align-3.C   -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  output pattern test
regressions that don't for some reason show up on the trunk.

I've tracked it down to input_location_and_block being called recursively,
first on some UBSAN_NULL ifn call's location which needs to stream a BLOCK
that hasn't been streamed yet, which in turn needs to stream some locations
for the decls in the BLOCK.

Looking at that align-3.C testcase on the trunk, I also see the recursive
lto_output_location_1 calls as well.  First on block:
$18 = <block 0x7fffea738480>
which is in the block tree from what I can see just fine (see the end of
mail).

Now, output_function has code that should stream the BLOCK tree leafs:
  /* Output DECL_INITIAL for the function, which contains the tree of
     lexical scopes.  */
  stream_write_tree (ob, DECL_INITIAL (function), true);
  /* As we do not recurse into BLOCK_SUBBLOCKS but only BLOCK_SUPERCONTEXT
     collect block tree leafs and stream those.  */
  auto_vec<tree> block_tree_leafs;
  if (DECL_INITIAL (function))
    collect_block_tree_leafs (DECL_INITIAL (function), block_tree_leafs);
  streamer_write_uhwi (ob, block_tree_leafs.length ());
  for (unsigned i = 0; i < block_tree_leafs.length (); ++i)
    stream_write_tree (ob, block_tree_leafs[i], true);

static void
collect_block_tree_leafs (tree root, vec<tree> &leafs)
{
  for (root = BLOCK_SUBBLOCKS (root); root; root = BLOCK_CHAIN (root))
    if (! BLOCK_SUBBLOCKS (root))
      leafs.safe_push (root);
    else
      collect_block_tree_leafs (BLOCK_SUBBLOCKS (root), leafs);
}

but the problem is that it is broken, it doesn't cover all block leafs,
but only leafs with an odd depth from DECL_INITIAL (and only some of those).

The following patch fixes that, but I guess we are going to stream at that
point significantly more blocks than before (though I guess most of the time
we'd stream them later on when streaming the gimple_locations that refer to
them).

2020-09-10  Jakub Jelinek  <jakub@redhat.com>

	* lto-streamer-out.c (collect_block_tree_leafs): Recurse on
	root rather than BLOCK_SUBBLOCKS (root).
2020-09-10 20:55:46 +02:00
Jonathan Wakely
1d5589d11e libstdc++: Fix -Wsign-compare warnings
libstdc++-v3/ChangeLog:

	* include/bits/locale_conv.h (__do_str_codecvt, __str_codecvt_in_all):
	Add casts to compare types of the same signedness.
2020-09-10 18:57:39 +01:00
Jonathan Wakely
866c53cb2e libstdc++: Fix -Wunused-local-typedefs warning
libstdc++-v3/ChangeLog:

	* include/bits/ranges_algobase.h (__equal_fn): Remove unused
	typedef.
2020-09-10 18:57:05 +01:00
Jonathan Wakely
f903c13ce8 libstdc++: Fix macro redefinition warnings
Including <version> after <iterator> gives a warning about redefining
the __cpp_lib_array_constexpr macro. What happens is that <iterator>
sets the C++20 value, then <version> redefines it to the C++17 value,
then undefines it and defines it again to the C++20 value.

This change avoids defining it to the C++17 value when compiling C++20
or later (which also means we no longer need the #undef).

A similar warning happens for __cpp_lib_constexpr_char_traits when
including <version> after any header that includes <bits/char_traits.h>.

libstdc++-v3/ChangeLog:

	* include/std/version (__cpp_lib_array_constexpr):
	(__cpp_lib_constexpr_char_traits): Only define C++17 value when
	compiling C++17.
2020-09-10 18:51:24 +01:00
Jonathan Wakely
0943b55817 libstdc++: Fix -Wdeprecated-declarations warnings
libstdc++-v3/ChangeLog:

	* include/experimental/bits/shared_ptr.h (shared_ptr(auto_ptr&&))
	(operator=(auto_ptr&&)): Add diagnostic pragmas to suppress
	warnings for uses of std::auto_ptr.
	* include/experimental/type_traits (is_literal_type_v):
	Likewise, for use of std::is_literal_type.
	* include/std/condition_variable (condition_variable_any::_Unlock):
	Likewise, for use of std::uncaught_exception.
2020-09-10 18:48:25 +01:00
Jonathan Wakely
b6b9fd4af9 libstdc++: Fix -Wnarrowing warnings
libstdc++-v3/ChangeLog:

	* include/bits/fs_path.h (path::_List::type()): Avoid narrowing
	conversion.
	* include/std/chrono (operator+(const year&, const years&)):
	Likewise.
2020-09-10 18:47:08 +01:00
Nathan Sidwell
f9189e1088 c++: TINFO_VAR_DECLARED_CONSTINIT -> DECL_DECLARED_CONSTINIT_P
We need to record whether template function-scopestatic decls are
constinit.  That's currently held on the var's TEMPLATE_INFO data.
But I want to get rid of such decl's template header as they're not
really templates, and they're never instantiated separately from their
containing function's definition.  (Just like auto vars, which don't
get them for instance).

This patch moves the flag into a spare decl_lang_flag.

	gcc/cp/
	* cp-tree.h (TINFO_VAR_DECLARED_CONSTINIT): Replace with ...
	(DECL_DECLARED_CONSTINIT_P): ... this.
	* decl.c (start_decl): No need to retrofit_lang_decl for constinit
	flag.
	(cp_finish_decl): Use DECL_DECLARED_CONSTINIT_P.
	* pt.c (tsubst_decl): No need to handle constinit flag
	propagation.
	(tsubst_expr): Or here.
2020-09-10 09:37:37 -07:00
Alex Coplan
1c68cf348a aarch64: Add support for Cortex-R82
This adds support for Arm's Cortex-R82 CPU to GCC. For more information about
this CPU, see [0].

[0] : https://developer.arm.com/ip-products/processors/cortex-r/cortex-r82

gcc/ChangeLog:

	* config/aarch64/aarch64-cores.def: Add Cortex-R82.
	* config/aarch64/aarch64-tune.md: Regenerate.
	* doc/invoke.texi: Add entry for Cortex-R82.
2020-09-10 17:10:37 +01:00
Alex Coplan
786177a3fc aarch64: Add support for Armv8-R
This adds support for Armv8-R AArch64 to GCC. It adds the -march value
armv8-r and sets the ACLE feature macro __ARM_ARCH_PROFILE correctly
when -march is set to armv8-r.

gcc/ChangeLog:

	* common/config/aarch64/aarch64-common.c
	(aarch64_get_extension_string_for_isa_flags): Don't force +crc for
	Armv8-R.
	* config/aarch64/aarch64-arches.def: Add entry for Armv8-R.
	* config/aarch64/aarch64-c.c (aarch64_define_unconditional_macros): Set
	__ARM_ARCH_PROFILE correctly for Armv8-R.
	* config/aarch64/aarch64.h (AARCH64_FL_V8_R): New.
	(AARCH64_FL_FOR_ARCH8_R): New.
	(AARCH64_ISA_V8_R): New.
	* doc/invoke.texi: Add Armv8-R to architecture table.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/acle/armv8-r.c: New test.
2020-09-10 17:10:31 +01:00
Jonathan Wakely
36efcd7de0 libstdc++: Fix some -Wunused-parameter warnings
libstdc++-v3/ChangeLog:

	* include/bits/codecvt.h (codecvt_byname): Remove names of
	unused parameters.
2020-09-10 17:09:16 +01:00
Jonathan Wakely
b84b132e38 libstdc++: Clean up inconsistent whitespace
libstdc++-v3/ChangeLog:

	* include/bits/locale_facets_nonio.tcc: Adjust whitespace.
2020-09-10 17:09:16 +01:00
Krystian Kuźniarek
ef8b4335d9 libstdc++: Add parentheses around assignments used as truth values
libstdc++-v3/ChangeLog:

	* include/c_global/cmath (__lerp): Avoid -Wparentheses warnings.
2020-09-10 17:09:16 +01:00
Krystian Kuźniarek
2b4cc19bd5 libstdc++: Add unused attributes to suppress warnings
libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h: Fix -Wunused-variable
	warnings.
	* include/ext/new_allocator.h: Fix -Wunused-parameter
	warnings.
2020-09-10 17:09:15 +01:00
Jonathan Wakely
afea21f961 libstdc++: Enforce LWG 3472 preconditions on std::counted_iterator
libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (counted_iterator): Add assertions
	to check preconditions added by LWG 3472.
2020-09-10 17:09:15 +01:00
Iain Buclaw
0ed757604f libphobos: libdruntime doesn't support shadow stack (PR95680)
The first implementation hit a front-end implementation bug where
version conditions are resolved ahead of static if confitions.

The logic for whether to use asm implemented fiber_switchContext or
libc's swapcontext has been moved from GNU_Enable_CET to version CET.

libphobos/ChangeLog:

	PR d/95680
	PR d/97007
	* Makefile.am (AM_MAKEFLAGS): Remove $(CET_FLAGS).
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac (DCFG_ENABLE_CET): Remove substitution.
	(CET_DFLAGS): Substitute.
	* libdruntime/Makefile.am (AM_DFLAGS): Add $(CET_DFLAGS).
	(AM_CFLAGS): Add $(CET_FLAGS).
	(AM_CCASFLAGS): Likewise.
	* libdruntime/Makefile.in: Regenerate.
	* libdruntime/core/thread.d: Replace static if GNU_Enable_CET
	condition with `version (CET)'.
	* libdruntime/gcc/config.d.in (GNU_Enable_CET): Remove.
	* src/Makefile.am (AM_DFLAGS): Add $(CET_DFLAGS).
	(AM_CFLAGS): Add $(CET_FLAGS).
	* src/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/testsuite_flags.in: Add $(CET_DFLAGS) to --gdcflags.
2020-09-10 18:04:12 +02:00
Iain Buclaw
ead85749b0 d: Enable miscellaneous warnings by -Wextra flag
These warnings are handled outside of the D core language front-end, so
shouldn't be enabled by -Wall.

gcc/d/ChangeLog:

	* lang.opt (Waddress): Enable warning by -Wextra.
	(Wcast-result): Likewise.
	(Wunknown-pragmas): Likewise.
2020-09-10 18:04:11 +02:00
Iain Buclaw
27f698bde9 d: Don't warn about variables initialized with 'void'
There is no problem with using `T var = void', it is if the variable
remains uninitialized on first use that a warning should be issued.

gcc/d/ChangeLog:

	* decl.cc (DeclVisitor::visit (VarDeclaration *)): Don't warn about
	variables initialized with 'void'.
2020-09-10 18:04:11 +02:00
Iain Buclaw
29ff25e706 d: Warn when casting from a D class to a C++ class.
Before, the warning was only issued when casting in the other direction.
Now a warning is printed for both directions.

gcc/d/ChangeLog:

	* d-convert.cc (convert_expr): Warn when casting from a D class to a
	C++ class.

gcc/testsuite/ChangeLog:

	* gdc.dg/Waddress.d: New test.
	* gdc.dg/Wcastresult1.d: New test.
	* gdc.dg/Wcastresult2.d: New test.
2020-09-10 18:04:11 +02:00
Eric Botcazou
e63eb26d22 Fix bogus error on Value_Size clause for variant record type
This is a regression present on the mainline and 10 branch: the compiler
rejects a Value_Size clause on a discriminated record type with variant.

gcc/ada/ChangeLog:
	* gcc-interface/decl.c (set_rm_size): Do not take into account the
	Value_Size clause if it is not for the entity itself.

gcc/testsuite/ChangeLog:
	* gnat.dg/specs/size_clause5.ads: New test.
2020-09-10 18:00:57 +02:00
Eric Botcazou
71465223b9 Fix uninitialized variable with nested variant record types
This fixes a wrong code issue with nested variant record types: the
compiler generates move instructions that depend on an uninitialized
variable, which was initially a SAVE_EXPR not instantiated early enough.

gcc/ada/ChangeLog:
	* gcc-interface/decl.c (build_subst_list): For a definition, make
	sure to instantiate the SAVE_EXPRs generated by the elaboration of
	the constraints in front of the elaboration of the type itself.

gcc/testsuite/ChangeLog:
	* gnat.dg/discr59.adb: New test.
	* gnat.dg/discr59_pkg1.ads: New helper.
	* gnat.dg/discr59_pkg2.ads: Likewise.
2020-09-10 18:00:57 +02:00
Eric Botcazou
66a204a656 Add emergency dump after an ICE
This is only for internal debugging purposes.

gcc/ada/ChangeLog:
	* gcc-interface/misc.c: Include tree-pass.h.
	(internal_error_function): Call emergency_dump_function.
2020-09-10 18:00:57 +02:00
Jakub Jelinek
d9b054d56b arm: Fix up arm_override_options_after_change_1
Looking further at arm_override_options_after_change_1, it also seems to be
incorrect, rather than testing
!opts->x_str_align_functions
it should be really testing
!opts_set->x_str_align_functions
and get &global_options_set or similar passed to it as additional opts_set
argument.  That is because otherwise the decision will be sticky, while it
should be done whenever use provided -falign-functions but didn't provide
-falign-functions= (either on the command line, or through optimize
attribute or pragma).

Here is a fix for that (incremental change on top of the previous patch).

2020-09-10  Jakub Jelinek  <jakub@redhat.com>

	* config/arm/arm.c (arm_override_options_after_change_1): Add opts_set
	argument, test opts_set->x_str_align_functions rather than
	opts->x_str_align_functions.
	(arm_override_options_after_change, arm_option_override_internal,
	arm_set_current_function): Adjust callers.
2020-09-10 17:40:08 +02:00
Jakub Jelinek
57e113cf7c arm: Fix up arm_override_options_after_change [PR96939]
As mentioned in the PR, the testcase fails to link, because when set_cfun is
being called on the crc function, arm_override_options_after_change is
called from set_cfun -> invoke_set_current_function_hook:
      /* Change optimization options if needed.  */
      if (optimization_current_node != opts)
        {
          optimization_current_node = opts;
          cl_optimization_restore (&global_options, TREE_OPTIMIZATION (opts));
        }
and at that point target_option_default_node actually matches even the
current state of options, so this means armv7 (or whatever) arch is set as
arm_active_target, then
      targetm.set_current_function (fndecl);
is called later in that function, which because the crc function's
DECL_FUNCTION_SPECIFIC_TARGET is different from the current one will do:
  cl_target_option_restore (&global_options, TREE_TARGET_OPTION (new_tree));
which calls arm_option_restore and sets arm_active_target to armv8-a+crc
(so far so good).
Later arm_set_current_function calls:
  save_restore_target_globals (new_tree);
which in this case calls:
      /* Call target_reinit and save the state for TARGET_GLOBALS.  */
      TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
which because optimization_current_node != optimization_default_node
(the testcase is LTO, so all functions have their
DECL_FUNCTION_SPECIFIC_TARGET and TREE_OPTIMIZATION nodes) will call:
      cl_optimization_restore
        (&global_options,
         TREE_OPTIMIZATION (optimization_default_node));
and
      cl_optimization_restore (&global_options,
                               TREE_OPTIMIZATION (opts));
The problem is that these call arm_override_options_after_change again,
and that one uses the target_option_default_node as what to set the
arm_active_target to (i.e. back to armv7 or whatever, but not to the
armv8-a+crc that should be the active target for the crc function).
That means we then error on the builtin call in that function.

Now, the targetm.override_options_after_change hook is called always at the
end of cl_optimization_restore, i.e. when we change the Optimization marked
generic options.  So it seems unnecessary to call arm_configure_build_target
at that point (nothing it depends on changed), and additionally incorrect
(because it uses the target_option_default_node, rather than the current
set of options; we'd need to revert
https://gcc.gnu.org/legacy-ml/gcc-patches/2016-12/msg01390.html
otherwise so that it works again with global_options otherwise).
The options that arm_configure_build_target cares about will change only
during option parsing (which is where it is called already), or during
arm_set_current_function, where it is done during the
cl_target_option_restore.
Now, arm_override_options_after_change_1 wants to adjust the
str_align_functions, which depends on the current Optimization options (e.g.
optimize_size and flag_align_options and str_align_functions) as well as
the target options target_flags, so IMHO needs to be called both
when the Optimization options (possibly) change, i.e. from
the targetm.override_options_after_change hook, and from when the target
options change (set_current_function hook).

2020-09-10  Jakub Jelinek  <jakub@redhat.com>

	PR target/96939
	* config/arm/arm.c (arm_override_options_after_change): Don't call
	arm_configure_build_target here.
	(arm_set_current_function): Call arm_override_options_after_change_1
	at the end.

	* gcc.target/arm/lto/pr96939_0.c: New test.
	* gcc.target/arm/lto/pr96939_1.c: New file.
2020-09-10 17:39:00 +02:00
Pat Haugen
b0894ae0e7 Fix instruction types.
I noticed that some of the VSR<->GPR move instructions are not typed correctly. This patch fixes those instructions so that the scheduler treats them with the correct latency.

2020-09-10  Pat Haugen  <pthaugen@linux.ibm.com>

gcc/
	* config/rs6000/rs6000.md
	(lfiwzx, floatunssi<mode>2_lfiwzx, p8_mtvsrwz, p8_mtvsrd_sf): Fix insn
	type.
	* config/rs6000/vsx.md
	(vsx_concat_<mode>, vsx_splat_<mode>_reg, vsx_splat_v4sf): Likewise.
2020-09-10 10:00:35 -05:00
Jonathan Wakely
30b41cfbb2 libstdc++: handle small max_blocks_per_chunk in pool resources [PR 94160]
When a pool resource is constructed with max_blocks_per_chunk=1 it ends
up creating a pool with blocks_per_chunk=0 which means it never
allocates anything. Instead it returns null pointers, which should be
impossible.

To avoid this problem, round the max_blocks_per_chunk value to a
multiple of four, so it's never smaller than four.

libstdc++-v3/ChangeLog:

	PR libstdc++/94160
	* src/c++17/memory_resource.cc (munge_options): Round
	max_blocks_per_chunk to a multiple of four.
	(__pool_resource::_M_alloc_pools()): Simplify slightly.
	* testsuite/20_util/unsynchronized_pool_resource/allocate.cc:
	Check that valid pointers are returned when small values are
	used for max_blocks_per_chunk.
2020-09-10 15:42:09 +01:00
Jonathan Wakely
1e718ec51a libstdc++: Reduce monotonic_buffer_resource overallocation [PR 96942]
The primary reason for this change is to reduce the size of buffers
allocated by std::pmr::monotonic_buffer_resource. Previously, a new
buffer would always add the size of the linked list node (11 bytes) and
then round up to the next power of two. This results in a huge increase
if the expected size of the next buffer is already a power of two. For
example, if the resource is constructed with a desired initial size of
4096 the first buffer it allocates will be std::bit_ceil(4096+11) which
is 8192.  If the user has carefully selected the initial size to match
their expected memory requirements then allocating double that amount
wastes a lot of memory.

After this patch the allocated size will be rounded up to a 64-byte
boundary, instead of to a power of two. This means for an initial size
of 4096 only 4160 bytes get allocated.

Previously only the base-2 logarithm of the size was stored, which could
be stored in a single 8-bit integer. Now that the size isn't always a
power of two we need to use more bits to store it. As the size is always
a multiple of 64 the low six bits are not needed, and so we can use the
same approach that the pool resources already use of storing the base-2
logarithm of the alignment in the low bits that are not used for the
size. To avoid code duplication, a new aligned_size<N> helper class is
introduced by this patch, which is then used by both the pool resources'
big_block type and the monotonic_buffer_resource::_Chunk type.

Originally the big_block type used two bit-fields to store the size and
alignment in the space of a single size_t member. The aligned_size type
uses a single size_t member and uses masks and bitwise operations to
manipulate the size and alignment values. This results in better code
than the old version, because the bit-fields weren't optimally ordered
for little endian architectures, so the alignment was actually stored in
the high bits, not the unused low bits, requiring additional shifts to
calculate the values. Using bitwise operations directly avoids needing
to reorder the bit-fields depending on the endianness.

While adapting the _Chunk and big_block types to use aligned_size<N> I
also added checks for size overflows (technically, unsigned wraparound).
The memory resources now ensure that when they require an allocation
that is too large to represent in size_t they will request SIZE_MAX
bytes from the upstream resource, rather than requesting a small value
that results from wrapround. The testsuite is enhanced to verify this.

libstdc++-v3/ChangeLog:

	PR libstdc++/96942
	* include/std/memory_resource (monotonic_buffer_resource::do_allocate):
	Use __builtin_expect when checking if a new buffer needs to be
	allocated from the upstream resource, and for checks for edge
	cases like zero sized buffers and allocations.
	* src/c++17/memory_resource.cc (aligned_size): New class template.
	(aligned_ceil): New helper function to round up to a given
	alignment.
	(monotonic_buffer_resource::chunk): Replace _M_size and _M_align
	with an aligned_size member. Remove _M_canary member. Change _M_next
	to pointer instead of unaligned buffer.
	(monotonic_buffer_resource::chunk::allocate): Round up to multiple
	of 64 instead of to power of two. Check for size overflow. Remove
	redundant check for minimum required alignment.
	(monotonic_buffer_resource::chunk::release): Adjust for changes
	to data members.
	(monotonic_buffer_resource::_M_new_buffer): Use aligned_ceil.
	(big_block): Replace _M_size and _M_align with aligned_size
	member.
	(big_block::big_block): Check for size overflow.
	(big_block::size, big_block::align): Adjust to use aligned_size.
	(big_block::alloc_size): Use aligned_ceil.
	(munge_options): Use aligned_ceil.
	(__pool_resource::allocate): Use big_block::align for alignment.
	* testsuite/20_util/monotonic_buffer_resource/allocate.cc: Check
	upstream resource gets expected values for impossible sizes.
	* testsuite/20_util/unsynchronized_pool_resource/allocate.cc:
	Likewise. Adjust checks for expected alignment in existing test.
2020-09-10 15:41:53 +01:00
Nathan Sidwell
f40866967d c++: DECL_LOCAL_FUNCTION_P -> DECL_LOCAL_DECL_P
Our handling of block-scope extern decls is insufficient for modern
C++, in particular modules, (but also constexprs).  We mark such local
function decls, and this patch extends that to marking local var decls
too, so mainly a macro rename.  Also, we set this flag earlier, rather
than learning about it when pushing the decl.  This is a step towards
handling these properly.

	gcc/cp/
	* cp-tree.h (DECL_LOCAL_FUNCTION_P): Rename to ...
	(DECL_LOCAL_DECL_P): ... here.  Accept both fns and vars.
	* decl.c (start_decl): Set DECL_LOCAL_DECL_P for local externs.
	(omp_declare_variant_finalize_one): Use DECL_LOCAL_DECL_P.
	(local_variable_p): Simplify.
	* name-lookup.c (set_decl_context_in_fn): Assert DECL_LOCAL_DECL_P
	is as expected.  Simplify.
	(do_pushdecl): Don't set decl_context_in_fn for friends.
	(is_local_extern): Simplify.
	* call.c (equal_functions): Use DECL_LOCAL_DECL_P.
	* parser.c (cp_parser_postfix_expression): Likewise.
	(cp_parser_omp_declare_reduction): Likewise.
	* pt.c (check_default_tmpl_args): Likewise.
	(tsubst_expr): Assert nested reduction function is local.
	(type_dependent_expression_p): Use DECL_LOCAL_DECL_P.
	* semantics.c (finish_call_expr): Likewise.
	libcc1/
	* libcp1plugin.cc (plugin_build_call_expr): Use DECL_LOCAL_DECL_P.
2020-09-10 05:45:46 -07:00
Tom de Vries
d41f8429e9 [testsuite] Add missing require-effective-target allloca
Add a missing require-effect-target alloca directive.

Tested on nvptx.

gcc/testsuite/ChangeLog:

	* gcc.dg/analyzer/vla-1.c: Add require-effective-target alloca.
2020-09-10 13:57:48 +02:00
Jonathan Yong
ae6cf62861 Cygwin/MinGW: Do not version lto plugins
GCC on Linux already uses liblto_plugin.so directly without
the libtool version suffix, adjust windows GCC to do the same.

gcc/ChangeLog:

	* config.host: Adjust plugin name for Windows.

lto-plugin/ChangeLog:

	* Makefile.am: drop versioning from libtool completely.
	* Makefile.in: regenerate.
2020-09-10 11:54:28 +00:00
Tom de Vries
f96b6328fa [tree-optimization] Don't clear ctrl-altering flag for IFN_UNIQUE
There's an invariant for IFN_UNIQUE, listed here in
gimple_call_initialize_ctrl_altering:
...
      /* IFN_UNIQUE should be the last insn, to make checking for it
         as cheap as possible.  */
      || (gimple_call_internal_p (stmt)
          && gimple_call_internal_unique_p (stmt)))
    gimple_call_set_ctrl_altering (stmt, true);
...

Recent commit fab7764484 "tree-optimization/96931 - clear ctrl-altering flag
more aggressively" breaks this invariant, causing an ICE triggered during
libgomp testing for x86_64 with nvptx accelerator:
...
during RTL pass: mach
asyncwait-1.f90: In function ‘MAIN__._omp_fn.0’:
asyncwait-1.f90:19: internal compiler error: in nvptx_find_par, at \
  config/nvptx/nvptx.c:3293
...

Fix this by listing IFN_UNIQUE as exception in
cleanup_call_ctrl_altering_flag.

Build for x86_64 with nvptx accelerator, tested libgomp.

gcc/ChangeLog:

	PR tree-optimization/97000
	* tree-cfgcleanup.c (cleanup_call_ctrl_altering_flag): Don't clear
	flag for IFN_UNIQUE.
2020-09-10 12:59:29 +02:00